@@ -3305,6 +3305,31 @@ exit:
3305
3305
}
3306
3306
/* END_CASE */
3307
3307
3308
+ /* BEGIN_CASE */
3309
+ void crypto_generator_init( )
3310
+ {
3311
+ /* Test each valid way of initializing the object, except for `= {0}`, as
3312
+ * Clang 5 complains when `-Wmissing-field-initializers` is used, even
3313
+ * though it's OK by the C standard. We could test for this, but we'd need
3314
+ * to supress the Clang warning for the test. */
3315
+ psa_crypto_generator_t func = psa_crypto_generator_init( );
3316
+ psa_crypto_generator_t init = PSA_CRYPTO_GENERATOR_INIT;
3317
+ psa_crypto_generator_t zero;
3318
+
3319
+ memset( &zero, 0, sizeof( zero ) );
3320
+
3321
+ /* Although not technically guaranteed by the C standard nor the PSA Crypto
3322
+ * specification, we test that all valid ways of initializing the object
3323
+ * have the same bit pattern. This is a stronger requirement that may not
3324
+ * be valid on all platforms or PSA Crypto implementations, but implies the
3325
+ * weaker actual requirement is met: that a freshly initialized object, no
3326
+ * matter how it was initialized, acts the same as any other valid
3327
+ * initialization. */
3328
+ TEST_EQUAL( memcmp( &func, &zero, sizeof( zero ) ), 0 );
3329
+ TEST_EQUAL( memcmp( &init, &zero, sizeof( zero ) ), 0 );
3330
+ }
3331
+ /* END_CASE */
3332
+
3308
3333
/* BEGIN_CASE */
3309
3334
void derive_setup( int key_type_arg,
3310
3335
data_t *key_data,
0 commit comments