From 9eabf16ed8681d293c295b5bf439cc861d00c739 Mon Sep 17 00:00:00 2001 From: Chris Conlon Date: Wed, 1 Dec 2021 10:42:31 -0700 Subject: [PATCH] fix redefinition of OS_Seed error with FIPS Ready on some compilers --- wolfssl/wolfcrypt/asn_public.h | 2 +- wolfssl/wolfcrypt/random.h | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/wolfssl/wolfcrypt/asn_public.h b/wolfssl/wolfcrypt/asn_public.h index bc7f85ca4..b1129b858 100644 --- a/wolfssl/wolfcrypt/asn_public.h +++ b/wolfssl/wolfcrypt/asn_public.h @@ -64,9 +64,9 @@ This library defines the interface APIs for X509 certificates. #define WC_RSAKEY_TYPE_DEFINED #endif #ifndef WC_RNG_TYPE_DEFINED + typedef struct OS_Seed OS_Seed; typedef struct WC_RNG WC_RNG; #ifdef WC_RNG_SEED_CB - typedef struct OS_Seed OS_Seed; typedef int (*wc_RngSeed_Cb)(OS_Seed* os, byte* seed, word32 sz); #endif #define WC_RNG_TYPE_DEFINED diff --git a/wolfssl/wolfcrypt/random.h b/wolfssl/wolfcrypt/random.h index 49bd60fb0..2c5d20746 100644 --- a/wolfssl/wolfcrypt/random.h +++ b/wolfssl/wolfcrypt/random.h @@ -130,9 +130,17 @@ #endif #endif +#ifndef WC_RNG_TYPE_DEFINED /* guard on redeclaration */ + typedef struct OS_Seed OS_Seed; + typedef struct WC_RNG WC_RNG; + #ifdef WC_RNG_SEED_CB + typedef int (*wc_RngSeed_Cb)(OS_Seed* os, byte* seed, word32 sz); + #endif + #define WC_RNG_TYPE_DEFINED +#endif /* OS specific seeder */ -typedef struct OS_Seed { +struct OS_Seed { #if defined(USE_WINDOWS_API) ProviderHandle handle; #else @@ -141,13 +149,7 @@ typedef struct OS_Seed { #if defined(WOLF_CRYPTO_CB) int devId; #endif -} OS_Seed; - - -#ifndef WC_RNG_TYPE_DEFINED /* guard on redeclaration */ - typedef struct WC_RNG WC_RNG; - #define WC_RNG_TYPE_DEFINED -#endif +}; #ifdef HAVE_HASHDRBG struct DRBG_internal { @@ -168,7 +170,7 @@ struct DRBG_internal { /* RNG context */ struct WC_RNG { - OS_Seed seed; + struct OS_Seed seed; void* heap; #ifdef HAVE_HASHDRBG /* Hash-based Deterministic Random Bit Generator */ @@ -234,7 +236,6 @@ WOLFSSL_API int wc_FreeRng(WC_RNG*); #endif #ifdef WC_RNG_SEED_CB - typedef int (*wc_RngSeed_Cb)(OS_Seed* os, byte* seed, word32 sz); WOLFSSL_API int wc_SetSeed_Cb(wc_RngSeed_Cb cb); #endif