66
77#include <zephyr/ztest.h>
88#include <psa/crypto.h>
9+ #include <zephyr/sys/util_macro.h>
910
1011static const uint8_t client_private_key [] = {
1112 0xB0 , 0x76 , 0x51 , 0xEA , 0x20 , 0xF0 , 0x28 , 0xA8 , 0x16 , 0xEE , 0x01 ,
@@ -27,13 +28,13 @@ static const uint8_t server_public_key[] = {
2728 0x8D , 0x49 , 0x85 , 0x8C , 0x7A , 0x9F , 0xC1 , 0x46 , 0xDA , 0xCC , 0x96 ,
2829 0xEF , 0x6E , 0xD4 , 0xDA , 0x71 , 0xBF , 0xED , 0x32 , 0x0D , 0x76 ,
2930};
30- #if (! CONFIG_TEST_WRAPPED_KEYS )
31+ if (! IS_ENABLED ( CONFIG_TEST_WRAPPED_KEYS )) {
3132 static const uint8_t expected_shared_secret [] = {
3233 0xF2 , 0xE6 , 0x0E , 0x1C , 0xB7 , 0x64 , 0xBC , 0x48 , 0xF2 , 0x9D , 0xBB ,
3334 0x12 , 0xFB , 0x12 , 0x17 , 0x31 , 0x32 , 0x1D , 0x79 , 0xAF , 0x0A , 0x9F ,
3435 0xAB , 0xAD , 0x34 , 0x05 , 0xA2 , 0x07 , 0x39 , 0x9C , 0x5F , 0x15 ,
3536 };
36- #endif
37+ }
3738ZTEST (psa_crypto_test , test_key_agreement_ecdh_25519 )
3839{
3940 uint8_t shared_secret_buf [32 ];
@@ -45,10 +46,10 @@ ZTEST(psa_crypto_test, test_key_agreement_ecdh_25519)
4546 psa_set_key_type (& attributes , PSA_KEY_TYPE_ECC_KEY_PAIR (PSA_ECC_FAMILY_MONTGOMERY ));
4647 psa_set_key_usage_flags (& attributes , PSA_KEY_USAGE_DERIVE );
4748 psa_set_key_algorithm (& attributes , PSA_ALG_ECDH );
48- #if ( CONFIG_TEST_WRAPPED_KEYS )
49+ if ( IS_ENABLED ( CONFIG_TEST_WRAPPED_KEYS )) {
4950 psa_set_key_lifetime (& attributes , PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION (
5051 PSA_KEY_PERSISTENCE_VOLATILE , 0 ));
51- #endif
52+ }
5253 zassert_equal (psa_import_key (& attributes , client_private_key , sizeof (client_private_key ),
5354 & key_id ),
5455 PSA_SUCCESS , "Failed to import client key" );
@@ -66,10 +67,10 @@ ZTEST(psa_crypto_test, test_key_agreement_ecdh_25519)
6667 psa_set_key_type (& attributes , PSA_KEY_TYPE_ECC_KEY_PAIR (PSA_ECC_FAMILY_MONTGOMERY ));
6768 psa_set_key_usage_flags (& attributes , PSA_KEY_USAGE_DERIVE );
6869 psa_set_key_algorithm (& attributes , PSA_ALG_ECDH );
69- #if ( CONFIG_TEST_WRAPPED_KEYS )
70+ if ( IS_ENABLED ( CONFIG_TEST_WRAPPED_KEYS )) {
7071 psa_set_key_lifetime (& attributes , PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION (
7172 PSA_KEY_PERSISTENCE_VOLATILE , 0 ));
72- #endif
73+ }
7374 zassert_equal (psa_import_key (& attributes , server_private_key , sizeof (server_private_key ),
7475 & key_id ),
7576 PSA_SUCCESS , "Failed to import server key" );
@@ -81,10 +82,10 @@ ZTEST(psa_crypto_test, test_key_agreement_ecdh_25519)
8182 PSA_SUCCESS , "Failed to perform key agreement with client" );
8283
8384 zassert_equal (psa_destroy_key (key_id ), PSA_SUCCESS , "Failed to destroy server key" );
84- #if (! CONFIG_TEST_WRAPPED_KEYS )
85+ if (! IS_ENABLED ( CONFIG_TEST_WRAPPED_KEYS )) {
8586 /* Verify shared secret */
8687 zassert_mem_equal (shared_secret_buf , expected_shared_secret ,
8788 sizeof (expected_shared_secret ),
8889 "Key agreement did not resolve the correct shared secret" );
89- #endif
90+ }
9091}
0 commit comments