From 5a5dc77696cb390d7aaab540d784a3f20e1cd412 Mon Sep 17 00:00:00 2001 From: Jaeden Amero Date: Fri, 4 Jan 2019 15:33:37 +0000 Subject: [PATCH] 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. --- include/psa/crypto_struct.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/psa/crypto_struct.h b/include/psa/crypto_struct.h index efc30b804..5eb262405 100644 --- a/include/psa/crypto_struct.h +++ b/include/psa/crypto_struct.h @@ -140,6 +140,7 @@ struct psa_cipher_operation_s uint8_t block_size; union { + unsigned dummy; /* Enable easier initializing of the union. */ mbedtls_cipher_context_t cipher; } ctx; };