ssl_helpers.c: Add ticket write/parse test functions
Add ticket write/parse test functions as defined by mbedtls_ssl_ticket_write/parse_t. They are intended to be used in negative testing involving tickets. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
297c608915
commit
77abfe67db
2 changed files with 40 additions and 0 deletions
|
@ -589,6 +589,16 @@ int mbedtls_test_tweak_tls13_certificate_msg_vector_len(
|
|||
int *expected_result, mbedtls_ssl_chk_buf_ptr_args *args);
|
||||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||
int mbedtls_test_ticket_write(
|
||||
void *p_ticket, const mbedtls_ssl_session *session,
|
||||
unsigned char *start, const unsigned char *end,
|
||||
size_t *tlen, uint32_t *ticket_lifetime);
|
||||
|
||||
int mbedtls_test_ticket_parse(void *p_ticket, mbedtls_ssl_session *session,
|
||||
unsigned char *buf, size_t len);
|
||||
#endif /* MBEDTLS_SSL_SESSION_TICKETS */
|
||||
|
||||
#define ECJPAKE_TEST_PWD "bla"
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
|
|
|
@ -2419,4 +2419,34 @@ int mbedtls_test_tweak_tls13_certificate_msg_vector_len(
|
|||
return 0;
|
||||
}
|
||||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
|
||||
/* Functions for session ticket tests */
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||
int mbedtls_test_ticket_write(
|
||||
void *p_ticket, const mbedtls_ssl_session *session,
|
||||
unsigned char *start, const unsigned char *end,
|
||||
size_t *tlen, uint32_t *lifetime)
|
||||
{
|
||||
int ret;
|
||||
((void) p_ticket);
|
||||
|
||||
if ((ret = mbedtls_ssl_session_save(session, start, end - start,
|
||||
tlen)) != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Maximum ticket lifetime as defined in RFC 8446 */
|
||||
*lifetime = 7 * 24 * 3600;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mbedtls_test_ticket_parse(void *p_ticket, mbedtls_ssl_session *session,
|
||||
unsigned char *buf, size_t len)
|
||||
{
|
||||
((void) p_ticket);
|
||||
|
||||
return mbedtls_ssl_session_load(session, buf, len);
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_SESSION_TICKETS */
|
||||
#endif /* MBEDTLS_SSL_TLS_C */
|
||||
|
|
Loading…
Reference in a new issue