99
1010const uint8_t aes_key_buf [] = {0xea , 0x4f , 0x6f , 0x3c , 0x2f , 0xed , 0x2b , 0x9d ,
1111 0xd9 , 0x70 , 0x8c , 0x2e , 0x72 , 0x1a , 0xe0 , 0x0f };
12- const uint8_t wrapped_aes_key_buf [] = {0x52 , 0xb3 , 0x41 , 0x71 , 0xcf , 0xd6 ,
13- 0xa2 , 0x00 , 0xe6 , 0xe4 , 0x75 , 0x57 , 0xa6 , 0xe5 , 0x0a , 0x0f };
12+ const uint8_t wrapped_aes_key_buf [] = {0x52 , 0xb3 , 0x41 , 0x71 , 0xcf , 0xd6 , 0xa2 , 0x00 ,
13+ 0xe6 , 0xe4 , 0x75 , 0x57 , 0xa6 , 0xe5 , 0x0a , 0x0f };
1414const uint8_t aes_nonce_buf [] = {0xf9 , 0x75 , 0x80 , 0x9d , 0xdb , 0x51 ,
1515 0x72 , 0x38 , 0x27 , 0x45 , 0x63 , 0x4f };
1616const uint8_t aes_ad_buf [] = {0x5c , 0x65 , 0xd4 , 0xf2 , 0x61 , 0xd2 , 0xc5 , 0x4f , 0xfe , 0x6a };
@@ -20,10 +20,12 @@ const uint8_t chachapoly_key_buf[] = {0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86,
2020 0x88 , 0x89 , 0x8a , 0x8b , 0x8c , 0x8d , 0x8e , 0x8f ,
2121 0x90 , 0x91 , 0x92 , 0x93 , 0x94 , 0x95 , 0x96 , 0x97 ,
2222 0x98 , 0x99 , 0x9a , 0x9b , 0x9c , 0x9d , 0x9e , 0x9f };
23- const uint8_t wrapped_chachapoly_key_buf [] = {0x19 , 0x67 , 0x03 , 0x6a , 0x20 , 0xe6 , 0x32 ,
24- 0xed , 0x21 , 0x2a , 0x4a , 0xdc , 0x2c , 0x5f , 0x19 ,
25- 0x22 , 0x77 , 0x56 , 0x61 , 0x92 , 0x2c , 0xf3 , 0xdc ,
26- 0xe8 , 0x8e , 0x81 , 0x45 , 0x4d , 0xd6 , 0xc7 , 0x86 , 0x0b };
23+ #if defined(CONFIG_TEST_WRAPPED_KEYS ) && CONFIG_TEST_WRAPPED_KEYS
24+ const uint8_t wrapped_chachapoly_key_buf [] = {0x19 , 0x67 , 0x03 , 0x6a , 0x20 , 0xe6 , 0x32 , 0xed ,
25+ 0x21 , 0x2a , 0x4a , 0xdc , 0x2c , 0x5f , 0x19 , 0x22 ,
26+ 0x77 , 0x56 , 0x61 , 0x92 , 0x2c , 0xf3 , 0xdc , 0xe8 ,
27+ 0x8e , 0x81 , 0x45 , 0x4d , 0xd6 , 0xc7 , 0x86 , 0x0b };
28+ #endif
2729const uint8_t chachapoly_nonce_buf [] = {0x07 , 0x00 , 0x00 , 0x00 , 0x40 , 0x41 ,
2830 0x42 , 0x43 , 0x44 , 0x45 , 0x46 , 0x47 };
2931const uint8_t chachapoly_ad_buf [] = {0x50 , 0x51 , 0x52 , 0x53 , 0xc0 , 0xc1 ,
@@ -67,16 +69,17 @@ ZTEST(psa_crypto_test, test_aead_aes_ccm)
6769 psa_set_key_usage_flags (& attributes , PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT );
6870 psa_set_key_algorithm (& attributes , alg );
6971
70- #if defined(CONFIG_TEST_WRAPPED_KEYS ) && CONFIG_TEST_WRAPPED_KEYS
72+ #if defined(CONFIG_TEST_WRAPPED_KEYS ) && CONFIG_TEST_WRAPPED_KEYS
7173 printf ("Test Wrapper keys enabled\n" );
7274 psa_set_key_lifetime (& attributes , PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION (
7375 PSA_KEY_PERSISTENCE_VOLATILE , 1 ));
74- zassert_equal (psa_import_key (& attributes , wrapped_aes_key_buf , sizeof (wrapped_aes_key_buf ), & key_id ),
75- PSA_SUCCESS , "Failed to import key" );
76- #else
76+ zassert_equal (psa_import_key (& attributes , wrapped_aes_key_buf , sizeof (wrapped_aes_key_buf ),
77+ & key_id ),
78+ PSA_SUCCESS , "Failed to import key" );
79+ #else
7780 zassert_equal (psa_import_key (& attributes , aes_key_buf , sizeof (aes_key_buf ), & key_id ),
7881 PSA_SUCCESS , "Failed to import key" );
79- #endif
82+ #endif
8083 zassert_equal (psa_aead_encrypt (key_id , alg , aes_nonce_buf , sizeof (aes_nonce_buf ),
8184 aes_ad_buf , sizeof (aes_ad_buf ), aes_plaintext ,
8285 sizeof (aes_plaintext ), cipher_tag_buf ,
@@ -113,16 +116,17 @@ ZTEST(psa_crypto_test, test_aead_aes_gcm)
113116 psa_set_key_usage_flags (& attributes , PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT );
114117 psa_set_key_algorithm (& attributes , alg );
115118
116- #if defined(CONFIG_TEST_WRAPPED_KEYS ) && CONFIG_TEST_WRAPPED_KEYS
119+ #if defined(CONFIG_TEST_WRAPPED_KEYS ) && CONFIG_TEST_WRAPPED_KEYS
117120 printf ("Test Wrapper keys enabled\n" );
118- psa_set_key_lifetime (& attributes , PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION (
119- PSA_KEY_PERSISTENCE_VOLATILE , 1 ));
120- zassert_equal (psa_import_key (& attributes , wrapped_aes_key_buf , sizeof (wrapped_aes_key_buf ), & key_id ),
121+ psa_set_key_lifetime (& attributes , PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION (
122+ PSA_KEY_PERSISTENCE_VOLATILE , 1 ));
123+ zassert_equal (psa_import_key (& attributes , wrapped_aes_key_buf , sizeof (wrapped_aes_key_buf ),
124+ & key_id ),
121125 PSA_SUCCESS , "Failed to import key" );
122- #else
126+ #else
123127 zassert_equal (psa_import_key (& attributes , aes_key_buf , sizeof (aes_key_buf ), & key_id ),
124128 PSA_SUCCESS , "Failed to import key" );
125- #endif
129+ #endif
126130 zassert_equal (psa_aead_encrypt (key_id , alg , aes_nonce_buf , sizeof (aes_nonce_buf ),
127131 aes_ad_buf , sizeof (aes_ad_buf ), aes_plaintext ,
128132 sizeof (aes_plaintext ), cipher_tag_buf ,
@@ -157,17 +161,18 @@ ZTEST(psa_crypto_test, test_aead_chacha20_poly1305)
157161 psa_set_key_usage_flags (& attributes , PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT );
158162 psa_set_key_algorithm (& attributes , alg );
159163
160- #if defined(CONFIG_TEST_WRAPPED_KEYS ) && CONFIG_TEST_WRAPPED_KEYS
164+ #if defined(CONFIG_TEST_WRAPPED_KEYS ) && CONFIG_TEST_WRAPPED_KEYS
161165 printf ("Test Wrapper keys enabled\n" );
162166 psa_set_key_lifetime (& attributes , PSA_KEY_LIFETIME_FROM_PERSISTENCE_AND_LOCATION (
163- PSA_KEY_PERSISTENCE_VOLATILE , 1 ));
167+ PSA_KEY_PERSISTENCE_VOLATILE , 1 ));
164168 zassert_equal (psa_import_key (& attributes , wrapped_chachapoly_key_buf ,
165- sizeof (wrapped_chachapoly_key_buf ), & key_id ),
166- PSA_SUCCESS , "Failed to import key" );
167- #else
168- zassert_equal (psa_import_key (& attributes , chachapoly_key_buf , sizeof (chachapoly_key_buf ), & key_id ),
169+ sizeof (wrapped_chachapoly_key_buf ), & key_id ),
170+ PSA_SUCCESS , "Failed to import key" );
171+ #else
172+ zassert_equal (psa_import_key (& attributes , chachapoly_key_buf , sizeof (chachapoly_key_buf ),
173+ & key_id ),
169174 PSA_SUCCESS , "Failed to import key" );
170- #endif
175+ #endif
171176 zassert_equal (psa_aead_encrypt (key_id , alg , chachapoly_nonce_buf ,
172177 sizeof (chachapoly_nonce_buf ), chachapoly_ad_buf ,
173178 sizeof (chachapoly_ad_buf ), chachapoly_plaintext ,
0 commit comments