



@subheading gnutls_alert_get_name
@anchor{gnutls_alert_get_name}
@deftypefun {const char *} {gnutls_alert_get_name} (gnutls_alert_description_t @var{alert})
@var{alert}: is an alert number @code{gnutls_session_t} structure.

This function will return a string that describes the given alert
number, or @code{NULL}.  See @code{gnutls_alert_get()}.

@strong{Returns:} string corresponding to @code{gnutls_alert_description_t} value.
@end deftypefun

@subheading gnutls_alert_get
@anchor{gnutls_alert_get}
@deftypefun {gnutls_alert_description_t} {gnutls_alert_get} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

This function will return the last alert number received.  This
function should be called if @code{GNUTLS_E_WARNING_ALERT_RECEIVED} or
@code{GNUTLS_E_FATAL_ALERT_RECEIVED} has been returned by a gnutls
function.  The peer may send alerts if he thinks some things were
not right. Check gnutls.h for the available alert descriptions.

If no alert has been received the returned value is undefined.

@strong{Returns:} returns the last alert received, a
@code{gnutls_alert_description_t} value.
@end deftypefun

@subheading gnutls_alert_send_appropriate
@anchor{gnutls_alert_send_appropriate}
@deftypefun {int} {gnutls_alert_send_appropriate} (gnutls_session_t @var{session}, int @var{err})
@var{session}: is a @code{gnutls_session_t} structure.

@var{err}: is an integer

Sends an alert to the peer depending on the error code returned by
a gnutls function. This function will call @code{gnutls_error_to_alert()}
to determine the appropriate alert to send.

This function may also return @code{GNUTLS_E_AGAIN}, or
@code{GNUTLS_E_INTERRUPTED}.

If the return value is @code{GNUTLS_E_INVALID_REQUEST}, then no alert has
been sent to the peer.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, otherwise
an error code is returned.
@end deftypefun

@subheading gnutls_alert_send
@anchor{gnutls_alert_send}
@deftypefun {int} {gnutls_alert_send} (gnutls_session_t @var{session}, gnutls_alert_level_t @var{level}, gnutls_alert_description_t @var{desc})
@var{session}: is a @code{gnutls_session_t} structure.

@var{level}: is the level of the alert

@var{desc}: is the alert 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 @code{GNUTLS_E_INTERRUPTED} or
@code{GNUTLS_E_AGAIN} as well.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, otherwise
an error code is returned.
@end deftypefun

@subheading gnutls_anon_allocate_client_credentials
@anchor{gnutls_anon_allocate_client_credentials}
@deftypefun {int} {gnutls_anon_allocate_client_credentials} (gnutls_anon_client_credentials_t *                                          @var{sc})
@var{sc}: is a pointer to a @code{gnutls_anon_client_credentials_t} structure.

This structure is complex enough to manipulate directly thus
this helper function is provided in order to allocate it.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_anon_allocate_server_credentials
@anchor{gnutls_anon_allocate_server_credentials}
@deftypefun {int} {gnutls_anon_allocate_server_credentials} (gnutls_anon_server_credentials_t *                                          @var{sc})
@var{sc}: is a pointer to a @code{gnutls_anon_server_credentials_t} structure.

This structure is complex enough to manipulate directly thus this
helper function is provided in order to allocate it.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_anon_free_client_credentials
@anchor{gnutls_anon_free_client_credentials}
@deftypefun {void} {gnutls_anon_free_client_credentials} (gnutls_anon_client_credentials_t @var{sc})
@var{sc}: is a @code{gnutls_anon_client_credentials_t} structure.

This structure is complex enough to manipulate directly thus this
helper function is provided in order to free (deallocate) it.
@end deftypefun

@subheading gnutls_anon_free_server_credentials
@anchor{gnutls_anon_free_server_credentials}
@deftypefun {void} {gnutls_anon_free_server_credentials} (gnutls_anon_server_credentials_t @var{sc})
@var{sc}: is a @code{gnutls_anon_server_credentials_t} structure.

This structure is complex enough to manipulate directly thus this
helper function is provided in order to free (deallocate) it.
@end deftypefun

@subheading gnutls_anon_set_params_function
@anchor{gnutls_anon_set_params_function}
@deftypefun {void} {gnutls_anon_set_params_function} (gnutls_anon_server_credentials_t @var{res}, gnutls_params_function * @var{func})
@var{res}: is a gnutls_anon_server_credentials_t structure

@var{func}: is the function to be called

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 zero on success.
@end deftypefun

@subheading gnutls_anon_set_server_dh_params
@anchor{gnutls_anon_set_server_dh_params}
@deftypefun {void} {gnutls_anon_set_server_dh_params} (gnutls_anon_server_credentials_t @var{res}, gnutls_dh_params_t @var{dh_params})
@var{res}: is a gnutls_anon_server_credentials_t structure

@var{dh_params}: is a structure that holds Diffie-Hellman parameters.

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.
@end deftypefun

@subheading gnutls_anon_set_server_params_function
@anchor{gnutls_anon_set_server_params_function}
@deftypefun {void} {gnutls_anon_set_server_params_function} (gnutls_anon_server_credentials_t @var{res}, gnutls_params_function * @var{func})
@var{res}: is a gnutls_certificate_credentials_t structure

@var{func}: is the function to be called

This function will set a callback in order for the server to get
the Diffie-Hellman parameters for anonymous authentication.  The
callback should return zero on success.
@end deftypefun

@subheading gnutls_auth_client_get_type
@anchor{gnutls_auth_client_get_type}
@deftypefun {gnutls_credentials_type_t} {gnutls_auth_client_get_type} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

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.

@strong{Returns:} The type of credentials for the client authentication
schema, a @code{gnutls_credentials_type_t} type.
@end deftypefun

@subheading gnutls_auth_get_type
@anchor{gnutls_auth_get_type}
@deftypefun {gnutls_credentials_type_t} {gnutls_auth_get_type} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

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:
@code{GNUTLS_KX_RSA}, @code{GNUTLS_KX_DHE_RSA}), the same function are to be
used to access the authentication data.

@strong{Returns:} The type of credentials for the current authentication
schema, a @code{gnutls_credentials_type_t} type.
@end deftypefun

@subheading gnutls_auth_server_get_type
@anchor{gnutls_auth_server_get_type}
@deftypefun {gnutls_credentials_type_t} {gnutls_auth_server_get_type} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

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.

@strong{Returns:} The type of credentials for the server authentication
schema, a @code{gnutls_credentials_type_t} type.
@end deftypefun

@subheading gnutls_bye
@anchor{gnutls_bye}
@deftypefun {int} {gnutls_bye} (gnutls_session_t @var{session}, gnutls_close_request_t @var{how})
@var{session}: is a @code{gnutls_session_t} structure.

@var{how}: is an integer

Terminates the current TLS/SSL connection. The connection should
have been initiated using @code{gnutls_handshake()}.  @code{how} should be one
of @code{GNUTLS_SHUT_RDWR}, @code{GNUTLS_SHUT_WR}.

In case of @code{GNUTLS_SHUT_RDWR} then the TLS connection gets
terminated and further receives and sends will be disallowed.  If
the return value is zero you may continue using the connection.
@code{GNUTLS_SHUT_RDWR} actually sends an alert containing a close
request and waits for the peer to reply with the same message.

In case of @code{GNUTLS_SHUT_WR} then the TLS connection gets terminated
and further sends will be disallowed. In order to reuse the
connection you should wait for an EOF from the peer.
@code{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, thus causing a
transmission error to the peer.  This error cannot be
distinguished from a malicious party prematurely terminating the
session, thus this behavior is not recommended.

This function may also return @code{GNUTLS_E_AGAIN} or
@code{GNUTLS_E_INTERRUPTED}; cf.  @code{gnutls_record_get_direction()}.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code, see
function documentation for entire semantics.
@end deftypefun

@subheading gnutls_certificate_activation_time_peers
@anchor{gnutls_certificate_activation_time_peers}
@deftypefun {time_t} {gnutls_certificate_activation_time_peers} (gnutls_session_t @var{session})
@var{session}: is a gnutls session

This function will return the peer's certificate activation time.
This is the creation time for openpgp keys.

@strong{Returns:} (time_t)-1 on error.

@strong{Deprecated:} @code{gnutls_certificate_verify_peers2()} now verifies activation times.
@end deftypefun

@subheading gnutls_certificate_allocate_credentials
@anchor{gnutls_certificate_allocate_credentials}
@deftypefun {int} {gnutls_certificate_allocate_credentials} (gnutls_certificate_credentials_t *                                          @var{res})
@var{res}: is a pointer to a @code{gnutls_certificate_credentials_t} structure.

This structure is complex enough to manipulate directly thus this
helper function is provided in order to allocate it.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_certificate_client_get_request_status
@anchor{gnutls_certificate_client_get_request_status}
@deftypefun {int} {gnutls_certificate_client_get_request_status} (gnutls_session_t @var{session})
@var{session}: is a gnutls session

Get whether client certificate is requested or not.

@strong{Returns:} 0 if the peer (server) did not request client
authentication or 1 otherwise, or a negative value in case of
error.
@end deftypefun

@subheading gnutls_certificate_client_set_retrieve_function
@anchor{gnutls_certificate_client_set_retrieve_function}
@deftypefun {void} {gnutls_certificate_client_set_retrieve_function} (gnutls_certificate_credentials_t @var{cred}, gnutls_certificate_client_retrieve_function * @var{func})
@var{cred}: is a @code{gnutls_certificate_credentials_t} structure.

@var{func}: is the callback function

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_retr_st* st);

@code{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 @code{gnutls_x509_rdn_get()}.

@code{pk_algos} contains a list with server's acceptable signature algorithms.
The certificate returned should support the server's given algorithms.

@code{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.
@end deftypefun

@subheading gnutls_certificate_expiration_time_peers
@anchor{gnutls_certificate_expiration_time_peers}
@deftypefun {time_t} {gnutls_certificate_expiration_time_peers} (gnutls_session_t @var{session})
@var{session}: is a gnutls session

This function will return the peer's certificate expiration time.

@strong{Returns:} (time_t)-1 on error.

@strong{Deprecated:} @code{gnutls_certificate_verify_peers2()} now verifies expiration times.
@end deftypefun

@subheading gnutls_certificate_free_ca_names
@anchor{gnutls_certificate_free_ca_names}
@deftypefun {void} {gnutls_certificate_free_ca_names} (gnutls_certificate_credentials_t @var{sc})
@var{sc}: is a @code{gnutls_certificate_credentials_t} structure.

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.
@end deftypefun

@subheading gnutls_certificate_free_cas
@anchor{gnutls_certificate_free_cas}
@deftypefun {void} {gnutls_certificate_free_cas} (gnutls_certificate_credentials_t @var{sc})
@var{sc}: is a @code{gnutls_certificate_credentials_t} structure.

This function will delete all the CAs associated with the given
credentials. Servers that do not use
@code{gnutls_certificate_verify_peers2()} may call this to save some
memory.
@end deftypefun

@subheading gnutls_certificate_free_credentials
@anchor{gnutls_certificate_free_credentials}
@deftypefun {void} {gnutls_certificate_free_credentials} (gnutls_certificate_credentials_t @var{sc})
@var{sc}: is a @code{gnutls_certificate_credentials_t} structure.

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).
@end deftypefun

@subheading gnutls_certificate_free_crls
@anchor{gnutls_certificate_free_crls}
@deftypefun {void} {gnutls_certificate_free_crls} (gnutls_certificate_credentials_t @var{sc})
@var{sc}: is a @code{gnutls_certificate_credentials_t} structure.

This function will delete all the CRLs associated
with the given credentials.
@end deftypefun

@subheading gnutls_certificate_free_keys
@anchor{gnutls_certificate_free_keys}
@deftypefun {void} {gnutls_certificate_free_keys} (gnutls_certificate_credentials_t @var{sc})
@var{sc}: is a @code{gnutls_certificate_credentials_t} structure.

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.
@end deftypefun

@subheading gnutls_certificate_get_issuer
@anchor{gnutls_certificate_get_issuer}
@deftypefun {int} {gnutls_certificate_get_issuer} (gnutls_certificate_credentials_t @var{sc}, gnutls_x509_crt_t @var{cert}, gnutls_x509_crt_t* @var{issuer}, unsigned int @var{flags})
@var{sc}: is a @code{gnutls_certificate_credentials_t} structure.

@var{cert}: is the certificate to find issuer for

@var{issuer}: Will hold the issuer if any. Should be treated as constant.

@var{flags}: Use zero.

This function will return the issuer of a given certificate.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_certificate_get_openpgp_keyring
@anchor{gnutls_certificate_get_openpgp_keyring}
@deftypefun {void} {gnutls_certificate_get_openpgp_keyring} (gnutls_certificate_credentials_t @var{sc}, gnutls_openpgp_keyring_t * @var{keyring})
@var{sc}: is a @code{gnutls_certificate_credentials_t} structure.

@var{keyring}: the exported keyring. Should be treated as constant

This function will export the OpenPGP keyring associated with the
given credentials.

@strong{Since:} 2.4.0
@end deftypefun

@subheading gnutls_certificate_get_ours
@anchor{gnutls_certificate_get_ours}
@deftypefun {const gnutls_datum_t *} {gnutls_certificate_get_ours} (gnutls_session_t @var{session})
@var{session}: is a gnutls session

Get the certificate as sent to the peer, in the last handshake.
These certificates are in raw format.  In X.509 this is a
certificate list. In OpenPGP this is a single certificate.

@strong{Returns:} return a pointer to a @code{gnutls_datum_t} containing our
certificates, or @code{NULL} in case of an error or if no certificate
was used.
@end deftypefun

@subheading gnutls_certificate_get_peers
@anchor{gnutls_certificate_get_peers}
@deftypefun {const gnutls_datum_t *} {gnutls_certificate_get_peers} (gnutls_session_t                               @var{session}, unsigned int * @var{list_size})
@var{session}: is a gnutls session

@var{list_size}: is the length of the certificate list

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.

@strong{Returns:} return a pointer to a @code{gnutls_datum_t} containing our
certificates, or @code{NULL} in case of an error or if no certificate
was used.
@end deftypefun

@subheading gnutls_certificate_get_x509_cas
@anchor{gnutls_certificate_get_x509_cas}
@deftypefun {void} {gnutls_certificate_get_x509_cas} (gnutls_certificate_credentials_t @var{sc}, gnutls_x509_crt_t ** @var{x509_ca_list}, unsigned int * @var{ncas})
@var{sc}: is a @code{gnutls_certificate_credentials_t} structure.

@var{x509_ca_list}: will point to the CA list. Should be treated as constant

@var{ncas}: the number of CAs

This function will export all the CAs associated with the given
credentials.

@strong{Since:} 2.4.0
@end deftypefun

@subheading gnutls_certificate_get_x509_crls
@anchor{gnutls_certificate_get_x509_crls}
@deftypefun {void} {gnutls_certificate_get_x509_crls} (gnutls_certificate_credentials_t @var{sc}, gnutls_x509_crl_t ** @var{x509_crl_list}, unsigned int * @var{ncrls})
@var{sc}: is a @code{gnutls_certificate_credentials_t} structure.

@var{x509_crl_list}: the exported CRL list. Should be treated as constant

@var{ncrls}: the number of exported CRLs

This function will export all the CRLs associated with the given
credentials.

@strong{Since:} 2.4.0
@end deftypefun

@subheading gnutls_certificate_send_x509_rdn_sequence
@anchor{gnutls_certificate_send_x509_rdn_sequence}
@deftypefun {void} {gnutls_certificate_send_x509_rdn_sequence} (gnutls_session_t @var{session}, int @var{status})
@var{session}: is a pointer to a @code{gnutls_session_t} structure.

@var{status}: is 0 or 1

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.
@end deftypefun

@subheading gnutls_certificate_server_set_request
@anchor{gnutls_certificate_server_set_request}
@deftypefun {void} {gnutls_certificate_server_set_request} (gnutls_session_t @var{session}, gnutls_certificate_request_t @var{req})
@var{session}: is a @code{gnutls_session_t} structure.

@var{req}: is one of GNUTLS_CERT_REQUEST, GNUTLS_CERT_REQUIRE

This function specifies if we (in case of a server) are going to
send a certificate request message to the client. If @code{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.
@end deftypefun

@subheading gnutls_certificate_server_set_retrieve_function
@anchor{gnutls_certificate_server_set_retrieve_function}
@deftypefun {void} {gnutls_certificate_server_set_retrieve_function} (gnutls_certificate_credentials_t @var{cred}, gnutls_certificate_server_retrieve_function * @var{func})
@var{cred}: is a @code{gnutls_certificate_credentials_t} structure.

@var{func}: is the callback function

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, gnutls_retr_st* st);

@code{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.
@end deftypefun

@subheading gnutls_certificate_set_dh_params
@anchor{gnutls_certificate_set_dh_params}
@deftypefun {void} {gnutls_certificate_set_dh_params} (gnutls_certificate_credentials_t @var{res}, gnutls_dh_params_t @var{dh_params})
@var{res}: is a gnutls_certificate_credentials_t structure

@var{dh_params}: is a structure that holds Diffie-Hellman parameters.

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.
@end deftypefun

@subheading gnutls_certificate_set_params_function
@anchor{gnutls_certificate_set_params_function}
@deftypefun {void} {gnutls_certificate_set_params_function} (gnutls_certificate_credentials_t @var{res}, gnutls_params_function * @var{func})
@var{res}: is a gnutls_certificate_credentials_t structure

@var{func}: is the function to be called

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 zero on success.
@end deftypefun

@subheading gnutls_certificate_set_retrieve_function
@anchor{gnutls_certificate_set_retrieve_function}
@deftypefun {void} {gnutls_certificate_set_retrieve_function} (gnutls_certificate_credentials_t @var{cred}, gnutls_certificate_retrieve_function * @var{func})
@var{cred}: is a @code{gnutls_certificate_credentials_t} structure.

@var{func}: is the callback function

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_retr2_st* st);

@code{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 @code{gnutls_x509_rdn_get()}.

@code{pk_algos} contains a list with server's acceptable signature algorithms.
The certificate returned should support the server's given algorithms.

@code{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.
@end deftypefun

@subheading gnutls_certificate_set_rsa_export_params
@anchor{gnutls_certificate_set_rsa_export_params}
@deftypefun {void} {gnutls_certificate_set_rsa_export_params} (gnutls_certificate_credentials_t                                           @var{res}, gnutls_rsa_params_t @var{rsa_params})
@var{res}: is a gnutls_certificate_credentials_t structure

@var{rsa_params}: is a structure that holds temporary RSA parameters.

This function will set the temporary RSA parameters for a
certificate server to use.  These parameters will be used in
RSA-EXPORT cipher suites.
@end deftypefun

@subheading gnutls_certificate_set_verify_flags
@anchor{gnutls_certificate_set_verify_flags}
@deftypefun {void} {gnutls_certificate_set_verify_flags} (gnutls_certificate_credentials_t                                      @var{res}, unsigned int @var{flags})
@var{res}: is a gnutls_certificate_credentials_t structure

@var{flags}: are the flags

This function will set the flags to be used at verification of the
certificates.  Flags must be OR of the
@code{gnutls_certificate_verify_flags} enumerations.
@end deftypefun

@subheading gnutls_certificate_set_verify_function
@anchor{gnutls_certificate_set_verify_function}
@deftypefun {void} {gnutls_certificate_set_verify_function} (gnutls_certificate_credentials_t @var{cred}, gnutls_certificate_verify_function * @var{func})
@var{cred}: is a @code{gnutls_certificate_credentials_t} structure.

@var{func}: is the callback function

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 @code{gnutls_certificate_verify_peers2()},
@code{gnutls_certificate_type_get()}, @code{gnutls_certificate_get_peers()} functions
can be used.

The callback function should return 0 for the handshake to continue
or non-zero to terminate.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_certificate_set_verify_limits
@anchor{gnutls_certificate_set_verify_limits}
@deftypefun {void} {gnutls_certificate_set_verify_limits} (gnutls_certificate_credentials_t @var{res}, unsigned int @var{max_bits}, unsigned int @var{max_depth})
@var{res}: is a gnutls_certificate_credentials structure

@var{max_bits}: is the number of bits of an acceptable certificate (default 8200)

@var{max_depth}: is maximum depth of the verification of a certificate chain (default 5)

This function will set some upper limits for the default
verification function, @code{gnutls_certificate_verify_peers2()}, to avoid
denial of service attacks.  You can set them to zero to disable
limits.
@end deftypefun

@subheading gnutls_certificate_set_x509_crl_file
@anchor{gnutls_certificate_set_x509_crl_file}
@deftypefun {int} {gnutls_certificate_set_x509_crl_file} (gnutls_certificate_credentials_t @var{res}, const char * @var{crlfile}, gnutls_x509_crt_fmt_t @var{type})
@var{res}: is a @code{gnutls_certificate_credentials_t} structure.

@var{crlfile}: is a file containing the list of verified CRLs (DER or PEM list)

@var{type}: is PEM or DER

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
@code{gnutls_certificate_verify_peers2()}.
This function may be called multiple times.

@strong{Returns:} number of CRLs processed or a negative value on error.
@end deftypefun

@subheading gnutls_certificate_set_x509_crl_mem
@anchor{gnutls_certificate_set_x509_crl_mem}
@deftypefun {int} {gnutls_certificate_set_x509_crl_mem} (gnutls_certificate_credentials_t @var{res}, const gnutls_datum_t * @var{CRL}, gnutls_x509_crt_fmt_t @var{type})
@var{res}: is a @code{gnutls_certificate_credentials_t} structure.

@var{CRL}: is a list of trusted CRLs. They should have been verified before.

@var{type}: is DER or PEM

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
@code{gnutls_certificate_verify_peers2()}.  This function may be called
multiple times.

@strong{Returns:} number of CRLs processed, or a negative value on error.
@end deftypefun

@subheading gnutls_certificate_set_x509_crl
@anchor{gnutls_certificate_set_x509_crl}
@deftypefun {int} {gnutls_certificate_set_x509_crl} (gnutls_certificate_credentials_t @var{res}, gnutls_x509_crl_t * @var{crl_list}, int @var{crl_list_size})
@var{res}: is a @code{gnutls_certificate_credentials_t} structure.

@var{crl_list}: is a list of trusted CRLs. They should have been verified before.

@var{crl_list_size}: holds the size of the crl_list

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
@code{gnutls_certificate_verify_peers2()}.  This function may be called
multiple times.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.

@strong{Since:} 2.4.0
@end deftypefun

@subheading gnutls_certificate_set_x509_key_file
@anchor{gnutls_certificate_set_x509_key_file}
@deftypefun {int} {gnutls_certificate_set_x509_key_file} (gnutls_certificate_credentials_t @var{res}, const char * @var{certfile}, const char * @var{keyfile}, gnutls_x509_crt_fmt_t @var{type})
@var{res}: is a @code{gnutls_certificate_credentials_t} structure.

@var{certfile}: is a file that containing the certificate list (path) for
the specified private key, in PKCS7 format, or a list of certificates

@var{keyfile}: is a file that contains the private key

@var{type}: is PEM or DER

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 @code{certfile}.

Currently only PKCS-1 encoded RSA and DSA private keys are accepted by
this function.

This function can also accept PKCS @code{11} URLs. In that case it
will import the private key and certificate indicated by the urls.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_certificate_set_x509_key_mem
@anchor{gnutls_certificate_set_x509_key_mem}
@deftypefun {int} {gnutls_certificate_set_x509_key_mem} (gnutls_certificate_credentials_t @var{res}, const gnutls_datum_t * @var{cert}, const gnutls_datum_t * @var{key}, gnutls_x509_crt_fmt_t @var{type})
@var{res}: is a @code{gnutls_certificate_credentials_t} structure.

@var{cert}: contains a certificate list (path) for the specified private key

@var{key}: is the private key, or @code{NULL}

@var{type}: is PEM or DER

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).

@strong{Currently are supported:} RSA PKCS-1 encoded private keys,
DSA private keys.

DSA private keys are encoded the OpenSSL way, which is an ASN.1
DER sequence of 6 INTEGERs - version, p, q, g, pub, priv.

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 @code{key} may be @code{NULL} if you are using a sign callback, see
@code{gnutls_sign_callback_set()}.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_certificate_set_x509_key
@anchor{gnutls_certificate_set_x509_key}
@deftypefun {int} {gnutls_certificate_set_x509_key} (gnutls_certificate_credentials_t @var{res}, gnutls_x509_crt_t * @var{cert_list}, int @var{cert_list_size}, gnutls_x509_privkey_t @var{key})
@var{res}: is a @code{gnutls_certificate_credentials_t} structure.

@var{cert_list}: contains a certificate list (path) for the specified private key

@var{cert_list_size}: holds the size of the certificate list

@var{key}: is a gnutls_x509_privkey_t key

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 @code{cert_list}.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.

@strong{Since:} 2.4.0
@end deftypefun

@subheading gnutls_certificate_set_x509_simple_pkcs12_file
@anchor{gnutls_certificate_set_x509_simple_pkcs12_file}
@deftypefun {int} {gnutls_certificate_set_x509_simple_pkcs12_file} (gnutls_certificate_credentials_t @var{res}, const char * @var{pkcs12file}, gnutls_x509_crt_fmt_t @var{type}, const char * @var{password})
@var{res}: is a @code{gnutls_certificate_credentials_t} structure.

@var{pkcs12file}: filename of file containing PKCS@code{12} blob.

@var{type}: is PEM or DER of the @code{pkcs12file}.

@var{password}: optional password used to decrypt PKCS@code{12} file, bags and keys.

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).

@strong{MAC:} ed PKCS@code{12} files are supported.  Encrypted PKCS@code{12} bags are
supported.  Encrypted PKCS@code{8} private keys are supported.  However,
only password based security, and the same password for all
operations, are supported.

The private keys may be RSA PKCS@code{1} or DSA private keys encoded in
the OpenSSL way.

PKCS@code{12} 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 PKCS@code{12} 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.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_certificate_set_x509_simple_pkcs12_mem
@anchor{gnutls_certificate_set_x509_simple_pkcs12_mem}
@deftypefun {int} {gnutls_certificate_set_x509_simple_pkcs12_mem} (gnutls_certificate_credentials_t @var{res}, const gnutls_datum_t * @var{p12blob}, gnutls_x509_crt_fmt_t @var{type}, const char * @var{password})
@var{res}: is a @code{gnutls_certificate_credentials_t} structure.

@var{p12blob}: the PKCS@code{12} blob.

@var{type}: is PEM or DER of the @code{pkcs12file}.

@var{password}: optional password used to decrypt PKCS@code{12} file, bags and keys.

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).

@strong{MAC:} ed PKCS@code{12} files are supported.  Encrypted PKCS@code{12} bags are
supported.  Encrypted PKCS@code{8} private keys are supported.  However,
only password based security, and the same password for all
operations, are supported.

The private keys may be RSA PKCS@code{1} or DSA private keys encoded in
the OpenSSL way.

PKCS@code{12} 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 PKCS@code{12} 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.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.

@strong{Since:} 2.8.0
@end deftypefun

@subheading gnutls_certificate_set_x509_trust_file
@anchor{gnutls_certificate_set_x509_trust_file}
@deftypefun {int} {gnutls_certificate_set_x509_trust_file} (gnutls_certificate_credentials_t @var{res}, const char * @var{cafile}, gnutls_x509_crt_fmt_t @var{type})
@var{res}: is a @code{gnutls_certificate_credentials_t} structure.

@var{cafile}: is a file containing the list of trusted CAs (DER or PEM list)

@var{type}: is PEM or DER

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
@code{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 @code{gnutls_certificate_send_x509_rdn_sequence()}.

This function can also accept PKCS @code{11} URLs. In that case it
will import all certificates that are marked as trusted.

@strong{Returns:} number of certificates processed, or a negative value on
error.
@end deftypefun

@subheading gnutls_certificate_set_x509_trust_mem
@anchor{gnutls_certificate_set_x509_trust_mem}
@deftypefun {int} {gnutls_certificate_set_x509_trust_mem} (gnutls_certificate_credentials_t @var{res}, const gnutls_datum_t * @var{ca}, gnutls_x509_crt_fmt_t @var{type})
@var{res}: is a @code{gnutls_certificate_credentials_t} structure.

@var{ca}: is a list of trusted CAs or a DER certificate

@var{type}: is DER or PEM

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
@code{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
@code{gnutls_certificate_send_x509_rdn_sequence()}.

@strong{Returns:} the number of certificates processed or a negative value
on error.
@end deftypefun

@subheading gnutls_certificate_set_x509_trust
@anchor{gnutls_certificate_set_x509_trust}
@deftypefun {int} {gnutls_certificate_set_x509_trust} (gnutls_certificate_credentials_t @var{res}, gnutls_x509_crt_t * @var{ca_list}, int @var{ca_list_size})
@var{res}: is a @code{gnutls_certificate_credentials_t} structure.

@var{ca_list}: is a list of trusted CAs

@var{ca_list_size}: holds the size of the CA list

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
@code{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
@code{gnutls_certificate_send_x509_rdn_sequence()}.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.

@strong{Since:} 2.4.0
@end deftypefun

@subheading gnutls_certificate_type_get_id
@anchor{gnutls_certificate_type_get_id}
@deftypefun {gnutls_certificate_type_t} {gnutls_certificate_type_get_id} (const char * @var{name})
@var{name}: is a certificate type name

The names are compared in a case insensitive way.

@strong{Returns:} a @code{gnutls_certificate_type_t} for the specified in a
string certificate type, or @code{GNUTLS_CRT_UNKNOWN} on error.
@end deftypefun

@subheading gnutls_certificate_type_get_name
@anchor{gnutls_certificate_type_get_name}
@deftypefun {const char *} {gnutls_certificate_type_get_name} (gnutls_certificate_type_t @var{type})
@var{type}: is a certificate type

Convert a @code{gnutls_certificate_type_t} type to a string.

@strong{Returns:} a string that contains the name of the specified
certificate type, or @code{NULL} in case of unknown types.
@end deftypefun

@subheading gnutls_certificate_type_get
@anchor{gnutls_certificate_type_get}
@deftypefun {gnutls_certificate_type_t} {gnutls_certificate_type_get} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

The certificate type is by default X.509, unless it is negotiated
as a TLS extension.

@strong{Returns:} the currently used @code{gnutls_certificate_type_t} certificate
type.
@end deftypefun

@subheading gnutls_certificate_type_list
@anchor{gnutls_certificate_type_list}
@deftypefun {const gnutls_certificate_type_t *} {gnutls_certificate_type_list} ( @var{void})

Get a list of certificate types.  Note that to be able to use
OpenPGP certificates, you must link to libgnutls-extra and call
@code{gnutls_global_init_extra()}.

@strong{Returns:} a zero-terminated list of @code{gnutls_certificate_type_t}
integers indicating the available certificate types.
@end deftypefun

@subheading gnutls_certificate_type_set_priority
@anchor{gnutls_certificate_type_set_priority}
@deftypefun {int} {gnutls_certificate_type_set_priority} (gnutls_session_t @var{session}, const int * @var{list})
@var{session}: is a @code{gnutls_session_t} structure.

@var{list}: is a 0 terminated list of gnutls_certificate_type_t elements.

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.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_certificate_verify_peers2
@anchor{gnutls_certificate_verify_peers2}
@deftypefun {int} {gnutls_certificate_verify_peers2} (gnutls_session_t @var{session}, unsigned int * @var{status})
@var{session}: is a gnutls session

@var{status}: is the output of the verification

This function will try to verify the peer's certificate and return
its status (trusted, invalid etc.).  The value of @code{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
@code{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 @code{gnutls_x509_crt_list_verify()} with the CAs in
the credentials as trusted CAs.

@strong{Returns:} a negative error code on error and zero on success.
@end deftypefun

@subheading gnutls_certificate_verify_peers
@anchor{gnutls_certificate_verify_peers}
@deftypefun {int} {gnutls_certificate_verify_peers} (gnutls_session_t @var{session})
@var{session}: is a gnutls session

This function will try to verify the peer's certificate and return
its status (trusted, invalid etc.).  However you must also check
the peer's name in order to check if the verified certificate
belongs to the actual peer.

This function uses @code{gnutls_x509_crt_list_verify()}.

@strong{Returns:} one or more of the @code{gnutls_certificate_status_t}
enumerated elements bitwise or'd, or a negative value on error.

@strong{Deprecated:} Use @code{gnutls_certificate_verify_peers2()} instead.
@end deftypefun

@subheading gnutls_check_version
@anchor{gnutls_check_version}
@deftypefun {const char *} {gnutls_check_version} (const char * @var{req_version})
@var{req_version}: version string to compare with, or @code{NULL}.

Check GnuTLS Library version.

See @code{GNUTLS_VERSION} for a suitable @code{req_version} string.

@strong{Return value:} Check that the version of the library is at
minimum the one given as a string in @code{req_version} and return the
actual version string of the library; return @code{NULL} if the
condition is not met.  If @code{NULL} is passed to this function no
check is done and only the version string is returned.
@end deftypefun

@subheading gnutls_cipher_decrypt2
@anchor{gnutls_cipher_decrypt2}
@deftypefun {int} {gnutls_cipher_decrypt2} (gnutls_cipher_hd_t @var{handle}, const void * @var{ciphertext}, size_t @var{ciphertextlen}, void * @var{text}, size_t @var{textlen})
@var{handle}: is a @code{gnutls_cipher_hd_t} structure.

@var{ciphertext}: the data to encrypt

@var{ciphertextlen}: The length of data to encrypt

@var{text}: the decrypted data

@var{textlen}: The available length for decrypted data

This function will decrypt the given data using the algorithm
specified by the context.

@strong{Returns:} Zero or a negative value on error.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_cipher_decrypt
@anchor{gnutls_cipher_decrypt}
@deftypefun {int} {gnutls_cipher_decrypt} (gnutls_cipher_hd_t @var{handle}, void * @var{ciphertext}, size_t @var{ciphertextlen})
@var{handle}: is a @code{gnutls_cipher_hd_t} structure.

@var{ciphertext}: the data to encrypt

@var{ciphertextlen}: The length of data to encrypt

This function will decrypt the given data using the algorithm
specified by the context.

@strong{Returns:} Zero or a negative value on error.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_cipher_deinit
@anchor{gnutls_cipher_deinit}
@deftypefun {void} {gnutls_cipher_deinit} (gnutls_cipher_hd_t @var{handle})
@var{handle}: is a @code{gnutls_cipher_hd_t} structure.

This function will deinitialize all resources occupied by the given
encryption context.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_cipher_encrypt2
@anchor{gnutls_cipher_encrypt2}
@deftypefun {int} {gnutls_cipher_encrypt2} (gnutls_cipher_hd_t @var{handle}, void * @var{text}, size_t @var{textlen}, void * @var{ciphertext}, size_t @var{ciphertextlen})
@var{handle}: is a @code{gnutls_cipher_hd_t} structure.

@var{text}: the data to encrypt

@var{textlen}: The length of data to encrypt

@var{ciphertext}: the encrypted data

@var{ciphertextlen}: The available length for encrypted data

This function will encrypt the given data using the algorithm
specified by the context.

@strong{Returns:} Zero or a negative value on error.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_cipher_encrypt
@anchor{gnutls_cipher_encrypt}
@deftypefun {int} {gnutls_cipher_encrypt} (gnutls_cipher_hd_t @var{handle}, void * @var{text}, size_t @var{textlen})
@var{handle}: is a @code{gnutls_cipher_hd_t} structure.

@var{text}: the data to encrypt

@var{textlen}: The length of data to encrypt

This function will encrypt the given data using the algorithm
specified by the context.

@strong{Returns:} Zero or a negative value on error.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_cipher_get_block_size
@anchor{gnutls_cipher_get_block_size}
@deftypefun {int} {gnutls_cipher_get_block_size} (gnutls_cipher_algorithm_t @var{algorithm})
@var{algorithm}: is an encryption algorithm

Get block size for encryption algorithm.

@strong{Returns:} block size for encryption algorithm.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_cipher_get_id
@anchor{gnutls_cipher_get_id}
@deftypefun {gnutls_cipher_algorithm_t} {gnutls_cipher_get_id} (const char * @var{name})
@var{name}: is a MAC algorithm name

The names are compared in a case insensitive way.

@strong{Returns:} return a @code{gnutls_cipher_algorithm_t} value corresponding to
the specified cipher, or @code{GNUTLS_CIPHER_UNKNOWN} on error.
@end deftypefun

@subheading gnutls_cipher_get_key_size
@anchor{gnutls_cipher_get_key_size}
@deftypefun {size_t} {gnutls_cipher_get_key_size} (gnutls_cipher_algorithm_t @var{algorithm})
@var{algorithm}: is an encryption algorithm

Get key size for cipher.

@strong{Returns:} length (in bytes) of the given cipher's key size, or 0 if
the given cipher is invalid.
@end deftypefun

@subheading gnutls_cipher_get_name
@anchor{gnutls_cipher_get_name}
@deftypefun {const char *} {gnutls_cipher_get_name} (gnutls_cipher_algorithm_t @var{algorithm})
@var{algorithm}: is an encryption algorithm

Convert a @code{gnutls_cipher_algorithm_t} type to a string.

@strong{Returns:} a pointer to a string that contains the name of the
specified cipher, or @code{NULL}.
@end deftypefun

@subheading gnutls_cipher_get
@anchor{gnutls_cipher_get}
@deftypefun {gnutls_cipher_algorithm_t} {gnutls_cipher_get} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

Get currently used cipher.

@strong{Returns:} the currently used cipher, a @code{gnutls_cipher_algorithm_t}
type.
@end deftypefun

@subheading gnutls_cipher_init
@anchor{gnutls_cipher_init}
@deftypefun {int} {gnutls_cipher_init} (gnutls_cipher_hd_t * @var{handle}, gnutls_cipher_algorithm_t @var{cipher}, const gnutls_datum_t * @var{key}, const gnutls_datum_t * @var{iv})
@var{handle}: is a @code{gnutls_cipher_hd_t} structure.

@var{cipher}: the encryption algorithm to use

@var{key}: The key to be used for encryption

@var{iv}: The IV to use (if not applicable set NULL)

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.

@strong{Returns:} Zero or a negative value on error.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_cipher_list
@anchor{gnutls_cipher_list}
@deftypefun {const gnutls_cipher_algorithm_t *} {gnutls_cipher_list} ( @var{void})

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., PKCS@code{8} or similar).

@strong{Returns:} a zero-terminated list of @code{gnutls_cipher_algorithm_t}
integers indicating the available ciphers.
@end deftypefun

@subheading gnutls_cipher_set_priority
@anchor{gnutls_cipher_set_priority}
@deftypefun {int} {gnutls_cipher_set_priority} (gnutls_session_t @var{session}, const int * @var{list})
@var{session}: is a @code{gnutls_session_t} structure.

@var{list}: is a 0 terminated list of gnutls_cipher_algorithm_t elements.

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.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_cipher_suite_get_name
@anchor{gnutls_cipher_suite_get_name}
@deftypefun {const char *} {gnutls_cipher_suite_get_name} (gnutls_kx_algorithm_t @var{kx_algorithm}, gnutls_cipher_algorithm_t @var{cipher_algorithm}, gnutls_mac_algorithm_t @var{mac_algorithm})
@var{kx_algorithm}: is a Key exchange algorithm

@var{cipher_algorithm}: is a cipher algorithm

@var{mac_algorithm}: is a MAC algorithm

Note that the full cipher suite name must be prepended by TLS or
SSL depending of the protocol in use.

@strong{Returns:} a string that contains the name of a TLS cipher suite,
specified by the given algorithms, or @code{NULL}.
@end deftypefun

@subheading gnutls_cipher_suite_info
@anchor{gnutls_cipher_suite_info}
@deftypefun {const char *} {gnutls_cipher_suite_info} (size_t @var{idx}, char * @var{cs_id}, gnutls_kx_algorithm_t * @var{kx}, gnutls_cipher_algorithm_t * @var{cipher}, gnutls_mac_algorithm_t * @var{mac}, gnutls_protocol_t * @var{min_version})
@var{idx}: index of cipher suite to get information about, starts on 0.

@var{cs_id}: output buffer with room for 2 bytes, indicating cipher suite value

@var{kx}: output variable indicating key exchange algorithm, or @code{NULL}.

@var{cipher}: output variable indicating cipher, or @code{NULL}.

@var{mac}: output variable indicating MAC algorithm, or @code{NULL}.

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.

@strong{Returns:} the name of @code{idx} cipher suite, and set the information
about the cipher suite in the output variables.  If @code{idx} is out of
bounds, @code{NULL} is returned.
@end deftypefun

@subheading gnutls_compression_get_id
@anchor{gnutls_compression_get_id}
@deftypefun {gnutls_compression_method_t} {gnutls_compression_get_id} (const char * @var{name})
@var{name}: is a compression method name

The names are compared in a case insensitive way.

@strong{Returns:} an id of the specified in a string compression method, or
@code{GNUTLS_COMP_UNKNOWN} on error.
@end deftypefun

@subheading gnutls_compression_get_name
@anchor{gnutls_compression_get_name}
@deftypefun {const char *} {gnutls_compression_get_name} (gnutls_compression_method_t @var{algorithm})
@var{algorithm}: is a Compression algorithm

Convert a @code{gnutls_compression_method_t} value to a string.

@strong{Returns:} a pointer to a string that contains the name of the
specified compression algorithm, or @code{NULL}.
@end deftypefun

@subheading gnutls_compression_get
@anchor{gnutls_compression_get}
@deftypefun {gnutls_compression_method_t} {gnutls_compression_get} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

Get currently used compression algorithm.

@strong{Returns:} the currently used compression method, a
@code{gnutls_compression_method_t} value.
@end deftypefun

@subheading gnutls_compression_list
@anchor{gnutls_compression_list}
@deftypefun {const gnutls_compression_method_t *} {gnutls_compression_list} ( @var{void})

Get a list of compression methods.  Note that to be able to use LZO
compression, you must link to libgnutls-extra and call
@code{gnutls_global_init_extra()}.

@strong{Returns:} a zero-terminated list of @code{gnutls_compression_method_t}
integers indicating the available compression methods.
@end deftypefun

@subheading gnutls_compression_set_priority
@anchor{gnutls_compression_set_priority}
@deftypefun {int} {gnutls_compression_set_priority} (gnutls_session_t @var{session}, const int * @var{list})
@var{session}: is a @code{gnutls_session_t} structure.

@var{list}: is a 0 terminated list of gnutls_compression_method_t elements.

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.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_credentials_clear
@anchor{gnutls_credentials_clear}
@deftypefun {void} {gnutls_credentials_clear} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

Clears all the credentials previously set in this session.
@end deftypefun

@subheading gnutls_credentials_set
@anchor{gnutls_credentials_set}
@deftypefun {int} {gnutls_credentials_set} (gnutls_session_t @var{session}, gnutls_credentials_type_t @var{type}, void * @var{cred})
@var{session}: is a @code{gnutls_session_t} structure.

@var{type}: is the type of the credentials

@var{cred}: is a pointer to a structure.

Sets the needed credentials for the specified type.  Eg username,
password - or public and private keys etc.  The @code{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 @code{gnutls_deinit()}.

For @code{GNUTLS_CRD_ANON}, @code{cred} should be
@code{gnutls_anon_client_credentials_t} in case of a client.  In case of
a server it should be @code{gnutls_anon_server_credentials_t}.

For @code{GNUTLS_CRD_SRP}, @code{cred} should be @code{gnutls_srp_client_credentials_t}
in case of a client, and @code{gnutls_srp_server_credentials_t}, in case
of a server.

For @code{GNUTLS_CRD_CERTIFICATE}, @code{cred} should be
@code{gnutls_certificate_credentials_t}.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (zero) is returned,
otherwise an error code is returned.
@end deftypefun

@subheading gnutls_crypto_bigint_register2
@anchor{gnutls_crypto_bigint_register2}
@deftypefun {int} {gnutls_crypto_bigint_register2} (int @var{priority}, int @var{version}, const gnutls_crypto_bigint_st * @var{s})
@var{priority}: is the priority of the interface

@var{version}: should be set to @code{GNUTLS_CRYPTO_API_VERSION}

@var{s}: is a structure holding new interface's data

This function will register an interface for gnutls to operate
on big integers. Any interface registered will override
the included interface. The interface with the lowest
priority will be used by gnutls.

Note that the bigint interface must interoperate with the public
key interface. Thus if this interface is updated the
@code{gnutls_crypto_pk_register()} should also be used.

This function should be called before @code{gnutls_global_init()}.

For simplicity you can use the convenience @code{gnutls_crypto_bigint_register()}
macro.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, otherwise an error.

@strong{Since:} 2.6.0
@end deftypefun

@subheading gnutls_crypto_cipher_register2
@anchor{gnutls_crypto_cipher_register2}
@deftypefun {int} {gnutls_crypto_cipher_register2} (int @var{priority}, int @var{version}, const gnutls_crypto_cipher_st * @var{s})
@var{priority}: is the priority of the cipher interface

@var{version}: should be set to @code{GNUTLS_CRYPTO_API_VERSION}

@var{s}: is a structure holding new interface's data

This function will register a cipher interface to be used by
gnutls. Any interface registered will override the included engine
and by convention kernel implemented interfaces should have
priority of 90. The interface with the lowest priority will be used
by gnutls.

This function should be called before @code{gnutls_global_init()}.

For simplicity you can use the convenience
@code{gnutls_crypto_cipher_register()} macro.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, otherwise an error.

@strong{Since:} 2.6.0
@end deftypefun

@subheading gnutls_crypto_digest_register2
@anchor{gnutls_crypto_digest_register2}
@deftypefun {int} {gnutls_crypto_digest_register2} (int @var{priority}, int @var{version}, const gnutls_crypto_digest_st * @var{s})
@var{priority}: is the priority of the digest interface

@var{version}: should be set to @code{GNUTLS_CRYPTO_API_VERSION}

@var{s}: is a structure holding new interface's data

This function will register a digest interface to be used by
gnutls. Any interface registered will override the included engine
and by convention kernel implemented interfaces should have
priority of 90. The interface with the lowest priority will be used
by gnutls.

This function should be called before @code{gnutls_global_init()}.

For simplicity you can use the convenience
@code{gnutls_crypto_digest_register()} macro.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, otherwise an error.

@strong{Since:} 2.6.0
@end deftypefun

@subheading gnutls_crypto_mac_register2
@anchor{gnutls_crypto_mac_register2}
@deftypefun {int} {gnutls_crypto_mac_register2} (int @var{priority}, int @var{version}, const gnutls_crypto_mac_st * @var{s})
@var{priority}: is the priority of the mac interface

@var{version}: should be set to @code{GNUTLS_CRYPTO_API_VERSION}

@var{s}: is a structure holding new interface's data

This function will register a mac interface to be used by
gnutls. Any interface registered will override the included engine
and by convention kernel implemented interfaces should have
priority of 90. The interface with the lowest priority will be used
by gnutls.

This function should be called before @code{gnutls_global_init()}.

For simplicity you can use the convenience
@code{gnutls_crypto_digest_register()} macro.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, otherwise an error.

@strong{Since:} 2.6.0
@end deftypefun

@subheading gnutls_crypto_pk_register2
@anchor{gnutls_crypto_pk_register2}
@deftypefun {int} {gnutls_crypto_pk_register2} (int @var{priority}, int @var{version}, const gnutls_crypto_pk_st * @var{s})
@var{priority}: is the priority of the interface

@var{version}: should be set to @code{GNUTLS_CRYPTO_API_VERSION}

@var{s}: is a structure holding new interface's data

This function will register an interface for gnutls to operate
on public key operations. Any interface registered will override
the included interface. The interface with the lowest
priority will be used by gnutls.

Note that the bigint interface must interoperate with the bigint
interface. Thus if this interface is updated the
@code{gnutls_crypto_bigint_register()} should also be used.

This function should be called before @code{gnutls_global_init()}.

For simplicity you can use the convenience @code{gnutls_crypto_pk_register()}
macro.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, otherwise an error.

@strong{Since:} 2.6.0
@end deftypefun

@subheading gnutls_crypto_rnd_register2
@anchor{gnutls_crypto_rnd_register2}
@deftypefun {int} {gnutls_crypto_rnd_register2} (int @var{priority}, int @var{version}, const gnutls_crypto_rnd_st * @var{s})
@var{priority}: is the priority of the generator

@var{version}: should be set to @code{GNUTLS_CRYPTO_API_VERSION}

@var{s}: is a structure holding new generator's data

This function will register a random generator to be used by
gnutls.  Any generator registered will override the included
generator and by convention kernel implemented generators have
priority of 90.  The generator with the lowest priority will be
used by gnutls.

This function should be called before @code{gnutls_global_init()}.

For simplicity you can use the convenience
@code{gnutls_crypto_rnd_register()} macro.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, otherwise an error.

@strong{Since:} 2.6.0
@end deftypefun

@subheading gnutls_crypto_single_cipher_register2
@anchor{gnutls_crypto_single_cipher_register2}
@deftypefun {int} {gnutls_crypto_single_cipher_register2} (gnutls_cipher_algorithm_t @var{algorithm}, int @var{priority}, int @var{version}, const gnutls_crypto_cipher_st * @var{s})
@var{algorithm}: is the gnutls algorithm identifier

@var{priority}: is the priority of the algorithm

@var{version}: should be set to @code{GNUTLS_CRYPTO_API_VERSION}

@var{s}: is a structure holding new cipher's data

This function will register a cipher algorithm to be used by
gnutls.  Any algorithm registered will override the included
algorithms and by convention kernel implemented algorithms have
priority of 90.  The algorithm with the lowest priority will be
used by gnutls.

This function should be called before @code{gnutls_global_init()}.

For simplicity you can use the convenience
@code{gnutls_crypto_single_cipher_register()} macro.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, otherwise an error.

@strong{Since:} 2.6.0
@end deftypefun

@subheading gnutls_crypto_single_digest_register2
@anchor{gnutls_crypto_single_digest_register2}
@deftypefun {int} {gnutls_crypto_single_digest_register2} (gnutls_digest_algorithm_t @var{algorithm}, int @var{priority}, int @var{version}, const gnutls_crypto_digest_st * @var{s})
@var{algorithm}: is the gnutls algorithm identifier

@var{priority}: is the priority of the algorithm

@var{version}: should be set to @code{GNUTLS_CRYPTO_API_VERSION}

@var{s}: is a structure holding new algorithms's data

This function will register a digest (hash) algorithm to be used by
gnutls.  Any algorithm registered will override the included
algorithms and by convention kernel implemented algorithms have
priority of 90.  The algorithm with the lowest priority will be
used by gnutls.

This function should be called before @code{gnutls_global_init()}.

For simplicity you can use the convenience
@code{gnutls_crypto_single_digest_register()} macro.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, otherwise an error.

@strong{Since:} 2.6.0
@end deftypefun

@subheading gnutls_crypto_single_mac_register2
@anchor{gnutls_crypto_single_mac_register2}
@deftypefun {int} {gnutls_crypto_single_mac_register2} (gnutls_mac_algorithm_t @var{algorithm}, int @var{priority}, int @var{version}, const gnutls_crypto_mac_st * @var{s})
@var{algorithm}: is the gnutls algorithm identifier

@var{priority}: is the priority of the algorithm

@var{version}: should be set to @code{GNUTLS_CRYPTO_API_VERSION}

@var{s}: is a structure holding new algorithms's data

This function will register a MAC algorithm to be used by gnutls.
Any algorithm registered will override the included algorithms and
by convention kernel implemented algorithms have priority of 90.
The algorithm with the lowest priority will be used by gnutls.

This function should be called before @code{gnutls_global_init()}.

For simplicity you can use the convenience
@code{gnutls_crypto_single_mac_register()} macro.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, otherwise an error.

@strong{Since:} 2.6.0
@end deftypefun

@subheading gnutls_db_check_entry
@anchor{gnutls_db_check_entry}
@deftypefun {int} {gnutls_db_check_entry} (gnutls_session_t @var{session}, gnutls_datum_t @var{session_entry})
@var{session}: is a @code{gnutls_session_t} structure.

@var{session_entry}: is the session data (not key)

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.

@strong{Returns:} Returns @code{GNUTLS_E_EXPIRED}, if the database entry has
expired or 0 otherwise.
@end deftypefun

@subheading gnutls_db_get_ptr
@anchor{gnutls_db_get_ptr}
@deftypefun {void *} {gnutls_db_get_ptr} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

Get db function pointer.

@strong{Returns:} the pointer that will be sent to db store, retrieve and
delete functions, as the first argument.
@end deftypefun

@subheading gnutls_db_remove_session
@anchor{gnutls_db_remove_session}
@deftypefun {void} {gnutls_db_remove_session} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

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 @code{gnutls_deinit()} is called.

Normally @code{gnutls_deinit()} will remove abnormally terminated
sessions.
@end deftypefun

@subheading gnutls_db_set_cache_expiration
@anchor{gnutls_db_set_cache_expiration}
@deftypefun {void} {gnutls_db_set_cache_expiration} (gnutls_session_t @var{session}, int @var{seconds})
@var{session}: is a @code{gnutls_session_t} structure.

@var{seconds}: is the number of seconds.

Set the expiration time for resumed sessions. The default is 3600
(one hour) at the time writing this.
@end deftypefun

@subheading gnutls_db_set_ptr
@anchor{gnutls_db_set_ptr}
@deftypefun {void} {gnutls_db_set_ptr} (gnutls_session_t @var{session}, void * @var{ptr})
@var{session}: is a @code{gnutls_session_t} structure.

@var{ptr}: is the pointer

Sets the pointer that will be provided to db store, retrieve and
delete functions, as the first argument.
@end deftypefun

@subheading gnutls_db_set_remove_function
@anchor{gnutls_db_set_remove_function}
@deftypefun {void} {gnutls_db_set_remove_function} (gnutls_session_t @var{session}, gnutls_db_remove_func @var{rem_func})
@var{session}: is a @code{gnutls_session_t} structure.

@var{rem_func}: is the function.

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 @code{rem_func} will be null unless
@code{gnutls_db_set_ptr()} has been called.
@end deftypefun

@subheading gnutls_db_set_retrieve_function
@anchor{gnutls_db_set_retrieve_function}
@deftypefun {void} {gnutls_db_set_retrieve_function} (gnutls_session_t @var{session}, gnutls_db_retr_func @var{retr_func})
@var{session}: is a @code{gnutls_session_t} structure.

@var{retr_func}: is the function.

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
@code{gnutls_malloc()}.

The first argument to @code{retr_func} will be null unless
@code{gnutls_db_set_ptr()} has been called.
@end deftypefun

@subheading gnutls_db_set_store_function
@anchor{gnutls_db_set_store_function}
@deftypefun {void} {gnutls_db_set_store_function} (gnutls_session_t @var{session}, gnutls_db_store_func @var{store_func})
@var{session}: is a @code{gnutls_session_t} structure.

@var{store_func}: is the function

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 @code{store_func()} will be null unless
@code{gnutls_db_set_ptr()} has been called.
@end deftypefun

@subheading gnutls_deinit
@anchor{gnutls_deinit}
@deftypefun {void} {gnutls_deinit} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

This function clears all buffers associated with the @code{session}.
This function will also remove session data from the session
database if the session was terminated abnormally.
@end deftypefun

@subheading gnutls_dh_get_group
@anchor{gnutls_dh_get_group}
@deftypefun {int} {gnutls_dh_get_group} (gnutls_session_t @var{session}, gnutls_datum_t * @var{raw_gen}, gnutls_datum_t * @var{raw_prime})
@var{session}: is a gnutls session

@var{raw_gen}: will hold the generator.

@var{raw_prime}: will hold the prime.

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 @code{gnutls_free()}.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, otherwise
an error code is returned.
@end deftypefun

@subheading gnutls_dh_get_peers_public_bits
@anchor{gnutls_dh_get_peers_public_bits}
@deftypefun {int} {gnutls_dh_get_peers_public_bits} (gnutls_session_t @var{session})
@var{session}: is a gnutls session

Get the Diffie-Hellman public key bit size.  Can be used for both
anonymous and ephemeral Diffie-Hellman.

@strong{Returns:} the public key bit size used in the last Diffie-Hellman
key exchange with the peer, or a negative value in case of error.
@end deftypefun

@subheading gnutls_dh_get_prime_bits
@anchor{gnutls_dh_get_prime_bits}
@deftypefun {int} {gnutls_dh_get_prime_bits} (gnutls_session_t @var{session})
@var{session}: is a gnutls session

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.

@strong{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.
@end deftypefun

@subheading gnutls_dh_get_pubkey
@anchor{gnutls_dh_get_pubkey}
@deftypefun {int} {gnutls_dh_get_pubkey} (gnutls_session_t @var{session}, gnutls_datum_t * @var{raw_key})
@var{session}: is a gnutls session

@var{raw_key}: will hold the public key.

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 @code{gnutls_free()}.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, otherwise
an error code is returned.
@end deftypefun

@subheading gnutls_dh_get_secret_bits
@anchor{gnutls_dh_get_secret_bits}
@deftypefun {int} {gnutls_dh_get_secret_bits} (gnutls_session_t @var{session})
@var{session}: is a gnutls session

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.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, otherwise
an error code is returned.
@end deftypefun

@subheading gnutls_dh_params_cpy
@anchor{gnutls_dh_params_cpy}
@deftypefun {int} {gnutls_dh_params_cpy} (gnutls_dh_params_t @var{dst}, gnutls_dh_params_t @var{src})
@var{dst}: Is the destination structure, which should be initialized.

@var{src}: Is the source structure

This function will copy the DH parameters structure from source
to destination.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (zero) is returned,
otherwise an error code is returned.
@end deftypefun

@subheading gnutls_dh_params_deinit
@anchor{gnutls_dh_params_deinit}
@deftypefun {void} {gnutls_dh_params_deinit} (gnutls_dh_params_t @var{dh_params})
@var{dh_params}: Is a structure that holds the prime numbers

This function will deinitialize the DH parameters structure.
@end deftypefun

@subheading gnutls_dh_params_export_pkcs3
@anchor{gnutls_dh_params_export_pkcs3}
@deftypefun {int} {gnutls_dh_params_export_pkcs3} (gnutls_dh_params_t @var{params}, gnutls_x509_crt_fmt_t @var{format}, unsigned char * @var{params_data}, size_t * @var{params_data_size})
@var{params}: Holds the DH parameters

@var{format}: the format of output params. One of PEM or DER.

@var{params_data}: will contain a PKCS3 DHParams structure PEM or DER encoded

@var{params_data_size}: holds the size of params_data (and will be replaced by the actual size of parameters)

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".

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (zero) is returned,
otherwise an error code is returned.
@end deftypefun

@subheading gnutls_dh_params_export_raw
@anchor{gnutls_dh_params_export_raw}
@deftypefun {int} {gnutls_dh_params_export_raw} (gnutls_dh_params_t @var{params}, gnutls_datum_t * @var{prime}, gnutls_datum_t * @var{generator}, unsigned int * @var{bits})
@var{params}: Holds the DH parameters

@var{prime}: will hold the new prime

@var{generator}: will hold the new generator

@var{bits}: if non null will hold is the prime's number of bits

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 @code{gnutls_malloc()} and will be stored in the
appropriate datum.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (zero) is returned,
otherwise an error code is returned.
@end deftypefun

@subheading gnutls_dh_params_generate2
@anchor{gnutls_dh_params_generate2}
@deftypefun {int} {gnutls_dh_params_generate2} (gnutls_dh_params_t @var{params}, unsigned int @var{bits})
@var{params}: Is the structure that the DH parameters will be stored

@var{bits}: is the prime's number of bits

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
@code{gnutls_malloc()} and will be stored in the appropriate datum.
This function is normally slow.

Do not set the number of bits directly, use @code{gnutls_sec_param_to_pk_bits()} to
get bits for @code{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.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (zero) is returned,
otherwise an error code is returned.
@end deftypefun

@subheading gnutls_dh_params_import_pkcs3
@anchor{gnutls_dh_params_import_pkcs3}
@deftypefun {int} {gnutls_dh_params_import_pkcs3} (gnutls_dh_params_t @var{params}, const gnutls_datum_t * @var{pkcs3_params}, gnutls_x509_crt_fmt_t @var{format})
@var{params}: A structure where the parameters will be copied to

@var{pkcs3_params}: should contain a PKCS3 DHParams structure PEM or DER encoded

@var{format}: the format of params. PEM or DER.

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".

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (zero) is returned,
otherwise an error code is returned.
@end deftypefun

@subheading gnutls_dh_params_import_raw
@anchor{gnutls_dh_params_import_raw}
@deftypefun {int} {gnutls_dh_params_import_raw} (gnutls_dh_params_t @var{dh_params}, const gnutls_datum_t * @var{prime}, const gnutls_datum_t * @var{generator})
@var{dh_params}: Is a structure that will hold the prime numbers

@var{prime}: holds the new prime

@var{generator}: holds the new generator

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.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (zero) is returned,
otherwise an error code is returned.
@end deftypefun

@subheading gnutls_dh_params_init
@anchor{gnutls_dh_params_init}
@deftypefun {int} {gnutls_dh_params_init} (gnutls_dh_params_t * @var{dh_params})
@var{dh_params}: Is a structure that will hold the prime numbers

This function will initialize the DH parameters structure.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (zero) is returned,
otherwise an error code is returned.
@end deftypefun

@subheading gnutls_dh_set_prime_bits
@anchor{gnutls_dh_set_prime_bits}
@deftypefun {void} {gnutls_dh_set_prime_bits} (gnutls_session_t @var{session}, unsigned int @var{bits})
@var{session}: is a @code{gnutls_session_t} structure.

@var{bits}: is the number of bits

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
@code{GNUTLS_E_DH_PRIME_UNACCEPTABLE} will be returned by the handshake.

This function has no effect in server side.
@end deftypefun

@subheading gnutls_error_is_fatal
@anchor{gnutls_error_is_fatal}
@deftypefun {int} {gnutls_error_is_fatal} (int @var{error})
@var{error}: is a GnuTLS error code, a negative value

If a GnuTLS function returns a negative value you may feed that
value to this function to see if the error condition is fatal.

Note that you may want to check the error code manually, since some
non-fatal errors to the protocol may be fatal for you program.

This function is only useful if you are dealing with errors from
the record layer or the handshake layer.

@strong{Returns:} 1 if the error code is fatal, for positive @code{error} values,
0 is returned.  For unknown @code{error} values, -1 is returned.
@end deftypefun

@subheading gnutls_error_to_alert
@anchor{gnutls_error_to_alert}
@deftypefun {int} {gnutls_error_to_alert} (int @var{err}, int * @var{level})
@var{err}: is a negative integer

@var{level}: the alert level will be stored there

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 @code{err} is @code{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.

@strong{Returns:} the alert code to use for a particular error code.
@end deftypefun

@subheading gnutls_ext_register
@anchor{gnutls_ext_register}
@deftypefun {int} {gnutls_ext_register} (int @var{type}, const char * @var{name}, gnutls_ext_parse_type_t @var{parse_type}, gnutls_ext_recv_func @var{recv_func}, gnutls_ext_send_func @var{send_func})
@var{type}: the 16-bit integer referring to the extension type

@var{name}: human printable name of the extension used for debugging

@var{parse_type}: either @code{GNUTLS_EXT_TLS} or @code{GNUTLS_EXT_APPLICATION}.

@var{recv_func}: a function to receive extension data

@var{send_func}: a function to send extension data

This function is used to register a new TLS extension handler.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.

@strong{Deprecated in:} 2.12.0
@end deftypefun

@subheading gnutls_fingerprint
@anchor{gnutls_fingerprint}
@deftypefun {int} {gnutls_fingerprint} (gnutls_digest_algorithm_t @var{algo}, const gnutls_datum_t * @var{data}, void * @var{result}, size_t * @var{result_size})
@var{algo}: is a digest algorithm

@var{data}: is the data

@var{result}: is the place where the result will be copied (may be null).

@var{result_size}: should hold the size of the result. The actual size
of the returned result will also be copied there.

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.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, otherwise
an error code is returned.
@end deftypefun

@subheading gnutls_free
@anchor{gnutls_free}
@deftypefun {void} {gnutls_free} (void * @var{ptr})
This function will free data pointed by ptr.

The deallocation function used is the one set by
@code{gnutls_global_set_mem_functions()}.
@end deftypefun

@subheading gnutls_global_deinit
@anchor{gnutls_global_deinit}
@deftypefun {void} {gnutls_global_deinit} ( @var{void})

This function deinitializes the global data, that were initialized
using @code{gnutls_global_init()}.

Note!  This function is not thread safe.  See the discussion for
@code{gnutls_global_init()} for more information.
@end deftypefun

@subheading gnutls_global_init
@anchor{gnutls_global_init}
@deftypefun {int} {gnutls_global_init} ( @var{void})

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
@code{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
@code{gnutls_global_deinit()} only releases resources when it has been
called as many times as @code{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.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (zero) is returned,
otherwise an error code is returned.
@end deftypefun

@subheading gnutls_global_set_log_function
@anchor{gnutls_global_set_log_function}
@deftypefun {void} {gnutls_global_set_log_function} (gnutls_log_func @var{log_func})
@var{log_func}: it's a log function

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*);
@end deftypefun

@subheading gnutls_global_set_log_level
@anchor{gnutls_global_set_log_level}
@deftypefun {void} {gnutls_global_set_log_level} (int @var{level})
@var{level}: it's an integer from 0 to 9.

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.
@end deftypefun

@subheading gnutls_global_set_mem_functions
@anchor{gnutls_global_set_mem_functions}
@deftypefun {void} {gnutls_global_set_mem_functions} (gnutls_alloc_function @var{alloc_func}, gnutls_alloc_function @var{secure_alloc_func}, gnutls_is_secure_function @var{is_secure_func}, gnutls_realloc_function @var{realloc_func}, gnutls_free_function @var{free_func})
@var{alloc_func}: it's the default memory allocation function. Like @code{malloc()}.

@var{secure_alloc_func}: This is the memory allocation function that will be used for sensitive data.

@var{is_secure_func}: a function that returns 0 if the memory given is not secure. May be NULL.

@var{realloc_func}: A realloc function

@var{free_func}: The function that frees allocated data. Must accept a NULL pointer.

This is the function were you set the memory allocation functions
gnutls is going to use. By default the libc's allocation functions
(@code{malloc()}, @code{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 @code{gnutls_global_init()} is called.
This function is not thread safe.
@end deftypefun

@subheading gnutls_global_set_mutex
@anchor{gnutls_global_set_mutex}
@deftypefun {void} {gnutls_global_set_mutex} (mutex_init_func @var{init}, mutex_deinit_func @var{deinit}, mutex_lock_func @var{lock}, mutex_unlock_func @var{unlock})
@var{init}: mutex initialization function

@var{deinit}: mutex deinitialization function

@var{lock}: mutex locking function

@var{unlock}: mutex unlocking function

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 @code{gnutls_global_init()}.
@end deftypefun

@subheading gnutls_global_set_time_function
@anchor{gnutls_global_set_time_function}
@deftypefun {void} {gnutls_global_set_time_function} (gnutls_time_func @var{time_func})
@var{time_func}: it's the system time function

This is the function where you can override the default system
time function.

gnutls_time_func is of the form,
time_t (*gnutls_time_func)( time*);
@end deftypefun

@subheading gnutls_handshake_get_last_in
@anchor{gnutls_handshake_get_last_in}
@deftypefun {gnutls_handshake_description_t} {gnutls_handshake_get_last_in} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

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 @code{gnutls_handshake_description_t} in gnutls.h for the
available handshake descriptions.

@strong{Returns:} the last handshake message type received, a
@code{gnutls_handshake_description_t}.
@end deftypefun

@subheading gnutls_handshake_get_last_out
@anchor{gnutls_handshake_get_last_out}
@deftypefun {gnutls_handshake_description_t} {gnutls_handshake_get_last_out} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

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 @code{gnutls_handshake_description_t} in gnutls.h for the
available handshake descriptions.

@strong{Returns:} the last handshake message type sent, a
@code{gnutls_handshake_description_t}.
@end deftypefun

@subheading gnutls_handshake_set_max_packet_length
@anchor{gnutls_handshake_set_max_packet_length}
@deftypefun {void} {gnutls_handshake_set_max_packet_length} (gnutls_session_t @var{session}, size_t @var{max})
@var{session}: is a @code{gnutls_session_t} structure.

@var{max}: is the maximum number.

This function will set the maximum size of all handshake messages.
Handshakes over this size are rejected with
@code{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.
@end deftypefun

@subheading gnutls_handshake_set_post_client_hello_function
@anchor{gnutls_handshake_set_post_client_hello_function}
@deftypefun {void} {gnutls_handshake_set_post_client_hello_function} (gnutls_session_t @var{session}, gnutls_handshake_post_client_hello_func                                                  @var{func})
@var{session}: is a @code{gnutls_session_t} structure.

@var{func}: is the function to be called

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.

@strong{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.
@end deftypefun

@subheading gnutls_handshake_set_private_extensions
@anchor{gnutls_handshake_set_private_extensions}
@deftypefun {void} {gnutls_handshake_set_private_extensions} (gnutls_session_t @var{session}, int @var{allow})
@var{session}: is a @code{gnutls_session_t} structure.

@var{allow}: is an integer (0 or 1)

This function will enable or disable the use of private cipher
suites (the ones that start with 0xFF).  By default or if @code{allow}
is 0 then these cipher suites will not be advertized nor used.

Unless this function is called with the option to allow (1), then
no compression algorithms, like LZO.  That is because these
algorithms are not yet defined in any RFC or even internet draft.

Enabling the private ciphersuites when talking to other than
gnutls servers and clients may cause interoperability problems.
@end deftypefun

@subheading gnutls_handshake
@anchor{gnutls_handshake}
@deftypefun {int} {gnutls_handshake} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

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 @code{GNUTLS_E_AGAIN} and
@code{GNUTLS_E_INTERRUPTED} interrupt the handshake procedure, which
should be later be resumed.  Call this function again, until it
returns 0; cf.  @code{gnutls_record_get_direction()} and
@code{gnutls_error_is_fatal()}.

If this function is called by a server after a rehandshake request
then @code{GNUTLS_E_GOT_APPLICATION_DATA} or
@code{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 @code{GNUTLS_E_GOT_APPLICATION_DATA} it might also mean that
some data were pending.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, otherwise an error.
@end deftypefun

@subheading gnutls_hash_deinit
@anchor{gnutls_hash_deinit}
@deftypefun {void} {gnutls_hash_deinit} (gnutls_hash_hd_t @var{handle}, void * @var{digest})
@var{handle}: is a @code{gnutls_hash_hd_t} structure.

@var{digest}: is the output value of the hash

This function will deinitialize all resources occupied by
the given hash context.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_hash_fast
@anchor{gnutls_hash_fast}
@deftypefun {int} {gnutls_hash_fast} (gnutls_digest_algorithm_t @var{algorithm}, const void * @var{text}, size_t @var{textlen}, void * @var{digest})
@var{algorithm}: the hash algorithm to use

@var{text}: the data to hash

@var{textlen}: The length of data to hash

@var{digest}: is the output value of the hash

This convenience function will hash the given data and return output
on a single call.

@strong{Returns:} Zero or a negative value on error.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_hash_get_len
@anchor{gnutls_hash_get_len}
@deftypefun {int} {gnutls_hash_get_len} (gnutls_digest_algorithm_t @var{algorithm})
@var{algorithm}: the hash algorithm to use

This function will return the length of the output data
of the given hash algorithm.

@strong{Returns:} The length or zero on error.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_hash_init
@anchor{gnutls_hash_init}
@deftypefun {int} {gnutls_hash_init} (gnutls_hash_hd_t * @var{dig}, gnutls_digest_algorithm_t @var{algorithm})
@var{dig}: is a @code{gnutls_hash_hd_t} structure.

@var{algorithm}: the hash algorithm to use

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.

@strong{Returns:} Zero or a negative value on error.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_hash_output
@anchor{gnutls_hash_output}
@deftypefun {void} {gnutls_hash_output} (gnutls_hash_hd_t @var{handle}, void * @var{digest})
@var{handle}: is a @code{gnutls_hash_hd_t} structure.

@var{digest}: is the output value of the hash

This function will output the current hash value.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_hash
@anchor{gnutls_hash}
@deftypefun {int} {gnutls_hash} (gnutls_hash_hd_t @var{handle}, const void * @var{text}, size_t @var{textlen})
@var{handle}: is a @code{gnutls_cipher_hd_t} structure.

@var{text}: the data to hash

@var{textlen}: The length of data to hash

This function will hash the given data using the algorithm
specified by the context.

@strong{Returns:} Zero or a negative value on error.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_hex2bin
@anchor{gnutls_hex2bin}
@deftypefun {int} {gnutls_hex2bin} (const char * @var{hex_data}, size_t @var{hex_size}, char * @var{bin_data}, size_t * @var{bin_size})
@var{hex_data}: string with data in hex format

@var{hex_size}: size of hex data

@var{bin_data}: output array with binary data

@var{bin_size}: when calling *@code{bin_size} should hold size of @code{bin_data},
on return will hold actual size of @code{bin_data}.

Convert a buffer with hex data to binary data.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, otherwise an error.

@strong{Since:} 2.4.0
@end deftypefun

@subheading gnutls_hex_decode
@anchor{gnutls_hex_decode}
@deftypefun {int} {gnutls_hex_decode} (const gnutls_datum_t * @var{hex_data}, char * @var{result}, size_t * @var{result_size})
@var{hex_data}: contain the encoded data

@var{result}: the place where decoded data will be copied

@var{result_size}: holds the size of the result

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.

@strong{Returns:} @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if the buffer given is not
long enough, or 0 on success.
@end deftypefun

@subheading gnutls_hex_encode
@anchor{gnutls_hex_encode}
@deftypefun {int} {gnutls_hex_encode} (const gnutls_datum_t * @var{data}, char * @var{result}, size_t * @var{result_size})
@var{data}: contain the raw data

@var{result}: the place where hex data will be copied

@var{result_size}: holds the size of the result

This function will convert the given data to printable data, using
the hex encoding, as used in the PSK password files.

@strong{Returns:} @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if the buffer given is not
long enough, or 0 on success.
@end deftypefun

@subheading gnutls_hmac_deinit
@anchor{gnutls_hmac_deinit}
@deftypefun {void} {gnutls_hmac_deinit} (gnutls_hmac_hd_t @var{handle}, void * @var{digest})
@var{handle}: is a @code{gnutls_hmac_hd_t} structure.

@var{digest}: is the output value of the MAC

This function will deinitialize all resources occupied by
the given hmac context.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_hmac_fast
@anchor{gnutls_hmac_fast}
@deftypefun {int} {gnutls_hmac_fast} (gnutls_mac_algorithm_t @var{algorithm}, const void * @var{key}, size_t @var{keylen}, const void * @var{text}, size_t @var{textlen}, void * @var{digest})
@var{algorithm}: the hash algorithm to use

@var{key}: the key to use

@var{keylen}: The length of the key

@var{text}: the data to hash

@var{textlen}: The length of data to hash

@var{digest}: is the output value of the hash

This convenience function will hash the given data and return output
on a single call.

@strong{Returns:} Zero or a negative value on error.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_hmac_get_len
@anchor{gnutls_hmac_get_len}
@deftypefun {int} {gnutls_hmac_get_len} (gnutls_mac_algorithm_t @var{algorithm})
@var{algorithm}: the hmac algorithm to use

This function will return the length of the output data
of the given hmac algorithm.

@strong{Returns:} The length or zero on error.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_hmac_init
@anchor{gnutls_hmac_init}
@deftypefun {int} {gnutls_hmac_init} (gnutls_hmac_hd_t * @var{dig}, gnutls_digest_algorithm_t @var{algorithm}, const void * @var{key}, size_t @var{keylen})
@var{dig}: is a @code{gnutls_hmac_hd_t} structure.

@var{algorithm}: the HMAC algorithm to use

@var{key}: The key to be used for encryption

@var{keylen}: The length of the key

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.

@strong{Returns:} Zero or a negative value on error.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_hmac_output
@anchor{gnutls_hmac_output}
@deftypefun {void} {gnutls_hmac_output} (gnutls_hmac_hd_t @var{handle}, void * @var{digest})
@var{handle}: is a @code{gnutls_hmac_hd_t} structure.

@var{digest}: is the output value of the MAC

This function will output the current MAC value.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_hmac
@anchor{gnutls_hmac}
@deftypefun {int} {gnutls_hmac} (gnutls_hmac_hd_t @var{handle}, const void * @var{text}, size_t @var{textlen})
@var{handle}: is a @code{gnutls_cipher_hd_t} structure.

@var{text}: the data to hash

@var{textlen}: The length of data to hash

This function will hash the given data using the algorithm
specified by the context.

@strong{Returns:} Zero or a negative value on error.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_init
@anchor{gnutls_init}
@deftypefun {int} {gnutls_init} (gnutls_session_t * @var{session}, gnutls_connection_end_t @var{con_end})
@var{session}: is a pointer to a @code{gnutls_session_t} structure.

@var{con_end}: indicate if this session is to be used for server or client.

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 @code{gnutls_deinit()}.  Returns zero on success.

@code{con_end} can be one of @code{GNUTLS_CLIENT} and @code{GNUTLS_SERVER}.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_kx_get_id
@anchor{gnutls_kx_get_id}
@deftypefun {gnutls_kx_algorithm_t} {gnutls_kx_get_id} (const char * @var{name})
@var{name}: is a KX name

Convert a string to a @code{gnutls_kx_algorithm_t} value.  The names are
compared in a case insensitive way.

@strong{Returns:} an id of the specified KX algorithm, or @code{GNUTLS_KX_UNKNOWN}
on error.
@end deftypefun

@subheading gnutls_kx_get_name
@anchor{gnutls_kx_get_name}
@deftypefun {const char *} {gnutls_kx_get_name} (gnutls_kx_algorithm_t @var{algorithm})
@var{algorithm}: is a key exchange algorithm

Convert a @code{gnutls_kx_algorithm_t} value to a string.

@strong{Returns:} a pointer to a string that contains the name of the
specified key exchange algorithm, or @code{NULL}.
@end deftypefun

@subheading gnutls_kx_get
@anchor{gnutls_kx_get}
@deftypefun {gnutls_kx_algorithm_t} {gnutls_kx_get} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

Get currently used key exchange algorithm.

@strong{Returns:} the key exchange algorithm used in the last handshake, a
@code{gnutls_kx_algorithm_t} value.
@end deftypefun

@subheading gnutls_kx_list
@anchor{gnutls_kx_list}
@deftypefun {const gnutls_kx_algorithm_t *} {gnutls_kx_list} ( @var{void})

Get a list of supported key exchange algorithms.

@strong{Returns:} a zero-terminated list of @code{gnutls_kx_algorithm_t} integers
indicating the available key exchange algorithms.
@end deftypefun

@subheading gnutls_kx_set_priority
@anchor{gnutls_kx_set_priority}
@deftypefun {int} {gnutls_kx_set_priority} (gnutls_session_t @var{session}, const int * @var{list})
@var{session}: is a @code{gnutls_session_t} structure.

@var{list}: is a 0 terminated list of gnutls_kx_algorithm_t elements.

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.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_mac_get_id
@anchor{gnutls_mac_get_id}
@deftypefun {gnutls_mac_algorithm_t} {gnutls_mac_get_id} (const char * @var{name})
@var{name}: is a MAC algorithm name

Convert a string to a @code{gnutls_mac_algorithm_t} value.  The names are
compared in a case insensitive way.

@strong{Returns:} a @code{gnutls_mac_algorithm_t} id of the specified MAC
algorithm string, or @code{GNUTLS_MAC_UNKNOWN} on failures.
@end deftypefun

@subheading gnutls_mac_get_key_size
@anchor{gnutls_mac_get_key_size}
@deftypefun {size_t} {gnutls_mac_get_key_size} (gnutls_mac_algorithm_t @var{algorithm})
@var{algorithm}: is an encryption algorithm

Get size of MAC key.

@strong{Returns:} length (in bytes) of the given MAC key size, or 0 if the
given MAC algorithm is invalid.
@end deftypefun

@subheading gnutls_mac_get_name
@anchor{gnutls_mac_get_name}
@deftypefun {const char *} {gnutls_mac_get_name} (gnutls_mac_algorithm_t @var{algorithm})
@var{algorithm}: is a MAC algorithm

Convert a @code{gnutls_mac_algorithm_t} value to a string.

@strong{Returns:} a string that contains the name of the specified MAC
algorithm, or @code{NULL}.
@end deftypefun

@subheading gnutls_mac_get
@anchor{gnutls_mac_get}
@deftypefun {gnutls_mac_algorithm_t} {gnutls_mac_get} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

Get currently used MAC algorithm.

@strong{Returns:} the currently used mac algorithm, a
@code{gnutls_mac_algorithm_t} value.
@end deftypefun

@subheading gnutls_mac_list
@anchor{gnutls_mac_list}
@deftypefun {const gnutls_mac_algorithm_t *} {gnutls_mac_list} ( @var{void})

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).

@strong{Returns:} Return a zero-terminated list of @code{gnutls_mac_algorithm_t}
integers indicating the available MACs.
@end deftypefun

@subheading gnutls_mac_set_priority
@anchor{gnutls_mac_set_priority}
@deftypefun {int} {gnutls_mac_set_priority} (gnutls_session_t @var{session}, const int * @var{list})
@var{session}: is a @code{gnutls_session_t} structure.

@var{list}: is a 0 terminated list of gnutls_mac_algorithm_t elements.

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.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_malloc
@anchor{gnutls_malloc}
@deftypefun {void *} {gnutls_malloc} (size_t @var{s})

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
@code{gnutls_global_set_mem_functions()}.
@end deftypefun

@subheading gnutls_openpgp_send_cert
@anchor{gnutls_openpgp_send_cert}
@deftypefun {void} {gnutls_openpgp_send_cert} (gnutls_session_t @var{session}, gnutls_openpgp_crt_status_t @var{status})
@var{session}: is a pointer to a @code{gnutls_session_t} structure.

@var{status}: is one of GNUTLS_OPENPGP_CERT, or GNUTLS_OPENPGP_CERT_FINGERPRINT

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.
@end deftypefun

@subheading gnutls_pem_base64_decode_alloc
@anchor{gnutls_pem_base64_decode_alloc}
@deftypefun {int} {gnutls_pem_base64_decode_alloc} (const char * @var{header}, const gnutls_datum_t * @var{b64_data}, gnutls_datum_t * @var{result})
@var{header}: The PEM header (eg. CERTIFICATE)

@var{b64_data}: contains the encoded data

@var{result}: the place where decoded data lie

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 @code{gnutls_free()} to free the returned data.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, otherwise
an error code is returned.
@end deftypefun

@subheading gnutls_pem_base64_decode
@anchor{gnutls_pem_base64_decode}
@deftypefun {int} {gnutls_pem_base64_decode} (const char * @var{header}, const gnutls_datum_t * @var{b64_data}, unsigned char * @var{result}, size_t * @var{result_size})
@var{header}: A null terminated string with the PEM header (eg. CERTIFICATE)

@var{b64_data}: contain the encoded data

@var{result}: the place where decoded data will be copied

@var{result_size}: holds the size of the result

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.

@strong{Returns:} On success @code{GNUTLS_E_SUCCESS} (0) is returned,
@code{GNUTLS_E_SHORT_MEMORY_BUFFER} is returned if the buffer given is
not long enough, or 0 on success.
@end deftypefun

@subheading gnutls_pem_base64_encode_alloc
@anchor{gnutls_pem_base64_encode_alloc}
@deftypefun {int} {gnutls_pem_base64_encode_alloc} (const char * @var{msg}, const gnutls_datum_t * @var{data}, gnutls_datum_t * @var{result})
@var{msg}: is a message to be put in the encoded header

@var{data}: contains the raw data

@var{result}: will hold the newly allocated encoded data

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 @code{gnutls_free()} to free the returned data.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, otherwise
an error code is returned.
@end deftypefun

@subheading gnutls_pem_base64_encode
@anchor{gnutls_pem_base64_encode}
@deftypefun {int} {gnutls_pem_base64_encode} (const char * @var{msg}, const gnutls_datum_t * @var{data}, char * @var{result}, size_t * @var{result_size})
@var{msg}: is a message to be put in the header

@var{data}: contain the raw data

@var{result}: the place where base64 data will be copied

@var{result_size}: holds the size of the result

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.

@strong{Returns:} On success @code{GNUTLS_E_SUCCESS} (0) is returned,
@code{GNUTLS_E_SHORT_MEMORY_BUFFER} is returned if the buffer given is
not long enough, or 0 on success.
@end deftypefun

@subheading gnutls_perror
@anchor{gnutls_perror}
@deftypefun {void} {gnutls_perror} (int @var{error})
@var{error}: is a GnuTLS error code, a negative value

This function is like @code{perror()}. The only difference is that it
accepts an error number returned by a gnutls function.
@end deftypefun

@subheading gnutls_pk_algorithm_get_name
@anchor{gnutls_pk_algorithm_get_name}
@deftypefun {const char *} {gnutls_pk_algorithm_get_name} (gnutls_pk_algorithm_t @var{algorithm})
@var{algorithm}: is a pk algorithm

Convert a @code{gnutls_pk_algorithm_t} value to a string.

@strong{Returns:} a string that contains the name of the specified public
key algorithm, or @code{NULL}.
@end deftypefun

@subheading gnutls_pk_bits_to_sec_param
@anchor{gnutls_pk_bits_to_sec_param}
@deftypefun {gnutls_sec_param_t} {gnutls_pk_bits_to_sec_param} (gnutls_pk_algorithm_t @var{algo}, unsigned int @var{bits})
@var{algo}: is a public key algorithm

@var{bits}: is the number of bits

This is the inverse of @code{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.

@strong{Returns:} The security parameter.
@end deftypefun

@subheading gnutls_pk_get_id
@anchor{gnutls_pk_get_id}
@deftypefun {gnutls_pk_algorithm_t} {gnutls_pk_get_id} (const char * @var{name})
@var{name}: is a string containing a public key algorithm name.

Convert a string to a @code{gnutls_pk_algorithm_t} value.  The names are
compared in a case insensitive way.  For example,
gnutls_pk_get_id("RSA") will return @code{GNUTLS_PK_RSA}.

@strong{Returns:} a @code{gnutls_pk_algorithm_t} id of the specified public key
algorithm string, or @code{GNUTLS_PK_UNKNOWN} on failures.

@strong{Since:} 2.6.0
@end deftypefun

@subheading gnutls_pk_get_name
@anchor{gnutls_pk_get_name}
@deftypefun {const char *} {gnutls_pk_get_name} (gnutls_pk_algorithm_t @var{algorithm})
@var{algorithm}: is a public key algorithm

Convert a @code{gnutls_pk_algorithm_t} value to a string.

@strong{Returns:} a pointer to a string that contains the name of the
specified public key algorithm, or @code{NULL}.

@strong{Since:} 2.6.0
@end deftypefun

@subheading gnutls_pk_list
@anchor{gnutls_pk_list}
@deftypefun {const gnutls_pk_algorithm_t *} {gnutls_pk_list} ( @var{void})

Get a list of supported public key algorithms.

@strong{Returns:} a zero-terminated list of @code{gnutls_pk_algorithm_t} integers
indicating the available ciphers.

@strong{Since:} 2.6.0
@end deftypefun

@subheading gnutls_pkcs11_add_provider
@anchor{gnutls_pkcs11_add_provider}
@deftypefun {int} {gnutls_pkcs11_add_provider} (const char * @var{name}, const char * @var{params})
@var{name}: The filename of the module

@var{params}: should be NULL

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.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pkcs11_copy_secret_key
@anchor{gnutls_pkcs11_copy_secret_key}
@deftypefun {int} {gnutls_pkcs11_copy_secret_key} (const char * @var{token_url}, gnutls_datum_t * @var{key}, const char * @var{label}, unsigned int @var{key_usage}, unsigned int @var{flags})
@var{token_url}: A PKCS @code{11} URL specifying a token

@var{key}: The raw key

@var{label}: A name to be used for the stored data

@var{key_usage}: One of GNUTLS_KEY_*

@var{flags}: One of GNUTLS_PKCS11_OBJ_FLAG_*

This function will copy a raw secret (symmetric) key into a PKCS @code{11} 
token specified by a URL. The key can be marked as sensitive or not.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pkcs11_copy_x509_crt
@anchor{gnutls_pkcs11_copy_x509_crt}
@deftypefun {int} {gnutls_pkcs11_copy_x509_crt} (const char * @var{token_url}, gnutls_x509_crt_t @var{crt}, const char * @var{label}, unsigned int @var{flags})
@var{token_url}: A PKCS @code{11} URL specifying a token

@var{crt}: A certificate

@var{label}: A name to be used for the stored data

@var{flags}: One of GNUTLS_PKCS11_OBJ_FLAG_*

This function will copy a certificate into a PKCS @code{11} token specified by
a URL. The certificate can be marked as trusted or not.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pkcs11_copy_x509_privkey
@anchor{gnutls_pkcs11_copy_x509_privkey}
@deftypefun {int} {gnutls_pkcs11_copy_x509_privkey} (const char * @var{token_url}, gnutls_x509_privkey_t @var{key}, const char * @var{label}, unsigned int @var{key_usage}, unsigned int @var{flags})
@var{token_url}: A PKCS @code{11} URL specifying a token

@var{key}: A private key

@var{label}: A name to be used for the stored data

@var{key_usage}: One of GNUTLS_KEY_*

@var{flags}: One of GNUTLS_PKCS11_OBJ_* flags

This function will copy a private key into a PKCS @code{11} token specified by
a URL. It is highly recommended flags to contain @code{GNUTLS_PKCS11_OBJ_FLAG_MARK_SENSITIVE}
unless there is a strong reason not to.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pkcs11_deinit
@anchor{gnutls_pkcs11_deinit}
@deftypefun {void} {gnutls_pkcs11_deinit} ( @var{void})

This function will deinitialize the PKCS 11 subsystem in gnutls.
@end deftypefun

@subheading gnutls_pkcs11_delete_url
@anchor{gnutls_pkcs11_delete_url}
@deftypefun {int} {gnutls_pkcs11_delete_url} (const char * @var{object_url}, unsigned int @var{flags})
@var{object_url}: The URL of the object to delete.

@var{flags}: One of GNUTLS_PKCS11_OBJ_* flags

This function will delete objects matching the given URL.

@strong{Returns:} On success, the number of objects deleted is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pkcs11_init
@anchor{gnutls_pkcs11_init}
@deftypefun {int} {gnutls_pkcs11_init} (unsigned int @var{flags}, const char * @var{deprecated_config_file})
@var{flags}: @code{GNUTLS_PKCS11_FLAG_MANUAL} or @code{GNUTLS_PKCS11_FLAG_AUTO}

@var{deprecated_config_file}: either NULL or the location of a deprecated
configuration file

This function will initialize the PKCS 11 subsystem in gnutls. It will
read configuration files if @code{GNUTLS_PKCS11_FLAG_AUTO} is used or allow
you to independently load PKCS 11 modules using @code{gnutls_pkcs11_add_provider()}
if @code{GNUTLS_PKCS11_FLAG_MANUAL} is specified.

Using a custom configfile is deprecated and will not be supported in future
versions of gnutls.

Normally you don't need to call this function since it is being called
by @code{gnutls_global_init()} using the @code{GNUTLS_PKCS11_FLAG_AUTO}. If you need to
call this function, you must call it before @code{gnutls_global_init()}.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pkcs11_obj_deinit
@anchor{gnutls_pkcs11_obj_deinit}
@deftypefun {void} {gnutls_pkcs11_obj_deinit} (gnutls_pkcs11_obj_t @var{obj})
@var{obj}: The structure to be initialized

This function will deinitialize a certificate structure.
@end deftypefun

@subheading gnutls_pkcs11_obj_export_url
@anchor{gnutls_pkcs11_obj_export_url}
@deftypefun {int} {gnutls_pkcs11_obj_export_url} (gnutls_pkcs11_obj_t @var{obj}, gnutls_pkcs11_url_type_t @var{detailed}, char ** @var{url})
@var{obj}: Holds the PKCS 11 certificate

@var{detailed}: non zero if a detailed URL is required

@var{url}: will contain an allocated url

This function will export a URL identifying the given certificate.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pkcs11_obj_export
@anchor{gnutls_pkcs11_obj_export}
@deftypefun {int} {gnutls_pkcs11_obj_export} (gnutls_pkcs11_obj_t @var{obj}, void * @var{output_data}, size_t * @var{output_data_size})
@var{obj}: Holds the object

@var{output_data}: will contain a certificate PEM or DER encoded

@var{output_data_size}: holds the size of output_data (and will be
replaced by the actual size of parameters)

This function will export the pkcs11 object data. It is normal
for PKCS @code{11} data to be inaccesible and in that case @code{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".

@strong{Return value:} In case of failure a negative value will be
returned, and 0 on success.
@end deftypefun

@subheading gnutls_pkcs11_obj_get_info
@anchor{gnutls_pkcs11_obj_get_info}
@deftypefun {int} {gnutls_pkcs11_obj_get_info} (gnutls_pkcs11_obj_t @var{crt}, gnutls_pkcs11_obj_info_t @var{itype}, void * @var{output}, size_t * @var{output_size})
@var{crt}: should contain a @code{gnutls_pkcs11_obj_t} structure

@var{itype}: Denotes the type of information requested

@var{output}: where output will be stored

@var{output_size}: contains the maximum size of the output and will be overwritten with actual

This function will return information about the PKCS 11 certificatesuch
as the label, id as well as token information where the key is stored. When
output is text it returns null terminated string although @code{output_size} contains
the size of the actual data only.

@strong{Returns:} zero on success or a negative value on error.
@end deftypefun

@subheading gnutls_pkcs11_obj_get_type
@anchor{gnutls_pkcs11_obj_get_type}
@deftypefun {gnutls_pkcs11_obj_type_t} {gnutls_pkcs11_obj_get_type} (gnutls_pkcs11_obj_t @var{obj})
This function will return the type of the certificate being
stored in the structure.

@strong{Returns:} The type of the certificate.
@end deftypefun

@subheading gnutls_pkcs11_obj_import_url
@anchor{gnutls_pkcs11_obj_import_url}
@deftypefun {int} {gnutls_pkcs11_obj_import_url} (gnutls_pkcs11_obj_t @var{cert}, const char * @var{url}, unsigned int @var{flags})
@var{cert}: The structure to store the parsed certificate

@var{url}: a PKCS 11 url identifying the key

@var{flags}: One of GNUTLS_PKCS11_OBJ_* flags

This function will "import" a PKCS 11 URL identifying a certificate
key to the @code{gnutls_pkcs11_obj_t} structure. This does not involve any
parsing (such as X.509 or OpenPGP) since the @code{gnutls_pkcs11_obj_t} is
format agnostic. Only data are transferred.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pkcs11_obj_init
@anchor{gnutls_pkcs11_obj_init}
@deftypefun {int} {gnutls_pkcs11_obj_init} (gnutls_pkcs11_obj_t * @var{obj})
@var{obj}: The structure to be initialized

This function will initialize a pkcs11 certificate structure.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pkcs11_obj_list_import_url
@anchor{gnutls_pkcs11_obj_list_import_url}
@deftypefun {int} {gnutls_pkcs11_obj_list_import_url} (gnutls_pkcs11_obj_t * @var{p_list}, unsigned int * @var{n_list}, const char * @var{url}, gnutls_pkcs11_obj_attr_t @var{attrs}, unsigned int @var{flags})
@var{p_list}: An uninitialized object list (may be NULL)

@var{n_list}: initially should hold the maximum size of the list. Will contain the actual size.

@var{url}: A PKCS 11 url identifying a set of objects

@var{attrs}: Attributes of type @code{gnutls_pkcs11_obj_attr_t} that can be used to limit output

@var{flags}: One of GNUTLS_PKCS11_OBJ_* flags

This function will initialize and set values to an object list
by using all objects identified by a PKCS 11 URL.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pkcs11_privkey_deinit
@anchor{gnutls_pkcs11_privkey_deinit}
@deftypefun {void} {gnutls_pkcs11_privkey_deinit} (gnutls_pkcs11_privkey_t @var{key})
@var{key}: The structure to be initialized

This function will deinitialize a private key structure.
@end deftypefun

@subheading gnutls_pkcs11_privkey_export_url
@anchor{gnutls_pkcs11_privkey_export_url}
@deftypefun {int} {gnutls_pkcs11_privkey_export_url} (gnutls_pkcs11_privkey_t @var{key}, gnutls_pkcs11_url_type_t @var{detailed}, char ** @var{url})
@var{key}: Holds the PKCS 11 key

@var{detailed}: non zero if a detailed URL is required

@var{url}: will contain an allocated url

This function will export a URL identifying the given key.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pkcs11_privkey_get_info
@anchor{gnutls_pkcs11_privkey_get_info}
@deftypefun {int} {gnutls_pkcs11_privkey_get_info} (gnutls_pkcs11_privkey_t @var{pkey}, gnutls_pkcs11_obj_info_t @var{itype}, void * @var{output}, size_t * @var{output_size})
@var{pkey}: should contain a @code{gnutls_pkcs11_privkey_t} structure

@var{itype}: Denotes the type of information requested

@var{output}: where output will be stored

@var{output_size}: contains the maximum size of the output and will be overwritten with actual

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 @code{output_size} contains
the size of the actual data only.

@strong{Returns:} zero on success or a negative value on error.
@end deftypefun

@subheading gnutls_pkcs11_privkey_get_pk_algorithm
@anchor{gnutls_pkcs11_privkey_get_pk_algorithm}
@deftypefun {int} {gnutls_pkcs11_privkey_get_pk_algorithm} (gnutls_pkcs11_privkey_t @var{key}, unsigned int * @var{bits})
@var{key}: should contain a @code{gnutls_pkcs11_privkey_t} structure

This function will return the public key algorithm of a private
key.

@strong{Returns:} a member of the @code{gnutls_pk_algorithm_t} enumeration on
success, or a negative value on error.
@end deftypefun

@subheading gnutls_pkcs11_privkey_import_url
@anchor{gnutls_pkcs11_privkey_import_url}
@deftypefun {int} {gnutls_pkcs11_privkey_import_url} (gnutls_pkcs11_privkey_t @var{pkey}, const char * @var{url}, unsigned int @var{flags})
@var{pkey}: The structure to store the parsed key

@var{url}: a PKCS 11 url identifying the key

@var{flags}: sequence of GNUTLS_PKCS_PRIVKEY_*

This function will "import" a PKCS 11 URL identifying a private
key to the @code{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.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pkcs11_privkey_init
@anchor{gnutls_pkcs11_privkey_init}
@deftypefun {int} {gnutls_pkcs11_privkey_init} (gnutls_pkcs11_privkey_t * @var{key})
@var{key}: The structure to be initialized

This function will initialize an private key structure.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pkcs11_reinit
@anchor{gnutls_pkcs11_reinit}
@deftypefun {int} {gnutls_pkcs11_reinit} ( @var{void})

This function will reinitialize the PKCS 11 subsystem in gnutls. 
This is required by PKCS 11 when an application uses @code{fork()}. The
reinitialization function must be called on the child.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, otherwise a
negative error value.

@strong{Since:} 3.0.0
@end deftypefun

@subheading gnutls_pkcs11_set_pin_function
@anchor{gnutls_pkcs11_set_pin_function}
@deftypefun {void} {gnutls_pkcs11_set_pin_function} (gnutls_pkcs11_pin_callback_t @var{fn}, void * @var{userdata})
@var{fn}: The PIN callback

@var{userdata}: data to be supplied to callback

This function will set a callback function to be used when a PIN
is required for PKCS 11 operations.

Callback for PKCS@code{11} PIN entry.  The callback provides the PIN code
to unlock the token with label 'token_label', specified by the URL 
'token_url'.

The PIN code, as a NUL-terminated ASCII string, should be copied
into the 'pin' buffer (of maximum size pin_max), and
return 0 to indicate success. Alternatively, the callback may
return a negative gnutls error code to indicate failure and cancel
PIN entry (in which case, the contents of the 'pin' parameter are ignored).

When a PIN is required, the callback will be invoked repeatedly
(and indefinitely) until either the returned PIN code is correct,
the callback returns failure, or the token refuses login (e.g. when
the token is locked due to too many incorrect PINs!).  For the
first such invocation, the 'attempt' counter will have value zero;
it will increase by one for each subsequent attempt.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pkcs11_set_token_function
@anchor{gnutls_pkcs11_set_token_function}
@deftypefun {void} {gnutls_pkcs11_set_token_function} (gnutls_pkcs11_token_callback_t @var{fn}, void * @var{userdata})
@var{fn}: The token callback

@var{userdata}: data to be supplied to callback

This function will set a callback function to be used when a token
needs to be inserted to continue PKCS 11 operations.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pkcs11_token_get_flags
@anchor{gnutls_pkcs11_token_get_flags}
@deftypefun {int} {gnutls_pkcs11_token_get_flags} (const char * @var{url}, unsigned int * @var{flags})
@var{url}: should contain a PKCS 11 URL

@var{flags}: The output flags (GNUTLS_PKCS11_TOKEN_*)

This function will return information about the PKCS 11 token flags.

@strong{Returns:} zero on success or a negative value on error.
@end deftypefun

@subheading gnutls_pkcs11_token_get_info
@anchor{gnutls_pkcs11_token_get_info}
@deftypefun {int} {gnutls_pkcs11_token_get_info} (const char * @var{url}, gnutls_pkcs11_token_info_t @var{ttype}, void * @var{output}, size_t * @var{output_size})
@var{url}: should contain a PKCS 11 URL

@var{ttype}: Denotes the type of information requested

@var{output}: where output will be stored

@var{output_size}: contains the maximum size of the output and will be overwritten with actual

This function will return information about the PKCS 11 token such
as the label, id as well as token information where the key is stored.

@strong{Returns:} zero on success or a negative value on error.
@end deftypefun

@subheading gnutls_pkcs11_token_get_mechanism
@anchor{gnutls_pkcs11_token_get_mechanism}
@deftypefun {int} {gnutls_pkcs11_token_get_mechanism} (const char * @var{url}, int @var{idx}, unsigned long * @var{mechanism})
@var{url}: should contain a PKCS 11 URL

@var{idx}: The index of the mechanism

@var{mechanism}: The PKCS @code{11} mechanism ID

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.

@strong{Returns:} zero on success or a negative value on error.
@end deftypefun

@subheading gnutls_pkcs11_token_get_url
@anchor{gnutls_pkcs11_token_get_url}
@deftypefun {int} {gnutls_pkcs11_token_get_url} (unsigned int @var{seq}, gnutls_pkcs11_url_type_t @var{detailed}, char ** @var{url})
@var{seq}: sequence number starting from 0

@var{detailed}: non zero if a detailed URL is required

@var{url}: will contain an allocated url

This function will return the URL for each token available
in system. The url has to be released using @code{gnutls_free()}

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE}
if the sequence number exceeds the available tokens, otherwise a negative error value.
@end deftypefun

@subheading gnutls_pkcs11_token_init
@anchor{gnutls_pkcs11_token_init}
@deftypefun {int} {gnutls_pkcs11_token_init} (const char * @var{token_url}, const char * @var{so_pin}, const char * @var{label})
@var{token_url}: A PKCS @code{11} URL specifying a token

@var{so_pin}: Security Officer's PIN

@var{label}: A name to be used for the token

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.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pkcs11_token_set_pin
@anchor{gnutls_pkcs11_token_set_pin}
@deftypefun {int} {gnutls_pkcs11_token_set_pin} (const char * @var{token_url}, const char * @var{oldpin}, const char * @var{newpin}, unsigned int @var{flags})
@var{token_url}: A PKCS @code{11} URL specifying a token

@var{oldpin}: old user's PIN

@var{newpin}: new user's PIN

@var{flags}: one of gnutls_pkcs11_pin_flag_t

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.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_prf_raw
@anchor{gnutls_prf_raw}
@deftypefun {int} {gnutls_prf_raw} (gnutls_session_t @var{session}, size_t @var{label_size}, const char * @var{label}, size_t @var{seed_size}, const char * @var{seed}, size_t @var{outsize}, char * @var{out})
@var{session}: is a @code{gnutls_session_t} structure.

@var{label_size}: length of the @code{label} variable.

@var{label}: label used in PRF computation, typically a short string.

@var{seed_size}: length of the @code{seed} variable.

@var{seed}: optional extra data to seed the PRF with.

@var{outsize}: size of pre-allocated output buffer to hold the output.

@var{out}: pre-allocate buffer to hold the generated data.

Apply the TLS Pseudo-Random-Function (PRF) using the master secret
on some data.

The @code{label} variable usually contain a string denoting the purpose
for the generated data.  The @code{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 @code{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 @code{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.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_prf
@anchor{gnutls_prf}
@deftypefun {int} {gnutls_prf} (gnutls_session_t @var{session}, size_t @var{label_size}, const char * @var{label}, int @var{server_random_first}, size_t @var{extra_size}, const char * @var{extra}, size_t @var{outsize}, char * @var{out})
@var{session}: is a @code{gnutls_session_t} structure.

@var{label_size}: length of the @code{label} variable.

@var{label}: label used in PRF computation, typically a short string.

@var{server_random_first}: non-0 if server random field should be first in seed

@var{extra_size}: length of the @code{extra} variable.

@var{extra}: optional extra data to seed the PRF with.

@var{outsize}: size of pre-allocated output buffer to hold the output.

@var{out}: pre-allocate buffer to hold the generated data.

Apply the TLS Pseudo-Random-Function (PRF) using the master secret
on some data, seeded with the client and server random fields.

The @code{label} variable usually contain a string denoting the purpose
for the generated data.  The @code{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 @code{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 *@code{OUT}, which must be pre-allocated.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_priority_deinit
@anchor{gnutls_priority_deinit}
@deftypefun {void} {gnutls_priority_deinit} (gnutls_priority_t @var{priority_cache})
@var{priority_cache}: is a @code{gnutls_prioritity_t} structure.

Deinitializes the priority cache.
@end deftypefun

@subheading gnutls_priority_init
@anchor{gnutls_priority_init}
@deftypefun {int} {gnutls_priority_init} (gnutls_priority_t * @var{priority_cache}, const char * @var{priorities}, const char ** @var{err_pos})
@var{priority_cache}: is a @code{gnutls_prioritity_t} structure.

@var{priorities}: is a string describing priorities

@var{err_pos}: In case of an error this will have the position in the string the error occured

Sets priorities for the ciphers, key exchange methods, macs and
compression methods.

The @code{priorities} option allows you to specify a colon
separated list of the cipher priorities to enable.

@strong{Common keywords:} 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 with ciphers up to 128
bits, sorted by security margin.

"SECURE256" means all "secure" ciphersuites including the 256 bit
ciphers, sorted by security margin.

"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.

@strong{Special keywords:} "!" 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.

@strong{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", 

"NORMAL:@code{COMPAT}" is the most compatible mode.

@strong{Returns:} On syntax error @code{GNUTLS_E_INVALID_REQUEST} is returned,
@code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_priority_set_direct
@anchor{gnutls_priority_set_direct}
@deftypefun {int} {gnutls_priority_set_direct} (gnutls_session_t @var{session}, const char * @var{priorities}, const char ** @var{err_pos})
@var{session}: is a @code{gnutls_session_t} structure.

@var{priorities}: is a string describing priorities

@var{err_pos}: In case of an error this will have the position in the string the error occured

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 @code{gnutls_priority_init()}.

@strong{Returns:} On syntax error @code{GNUTLS_E_INVALID_REQUEST} is returned,
@code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_priority_set
@anchor{gnutls_priority_set}
@deftypefun {int} {gnutls_priority_set} (gnutls_session_t @var{session}, gnutls_priority_t @var{priority})
@var{session}: is a @code{gnutls_session_t} structure.

@var{priority}: is a @code{gnutls_priority_t} structure.

Sets the priorities to use on the ciphers, key exchange methods,
macs and compression methods.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_privkey_decrypt_data
@anchor{gnutls_privkey_decrypt_data}
@deftypefun {int} {gnutls_privkey_decrypt_data} (gnutls_privkey_t @var{key}, unsigned int @var{flags}, const gnutls_datum_t * @var{ciphertext}, gnutls_datum_t * @var{plaintext})
@var{key}: Holds the key

@var{flags}: zero for now

@var{ciphertext}: holds the data to be decrypted

@var{plaintext}: will contain the decrypted data, allocated with @code{gnutls_malloc()}

This function will decrypt the given data using the algorithm
supported by the private key.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_privkey_deinit
@anchor{gnutls_privkey_deinit}
@deftypefun {void} {gnutls_privkey_deinit} (gnutls_privkey_t @var{key})
@var{key}: The structure to be deinitialized

This function will deinitialize a private key structure.
@end deftypefun

@subheading gnutls_privkey_get_pk_algorithm
@anchor{gnutls_privkey_get_pk_algorithm}
@deftypefun {int} {gnutls_privkey_get_pk_algorithm} (gnutls_privkey_t @var{key}, unsigned int * @var{bits})
@var{key}: should contain a @code{gnutls_privkey_t} structure

@var{bits}: If set will return the number of bits of the parameters (may be NULL)

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.

@strong{Returns:} a member of the @code{gnutls_pk_algorithm_t} enumeration on
success, or a negative value on error.
@end deftypefun

@subheading gnutls_privkey_get_type
@anchor{gnutls_privkey_get_type}
@deftypefun {gnutls_privkey_type_t} {gnutls_privkey_get_type} (gnutls_privkey_t @var{key})
@var{key}: should contain a @code{gnutls_privkey_t} structure

This function will return the type of the private key. This is
actually the type of the subsystem used to set this private key.

@strong{Returns:} a member of the @code{gnutls_privkey_type_t} enumeration on
success, or a negative value on error.
@end deftypefun

@subheading gnutls_privkey_import_openpgp
@anchor{gnutls_privkey_import_openpgp}
@deftypefun {int} {gnutls_privkey_import_openpgp} (gnutls_privkey_t @var{pkey}, gnutls_openpgp_privkey_t @var{key}, unsigned int @var{flags})
@var{pkey}: The private key

@var{key}: The private key to be imported

@var{flags}: should be zero

This function will import the given private key to the abstract
@code{gnutls_privkey_t} structure.

The @code{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.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_privkey_import_pkcs11
@anchor{gnutls_privkey_import_pkcs11}
@deftypefun {int} {gnutls_privkey_import_pkcs11} (gnutls_privkey_t @var{pkey}, gnutls_pkcs11_privkey_t @var{key}, unsigned int @var{flags})
@var{pkey}: The private key

@var{key}: The private key to be imported

@var{flags}: should be zero

This function will import the given private key to the abstract
@code{gnutls_privkey_t} structure.

The @code{gnutls_pkcs11_privkey_t} object must not be deallocated
during the lifetime of this structure.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_privkey_import_x509
@anchor{gnutls_privkey_import_x509}
@deftypefun {int} {gnutls_privkey_import_x509} (gnutls_privkey_t @var{pkey}, gnutls_x509_privkey_t @var{key}, unsigned int @var{flags})
@var{pkey}: The private key

@var{key}: The private key to be imported

@var{flags}: should be zero

This function will import the given private key to the abstract
@code{gnutls_privkey_t} structure.

The @code{gnutls_x509_privkey_t} object must not be deallocated
during the lifetime of this structure.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_privkey_init
@anchor{gnutls_privkey_init}
@deftypefun {int} {gnutls_privkey_init} (gnutls_privkey_t * @var{key})
@var{key}: The structure to be initialized

This function will initialize an private key structure.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_privkey_sign_data
@anchor{gnutls_privkey_sign_data}
@deftypefun {int} {gnutls_privkey_sign_data} (gnutls_privkey_t @var{signer}, gnutls_digest_algorithm_t @var{hash}, unsigned int @var{flags}, const gnutls_datum_t * @var{data}, gnutls_datum_t * @var{signature})
@var{signer}: Holds the key

@var{hash}: should be a digest algorithm

@var{flags}: should be 0 for now

@var{data}: holds the data to be signed

@var{signature}: will contain the signature allocate with @code{gnutls_malloc()}

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 SHA-1 for the DSA keys.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.

@strong{Since:} 2.12.0
@end deftypefun

@subheading gnutls_privkey_sign_hash
@anchor{gnutls_privkey_sign_hash}
@deftypefun {int} {gnutls_privkey_sign_hash} (gnutls_privkey_t @var{signer}, gnutls_digest_algorithm_t @var{hash_algo}, unsigned int @var{flags}, const gnutls_datum_t * @var{hash_data}, gnutls_datum_t * @var{signature})
@var{signer}: Holds the signer's key

@var{hash_algo}: The hash algorithm used

@var{flags}: zero for now

@var{hash_data}: holds the data to be signed

@var{signature}: will contain newly allocated signature

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 @code{gnutls_x509_crt_get_preferred_hash_algorithm()} to determine
the hash algorithm.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.

@strong{Since:} 2.12.0
@end deftypefun

@subheading gnutls_protocol_get_id
@anchor{gnutls_protocol_get_id}
@deftypefun {gnutls_protocol_t} {gnutls_protocol_get_id} (const char * @var{name})
@var{name}: is a protocol name

The names are compared in a case insensitive way.

@strong{Returns:} an id of the specified protocol, or
@code{GNUTLS_VERSION_UNKNOWN} on error.
@end deftypefun

@subheading gnutls_protocol_get_name
@anchor{gnutls_protocol_get_name}
@deftypefun {const char *} {gnutls_protocol_get_name} (gnutls_protocol_t @var{version})
@var{version}: is a (gnutls) version number

Convert a @code{gnutls_protocol_t} value to a string.

@strong{Returns:} a string that contains the name of the specified TLS
version (e.g., "TLS1.0"), or @code{NULL}.
@end deftypefun

@subheading gnutls_protocol_get_version
@anchor{gnutls_protocol_get_version}
@deftypefun {gnutls_protocol_t} {gnutls_protocol_get_version} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

Get TLS version, a @code{gnutls_protocol_t} value.

@strong{Returns:} the version of the currently used protocol.
@end deftypefun

@subheading gnutls_protocol_list
@anchor{gnutls_protocol_list}
@deftypefun {const gnutls_protocol_t *} {gnutls_protocol_list} ( @var{void})

Get a list of supported protocols, e.g. SSL 3.0, TLS 1.0 etc.

@strong{Returns:} a zero-terminated list of @code{gnutls_protocol_t} integers
indicating the available protocols.
@end deftypefun

@subheading gnutls_protocol_set_priority
@anchor{gnutls_protocol_set_priority}
@deftypefun {int} {gnutls_protocol_set_priority} (gnutls_session_t @var{session}, const int * @var{list})
@var{session}: is a @code{gnutls_session_t} structure.

@var{list}: is a 0 terminated list of gnutls_protocol_t elements.

Sets the priority on the protocol versions supported by gnutls.
This function actually enables or disables protocols. Newer protocol
versions always have highest priority.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_psk_allocate_client_credentials
@anchor{gnutls_psk_allocate_client_credentials}
@deftypefun {int} {gnutls_psk_allocate_client_credentials} (gnutls_psk_client_credentials_t * @var{sc})
@var{sc}: is a pointer to a @code{gnutls_psk_server_credentials_t} structure.

This structure is complex enough to manipulate directly thus this
helper function is provided in order to allocate it.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_psk_allocate_server_credentials
@anchor{gnutls_psk_allocate_server_credentials}
@deftypefun {int} {gnutls_psk_allocate_server_credentials} (gnutls_psk_server_credentials_t * @var{sc})
@var{sc}: is a pointer to a @code{gnutls_psk_server_credentials_t} structure.

This structure is complex enough to manipulate directly thus this
helper function is provided in order to allocate it.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_psk_client_get_hint
@anchor{gnutls_psk_client_get_hint}
@deftypefun {const char *} {gnutls_psk_client_get_hint} (gnutls_session_t @var{session})
@var{session}: is a gnutls session

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.

@strong{Returns:} the identity hint of the peer, or @code{NULL} in case of an error.

@strong{Since:} 2.4.0
@end deftypefun

@subheading gnutls_psk_free_client_credentials
@anchor{gnutls_psk_free_client_credentials}
@deftypefun {void} {gnutls_psk_free_client_credentials} (gnutls_psk_client_credentials_t @var{sc})
@var{sc}: is a @code{gnutls_psk_client_credentials_t} structure.

This structure is complex enough to manipulate directly thus this
helper function is provided in order to free (deallocate) it.
@end deftypefun

@subheading gnutls_psk_free_server_credentials
@anchor{gnutls_psk_free_server_credentials}
@deftypefun {void} {gnutls_psk_free_server_credentials} (gnutls_psk_server_credentials_t @var{sc})
@var{sc}: is a @code{gnutls_psk_server_credentials_t} structure.

This structure is complex enough to manipulate directly thus this
helper function is provided in order to free (deallocate) it.
@end deftypefun

@subheading gnutls_psk_netconf_derive_key
@anchor{gnutls_psk_netconf_derive_key}
@deftypefun {int} {gnutls_psk_netconf_derive_key} (const char * @var{password}, const char * @var{psk_identity}, const char * @var{psk_identity_hint}, gnutls_datum_t * @var{output_key})
@var{password}: zero terminated string containing password.

@var{psk_identity}: zero terminated string with PSK identity.

@var{psk_identity_hint}: zero terminated string with PSK identity hint.

@var{output_key}: output variable, contains newly allocated *data pointer.

This function will derive a PSK key from a password, for use with
the Netconf protocol.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.

@strong{Since:} 2.4.0

@strong{Deprecated:} The need for this interface was dropped from the
standard on publication as a RFC.  The function works now but will
return a hard failure in a future release.
@end deftypefun

@subheading gnutls_psk_server_get_username
@anchor{gnutls_psk_server_get_username}
@deftypefun {const char *} {gnutls_psk_server_get_username} (gnutls_session_t @var{session})
@var{session}: is a gnutls session

This should only be called in case of PSK authentication and in
case of a server.

@strong{Returns:} the username of the peer, or @code{NULL} in case of an error.
@end deftypefun

@subheading gnutls_psk_set_client_credentials_function
@anchor{gnutls_psk_set_client_credentials_function}
@deftypefun {void} {gnutls_psk_set_client_credentials_function} (gnutls_psk_client_credentials_t                                             @var{cred}, gnutls_psk_client_credentials_function                                             * @var{func})
@var{cred}: is a @code{gnutls_psk_server_credentials_t} structure.

@var{func}: is the callback function

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 @code{username} and @code{key}->data must be allocated using @code{gnutls_malloc()}.
@code{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.
@end deftypefun

@subheading gnutls_psk_set_client_credentials
@anchor{gnutls_psk_set_client_credentials}
@deftypefun {int} {gnutls_psk_set_client_credentials} (gnutls_psk_client_credentials_t @var{res}, const char * @var{username}, const gnutls_datum_t * @var{key}, gnutls_psk_key_flags @var{flags})
@var{res}: is a @code{gnutls_psk_client_credentials_t} structure.

@var{username}: is the user's zero-terminated userid

@var{key}: is the user's key

This function sets the username and password, in a
gnutls_psk_client_credentials_t structure.  Those will be used in
PSK authentication.  @code{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).

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_psk_set_params_function
@anchor{gnutls_psk_set_params_function}
@deftypefun {void} {gnutls_psk_set_params_function} (gnutls_psk_server_credentials_t @var{res}, gnutls_params_function * @var{func})
@var{res}: is a gnutls_psk_server_credentials_t structure

@var{func}: is the function to be called

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 zero on success.
@end deftypefun

@subheading gnutls_psk_set_server_credentials_file
@anchor{gnutls_psk_set_server_credentials_file}
@deftypefun {int} {gnutls_psk_set_server_credentials_file} (gnutls_psk_server_credentials_t                                         @var{res}, const char * @var{password_file})
@var{res}: is a @code{gnutls_psk_server_credentials_t} structure.

@var{password_file}: is the PSK password file (passwd.psk)

This function sets the password file, in a
@code{gnutls_psk_server_credentials_t} structure.  This password file
holds usernames and keys and will be used for PSK authentication.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_psk_set_server_credentials_function
@anchor{gnutls_psk_set_server_credentials_function}
@deftypefun {void} {gnutls_psk_set_server_credentials_function} (gnutls_psk_server_credentials_t                                             @var{cred}, gnutls_psk_server_credentials_function                                             * @var{func})
@var{cred}: is a @code{gnutls_psk_server_credentials_t} structure.

@var{func}: is the callback function

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);

@code{username} contains the actual username.
The @code{key} must be filled in using the @code{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.
@end deftypefun

@subheading gnutls_psk_set_server_credentials_hint
@anchor{gnutls_psk_set_server_credentials_hint}
@deftypefun {int} {gnutls_psk_set_server_credentials_hint} (gnutls_psk_server_credentials_t @var{res}, const char * @var{hint})
@var{res}: is a @code{gnutls_psk_server_credentials_t} structure.

@var{hint}: is the PSK identity hint string

This function sets the identity hint, in a
@code{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).

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.

@strong{Since:} 2.4.0
@end deftypefun

@subheading gnutls_psk_set_server_dh_params
@anchor{gnutls_psk_set_server_dh_params}
@deftypefun {void} {gnutls_psk_set_server_dh_params} (gnutls_psk_server_credentials_t @var{res}, gnutls_dh_params_t @var{dh_params})
@var{res}: is a gnutls_psk_server_credentials_t structure

@var{dh_params}: is a structure that holds Diffie-Hellman parameters.

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.
@end deftypefun

@subheading gnutls_psk_set_server_params_function
@anchor{gnutls_psk_set_server_params_function}
@deftypefun {void} {gnutls_psk_set_server_params_function} (gnutls_psk_server_credentials_t @var{res}, gnutls_params_function * @var{func})
@var{res}: is a @code{gnutls_certificate_credentials_t} structure

@var{func}: is the function to be called

This function will set a callback in order for the server to get
the Diffie-Hellman parameters for PSK authentication.  The callback
should return zero on success.
@end deftypefun

@subheading gnutls_pubkey_deinit
@anchor{gnutls_pubkey_deinit}
@deftypefun {void} {gnutls_pubkey_deinit} (gnutls_pubkey_t @var{key})
@var{key}: The structure to be deinitialized

This function will deinitialize a public key structure.
@end deftypefun

@subheading gnutls_pubkey_export
@anchor{gnutls_pubkey_export}
@deftypefun {int} {gnutls_pubkey_export} (gnutls_pubkey_t @var{key}, gnutls_x509_crt_fmt_t @var{format}, void * @var{output_data}, size_t * @var{output_data_size})
@var{key}: Holds the certificate

@var{format}: the format of output params. One of PEM or DER.

@var{output_data}: will contain a certificate PEM or DER encoded

@var{output_data_size}: holds the size of output_data (and will be
replaced by the actual size of parameters)

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".

@strong{Return value:} In case of failure a negative value will be
returned, and 0 on success.
@end deftypefun

@subheading gnutls_pubkey_get_key_id
@anchor{gnutls_pubkey_get_key_id}
@deftypefun {int} {gnutls_pubkey_get_key_id} (gnutls_pubkey_t @var{key}, unsigned int @var{flags}, unsigned char * @var{output_data}, size_t * @var{output_data_size})
@var{key}: Holds the public key

@var{flags}: should be 0 for now

@var{output_data}: will contain the key ID

@var{output_data_size}: holds the size of output_data (and will be
replaced by the actual size of parameters)

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.

@strong{Return value:} In case of failure a negative value will be
returned, and 0 on success.
@end deftypefun

@subheading gnutls_pubkey_get_key_usage
@anchor{gnutls_pubkey_get_key_usage}
@deftypefun {int} {gnutls_pubkey_get_key_usage} (gnutls_pubkey_t @var{key}, unsigned int * @var{usage})
@var{key}: should contain a @code{gnutls_pubkey_t} structure

@var{usage}: If set will return the number of bits of the parameters (may be NULL)

This function will return the key usage of the public key.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pubkey_get_pk_algorithm
@anchor{gnutls_pubkey_get_pk_algorithm}
@deftypefun {int} {gnutls_pubkey_get_pk_algorithm} (gnutls_pubkey_t @var{key}, unsigned int * @var{bits})
@var{key}: should contain a @code{gnutls_pubkey_t} structure

@var{bits}: If set will return the number of bits of the parameters (may be NULL)

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.

@strong{Returns:} a member of the @code{gnutls_pk_algorithm_t} enumeration on
success, or a negative value on error.
@end deftypefun

@subheading gnutls_pubkey_get_pk_dsa_raw
@anchor{gnutls_pubkey_get_pk_dsa_raw}
@deftypefun {int} {gnutls_pubkey_get_pk_dsa_raw} (gnutls_pubkey_t @var{key}, gnutls_datum_t * @var{p}, gnutls_datum_t * @var{q}, gnutls_datum_t * @var{g}, gnutls_datum_t * @var{y})
@var{key}: Holds the public key

@var{p}: will hold the p

@var{q}: will hold the q

@var{g}: will hold the g

@var{y}: will hold the y

This function will export the DSA public key's parameters found in
the given certificate.  The new parameters will be allocated using
@code{gnutls_malloc()} and will be stored in the appropriate datum.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, otherwise an error.
@end deftypefun

@subheading gnutls_pubkey_get_pk_rsa_raw
@anchor{gnutls_pubkey_get_pk_rsa_raw}
@deftypefun {int} {gnutls_pubkey_get_pk_rsa_raw} (gnutls_pubkey_t @var{key}, gnutls_datum_t * @var{m}, gnutls_datum_t * @var{e})
@var{key}: Holds the certificate

@var{m}: will hold the modulus

@var{e}: will hold the public exponent

This function will export the RSA public key's parameters found in
the given structure.  The new parameters will be allocated using
@code{gnutls_malloc()} and will be stored in the appropriate datum.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, otherwise an error.
@end deftypefun

@subheading gnutls_pubkey_get_preferred_hash_algorithm
@anchor{gnutls_pubkey_get_preferred_hash_algorithm}
@deftypefun {int} {gnutls_pubkey_get_preferred_hash_algorithm} (gnutls_pubkey_t @var{key}, gnutls_digest_algorithm_t *                                             @var{hash}, unsigned int * @var{mand})
@var{key}: Holds the certificate

@var{hash}: The result of the call with the hash algorithm used for signature

@var{mand}: If non zero it means that the algorithm MUST use this hash. May be NULL.

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).

@strong{Returns:} the 0 if the hash algorithm is found. A negative value is
returned on error.

@strong{Since:} 2.11.0
@end deftypefun

@subheading gnutls_pubkey_get_verify_algorithm
@anchor{gnutls_pubkey_get_verify_algorithm}
@deftypefun {int} {gnutls_pubkey_get_verify_algorithm} (gnutls_pubkey_t @var{key}, const gnutls_datum_t * @var{signature}, gnutls_digest_algorithm_t * @var{hash})
@var{key}: Holds the certificate

@var{signature}: contains the signature

@var{hash}: The result of the call with the hash algorithm used for signature

This function will read the certifcate and the signed data to
determine the hash algorithm used to generate the signature.

@strong{Returns:} the 0 if the hash algorithm is found. A negative value is
returned on error.
@end deftypefun

@subheading gnutls_pubkey_import_dsa_raw
@anchor{gnutls_pubkey_import_dsa_raw}
@deftypefun {int} {gnutls_pubkey_import_dsa_raw} (gnutls_pubkey_t @var{key}, const gnutls_datum_t * @var{p}, const gnutls_datum_t * @var{q}, const gnutls_datum_t * @var{g}, const gnutls_datum_t * @var{y})
@var{key}: The structure to store the parsed key

@var{p}: holds the p

@var{q}: holds the q

@var{g}: holds the g

@var{y}: holds the y

This function will convert the given DSA raw parameters to the
native @code{gnutls_pubkey_t} format.  The output will be stored
in @code{key}.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pubkey_import_openpgp
@anchor{gnutls_pubkey_import_openpgp}
@deftypefun {int} {gnutls_pubkey_import_openpgp} (gnutls_pubkey_t @var{key}, gnutls_openpgp_crt_t @var{crt}, unsigned int @var{flags})
@var{key}: The public key

@var{crt}: The certificate to be imported

@var{flags}: should be zero

This function will import the given public key to the abstract
@code{gnutls_pubkey_t} structure. The subkey set as preferred will be
imported or the master key otherwise.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pubkey_import_pkcs11_url
@anchor{gnutls_pubkey_import_pkcs11_url}
@deftypefun {int} {gnutls_pubkey_import_pkcs11_url} (gnutls_pubkey_t @var{key}, const char * @var{url}, unsigned int @var{flags})
@var{key}: A key of type @code{gnutls_pubkey_t}

@var{url}: A PKCS 11 url

@var{flags}: One of GNUTLS_PKCS11_OBJ_* flags

This function will import a PKCS 11 certificate to a @code{gnutls_pubkey_t}
structure.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pubkey_import_pkcs11
@anchor{gnutls_pubkey_import_pkcs11}
@deftypefun {int} {gnutls_pubkey_import_pkcs11} (gnutls_pubkey_t @var{key}, gnutls_pkcs11_obj_t @var{obj}, unsigned int @var{flags})
@var{key}: The public key

@var{obj}: The parameters to be imported

@var{flags}: should be zero

This function will import the given public key to the abstract
@code{gnutls_pubkey_t} structure.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pubkey_import_privkey
@anchor{gnutls_pubkey_import_privkey}
@deftypefun {int} {gnutls_pubkey_import_privkey} (gnutls_pubkey_t @var{key}, gnutls_privkey_t @var{pkey}, unsigned int @var{usage}, unsigned int @var{flags})
@var{key}: The public key

@var{pkey}: The private key

@var{usage}: GNUTLS_KEY_* key usage flags.

@var{flags}: should be zero

This function will import the given public key to the abstract
@code{gnutls_pubkey_t} structure.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.

@strong{Since:} 2.12.0
@end deftypefun

@subheading gnutls_pubkey_import_rsa_raw
@anchor{gnutls_pubkey_import_rsa_raw}
@deftypefun {int} {gnutls_pubkey_import_rsa_raw} (gnutls_pubkey_t @var{key}, const gnutls_datum_t * @var{m}, const gnutls_datum_t * @var{e})
@var{key}: Is a structure will hold the parameters

@var{m}: holds the modulus

@var{e}: holds the public exponent

This function will replace the parameters in the given structure.
The new parameters should be stored in the appropriate
gnutls_datum.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an negative error code.
@end deftypefun

@subheading gnutls_pubkey_import_x509
@anchor{gnutls_pubkey_import_x509}
@deftypefun {int} {gnutls_pubkey_import_x509} (gnutls_pubkey_t @var{key}, gnutls_x509_crt_t @var{crt}, unsigned int @var{flags})
@var{key}: The public key

@var{crt}: The certificate to be imported

@var{flags}: should be zero

This function will import the given public key to the abstract
@code{gnutls_pubkey_t} structure.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pubkey_import
@anchor{gnutls_pubkey_import}
@deftypefun {int} {gnutls_pubkey_import} (gnutls_pubkey_t @var{key}, const gnutls_datum_t * @var{data}, gnutls_x509_crt_fmt_t @var{format})
@var{key}: The structure to store the parsed public key. 

@var{data}: The DER or PEM encoded certificate. 

@var{format}: One of DER or PEM 

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". 

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pubkey_init
@anchor{gnutls_pubkey_init}
@deftypefun {int} {gnutls_pubkey_init} (gnutls_pubkey_t * @var{key})
@var{key}: The structure to be initialized

This function will initialize an public key structure.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pubkey_set_key_usage
@anchor{gnutls_pubkey_set_key_usage}
@deftypefun {int} {gnutls_pubkey_set_key_usage} (gnutls_pubkey_t @var{key}, unsigned int @var{usage})
@var{key}: a certificate of type @code{gnutls_x509_crt_t}

@var{usage}: an ORed sequence of the GNUTLS_KEY_* elements.

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.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_pubkey_verify_data
@anchor{gnutls_pubkey_verify_data}
@deftypefun {int} {gnutls_pubkey_verify_data} (gnutls_pubkey_t @var{pubkey}, unsigned int @var{flags}, const gnutls_datum_t * @var{data}, const gnutls_datum_t * @var{signature})
@var{pubkey}: Holds the public key

@var{flags}: should be 0 for now

@var{data}: holds the data to be signed

@var{signature}: contains the signature

This function will verify the given signed data, using the
parameters from the certificate.

@strong{Returns:} In case of a verification failure
@code{GNUTLS_E_PK_SIG_VERIFY_FAILED} is returned, and a positive code
on success.

@strong{Since:} 2.12.0
@end deftypefun

@subheading gnutls_pubkey_verify_hash
@anchor{gnutls_pubkey_verify_hash}
@deftypefun {int} {gnutls_pubkey_verify_hash} (gnutls_pubkey_t @var{key}, unsigned int @var{flags}, const gnutls_datum_t * @var{hash}, const gnutls_datum_t * @var{signature})
@var{key}: Holds the certificate

@var{flags}: should be 0 for now

@var{hash}: holds the hash digest to be verified

@var{signature}: contains the signature

This function will verify the given signed digest, using the
parameters from the certificate.

@strong{Returns:} In case of a verification failure @code{GNUTLS_E_PK_SIG_VERIFY_FAILED} 
is returned, and a positive code on success.
@end deftypefun

@subheading gnutls_record_check_pending
@anchor{gnutls_record_check_pending}
@deftypefun {size_t} {gnutls_record_check_pending} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

This function checks if there are any data to receive in the gnutls
buffers.

@strong{Returns:} the size of that data or 0.
@end deftypefun

@subheading gnutls_record_disable_padding
@anchor{gnutls_record_disable_padding}
@deftypefun {void} {gnutls_record_disable_padding} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

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.
@end deftypefun

@subheading gnutls_record_get_direction
@anchor{gnutls_record_get_direction}
@deftypefun {int} {gnutls_record_get_direction} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

This function provides information about the internals of the
record protocol and is only useful if a prior gnutls function call
(e.g.  @code{gnutls_handshake()}) was interrupted for some reason, that
is, if a function returned @code{GNUTLS_E_INTERRUPTED} or
@code{GNUTLS_E_AGAIN}.  In such a case, you might want to call @code{select()}
or @code{poll()} before calling the interrupted gnutls function again.  To
tell you whether a file descriptor should be selected for either
reading or writing, @code{gnutls_record_get_direction()} returns 0 if the
interrupted function was trying to read data, and 1 if it was
trying to write data.

@strong{Returns:} 0 if trying to read data, 1 if trying to write data.
@end deftypefun

@subheading gnutls_record_get_max_size
@anchor{gnutls_record_get_max_size}
@deftypefun {size_t} {gnutls_record_get_max_size} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

Get the record size.  The maximum record size is negotiated by the
client after the first handshake message.

@strong{Returns:} The maximum record packet size in this connection.
@end deftypefun

@subheading gnutls_record_recv
@anchor{gnutls_record_recv}
@deftypefun {ssize_t} {gnutls_record_recv} (gnutls_session_t @var{session}, void * @var{data}, size_t @var{sizeofdata})
@var{session}: is a @code{gnutls_session_t} structure.

@var{data}: the buffer that the data will be read into

@var{sizeofdata}: the number of requested bytes

This function has the similar semantics with @code{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 @code{GNUTLS_E_REHANDSHAKE}.  This
message may be simply ignored, replied with an alert
@code{GNUTLS_A_NO_RENEGOTIATION}, or replied with a new handshake,
depending on the client's will.

If @code{EINTR} is returned by the internal push function (the default
is @code{recv()}) then @code{GNUTLS_E_INTERRUPTED} will be returned.  If
@code{GNUTLS_E_INTERRUPTED} or @code{GNUTLS_E_AGAIN} is returned, you must
call this function again to get the data.  See also
@code{gnutls_record_get_direction()}.

A server may also receive @code{GNUTLS_E_REHANDSHAKE} when a client has
initiated a handshake. In that case the server can only initiate a
handshake or terminate the connection.

@strong{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 @code{sizeofdata}.
@end deftypefun

@subheading gnutls_record_send
@anchor{gnutls_record_send}
@deftypefun {ssize_t} {gnutls_record_send} (gnutls_session_t @var{session}, const void * @var{data}, size_t @var{sizeofdata})
@var{session}: is a @code{gnutls_session_t} structure.

@var{data}: contains the data to send

@var{sizeofdata}: is the length of the data

This function has the similar semantics with @code{send()}.  The only
difference is that it accepts a GnuTLS session, and uses different
error codes.

Note that if the send buffer is full, @code{send()} will block this
function.  See the @code{send()} documentation for full information.  You
can replace the default push function by using
@code{gnutls_transport_set_ptr2()} with a call to @code{send()} with a
MSG_DONTWAIT flag if blocking is a problem.

If the EINTR is returned by the internal push function (the
default is @code{send()}@} then @code{GNUTLS_E_INTERRUPTED} will be returned. If
@code{GNUTLS_E_INTERRUPTED} or @code{GNUTLS_E_AGAIN} is returned, you must
call this function again, with the same parameters; alternatively
you could provide a @code{NULL} pointer for data, and 0 for
size. cf. @code{gnutls_record_get_direction()}.

@strong{Returns:} the number of bytes sent, or a negative error code.  The
number of bytes sent might be less than @code{sizeofdata}.  The maximum
number of bytes this function can send in a single call depends
on the negotiated maximum record size.
@end deftypefun

@subheading gnutls_record_set_max_size
@anchor{gnutls_record_set_max_size}
@deftypefun {ssize_t} {gnutls_record_set_max_size} (gnutls_session_t @var{session}, size_t @var{size})
@var{session}: is a @code{gnutls_session_t} structure.

@var{size}: is the new size

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.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (zero) is returned,
otherwise an error code is returned.
@end deftypefun

@subheading gnutls_rehandshake
@anchor{gnutls_rehandshake}
@deftypefun {int} {gnutls_rehandshake} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

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
@code{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 @code{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
@code{GNUTLS_E_WARNING_ALERT_RECEIVED} and the alert will be
@code{GNUTLS_A_NO_RENEGOTIATION}.  A client may also choose to ignore
this message.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, otherwise an error.
@end deftypefun

@subheading gnutls_rnd
@anchor{gnutls_rnd}
@deftypefun {int} {gnutls_rnd} (gnutls_rnd_level_t @var{level}, void * @var{data}, size_t @var{len})
@var{level}: a security level

@var{data}: place to store random bytes

@var{len}: The requested size

This function will generate random data and store it
to output buffer.

@strong{Returns:} Zero or a negative value on error.
@end deftypefun

@subheading gnutls_rsa_export_get_modulus_bits
@anchor{gnutls_rsa_export_get_modulus_bits}
@deftypefun {int} {gnutls_rsa_export_get_modulus_bits} (gnutls_session_t @var{session})
@var{session}: is a gnutls session

Get the export RSA parameter's modulus size.

@strong{Returns:} the bits used in the last RSA-EXPORT key exchange with the
peer, or a negative value in case of error.
@end deftypefun

@subheading gnutls_rsa_export_get_pubkey
@anchor{gnutls_rsa_export_get_pubkey}
@deftypefun {int} {gnutls_rsa_export_get_pubkey} (gnutls_session_t @var{session}, gnutls_datum_t * @var{exponent}, gnutls_datum_t * @var{modulus})
@var{session}: is a gnutls session

@var{exponent}: will hold the exponent.

@var{modulus}: will hold the modulus.

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 @code{gnutls_free()}.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, otherwise
an error code is returned.
@end deftypefun

@subheading gnutls_rsa_params_cpy
@anchor{gnutls_rsa_params_cpy}
@deftypefun {int} {gnutls_rsa_params_cpy} (gnutls_rsa_params_t @var{dst}, gnutls_rsa_params_t @var{src})
@var{dst}: Is the destination structure, which should be initialized.

@var{src}: Is the source structure

This function will copy the RSA parameters structure from source
to destination.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an negative error code.
@end deftypefun

@subheading gnutls_rsa_params_deinit
@anchor{gnutls_rsa_params_deinit}
@deftypefun {void} {gnutls_rsa_params_deinit} (gnutls_rsa_params_t @var{rsa_params})
@var{rsa_params}: Is a structure that holds the parameters

This function will deinitialize the RSA parameters structure.
@end deftypefun

@subheading gnutls_rsa_params_export_pkcs1
@anchor{gnutls_rsa_params_export_pkcs1}
@deftypefun {int} {gnutls_rsa_params_export_pkcs1} (gnutls_rsa_params_t @var{params}, gnutls_x509_crt_fmt_t @var{format}, unsigned char * @var{params_data}, size_t * @var{params_data_size})
@var{params}: Holds the RSA parameters

@var{format}: the format of output params. One of PEM or DER.

@var{params_data}: will contain a PKCS1 RSAPublicKey structure PEM or DER encoded

@var{params_data_size}: holds the size of params_data (and will be replaced by the actual size of parameters)

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".

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an negative error code.
@end deftypefun

@subheading gnutls_rsa_params_export_raw
@anchor{gnutls_rsa_params_export_raw}
@deftypefun {int} {gnutls_rsa_params_export_raw} (gnutls_rsa_params_t @var{params}, gnutls_datum_t * @var{m}, gnutls_datum_t * @var{e}, gnutls_datum_t * @var{d}, gnutls_datum_t * @var{p}, gnutls_datum_t * @var{q}, gnutls_datum_t * @var{u}, unsigned int * @var{bits})
@var{params}: a structure that holds the rsa parameters

@var{m}: will hold the modulus

@var{e}: will hold the public exponent

@var{d}: will hold the private exponent

@var{p}: will hold the first prime (p)

@var{q}: will hold the second prime (q)

@var{u}: will hold the coefficient

@var{bits}: if non null will hold the prime's number of bits

This function will export the RSA parameters found in the given
structure. The new parameters will be allocated using
@code{gnutls_malloc()} and will be stored in the appropriate datum.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an negative error code.
@end deftypefun

@subheading gnutls_rsa_params_generate2
@anchor{gnutls_rsa_params_generate2}
@deftypefun {int} {gnutls_rsa_params_generate2} (gnutls_rsa_params_t @var{params}, unsigned int @var{bits})
@var{params}: The structure where the parameters will be stored

@var{bits}: is the prime's number of bits

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.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an negative error code.
@end deftypefun

@subheading gnutls_rsa_params_import_pkcs1
@anchor{gnutls_rsa_params_import_pkcs1}
@deftypefun {int} {gnutls_rsa_params_import_pkcs1} (gnutls_rsa_params_t @var{params}, const gnutls_datum_t * @var{pkcs1_params}, gnutls_x509_crt_fmt_t @var{format})
@var{params}: A structure where the parameters will be copied to

@var{pkcs1_params}: should contain a PKCS1 RSAPublicKey structure PEM or DER encoded

@var{format}: the format of params. PEM or DER.

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".

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an negative error code.
@end deftypefun

@subheading gnutls_rsa_params_import_raw
@anchor{gnutls_rsa_params_import_raw}
@deftypefun {int} {gnutls_rsa_params_import_raw} (gnutls_rsa_params_t @var{rsa_params}, const gnutls_datum_t * @var{m}, const gnutls_datum_t * @var{e}, const gnutls_datum_t * @var{d}, const gnutls_datum_t * @var{p}, const gnutls_datum_t * @var{q}, const gnutls_datum_t * @var{u})
@var{rsa_params}: Is a structure will hold the parameters

@var{m}: holds the modulus

@var{e}: holds the public exponent

@var{d}: holds the private exponent

@var{p}: holds the first prime (p)

@var{q}: holds the second prime (q)

@var{u}: holds the coefficient

This function will replace the parameters in the given structure.
The new parameters should be stored in the appropriate
gnutls_datum.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an negative error code.
@end deftypefun

@subheading gnutls_rsa_params_init
@anchor{gnutls_rsa_params_init}
@deftypefun {int} {gnutls_rsa_params_init} (gnutls_rsa_params_t * @var{rsa_params})
@var{rsa_params}: Is a structure that will hold the parameters

This function will initialize the temporary RSA parameters structure.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an negative error code.
@end deftypefun

@subheading gnutls_safe_renegotiation_status
@anchor{gnutls_safe_renegotiation_status}
@deftypefun {int} {gnutls_safe_renegotiation_status} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

Can be used to check whether safe renegotiation is being used
in the current session.

@strong{Returns:} 0 when safe renegotiation is not used and non zero when
safe renegotiation is used.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_sec_param_get_name
@anchor{gnutls_sec_param_get_name}
@deftypefun {const char *} {gnutls_sec_param_get_name} (gnutls_sec_param_t @var{param})
@var{param}: is a security parameter

Convert a @code{gnutls_sec_param_t} value to a string.

@strong{Returns:} a pointer to a string that contains the name of the
specified public key algorithm, or @code{NULL}.
@end deftypefun

@subheading gnutls_sec_param_to_pk_bits
@anchor{gnutls_sec_param_to_pk_bits}
@deftypefun {unsigned int} {gnutls_sec_param_to_pk_bits} (gnutls_pk_algorithm_t @var{algo}, gnutls_sec_param_t @var{param})
@var{algo}: is a public key algorithm

@var{param}: is a security parameter

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.

@strong{Returns:} The number of bits, or zero.
@end deftypefun

@subheading gnutls_server_name_get
@anchor{gnutls_server_name_get}
@deftypefun {int} {gnutls_server_name_get} (gnutls_session_t @var{session}, void * @var{data}, size_t * @var{data_length}, unsigned int * @var{type}, unsigned int @var{indx})
@var{session}: is a @code{gnutls_session_t} structure.

@var{data}: will hold the data

@var{data_length}: will hold the data length. Must hold the maximum size of data.

@var{type}: will hold the server name indicator type

@var{indx}: is the index of the server_name

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 @code{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 @code{data} has not enough size to hold the server name
GNUTLS_E_SHORT_MEMORY_BUFFER is returned, and @code{data_length} will
hold the required size.

@code{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.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (zero) is returned,
otherwise an error code is returned.
@end deftypefun

@subheading gnutls_server_name_set
@anchor{gnutls_server_name_set}
@deftypefun {int} {gnutls_server_name_set} (gnutls_session_t @var{session}, gnutls_server_name_type_t @var{type}, const void * @var{name}, size_t @var{name_length})
@var{session}: is a @code{gnutls_session_t} structure.

@var{type}: specifies the indicator type

@var{name}: is a string that contains the server name.

@var{name_length}: holds the length of name

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 @code{name} depends on the @code{type} type.  In case of
@code{GNUTLS_NAME_DNS}, an ASCII zero-terminated domain name string,
without the trailing dot, is expected.  IPv4 or IPv6 addresses are
not permitted.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (zero) is returned,
otherwise an error code is returned.
@end deftypefun

@subheading gnutls_session_channel_binding
@anchor{gnutls_session_channel_binding}
@deftypefun {int} {gnutls_session_channel_binding} (gnutls_session_t @var{session}, gnutls_channel_binding_t @var{cbtype}, gnutls_datum_t * @var{cb})
@var{session}: is a @code{gnutls_session_t} structure.

@var{cbtype}: an @code{gnutls_channel_binding_t} enumeration type

@var{cb}: output buffer array with data

Extract given channel binding data of the @code{cbtype} (e.g.,
@code{GNUTLS_CB_TLS_UNIQUE}) type.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success,
@code{GNUTLS_E_UNIMPLEMENTED_FEATURE} if the @code{cbtype} is unsupported,
@code{GNUTLS_E_CHANNEL_BINDING_NOT_AVAILABLE} if the data is not
currently available, or an error code.

@strong{Since:} 2.12.0
@end deftypefun

@subheading gnutls_session_enable_compatibility_mode
@anchor{gnutls_session_enable_compatibility_mode}
@deftypefun {void} {gnutls_session_enable_compatibility_mode} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

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:
@code{gnutls_record_disable_padding()}

Normally only servers that require maximum compatibility with
everything out there, need to call this function.
@end deftypefun

@subheading gnutls_session_get_data2
@anchor{gnutls_session_get_data2}
@deftypefun {int} {gnutls_session_get_data2} (gnutls_session_t @var{session}, gnutls_datum_t * @var{data})
@var{session}: is a @code{gnutls_session_t} structure.

@var{data}: is a pointer to a datum that will hold the session.

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
@code{gnutls_session_set_data()}.  This function must be called after a
successful handshake.  The returned datum must be freed with
@code{gnutls_free()}.

Resuming sessions is really useful and speedups connections after
a successful one.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, otherwise
an error code is returned.
@end deftypefun

@subheading gnutls_session_get_data
@anchor{gnutls_session_get_data}
@deftypefun {int} {gnutls_session_get_data} (gnutls_session_t @var{session}, void * @var{session_data}, size_t * @var{session_data_size})
@var{session}: is a @code{gnutls_session_t} structure.

@var{session_data}: is a pointer to space to hold the session.

@var{session_data_size}: is the session_data's size, or it will be set by the function.

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
@code{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.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, otherwise
an error code is returned.
@end deftypefun

@subheading gnutls_session_get_id
@anchor{gnutls_session_get_id}
@deftypefun {int} {gnutls_session_get_id} (gnutls_session_t @var{session}, void * @var{session_id}, size_t * @var{session_id_size})
@var{session}: is a @code{gnutls_session_t} structure.

@var{session_id}: is a pointer to space to hold the session id.

@var{session_id_size}: is the session id's size, or it will be set by the function.

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.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, otherwise
an error code is returned.
@end deftypefun

@subheading gnutls_session_get_ptr
@anchor{gnutls_session_get_ptr}
@deftypefun {void *} {gnutls_session_get_ptr} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

Get user pointer for session.  Useful in callbacks.  This is the
pointer set with @code{gnutls_session_set_ptr()}.

@strong{Returns:} the user given pointer from the session structure, or
@code{NULL} if it was never set.
@end deftypefun

@subheading gnutls_session_is_resumed
@anchor{gnutls_session_is_resumed}
@deftypefun {int} {gnutls_session_is_resumed} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

Check whether session is resumed or not.

@strong{Returns:} non zero if this session is resumed, or a zero if this is
a new session.
@end deftypefun

@subheading gnutls_session_set_data
@anchor{gnutls_session_set_data}
@deftypefun {int} {gnutls_session_set_data} (gnutls_session_t @var{session}, const void * @var{session_data}, size_t @var{session_data_size})
@var{session}: is a @code{gnutls_session_t} structure.

@var{session_data}: is a pointer to space to hold the session.

@var{session_data_size}: is the session's size

Sets all session parameters, in order to resume a previously
established session.  The session data given must be the one
returned by @code{gnutls_session_get_data()}.  This function should be
called before @code{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.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, otherwise
an error code is returned.
@end deftypefun

@subheading gnutls_session_set_ptr
@anchor{gnutls_session_set_ptr}
@deftypefun {void} {gnutls_session_set_ptr} (gnutls_session_t @var{session}, void * @var{ptr})
@var{session}: is a @code{gnutls_session_t} structure.

@var{ptr}: is the user pointer

This function will set (associate) the user given pointer @code{ptr} to
the session structure.  This is pointer can be accessed with
@code{gnutls_session_get_ptr()}.
@end deftypefun

@subheading gnutls_session_ticket_enable_client
@anchor{gnutls_session_ticket_enable_client}
@deftypefun {int} {gnutls_session_ticket_enable_client} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

Request that the client should attempt session resumption using
SessionTicket.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, or an
error code.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_session_ticket_enable_server
@anchor{gnutls_session_ticket_enable_server}
@deftypefun {int} {gnutls_session_ticket_enable_server} (gnutls_session_t @var{session}, const gnutls_datum_t * @var{key})
@var{session}: is a @code{gnutls_session_t} structure.

@var{key}: key to encrypt session parameters.

Request that the server should attempt session resumption using
SessionTicket.  @code{key} must be initialized with
@code{gnutls_session_ticket_key_generate()}.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, or an
error code.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_session_ticket_key_generate
@anchor{gnutls_session_ticket_key_generate}
@deftypefun {int} {gnutls_session_ticket_key_generate} (gnutls_datum_t * @var{key})
@var{key}: is a pointer to a @code{gnutls_datum_t} which will contain a newly
created key.

Generate a random key to encrypt security parameters within
SessionTicket.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, or an
error code.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_set_default_export_priority
@anchor{gnutls_set_default_export_priority}
@deftypefun {int} {gnutls_set_default_export_priority} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

Sets some default priority on the ciphers, key exchange methods, macs
and compression methods.  This function also includes weak algorithms.

@strong{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
@code{gnutls_priority_set_direct()} or @code{gnutls_priority_set()} instead.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_set_default_priority
@anchor{gnutls_set_default_priority}
@deftypefun {int} {gnutls_set_default_priority} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

Sets some default priority on the ciphers, key exchange methods,
macs and compression methods.

@strong{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
@code{gnutls_priority_set_direct()} or @code{gnutls_priority_set()} instead.

@strong{Returns:} @code{GNUTLS_E_SUCCESS} on success, or an error code.
@end deftypefun

@subheading gnutls_sign_algorithm_get_name
@anchor{gnutls_sign_algorithm_get_name}
@deftypefun {const char *} {gnutls_sign_algorithm_get_name} (gnutls_sign_algorithm_t @var{sign})
@var{sign}: is a sign algorithm

Convert a @code{gnutls_sign_algorithm_t} value to a string.

@strong{Returns:} a string that contains the name of the specified sign
algorithm, or @code{NULL}.
@end deftypefun

@subheading gnutls_sign_algorithm_get_requested
@anchor{gnutls_sign_algorithm_get_requested}
@deftypefun {int} {gnutls_sign_algorithm_get_requested} (gnutls_session_t @var{session}, size_t @var{indx}, gnutls_sign_algorithm_t * @var{algo})
@var{session}: is a @code{gnutls_session_t} structure.

@var{indx}: is an index of the signature algorithm to return

@var{algo}: the returned certificate type will be stored there

Returns the signature algorithm specified by index that was
requested by the peer. If the specified index has no data available
this function returns @code{GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE}.  If
the negotiated TLS version does not support signature algorithms
then @code{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.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, otherwise
an error code is returned.

@strong{Since:} 2.10.0
@end deftypefun

@subheading gnutls_sign_callback_get
@anchor{gnutls_sign_callback_get}
@deftypefun {gnutls_sign_func} {gnutls_sign_callback_get} (gnutls_session_t @var{session}, void ** @var{userdata})
@var{session}: is a gnutls session

@var{userdata}: if non-@code{NULL}, will be set to abstract callback pointer.

Retrieve the callback function, and its userdata pointer.

@strong{Returns:} The function pointer set by @code{gnutls_sign_callback_set()}, or
if not set, @code{NULL}.

@strong{Deprecated:} Use the PKCS 11 interfaces instead.
@end deftypefun

@subheading gnutls_sign_callback_set
@anchor{gnutls_sign_callback_set}
@deftypefun {void} {gnutls_sign_callback_set} (gnutls_session_t @var{session}, gnutls_sign_func @var{sign_func}, void * @var{userdata})
@var{session}: is a gnutls session

@var{sign_func}: function pointer to application's sign callback.

@var{userdata}: void pointer that will be passed to sign callback.

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 @code{userdata} parameter is passed to the @code{sign_func} verbatim, and
can be used to store application-specific data needed in the
callback function.  See also @code{gnutls_sign_callback_get()}.

@strong{Deprecated:} Use the PKCS 11 interfaces instead.
@end deftypefun

@subheading gnutls_sign_get_id
@anchor{gnutls_sign_get_id}
@deftypefun {gnutls_sign_algorithm_t} {gnutls_sign_get_id} (const char * @var{name})
@var{name}: is a MAC algorithm name

The names are compared in a case insensitive way.

@strong{Returns:} return a @code{gnutls_sign_algorithm_t} value corresponding to
the specified cipher, or @code{GNUTLS_SIGN_UNKNOWN} on error.
@end deftypefun

@subheading gnutls_sign_get_name
@anchor{gnutls_sign_get_name}
@deftypefun {const char *} {gnutls_sign_get_name} (gnutls_sign_algorithm_t @var{algorithm})
@var{algorithm}: is a public key signature algorithm

Convert a @code{gnutls_sign_algorithm_t} value to a string.

@strong{Returns:} a pointer to a string that contains the name of the
specified public key signature algorithm, or @code{NULL}.

@strong{Since:} 2.6.0
@end deftypefun

@subheading gnutls_sign_list
@anchor{gnutls_sign_list}
@deftypefun {const gnutls_sign_algorithm_t *} {gnutls_sign_list} ( @var{void})

Get a list of supported public key signature algorithms.

@strong{Returns:} a zero-terminated list of @code{gnutls_sign_algorithm_t}
integers indicating the available ciphers.
@end deftypefun

@subheading gnutls_srp_allocate_client_credentials
@anchor{gnutls_srp_allocate_client_credentials}
@deftypefun {int} {gnutls_srp_allocate_client_credentials} (gnutls_srp_client_credentials_t * @var{sc})
@var{sc}: is a pointer to a @code{gnutls_srp_server_credentials_t} structure.

This structure is complex enough to manipulate directly thus
this helper function is provided in order to allocate it.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, or an
error code.
@end deftypefun

@subheading gnutls_srp_allocate_server_credentials
@anchor{gnutls_srp_allocate_server_credentials}
@deftypefun {int} {gnutls_srp_allocate_server_credentials} (gnutls_srp_server_credentials_t * @var{sc})
@var{sc}: is a pointer to a @code{gnutls_srp_server_credentials_t} structure.

This structure is complex enough to manipulate directly thus this
helper function is provided in order to allocate it.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, or an
error code.
@end deftypefun

@subheading gnutls_srp_base64_decode_alloc
@anchor{gnutls_srp_base64_decode_alloc}
@deftypefun {int} {gnutls_srp_base64_decode_alloc} (const gnutls_datum_t * @var{b64_data}, gnutls_datum_t * @var{result})
@var{b64_data}: contains the encoded data

@var{result}: the place where decoded data lie

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 @code{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.

@strong{Returns:} 0 on success, or an error code.
@end deftypefun

@subheading gnutls_srp_base64_decode
@anchor{gnutls_srp_base64_decode}
@deftypefun {int} {gnutls_srp_base64_decode} (const gnutls_datum_t * @var{b64_data}, char * @var{result}, size_t * @var{result_size})
@var{b64_data}: contain the encoded data

@var{result}: the place where decoded data will be copied

@var{result_size}: holds the size of the result

This function will decode the given encoded data, using the base64
encoding found in libsrp.

Note that @code{b64_data} should be null terminated.

Warning!  This base64 encoding is not the "standard" encoding, so
do not use it for non-SRP purposes.

@strong{Returns:} @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if the buffer given is not
long enough, or 0 on success.
@end deftypefun

@subheading gnutls_srp_base64_encode_alloc
@anchor{gnutls_srp_base64_encode_alloc}
@deftypefun {int} {gnutls_srp_base64_encode_alloc} (const gnutls_datum_t * @var{data}, gnutls_datum_t * @var{result})
@var{data}: contains the raw data

@var{result}: will hold the newly allocated encoded data

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 @code{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.

@strong{Returns:} 0 on success, or an error code.
@end deftypefun
@subheading gnutls_srp_base64_encode
@anchor{gnutls_srp_base64_encode}
@deftypefun {int} {gnutls_srp_base64_encode} (const gnutls_datum_t * @var{data}, char * @var{result}, size_t * @var{result_size})
@var{data}: contain the raw data

@var{result}: the place where base64 data will be copied

@var{result_size}: holds the size of the result

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.

@strong{Returns:} @code{GNUTLS_E_SHORT_MEMORY_BUFFER} if the buffer given is not
long enough, or 0 on success.
@end deftypefun

@subheading gnutls_srp_free_client_credentials
@anchor{gnutls_srp_free_client_credentials}
@deftypefun {void} {gnutls_srp_free_client_credentials} (gnutls_srp_client_credentials_t @var{sc})
@var{sc}: is a @code{gnutls_srp_client_credentials_t} structure.

This structure is complex enough to manipulate directly thus
this helper function is provided in order to free (deallocate) it.
@end deftypefun

@subheading gnutls_srp_free_server_credentials
@anchor{gnutls_srp_free_server_credentials}
@deftypefun {void} {gnutls_srp_free_server_credentials} (gnutls_srp_server_credentials_t @var{sc})
@var{sc}: is a @code{gnutls_srp_server_credentials_t} structure.

This structure is complex enough to manipulate directly thus
this helper function is provided in order to free (deallocate) it.
@end deftypefun

@subheading gnutls_srp_server_get_username
@anchor{gnutls_srp_server_get_username}
@deftypefun {const char *} {gnutls_srp_server_get_username} (gnutls_session_t @var{session})
@var{session}: is a gnutls session

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.

@strong{Returns:} SRP username of the peer, or NULL in case of error.
@end deftypefun

@subheading gnutls_srp_set_client_credentials_function
@anchor{gnutls_srp_set_client_credentials_function}
@deftypefun {void} {gnutls_srp_set_client_credentials_function} (gnutls_srp_client_credentials_t                                             @var{cred}, gnutls_srp_client_credentials_function                                             * @var{func})
@var{cred}: is a @code{gnutls_srp_server_credentials_t} structure.

@var{func}: is the callback function

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 @code{username} and @code{password} must be allocated using
@code{gnutls_malloc()}.  @code{username} and @code{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.
@end deftypefun

@subheading gnutls_srp_set_client_credentials
@anchor{gnutls_srp_set_client_credentials}
@deftypefun {int} {gnutls_srp_set_client_credentials} (gnutls_srp_client_credentials_t @var{res}, const char * @var{username}, const char * @var{password})
@var{res}: is a @code{gnutls_srp_client_credentials_t} structure.

@var{username}: is the user's userid

@var{password}: is the user's password

This function sets the username and password, in a
@code{gnutls_srp_client_credentials_t} structure.  Those will be used in
SRP authentication.  @code{username} and @code{password} should be ASCII
strings or UTF-8 strings prepared using the "SASLprep" profile of
"stringprep".

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, or an
error code.
@end deftypefun

@subheading gnutls_srp_set_prime_bits
@anchor{gnutls_srp_set_prime_bits}
@deftypefun {void} {gnutls_srp_set_prime_bits} (gnutls_session_t @var{session}, unsigned int @var{bits})
@var{session}: is a @code{gnutls_session_t} structure.

@var{bits}: is the number of bits

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
@code{GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER} will be returned by the
handshake.

This function has no effect in server side.

@strong{Since:} 2.6.0
@end deftypefun

@subheading gnutls_srp_set_server_credentials_file
@anchor{gnutls_srp_set_server_credentials_file}
@deftypefun {int} {gnutls_srp_set_server_credentials_file} (gnutls_srp_server_credentials_t @var{res}, const char * @var{password_file}, const char * @var{password_conf_file})
@var{res}: is a @code{gnutls_srp_server_credentials_t} structure.

@var{password_file}: is the SRP password file (tpasswd)

@var{password_conf_file}: is the SRP password conf file (tpasswd.conf)

This function sets the password files, in a
@code{gnutls_srp_server_credentials_t} structure.  Those password files
hold usernames and verifiers and will be used for SRP
authentication.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, or an
error code.
@end deftypefun

@subheading gnutls_srp_set_server_credentials_function
@anchor{gnutls_srp_set_server_credentials_function}
@deftypefun {void} {gnutls_srp_set_server_credentials_function} (gnutls_srp_server_credentials_t                                             @var{cred}, gnutls_srp_server_credentials_function                                             * @var{func})
@var{cred}: is a @code{gnutls_srp_server_credentials_t} structure.

@var{func}: is the callback function

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);

@code{username} contains the actual username.
The @code{salt}, @code{verifier}, @code{generator} and @code{prime} must be filled
in using the @code{gnutls_malloc()}. For convenience @code{prime} and @code{generator}
may also be one of the static parameters defined in extra.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.
@end deftypefun

@subheading gnutls_srp_verifier
@anchor{gnutls_srp_verifier}
@deftypefun {int} {gnutls_srp_verifier} (const char * @var{username}, const char * @var{password}, const gnutls_datum_t * @var{salt}, const gnutls_datum_t * @var{generator}, const gnutls_datum_t * @var{prime}, gnutls_datum_t * @var{res})
@var{username}: is the user's name

@var{password}: is the user's password

@var{salt}: should be some randomly generated bytes

@var{generator}: is the generator of the group

@var{prime}: is the group's prime

@var{res}: where the verifier will be stored.

This function will create an SRP verifier, as specified in
RFC2945.  The @code{prime} and @code{generator} should be one of the static
parameters defined in gnutls/extra.h or may be generated using the
libgcrypt functions @code{gcry_prime_generate()} and
@code{gcry_prime_group_generator()}.

The verifier will be allocated with @code{malloc} and will be stored in
@code{res} using binary format.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} (0) is returned, or an
error code.
@end deftypefun

@subheading gnutls_strerror_name
@anchor{gnutls_strerror_name}
@deftypefun {const char *} {gnutls_strerror_name} (int @var{error})
@var{error}: is an error returned by a gnutls function.

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".

@strong{Returns:} A string corresponding to the symbol name of the error
code.

@strong{Since:} 2.6.0
@end deftypefun

@subheading gnutls_strerror
@anchor{gnutls_strerror}
@deftypefun {const char *} {gnutls_strerror} (int @var{error})
@var{error}: is a GnuTLS error code, a negative value

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 @code{NULL}.

Error codes are always a negative value.

@strong{Returns:} A string explaining the GnuTLS error message.
@end deftypefun

@subheading gnutls_supplemental_get_name
@anchor{gnutls_supplemental_get_name}
@deftypefun {const char *} {gnutls_supplemental_get_name} (gnutls_supplemental_data_format_type_t @var{type})
@var{type}: is a supplemental data format type

Convert a @code{gnutls_supplemental_data_format_type_t} value to a
string.

@strong{Returns:} a string that contains the name of the specified
supplemental data format type, or @code{NULL} for unknown types.
@end deftypefun

@subheading gnutls_transport_get_ptr2
@anchor{gnutls_transport_get_ptr2}
@deftypefun {void} {gnutls_transport_get_ptr2} (gnutls_session_t @var{session}, gnutls_transport_ptr_t * @var{recv_ptr}, gnutls_transport_ptr_t * @var{send_ptr})
@var{session}: is a @code{gnutls_session_t} structure.

@var{recv_ptr}: will hold the value for the pull function

@var{send_ptr}: will hold the value for the push function

Used to get the arguments of the transport functions (like PUSH
and PULL).  These should have been set using
@code{gnutls_transport_set_ptr2()}.
@end deftypefun

@subheading gnutls_transport_get_ptr
@anchor{gnutls_transport_get_ptr}
@deftypefun {gnutls_transport_ptr_t} {gnutls_transport_get_ptr} (gnutls_session_t @var{session})
@var{session}: is a @code{gnutls_session_t} structure.

Used to get the first argument of the transport function (like
PUSH and PULL).  This must have been set using
@code{gnutls_transport_set_ptr()}.

@strong{Returns:} first argument of the transport function.
@end deftypefun

@subheading gnutls_transport_set_errno_function
@anchor{gnutls_transport_set_errno_function}
@deftypefun {void} {gnutls_transport_set_errno_function} (gnutls_session_t @var{session}, gnutls_errno_func @var{errno_func})
@var{session}: is a @code{gnutls_session_t} structure.

@var{errno_func}: a callback function similar to @code{write()}

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.
@end deftypefun

@subheading gnutls_transport_set_errno
@anchor{gnutls_transport_set_errno}
@deftypefun {void} {gnutls_transport_set_errno} (gnutls_session_t @var{session}, int @var{err})
@var{session}: is a @code{gnutls_session_t} structure.

@var{err}: error value to store in session-specific errno variable.

Store @code{err} in the session-specific errno variable.  Useful values
for @code{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/pull functions set by
gnutls_transport_set_push_function and
gnutls_transport_set_pullpush_function under Windows, where the
replacement push/pull may not have access to the same @code{errno}
variable that is used by GnuTLS (e.g., the application is linked to
msvcr71.dll and gnutls is linked to msvcrt.dll).

If you don't have the @code{session} variable easily accessible from the
push/pull function, and don't worry about thread conflicts, you can
also use @code{gnutls_transport_set_global_errno()}.
@end deftypefun

@subheading gnutls_transport_set_global_errno
@anchor{gnutls_transport_set_global_errno}
@deftypefun {void} {gnutls_transport_set_global_errno} (int @var{err})
@var{err}: error value to store in global errno variable.

Store @code{err} in the global errno variable.  Useful values for @code{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/pull functions set by
gnutls_transport_set_push_function and
gnutls_transport_set_pullpush_function under Windows, where the
replacement push/pull may not have access to the same @code{errno}
variable that is used by GnuTLS (e.g., the application is linked to
msvcr71.dll and gnutls is linked to msvcrt.dll).

Whether this function is thread safe or not depends on whether the
global variable errno is thread safe, some system libraries make it
a thread-local variable.  When feasible, using the guaranteed
thread-safe @code{gnutls_transport_set_errno()} may be better.
@end deftypefun

@subheading gnutls_transport_set_lowat
@anchor{gnutls_transport_set_lowat}
@deftypefun {void} {gnutls_transport_set_lowat} (gnutls_session_t @var{session}, int @var{num})
@var{session}: is a @code{gnutls_session_t} structure.

@var{num}: is the low water value.

Used to set the lowat value in order for select to check if there
are pending data to socket buffer. Used only if you have changed
the default low water value (default is 1).  Normally you will not
need that function.  This function is only useful if using
berkeley style sockets.  Otherwise it must be called and set lowat
to zero.
@end deftypefun

@subheading gnutls_transport_set_ptr2
@anchor{gnutls_transport_set_ptr2}
@deftypefun {void} {gnutls_transport_set_ptr2} (gnutls_session_t @var{session}, gnutls_transport_ptr_t @var{recv_ptr}, gnutls_transport_ptr_t @var{send_ptr})
@var{session}: is a @code{gnutls_session_t} structure.

@var{recv_ptr}: is the value for the pull function

@var{send_ptr}: is the value for the push function

Used to set the first argument of the transport function (like PUSH
and PULL). In berkeley style sockets this function will set the
connection handle.  With this function you can use two different
pointers for receiving and sending.
@end deftypefun

@subheading gnutls_transport_set_ptr
@anchor{gnutls_transport_set_ptr}
@deftypefun {void} {gnutls_transport_set_ptr} (gnutls_session_t @var{session}, gnutls_transport_ptr_t @var{ptr})
@var{session}: is a @code{gnutls_session_t} structure.

@var{ptr}: is the value.

Used to set the first argument of the transport function (like PUSH
and PULL).  In berkeley style sockets this function will set the
connection handle.
@end deftypefun

@subheading gnutls_transport_set_pull_function
@anchor{gnutls_transport_set_pull_function}
@deftypefun {void} {gnutls_transport_set_pull_function} (gnutls_session_t @var{session}, gnutls_pull_func @var{pull_func})
@var{session}: is a @code{gnutls_session_t} structure.

@var{pull_func}: a callback function similar to @code{read()}

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.

PULL_FUNC is of the form,
ssize_t (*gnutls_pull_func)(gnutls_transport_ptr_t, void*, size_t);
@end deftypefun

@subheading gnutls_transport_set_push_function
@anchor{gnutls_transport_set_push_function}
@deftypefun {void} {gnutls_transport_set_push_function} (gnutls_session_t @var{session}, gnutls_push_func @var{push_func})
@var{session}: is a @code{gnutls_session_t} structure.

@var{push_func}: a callback function similar to @code{write()}

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.

PUSH_FUNC is of the form,
ssize_t (*gnutls_push_func)(gnutls_transport_ptr_t, const void*, size_t);
@end deftypefun

@subheading gnutls_transport_set_vec_push_function
@anchor{gnutls_transport_set_vec_push_function}
@deftypefun {void} {gnutls_transport_set_vec_push_function} (gnutls_session_t @var{session}, gnutls_vec_push_func @var{vec_func})
@var{session}: is a @code{gnutls_session_t} structure.

@var{vec_func}: a callback function similar to @code{writev()}

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.

PUSH_FUNC is of the form,
ssize_t (*gnutls_push_func)(gnutls_transport_ptr_t, const void*, size_t);
@end deftypefun

@subheading gnutls_x509_crq_set_pubkey
@anchor{gnutls_x509_crq_set_pubkey}
@deftypefun {int} {gnutls_x509_crq_set_pubkey} (gnutls_x509_crq_t @var{crq}, gnutls_pubkey_t @var{key})
@var{crq}: should contain a @code{gnutls_x509_crq_t} structure

@var{key}: holds a public key

This function will set the public parameters from the given public
key to the request.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_x509_crt_import_pkcs11_url
@anchor{gnutls_x509_crt_import_pkcs11_url}
@deftypefun {int} {gnutls_x509_crt_import_pkcs11_url} (gnutls_x509_crt_t @var{crt}, const char * @var{url}, unsigned int @var{flags})
@var{crt}: A certificate of type @code{gnutls_x509_crt_t}

@var{url}: A PKCS 11 url

@var{flags}: One of GNUTLS_PKCS11_OBJ_* flags

This function will import a PKCS 11 certificate directly from a token
without involving the @code{gnutls_pkcs11_obj_t} structure. This function will
fail if the certificate stored is not of X.509 type.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_x509_crt_import_pkcs11
@anchor{gnutls_x509_crt_import_pkcs11}
@deftypefun {int} {gnutls_x509_crt_import_pkcs11} (gnutls_x509_crt_t @var{crt}, gnutls_pkcs11_obj_t @var{pkcs11_crt})
@var{crt}: A certificate of type @code{gnutls_x509_crt_t}

@var{pkcs11_crt}: A PKCS 11 object that contains a certificate

This function will import a PKCS 11 certificate to a @code{gnutls_x509_crt_t}
structure.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_x509_crt_list_import_pkcs11
@anchor{gnutls_x509_crt_list_import_pkcs11}
@deftypefun {int} {gnutls_x509_crt_list_import_pkcs11} (gnutls_x509_crt_t * @var{certs}, unsigned int @var{cert_max}, gnutls_pkcs11_obj_t * const @var{objs}, unsigned int @var{flags})
@var{certs}: A list of certificates of type @code{gnutls_x509_crt_t}

@var{cert_max}: The maximum size of the list

@var{objs}: A list of PKCS 11 objects

@var{flags}: 0 for now

This function will import a PKCS 11 certificate list to a list of 
@code{gnutls_x509_crt_t} structure. These must not be initialized.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun

@subheading gnutls_x509_crt_set_pubkey
@anchor{gnutls_x509_crt_set_pubkey}
@deftypefun {int} {gnutls_x509_crt_set_pubkey} (gnutls_x509_crt_t @var{crt}, gnutls_pubkey_t @var{key})
@var{crt}: should contain a @code{gnutls_x509_crt_t} structure

@var{key}: holds a public key

This function will set the public parameters from the given public
key to the request.

@strong{Returns:} On success, @code{GNUTLS_E_SUCCESS} is returned, otherwise a
negative error value.
@end deftypefun