| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The prototypes for the following functions lie in ‘gnutls/gnutls.h’.
alert: is an alert number.
Description: This function will return a string that describes the given alert
number, or NULL. See gnutls_alert_get().
Returns: string corresponding to gnutls_alert_description_t value.
alert: is an alert number.
Description: This function will return a string of the name of the alert.
Returns: string corresponding to gnutls_alert_description_t value.
Since: 3.0.0
session: is a gnutls_session_t structure.
Description: This function will return the last alert number received. This
function should be called when GNUTLS_E_WARNING_ALERT_RECEIVED or
GNUTLS_E_FATAL_ALERT_RECEIVED errors are returned by a gnutls
function. The peer may send alerts if he encounters an error.
If no alert has been received the returned value is undefined.
Returns: the last alert received, a
gnutls_alert_description_t value.
session: is a gnutls_session_t structure.
err: is an integer
Description: Sends an alert to the peer depending on the error code returned by
a gnutls function. This function will call gnutls_error_to_alert()
to determine the appropriate alert to send.
This function may also return GNUTLS_E_AGAIN, or
GNUTLS_E_INTERRUPTED.
If the return value is GNUTLS_E_INVALID_REQUEST, then no alert has
been sent to the peer.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise
an error code is returned.
session: is a gnutls_session_t structure.
level: is the level of the alert
desc: is the alert description
Description: This function will send an alert to the peer in order to inform him of something important (eg. his Certificate could not be verified). If the alert level is Fatal then the peer is expected to close the connection, otherwise he may ignore the alert and continue.
The error code of the underlying record send function will be
returned, so you may also receive GNUTLS_E_INTERRUPTED or
GNUTLS_E_AGAIN as well.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise
an error code is returned.
sc: is a pointer to a gnutls_anon_client_credentials_t structure.
Description: This structure is complex enough to manipulate directly thus this helper function is provided in order to allocate it.
Returns: GNUTLS_E_SUCCESS on success, or an error code.
sc: is a pointer to a gnutls_anon_server_credentials_t structure.
Description: This structure is complex enough to manipulate directly thus this helper function is provided in order to allocate it.
Returns: GNUTLS_E_SUCCESS on success, or an error code.
sc: is a gnutls_anon_client_credentials_t structure.
Description: This structure is complex enough to manipulate directly thus this helper function is provided in order to free (deallocate) it.
sc: is a gnutls_anon_server_credentials_t structure.
Description: This structure is complex enough to manipulate directly thus this helper function is provided in order to free (deallocate) it.
res: is a gnutls_anon_server_credentials_t structure
func: is the function to be called
Description: This function will set a callback in order for the server to get
the Diffie-Hellman or RSA parameters for anonymous authentication.
The callback should return GNUTLS_E_SUCCESS (0) on success.
res: is a gnutls_anon_server_credentials_t structure
dh_params: is a structure that holds Diffie-Hellman parameters.
Description: This function will set the Diffie-Hellman parameters for an anonymous server to use. These parameters will be used in Anonymous Diffie-Hellman cipher suites.
res: is a gnutls_certificate_credentials_t structure
func: is the function to be called
Description: This function will set a callback in order for the server to get
the Diffie-Hellman parameters for anonymous authentication. The
callback should return GNUTLS_E_SUCCESS (0) on success.
session: is a gnutls_session_t structure.
Description: Returns the type of credentials that were used for client authentication. The returned information is to be used to distinguish the function used to access authentication data.
Returns: The type of credentials for the client authentication
schema, a gnutls_credentials_type_t type.
session: is a gnutls_session_t structure.
Description: Returns type of credentials for the current authentication schema. The returned information is to be used to distinguish the function used to access authentication data.
Eg. for CERTIFICATE ciphersuites (key exchange algorithms:
GNUTLS_KX_RSA, GNUTLS_KX_DHE_RSA), the same function are to be
used to access the authentication data.
Returns: The type of credentials for the current authentication
schema, a gnutls_credentials_type_t type.
session: is a gnutls_session_t structure.
Description: Returns the type of credentials that were used for server authentication. The returned information is to be used to distinguish the function used to access authentication data.
Returns: The type of credentials for the server authentication
schema, a gnutls_credentials_type_t type.
session: is a gnutls_session_t structure.
how: is an integer
Description: Terminates the current TLS/SSL connection. The connection should
have been initiated using gnutls_handshake(). how should be one
of GNUTLS_SHUT_RDWR, GNUTLS_SHUT_WR.
In case of GNUTLS_SHUT_RDWR the TLS session gets
terminated and further receives and sends will be disallowed. If
the return value is zero you may continue using the underlying
transport layer. GNUTLS_SHUT_RDWR sends an alert containing a close
request and waits for the peer to reply with the same message.
In case of GNUTLS_SHUT_WR the TLS session gets terminated
and further sends will be disallowed. In order to reuse the
connection you should wait for an EOF from the peer.
GNUTLS_SHUT_WR sends an alert containing a close request.
Note that not all implementations will properly terminate a TLS connection. Some of them, usually for performance reasons, will terminate only the underlying transport layer, and thus not distinguishing between a malicious party prematurely terminating the connection and normal termination.
This function may also return GNUTLS_E_AGAIN or
GNUTLS_E_INTERRUPTED; cf. gnutls_record_get_direction().
Returns: GNUTLS_E_SUCCESS on success, or an error code, see
function documentation for entire semantics.
session: is a gnutls session
Description: This function will return the peer’s certificate activation time. This is the creation time for openpgp keys.
Returns: (time_t)-1 on error.
Deprecated: gnutls_certificate_verify_peers2() now verifies activation times.
res: is a pointer to a gnutls_certificate_credentials_t structure.
Description: This structure is complex enough to manipulate directly thus this helper function is provided in order to allocate it.
Returns: GNUTLS_E_SUCCESS on success, or an error code.
session: is a gnutls session
Description: Get whether client certificate is requested or not.
Returns: 0 if the peer (server) did not request client authentication or 1 otherwise, or a negative error code in case of error.
cred: is a gnutls_certificate_credentials_t structure.
func: is the callback function
Description: This function sets a callback to be called in order to retrieve the
certificate to be used in the handshake.
You are advised to use gnutls_certificate_set_retrieve_function2() because it
is much more efficient in the processing it requires from gnutls.
The callback’s function prototype is:
int (*callback)(gnutls_session_t, const gnutls_datum_t* req_ca_dn, int nreqs,
const gnutls_pk_algorithm_t* pk_algos, int pk_algos_length, gnutls_retr_st* st);
req_ca_cert is only used in X.509 certificates.
Contains a list with the CA names that the server considers trusted.
Normally we should send a certificate that is signed
by one of these CAs. These names are DER encoded. To get a more
meaningful value use the function gnutls_x509_rdn_get().
pk_algos contains a list with server’s acceptable signature algorithms.
The certificate returned should support the server’s given algorithms.
st should contain the certificates and private keys.
If the callback function is provided then gnutls will call it, in the handshake, after the certificate request message has been received.
The callback function should set the certificate list to be sent, and return 0 on success. If no certificate was selected then the number of certificates should be set to zero. The value (-1) indicates error and the handshake will be terminated.
session: is a gnutls session
Description: This function will return the peer’s certificate expiration time.
Returns: (time_t)-1 on error.
Deprecated: gnutls_certificate_verify_peers2() now verifies expiration times.
sc: is a gnutls_certificate_credentials_t structure.
Description: This function will delete all the CA name in the given credentials. Clients may call this to save some memory since in client side the CA names are not used. Servers might want to use this function if a large list of trusted CAs is present and sending the names of it would just consume bandwidth without providing information to client.
CA names are used by servers to advertize the CAs they support to clients.
sc: is a gnutls_certificate_credentials_t structure.
Description: This function will delete all the CAs associated with the given
credentials. Servers that do not use
gnutls_certificate_verify_peers2() may call this to save some
memory.
sc: is a gnutls_certificate_credentials_t structure.
Description: This structure is complex enough to manipulate directly thus this helper function is provided in order to free (deallocate) it.
This function does not free any temporary parameters associated with this structure (ie RSA and DH parameters are not freed by this function).
sc: is a gnutls_certificate_credentials_t structure.
Description: This function will delete all the CRLs associated with the given credentials.
sc: is a gnutls_certificate_credentials_t structure.
Description: This function will delete all the keys and the certificates associated with the given credentials. This function must not be called when a TLS negotiation that uses the credentials is in progress.
sc: is a gnutls_certificate_credentials_t structure.
cert: is the certificate to find issuer for
issuer: Will hold the issuer if any. Should be treated as constant.
flags: Use zero.
Description: This function will return the issuer of a given certificate.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 3.0.0
session: is a gnutls session
Description: Gets the certificate as sent to the peer in the last handshake. The certificate is in raw (DER) format. No certificate list is being returned. Only the first certificate.
Returns: a pointer to a gnutls_datum_t containing our
certificates, or NULL in case of an error or if no certificate
was used.
session: is a gnutls session
list_size: is the length of the certificate list
Description: Get the peer’s raw certificate (chain) as sent by the peer. These certificates are in raw format (DER encoded for X.509). In case of a X.509 then a certificate list may be present. The first certificate in the list is the peer’s certificate, following the issuer’s certificate, then the issuer’s issuer etc.
In case of OpenPGP keys a single key will be returned in raw format.
Returns: a pointer to a gnutls_datum_t containing our
certificates, or NULL in case of an error or if no certificate
was used.
session: is a pointer to a gnutls_session_t structure.
status: is 0 or 1
Description: If status is non zero, this function will order gnutls not to send the rdnSequence in the certificate request message. That is the server will not advertize it’s trusted CAs to the peer. If status is zero then the default behaviour will take effect, which is to advertize the server’s trusted CAs.
This function has no effect in clients, and in authentication methods other than certificate with X.509 certificates.
session: is a gnutls_session_t structure.
req: is one of GNUTLS_CERT_REQUEST, GNUTLS_CERT_REQUIRE
Description: This function specifies if we (in case of a server) are going to
send a certificate request message to the client. If req is
GNUTLS_CERT_REQUIRE then the server will return an error if the
peer does not provide a certificate. If you do not call this
function then the client will not be asked to send a certificate.
cred: is a gnutls_certificate_credentials_t structure.
func: is the callback function
Description: This function sets a callback to be called in order to retrieve the
certificate to be used in the handshake.
You are advised to use gnutls_certificate_set_retrieve_function2() because it
is much more efficient in the processing it requires from gnutls.
The callback’s function prototype is:
int (*callback)(gnutls_session_t, gnutls_retr_st* st);
st should contain the certificates and private keys.
If the callback function is provided then gnutls will call it, in the handshake, after the certificate request message has been received.
The callback function should set the certificate list to be sent, and return 0 on success. The value (-1) indicates error and the handshake will be terminated.
res: is a gnutls_certificate_credentials_t structure
dh_params: is a structure that holds Diffie-Hellman parameters.
Description: This function will set the Diffie-Hellman parameters for a certificate server to use. These parameters will be used in Ephemeral Diffie-Hellman cipher suites. Note that only a pointer to the parameters are stored in the certificate handle, so if you deallocate the parameters before the certificate is deallocated, you must change the parameters stored in the certificate first.
res: is a gnutls_certificate_credentials_t structure.
names: is an array of DNS name of the certificate (NULL if none)
names_size: holds the size of the names list
pcert_list: contains a certificate list (path) for the specified private key
pcert_list_size: holds the size of the certificate list
key: is a gnutls_x509_privkey_t key
Description: This function sets a certificate/private key pair in the
gnutls_certificate_credentials_t structure. This function may be
called more than once, in case multiple keys/certificates exist for
the server. For clients that wants to send more than its own end
entity certificate (e.g., also an intermediate CA cert) then put
the certificate chain in pcert_list. The pcert_list and key will
become part of the credentials structure and must not
be deallocated. They will be automatically deallocated when res is deinitialized.
Returns: GNUTLS_E_SUCCESS (0) on success, or a negative error code.
Since: 3.0.0
res: is a gnutls_certificate_credentials_t structure
func: is the function to be called
Description: This function will set a callback in order for the server to get
the Diffie-Hellman or RSA parameters for certificate
authentication. The callback should return GNUTLS_E_SUCCESS (0) on success.
cred: is a gnutls_certificate_credentials_t structure.
func: is the callback function
Description: This function sets a callback to be called in order to retrieve the certificate to be used in the handshake.
The callback’s function prototype is:
int (*callback)(gnutls_session_t, const gnutls_datum_t* req_ca_dn, int nreqs,
const gnutls_pk_algorithm_t* pk_algos, int pk_algos_length, gnutls_pcert_st* st);
req_ca_cert is only used in X.509 certificates.
Contains a list with the CA names that the server considers trusted.
Normally we should send a certificate that is signed
by one of these CAs. These names are DER encoded. To get a more
meaningful value use the function gnutls_x509_rdn_get().
pk_algos contains a list with server’s acceptable signature algorithms.
The certificate returned should support the server’s given algorithms.
st should contain the certificates and private keys.
If the callback function is provided then gnutls will call it, in the handshake, after the certificate request message has been received.
In server side pk_algos and req_ca_dn are NULL.
The callback function should set the certificate list to be sent, and return 0 on success. If no certificate was selected then the number of certificates should be set to zero. The value (-1) indicates error and the handshake will be terminated.
Since: 3.0.0
cred: is a gnutls_certificate_credentials_t structure.
func: is the callback function
Description: This function sets a callback to be called in order to retrieve the
certificate to be used in the handshake. You are advised
to use gnutls_certificate_set_retrieve_function2() because it
is much more efficient in the processing it requires from gnutls.
The callback’s function prototype is:
int (*callback)(gnutls_session_t, const gnutls_datum_t* req_ca_dn, int nreqs,
const gnutls_pk_algorithm_t* pk_algos, int pk_algos_length, gnutls_retr2_st* st);
req_ca_cert is only used in X.509 certificates.
Contains a list with the CA names that the server considers trusted.
Normally we should send a certificate that is signed
by one of these CAs. These names are DER encoded. To get a more
meaningful value use the function gnutls_x509_rdn_get().
pk_algos contains a list with server’s acceptable signature algorithms.
The certificate returned should support the server’s given algorithms.
st should contain the certificates and private keys.
If the callback function is provided then gnutls will call it, in the handshake, after the certificate request message has been received.
In server side pk_algos and req_ca_dn are NULL.
The callback function should set the certificate list to be sent, and return 0 on success. If no certificate was selected then the number of certificates should be set to zero. The value (-1) indicates error and the handshake will be terminated.
Since: 3.0.0
res: is a gnutls_certificate_credentials_t structure
rsa_params: is a structure that holds temporary RSA parameters.
Description: This function will set the temporary RSA parameters for a certificate server to use. These parameters will be used in RSA-EXPORT cipher suites.
res: is a gnutls_certificate_credentials_t structure
flags: are the flags
Description: This function will set the flags to be used at verification of the
certificates. Flags must be OR of the
gnutls_certificate_verify_flags enumerations.
cred: is a gnutls_certificate_credentials_t structure.
func: is the callback function
Description: This function sets a callback to be called when peer’s certificate has been received in order to verify it on receipt rather than doing after the handshake is completed.
The callback’s function prototype is: int (*callback)(gnutls_session_t);
If the callback function is provided then gnutls will call it, in the
handshake, just after the certificate message has been received.
To verify or obtain the certificate the gnutls_certificate_verify_peers2(),
gnutls_certificate_type_get(), gnutls_certificate_get_peers() functions
can be used.
The callback function should return 0 for the handshake to continue or non-zero to terminate.
Since: 2.10.0
res: is a gnutls_certificate_credentials structure
max_bits: is the number of bits of an acceptable certificate (default 8200)
max_depth: is maximum depth of the verification of a certificate chain (default 5)
Description: This function will set some upper limits for the default
verification function, gnutls_certificate_verify_peers2(), to avoid
denial of service attacks. You can set them to zero to disable
limits.
res: is a gnutls_certificate_credentials_t structure.
crlfile: is a file containing the list of verified CRLs (DER or PEM list)
type: is PEM or DER
Description: This function adds the trusted CRLs in order to verify client or server
certificates. In case of a client this is not required
to be called if the certificates are not verified using
gnutls_certificate_verify_peers2().
This function may be called multiple times.
Returns: number of CRLs processed or a negative error code on error.
res: is a gnutls_certificate_credentials_t structure.
CRL: is a list of trusted CRLs. They should have been verified before.
type: is DER or PEM
Description: This function adds the trusted CRLs in order to verify client or
server certificates. In case of a client this is not required to
be called if the certificates are not verified using
gnutls_certificate_verify_peers2(). This function may be called
multiple times.
Returns: number of CRLs processed, or a negative error code on error.
res: is a gnutls_certificate_credentials_t structure.
crl_list: is a list of trusted CRLs. They should have been verified before.
crl_list_size: holds the size of the crl_list
Description: This function adds the trusted CRLs in order to verify client or
server certificates. In case of a client this is not required to
be called if the certificates are not verified using
gnutls_certificate_verify_peers2(). This function may be called
multiple times.
Returns: GNUTLS_E_SUCCESS (0) on success, or a negative error code.
Since: 2.4.0
res: is a gnutls_certificate_credentials_t structure.
certfile: is a file that containing the certificate list (path) for the specified private key, in PKCS7 format, or a list of certificates
keyfile: is a file that contains the private key
type: is PEM or DER
Description: This function sets a certificate/private key pair in the
gnutls_certificate_credentials_t structure. This function may be
called more than once, in case multiple keys/certificates exist for
the server. For clients that need to send more than its own end
entity certificate, e.g., also an intermediate CA cert, then the certfile must contain the ordered certificate chain.
This function can also accept PKCS 11 URLs at keyfile and certfile. In that case it
will import the private key and certificate indicated by the URLs.
Returns: GNUTLS_E_SUCCESS (0) on success, or a negative error code.
res: is a gnutls_certificate_credentials_t structure.
cert: contains a certificate list (path) for the specified private key
key: is the private key, or NULL
type: is PEM or DER
Description: This function sets a certificate/private key pair in the gnutls_certificate_credentials_t structure. This function may be called more than once, in case multiple keys/certificates exist for the server.
Note that the keyUsage (2.5.29.15) PKIX extension in X.509 certificates is supported. This means that certificates intended for signing cannot be used for ciphersuites that require encryption.
If the certificate and the private key are given in PEM encoding then the strings that hold their values must be null terminated.
The key may be NULL if you are using a sign callback, see
gnutls_sign_callback_set().
Returns: GNUTLS_E_SUCCESS (0) on success, or a negative error code.
res: is a gnutls_certificate_credentials_t structure.
cert_list: contains a certificate list (path) for the specified private key
cert_list_size: holds the size of the certificate list
key: is a gnutls_x509_privkey_t key
Description: This function sets a certificate/private key pair in the
gnutls_certificate_credentials_t structure. This function may be
called more than once, in case multiple keys/certificates exist for
the server. For clients that wants to send more than its own end
entity certificate (e.g., also an intermediate CA cert) then put
the certificate chain in cert_list.
Returns: GNUTLS_E_SUCCESS (0) on success, or a negative error code.
Since: 2.4.0
res: is a gnutls_certificate_credentials_t structure.
pkcs12file: filename of file containing PKCS12 blob.
type: is PEM or DER of the pkcs12file.
password: optional password used to decrypt PKCS12 file, bags and keys.
Description: This function sets a certificate/private key pair and/or a CRL in the gnutls_certificate_credentials_t structure. This function may be called more than once (in case multiple keys/certificates exist for the server).
MAC: ed PKCS12 files are supported. Encrypted PKCS12 bags are
supported. Encrypted PKCS8 private keys are supported. However,
only password based security, and the same password for all
operations, are supported.
PKCS12 file may contain many keys and/or certificates, and there
is no way to identify which key/certificate pair you want. You
should make sure the PKCS12 file only contain one key/certificate
pair and/or one CRL.
It is believed that the limitations of this function is acceptable for most usage, and that any more flexibility would introduce complexity that would make it harder to use this functionality at all.
Returns: GNUTLS_E_SUCCESS (0) on success, or a negative error code.
res: is a gnutls_certificate_credentials_t structure.
p12blob: the PKCS12 blob.
type: is PEM or DER of the pkcs12file.
password: optional password used to decrypt PKCS12 file, bags and keys.
Description: This function sets a certificate/private key pair and/or a CRL in the gnutls_certificate_credentials_t structure. This function may be called more than once (in case multiple keys/certificates exist for the server).
MAC: ed PKCS12 files are supported. Encrypted PKCS12 bags are
supported. Encrypted PKCS8 private keys are supported. However,
only password based security, and the same password for all
operations, are supported.
PKCS12 file may contain many keys and/or certificates, and there
is no way to identify which key/certificate pair you want. You
should make sure the PKCS12 file only contain one key/certificate
pair and/or one CRL.
It is believed that the limitations of this function is acceptable for most usage, and that any more flexibility would introduce complexity that would make it harder to use this functionality at all.
Returns: GNUTLS_E_SUCCESS (0) on success, or a negative error code.
Since: 2.8.0
cred: is a gnutls_certificate_credentials_t structure.
cafile: is a file containing the list of trusted CAs (DER or PEM list)
type: is PEM or DER
Description: This function adds the trusted CAs in order to verify client or
server certificates. In case of a client this is not required to
be called if the certificates are not verified using
gnutls_certificate_verify_peers2(). This function may be called
multiple times.
In case of a server the names of the CAs set here will be sent to
the client if a certificate request is sent. This can be disabled
using gnutls_certificate_send_x509_rdn_sequence().
This function can also accept PKCS 11 URLs. In that case it
will import all certificates that are marked as trusted.
Returns: number of certificates processed, or a negative error code on error.
res: is a gnutls_certificate_credentials_t structure.
ca: is a list of trusted CAs or a DER certificate
type: is DER or PEM
Description: This function adds the trusted CAs in order to verify client or
server certificates. In case of a client this is not required to be
called if the certificates are not verified using
gnutls_certificate_verify_peers2(). This function may be called
multiple times.
In case of a server the CAs set here will be sent to the client if
a certificate request is sent. This can be disabled using
gnutls_certificate_send_x509_rdn_sequence().
Returns: the number of certificates processed or a negative error code on error.
res: is a gnutls_certificate_credentials_t structure.
ca_list: is a list of trusted CAs
ca_list_size: holds the size of the CA list
Description: This function adds the trusted CAs in order to verify client
or server certificates. In case of a client this is not required
to be called if the certificates are not verified using
gnutls_certificate_verify_peers2().
This function may be called multiple times.
In case of a server the CAs set here will be sent to the client if
a certificate request is sent. This can be disabled using
gnutls_certificate_send_x509_rdn_sequence().
Returns: the number of certificates processed or a negative error code on error.
Since: 2.4.0
name: is a certificate type name
Description: The names are compared in a case insensitive way.
Returns: a gnutls_certificate_type_t for the specified in a
string certificate type, or GNUTLS_CRT_UNKNOWN on error.
type: is a certificate type
Description: Convert a gnutls_certificate_type_t type to a string.
Returns: a string that contains the name of the specified
certificate type, or NULL in case of unknown types.
session: is a gnutls_session_t structure.
Description: The certificate type is by default X.509, unless it is negotiated as a TLS extension.
Returns: the currently used gnutls_certificate_type_t certificate
type.
Description:
Get a list of certificate types. Note that to be able to use
OpenPGP certificates, you must link to libgnutls-extra and call
gnutls_global_init_extra().
Returns: a (0)-terminated list of gnutls_certificate_type_t
integers indicating the available certificate types.
session: is a gnutls_session_t structure.
list: is a 0 terminated list of gnutls_certificate_type_t elements.
Description: Sets the priority on the certificate types supported by gnutls. Priority is higher for elements specified before others. After specifying the types you want, you must append a 0. Note that the certificate type priority is set on the client. The server does not use the cert type priority except for disabling types that were not specified.
Returns: GNUTLS_E_SUCCESS on success, or an error code.
session: is a gnutls session
status: is the output of the verification
Description: This function will try to verify the peer’s certificate and return
its status (trusted, invalid etc.). The value of status should
be one or more of the gnutls_certificate_status_t enumerated
elements bitwise or’d. To avoid denial of service attacks some
default upper limits regarding the certificate key size and chain
size are set. To override them use
gnutls_certificate_set_verify_limits().
Note that you must also check the peer’s name in order to check if the verified certificate belongs to the actual peer.
This function uses gnutls_x509_crt_list_verify() with the CAs in
the credentials as trusted CAs.
Returns: a negative error code on error and GNUTLS_E_SUCCESS (0) on success.
req_version: version string to compare with, or NULL.
Description: Check GnuTLS Library version.
See GNUTLS_VERSION for a suitable req_version string.
Returns: Check that the version of the library is at
minimum the one given as a string in req_version and return the
actual version string of the library; return NULL if the
condition is not met. If NULL is passed to this function no
check is done and only the version string is returned.
handle: is a gnutls_cipher_hd_t structure.
text: the data to be authenticated
text_size: The length of the data
Description: This function operates on authenticated encryption with associated data (AEAD) ciphers and authenticate the input data. This function can only be called once and before any encryption operations.
Returns: Zero or a negative error code on error.
Since: 3.0.0
handle: is a gnutls_cipher_hd_t structure.
ciphertext: the data to encrypt
ciphertextlen: The length of data to encrypt
text: the decrypted data
textlen: The available length for decrypted data
Description: This function will decrypt the given data using the algorithm specified by the context.
Returns: Zero or a negative error code on error.
Since: 2.12.0
handle: is a gnutls_cipher_hd_t structure.
ciphertext: the data to encrypt
ciphertextlen: The length of data to encrypt
Description: This function will decrypt the given data using the algorithm specified by the context.
Returns: Zero or a negative error code on error.
Since: 2.10.0
handle: is a gnutls_cipher_hd_t structure.
Description: This function will deinitialize all resources occupied by the given encryption context.
Since: 2.10.0
handle: is a gnutls_cipher_hd_t structure.
text: the data to encrypt
textlen: The length of data to encrypt
ciphertext: the encrypted data
ciphertextlen: The available length for encrypted data
Description: This function will encrypt the given data using the algorithm specified by the context.
Returns: Zero or a negative error code on error.
Since: 2.12.0
handle: is a gnutls_cipher_hd_t structure.
text: the data to encrypt
textlen: The length of data to encrypt
Description: This function will encrypt the given data using the algorithm specified by the context.
Returns: Zero or a negative error code on error.
Since: 2.10.0
algorithm: is an encryption algorithm
Description: Get block size for encryption algorithm.
Returns: block size for encryption algorithm.
Since: 2.10.0
name: is a MAC algorithm name
Description: The names are compared in a case insensitive way.
Returns: return a gnutls_cipher_algorithm_t value corresponding to
the specified cipher, or GNUTLS_CIPHER_UNKNOWN on error.
algorithm: is an encryption algorithm
Description: Get key size for cipher.
Returns: length (in bytes) of the given cipher’s key size, or 0 if the given cipher is invalid.
algorithm: is an encryption algorithm
Description: Convert a gnutls_cipher_algorithm_t type to a string.
Returns: a pointer to a string that contains the name of the
specified cipher, or NULL.
session: is a gnutls_session_t structure.
Description: Get currently used cipher.
Returns: the currently used cipher, a gnutls_cipher_algorithm_t
type.
handle: is a gnutls_cipher_hd_t structure.
cipher: the encryption algorithm to use
key: The key to be used for encryption
iv: The IV to use (if not applicable set NULL)
Description: This function will initialize an context that can be used for encryption/decryption of data. This will effectively use the current crypto backend in use by gnutls or the cryptographic accelerator in use.
Returns: Zero or a negative error code on error.
Since: 2.10.0
Description:
Get a list of supported cipher algorithms. Note that not
necessarily all ciphers are supported as TLS cipher suites. For
example, DES is not supported as a cipher suite, but is supported
for other purposes (e.g., PKCS8 or similar).
This function is not thread safe.
Returns: a (0)-terminated list of gnutls_cipher_algorithm_t
integers indicating the available ciphers.
handle: is a gnutls_cipher_hd_t structure.
iv: the IV to set
ivlen: The length of the IV
Description: This function will set the IV to be used for the next encryption block.
Since: 3.0.0
session: is a gnutls_session_t structure.
list: is a 0 terminated list of gnutls_cipher_algorithm_t elements.
Description: Sets the priority on the ciphers supported by gnutls. Priority is higher for elements specified before others. After specifying the ciphers you want, you must append a 0. Note that the priority is set on the client. The server does not use the algorithm’s priority except for disabling algorithms that were not specified.
Returns: GNUTLS_E_SUCCESS (0) on success, or a negative error code.
kx_algorithm: is a Key exchange algorithm
cipher_algorithm: is a cipher algorithm
mac_algorithm: is a MAC algorithm
Description: Note that the full cipher suite name must be prepended by TLS or SSL depending of the protocol in use.
Returns: a string that contains the name of a TLS cipher suite,
specified by the given algorithms, or NULL.
idx: index of cipher suite to get information about, starts on 0.
cs_id: output buffer with room for 2 bytes, indicating cipher suite value
kx: output variable indicating key exchange algorithm, or NULL.
cipher: output variable indicating cipher, or NULL.
mac: output variable indicating MAC algorithm, or NULL.
min_version: output variable indicating TLS protocol version, or NULL.
Description: Get information about supported cipher suites. Use the function iteratively to get information about all supported cipher suites. Call with idx=0 to get information about first cipher suite, then idx=1 and so on until the function returns NULL.
Returns: the name of idx cipher suite, and set the information
about the cipher suite in the output variables. If idx is out of
bounds, NULL is returned.
handle: is a gnutls_cipher_hd_t structure.
tag: will hold the tag
tag_size: The length of the tag to return
Description: This function operates on authenticated encryption with associated data (AEAD) ciphers and will return the output tag.
Returns: Zero or a negative error code on error.
Since: 3.0.0
name: is a compression method name
Description: The names are compared in a case insensitive way.
Returns: an id of the specified in a string compression method, or
GNUTLS_COMP_UNKNOWN on error.
algorithm: is a Compression algorithm
Description: Convert a gnutls_compression_method_t value to a string.
Returns: a pointer to a string that contains the name of the
specified compression algorithm, or NULL.
session: is a gnutls_session_t structure.
Description: Get currently used compression algorithm.
Returns: the currently used compression method, a
gnutls_compression_method_t value.
Description: Get a list of compression methods.
Returns: a zero-terminated list of gnutls_compression_method_t
integers indicating the available compression methods.
session: is a gnutls_session_t structure.
list: is a 0 terminated list of gnutls_compression_method_t elements.
Description: Sets the priority on the compression algorithms supported by gnutls. Priority is higher for elements specified before others. After specifying the algorithms you want, you must append a 0. Note that the priority is set on the client. The server does not use the algorithm’s priority except for disabling algorithms that were not specified.
TLS 1.0 does not define any compression algorithms except NULL. Other compression algorithms are to be considered as gnutls extensions.
Returns: GNUTLS_E_SUCCESS on success, or an error code.
session: is a gnutls_session_t structure.
Description: Clears all the credentials previously set in this session.
session: is a gnutls_session_t structure.
type: is the type of the credentials
cred: is a pointer to a structure.
Description: Sets the needed credentials for the specified type. Eg username,
password - or public and private keys etc. The cred parameter is
a structure that depends on the specified type and on the current
session (client or server).
In order to minimize memory usage, and share credentials between
several threads gnutls keeps a pointer to cred, and not the whole
cred structure. Thus you will have to keep the structure allocated
until you call gnutls_deinit().
For GNUTLS_CRD_ANON, cred should be
gnutls_anon_client_credentials_t in case of a client. In case of
a server it should be gnutls_anon_server_credentials_t.
For GNUTLS_CRD_SRP, cred should be gnutls_srp_client_credentials_t
in case of a client, and gnutls_srp_server_credentials_t, in case
of a server.
For GNUTLS_CRD_CERTIFICATE, cred should be
gnutls_certificate_credentials_t.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned,
otherwise a negative error code is returned.
session: is a gnutls_session_t structure.
session_entry: is the session data (not key)
Description: Check if database entry has expired. This function is to be used when you want to clear unnesessary session which occupy space in your backend.
Returns: Returns GNUTLS_E_EXPIRED, if the database entry has
expired or 0 otherwise.
session: is a gnutls_session_t structure.
Description: Get db function pointer.
Returns: the pointer that will be sent to db store, retrieve and delete functions, as the first argument.
session: is a gnutls_session_t structure.
Description: This function will remove the current session data from the
session database. This will prevent future handshakes reusing
these session data. This function should be called if a session
was terminated abnormally, and before gnutls_deinit() is called.
Normally gnutls_deinit() will remove abnormally terminated
sessions.
session: is a gnutls_session_t structure.
seconds: is the number of seconds.
Description: Set the expiration time for resumed sessions. The default is 3600 (one hour) at the time writing this.
session: is a gnutls_session_t structure.
ptr: is the pointer
Description: Sets the pointer that will be provided to db store, retrieve and delete functions, as the first argument.
session: is a gnutls_session_t structure.
rem_func: is the function.
Description: Sets the function that will be used to remove data from the resumed sessions database. This function must return 0 on success.
The first argument to rem_func will be null unless
gnutls_db_set_ptr() has been called.
session: is a gnutls_session_t structure.
retr_func: is the function.
Description: Sets the function that will be used to retrieve data from the resumed sessions database. This function must return a gnutls_datum_t containing the data on success, or a gnutls_datum_t containing null and 0 on failure.
The datum’s data must be allocated using the function
gnutls_malloc().
The first argument to retr_func will be null unless
gnutls_db_set_ptr() has been called.
session: is a gnutls_session_t structure.
store_func: is the function
Description: Sets the function that will be used to store data from the resumed sessions database. This function must remove 0 on success.
The first argument to store_func will be null unless
gnutls_db_set_ptr() has been called.
session: is a gnutls_session_t structure.
Description: This function clears all buffers associated with the session.
This function will also remove session data from the session
database if the session was terminated abnormally.
session: is a gnutls session
raw_gen: will hold the generator.
raw_prime: will hold the prime.
Description: This function will return the group parameters used in the last
Diffie-Hellman key exchange with the peer. These are the prime and
the generator used. This function should be used for both
anonymous and ephemeral Diffie-Hellman. The output parameters must
be freed with gnutls_free().
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise
an error code is returned.
session: is a gnutls session
Description: Get the Diffie-Hellman public key bit size. Can be used for both anonymous and ephemeral Diffie-Hellman.
Returns: The public key bit size used in the last Diffie-Hellman key exchange with the peer, or a negative error code in case of error.
session: is a gnutls session
Description: This function will return the bits of the prime used in the last Diffie-Hellman key exchange with the peer. Should be used for both anonymous and ephemeral Diffie-Hellman. Note that some ciphers, like RSA and DSA without DHE, does not use a Diffie-Hellman key exchange, and then this function will return 0.
Returns: The Diffie-Hellman bit strength is returned, or 0 if no Diffie-Hellman key exchange was done, or a negative error code on failure.
session: is a gnutls session
raw_key: will hold the public key.
Description: This function will return the peer’s public key used in the last
Diffie-Hellman key exchange. This function should be used for both
anonymous and ephemeral Diffie-Hellman. The output parameters must
be freed with gnutls_free().
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise
an error code is returned.
session: is a gnutls session
Description: This function will return the bits used in the last Diffie-Hellman key exchange with the peer. Should be used for both anonymous and ephemeral Diffie-Hellman.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise
an error code is returned.
dst: Is the destination structure, which should be initialized.
src: Is the source structure
Description: This function will copy the DH parameters structure from source to destination.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned,
otherwise a negative error code is returned.
dh_params: Is a structure that holds the prime numbers
Description: This function will deinitialize the DH parameters structure.
params: Holds the DH parameters
format: the format of output params. One of PEM or DER.
params_data: will contain a PKCS3 DHParams structure PEM or DER encoded
params_data_size: holds the size of params_data (and will be replaced by the actual size of parameters)
Description: This function will export the given dh parameters to a PKCS3 DHParams structure. This is the format generated by "openssl dhparam" tool. If the buffer provided is not long enough to hold the output, then GNUTLS_E_SHORT_MEMORY_BUFFER will be returned.
If the structure is PEM encoded, it will have a header of "BEGIN DH PARAMETERS".
Returns: On success, GNUTLS_E_SUCCESS (0) is returned,
otherwise a negative error code is returned.
params: Holds the DH parameters
prime: will hold the new prime
generator: will hold the new generator
bits: if non null will hold is the prime’s number of bits
Description: This function will export the pair of prime and generator for use
in the Diffie-Hellman key exchange. The new parameters will be
allocated using gnutls_malloc() and will be stored in the
appropriate datum.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned,
otherwise a negative error code is returned.
params: Is the structure that the DH parameters will be stored
bits: is the prime’s number of bits
Description: This function will generate a new pair of prime and generator for use in
the Diffie-Hellman key exchange. The new parameters will be allocated using
gnutls_malloc() and will be stored in the appropriate datum.
This function is normally slow.
Do not set the number of bits directly, use gnutls_sec_param_to_pk_bits() to
get bits for GNUTLS_PK_DSA.
Also note that the DH parameters are only useful to servers.
Since clients use the parameters sent by the server, it’s of
no use to call this in client side.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned,
otherwise a negative error code is returned.
params: A structure where the parameters will be copied to
pkcs3_params: should contain a PKCS3 DHParams structure PEM or DER encoded
format: the format of params. PEM or DER.
Description: This function will extract the DHParams found in a PKCS3 formatted structure. This is the format generated by "openssl dhparam" tool.
If the structure is PEM encoded, it should have a header of "BEGIN DH PARAMETERS".
Returns: On success, GNUTLS_E_SUCCESS (0) is returned,
otherwise a negative error code is returned.
dh_params: Is a structure that will hold the prime numbers
prime: holds the new prime
generator: holds the new generator
Description: This function will replace the pair of prime and generator for use in the Diffie-Hellman key exchange. The new parameters should be stored in the appropriate gnutls_datum.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned,
otherwise a negative error code is returned.
dh_params: Is a structure that will hold the prime numbers
Description: This function will initialize the DH parameters structure.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned,
otherwise a negative error code is returned.
session: is a gnutls_session_t structure.
bits: is the number of bits
Description: This function sets the number of bits, for use in an Diffie-Hellman key exchange. This is used both in DH ephemeral and DH anonymous cipher suites. This will set the minimum size of the prime that will be used for the handshake.
In the client side it sets the minimum accepted number of bits. If
a server sends a prime with less bits than that
GNUTLS_E_DH_PRIME_UNACCEPTABLE will be returned by the handshake.
This function has no effect in server side.
key: is a random key to be used at cookie generation
client_data: contains data identifying the client (i.e. address)
client_data_size: The size of client’s data
prestate: The previous cookie returned by gnutls_dtls_cookie_verify()
ptr: A transport pointer to be used by push_func
push_func: A function that will be used to reply
Description: This function can be used to prevent denial of service
attacks to a DTLS server by requiring the client to
reply using a cookie sent by this function. That way
it can be ensured that a client we allocated resources
for (i.e. gnutls_session_t) is the one that the
original incoming packet was originated from.
Returns: the number of bytes sent, or a negative error code.
Since: 3.0.0
key: is a random key to be used at cookie generation
client_data: contains data identifying the client (i.e. address)
client_data_size: The size of client’s data
_msg: An incoming message that initiates a connection.
msg_size: The size of the message.
prestate: The cookie of this client.
Description: This function will verify an incoming message for
a valid cookie. If a valid cookie is returned then
it should be associated with the session using
gnutls_dtls_prestate_set();
Returns: GNUTLS_E_SUCCESS (0) on success, or a negative error code.
Since: 3.0.0
session: is a gnutls_session_t structure.
Description: This function will return the actual maximum transfer unit for application data. I.e. DTLS headers are subtracted from the actual MTU.
Returns: the maximum allowed transfer unit.
Since: 3.0.0
session: is a gnutls_session_t structure.
Description: This function will return the MTU size as set with
gnutls_dtls_set_mtu(). This is not the actual MTU
of data you can transmit. Use gnutls_dtls_get_data_mtu()
for that reason.
Returns: the set maximum transfer unit.
Since: 3.0.0
session: a new session
prestate: contains the client’s prestate
Description: This function will associate the prestate acquired by the cookie authentication with the client, with the newly established session.
Since: 3.0.0
session: is a gnutls_session_t structure.
mtu: The maximum transfer unit of the interface
Description: This function will set the maximum transfer unit of the interface that DTLS packets are expected to leave from.
Since: 3.0.0
session: is a gnutls_session_t structure.
retrans_timeout: The time at which a retransmission will occur in milliseconds
total_timeout: The time at which the connection will be aborted, in milliseconds.
Description: This function will set the timeouts required for the DTLS handshake
protocol. The retransmission timeout is the time after which a
message from the peer is not received, the previous messages will
be retransmitted. The total timeout is the time after which the
handshake will be aborted with GNUTLS_E_TIMEDOUT.
The DTLS protocol recommends the values of 1 sec and 60 seconds respectively.
If the retransmission timeout is zero then the handshake will operate
in a non-blocking way, i.e., return GNUTLS_E_AGAIN.
Since: 3.0.0
curve: is an ECC curve
Description: Convert a gnutls_ecc_curve_t value to a string.
Returns: a string that contains the name of the specified
curve or NULL.
Since: 3.0.0
curve: is an ECC curve
Description: Returns the size in bytes of the curve.
Returns: a the size or (0).
Since: 3.0.0
session: is a gnutls_session_t structure.
Description: Returns the currently used elliptic curve. Only valid when using an elliptic curve ciphersuite.
Returns: the currently used curve, a gnutls_ecc_curve_t
type.
Since: 3.0.0
error: is a GnuTLS error code, a negative error code
Description: If a GnuTLS function returns a negative error code you may feed that value to this function to see if the error condition is fatal. Note that you may also want to check the error code manually, since some non-fatal errors to the protocol (such as a warning alert or a rehandshake request) may be fatal for your program.
This function is only useful if you are dealing with errors from the record layer or the handshake layer.
Returns: 1 if the error code is fatal, for positive error values,
0 is returned. For unknown error values, -1 is returned.
err: is a negative integer
level: the alert level will be stored there
Description: Get an alert depending on the error code returned by a gnutls
function. All alerts sent by this function should be considered
fatal. The only exception is when err is GNUTLS_E_REHANDSHAKE,
where a warning alert should be sent to the peer indicating that no
renegotiation will be performed.
If there is no mapping to a valid alert the alert to indicate internal error is returned.
Returns: the alert code to use for a particular error code.
algo: is a digest algorithm
data: is the data
result: is the place where the result will be copied (may be null).
result_size: should hold the size of the result. The actual size of the returned result will also be copied there.
Description: This function will calculate a fingerprint (actually a hash), of the given data. The result is not printable data. You should convert it to hex, or to something else printable.
This is the usual way to calculate a fingerprint of an X.509 DER encoded certificate. Note however that the fingerprint of an OpenPGP is not just a hash and cannot be calculated with this function.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise
an error code is returned.
ptr: pointer to memory
Description: This function will free data pointed by ptr.
The deallocation function used is the one set by
gnutls_global_set_mem_functions().
Description:
This function deinitializes the global data, that were initialized
using gnutls_global_init().
Note! This function is not thread safe. See the discussion for
gnutls_global_init() for more information.
Description:
This function initializes the global data to defaults. Every
gnutls application has a global data which holds common parameters
shared by gnutls session structures. You should call
gnutls_global_deinit() when gnutls usage is no longer needed
Note that this function will also initialize the underlying crypto backend, if it has not been initialized before.
This function increment a global counter, so that
gnutls_global_deinit() only releases resources when it has been
called as many times as gnutls_global_init(). This is useful when
GnuTLS is used by more than one library in an application. This
function can be called many times, but will only do something the
first time.
Note! This function is not thread safe. If two threads call this function simultaneously, they can cause a race between checking the global counter and incrementing it, causing both threads to execute the library initialization code. That would lead to a memory leak. To handle this, your application could invoke this function after aquiring a thread mutex. To ignore the potential memory leak is also an option.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned,
otherwise a negative error code is returned.
log_func: it is the audit log function
Description: This is the function where you set the logging function gnutls is
going to use. This is different from gnutls_global_set_log_function()
because it will report the session of the event if any. Note that
that session might be null if there is no corresponding TLS session.
gnutls_audit_log_func is of the form,
void (*gnutls_audit_log_func)( gnutls_session_t, int level, const char*);
Since: 3.0.0
log_func: it’s a log function
Description: This is the function where you set the logging function gnutls is
going to use. This function only accepts a character array.
Normally you may not use this function since it is only used for
debugging purposes.
gnutls_log_func is of the form,
void (*gnutls_log_func)( int level, const char*);
level: it’s an integer from 0 to 9.
Description: This is the function that allows you to set the log level. The level is an integer between 0 and 9. Higher values mean more verbosity. The default value is 0. Larger values should only be used with care, since they may reveal sensitive information.
Use a log level over 10 to enable all debugging options.
alloc_func: it’s the default memory allocation function. Like malloc().
secure_alloc_func: This is the memory allocation function that will be used for sensitive data.
is_secure_func: a function that returns 0 if the memory given is not secure. May be NULL.
realloc_func: A realloc function
free_func: The function that frees allocated data. Must accept a NULL pointer.
Description: This is the function were you set the memory allocation functions
gnutls is going to use. By default the libc’s allocation functions
(malloc(), free()), are used by gnutls, to allocate both sensitive
and not sensitive data. This function is provided to set the
memory allocation functions to something other than the defaults
This function must be called before gnutls_global_init() is called.
This function is not thread safe.
init: mutex initialization function
deinit: mutex deinitialization function
lock: mutex locking function
unlock: mutex unlocking function
Description: With this function you are allowed to override the default mutex locks used in some parts of gnutls and dependent libraries. This function should be used if you have complete control of your program and libraries. Do not call this function from a library. Instead only initialize gnutls and the default OS mutex locks will be used.
This function must be called before gnutls_global_init().
Since: 2.12.0
time_func: it’s the system time function, a gnutls_time_func() callback.
Description: This is the function where you can override the default system time function. The application provided function should behave the same as the standard function.
Since: 2.12.0
session: is a gnutls_session_t structure.
Description: This function is only useful to check where the last performed handshake failed. If the previous handshake succeed or was not performed at all then no meaningful value will be returned.
Check gnutls_handshake_description_t in gnutls.h for the
available handshake descriptions.
Returns: the last handshake message type received, a
gnutls_handshake_description_t.
session: is a gnutls_session_t structure.
Description: This function is only useful to check where the last performed handshake failed. If the previous handshake succeed or was not performed at all then no meaningful value will be returned.
Check gnutls_handshake_description_t in gnutls.h for the
available handshake descriptions.
Returns: the last handshake message type sent, a
gnutls_handshake_description_t.
session: is a gnutls_session_t structure.
max: is the maximum number.
Description: This function will set the maximum size of all handshake messages.
Handshakes over this size are rejected with
GNUTLS_E_HANDSHAKE_TOO_LARGE error code. The default value is
48kb which is typically large enough. Set this to 0 if you do not
want to set an upper limit.
The reason for restricting the handshake message sizes are to limit Denial of Service attacks.
session: is a gnutls_session_t structure.
func: is the function to be called
Description: This function will set a callback to be called after the client hello has been received (callback valid in server side only). This allows the server to adjust settings based on received extensions.
Those settings could be ciphersuites, requesting certificate, or anything else except for version negotiation (this is done before the hello message is parsed).
This callback must return 0 on success or a gnutls error code to terminate the handshake.
Warning: You should not use this function to terminate the handshake based on client input unless you know what you are doing. Before the handshake is finished there is no way to know if there is a man-in-the-middle attack being performed.
session: is a gnutls_session_t structure.
allow: is an integer (0 or 1)
Description: This function will enable or disable the use of private cipher
suites (the ones that start with 0xFF). By default or if allow
is 0 then these cipher suites will not be advertized nor used.
Currently GnuTLS does not include such cipher-suites or compression algorithms.
Enabling the private ciphersuites when talking to other than gnutls servers and clients may cause interoperability problems.
session: is a gnutls_session_t structure.
Description: This function does the handshake of the TLS/SSL protocol, and initializes the TLS connection.
This function will fail if any problem is encountered, and will return a negative error code. In case of a client, if the client has asked to resume a session, but the server couldn’t, then a full handshake will be performed.
The non-fatal errors such as GNUTLS_E_AGAIN and
GNUTLS_E_INTERRUPTED interrupt the handshake procedure, which
should be later be resumed. Call this function again, until it
returns 0; cf. gnutls_record_get_direction() and
gnutls_error_is_fatal().
If this function is called by a server after a rehandshake request
then GNUTLS_E_GOT_APPLICATION_DATA or
GNUTLS_E_WARNING_ALERT_RECEIVED may be returned. Note that these
are non fatal errors, only in the specific case of a rehandshake.
Their meaning is that the client rejected the rehandshake request or
in the case of GNUTLS_E_GOT_APPLICATION_DATA it might also mean that
some data were pending.
Returns: GNUTLS_E_SUCCESS on success, otherwise a negative error code.
handle: is a gnutls_hash_hd_t structure.
digest: is the output value of the hash
Description: This function will deinitialize all resources occupied by the given hash context.
Since: 2.10.0
algorithm: the hash algorithm to use
text: the data to hash
textlen: The length of data to hash
digest: is the output value of the hash
Description: This convenience function will hash the given data and return output on a single call.
Returns: Zero or a negative error code on error.
Since: 2.10.0
algorithm: the hash algorithm to use
Description: This function will return the length of the output data of the given hash algorithm.
Returns: The length or zero on error.
Since: 2.10.0
dig: is a gnutls_hash_hd_t structure.
algorithm: the hash algorithm to use
Description: This function will initialize an context that can be used to produce a Message Digest of data. This will effectively use the current crypto backend in use by gnutls or the cryptographic accelerator in use.
Returns: Zero or a negative error code on error.
Since: 2.10.0
handle: is a gnutls_hash_hd_t structure.
digest: is the output value of the hash
Description: This function will output the current hash value.
Since: 2.10.0
handle: is a gnutls_cipher_hd_t structure.
text: the data to hash
textlen: The length of data to hash
Description: This function will hash the given data using the algorithm specified by the context.
Returns: Zero or a negative error code on error.
Since: 2.10.0
hex_data: string with data in hex format
hex_size: size of hex data
bin_data: output array with binary data
bin_size: when calling should hold maximum size of bin_data,
on return will hold actual length of bin_data.
Description: Convert a buffer with hex data to binary data.
Returns: GNUTLS_E_SUCCESS on success, otherwise a negative error code.
Since: 2.4.0
hex_data: contain the encoded data
result: the place where decoded data will be copied
result_size: holds the size of the result
Description: This function will decode the given encoded data, using the hex encoding used by PSK password files.
Note that hex_data should be null terminated.
Returns: GNUTLS_E_SHORT_MEMORY_BUFFER if the buffer given is not
long enough, or 0 on success.
data: contain the raw data
result: the place where hex data will be copied
result_size: holds the size of the result
Description: This function will convert the given data to printable data, using the hex encoding, as used in the PSK password files.
Returns: GNUTLS_E_SHORT_MEMORY_BUFFER if the buffer given is not
long enough, or 0 on success.
handle: is a gnutls_hmac_hd_t structure.
digest: is the output value of the MAC
Description: This function will deinitialize all resources occupied by the given hmac context.
Since: 2.10.0
algorithm: the hash algorithm to use
key: the key to use
keylen: The length of the key
text: the data to hash
textlen: The length of data to hash
digest: is the output value of the hash
Description: This convenience function will hash the given data and return output on a single call.
Returns: Zero or a negative error code on error.
Since: 2.10.0
algorithm: the hmac algorithm to use
Description: This function will return the length of the output data of the given hmac algorithm.
Returns: The length or zero on error.
Since: 2.10.0
dig: is a gnutls_hmac_hd_t structure.
algorithm: the HMAC algorithm to use
key: The key to be used for encryption
keylen: The length of the key
Description: This function will initialize an context that can be used to produce a Message Authentication Code (MAC) of data. This will effectively use the current crypto backend in use by gnutls or the cryptographic accelerator in use.
Returns: Zero or a negative error code on error.
Since: 2.10.0
handle: is a gnutls_hmac_hd_t structure.
digest: is the output value of the MAC
Description: This function will output the current MAC value.
Since: 2.10.0
handle: is a gnutls_cipher_hd_t structure.
text: the data to hash
textlen: The length of data to hash
Description: This function will hash the given data using the algorithm specified by the context.
Returns: Zero or a negative error code on error.
Since: 2.10.0
session: is a pointer to a gnutls_session_t structure.
flags: indicate if this session is to be used for server or client.
Description: This function initializes the current session to null. Every
session must be initialized before use, so internal structures can
be allocated. This function allocates structures which can only
be free’d by calling gnutls_deinit(). Returns GNUTLS_E_SUCCESS (0) on success.
flags can be one of GNUTLS_CLIENT and GNUTLS_SERVER. For a DTLS
entity, the flags GNUTLS_DATAGRAM and GNUTLS_NONBLOCK are
also available. The latter flag will enable a non-blocking
operation of the DTLS timers.
Returns: GNUTLS_E_SUCCESS on success, or an error code.
key: is a pointer to a gnutls_datum_t which will contain a newly
created key.
key_size: The number of bytes of the key.
Description: Generates a random key of key_bytes size.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, or an
error code.
Since: 3.0.0
name: is a KX name
Description: Convert a string to a gnutls_kx_algorithm_t value. The names are
compared in a case insensitive way.
Returns: an id of the specified KX algorithm, or GNUTLS_KX_UNKNOWN
on error.
algorithm: is a key exchange algorithm
Description: Convert a gnutls_kx_algorithm_t value to a string.
Returns: a pointer to a string that contains the name of the
specified key exchange algorithm, or NULL.
session: is a gnutls_session_t structure.
Description: Get currently used key exchange algorithm.
Returns: the key exchange algorithm used in the last handshake, a
gnutls_kx_algorithm_t value.
Description: Get a list of supported key exchange algorithms.
This function is not thread safe.
Returns: a (0)-terminated list of gnutls_kx_algorithm_t integers
indicating the available key exchange algorithms.
session: is a gnutls_session_t structure.
list: is a 0 terminated list of gnutls_kx_algorithm_t elements.
Description: Sets the priority on the key exchange algorithms supported by gnutls. Priority is higher for elements specified before others. After specifying the algorithms you want, you must append a 0. Note that the priority is set on the client. The server does not use the algorithm’s priority except for disabling algorithms that were not specified.
Returns: GNUTLS_E_SUCCESS on success, or an error code.
name: is a MAC algorithm name
Description: Convert a string to a gnutls_mac_algorithm_t value. The names are
compared in a case insensitive way.
Returns: a gnutls_mac_algorithm_t id of the specified MAC
algorithm string, or GNUTLS_MAC_UNKNOWN on failures.
algorithm: is an encryption algorithm
Description: Get size of MAC key.
Returns: length (in bytes) of the given MAC key size, or 0 if the given MAC algorithm is invalid.
algorithm: is a MAC algorithm
Description: Convert a gnutls_mac_algorithm_t value to a string.
Returns: a string that contains the name of the specified MAC
algorithm, or NULL.
session: is a gnutls_session_t structure.
Description: Get currently used MAC algorithm.
Returns: the currently used mac algorithm, a
gnutls_mac_algorithm_t value.
Description: Get a list of hash algorithms for use as MACs. Note that not necessarily all MACs are supported in TLS cipher suites. For example, MD2 is not supported as a cipher suite, but is supported for other purposes (e.g., X.509 signature verification or similar).
This function is not thread safe.
Returns: Return a (0)-terminated list of gnutls_mac_algorithm_t
integers indicating the available MACs.
session: is a gnutls_session_t structure.
list: is a 0 terminated list of gnutls_mac_algorithm_t elements.
Description: Sets the priority on the mac algorithms supported by gnutls. Priority is higher for elements specified before others. After specifying the algorithms you want, you must append a 0. Note that the priority is set on the client. The server does not use the algorithm’s priority except for disabling algorithms that were not specified.
Returns: GNUTLS_E_SUCCESS on success, or an error code.
s: size to allocate in bytes
Description: This function will allocate ’s’ bytes data, and return a pointer to memory. This function is supposed to be used by callbacks.
The allocation function used is the one set by
gnutls_global_set_mem_functions().
session: is a pointer to a gnutls_session_t structure.
status: is one of GNUTLS_OPENPGP_CERT, or GNUTLS_OPENPGP_CERT_FINGERPRINT
Description: This function will order gnutls to send the key fingerprint instead of the key in the initial handshake procedure. This should be used with care and only when there is indication or knowledge that the server can obtain the client’s key.
pcert: The structure to be deinitialized
Description: This function will deinitialize a pcert structure.
Since: 3.0.0
pcert: The pcert structure
cert: The raw certificate to be imported
format: The format of the certificate
keyid: The key ID to use (NULL for the master key)
flags: zero for now
Description: This convenience function will import the given certificate to a
gnutls_pcert_st structure. The structure must be deinitialized
afterwards using gnutls_pcert_deinit();
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 3.0.0
pcert: The pcert structure
crt: The raw certificate to be imported
flags: zero for now
Description: This convenience function will import the given certificate to a
gnutls_pcert_st structure. The structure must be deinitialized
afterwards using gnutls_pcert_deinit();
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 3.0.0
pcert: The pcert structure
cert: The raw certificate to be imported
format: The format of the certificate
flags: zero for now
Description: This convenience function will import the given certificate to a
gnutls_pcert_st structure. The structure must be deinitialized
afterwards using gnutls_pcert_deinit();
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 3.0.0
pcert: The pcert structure
crt: The raw certificate to be imported
flags: zero for now
Description: This convenience function will import the given certificate to a
gnutls_pcert_st structure. The structure must be deinitialized
afterwards using gnutls_pcert_deinit();
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 3.0.0
pcerts: The structures to store the parsed certificate. Must not be initialized.
pcert_max: Initially must hold the maximum number of certs. It will be updated with the number of certs available.
data: The certificates.
format: One of DER or PEM.
flags: must be (0) or an OR’d sequence of gnutls_certificate_import_flags.
Description: This function will convert the given PEM encoded certificate list
to the native gnutls_x509_crt_t format. The output will be stored
in certs. They will be automatically initialized.
If the Certificate is PEM encoded it should have a header of "X509 CERTIFICATE", or "CERTIFICATE".
Returns: the number of certificates read or a negative error value.
Since: 3.0.0
header: The PEM header (eg. CERTIFICATE)
b64_data: contains the encoded data
result: the place where decoded data lie
Description: This function will decode the given encoded data. The decoded data will be allocated, and stored into result. If the header given is non null this function will search for "—–BEGIN header" and decode only this part. Otherwise it will decode the first PEM packet found.
You should use gnutls_free() to free the returned data.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise
an error code is returned.
header: A null terminated string with the PEM header (eg. CERTIFICATE)
b64_data: contain the encoded data
result: the place where decoded data will be copied
result_size: holds the size of the result
Description: This function will decode the given encoded data. If the header given is non null this function will search for "—–BEGIN header" and decode only this part. Otherwise it will decode the first PEM packet found.
Returns: On success GNUTLS_E_SUCCESS (0) is returned,
GNUTLS_E_SHORT_MEMORY_BUFFER is returned if the buffer given is
not long enough, or 0 on success.
msg: is a message to be put in the encoded header
data: contains the raw data
result: will hold the newly allocated encoded data
Description: This function will convert the given data to printable data, using the base64 encoding. This is the encoding used in PEM messages. This function will allocate the required memory to hold the encoded data.
You should use gnutls_free() to free the returned data.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise
an error code is returned.
msg: is a message to be put in the header
data: contain the raw data
result: the place where base64 data will be copied
result_size: holds the size of the result
Description: This function will convert the given data to printable data, using the base64 encoding. This is the encoding used in PEM messages.
The output string will be null terminated, although the size will not include the terminating null.
Returns: On success GNUTLS_E_SUCCESS (0) is returned,
GNUTLS_E_SHORT_MEMORY_BUFFER is returned if the buffer given is
not long enough, or 0 on success.
error: is a GnuTLS error code, a negative error code
Description: This function is like perror(). The only difference is that it
accepts an error number returned by a gnutls function.
algorithm: is a pk algorithm
Description: Convert a gnutls_pk_algorithm_t value to a string.
Returns: a string that contains the name of the specified public
key algorithm, or NULL.
algo: is a public key algorithm
bits: is the number of bits
Description: This is the inverse of gnutls_sec_param_to_pk_bits(). Given an algorithm
and the number of bits, it will return the security parameter. This is
a rough indication.
Returns: The security parameter.
Since: 2.12.0
name: is a string containing a public key algorithm name.
Description: Convert a string to a gnutls_pk_algorithm_t value. The names are
compared in a case insensitive way. For example,
gnutls_pk_get_id("RSA") will return GNUTLS_PK_RSA.
Returns: a gnutls_pk_algorithm_t id of the specified public key
algorithm string, or GNUTLS_PK_UNKNOWN on failures.
Since: 2.6.0
algorithm: is a public key algorithm
Description: Convert a gnutls_pk_algorithm_t value to a string.
Returns: a pointer to a string that contains the name of the
specified public key algorithm, or NULL.
Since: 2.6.0
Description: Get a list of supported public key algorithms.
This function is not thread safe.
Returns: a (0)-terminated list of gnutls_pk_algorithm_t integers
indicating the available ciphers.
Since: 2.6.0
name: The filename of the module
params: should be NULL
Description: This function will load and add a PKCS 11 module to the module list used in gnutls. After this function is called the module will be used for PKCS 11 operations.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
token_url: A PKCS 11 URL specifying a token
key: The raw key
label: A name to be used for the stored data
key_usage: One of GNUTLS_KEY_*
flags: One of GNUTLS_PKCS11_OBJ_FLAG_*
Description: This function will copy a raw secret (symmetric) key into a PKCS 11
token specified by a URL. The key can be marked as sensitive or not.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
token_url: A PKCS 11 URL specifying a token
crt: A certificate
label: A name to be used for the stored data
flags: One of GNUTLS_PKCS11_OBJ_FLAG_*
Description: This function will copy a certificate into a PKCS 11 token specified by
a URL. The certificate can be marked as trusted or not.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
token_url: A PKCS 11 URL specifying a token
key: A private key
label: A name to be used for the stored data
key_usage: One of GNUTLS_KEY_*
flags: One of GNUTLS_PKCS11_OBJ_* flags
Description: This function will copy a private key into a PKCS 11 token specified by
a URL. It is highly recommended flags to contain GNUTLS_PKCS11_OBJ_FLAG_MARK_SENSITIVE
unless there is a strong reason not to.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
Description: This function will deinitialize the PKCS 11 subsystem in gnutls.
Since: 2.12.0
object_url: The URL of the object to delete.
flags: One of GNUTLS_PKCS11_OBJ_* flags
Description: This function will delete objects matching the given URL. Note that not all tokens support the delete operation.
Returns: On success, the number of objects deleted is returned, otherwise a negative error value.
Since: 2.12.0
flags: GNUTLS_PKCS11_FLAG_MANUAL or GNUTLS_PKCS11_FLAG_AUTO
deprecated_config_file: either NULL or the location of a deprecated configuration file
Description: This function will initialize the PKCS 11 subsystem in gnutls. It will
read configuration files if GNUTLS_PKCS11_FLAG_AUTO is used or allow
you to independently load PKCS 11 modules using gnutls_pkcs11_add_provider()
if GNUTLS_PKCS11_FLAG_MANUAL is specified.
Normally you don’t need to call this function since it is being called
by gnutls_global_init() using the GNUTLS_PKCS11_FLAG_AUTO. If other option
is required then it must be called before it.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
obj: The structure to be initialized
Description: This function will deinitialize a certificate structure.
Since: 2.12.0
obj: Holds the PKCS 11 certificate
detailed: non zero if a detailed URL is required
url: will contain an allocated url
Description: This function will export a URL identifying the given certificate.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
obj: Holds the object
output_data: will contain a certificate PEM or DER encoded
output_data_size: holds the size of output_data (and will be replaced by the actual size of parameters)
Description: This function will export the PKCS11 object data. It is normal for
data to be inaccesible and in that case GNUTLS_E_INVALID_REQUEST
will be returned.
If the buffer provided is not long enough to hold the output, then *output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will be returned.
If the structure is PEM encoded, it will have a header of "BEGIN CERTIFICATE".
Returns: In case of failure a negative error code will be
returned, and GNUTLS_E_SUCCESS (0) on success.
Since: 2.12.0
crt: should contain a gnutls_pkcs11_obj_t structure
itype: Denotes the type of information requested
output: where output will be stored
output_size: contains the maximum size of the output and will be overwritten with actual
Description: This function will return information about the PKCS11 certificate
such as the label, id as well as token information where the key is
stored. When output is text it returns null terminated string
although output_size contains the size of the actual data only.
Returns: GNUTLS_E_SUCCESS (0) on success or a negative error code on error.
Since: 2.12.0
obj: Holds the PKCS 11 object
Description: This function will return the type of the certificate being stored in the structure.
Returns: The type of the certificate.
Since: 2.12.0
cert: The structure to store the parsed certificate
url: a PKCS 11 url identifying the key
flags: One of GNUTLS_PKCS11_OBJ_* flags
Description: This function will "import" a PKCS 11 URL identifying a certificate
key to the gnutls_pkcs11_obj_t structure. This does not involve any
parsing (such as X.509 or OpenPGP) since the gnutls_pkcs11_obj_t is
format agnostic. Only data are transferred.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
obj: The structure to be initialized
Description: This function will initialize a pkcs11 certificate structure.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
p_list: An uninitialized object list (may be NULL)
n_list: initially should hold the maximum size of the list. Will contain the actual size.
url: A PKCS 11 url identifying a set of objects
attrs: Attributes of type gnutls_pkcs11_obj_attr_t that can be used to limit output
flags: One of GNUTLS_PKCS11_OBJ_* flags
Description: This function will initialize and set values to an object list by using all objects identified by a PKCS 11 URL.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: The structure to be initialized
Description: This function will deinitialize a private key structure.
key: Holds the PKCS 11 key
detailed: non zero if a detailed URL is required
url: will contain an allocated url
Description: This function will export a URL identifying the given key.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
url: a token URL
pk: the public key algorithm
bits: the security bits
label: a label
flags: should be zero
Description: This function will generate a private key in the specified
by the url token. The pivate key will be generate within
the token and will not be exportable.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 3.0.0
pkey: should contain a gnutls_pkcs11_privkey_t structure
itype: Denotes the type of information requested
output: where output will be stored
output_size: contains the maximum size of the output and will be overwritten with actual
Description: This function will return information about the PKCS 11 private key such
as the label, id as well as token information where the key is stored. When
output is text it returns null terminated string although output_size contains
the size of the actual data only.
Returns: GNUTLS_E_SUCCESS (0) on success or a negative error code on error.
key: should contain a gnutls_pkcs11_privkey_t structure
bits: if bits is non null it will hold the size of the parameters’ in bits
Description: This function will return the public key algorithm of a private key.
Returns: a member of the gnutls_pk_algorithm_t enumeration on
success, or a negative error code on error.
pkey: The structure to store the parsed key
url: a PKCS 11 url identifying the key
flags: sequence of GNUTLS_PKCS_PRIVKEY_*
Description: This function will "import" a PKCS 11 URL identifying a private
key to the gnutls_pkcs11_privkey_t structure. In reality since
in most cases keys cannot be exported, the private key structure
is being associated with the available operations on the token.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
key: The structure to be initialized
Description: This function will initialize an private key structure.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
fn: The PIN callback, a gnutls_pkcs11_pin_callback_t() function.
userdata: data to be supplied to callback
Description: This function will set a callback function to be used when a PIN is
required for PKCS 11 operations. See
gnutls_pkcs11_pin_callback_t() on how the callback should behave.
Since: 2.12.0
fn: The token callback
userdata: data to be supplied to callback
Description: This function will set a callback function to be used when a token needs to be inserted to continue PKCS 11 operations.
Since: 2.12.0
url: should contain a PKCS 11 URL
flags: The output flags (GNUTLS_PKCS11_TOKEN_*)
Description: This function will return information about the PKCS 11 token flags.
The flags from the gnutls_pkcs11_token_info_t enumeration.
Returns: GNUTLS_E_SUCCESS (0) on success or a negative error code on error.
Since: 2.12.0
url: should contain a PKCS 11 URL
ttype: Denotes the type of information requested
output: where output will be stored
output_size: contains the maximum size of the output and will be overwritten with actual
Description: This function will return information about the PKCS 11 token such as the label, id, etc.
Returns: GNUTLS_E_SUCCESS (0) on success or a negative error code
on error.
Since: 2.12.0
url: should contain a PKCS 11 URL
idx: The index of the mechanism
mechanism: The PKCS 11 mechanism ID
Description: This function will return the names of the supported mechanisms by the token. It should be called with an increasing index until it return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE.
Returns: GNUTLS_E_SUCCESS (0) on success or a negative error code on error.
Since: 2.12.0
seq: sequence number starting from 0
detailed: non zero if a detailed URL is required
url: will contain an allocated url
Description: This function will return the URL for each token available
in system. The url has to be released using gnutls_free()
Returns: On success, GNUTLS_E_SUCCESS (0) is returned,
GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE if the sequence number
exceeds the available tokens, otherwise a negative error value.
Since: 2.12.0
token_url: A PKCS 11 URL specifying a token
so_pin: Security Officer’s PIN
label: A name to be used for the token
Description: This function will initialize (format) a token. If the token is at a factory defaults state the security officer’s PIN given will be set to be the default. Otherwise it should match the officer’s PIN.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
token_url: A PKCS 11 URL specifying a token
oldpin: old user’s PIN
newpin: new user’s PIN
flags: one of gnutls_pkcs11_pin_flag_t.
Description: This function will modify or set a user’s PIN for the given token. If it is called to set a user pin for first time the oldpin must be NULL.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
type: Holds the PKCS 11 object type, a gnutls_pkcs11_obj_type_t.
Description: This function will return a human readable description of the
PKCS11 object type obj. It will return "Unknown" for unknown
types.
Returns: human readable string labeling the PKCS11 object type type.
Since: 2.12.0
session: is a gnutls_session_t structure.
label_size: length of the label variable.
label: label used in PRF computation, typically a short string.
seed_size: length of the seed variable.
seed: optional extra data to seed the PRF with.
outsize: size of pre-allocated output buffer to hold the output.
out: pre-allocate buffer to hold the generated data.
Description: Apply the TLS Pseudo-Random-Function (PRF) using the master secret on some data.
The label variable usually contain a string denoting the purpose
for the generated data. The seed usually contain data such as the
client and server random, perhaps together with some additional
data that is added to guarantee uniqueness of the output for a
particular purpose.
Because the output is not guaranteed to be unique for a particular
session unless seed include the client random and server random
fields (the PRF would output the same data on another connection
resumed from the first one), it is not recommended to use this
function directly. The gnutls_prf() function seed the PRF with the
client and server random fields directly, and is recommended if you
want to generate pseudo random data unique for each session.
Returns: GNUTLS_E_SUCCESS on success, or an error code.
session: is a gnutls_session_t structure.
label_size: length of the label variable.
label: label used in PRF computation, typically a short string.
server_random_first: non-0 if server random field should be first in seed
extra_size: length of the extra variable.
extra: optional extra data to seed the PRF with.
outsize: size of pre-allocated output buffer to hold the output.
out: pre-allocate buffer to hold the generated data.
Description: Apply the TLS Pseudo-Random-Function (PRF) using the master secret on some data, seeded with the client and server random fields.
The label variable usually contain a string denoting the purpose
for the generated data. The server_random_first indicate whether
the client random field or the server random field should be first
in the seed. Non-0 indicate that the server random field is first,
0 that the client random field is first.
The extra variable can be used to add more data to the seed, after
the random variables. It can be used to tie make sure the
generated output is strongly connected to some additional data
(e.g., a string used in user authentication).
The output is placed in out, which must be pre-allocated.
Returns: GNUTLS_E_SUCCESS on success, or an error code.
priority_cache: is a gnutls_prioritity_t structure.
Description: Deinitializes the priority cache.
priority_cache: is a gnutls_prioritity_t structure.
priorities: is a string describing priorities
err_pos: In case of an error this will have the position in the string the error occured
Description: Sets priorities for the ciphers, key exchange methods, macs and compression methods.
The priorities option allows you to specify a colon
separated list of the cipher priorities to enable.
Some keywords are defined to provide quick access
to common preferences.
"PERFORMANCE" means all the "secure" ciphersuites are enabled, limited to 128 bit ciphers and sorted by terms of speed performance.
"NORMAL" means all "secure" ciphersuites. The 256-bit ciphers are included as a fallback only. The ciphers are sorted by security margin.
"SECURE128" means all "secure" ciphersuites of security level 128-bit or more.
"SECURE192" means all "secure" ciphersuites of security level 192-bit or more.
"SUITEB128" means all the NSA SuiteB ciphersuites with security level of 128.
"SUITEB192" means all the NSA SuiteB ciphersuites with security level of 192.
"EXPORT" means all ciphersuites are enabled, including the low-security 40 bit ciphers.
"NONE" means nothing is enabled. This disables even protocols and compression methods.
Special keywords are "!", "-" and "+". "!" or "-" appended with an algorithm will remove this algorithm. "+" appended with an algorithm will add this algorithm.
Check the GnuTLS manual section "Priority strings" for detailed information.
Examples: "NONE:+VERS-TLS-ALL:+MAC-ALL:+RSA:+AES-128-CBC:+SIGN-ALL:+COMP-NULL"
"NORMAL:-ARCFOUR-128" means normal ciphers except for ARCFOUR-128.
"SECURE:-VERS-SSL3.0:+COMP-DEFLATE" means that only secure ciphers are enabled, SSL3.0 is disabled, and libz compression enabled.
"NONE:+VERS-TLS-ALL:+AES-128-CBC:+RSA:+SHA1:+COMP-NULL:+SIGN-RSA-SHA1",
"NONE:+VERS-TLS-ALL:+AES-128-CBC:+ECDHE-RSA:+SHA1:+COMP-NULL:+SIGN-RSA-SHA1:+CURVE-SECP256R1",
"NORMAL:COMPAT" is the most compatible mode.
Returns: On syntax error GNUTLS_E_INVALID_REQUEST is returned,
GNUTLS_E_SUCCESS on success, or an error code.
session: is a gnutls_session_t structure.
priorities: is a string describing priorities
err_pos: In case of an error this will have the position in the string the error occured
Description: Sets the priorities to use on the ciphers, key exchange methods,
macs and compression methods. This function avoids keeping a
priority cache and is used to directly set string priorities to a
TLS session. For documentation check the gnutls_priority_init().
Returns: On syntax error GNUTLS_E_INVALID_REQUEST is returned,
GNUTLS_E_SUCCESS on success, or an error code.
session: is a gnutls_session_t structure.
priority: is a gnutls_priority_t structure.
Description: Sets the priorities to use on the ciphers, key exchange methods, macs and compression methods.
Returns: GNUTLS_E_SUCCESS on success, or an error code.
key: Holds the key
flags: zero for now
ciphertext: holds the data to be decrypted
plaintext: will contain the decrypted data, allocated with gnutls_malloc()
Description: This function will decrypt the given data using the algorithm supported by the private key.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: The structure to be deinitialized
Description: This function will deinitialize a private key structure.
Since: 2.12.0
key: should contain a gnutls_privkey_t structure
bits: If set will return the number of bits of the parameters (may be NULL)
Description: This function will return the public key algorithm of a private key and if possible will return a number of bits that indicates the security parameter of the key.
Returns: a member of the gnutls_pk_algorithm_t enumeration on
success, or a negative error code on error.
Since: 2.12.0
key: should contain a gnutls_privkey_t structure
Description: This function will return the type of the private key. This is actually the type of the subsystem used to set this private key.
Returns: a member of the gnutls_privkey_type_t enumeration on
success, or a negative error code on error.
Since: 2.12.0
pkey: The private key
pk: The public key algorithm
userdata: private data to be provided to the callbacks
sign_func: callback for signature operations
decrypt_func: callback for decryption operations
flags: Flags for the import
Description: This function will associate the given callbacks with the
gnutls_privkey_t structure. At least one of the two callbacks
must be non-null.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 3.0.0
pkey: The private key
key: The private key to be imported
flags: Flags for the import
Description: This function will import the given private key to the abstract
gnutls_privkey_t structure.
The gnutls_openpgp_privkey_t object must not be deallocated
during the lifetime of this structure. The subkey set as
preferred will be used, or the master key otherwise.
flags might be zero or one of GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE
and GNUTLS_PRIVKEY_IMPORT_COPY.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
pkey: The private key
key: The private key to be imported
flags: Flags for the import
Description: This function will import the given private key to the abstract
gnutls_privkey_t structure.
The gnutls_pkcs11_privkey_t object must not be deallocated
during the lifetime of this structure.
flags might be zero or one of GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE
and GNUTLS_PRIVKEY_IMPORT_COPY.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
pkey: The private key
key: The private key to be imported
flags: Flags for the import
Description: This function will import the given private key to the abstract
gnutls_privkey_t structure.
The gnutls_x509_privkey_t object must not be deallocated
during the lifetime of this structure.
flags might be zero or one of GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE
and GNUTLS_PRIVKEY_IMPORT_COPY.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: The structure to be initialized
Description: This function will initialize an private key structure.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
signer: Holds the key
hash: should be a digest algorithm
flags: should be 0 for now
data: holds the data to be signed
signature: will contain the signature allocate with gnutls_malloc()
Description: This function will sign the given data using a signature algorithm supported by the private key. Signature algorithms are always used together with a hash functions. Different hash functions may be used for the RSA algorithm, but only the SHA family for the DSA keys.
Use gnutls_pubkey_get_preferred_hash_algorithm() to determine
the hash algorithm.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
signer: Holds the signer’s key
hash_algo: The hash algorithm used
flags: zero for now
hash_data: holds the data to be signed
signature: will contain newly allocated signature
Description: This function will sign the given hashed data using a signature algorithm supported by the private key. Signature algorithms are always used together with a hash functions. Different hash functions may be used for the RSA algorithm, but only SHA-XXX for the DSA keys.
Use gnutls_pubkey_get_preferred_hash_algorithm() to determine
the hash algorithm.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
name: is a protocol name
Description: The names are compared in a case insensitive way.
Returns: an id of the specified protocol, or
GNUTLS_VERSION_UNKNOWN on error.
version: is a (gnutls) version number
Description: Convert a gnutls_protocol_t value to a string.
Returns: a string that contains the name of the specified TLS
version (e.g., "TLS1.0"), or NULL.
session: is a gnutls_session_t structure.
Description: Get TLS version, a gnutls_protocol_t value.
Returns: The version of the currently used protocol.
Description: Get a list of supported protocols, e.g. SSL 3.0, TLS 1.0 etc.
This function is not threat safe.
Returns: a (0)-terminated list of gnutls_protocol_t integers
indicating the available protocols.
session: is a gnutls_session_t structure.
list: is a 0 terminated list of gnutls_protocol_t elements.
Description: Sets the priority on the protocol versions supported by gnutls. This function actually enables or disables protocols. Newer protocol versions always have highest priority.
Returns: GNUTLS_E_SUCCESS on success, or an error code.
sc: is a pointer to a gnutls_psk_server_credentials_t structure.
Description: This structure is complex enough to manipulate directly thus this helper function is provided in order to allocate it.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise
an error code is returned.
sc: is a pointer to a gnutls_psk_server_credentials_t structure.
Description: This structure is complex enough to manipulate directly thus this helper function is provided in order to allocate it.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise
an error code is returned.
session: is a gnutls session
Description: The PSK identity hint may give the client help in deciding which username to use. This should only be called in case of PSK authentication and in case of a client.
Returns: the identity hint of the peer, or NULL in case of an error.
Since: 2.4.0
sc: is a gnutls_psk_client_credentials_t structure.
Description: This structure is complex enough to manipulate directly thus this helper function is provided in order to free (deallocate) it.
sc: is a gnutls_psk_server_credentials_t structure.
Description: This structure is complex enough to manipulate directly thus this helper function is provided in order to free (deallocate) it.
session: is a gnutls session
Description: This should only be called in case of PSK authentication and in case of a server.
Returns: the username of the peer, or NULL in case of an error.
cred: is a gnutls_psk_server_credentials_t structure.
func: is the callback function
Description: This function can be used to set a callback to retrieve the username and password for client PSK authentication. The callback’s function form is: int (*callback)(gnutls_session_t, char** username, gnutls_datum_t* key);
The username and key->data must be allocated using gnutls_malloc(). username should be ASCII strings or UTF-8 strings prepared using
the "SASLprep" profile of "stringprep".
The callback function will be called once per handshake.
The callback function should return 0 on success. -1 indicates an error.
res: is a gnutls_psk_client_credentials_t structure.
username: is the user’s zero-terminated userid
key: is the user’s key
flags: indicate the format of the key, either
GNUTLS_PSK_KEY_RAW or GNUTLS_PSK_KEY_HEX.
Description: This function sets the username and password, in a
gnutls_psk_client_credentials_t structure. Those will be used in
PSK authentication. username should be an ASCII string or UTF-8
strings prepared using the "SASLprep" profile of "stringprep". The
key can be either in raw byte format or in Hex format (without the
0x prefix).
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise
an error code is returned.
res: is a gnutls_psk_server_credentials_t structure
func: is the function to be called
Description: This function will set a callback in order for the server to get
the Diffie-Hellman or RSA parameters for PSK authentication. The
callback should return GNUTLS_E_SUCCESS (0) on success.
res: is a gnutls_psk_server_credentials_t structure.
password_file: is the PSK password file (passwd.psk)
Description: This function sets the password file, in a
gnutls_psk_server_credentials_t structure. This password file
holds usernames and keys and will be used for PSK authentication.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise
an error code is returned.
cred: is a gnutls_psk_server_credentials_t structure.
func: is the callback function
Description: This function can be used to set a callback to retrieve the user’s PSK credentials.
The callback’s function form is:
int (*callback)(gnutls_session_t, const char* username,
gnutls_datum_t* key);
username contains the actual username.
The key must be filled in using the gnutls_malloc().
In case the callback returned a negative number then gnutls will assume that the username does not exist.
The callback function will only be called once per handshake. The callback function should return 0 on success, while -1 indicates an error.
res: is a gnutls_psk_server_credentials_t structure.
hint: is the PSK identity hint string
Description: This function sets the identity hint, in a
gnutls_psk_server_credentials_t structure. This hint is sent to
the client to help it chose a good PSK credential (i.e., username
and password).
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise
an error code is returned.
Since: 2.4.0
res: is a gnutls_psk_server_credentials_t structure
dh_params: is a structure that holds Diffie-Hellman parameters.
Description: This function will set the Diffie-Hellman parameters for an anonymous server to use. These parameters will be used in Diffie-Hellman exchange with PSK cipher suites.
res: is a gnutls_certificate_credentials_t structure
func: is the function to be called
Description: This function will set a callback in order for the server to get
the Diffie-Hellman parameters for PSK authentication. The callback
should return GNUTLS_E_SUCCESS (0) on success.
key: The structure to be deinitialized
Description: This function will deinitialize a public key structure.
Since: 2.12.0
key: Holds the certificate
format: the format of output params. One of PEM or DER.
output_data: will contain a certificate PEM or DER encoded
output_data_size: holds the size of output_data (and will be replaced by the actual size of parameters)
Description: This function will export the certificate to DER or PEM format.
If the buffer provided is not long enough to hold the output, then
*output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will
be returned.
If the structure is PEM encoded, it will have a header of "BEGIN CERTIFICATE".
Returns: In case of failure a negative error code will be returned, and 0 on success.
Since: 2.12.0
key: Holds the public key
flags: should be 0 for now
output_data: will contain the key ID
output_data_size: holds the size of output_data (and will be replaced by the actual size of parameters)
Description: This function will return a unique ID the depends on the public key parameters. This ID can be used in checking whether a certificate corresponds to the given public key.
If the buffer provided is not long enough to hold the output, then
*output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will
be returned. The output will normally be a SHA-1 hash output,
which is 20 bytes.
Returns: In case of failure a negative error code will be returned, and 0 on success.
Since: 2.12.0
key: should contain a gnutls_pubkey_t structure
usage: If set will return the number of bits of the parameters (may be NULL)
Description: This function will return the key usage of the public key.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: Holds the public key
flags: should be 0 for now
output_data: will contain the key ID
output_data_size: holds the size of output_data (and will be replaced by the actual size of parameters)
subkey: Will be non zero if the key ID corresponds to a subkey
Description: This function will return a unique ID the depends on the public key parameters. This ID can be used in checking whether a certificate corresponds to the given public key.
If the buffer provided is not long enough to hold the output, then
*output_data_size is updated and GNUTLS_E_SHORT_MEMORY_BUFFER will
be returned. The output will normally be a SHA-1 hash output,
which is 20 bytes.
Returns: In case of failure a negative error code will be returned, and 0 on success.
Since: 3.0.0
key: should contain a gnutls_pubkey_t structure
bits: If set will return the number of bits of the parameters (may be NULL)
Description: This function will return the public key algorithm of a public key and if possible will return a number of bits that indicates the security parameter of the key.
Returns: a member of the gnutls_pk_algorithm_t enumeration on
success, or a negative error code on error.
Since: 2.12.0
key: Holds the public key
p: will hold the p
q: will hold the q
g: will hold the g
y: will hold the y
Description: This function will export the DSA public key’s parameters found in
the given certificate. The new parameters will be allocated using
gnutls_malloc() and will be stored in the appropriate datum.
Returns: GNUTLS_E_SUCCESS on success, otherwise a negative error code.
Since: 2.12.0
key: Holds the public key
curve: will hold the curve
x: will hold x
y: will hold y
Description: This function will export the ECC public key’s parameters found in
the given certificate. The new parameters will be allocated using
gnutls_malloc() and will be stored in the appropriate datum.
Returns: GNUTLS_E_SUCCESS on success, otherwise a negative error code.
Since: 3.0.0
key: Holds the public key
parameters: DER encoding of an ANSI X9.62 parameters
ecpoint: DER encoding of ANSI X9.62 ECPoint
Description: This function will export the ECC public key’s parameters found in
the given certificate. The new parameters will be allocated using
gnutls_malloc() and will be stored in the appropriate datum.
Returns: GNUTLS_E_SUCCESS on success, otherwise a negative error code.
Since: 3.0.0
key: Holds the certificate
m: will hold the modulus
e: will hold the public exponent
Description: This function will export the RSA public key’s parameters found in
the given structure. The new parameters will be allocated using
gnutls_malloc() and will be stored in the appropriate datum.
Returns: GNUTLS_E_SUCCESS on success, otherwise a negative error code.
Since: 2.12.0
key: Holds the certificate
hash: The result of the call with the hash algorithm used for signature
mand: If non zero it means that the algorithm MUST use this hash. May be NULL.
Description: This function will read the certifcate and return the appropriate digest algorithm to use for signing with this certificate. Some certificates (i.e. DSA might not be able to sign without the preferred algorithm).
Returns: the 0 if the hash algorithm is found. A negative error code is returned on error.
Since: 2.12.0
key: Holds the certificate
signature: contains the signature
hash: The result of the call with the hash algorithm used for signature
Description: This function will read the certifcate and the signed data to determine the hash algorithm used to generate the signature.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: The structure to store the parsed key
p: holds the p
q: holds the q
g: holds the g
y: holds the y
Description: This function will convert the given DSA raw parameters to the
native gnutls_pubkey_t format. The output will be stored
in key.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: The structure to store the parsed key
curve: holds the curve
x: holds the x
y: holds the y
Description: This function will convert the given elliptic curve parameters to a
gnutls_pubkey_t. The output will be stored in key.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 3.0.0
key: The structure to store the parsed key
parameters: DER encoding of an ANSI X9.62 parameters
ecpoint: DER encoding of ANSI X9.62 ECPoint
Description: This function will convert the given elliptic curve parameters to a
gnutls_pubkey_t. The output will be stored in key.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 3.0.0
key: The public key
crt: The certificate to be imported
flags: should be zero
Description: Imports a public key from an openpgp key. This function will import
the given public key to the abstract gnutls_pubkey_t
structure. The subkey set as preferred will be imported or the
master key otherwise.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: A key of type gnutls_pubkey_t
url: A PKCS 11 url
flags: One of GNUTLS_PKCS11_OBJ_* flags
Description: This function will import a PKCS 11 certificate to a gnutls_pubkey_t
structure.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: The public key
obj: The parameters to be imported
flags: should be zero
Description: Imports a public key from a pkcs11 key. This function will import
the given public key to the abstract gnutls_pubkey_t structure.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: The public key
pkey: The private key
usage: GNUTLS_KEY_* key usage flags.
flags: should be zero
Description: Imports the public key from a private. This function will import
the given public key to the abstract gnutls_pubkey_t structure.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: Is a structure will hold the parameters
m: holds the modulus
e: holds the public exponent
Description: This function will replace the parameters in the given structure. The new parameters should be stored in the appropriate gnutls_datum.
Returns: GNUTLS_E_SUCCESS on success, or an negative error code.
Since: 2.12.0
key: The public key
crt: The certificate to be imported
flags: should be zero
Description: This function will import the given public key to the abstract
gnutls_pubkey_t structure.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: The structure to store the parsed public key.
data: The DER or PEM encoded certificate.
format: One of DER or PEM
Description: This function will convert the given DER or PEM encoded Public key
to the native gnutls_pubkey_t format.The output will be stored
in key.
If the Certificate is PEM encoded it should have a header of "PUBLIC KEY".
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: The structure to be initialized
Description: This function will initialize an public key structure.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
key: a certificate of type gnutls_x509_crt_t
usage: an ORed sequence of the GNUTLS_KEY_* elements.
Description: This function will set the key usage flags of the public key. This is only useful if the key is to be exported to a certificate or certificate request.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
pubkey: Holds the public key
algo: The signature algorithm used
flags: should be 0 for now
data: holds the signed data
signature: contains the signature
Description: This function will verify the given signed data, using the parameters from the certificate.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value (GNUTLS_E_PK_SIG_VERIFY_FAILED in verification failure).
Since: 3.0.0
pubkey: Holds the public key
flags: should be 0 for now
data: holds the signed data
signature: contains the signature
Description: This function will verify the given signed data, using the parameters from the certificate.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value (GNUTLS_E_PK_SIG_VERIFY_FAILED in verification failure).
Since: 2.12.0
key: Holds the certificate
flags: should be 0 for now
hash: holds the hash digest to be verified
signature: contains the signature
Description: This function will verify the given signed digest, using the parameters from the certificate.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value (GNUTLS_E_PK_SIG_VERIFY_FAILED in verification failure).
Since: 2.12.0
session: is a gnutls_session_t structure.
Description: This function checks if there are unread data
in the gnutls buffers. If the return value is
non-zero the next call to gnutls_record_recv()
is guarranteed not to block.
Returns: Returns the size of the data or zero.
session: is a gnutls_session_t structure.
Description: Used to disabled padding in TLS 1.0 and above. Normally you do not need to use this function, but there are buggy clients that complain if a server pads the encrypted data. This of course will disable protection against statistical attacks on the data.
Normally only servers that require maximum compatibility with everything out there, need to call this function.
session: is a gnutls_session_t structure.
Description: This function provides information about the internals of the
record protocol and is only useful if a prior gnutls function call
(e.g. gnutls_handshake()) was interrupted for some reason, that
is, if a function returned GNUTLS_E_INTERRUPTED or
GNUTLS_E_AGAIN. In such a case, you might want to call select()
or poll() before calling the interrupted gnutls function again. To
tell you whether a file descriptor should be selected for either
reading or writing, gnutls_record_get_direction() returns 0 if the
interrupted function was trying to read data, and 1 if it was
trying to write data.
Returns: 0 if trying to read data, 1 if trying to write data.
session: is a gnutls_session_t structure.
Description: Returns the number of discarded packets in a DTLS connection.
Returns: The number of discarded packets.
Since: 3.0.0
session: is a gnutls_session_t structure.
Description: Get the record size. The maximum record size is negotiated by the client after the first handshake message.
Returns: The maximum record packet size in this connection.
session: is a gnutls_session_t structure.
data: the buffer that the data will be read into
data_size: the number of requested bytes
seq: is the packet’s 64-bit sequence number. Should have space for 8 bytes.
Description: This function is the same as gnutls_record_recv(), except that
it returns in addition to data, the sequence number of the data.
This is useful in DTLS where record packets might be received
out-of-order. The returned 8-byte sequence number is an
integer in big-endian format and should be
treated as a unique message identification.
Returns: The number of bytes received and zero on EOF. A negative
error code is returned in case of an error. The number of bytes
received might be less than data_size.
Since: 3.0.0
session: is a gnutls_session_t structure.
data: the buffer that the data will be read into
data_size: the number of requested bytes
Description: This function has the similar semantics with recv(). The only
difference is that it accepts a GnuTLS session, and uses different
error codes.
In the special case that a server requests a renegotiation, the
client may receive an error code of GNUTLS_E_REHANDSHAKE. This
message may be simply ignored, replied with an alert
GNUTLS_A_NO_RENEGOTIATION, or replied with a new handshake,
depending on the client’s will.
If EINTR is returned by the internal push function (the default
is recv()) then GNUTLS_E_INTERRUPTED will be returned. If
GNUTLS_E_INTERRUPTED or GNUTLS_E_AGAIN is returned, you must
call this function again to get the data. See also
gnutls_record_get_direction().
A server may also receive GNUTLS_E_REHANDSHAKE when a client has
initiated a handshake. In that case the server can only initiate a
handshake or terminate the connection.
Returns: The number of bytes received and zero on EOF (for stream
connections). A negative error code is returned in case of an error.
The number of bytes received might be less than the requested data_size.
session: is a gnutls_session_t structure.
data: contains the data to send
data_size: is the length of the data
Description: This function has the similar semantics with send(). The only
difference is that it accepts a GnuTLS session, and uses different
error codes.
Note that if the send buffer is full, send() will block this
function. See the send() documentation for full information. You
can replace the default push function by using
gnutls_transport_set_ptr2() with a call to send() with a
MSG_DONTWAIT flag if blocking is a problem.
If the EINTR is returned by the internal push function (the
default is send()) then GNUTLS_E_INTERRUPTED will be returned. If
GNUTLS_E_INTERRUPTED or GNUTLS_E_AGAIN is returned, you must
call this function again, with the same parameters; alternatively
you could provide a NULL pointer for data, and 0 for
size. cf. gnutls_record_get_direction().
Returns: The number of bytes sent, or a negative error code. The
number of bytes sent might be less than data_size. The maximum
number of bytes this function can send in a single call depends
on the negotiated maximum record size.
session: is a gnutls_session_t structure.
size: is the new size
Description: This function sets the maximum record packet size in this connection. This property can only be set to clients. The server may choose not to accept the requested size.
Acceptable values are 512(=2^9), 1024(=2^10), 2048(=2^11) and 4096(=2^12). The requested record size does get in effect immediately only while sending data. The receive part will take effect after a successful handshake.
This function uses a TLS extension called ’max record size’. Not all TLS implementations use or even understand this extension.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned,
otherwise a negative error code is returned.
session: is a gnutls_session_t structure.
Description: This function will renegotiate security parameters with the client. This should only be called in case of a server.
This message informs the peer that we want to renegotiate parameters (perform a handshake).
If this function succeeds (returns 0), you must call the
gnutls_handshake() function in order to negotiate the new
parameters.
Since TLS is full duplex some application data might have been
sent during peer’s processing of this message. In that case
one should call gnutls_record_recv() until GNUTLS_E_REHANDSHAKE
is returned to clear any pending data. Care must be taken if
rehandshake is mandatory to terminate if it does not start after
some threshold.
If the client does not wish to renegotiate parameters he will
should with an alert message, thus the return code will be
GNUTLS_E_WARNING_ALERT_RECEIVED and the alert will be
GNUTLS_A_NO_RENEGOTIATION. A client may also choose to ignore
this message.
Returns: GNUTLS_E_SUCCESS on success, otherwise a negative error code.
level: a security level
data: place to store random bytes
len: The requested size
Description: This function will generate random data and store it to output buffer.
Returns: Zero or a negative error code on error.
Since: 2.12.0
session: is a gnutls session
Description: Get the export RSA parameter’s modulus size.
Returns: The bits used in the last RSA-EXPORT key exchange with the peer, or a negative error code in case of error.
session: is a gnutls session
exponent: will hold the exponent.
modulus: will hold the modulus.
Description: This function will return the peer’s public key exponent and
modulus used in the last RSA-EXPORT authentication. The output
parameters must be freed with gnutls_free().
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise
an error code is returned.
dst: Is the destination structure, which should be initialized.
src: Is the source structure
Description: This function will copy the RSA parameters structure from source to destination.
Returns: GNUTLS_E_SUCCESS on success, or an negative error code.
rsa_params: Is a structure that holds the parameters
Description: This function will deinitialize the RSA parameters structure.
params: Holds the RSA parameters
format: the format of output params. One of PEM or DER.
params_data: will contain a PKCS1 RSAPublicKey structure PEM or DER encoded
params_data_size: holds the size of params_data (and will be replaced by the actual size of parameters)
Description: This function will export the given RSA parameters to a PKCS1 RSAPublicKey structure. If the buffer provided is not long enough to hold the output, then GNUTLS_E_SHORT_MEMORY_BUFFER will be returned.
If the structure is PEM encoded, it will have a header of "BEGIN RSA PRIVATE KEY".
Returns: GNUTLS_E_SUCCESS on success, or an negative error code.
rsa: a structure that holds the rsa parameters
m: will hold the modulus
e: will hold the public exponent
d: will hold the private exponent
p: will hold the first prime (p)
q: will hold the second prime (q)
u: will hold the coefficient
bits: if non null will hold the prime’s number of bits
Description: This function will export the RSA parameters found in the given
structure. The new parameters will be allocated using
gnutls_malloc() and will be stored in the appropriate datum.
Returns: GNUTLS_E_SUCCESS on success, or an negative error code.
params: The structure where the parameters will be stored
bits: is the prime’s number of bits
Description: This function will generate new temporary RSA parameters for use in RSA-EXPORT ciphersuites. This function is normally slow.
Note that if the parameters are to be used in export cipher suites the bits value should be 512 or less. Also note that the generation of new RSA parameters is only useful to servers. Clients use the parameters sent by the server, thus it’s no use calling this in client side.
Returns: GNUTLS_E_SUCCESS on success, or an negative error code.
params: A structure where the parameters will be copied to
pkcs1_params: should contain a PKCS1 RSAPublicKey structure PEM or DER encoded
format: the format of params. PEM or DER.
Description: This function will extract the RSAPublicKey found in a PKCS1 formatted structure.
If the structure is PEM encoded, it should have a header of "BEGIN RSA PRIVATE KEY".
Returns: GNUTLS_E_SUCCESS on success, or an negative error code.
rsa_params: Is a structure will hold the parameters
m: holds the modulus
e: holds the public exponent
d: holds the private exponent
p: holds the first prime (p)
q: holds the second prime (q)
u: holds the coefficient
Description: This function will replace the parameters in the given structure. The new parameters should be stored in the appropriate gnutls_datum.
Returns: GNUTLS_E_SUCCESS on success, or an negative error code.
rsa_params: Is a structure that will hold the parameters
Description: This function will initialize the temporary RSA parameters structure.
Returns: GNUTLS_E_SUCCESS on success, or an negative error code.
session: is a gnutls_session_t structure.
Description: Can be used to check whether safe renegotiation is being used in the current session.
Returns: 0 when safe renegotiation is not used and non (0) when safe renegotiation is used.
Since: 2.10.0
param: is a security parameter
Description: Convert a gnutls_sec_param_t value to a string.
Returns: a pointer to a string that contains the name of the
specified public key algorithm, or NULL.
Since: 2.12.0
algo: is a public key algorithm
param: is a security parameter
Description: When generating private and public key pairs a difficult question is which size of "bits" the modulus will be in RSA and the group size in DSA. The easy answer is 1024, which is also wrong. This function will convert a human understandable security parameter to an appropriate size for the specific algorithm.
Returns: The number of bits, or (0).
Since: 2.12.0
session: is a gnutls_session_t structure.
data: will hold the data
data_length: will hold the data length. Must hold the maximum size of data.
type: will hold the server name indicator type
indx: is the index of the server_name
Description: This function will allow you to get the name indication (if any), a client has sent. The name indication may be any of the enumeration gnutls_server_name_type_t.
If type is GNUTLS_NAME_DNS, then this function is to be used by
servers that support virtual hosting, and the data will be a null
terminated UTF-8 string.
If data has not enough size to hold the server name
GNUTLS_E_SHORT_MEMORY_BUFFER is returned, and data_length will
hold the required size.
index is used to retrieve more than one server names (if sent by
the client). The first server name has an index of 0, the second 1
and so on. If no name with the given index exists
GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE is returned.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned,
otherwise a negative error code is returned.
session: is a gnutls_session_t structure.
type: specifies the indicator type
name: is a string that contains the server name.
name_length: holds the length of name
Description: This function is to be used by clients that want to inform (via a TLS extension mechanism) the server of the name they connected to. This should be used by clients that connect to servers that do virtual hosting.
The value of name depends on the type type. In case of
GNUTLS_NAME_DNS, an ASCII (0)-terminated domain name string,
without the trailing dot, is expected. IPv4 or IPv6 addresses are
not permitted.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned,
otherwise a negative error code is returned.
session: is a gnutls_session_t structure.
cbtype: an gnutls_channel_binding_t enumeration type
cb: output buffer array with data
Description: Extract given channel binding data of the cbtype (e.g.,
GNUTLS_CB_TLS_UNIQUE) type.
Returns: GNUTLS_E_SUCCESS on success,
GNUTLS_E_UNIMPLEMENTED_FEATURE if the cbtype is unsupported,
GNUTLS_E_CHANNEL_BINDING_NOT_AVAILABLE if the data is not
currently available, or an error code.
Since: 2.12.0
session: is a gnutls_session_t structure.
Description: This function can be used to disable certain (security) features in
TLS in order to maintain maximum compatibility with buggy
clients. It is equivalent to calling:
gnutls_record_disable_padding()
Normally only servers that require maximum compatibility with everything out there, need to call this function.
session: is a gnutls_session_t structure.
data: is a pointer to a datum that will hold the session.
Description: Returns all session parameters, in order to support resuming. The
client should call this, and keep the returned session, if he wants
to resume that current version later by calling
gnutls_session_set_data(). This function must be called after a
successful handshake. The returned datum must be freed with
gnutls_free().
Resuming sessions is really useful and speedups connections after a successful one.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise
an error code is returned.
session: is a gnutls_session_t structure.
session_data: is a pointer to space to hold the session.
session_data_size: is the session_data’s size, or it will be set by the function.
Description: Returns all session parameters, in order to support resuming. The
client should call this, and keep the returned session, if he
wants to resume that current version later by calling
gnutls_session_set_data() This function must be called after a
successful handshake.
Resuming sessions is really useful and speedups connections after a successful one.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise
an error code is returned.
session: is a gnutls_session_t structure.
session_id: is a pointer to space to hold the session id.
session_id_size: is the session id’s size, or it will be set by the function.
Description: Returns the current session id. This can be used if you want to check if the next session you tried to resume was actually resumed. This is because resumed sessions have the same sessionID with the original session.
Session id is some data set by the server, that identify the current session. In TLS 1.0 and SSL 3.0 session id is always less than 32 bytes.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise
an error code is returned.
session: is a gnutls_session_t structure.
Description: Get user pointer for session. Useful in callbacks. This is the
pointer set with gnutls_session_set_ptr().
Returns: the user given pointer from the session structure, or
NULL if it was never set.
session: is a gnutls_session_t structure.
Description: Check whether session is resumed or not.
Returns: non zero if this session is resumed, or a zero if this is a new session.
session: is a gnutls_session_t structure.
session_data: is a pointer to space to hold the session.
session_data_size: is the session’s size
Description: Sets all session parameters, in order to resume a previously
established session. The session data given must be the one
returned by gnutls_session_get_data(). This function should be
called before gnutls_handshake().
Keep in mind that session resuming is advisory. The server may choose not to resume the session, thus a full handshake will be performed.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise
an error code is returned.
session: is a gnutls_session_t structure.
ptr: is the user pointer
Description: This function will set (associate) the user given pointer ptr to
the session structure. This is pointer can be accessed with
gnutls_session_get_ptr().
session: is a gnutls_session_t structure.
Description: Request that the client should attempt session resumption using SessionTicket.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, or an
error code.
Since: 2.10.0
session: is a gnutls_session_t structure.
key: key to encrypt session parameters.
Description: Request that the server should attempt session resumption using
SessionTicket. key must be initialized with
gnutls_session_ticket_key_generate().
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, or an
error code.
Since: 2.10.0
key: is a pointer to a gnutls_datum_t which will contain a newly
created key.
Description: Generate a random key to encrypt security parameters within SessionTicket.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, or an
error code.
Since: 2.10.0
session: is a gnutls_session_t structure.
Description: Sets some default priority on the ciphers, key exchange methods, macs and compression methods. This function also includes weak algorithms.
This is the same as calling: gnutls_priority_set_direct (session, "EXPORT", NULL);
This function is kept around for backwards compatibility, but
because of its wide use it is still fully supported. If you wish
to allow users to provide a string that specify which ciphers to
use (which is recommended), you should use
gnutls_priority_set_direct() or gnutls_priority_set() instead.
Returns: GNUTLS_E_SUCCESS on success, or an error code.
session: is a gnutls_session_t structure.
Description: Sets some default priority on the ciphers, key exchange methods, macs and compression methods.
This is the same as calling: gnutls_priority_set_direct (session, "NORMAL", NULL);
This function is kept around for backwards compatibility, but
because of its wide use it is still fully supported. If you wish
to allow users to provide a string that specify which ciphers to
use (which is recommended), you should use
gnutls_priority_set_direct() or gnutls_priority_set() instead.
Returns: GNUTLS_E_SUCCESS on success, or an error code.
session: is a gnutls_session_t structure.
indx: is an index of the signature algorithm to return
algo: the returned certificate type will be stored there
Description: Returns the signature algorithm specified by index that was
requested by the peer. If the specified index has no data available
this function returns GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE. If
the negotiated TLS version does not support signature algorithms
then GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE will be returned even
for the first index. The first index is 0.
This function is useful in the certificate callback functions to assist in selecting the correct certificate.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise
an error code is returned.
Since: 2.10.0
session: is a gnutls session
userdata: if non-NULL, will be set to abstract callback pointer.
Description: Retrieve the callback function, and its userdata pointer.
Returns: The function pointer set by gnutls_sign_callback_set(), or
if not set, NULL.
Deprecated: Use the PKCS 11 interfaces instead.
session: is a gnutls session
sign_func: function pointer to application’s sign callback.
userdata: void pointer that will be passed to sign callback.
Description: Set the callback function. The function must have this prototype:
typedef int (*gnutls_sign_func) (gnutls_session_t session, void *userdata, gnutls_certificate_type_t cert_type, const gnutls_datum_t * cert, const gnutls_datum_t * hash, gnutls_datum_t * signature);
The userdata parameter is passed to the sign_func verbatim, and
can be used to store application-specific data needed in the
callback function. See also gnutls_sign_callback_get().
Deprecated: Use the PKCS 11 or gnutls_privkey_t interfacess like gnutls_privkey_import_ext() instead.
name: is a MAC algorithm name
Description: The names are compared in a case insensitive way.
Returns: return a gnutls_sign_algorithm_t value corresponding to
the specified cipher, or GNUTLS_SIGN_UNKNOWN on error.
algorithm: is a sign algorithm
Description: Convert a gnutls_sign_algorithm_t value to a string.
Returns: a string that contains the name of the specified sign
algorithm, or NULL.
Description: Get a list of supported public key signature algorithms.
Returns: a (0)-terminated list of gnutls_sign_algorithm_t
integers indicating the available ciphers.
sc: is a pointer to a gnutls_srp_server_credentials_t structure.
Description: This structure is complex enough to manipulate directly thus this helper function is provided in order to allocate it.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, or an
error code.
sc: is a pointer to a gnutls_srp_server_credentials_t structure.
Description: This structure is complex enough to manipulate directly thus this helper function is provided in order to allocate it.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, or an
error code.
b64_data: contains the encoded data
result: the place where decoded data lie
Description: This function will decode the given encoded data. The decoded data will be allocated, and stored into result. It will decode using the base64 algorithm as used in libsrp.
You should use gnutls_free() to free the returned data.
Warning! This base64 encoding is not the "standard" encoding, so do not use it for non-SRP purposes.
Returns: 0 on success, or an error code.
b64_data: contain the encoded data
result: the place where decoded data will be copied
result_size: holds the size of the result
Description: This function will decode the given encoded data, using the base64 encoding found in libsrp.
Note that b64_data should be null terminated.
Warning! This base64 encoding is not the "standard" encoding, so do not use it for non-SRP purposes.
Returns: GNUTLS_E_SHORT_MEMORY_BUFFER if the buffer given is not
long enough, or 0 on success.
data: contains the raw data
result: will hold the newly allocated encoded data
Description: This function will convert the given data to printable data, using the base64 encoding. This is the encoding used in SRP password files. This function will allocate the required memory to hold the encoded data.
You should use gnutls_free() to free the returned data.
Warning! This base64 encoding is not the "standard" encoding, so do not use it for non-SRP purposes.
Returns: 0 on success, or an error code.
data: contain the raw data
result: the place where base64 data will be copied
result_size: holds the size of the result
Description: This function will convert the given data to printable data, using the base64 encoding, as used in the libsrp. This is the encoding used in SRP password files. If the provided buffer is not long enough GNUTLS_E_SHORT_MEMORY_BUFFER is returned.
Warning! This base64 encoding is not the "standard" encoding, so do not use it for non-SRP purposes.
Returns: GNUTLS_E_SHORT_MEMORY_BUFFER if the buffer given is not
long enough, or 0 on success.
sc: is a gnutls_srp_client_credentials_t structure.
Description: This structure is complex enough to manipulate directly thus this helper function is provided in order to free (deallocate) it.
sc: is a gnutls_srp_server_credentials_t structure.
Description: This structure is complex enough to manipulate directly thus this helper function is provided in order to free (deallocate) it.
session: is a gnutls session
Description: This function will return the username of the peer. This should only be called in case of SRP authentication and in case of a server. Returns NULL in case of an error.
Returns: SRP username of the peer, or NULL in case of error.
cred: is a gnutls_srp_server_credentials_t structure.
func: is the callback function
Description: This function can be used to set a callback to retrieve the username and password for client SRP authentication. The callback’s function form is:
int (*callback)(gnutls_session_t, char** username, char**password);
The username and password must be allocated using
gnutls_malloc(). username and password should be ASCII strings
or UTF-8 strings prepared using the "SASLprep" profile of
"stringprep".
The callback function will be called once per handshake before the initial hello message is sent.
The callback should not return a negative error code the second time called, since the handshake procedure will be aborted.
The callback function should return 0 on success. -1 indicates an error.
res: is a gnutls_srp_client_credentials_t structure.
username: is the user’s userid
password: is the user’s password
Description: This function sets the username and password, in a
gnutls_srp_client_credentials_t structure. Those will be used in
SRP authentication. username and password should be ASCII
strings or UTF-8 strings prepared using the "SASLprep" profile of
"stringprep".
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, or an
error code.
session: is a gnutls_session_t structure.
bits: is the number of bits
Description: This function sets the minimum accepted number of bits, for use in an SRP key exchange. If zero, the default 2048 bits will be used.
In the client side it sets the minimum accepted number of bits. If
a server sends a prime with less bits than that
GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER will be returned by the
handshake.
This function has no effect in server side.
Since: 2.6.0
res: is a gnutls_srp_server_credentials_t structure.
password_file: is the SRP password file (tpasswd)
password_conf_file: is the SRP password conf file (tpasswd.conf)
Description: This function sets the password files, in a
gnutls_srp_server_credentials_t structure. Those password files
hold usernames and verifiers and will be used for SRP
authentication.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, or an
error code.
cred: is a gnutls_srp_server_credentials_t structure.
func: is the callback function
Description: This function can be used to set a callback to retrieve the user’s SRP credentials. The callback’s function form is:
int (*callback)(gnutls_session_t, const char* username,
gnutls_datum_t* salt, gnutls_datum_t *verifier, gnutls_datum_t* g,
gnutls_datum_t* n);
username contains the actual username.
The salt, verifier, generator and prime must be filled
in using the gnutls_malloc(). For convenience prime and generator
may also be one of the static parameters defined in gnutls.h.
In case the callback returned a negative number then gnutls will assume that the username does not exist.
In order to prevent attackers from guessing valid usernames, if a user does not exist, g and n values should be filled in using a random user’s parameters. In that case the callback must return the special value (1).
The callback function will only be called once per handshake. The callback function should return 0 on success, while -1 indicates an error.
username: is the user’s name
password: is the user’s password
salt: should be some randomly generated bytes
generator: is the generator of the group
prime: is the group’s prime
res: where the verifier will be stored.
Description: This function will create an SRP verifier, as specified in
RFC2945. The prime and generator should be one of the static
parameters defined in gnutls/gnutls.h or may be generated.
The verifier will be allocated with gnutls_malloc() and will be stored in res using binary format.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, or an
error code.
error: is an error returned by a gnutls function.
Description: Return the GnuTLS error code define as a string. For example, gnutls_strerror_name (GNUTLS_E_DH_PRIME_UNACCEPTABLE) will return the string "GNUTLS_E_DH_PRIME_UNACCEPTABLE".
Returns: A string corresponding to the symbol name of the error code.
Since: 2.6.0
error: is a GnuTLS error code, a negative error code
Description: This function is similar to strerror. The difference is that it
accepts an error number returned by a gnutls function; In case of
an unknown error a descriptive string is sent instead of NULL.
Error codes are always a negative error code.
Returns: A string explaining the GnuTLS error message.
type: is a supplemental data format type
Description: Convert a gnutls_supplemental_data_format_type_t value to a
string.
Returns: a string that contains the name of the specified
supplemental data format type, or NULL for unknown types.
session: is a gnutls_session_t structure.
recv_ptr: will hold the value for the pull function
send_ptr: will hold the value for the push function
Description: Used to get the arguments of the transport functions (like PUSH
and PULL). These should have been set using
gnutls_transport_set_ptr2().
session: is a gnutls_session_t structure.
Description: Used to get the first argument of the transport function (like
PUSH and PULL). This must have been set using
gnutls_transport_set_ptr().
Returns: The first argument of the transport function.
session: is a gnutls_session_t structure.
errno_func: a callback function similar to write()
Description: This is the function where you set a function to retrieve errno
after a failed push or pull operation.
errno_func is of the form,
int (*gnutls_errno_func)(gnutls_transport_ptr_t);
and should return the errno.
Since: 2.12.0
session: is a gnutls_session_t structure.
err: error value to store in session-specific errno variable.
Description: Store err in the session-specific errno variable. Useful values
for err is EAGAIN and EINTR, other values are treated will be
treated as real errors in the push/pull function.
This function is useful in replacement push and pull functions set by
gnutls_transport_set_push_function() and
gnutls_transport_set_pull_function() under Windows, where the
replacements may not have access to the same errno
variable that is used by GnuTLS (e.g., the application is linked to
msvcr71.dll and gnutls is linked to msvcrt.dll).
session: is a gnutls_session_t structure.
recv_ptr: is the value for the pull function
send_ptr: is the value for the push function
Description: Used to set the first argument of the transport function (for push and pull callbacks). In berkeley style sockets this function will set the connection descriptor. With this function you can use two different pointers for receiving and sending.
session: is a gnutls_session_t structure.
ptr: is the value.
Description: Used to set the first argument of the transport function (for push and pull callbacks). In berkeley style sockets this function will set the connection descriptor.
session: is a gnutls_session_t structure.
pull_func: a callback function similar to read()
Description: This is the function where you set a function for gnutls to receive
data. Normally, if you use berkeley style sockets, do not need to
use this function since the default recv(2) will probably be ok.
The callback should return 0 on connection termination, a positive
number indicating the number of bytes received, and -1 on error.
gnutls_pull_func is of the form,
ssize_t (*gnutls_pull_func)(gnutls_transport_ptr_t, void*, size_t);
session: is a gnutls_session_t structure.
func: a callback function
Description: This is the function where you set a function for gnutls to know
whether data are ready to be received. It should wait for data a
given time frame in milliseconds. The callback should return 0 on
timeout, a positive number if data can be received, and -1 on error.
You’ll need to override this function if select() is not suitable
for the provided transport calls.
The callback function is used in DTLS only.
gnutls_pull_timeout_func is of the form,
ssize_t (*gnutls_pull_timeout_func)(gnutls_transport_ptr_t, unsigned int ms);
Since: 3.0.0
session: is a gnutls_session_t structure.
push_func: a callback function similar to write()
Description: This is the function where you set a push function for gnutls to
use in order to send data. If you are going to use berkeley style
sockets, you do not need to use this function since the default
send(2) will probably be ok. Otherwise you should specify this
function for gnutls to be able to send data.
The callback should return a positive number indicating the
bytes sent, and -1 on error.
push_func is of the form,
ssize_t (*gnutls_push_func)(gnutls_transport_ptr_t, const void*, size_t);
session: is a gnutls_session_t structure.
vec_func: a callback function similar to writev()
Description: Using this function you can override the default writev(2)
function for gnutls to send data. Setting this callback
instead of gnutls_transport_set_push_function() is recommended
since it introduces less overhead in the TLS handshake process.
vec_func is of the form,
ssize_t (*gnutls_vec_push_func) (gnutls_transport_ptr_t, const giovec_t * iov, int iovcnt);
Since: 2.12.0
crq: should contain a gnutls_x509_crq_t structure
key: holds a public key
Description: This function will set the public parameters from the given public key to the request.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
crt: A certificate of type gnutls_x509_crt_t
url: A PKCS 11 url
flags: One of GNUTLS_PKCS11_OBJ_* flags
Description: This function will import a PKCS 11 certificate directly from a token
without involving the gnutls_pkcs11_obj_t structure. This function will
fail if the certificate stored is not of X.509 type.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
crt: A certificate of type gnutls_x509_crt_t
pkcs11_crt: A PKCS 11 object that contains a certificate
Description: This function will import a PKCS 11 certificate to a gnutls_x509_crt_t
structure.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
certs: A list of certificates of type gnutls_x509_crt_t
cert_max: The maximum size of the list
objs: A list of PKCS 11 objects
flags: 0 for now
Description: This function will import a PKCS 11 certificate list to a list of
gnutls_x509_crt_t structure. These must not be initialized.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
crt: should contain a gnutls_x509_crt_t structure
key: holds a public key
Description: This function will set the public parameters from the given public key to the request.
Returns: On success, GNUTLS_E_SUCCESS (0) is returned, otherwise a
negative error value.
Since: 2.12.0
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by nmav on November 22, 2011 using texi2html 1.82.