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.
diff --git a/include/psa/crypto_struct.h b/include/psa/crypto_struct.h
index c0a6738..8987840 100644
--- a/include/psa/crypto_struct.h
+++ b/include/psa/crypto_struct.h
@@ -50,6 +50,7 @@
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 @@
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 @@
uint8_t block_size;
union
{
+ unsigned dummy; /* Make the union non-empty even with no supported algorithms. */
} ctx;
};
@@ -115,6 +118,7 @@
uint8_t block_size;
union
{
+ unsigned dummy; /* Make the union non-empty even with no supported algorithms. */
} ctx;
};