diff --git a/wolfssl/wolfcrypt/cryptocb.h b/wolfssl/wolfcrypt/cryptocb.h index 7b1753381..f5a081f9a 100644 --- a/wolfssl/wolfcrypt/cryptocb.h +++ b/wolfssl/wolfcrypt/cryptocb.h @@ -75,10 +75,15 @@ /* Crypto Information Structure for callbacks */ typedef struct wc_CryptoInfo { int algo_type; /* enum wc_AlgoType */ +#if HAVE_ANONYMOUS_INLINE_AGGREGATES + union { +#endif #if !defined(NO_RSA) || defined(HAVE_ECC) struct { int type; /* enum wc_PkType */ +#if HAVE_ANONYMOUS_INLINE_AGGREGATES union { +#endif #ifndef NO_RSA struct { const byte* in; @@ -182,14 +187,18 @@ typedef struct wc_CryptoInfo { byte contextLen; } ed25519verify; #endif +#if HAVE_ANONYMOUS_INLINE_AGGREGATES }; +#endif } pk; #endif /* !NO_RSA || HAVE_ECC */ #if !defined(NO_AES) || !defined(NO_DES3) struct { int type; /* enum wc_CipherType */ int enc; +#if HAVE_ANONYMOUS_INLINE_AGGREGATES union { +#endif #ifdef HAVE_AESGCM struct { Aes* aes; @@ -232,7 +241,9 @@ typedef struct wc_CryptoInfo { word32 sz; } des3; #endif +#if HAVE_ANONYMOUS_INLINE_AGGREGATES }; +#endif } cipher; #endif /* !NO_AES || !NO_DES3 */ #if !defined(NO_SHA) || !defined(NO_SHA256) || \ @@ -242,7 +253,9 @@ typedef struct wc_CryptoInfo { const byte* in; word32 inSz; byte* digest; +#if HAVE_ANONYMOUS_INLINE_AGGREGATES union { +#endif #ifndef NO_SHA wc_Sha* sha1; #endif @@ -255,7 +268,9 @@ typedef struct wc_CryptoInfo { #ifdef WOLFSSL_SHA512 wc_Sha512* sha512; #endif +#if HAVE_ANONYMOUS_INLINE_AGGREGATES }; +#endif } hash; #endif /* !NO_SHA || !NO_SHA256 */ #ifndef NO_HMAC @@ -292,6 +307,9 @@ typedef struct wc_CryptoInfo { int type; } cmac; #endif +#if HAVE_ANONYMOUS_INLINE_AGGREGATES + }; +#endif } wc_CryptoInfo; diff --git a/wolfssl/wolfcrypt/types.h b/wolfssl/wolfcrypt/types.h index 7bc885194..8981619fa 100644 --- a/wolfssl/wolfcrypt/types.h +++ b/wolfssl/wolfcrypt/types.h @@ -95,6 +95,17 @@ decouple library dependencies with standard string, memory and so on. typedef const char* const wcchar; #endif + #ifndef HAVE_ANONYMOUS_INLINE_AGGREGATES + /* if __STDC__, pivot on the version, otherwise guess it's allowed, + * subject to override. + */ + #if !defined(__STDC__) \ + || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201101L)) + #define HAVE_ANONYMOUS_INLINE_AGGREGATES 1 + #else + #define HAVE_ANONYMOUS_INLINE_AGGREGATES 0 + #endif + #endif /* try to set SIZEOF_LONG or SIZEOF_LONG_LONG if user didn't */ #if defined(_MSC_VER) || defined(HAVE_LIMITS_H) diff --git a/wolfssl/wolfcrypt/wc_port.h b/wolfssl/wolfcrypt/wc_port.h index ca71bf7d9..b94429281 100644 --- a/wolfssl/wolfcrypt/wc_port.h +++ b/wolfssl/wolfcrypt/wc_port.h @@ -130,6 +130,11 @@ _Pragma("GCC diagnostic pop"); + /* the kernel uses -std=c89, but not -pedantic, and makes full use of anon + * structs/unions, so we should too. + */ + #define HAVE_ANONYMOUS_INLINE_AGGREGATES 1 + /* Linux headers define these using C expressions, but we need * them to be evaluable by the preprocessor, for use in sp_int.h. */