Loading...
Searching...
No Matches
DTLS sock credentials API

Credential handling for DTLS sock. More...

Detailed Description

Credential handling for DTLS sock.

Files

file  creds.h
 DTLS sock definitions.
 

Typedefs

typedef credman_tag_t(* sock_dtls_client_psk_cb_t) (sock_dtls_t *sock, sock_udp_ep_t *ep, credman_tag_t tags[], unsigned tags_len, const char *hint, size_t hint_len)
 Pre-Shared Key client callback.
 
typedef credman_tag_t(* sock_dtls_rpk_cb_t) (sock_dtls_t *sock, sock_udp_ep_t *ep, credman_tag_t tags[], unsigned tags_len)
 Raw Public Key callback.
 

Functions

int sock_dtls_set_server_psk_id_hint (sock_dtls_t *sock, const char *hint)
 Sets the PSK Identity hint to be sent to clients during handshake.
 
int sock_dtls_add_credential (sock_dtls_t *sock, credman_tag_t tag)
 Adds a credential tag to list of available credentials for sock.
 
int sock_dtls_remove_credential (sock_dtls_t *sock, credman_tag_t tag)
 Removes a credential tag of the list of available credentials for sock.
 
size_t sock_dtls_get_credentials (sock_dtls_t *sock, const credman_tag_t **out)
 Returns an array of tags of the registered credentials in sock.
 
void sock_dtls_set_client_psk_cb (sock_dtls_t *sock, sock_dtls_client_psk_cb_t cb)
 Sets the callback function for clients to specify a credential to use for a given connection.
 
void sock_dtls_set_rpk_cb (sock_dtls_t *sock, sock_dtls_rpk_cb_t cb)
 Sets the callback function to specify a credential to use for a given connection, when using Raw Public Keys.
 
#define CONFIG_DTLS_CREDENTIALS_MAX   4
 Default buffer size for TLS credential tags.
 

Macro Definition Documentation

◆ CONFIG_DTLS_CREDENTIALS_MAX

#define CONFIG_DTLS_CREDENTIALS_MAX   4

Default buffer size for TLS credential tags.

Definition at line 45 of file creds.h.

Typedef Documentation

◆ sock_dtls_client_psk_cb_t

typedef credman_tag_t(* sock_dtls_client_psk_cb_t) (sock_dtls_t *sock, sock_udp_ep_t *ep, credman_tag_t tags[], unsigned tags_len, const char *hint, size_t hint_len)

Pre-Shared Key client callback.

Called during handshake to determine session credential.

Parameters
[in]sockDTLS sock object
[in]epRemove UDP endpoint representing the session
[in]tagsList of credential tags available for sock
[in]tags_lenNumber of credentials in tags
[in]hintHint sent by the server. May be NULL
[in]hint_lenLength of hint
Returns
Tag of the credential to use when a suitable one is found
Return values
CREDMAN_TAG_EMPTYotherwise

Definition at line 62 of file creds.h.

◆ sock_dtls_rpk_cb_t

typedef credman_tag_t(* sock_dtls_rpk_cb_t) (sock_dtls_t *sock, sock_udp_ep_t *ep, credman_tag_t tags[], unsigned tags_len)

Raw Public Key callback.

Called during handshake to determine the session credential.

Parameters
[in]sockDTLS sock object
[in]epRemote UDP endpoint representing the session
[in]tagsList of credential tags available for sock
[in]tags_lenNumber of credentials in tags
Returns
Tag of the credential to use when a suitable one is found
Return values
CREDMAN_TAG_EMPTYotherwise

Definition at line 77 of file creds.h.

Function Documentation

◆ sock_dtls_add_credential()

int sock_dtls_add_credential ( sock_dtls_t sock,
credman_tag_t  tag 
)

Adds a credential tag to list of available credentials for sock.

Precondition
sock != NULL
Parameters
[in]sockDTLS sock object
[in]tagTag of the credential to add
Return values
0on success
-1otherwise

◆ sock_dtls_get_credentials()

size_t sock_dtls_get_credentials ( sock_dtls_t sock,
const credman_tag_t **  out 
)

Returns an array of tags of the registered credentials in sock.

Parameters
[in]sockDTLS sock object
[out]outPointer to place the reference to a read-only array of credman_tag_t
Returns
Number of registered credentials

◆ sock_dtls_remove_credential()

int sock_dtls_remove_credential ( sock_dtls_t sock,
credman_tag_t  tag 
)

Removes a credential tag of the list of available credentials for sock.

Precondition
sock != NULL
Parameters
[in]sockDTLS sock object
[in]tagTag of the credential to remove
Return values
0on success
-1otherwise

◆ sock_dtls_set_client_psk_cb()

void sock_dtls_set_client_psk_cb ( sock_dtls_t sock,
sock_dtls_client_psk_cb_t  cb 
)

Sets the callback function for clients to specify a credential to use for a given connection.

Parameters
[in]sockThe DTLS sock object to set the callback to.
[in]cbCallback to set.

◆ sock_dtls_set_rpk_cb()

void sock_dtls_set_rpk_cb ( sock_dtls_t sock,
sock_dtls_rpk_cb_t  cb 
)

Sets the callback function to specify a credential to use for a given connection, when using Raw Public Keys.

Parameters
[in]sockThe DTLS sock object to set the callback to.
[in]cbCallback to set.

◆ sock_dtls_set_server_psk_id_hint()

int sock_dtls_set_server_psk_id_hint ( sock_dtls_t sock,
const char *  hint 
)

Sets the PSK Identity hint to be sent to clients during handshake.

This hint is optional. It helps clients to decide which PSK Identity to use.

Parameters
[in,out]sockThe DTLS sock object to set the hint to.
[in]hintPSK Identity hint as NULL-terminated string.
Return values
0on success
-1on error