Add extern apis mbedtls_ticket_get_psk.

Signed-off-by: Xiaokang Qian <xiaokang.qian@arm.com>
This commit is contained in:
Xiaokang Qian 2022-12-15 14:38:29 +00:00
parent 32af4fbbdb
commit d05ac5dfce
2 changed files with 34 additions and 0 deletions

View file

@ -2629,6 +2629,13 @@ static inline int mbedtls_ssl_tls13_cipher_suite_is_offered(
return 0; return 0;
} }
#ifdef MBEDTLS_SSL_SESSION_TICKETS
int mbedtls_ssl_tls13_ticket_get_psk(mbedtls_ssl_context *ssl,
psa_algorithm_t *hash_alg,
const unsigned char **psk,
size_t *psk_len);
#endif
/** /**
* \brief Validate cipher suite against config in SSL context. * \brief Validate cipher suite against config in SSL context.
* *

View file

@ -1574,4 +1574,31 @@ int mbedtls_ssl_tls13_check_received_extension(
return MBEDTLS_ERR_SSL_UNSUPPORTED_EXTENSION; return MBEDTLS_ERR_SSL_UNSUPPORTED_EXTENSION;
} }
#ifdef MBEDTLS_SSL_SESSION_TICKETS
int mbedtls_ssl_tls13_ticket_get_psk(mbedtls_ssl_context *ssl,
psa_algorithm_t *hash_alg,
const unsigned char **psk,
size_t *psk_len)
{
mbedtls_ssl_session *session = ssl->session_negotiate;
const mbedtls_ssl_ciphersuite_t *ciphersuite_info = NULL;
if (ssl->handshake->resume == 0 || session == NULL ||
session->ticket == NULL) {
return -1;
}
ciphersuite_info = mbedtls_ssl_ciphersuite_from_id(session->ciphersuite);
if (ciphersuite_info != NULL) {
*hash_alg = mbedtls_psa_translate_md(ciphersuite_info->mac);
}
*psk = session->resumption_key;
*psk_len = session->resumption_key_len;
return 0;
}
#endif /* MBEDTLS_SSL_SESSION_TICKETS */
#endif /* MBEDTLS_SSL_TLS_C && MBEDTLS_SSL_PROTO_TLS1_3 */ #endif /* MBEDTLS_SSL_TLS_C && MBEDTLS_SSL_PROTO_TLS1_3 */