From 058e0b99631b4279a9f939c2773ee10beb197c73 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 22 Mar 2018 16:20:19 +0100 Subject: [PATCH] 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. --- include/psa/crypto_struct.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/psa/crypto_struct.h b/include/psa/crypto_struct.h index c0a673860..898784013 100644 --- a/include/psa/crypto_struct.h +++ b/include/psa/crypto_struct.h @@ -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; };