@@ -1441,15 +1441,15 @@ void key_policy_init( )
1441
1441
1442
1442
memset( &zero, 0, sizeof( zero ) );
1443
1443
1444
- /* Although not technically guaranteed by the C standard nor the PSA Crypto
1445
- * specification, we test that all valid ways of initializing the object
1446
- * have the same bit pattern. This is a stronger requirement that may not
1447
- * be valid on all platforms or PSA Crypto implementations, but implies the
1448
- * weaker actual requirement is met: that a freshly initialized object, no
1449
- * matter how it was initialized, acts the same as any other valid
1450
- * initialization. */
1451
- TEST_EQUAL( memcmp ( &func, &zero, sizeof( zero ) ), 0 );
1452
- TEST_EQUAL( memcmp ( &init, & zero, sizeof( zero ) ), 0 );
1444
+ /* A default key policy should not permit any usage. */
1445
+ TEST_EQUAL( psa_key_policy_get_usage( &func ), 0 );
1446
+ TEST_EQUAL( psa_key_policy_get_usage( &init ), 0 );
1447
+ TEST_EQUAL( psa_key_policy_get_usage( &zero ), 0 );
1448
+
1449
+ /* A default key policy should not permit any algorithm. */
1450
+ TEST_EQUAL( psa_key_policy_get_algorithm( &func ), 0 );
1451
+ TEST_EQUAL( psa_key_policy_get_algorithm ( &init ), 0 );
1452
+ TEST_EQUAL( psa_key_policy_get_algorithm ( &zero ), 0 );
1453
1453
}
1454
1454
/* END_CASE */
1455
1455
@@ -1960,15 +1960,10 @@ void hash_operation_init( )
1960
1960
1961
1961
memset( &zero, 0, sizeof( zero ) );
1962
1962
1963
- /* Although not technically guaranteed by the C standard nor the PSA Crypto
1964
- * specification, we test that all valid ways of initializing the object
1965
- * have the same bit pattern. This is a stronger requirement that may not
1966
- * be valid on all platforms or PSA Crypto implementations, but implies the
1967
- * weaker actual requirement is met: that a freshly initialized object, no
1968
- * matter how it was initialized, acts the same as any other valid
1969
- * initialization. */
1970
- TEST_EQUAL( memcmp( &func, &zero, sizeof( zero ) ), 0 );
1971
- TEST_EQUAL( memcmp( &init, &zero, sizeof( zero ) ), 0 );
1963
+ /* A default hash operation should be abortable without error. */
1964
+ PSA_ASSERT( psa_hash_abort( &func ) );
1965
+ PSA_ASSERT( psa_hash_abort( &init ) );
1966
+ PSA_ASSERT( psa_hash_abort( &zero ) );
1972
1967
}
1973
1968
/* END_CASE */
1974
1969
@@ -2183,15 +2178,10 @@ void mac_operation_init( )
2183
2178
2184
2179
memset( &zero, 0, sizeof( zero ) );
2185
2180
2186
- /* Although not technically guaranteed by the C standard nor the PSA Crypto
2187
- * specification, we test that all valid ways of initializing the object
2188
- * have the same bit pattern. This is a stronger requirement that may not
2189
- * be valid on all platforms or PSA Crypto implementations, but implies the
2190
- * weaker actual requirement is met: that a freshly initialized object, no
2191
- * matter how it was initialized, acts the same as any other valid
2192
- * initialization. */
2193
- TEST_EQUAL( memcmp( &func, &zero, sizeof( zero ) ), 0 );
2194
- TEST_EQUAL( memcmp( &init, &zero, sizeof( zero ) ), 0 );
2181
+ /* A default MAC operation should be abortable without error. */
2182
+ PSA_ASSERT( psa_mac_abort( &func ) );
2183
+ PSA_ASSERT( psa_mac_abort( &init ) );
2184
+ PSA_ASSERT( psa_mac_abort( &zero ) );
2195
2185
}
2196
2186
/* END_CASE */
2197
2187
@@ -2338,15 +2328,10 @@ void cipher_operation_init( )
2338
2328
2339
2329
memset( &zero, 0, sizeof( zero ) );
2340
2330
2341
- /* Although not technically guaranteed by the C standard nor the PSA Crypto
2342
- * specification, we test that all valid ways of initializing the object
2343
- * have the same bit pattern. This is a stronger requirement that may not
2344
- * be valid on all platforms or PSA Crypto implementations, but implies the
2345
- * weaker actual requirement is met: that a freshly initialized object, no
2346
- * matter how it was initialized, acts the same as any other valid
2347
- * initialization. */
2348
- TEST_EQUAL( memcmp( &func, &zero, sizeof( zero ) ), 0 );
2349
- TEST_EQUAL( memcmp( &init, &zero, sizeof( zero ) ), 0 );
2331
+ /* A default cipher operation should be abortable without error. */
2332
+ PSA_ASSERT( psa_cipher_abort( &func ) );
2333
+ PSA_ASSERT( psa_cipher_abort( &init ) );
2334
+ PSA_ASSERT( psa_cipher_abort( &zero ) );
2350
2335
}
2351
2336
/* END_CASE */
2352
2337
@@ -3527,21 +3512,25 @@ void crypto_generator_init( )
3527
3512
* Clang 5 complains when `-Wmissing-field-initializers` is used, even
3528
3513
* though it's OK by the C standard. We could test for this, but we'd need
3529
3514
* to supress the Clang warning for the test. */
3515
+ size_t capacity;
3530
3516
psa_crypto_generator_t func = psa_crypto_generator_init( );
3531
3517
psa_crypto_generator_t init = PSA_CRYPTO_GENERATOR_INIT;
3532
3518
psa_crypto_generator_t zero;
3533
3519
3534
3520
memset( &zero, 0, sizeof( zero ) );
3535
3521
3536
- /* Although not technically guaranteed by the C standard nor the PSA Crypto
3537
- * specification, we test that all valid ways of initializing the object
3538
- * have the same bit pattern. This is a stronger requirement that may not
3539
- * be valid on all platforms or PSA Crypto implementations, but implies the
3540
- * weaker actual requirement is met: that a freshly initialized object, no
3541
- * matter how it was initialized, acts the same as any other valid
3542
- * initialization. */
3543
- TEST_EQUAL( memcmp( &func, &zero, sizeof( zero ) ), 0 );
3544
- TEST_EQUAL( memcmp( &init, &zero, sizeof( zero ) ), 0 );
3522
+ /* A default generator should have no capacity. */
3523
+ PSA_ASSERT( psa_get_generator_capacity( &func, &capacity ) );
3524
+ TEST_EQUAL( capacity, 0 );
3525
+ PSA_ASSERT( psa_get_generator_capacity( &init, &capacity ) );
3526
+ TEST_EQUAL( capacity, 0 );
3527
+ PSA_ASSERT( psa_get_generator_capacity( &zero, &capacity ) );
3528
+ TEST_EQUAL( capacity, 0 );
3529
+
3530
+ /* A default generator should be abortable without error. */
3531
+ PSA_ASSERT( psa_generator_abort(&func) );
3532
+ PSA_ASSERT( psa_generator_abort(&init) );
3533
+ PSA_ASSERT( psa_generator_abort(&zero) );
3545
3534
}
3546
3535
/* END_CASE */
3547
3536
0 commit comments