![]() |
![]() |
![]() |
GNU TLS API Reference Manual | ![]() |
---|
extraextra — |
#define LIBGNUTLS_EXTRA_VERSION int (*gnutls_openpgp_recv_key_func) (gnutls_session_t session, unsigned char *keyfpr, unsigned int keyfpr_length, gnutls_datum_t *key); void gnutls_openpgp_set_recv_key_function (gnutls_session_t session, gnutls_openpgp_recv_key_func func); int gnutls_certificate_set_openpgp_key_file (gnutls_certificate_credentials_t res, const char *CERTFILE, const char *KEYFILE); int gnutls_certificate_set_openpgp_key_mem (gnutls_certificate_credentials_t res, const gnutls_datum_t *CERT, const gnutls_datum_t *KEY); int gnutls_certificate_set_openpgp_keyserver (gnutls_certificate_credentials_t res, const char *keyserver, int port); int gnutls_certificate_set_openpgp_trustdb (gnutls_certificate_credentials_t res, const char *trustdb); int gnutls_certificate_set_openpgp_keyring_mem (gnutls_certificate_credentials_t c, unsigned char *data, size_t dlen); int gnutls_certificate_set_openpgp_keyring_file (gnutls_certificate_credentials_t c, const char *file); enum gnutls_ia_apptype; int (*gnutls_ia_avp_func) (gnutls_session_t session, void *ptr, const char *last, size_t lastlen, char **new, size_t *newlen); typedef gnutls_ia_server_credentials_t; typedef gnutls_ia_client_credentials_t; void gnutls_ia_free_client_credentials (gnutls_ia_client_credentials_t sc); int gnutls_ia_allocate_client_credentials (gnutls_ia_client_credentials_t *sc); void gnutls_ia_free_server_credentials (gnutls_ia_server_credentials_t sc); int gnutls_ia_allocate_server_credentials (gnutls_ia_server_credentials_t *sc); void gnutls_ia_set_client_avp_function (gnutls_ia_client_credentials_t cred, gnutls_ia_avp_func avp_func); void gnutls_ia_set_server_avp_function (gnutls_ia_server_credentials_t cred, gnutls_ia_avp_func avp_func); void gnutls_ia_set_client_avp_ptr (gnutls_ia_client_credentials_t cred, void *ptr); void* gnutls_ia_get_client_avp_ptr (gnutls_ia_client_credentials_t cred); void gnutls_ia_set_server_avp_ptr (gnutls_ia_server_credentials_t cred, void *ptr); void* gnutls_ia_get_server_avp_ptr (gnutls_ia_server_credentials_t cred); gnutls_ia_mode_t gnutls_ia_client_get (gnutls_session_t session); void gnutls_ia_client_set (gnutls_session_t session, gnutls_ia_mode_t state); gnutls_ia_mode_t gnutls_ia_server_get (gnutls_session_t session); void gnutls_ia_server_set (gnutls_session_t session, gnutls_ia_mode_t state); int gnutls_ia_handshake_p (gnutls_session_t session); int gnutls_ia_handshake (gnutls_session_t session); enum gnutls_endphase_t; int gnutls_ia_permute_inner_secret (gnutls_session_t session, size_t session_keys_size, const char *session_keys); int gnutls_ia_client_endphase (gnutls_session_t session, char *checksum, int final_p); int gnutls_ia_server_endphase (gnutls_session_t session, char *checksum, int final_p); ssize_t gnutls_ia_send (gnutls_session_t session, char *data, ssize_t datal); ssize_t gnutls_ia_recv (gnutls_session_t session, char *data, ssize_t datal); int gnutls_ia_generate_challenge (gnutls_session_t session, size_t buffer_size, char *buffer); void gnutls_ia_extract_inner_secret (gnutls_session_t session, char *buffer); int gnutls_global_init_extra (void); const char* gnutls_extra_check_version (const char *req_version);
int (*gnutls_openpgp_recv_key_func) (gnutls_session_t session, unsigned char *keyfpr, unsigned int keyfpr_length, gnutls_datum_t *key);
A callback of this type is used to retrieve OpenPGP keys. Only
useful on the server, and will only be used if the peer send a key
fingerprint instead of a full key. See also
gnutls_openpgp_set_recv_key_function()
.
session : |
a TLS session |
keyfpr : |
key fingerprint |
keyfpr_length : |
length of key fingerprint |
key : |
output key. |
Returns : |
void gnutls_openpgp_set_recv_key_function (gnutls_session_t session, gnutls_openpgp_recv_key_func func);
This funtion will set a key retrieval function for OpenPGP keys. This callback is only useful in server side, and will be used if the peer sent a key fingerprint instead of a full key.
session : |
a TLS session |
func : |
the callback |
int gnutls_certificate_set_openpgp_key_file (gnutls_certificate_credentials_t res, const char *CERTFILE, const char *KEYFILE);
This funtion is used to load OpenPGP keys into the GnuTLS credentials structure. It doesn't matter whether the keys are armored or but, but the files should only contain one key which should not be encrypted.
res : |
the destination context to save the data. |
CERTFILE : |
the file that contains the public key. |
KEYFILE : |
the file that contains the secret key. |
Returns : |
int gnutls_certificate_set_openpgp_key_mem (gnutls_certificate_credentials_t res, const gnutls_datum_t *CERT, const gnutls_datum_t *KEY);
This funtion is used to load OpenPGP keys into the GnuTLS credential structure. It doesn't matter whether the keys are armored or but, but the files should only contain one key which should not be encrypted.
res : |
the destination context to save the data. |
CERT : |
the datum that contains the public key. |
KEY : |
the datum that contains the secret key. |
Returns : |
int gnutls_certificate_set_openpgp_keyserver (gnutls_certificate_credentials_t res, const char *keyserver, int port);
This funtion will set a key server for use with openpgp keys. This key server will only be used if the peer sends a key fingerprint instead of a key in the handshake. Using a key server may delay the handshake process.
res : |
the destination context to save the data. |
keyserver : |
is the key server address |
port : |
is the key server port to connect to |
Returns : |
int gnutls_certificate_set_openpgp_trustdb (gnutls_certificate_credentials_t res, const char *trustdb);
This funtion will set a GnuPG trustdb which will be used in key verification functions. Only version 3 trustdb files are supported.
res : |
the destination context to save the data. |
trustdb : |
is the trustdb filename |
Returns : |
int gnutls_certificate_set_openpgp_keyring_mem (gnutls_certificate_credentials_t c, unsigned char *data, size_t dlen);
The function is used to set keyrings that will be used internally by various OpenPGP functions. For example to find a key when it is needed for an operations. The keyring will also be used at the verification functions.
c : |
A certificate credentials structure |
data : |
buffer with keyring data. |
dlen : |
length of data buffer. |
Returns : |
int gnutls_certificate_set_openpgp_keyring_file (gnutls_certificate_credentials_t c, const char *file);
The function is used to set keyrings that will be used internally by various OpenPGP functions. For example to find a key when it is needed for an operations. The keyring will also be used at the verification functions.
c : |
A certificate credentials structure |
file : |
filename of the keyring. |
Returns : |
typedef enum { GNUTLS_IA_APPLICATION_PAYLOAD = 0, GNUTLS_IA_INTERMEDIATE_PHASE_FINISHED = 1, GNUTLS_IA_FINAL_PHASE_FINISHED = 2 } gnutls_ia_apptype;
int (*gnutls_ia_avp_func) (gnutls_session_t session, void *ptr, const char *last, size_t lastlen, char **new, size_t *newlen);
session : |
|
ptr : |
|
last : |
|
lastlen : |
|
new : |
|
newlen : |
|
Returns : |
typedef struct gnutls_ia_server_credentials_st* gnutls_ia_server_credentials_t;
typedef struct gnutls_ia_client_credentials_st* gnutls_ia_client_credentials_t;
void gnutls_ia_free_client_credentials (gnutls_ia_client_credentials_t sc);
This structure is complex enough to manipulate directly thus this helper function is provided in order to free (deallocate) it.
sc : |
is an gnutls_ia_client_credentials_t structure. |
int gnutls_ia_allocate_client_credentials (gnutls_ia_client_credentials_t *sc);
This structure is complex enough to manipulate directly thus this helper function is provided in order to allocate it.
sc : |
is a pointer to an gnutls_ia_server_credentials_t structure. |
Returns : | 0 on success. |
void gnutls_ia_free_server_credentials (gnutls_ia_server_credentials_t sc);
This structure is complex enough to manipulate directly thus this helper function is provided in order to free (deallocate) it.
sc : |
is an gnutls_ia_server_credentials_t structure. |
int gnutls_ia_allocate_server_credentials (gnutls_ia_server_credentials_t *sc);
This structure is complex enough to manipulate directly thus this helper function is provided in order to allocate it.
sc : |
is a pointer to an gnutls_ia_server_credentials_t structure. |
Returns : | 0 on success. |
void gnutls_ia_set_client_avp_function (gnutls_ia_client_credentials_t cred, gnutls_ia_avp_func avp_func);
Set the TLS/IA AVP callback handler used for the session.
The AVP callback is called to process AVPs received from the server, and to get a new AVP to send to the server.
The callback's function form is: int (*avp_func) (gnutls_session_t session, void *ptr, const char *last, size_t lastlen, char **new, size_t *newlen);
The session
parameter is the gnutls_session_t structure
corresponding to the current session. The ptr
parameter is the
application hook pointer, set through
gnutls_ia_set_client_avp_ptr()
. The AVP received from the server
is present in last
of lastlen
size, which will be NULL
on the
first invocation. The newly allocated output AVP to send to the
server should be placed in *new
of *newlen
size.
The callback may invoke gnutls_ia_permute_inner_secret()
to mix any
generated session keys with the TLS/IA inner secret.
Return 0 (GNUTLS_IA_APPLICATION_PAYLOAD
) on success, or a negative
error code to abort the TLS/IA handshake.
Note that the callback must use allocate the new
parameter using
gnutls_malloc()
, because it is released via gnutls_free()
by the
TLS/IA handshake function.
cred : |
is a gnutls_ia_client_credentials_t structure. |
avp_func : |
is the callback function |
void gnutls_ia_set_server_avp_function (gnutls_ia_server_credentials_t cred, gnutls_ia_avp_func avp_func);
cred : |
|
avp_func : |
void gnutls_ia_set_client_avp_ptr (gnutls_ia_client_credentials_t cred, void *ptr);
Sets the pointer that will be provided to the TLS/IA callback function as the first argument.
cred : |
is a gnutls_ia_client_credentials_t structure. |
ptr : |
is the pointer |
void* gnutls_ia_get_client_avp_ptr (gnutls_ia_client_credentials_t cred);
cred : |
is a gnutls_ia_client_credentials_t structure. |
Returns : | the pointer that will be provided to the TLS/IA callback function as the first argument. |
void gnutls_ia_set_server_avp_ptr (gnutls_ia_server_credentials_t cred, void *ptr);
Sets the pointer that will be provided to the TLS/IA callback function as the first argument.
cred : |
is a gnutls_ia_client_credentials_t structure. |
ptr : |
is the pointer |
void* gnutls_ia_get_server_avp_ptr (gnutls_ia_server_credentials_t cred);
cred : |
is a gnutls_ia_client_credentials_t structure. |
Returns : | the pointer that will be provided to the TLS/IA callback function as the first argument. |
gnutls_ia_mode_t gnutls_ia_client_get (gnutls_session_t session);
For a client, this function return the value set by the application
itself with gnutls_ia_client_set()
earlier. If that function has
not been invoked, TLS/IA is disabled, and GNUTLS_IA_DISABLED
is
returned.
For a server, after a successful call to gnutls_handshake()
, this
will contain the client's TLS/IA preference. A return value of
GNUTLS_IA_DISABLED
then means that the client did not support
TLS/IA. A return value of GNUTLS_IA_APP_PHASE_ON_RESUMPTION_NO
means that the client did not request an Inner Application phase if
the session is resumed. If GNUTLS_IA_APP_PHASE_ON_RESUMPTION_YES
is returned, the client requested an Inner Application phase
regardless of whether the session is resumed or not.
Note that the server should not use this function to decide whether
to invoke gnutls_ia_handshake()
, instead use
gnutls_ia_handshake_p()
. This return value only indicate the
client's preference, which may not be what the server wants to
follow.
session : |
is a gnutls_session_t structure. |
Returns : | a gnutls_ia_mode_t indicating client TLS/IA preference. |
void gnutls_ia_client_set (gnutls_session_t session, gnutls_ia_mode_t state);
Set the TLS/IA mode that will be requested by the client in the TLS
handshake. For this function to have any effect, it must be called
before gnutls_handshake()
. This function does nothing if called in
a server.
A state
value GNUTLS_IA_DISABLED
means that the client do not
wish to use TLS/IA (the default).
GNUTLS_IA_APP_PHASE_ON_RESUMPTION_NO
means that the client request
TLS/IA, and that if the TLS session is resumed, that there is no
Inner Application phase. GNUTLS_IA_APP_PHASE_ON_RESUMPTION_YES
means that the client request TLS/IA, and that if the TLS session
is resumed, there is an Inner Application phase.
Note that the client has to check whether the server supported
TLS/IA before invoking gnutls_ia_handshake()
. Specifically, the
client should use gnutls_ia_handshake_p()
, after gnutls_handshake()
has finished, to decide whether to call gnutls_ia_handshake()
or
not.
session : |
is a gnutls_session_t structure. |
state : |
a gnutls_ia_mode_t value to indicate requested TLS/IA client mode. |
gnutls_ia_mode_t gnutls_ia_server_get (gnutls_session_t session);
For a server, this function return the value set by the application
itself with gnutls_ia_server_set()
earlier. If that function has
not been invoked, TLS/IA is disabled, and GNUTLS_IA_DISABLED
is
returned.
For a client, after a successful call to gnutls_handshake()
, this
will contain the server's TLS/IA preference. A return value of
GNUTLS_IA_DISABLED
then means that the server did not support
TLS/IA, and the client cannot proceed with the
gnutls_ia_handshake()
. The client may abort the session at that
point, if TLS/IA is required. A return value of
GNUTLS_IA_APP_PHASE_ON_RESUMPTION_NO
means that TLS/IA is
supported by the server, and if the session is resumed, there will
be no Inner Application phase. If
GNUTLS_IA_APP_PHASE_ON_RESUMPTION_YES
is returned, an Inner
Application phase is required.
Note that clients is recommended to use gnutls_ia_handshake_p()
to
decide whether to call gnutls_ia_handshake()
or not.
session : |
is a gnutls_session_t structure. |
Returns : | a gnutls_ia_mode_t indicating server TLS/IA preference. |
void gnutls_ia_server_set (gnutls_session_t session, gnutls_ia_mode_t state);
Call this function to decide which TLS/IA mode the server should operate in. This function does nothing if called in a client. TLS/IA will only be enabled if the client requests this.
A value of GNUTLS_IA_DISABLED
means that TLS/IA should be disabled
regardless of what the client requests (the default). A value of
GNUTLS_IA_APP_PHASE_ON_RESUMPTION_NO
means that the server support
TLS/IA, and further that if the session is resumed, and if the
client did not request an Inner Application phase (i.e., the client
has set the AppPhaseOnResumption flag to no), then the server will
not require an Inner Application phase. A value of
GNUTLS_IA_APP_PHASE_ON_RESUMPTION_YES
means that if the client
requests TLS/IA, the server will always require an Inner
Application phase, even if the session is resumed.
Whether to start the TLS/IA handshake depend on whether the client
supports or requested TLS/IA. A server should thus use
gnutls_ia_handshake_p()
to decide whether to call
gnutls_ia_handshake()
or not.
session : |
is a gnutls_session_t structure. |
state : |
a gnutls_ia_mode_t value to indicate requested TLS/IA server mode. |
int gnutls_ia_handshake_p (gnutls_session_t session);
Predicate to be used after gnutls_handshake()
to decide whether to
invoke gnutls_ia_handshake()
. Usable by both clients and servers.
session : |
is a gnutls_session_t structure. |
Returns : | non-zero if TLS/IA handshake is expected, zero otherwise. |
int gnutls_ia_handshake (gnutls_session_t session);
Perform a TLS/IA handshake. This should be called after
gnutls_handshake()
iff gnutls_ia_handshake_p()
.
Return 0 on success, or an error code.
session : |
is a gnutls_session_t structure. |
Returns : |
typedef enum { GNUTLS_IA_INTERMEDIATEPHASE, GNUTLS_IA_FINALPHASE } gnutls_endphase_t;
int gnutls_ia_permute_inner_secret (gnutls_session_t session, size_t session_keys_size, const char *session_keys);
Permute the inner secret using the generate session keys.
This can be called in the TLS/IA AVP callback to mix any generated session keys with the TLS/IA inner secret.
When using the low-level interface, this should be called during an
application phase, before calling gnutls_ia_client_endphase()
or
gnutls_ia_server_endphase()
, if the application generated any
session keys that should be mixed with the inner secret.
session : |
is a gnutls_session_t structure. |
session_keys_size : |
Size of generated session keys (0 if none). |
session_keys : |
Generated session keys, used to permute inner secret (NULL if none). |
Returns : | Return zero on success, or a negative error code. |
int gnutls_ia_client_endphase (gnutls_session_t session, char *checksum, int final_p);
Acknowledge the end of an application phase in the TLS/IA
handshake. This function verify the checksum
data using the TLS
PRF and the inner secret. It will send an
GNUTLS_A_INNER_APPLICATION_VERIFICATION alert to the server if
verification fails, and GNUTLS_A_INNER_APPLICATION_FAILURE on any
other error.
This must only be called when gnutls_ia_recv()
return
GNUTLS_E_WARNING_IA_IPHF_RECEIVED or
GNUTLS_E_WARNING_IA_FPHF_RECEIVED.
Return zero on success, or an error code.
session : |
is a gnutls_session_t structure. |
checksum : |
Checksum data recived from server, via gnutls_ia_recv() .
|
final_p : |
Set iff this signal the final phase. |
Returns : |
int gnutls_ia_server_endphase (gnutls_session_t session, char *checksum, int final_p);
session : |
|
checksum : |
|
final_p : |
|
Returns : |
ssize_t gnutls_ia_send (gnutls_session_t session, char *data, ssize_t datal);
Send TLS/IA application payload data. This function has the
similar semantics with send()
. The only difference is that is
accepts a GNUTLS session, and uses different error codes.
The TLS/IA protocol is synchronous, so you cannot send more than one packet at a time. The client always send the first packet.
To finish an application phase, use gnutls_ia_client_endphase()
and
gnutls_ia_server_endphase()
. After that, the client should send
the first packet again.
If the EINTR is returned by the internal push function (the default
is send()
} then GNUTLS_E_INTERRUPTED
will be returned. If
GNUTLS_E_INTERRUPTED
or GNUTLS_E_AGAIN
is returned, you must call
this function again, with the same parameters; alternatively you
could provide a NULL
pointer for data, and 0 for size.
session : |
is a gnutls_session_t structure. |
data : |
contains the data to send |
datal : |
|
Returns : | the number of bytes sent, or a negative error code. |
ssize_t gnutls_ia_recv (gnutls_session_t session, char *data, ssize_t datal);
Receive TLS/IA data. This function has the similar semantics with
recv()
. The only difference is that is accepts a GNUTLS session,
and uses different error codes.
If EINTR is returned by the internal push function (the default is
code
{recv()
}) then GNUTLS_E_INTERRUPTED will be returned. If
GNUTLS_E_INTERRUPTED or GNUTLS_E_AGAIN is returned, you must call
this function again, with the same parameters; alternatively you
could provide a NULL pointer for data, and 0 for size.
session : |
is a gnutls_session_t structure. |
data : |
the buffer that the data will be read into, must hold >= 12 bytes. |
datal : |
|
Returns : | the number of bytes received. A negative error code is
returned in case of an error. The
GNUTLS_E_WARNING_IA_IPHF_RECEIVED is returned when a intermediate
phase finished message has been received, and
GNUTLS_E_WARNING_IA_FPHF_RECEIVED when a final phase finished
message has been received; in both cases will data hold 12 bytes
of checksum data that should be passed on to
gnutls_ia_client_endphase() or gnutls_ia_server_endphase() ,
respectively.
|
int gnutls_ia_generate_challenge (gnutls_session_t session, size_t buffer_size, char *buffer);
Generate a application challenge that the client cannot control or predict, based on the TLS/IA inner secret.
session : |
is a gnutls_session_t structure. |
buffer_size : |
size of output buffer. |
buffer : |
pre-allocated buffer to contain buffer_size bytes of output.
|
Returns : | Returns 0 on success, or an negative error code. |
void gnutls_ia_extract_inner_secret (gnutls_session_t session, char *buffer);
Copy the 48 bytes large inner secret into the specified buffer
Use this function after the TLS/IA handshake has concluded (i.e., after the last TLS/IA Final Phase Message has been acknowledged).
The TLS/IA inner secret can be used as input to a PRF to derive session keys. Do not use the inner secret directly as a session key, because for a resumed session that does not include an application phase, the inner secret will be identical to the inner secret in the original session. It is important to include, for example, the client and server randomness when deriving a sesssion key from the inner secret.
session : |
is a gnutls_session_t structure. |
buffer : |
pre-allocated buffer to hold 48 bytes of inner secret. |
int gnutls_global_init_extra (void);
This function initializes the global state of gnutls-extra library to defaults.
Returns : | zero on success.
Note that gnutls_global_init() has to be called before this function.
If this function is not called then the gnutls-extra library will not
be usable.
|
const char* gnutls_extra_check_version (const char *req_version);
Check that the version of the gnutls-extra library is at minimum the requested one and return the version string; return NULL if the condition is not satisfied. If a NULL is passed to this function, no check is done, but the version string is simply returned.
req_version : |
the version to check |
Returns : |
<< gnutls | x509 >> |