Skip to content

Commit 63c98a7

Browse files
committed
psa: Enable easier initialization of cipher operations
The struct psa_cipher_operation_s is built with a mbedtls_cipher_context_t. The shape of mbedtls_cipher_context_t and an initializer that works with Clang 5.0 and its -Wmissing-field-initializers varies based on the configuration of the library. Instead of making multiple initializers based on a maze of ifdefs for all combinations of MBEDTLS_CIPHER_MODE_WITH_PADDING, MBEDTLS_CMAC_C, and MBEDTLS_USE_PSA_CRYPTO, add a dummy variable to psa_cipher_operation_s's union that encloses mbedtls_cipher_context_t. This allows us to initialize the dummy with a Clang-approved initializer and have it properly initialize the entire object.
1 parent 83912be commit 63c98a7

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

include/psa/crypto_struct.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ struct psa_cipher_operation_s
140140
uint8_t block_size;
141141
union
142142
{
143+
unsigned dummy; /* Enable easier initializing of the union. */
143144
mbedtls_cipher_context_t cipher;
144145
} ctx;
145146
};

0 commit comments

Comments
 (0)