mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-30 15:32:58 +00:00
test_suite_ssl: Added ssl_session_id_accessors_check.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
This commit is contained in:
parent
40d4708f17
commit
411cb6c30f
@ -961,6 +961,14 @@ TLS 1.3: SRV: session serialization: Wrong config
|
||||
depends_on:MBEDTLS_SSL_PROTO_TLS1_3:MBEDTLS_SSL_SRV_C
|
||||
ssl_session_serialize_version_check:0:0:0:1:MBEDTLS_SSL_IS_SERVER:MBEDTLS_SSL_VERSION_TLS1_3
|
||||
|
||||
Test Session id & Ciphersuite accesors TLS 1.2
|
||||
depends_on:MBEDTLS_SSL_PROTO_TLS1_2
|
||||
ssl_session_id_accessors_check:MBEDTLS_SSL_VERSION_TLS1_2
|
||||
|
||||
Test Session id & Ciphersuite accesors TLS 1.3
|
||||
depends_on:MBEDTLS_SSL_PROTO_TLS1_3
|
||||
ssl_session_id_accessors_check:MBEDTLS_SSL_VERSION_TLS1_3
|
||||
|
||||
Record crypt, AES-128-CBC, 1.2, SHA-384
|
||||
depends_on:MBEDTLS_SSL_HAVE_AES:MBEDTLS_SSL_HAVE_CBC:MBEDTLS_SSL_PROTO_TLS1_2:MBEDTLS_MD_CAN_SHA384
|
||||
ssl_crypt_record:MBEDTLS_CIPHER_AES_128_CBC:MBEDTLS_MD_SHA384:0:0:MBEDTLS_SSL_VERSION_TLS1_2:0:0
|
||||
|
@ -2379,6 +2379,54 @@ exit:
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void ssl_session_id_accessors_check(int tls_version)
|
||||
{
|
||||
mbedtls_ssl_session session;
|
||||
int ciphersuite_id;
|
||||
const mbedtls_ssl_ciphersuite_t *ciphersuite_info;
|
||||
|
||||
mbedtls_ssl_session_init(&session);
|
||||
USE_PSA_INIT();
|
||||
|
||||
switch (tls_version) {
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
|
||||
case MBEDTLS_SSL_VERSION_TLS1_3:
|
||||
ciphersuite_id = MBEDTLS_TLS1_3_AES_128_GCM_SHA256;
|
||||
TEST_ASSERT(mbedtls_test_ssl_tls13_populate_session(
|
||||
&session, 0, MBEDTLS_SSL_IS_SERVER) == 0);
|
||||
break;
|
||||
#endif
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
||||
case MBEDTLS_SSL_VERSION_TLS1_2:
|
||||
ciphersuite_id = MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256;
|
||||
TEST_ASSERT(mbedtls_test_ssl_tls12_populate_session(
|
||||
&session, 0, MBEDTLS_SSL_IS_SERVER, NULL) == 0);
|
||||
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
/* should never happen */
|
||||
TEST_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
TEST_ASSERT(*mbedtls_ssl_session_get_id(&session) == session.id);
|
||||
TEST_ASSERT(mbedtls_ssl_session_get_id_len(&session) == session.id_len);
|
||||
/* mbedtls_test_ssl_tls1x_populate_session sets a mock suite-id of 0xabcd */
|
||||
TEST_ASSERT(mbedtls_ssl_session_get_ciphersuite_id(&session) == 0xabcd);
|
||||
|
||||
/* Test setting a reference id for tls1.3 and tls1.2 */
|
||||
ciphersuite_info = mbedtls_ssl_ciphersuite_from_id(ciphersuite_id);
|
||||
if (ciphersuite_info != NULL) {
|
||||
TEST_ASSERT(mbedtls_ssl_ciphersuite_get_id(ciphersuite_info) == ciphersuite_id);
|
||||
}
|
||||
|
||||
exit:
|
||||
mbedtls_ssl_session_free(&session);
|
||||
USE_PSA_DONE();
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED:MBEDTLS_RSA_C:MBEDTLS_ECP_HAVE_SECP384R1:!MBEDTLS_SSL_PROTO_TLS1_3:MBEDTLS_PKCS1_V15:MBEDTLS_MD_CAN_SHA256 */
|
||||
void mbedtls_endpoint_sanity(int endpoint_type)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user