From 9e2ae79c8a1f22ea687857949cd4c70ee2ac14dd Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Mon, 5 Jan 2015 16:36:24 -0700 Subject: [PATCH] include in tfm and compatability for random and sha256 --- cyassl/ctaocrypt/settings.h | 54 ++++++++++++++++++++++++++----------- wolfcrypt/src/tfm.c | 2 +- wolfssl/wolfcrypt/random.h | 1 + wolfssl/wolfcrypt/sha256.h | 7 ----- 4 files changed, 41 insertions(+), 23 deletions(-) diff --git a/cyassl/ctaocrypt/settings.h b/cyassl/ctaocrypt/settings.h index 3e690032f..0a07ac89a 100644 --- a/cyassl/ctaocrypt/settings.h +++ b/cyassl/ctaocrypt/settings.h @@ -26,6 +26,7 @@ #ifndef CTAO_CRYPT_SETTINGS_H #define CTAO_CRYPT_SETTINGS_H +/* Macro redefinitions for compatibility */ #ifdef WOLFSSL_SHA512 #define CYASSL_SHA512 WOLFSSL_SHA512 #endif @@ -38,21 +39,16 @@ * using old function calls */ #ifndef HAVE_FIPS - #ifndef NO_HMAC - #include - /* does init */ - #define HmacSetKey wc_HmacSetKey - #define HmacUpdate wc_HmacUpdate - #define HmacFinal wc_HmacFinal - #ifdef HAVE_CAVIUM - #define HmacInitCavium wc_HmacInitCavium - #define HmacFreeCavium wc_HmacFreeCavium - #endif - #define CyaSSL_GetHmacMaxSize wc_wolfSSL_GetHmacMaxSize - #ifdef HAVE_HKDF - #define HKDF wc_HKDF - #endif /* HAVE_HKDF */ - #endif /* NO_HMAC */ + /* for random.h compatibility */ + #include + #define InitRng wc_InitRng + #define RNG_GenerateBlock wc_RNG_GenerateBlock + #define RNG_GenerateByte wc_RNG_GenerateByte + + #if defined(HAVE_HASHDRBG) || defined(NO_RC4) + #define FreeRng wc_FreeRng + #define RNG_HealthTest wc_RNG_HealthTest + #endif /* HAVE_HASHDRBG || NO_RC4 */ #ifndef NO_AES #include @@ -150,6 +146,34 @@ #define Des3_FreeCavium wc_Des3_FreeCavium #endif #endif /* NO_DES3 */ + + #ifndef NO_SHA + #define InitSha wc_InitSha + #define ShaUpdate wc_ShaUpdate + #define ShaFinal wc_ShaFinal + #define ShaHash wc_ShaHash + #endif /* NO_SHA */ + + #ifndef NO_SHA256 + #define InitSha256 wc_InitSha256 + #define Sha256Update wc_Sha256Update + #define Sha256Final wc_Sha256Final + #define Sha256Hash wc_Sha256Hash + #endif /* NO_SHA256 */ + + #ifdef WOLFSSL_SHA512 + #define InitSha512 wc_InitSha512 + #define Sha512Update wc_Sha512Update + #define Sha512Final wc_Sha512Final + #define Sha512Hash wc_Sha512Hash + + #if defined(WOLFSSL_SHA384) || defined(HAVE_AESGCM) + #define InitSha384 wc_InitSha384 + #define Sha384Update wc_Sha384Update + #define Sha384Final wc_Sha384Final + #define Sha384Hash wc_Sha384Hash + #endif /* WOLFSSL_SHA384 */ + #endif /* WOLFSSL_SHA512 */ #endif /* HAVE_FIPS */ diff --git a/wolfcrypt/src/tfm.c b/wolfcrypt/src/tfm.c index ff49f15ad..4be9bac23 100644 --- a/wolfcrypt/src/tfm.c +++ b/wolfcrypt/src/tfm.c @@ -43,7 +43,7 @@ #ifdef USE_FAST_MATH #include -#include /* will define asm MACROS or C ones */ +#include /* will define asm MACROS or C ones */ /* math settings check */ diff --git a/wolfssl/wolfcrypt/random.h b/wolfssl/wolfcrypt/random.h index 117ff7983..3c1a1a199 100644 --- a/wolfssl/wolfcrypt/random.h +++ b/wolfssl/wolfcrypt/random.h @@ -35,6 +35,7 @@ #endif #ifndef HAVE_FIPS +#define CTAO_CRYPT_RANDOM_H #if defined(HAVE_HASHDRBG) || defined(NO_RC4) #ifdef NO_SHA256 #error "Hash DRBG requires SHA-256." diff --git a/wolfssl/wolfcrypt/sha256.h b/wolfssl/wolfcrypt/sha256.h index 65b3ac654..bba025b67 100644 --- a/wolfssl/wolfcrypt/sha256.h +++ b/wolfssl/wolfcrypt/sha256.h @@ -75,13 +75,6 @@ WOLFSSL_API int wc_Sha256Hash(const byte*, word32, byte*); #ifdef __cplusplus } /* extern "C" */ #endif -//#else -//#define wc_InitSha256 wc_InitSha256Sha256*); -//#define int wc_Sha256Update(Swc_Sha256Updateha256*, const byte*, word32); -//#define int wc_Sha256Final(wc_Sha256FinalSha256*, byte*); -//#define int wc_Sha256Hash(wc_Sha256Hashconst byte*, word32, byte*); -// -//#endif /* HAVE_FIPS */ #endif /* WOLF_CRYPT_SHA256_H */ #endif /* NO_SHA256 */