net/sock/dtls: add RPK callback for credential selection
This commit is contained in:
parent
81892ee389
commit
8b57b87258
@ -289,6 +289,7 @@ int sock_dtls_create(sock_dtls_t *sock, sock_udp_t *udp_sock,
|
|||||||
sock->buffer.data = NULL;
|
sock->buffer.data = NULL;
|
||||||
sock->psk_hint[0] = '\0';
|
sock->psk_hint[0] = '\0';
|
||||||
sock->client_psk_cb = NULL;
|
sock->client_psk_cb = NULL;
|
||||||
|
sock->rpk_cb = NULL;
|
||||||
#ifdef SOCK_HAS_ASYNC
|
#ifdef SOCK_HAS_ASYNC
|
||||||
sock->async_cb = NULL;
|
sock->async_cb = NULL;
|
||||||
sock->buf_ctx = NULL;
|
sock->buf_ctx = NULL;
|
||||||
@ -374,6 +375,12 @@ void sock_dtls_set_client_psk_cb(sock_dtls_t *sock, sock_dtls_client_psk_cb_t cb
|
|||||||
sock->client_psk_cb = cb;
|
sock->client_psk_cb = cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sock_dtls_set_rpk_cb(sock_dtls_t *sock, sock_dtls_rpk_cb_t cb)
|
||||||
|
{
|
||||||
|
assert(sock);
|
||||||
|
sock->rpk_cb = cb;
|
||||||
|
}
|
||||||
|
|
||||||
sock_udp_t *sock_dtls_get_udp_sock(sock_dtls_t *sock)
|
sock_udp_t *sock_dtls_get_udp_sock(sock_dtls_t *sock)
|
||||||
{
|
{
|
||||||
assert(sock);
|
assert(sock);
|
||||||
|
|||||||
@ -80,6 +80,7 @@ struct sock_dtls {
|
|||||||
unsigned tags_len; /**< Number of tags in the list 'tags' */
|
unsigned tags_len; /**< Number of tags in the list 'tags' */
|
||||||
dtls_peer_type role; /**< DTLS role of the socket */
|
dtls_peer_type role; /**< DTLS role of the socket */
|
||||||
sock_dtls_client_psk_cb_t client_psk_cb;/**< Callback to determine PSK credential for session */
|
sock_dtls_client_psk_cb_t client_psk_cb;/**< Callback to determine PSK credential for session */
|
||||||
|
sock_dtls_rpk_cb_t rpk_cb; /**< Callback to determine RPK credential for session */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -63,6 +63,20 @@ typedef credman_tag_t (*sock_dtls_client_psk_cb_t)(sock_dtls_t *sock, sock_udp_e
|
|||||||
credman_tag_t tags[], unsigned tags_len,
|
credman_tag_t tags[], unsigned tags_len,
|
||||||
const char* hint, size_t hint_len);
|
const char* hint, size_t hint_len);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Raw Public Key callback. Called during handshake to determine the session credential.
|
||||||
|
*
|
||||||
|
* @param[in] sock DTLS sock object
|
||||||
|
* @param[in] ep Remote UDP endpoint representing the session
|
||||||
|
* @param[in] tags List of credential tags available for @p sock
|
||||||
|
* @param[in] tags_len Number of credentials in @p tags
|
||||||
|
*
|
||||||
|
* @return Tag of the credential to use when a suitable one is found
|
||||||
|
* @retval CREDMAN_TAG_EMPTY otherwise
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets the PSK Identity hint to be sent to clients during handshake.
|
* @brief Sets the PSK Identity hint to be sent to clients during handshake.
|
||||||
*
|
*
|
||||||
@ -121,6 +135,15 @@ size_t sock_dtls_get_credentials(sock_dtls_t *sock, const credman_tag_t **out);
|
|||||||
*/
|
*/
|
||||||
void sock_dtls_set_client_psk_cb(sock_dtls_t *sock, sock_dtls_client_psk_cb_t cb);
|
void sock_dtls_set_client_psk_cb(sock_dtls_t *sock, sock_dtls_client_psk_cb_t cb);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the callback function to specify a credential to use for a given connection,
|
||||||
|
* when using Raw Public Keys.
|
||||||
|
*
|
||||||
|
* @param[in] sock The DTLS sock object to set the callback to.
|
||||||
|
* @param[in] cb Callback to set.
|
||||||
|
*/
|
||||||
|
void sock_dtls_set_rpk_cb(sock_dtls_t *sock, sock_dtls_rpk_cb_t cb);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user