Lines Matching refs:attributes
150 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
152 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_SIGN_HASH );
153 psa_set_key_algorithm( &attributes, alg );
154 psa_set_key_type( &attributes, key_type );
155 PSA_ASSERT( psa_import_key( &attributes, key_bytes, key_length, &key ) );
183 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
185 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT );
186 psa_set_key_algorithm( &attributes, alg );
187 psa_set_key_type( &attributes, key_type );
188 PSA_ASSERT( psa_import_key( &attributes, key_bytes, key_length, &key ) );
211 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
217 psa_set_key_id( &attributes, key_id );
218 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT );
219 psa_set_key_algorithm( &attributes, PSA_ALG_CTR );
220 psa_set_key_type( &attributes, PSA_KEY_TYPE_AES );
221 TEST_EQUAL( psa_get_key_attributes( key, &attributes ),
224 MBEDTLS_SVC_KEY_ID_GET_KEY_ID( psa_get_key_id( &attributes ) ), 0 );
226 MBEDTLS_SVC_KEY_ID_GET_OWNER_ID( psa_get_key_id( &attributes ) ), 0 );
227 TEST_EQUAL( psa_get_key_lifetime( &attributes ), 0 );
228 TEST_EQUAL( psa_get_key_usage_flags( &attributes ), 0 );
229 TEST_EQUAL( psa_get_key_algorithm( &attributes ), 0 );
230 TEST_EQUAL( psa_get_key_type( &attributes ), 0 );
231 TEST_EQUAL( psa_get_key_bits( &attributes ), 0 );
243 * Key attributes may have been returned by psa_get_key_attributes()
246 psa_reset_key_attributes( &attributes );
253 #define ASSERT_NO_SLOT_NUMBER( attributes ) \
258 attributes, \
264 #define ASSERT_NO_SLOT_NUMBER( attributes ) \
351 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
360 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT );
362 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DECRYPT );
364 psa_set_key_algorithm( &attributes, alg );
365 psa_set_key_type( &attributes, key_type );
367 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
370 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
371 key_bits = psa_get_key_bits( &attributes );
616 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
628 psa_set_key_type( &attributes, type );
629 psa_set_key_usage_flags( &attributes, usage );
630 psa_set_key_algorithm( &attributes, alg );
632 status = psa_import_key( &attributes,
651 * Key attributes may have been returned by psa_get_key_attributes()
666 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
676 psa_set_key_type( &attributes, type );
677 psa_set_key_bits( &attributes, attr_bits );
679 status = psa_import_key( &attributes, data->x, data->len, &key );
695 * Key attributes may have been returned by psa_get_key_attributes()
711 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
727 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_EXPORT );
728 psa_set_key_type( &attributes, type );
729 status = psa_import_key( &attributes, buffer, byte_size, &key );
735 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
736 TEST_EQUAL( psa_get_key_type( &attributes ), type );
737 TEST_EQUAL( psa_get_key_bits( &attributes ),
739 ASSERT_NO_SLOT_NUMBER( &attributes );
750 * Key attributes may have been returned by psa_get_key_attributes()
753 psa_reset_key_attributes( &attributes );
776 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
786 psa_set_key_type( &attributes, type );
787 status = psa_import_key( &attributes, p, length, &key );
820 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
829 psa_set_key_lifetime( &attributes, lifetime );
830 psa_set_key_usage_flags( &attributes, usage_arg );
831 psa_set_key_algorithm( &attributes, alg );
832 psa_set_key_type( &attributes, type );
835 PSA_ASSERT( psa_import_key( &attributes, data->x, data->len, &key ) );
876 PSA_ASSERT( psa_import_key( &attributes, exported, exported_length,
898 * Key attributes may have been returned by psa_get_key_attributes()
927 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
931 psa_set_key_lifetime( &attributes, lifetime );
932 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_EXPORT );
933 psa_set_key_algorithm( &attributes, alg );
934 psa_set_key_type( &attributes, type );
937 PSA_ASSERT( psa_import_key( &attributes, data->x, data->len, &key ) );
949 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
950 bits = psa_get_key_bits( &attributes );
962 * Key attributes may have been returned by psa_get_key_attributes()
965 psa_reset_key_attributes( &attributes );
984 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
989 psa_set_key_usage_flags( &attributes, usage );
990 psa_set_key_algorithm( &attributes, alg );
991 psa_set_key_type( &attributes, type );
994 PSA_ASSERT( psa_import_key( &attributes, data->x, data->len, &key ) );
1010 * Key attributes may have been returned by psa_get_key_attributes()
1015 psa_reset_key_attributes( &attributes );
1036 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
1040 psa_set_key_usage_flags( &attributes, usage );
1041 psa_set_key_algorithm( &attributes, alg );
1042 psa_set_key_type( &attributes, key_type );
1043 psa_set_key_bits( &attributes, bits );
1045 PSA_ASSERT( psa_generate_key( &attributes, &key ) );
1046 psa_reset_key_attributes( &attributes );
1048 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
1049 TEST_EQUAL( psa_get_key_type( &attributes ), expected_key_type );
1050 TEST_EQUAL( psa_get_key_bits( &attributes ), expected_bits );
1051 TEST_EQUAL( psa_get_key_usage_flags( &attributes ), expected_usage );
1052 TEST_EQUAL( psa_get_key_algorithm( &attributes ), expected_alg );
1056 * Key attributes may have been returned by psa_get_key_attributes()
1059 psa_reset_key_attributes( &attributes );
1123 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
1136 psa_set_key_usage_flags( &attributes, policy_usage );
1137 psa_set_key_algorithm( &attributes, policy_alg );
1138 psa_set_key_type( &attributes, key_type );
1140 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
1143 TEST_EQUAL( psa_get_key_usage_flags( &attributes ),
1187 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
1194 psa_set_key_usage_flags( &attributes, policy_usage );
1195 psa_set_key_algorithm( &attributes, policy_alg );
1196 psa_set_key_type( &attributes, key_type );
1198 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
1238 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
1253 psa_set_key_usage_flags( &attributes, policy_usage );
1254 psa_set_key_algorithm( &attributes, policy_alg );
1255 psa_set_key_type( &attributes, key_type );
1257 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
1303 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
1313 psa_set_key_usage_flags( &attributes, policy_usage );
1314 psa_set_key_algorithm( &attributes, policy_alg );
1315 psa_set_key_type( &attributes, key_type );
1317 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
1324 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
1325 key_bits = psa_get_key_bits( &attributes );
1356 * Key attributes may have been returned by psa_get_key_attributes()
1359 psa_reset_key_attributes( &attributes );
1377 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
1398 psa_set_key_usage_flags( &attributes, policy_usage );
1399 psa_set_key_algorithm( &attributes, policy_alg );
1400 psa_set_key_type( &attributes, key_type );
1402 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
1405 TEST_EQUAL( psa_get_key_usage_flags( &attributes ), expected_usage );
1461 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
1467 psa_set_key_usage_flags( &attributes, policy_usage );
1468 psa_set_key_algorithm( &attributes, policy_alg );
1469 psa_set_key_type( &attributes, key_type );
1471 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
1511 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
1519 psa_set_key_usage_flags( &attributes, policy_usage );
1520 psa_set_key_algorithm( &attributes, policy_alg );
1521 psa_set_key_type( &attributes, key_type );
1523 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
1544 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
1552 psa_set_key_usage_flags( &attributes, usage );
1553 psa_set_key_algorithm( &attributes, alg );
1554 psa_set_key_enrollment_algorithm( &attributes, alg2 );
1555 psa_set_key_type( &attributes, key_type );
1556 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
1573 * Key attributes may have been returned by psa_get_key_attributes()
1592 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
1600 psa_set_key_usage_flags( &attributes, policy_usage );
1601 psa_set_key_algorithm( &attributes, policy_alg );
1602 psa_set_key_type( &attributes, key_type );
1604 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
1654 /* Prepare the target attributes. */
1708 * Source and target key attributes may have been returned by
1748 /* Prepare the target attributes. */
2268 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
2279 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH );
2280 psa_set_key_algorithm( &attributes, alg );
2281 psa_set_key_type( &attributes, key_type );
2283 PSA_ASSERT( psa_import_key( &attributes, key_data, sizeof( key_data ),
2394 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
2413 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_SIGN_HASH );
2414 psa_set_key_algorithm( &attributes, alg );
2415 psa_set_key_type( &attributes, key_type );
2417 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
2482 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
2489 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_VERIFY_HASH );
2490 psa_set_key_algorithm( &attributes, alg );
2491 psa_set_key_type( &attributes, key_type );
2493 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
2655 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
2668 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT );
2669 psa_set_key_algorithm( &attributes, alg );
2670 psa_set_key_type( &attributes, key_type );
2671 PSA_ASSERT( psa_import_key( &attributes, key_data, sizeof( key_data ),
2836 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
2842 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT );
2843 psa_set_key_algorithm( &attributes, alg );
2844 psa_set_key_type( &attributes, key_type );
2850 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
2873 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
2882 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT );
2883 psa_set_key_algorithm( &attributes, alg );
2884 psa_set_key_type( &attributes, key_type );
2886 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
2913 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
2917 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT );
2918 psa_set_key_algorithm( &attributes, alg );
2919 psa_set_key_type( &attributes, key_type );
2924 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
2949 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
2955 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT );
2956 psa_set_key_algorithm( &attributes, alg );
2957 psa_set_key_type( &attributes, key_type );
2967 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
3001 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
3005 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT );
3006 psa_set_key_algorithm( &attributes, alg );
3007 psa_set_key_type( &attributes, key_type );
3015 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
3085 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
3089 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT );
3090 psa_set_key_algorithm( &attributes, alg );
3091 psa_set_key_type( &attributes, key_type );
3093 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
3187 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
3191 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DECRYPT );
3192 psa_set_key_algorithm( &attributes, alg );
3193 psa_set_key_type( &attributes, key_type );
3195 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
3286 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
3292 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DECRYPT );
3293 psa_set_key_algorithm( &attributes, alg );
3294 psa_set_key_type( &attributes, key_type );
3296 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
3340 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
3344 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DECRYPT );
3345 psa_set_key_algorithm( &attributes, alg );
3346 psa_set_key_type( &attributes, key_type );
3360 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
3395 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
3399 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT );
3400 psa_set_key_algorithm( &attributes, alg );
3401 psa_set_key_type( &attributes, key_type );
3403 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
3460 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
3464 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT );
3465 psa_set_key_algorithm( &attributes, alg );
3466 psa_set_key_type( &attributes, key_type );
3468 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
3600 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
3604 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT );
3605 psa_set_key_algorithm( &attributes, alg );
3606 psa_set_key_type( &attributes, key_type );
3608 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
3610 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
3611 key_bits = psa_get_key_bits( &attributes );
3694 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
3699 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT );
3700 psa_set_key_algorithm( &attributes, alg );
3701 psa_set_key_type( &attributes, key_type );
3703 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
3705 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
3706 key_bits = psa_get_key_bits( &attributes );
3761 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
3767 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DECRYPT );
3768 psa_set_key_algorithm( &attributes, alg );
3769 psa_set_key_type( &attributes, key_type );
3771 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
3773 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
3774 key_bits = psa_get_key_bits( &attributes );
4017 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
4032 psa_set_key_usage_flags( & attributes, PSA_KEY_USAGE_ENCRYPT );
4033 psa_set_key_algorithm( & attributes, alg );
4034 psa_set_key_type( & attributes, key_type );
4036 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
4039 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
4118 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
4133 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT );
4134 psa_set_key_algorithm( &attributes, alg );
4135 psa_set_key_type( &attributes, key_type );
4137 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
4140 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
4231 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
4244 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT );
4245 psa_set_key_algorithm( &attributes, alg );
4246 psa_set_key_type( &attributes, key_type );
4248 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
4251 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
4314 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
4328 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT );
4329 psa_set_key_algorithm( &attributes, alg );
4330 psa_set_key_type( &attributes, key_type );
4332 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
4335 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
4398 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
4412 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DECRYPT );
4413 psa_set_key_algorithm( &attributes, alg );
4414 psa_set_key_type( &attributes, key_type );
4416 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
4419 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
4483 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
4489 psa_set_key_usage_flags( &attributes,
4491 psa_set_key_algorithm( &attributes, alg );
4492 psa_set_key_type( &attributes, key_type );
4494 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
4537 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
4541 psa_set_key_usage_flags( & attributes,
4543 psa_set_key_algorithm( & attributes, alg );
4544 psa_set_key_type( & attributes, key_type );
4546 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
4549 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
4550 key_bits = psa_get_key_bits( &attributes );
5052 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
5056 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_SIGN_HASH );
5057 psa_set_key_algorithm( &attributes, alg );
5058 psa_set_key_type( &attributes, key_type );
5060 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
5062 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
5063 key_bits = psa_get_key_bits( &attributes );
5084 * Key attributes may have been returned by psa_get_key_attributes()
5087 psa_reset_key_attributes( &attributes );
5108 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
5114 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_SIGN_HASH );
5115 psa_set_key_algorithm( &attributes, alg );
5116 psa_set_key_type( &attributes, key_type );
5118 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
5133 psa_reset_key_attributes( &attributes );
5151 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
5155 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_SIGN_HASH | PSA_KEY_USAGE_VERIFY_HASH );
5156 psa_set_key_algorithm( &attributes, alg );
5157 psa_set_key_type( &attributes, key_type );
5159 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
5161 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
5162 key_bits = psa_get_key_bits( &attributes );
5200 * Key attributes may have been returned by psa_get_key_attributes()
5203 psa_reset_key_attributes( &attributes );
5219 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
5225 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_VERIFY_HASH );
5226 psa_set_key_algorithm( &attributes, alg );
5227 psa_set_key_type( &attributes, key_type );
5229 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
5237 psa_reset_key_attributes( &attributes );
5254 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
5258 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_VERIFY_HASH );
5259 psa_set_key_algorithm( &attributes, alg );
5260 psa_set_key_type( &attributes, key_type );
5262 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
5271 psa_reset_key_attributes( &attributes );
5291 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
5295 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_SIGN_MESSAGE );
5296 psa_set_key_algorithm( &attributes, alg );
5297 psa_set_key_type( &attributes, key_type );
5299 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
5301 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
5302 key_bits = psa_get_key_bits( &attributes );
5318 psa_reset_key_attributes( &attributes );
5343 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
5349 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_SIGN_MESSAGE );
5350 psa_set_key_algorithm( &attributes, alg );
5351 psa_set_key_type( &attributes, key_type );
5353 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
5368 psa_reset_key_attributes( &attributes );
5388 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
5392 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_SIGN_MESSAGE |
5394 psa_set_key_algorithm( &attributes, alg );
5395 psa_set_key_type( &attributes, key_type );
5397 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
5399 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
5400 key_bits = psa_get_key_bits( &attributes );
5431 psa_reset_key_attributes( &attributes );
5449 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
5455 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_VERIFY_MESSAGE );
5456 psa_set_key_algorithm( &attributes, alg );
5457 psa_set_key_type( &attributes, key_type );
5459 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
5467 psa_reset_key_attributes( &attributes );
5486 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
5490 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_VERIFY_MESSAGE );
5491 psa_set_key_algorithm( &attributes, alg );
5492 psa_set_key_type( &attributes, key_type );
5494 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
5504 psa_reset_key_attributes( &attributes );
5529 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
5534 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT );
5535 psa_set_key_algorithm( &attributes, alg );
5536 psa_set_key_type( &attributes, key_type );
5537 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
5541 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
5542 key_bits = psa_get_key_bits( &attributes );
5575 * Key attributes may have been returned by psa_get_key_attributes()
5578 psa_reset_key_attributes( &attributes );
5603 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
5607 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_ENCRYPT | PSA_KEY_USAGE_DECRYPT );
5608 psa_set_key_algorithm( &attributes, alg );
5609 psa_set_key_type( &attributes, key_type );
5611 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
5615 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
5616 key_bits = psa_get_key_bits( &attributes );
5650 * Key attributes may have been returned by psa_get_key_attributes()
5653 psa_reset_key_attributes( &attributes );
5677 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
5681 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DECRYPT );
5682 psa_set_key_algorithm( &attributes, alg );
5683 psa_set_key_type( &attributes, key_type );
5685 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
5688 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
5689 key_bits = psa_get_key_bits( &attributes );
5723 psa_reset_key_attributes( &attributes );
5747 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
5753 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DECRYPT );
5754 psa_set_key_algorithm( &attributes, alg );
5755 psa_set_key_type( &attributes, key_type );
5757 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
5785 psa_reset_key_attributes( &attributes );
5882 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
5891 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DERIVE );
5892 psa_set_key_algorithm( &attributes, alg );
5905 psa_set_key_type( &attributes, key_types[i] );
5906 PSA_ASSERT( psa_import_key( &attributes,
5936 psa_reset_key_attributes( &attributes );
5937 psa_set_key_type( &attributes, PSA_KEY_TYPE_RAW_DATA );
5938 psa_set_key_bits( &attributes, 8 );
5940 psa_key_derivation_output_key( &attributes, &operation,
5977 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
5981 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DERIVE );
5982 psa_set_key_algorithm( &attributes, alg );
5983 psa_set_key_type( &attributes, key_type );
5985 PSA_ASSERT( psa_import_key( &attributes,
6066 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
6080 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DERIVE );
6081 psa_set_key_algorithm( &attributes, alg );
6082 psa_set_key_type( &attributes, PSA_KEY_TYPE_DERIVE );
6095 PSA_ASSERT( psa_import_key( &attributes,
6101 PSA_ASSERT( psa_get_key_attributes( keys[i], &attributes ) );
6102 TEST_ASSERT( PSA_BITS_TO_BYTES( psa_get_key_bits( &attributes ) ) <=
6179 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
6183 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DERIVE );
6184 psa_set_key_algorithm( &attributes, alg );
6185 psa_set_key_type( &attributes, PSA_KEY_TYPE_DERIVE );
6187 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
6247 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
6252 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DERIVE );
6253 psa_set_key_algorithm( &attributes, alg );
6254 psa_set_key_type( &attributes, PSA_KEY_TYPE_DERIVE );
6255 PSA_ASSERT( psa_import_key( &attributes, key_data->x, key_data->len,
6265 psa_set_key_usage_flags( &attributes, derived_usage );
6266 psa_set_key_algorithm( &attributes, derived_alg );
6267 psa_set_key_type( &attributes, derived_type );
6268 psa_set_key_bits( &attributes, derived_bits );
6269 PSA_ASSERT( psa_key_derivation_output_key( &attributes, &operation,
6283 * Key attributes may have been returned by psa_get_key_attributes()
6441 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
6447 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DERIVE );
6448 psa_set_key_algorithm( &attributes, our_key_alg );
6449 psa_set_key_type( &attributes, our_key_type );
6450 PSA_ASSERT( psa_import_key( &attributes,
6488 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
6496 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DERIVE );
6497 psa_set_key_algorithm( &attributes, alg );
6498 psa_set_key_type( &attributes, our_key_type );
6499 PSA_ASSERT( psa_import_key( &attributes,
6503 PSA_ASSERT( psa_get_key_attributes( our_key, &attributes ) );
6504 key_bits = psa_get_key_bits( &attributes );
6534 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
6540 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DERIVE );
6541 psa_set_key_algorithm( &attributes, alg );
6542 psa_set_key_type( &attributes, our_key_type );
6543 PSA_ASSERT( psa_import_key( &attributes,
6594 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
6602 psa_set_key_usage_flags( &attributes, PSA_KEY_USAGE_DERIVE );
6603 psa_set_key_algorithm( &attributes, alg );
6604 psa_set_key_type( &attributes, our_key_type );
6605 PSA_ASSERT( psa_import_key( &attributes,
6705 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
6710 psa_set_key_usage_flags( &attributes, usage );
6711 psa_set_key_algorithm( &attributes, alg );
6712 psa_set_key_type( &attributes, type );
6713 psa_set_key_bits( &attributes, bits );
6716 psa_status_t status = psa_generate_key( &attributes, &key );
6735 * Key attributes may have been returned by psa_get_key_attributes()
6756 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
6778 psa_set_key_usage_flags( &attributes, usage );
6779 psa_set_key_algorithm( &attributes, alg );
6780 PSA_ASSERT( psa_set_key_domain_parameters( &attributes, type,
6782 psa_set_key_bits( &attributes, bits );
6785 TEST_EQUAL( psa_generate_key( &attributes, &key ), expected_status );
6790 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
6791 TEST_EQUAL( psa_get_key_type( &attributes ), type );
6792 TEST_EQUAL( psa_get_key_bits( &attributes ), bits );
6793 PSA_ASSERT( psa_get_key_domain_parameters( &attributes,
6841 * Key attributes may have been returned by psa_get_key_attributes() or
6844 psa_reset_key_attributes( &attributes );
6860 psa_key_attributes_t attributes = PSA_KEY_ATTRIBUTES_INIT;
6882 psa_set_key_id( &attributes, key_id );
6883 psa_set_key_usage_flags( &attributes, usage_flags );
6884 psa_set_key_algorithm( &attributes, alg );
6885 psa_set_key_type( &attributes, type );
6886 psa_set_key_bits( &attributes, bits );
6892 PSA_ASSERT( psa_import_key( &attributes, data->x, data->len,
6898 PSA_ASSERT( psa_generate_key( &attributes, &key ) );
6922 PSA_ASSERT( psa_key_derivation_output_key( &attributes,
6938 psa_reset_key_attributes( &attributes );
6957 PSA_ASSERT( psa_get_key_attributes( key, &attributes ) );
6959 psa_get_key_id( &attributes ), key_id ) );
6960 TEST_EQUAL( psa_get_key_lifetime( &attributes ),
6962 TEST_EQUAL( psa_get_key_type( &attributes ), type );
6963 TEST_EQUAL( psa_get_key_bits( &attributes ), bits );
6964 TEST_EQUAL( psa_get_key_usage_flags( &attributes ),
6966 TEST_EQUAL( psa_get_key_algorithm( &attributes ), alg );
6984 * Key attributes may have been returned by psa_get_key_attributes()
6987 psa_reset_key_attributes( &attributes );