mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-14 01:26:49 +00:00
tests: ssl: Fix session field guards
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
93b2c32ece
commit
819636994e
@ -1791,30 +1791,33 @@ int mbedtls_test_ssl_tls13_populate_session(mbedtls_ssl_session *session,
|
||||
session->endpoint = endpoint_type == MBEDTLS_SSL_IS_CLIENT ?
|
||||
MBEDTLS_SSL_IS_CLIENT : MBEDTLS_SSL_IS_SERVER;
|
||||
session->ciphersuite = 0xabcd;
|
||||
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||
session->ticket_age_add = 0x87654321;
|
||||
session->ticket_flags = 0x7;
|
||||
|
||||
session->resumption_key_len = 32;
|
||||
memset(session->resumption_key, 0x99, sizeof(session->resumption_key));
|
||||
|
||||
#if defined(MBEDTLS_SSL_EARLY_DATA)
|
||||
session->max_early_data_size = 0x87654321;
|
||||
#if defined(MBEDTLS_SSL_ALPN) && defined(MBEDTLS_SSL_SRV_C)
|
||||
int ret = mbedtls_ssl_session_set_ticket_alpn(session, "ALPNExample");
|
||||
if (ret != 0) {
|
||||
return -1;
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_ALPN && MBEDTLS_SSL_SRV_C */
|
||||
#endif /* MBEDTLS_SSL_EARLY_DATA */
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME) && defined(MBEDTLS_SSL_SRV_C)
|
||||
if (session->endpoint == MBEDTLS_SSL_IS_SERVER) {
|
||||
session->ticket_creation_time = mbedtls_ms_time() - 42;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_SRV_C)
|
||||
if (session->endpoint == MBEDTLS_SSL_IS_SERVER) {
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||
#if defined(MBEDTLS_SSL_EARLY_DATA) && defined(MBEDTLS_SSL_ALPN)
|
||||
int ret = mbedtls_ssl_session_set_ticket_alpn(session, "ALPNExample");
|
||||
if (ret != 0) {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
session->ticket_creation_time = mbedtls_ms_time() - 42;
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_SESSION_TICKETS */
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_SRV_C */
|
||||
|
||||
#if defined(MBEDTLS_SSL_CLI_C)
|
||||
if (session->endpoint == MBEDTLS_SSL_IS_CLIENT) {
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
session->ticket_reception_time = mbedtls_ms_time() - 40;
|
||||
#endif
|
||||
@ -1828,9 +1831,14 @@ int mbedtls_test_ssl_tls13_populate_session(mbedtls_ssl_session *session,
|
||||
}
|
||||
memset(session->ticket, 33, ticket_len);
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_SESSION_TICKETS */
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_CLI_C */
|
||||
|
||||
#if defined(MBEDTLS_SSL_EARLY_DATA)
|
||||
session->max_early_data_size = 0x87654321;
|
||||
#endif /* MBEDTLS_SSL_EARLY_DATA */
|
||||
|
||||
#if defined(MBEDTLS_SSL_RECORD_SIZE_LIMIT)
|
||||
session->record_size_limit = 2048;
|
||||
#endif
|
||||
|
@ -2094,6 +2094,7 @@ void ssl_serialize_session_save_load(int ticket_len, char *crt_file,
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
|
||||
if (tls_version == MBEDTLS_SSL_VERSION_TLS1_3) {
|
||||
TEST_ASSERT(original.ciphersuite == restored.ciphersuite);
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||
TEST_ASSERT(original.ticket_age_add == restored.ticket_age_add);
|
||||
TEST_ASSERT(original.ticket_flags == restored.ticket_flags);
|
||||
TEST_ASSERT(original.resumption_key_len == restored.resumption_key_len);
|
||||
@ -2104,22 +2105,24 @@ void ssl_serialize_session_save_load(int ticket_len, char *crt_file,
|
||||
restored.resumption_key,
|
||||
original.resumption_key_len) == 0);
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_SESSION_TICKETS */
|
||||
|
||||
#if defined(MBEDTLS_SSL_EARLY_DATA)
|
||||
TEST_ASSERT(
|
||||
original.max_early_data_size == restored.max_early_data_size);
|
||||
#if defined(MBEDTLS_SSL_ALPN) && defined(MBEDTLS_SSL_SRV_C)
|
||||
#if defined(MBEDTLS_SSL_SRV_C)
|
||||
if (endpoint_type == MBEDTLS_SSL_IS_SERVER) {
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||
#if defined(MBEDTLS_SSL_EARLY_DATA) && defined(MBEDTLS_SSL_ALPN)
|
||||
TEST_ASSERT(original.ticket_alpn != NULL);
|
||||
TEST_ASSERT(restored.ticket_alpn != NULL);
|
||||
TEST_MEMORY_COMPARE(original.ticket_alpn, strlen(original.ticket_alpn),
|
||||
restored.ticket_alpn, strlen(restored.ticket_alpn));
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_SESSION_TICKETS */
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_SRV_C */
|
||||
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS) && defined(MBEDTLS_SSL_CLI_C)
|
||||
#if defined(MBEDTLS_SSL_CLI_C)
|
||||
if (endpoint_type == MBEDTLS_SSL_IS_CLIENT) {
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
TEST_ASSERT(original.ticket_reception_time == restored.ticket_reception_time);
|
||||
#endif
|
||||
@ -2132,12 +2135,17 @@ void ssl_serialize_session_save_load(int ticket_len, char *crt_file,
|
||||
restored.ticket,
|
||||
original.ticket_len) == 0);
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_SSL_SESSION_TICKETS */
|
||||
}
|
||||
#endif
|
||||
#endif /* MBEDTLS_SSL_CLI_C */
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_PROTO_TLS1_3 */
|
||||
|
||||
#if defined(MBEDTLS_SSL_EARLY_DATA)
|
||||
TEST_ASSERT(
|
||||
original.max_early_data_size == restored.max_early_data_size);
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_RECORD_SIZE_LIMIT)
|
||||
TEST_ASSERT(original.record_size_limit == restored.record_size_limit);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user