test: psa: minor improvements to test

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
This commit is contained in:
Valerio Setti 2022-12-07 15:41:05 +01:00
parent d5fa0bfb85
commit f11e05a413
2 changed files with 13 additions and 8 deletions

View file

@ -7989,6 +7989,8 @@ run_test "ECJPAKE: server not configured" \
-C "found ecjpake_kkpp extension" \
-s "SSL - The handshake negotiation failed"
# Note: if the name of this test is changed, then please adjust the corresponding
# filtering label in "test_tls1_2_ecjpake_compatibility" (in "all.sh")
requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
run_test "ECJPAKE: working, TLS" \
@ -8028,6 +8030,8 @@ run_test "ECJPAKE: opaque password client+server, working, TLS" \
-S "SSL - The handshake negotiation failed" \
-S "SSL - Verification of the message MAC failed"
# Note: if the name of this test is changed, then please adjust the corresponding
# filtering label in "test_tls1_2_ecjpake_compatibility" (in "all.sh")
requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
@ -8049,6 +8053,8 @@ run_test "ECJPAKE: opaque password client only, working, TLS" \
-S "SSL - The handshake negotiation failed" \
-S "SSL - Verification of the message MAC failed"
# Note: if the name of this test is changed, then please adjust the corresponding
# filtering label in "test_tls1_2_ecjpake_compatibility" (in "all.sh")
requires_config_enabled MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
requires_config_enabled MBEDTLS_USE_PSA_CRYPTO
requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2

View file

@ -2590,12 +2590,12 @@ int tweak_tls13_certificate_msg_vector_len(
ret = ( use_opaque_arg ) ? \
mbedtls_ssl_set_hs_ecjpake_password_opaque( &ssl, pwd_slot ) : \
mbedtls_ssl_set_hs_ecjpake_password( &ssl, pwd_string, pwd_len ); \
TEST_ASSERT( ret == exp_ret_val )
TEST_EQUAL( ret, exp_ret_val )
#else
#define ECJPAKE_TEST_SET_PASSWORD( exp_ret_val ) \
ret = mbedtls_ssl_set_hs_ecjpake_password( &ssl, \
pwd_string, pwd_len ); \
TEST_ASSERT( ret == exp_ret_val )
TEST_EQUAL( ret, exp_ret_val )
#endif
/* END_HEADER */
@ -6219,13 +6219,12 @@ void ssl_ecjpake_set_password( int use_opaque_arg )
mbedtls_ssl_config_init( &conf );
TEST_ASSERT( mbedtls_ssl_config_defaults( &conf,
TEST_EQUAL( mbedtls_ssl_config_defaults( &conf,
MBEDTLS_SSL_IS_CLIENT,
MBEDTLS_SSL_TRANSPORT_STREAM,
MBEDTLS_SSL_PRESET_DEFAULT )
== 0 );
MBEDTLS_SSL_PRESET_DEFAULT ), 0 );
TEST_ASSERT( mbedtls_ssl_setup( &ssl, &conf ) == 0 );
TEST_EQUAL( mbedtls_ssl_setup( &ssl, &conf ), 0 );
/* test with empty password or unitialized password key (depending on use_opaque_arg) */
ECJPAKE_TEST_SET_PASSWORD( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
@ -6242,8 +6241,8 @@ void ssl_ecjpake_set_password( int use_opaque_arg )
psa_set_key_algorithm( &attributes, PSA_ALG_JPAKE );
psa_set_key_type( &attributes, PSA_KEY_TYPE_PASSWORD );
TEST_ASSERT( psa_import_key( &attributes, pwd_string,
pwd_len, &pwd_slot ) == PSA_SUCCESS );
PSA_ASSERT( psa_import_key( &attributes, pwd_string,
pwd_len, &pwd_slot ) );
}
#endif /* MBEDTLS_USE_PSA_CRYPTO */