Avoid empty unions

When no algorithms are present in a category (e.g. no AEAD algorithm),
the union in the corresponding operation structure was empty, which is
not valid C. Add a dummy field to avoid this.
This commit is contained in:
Gilles Peskine 2018-03-22 16:20:19 +01:00 committed by itayzafrir
parent 9a1ba0dd3f
commit 058e0b9963

View file

@ -50,6 +50,7 @@ struct psa_hash_operation_s
psa_algorithm_t alg;
union
{
unsigned dummy; /* Make the union non-empty even with no supported algorithms. */
#if defined(MBEDTLS_MD2_C)
mbedtls_md2_context md2;
#endif
@ -84,6 +85,7 @@ struct psa_mac_operation_s
uint8_t mac_size;
union
{
unsigned dummy; /* Make the union non-empty even with no supported algorithms. */
#if defined(MBEDTLS_MD_C)
mbedtls_md_context_t hmac;
#endif
@ -102,6 +104,7 @@ struct psa_cipher_operation_s
uint8_t block_size;
union
{
unsigned dummy; /* Make the union non-empty even with no supported algorithms. */
} ctx;
};
@ -115,6 +118,7 @@ struct psa_aead_operation_s
uint8_t block_size;
union
{
unsigned dummy; /* Make the union non-empty even with no supported algorithms. */
} ctx;
};