From 82aaff9e43046b30d5aa96596155099142a99e3f Mon Sep 17 00:00:00 2001 From: Takashi Kojo Date: Tue, 18 Aug 2015 11:22:51 +0900 Subject: [PATCH] Eliminate hash free in DoRound with non-TI case --- wolfcrypt/src/hash.c | 10 ---------- wolfssl/wolfcrypt/hash.h | 26 +++++++++++++++++++++++--- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/wolfcrypt/src/hash.c b/wolfcrypt/src/hash.c index 5adb06552..58fce69f8 100755 --- a/wolfcrypt/src/hash.c +++ b/wolfcrypt/src/hash.c @@ -43,8 +43,6 @@ WOLFSSL_API void wc_Md5RestorePos(Md5* m1, Md5* m2) { *m1 = *m2 ; } -WOLFSSL_API void wc_Md5Free(Md5* md5) { (void) md5 ; } - #endif #if !defined(NO_SHA) @@ -92,8 +90,6 @@ int wc_ShaHash(const byte* data, word32 len, byte* hash) } -WOLFSSL_API void wc_ShaFree(Sha* sha) { (void) sha ; } - #endif /* !defined(NO_SHA) */ #if !defined(NO_SHA256) @@ -142,8 +138,6 @@ int wc_Sha256Hash(const byte* data, word32 len, byte* hash) return ret; } -WOLFSSL_API void wc_Sha256Free(Sha256* sha256) { (void)sha256 ; } - #endif /* !defined(NO_SHA256) */ #endif /* !defined(WOLFSSL_TI_HASH) */ @@ -181,8 +175,6 @@ int wc_Sha512Hash(const byte* data, word32 len, byte* hash) return ret; } -WOLFSSL_API void wc_Sha512Free(Sha512* sha512) { (void)sha512 ; } - #if defined(WOLFSSL_SHA384) int wc_Sha384Hash(const byte* data, word32 len, byte* hash) { @@ -216,7 +208,5 @@ int wc_Sha384Hash(const byte* data, word32 len, byte* hash) return ret; } -WOLFSSL_API void wc_Sha384Free(Sha384* sha384) { (void) sha384 ; } - #endif /* defined(WOLFSSL_SHA384) */ #endif /* defined(WOLFSSL_SHA512) */ diff --git a/wolfssl/wolfcrypt/hash.h b/wolfssl/wolfcrypt/hash.h index 3b4e33af8..50e5d88be 100755 --- a/wolfssl/wolfcrypt/hash.h +++ b/wolfssl/wolfcrypt/hash.h @@ -28,7 +28,11 @@ #include WOLFSSL_API void wc_Md5GetHash(Md5*, byte*); WOLFSSL_API void wc_Md5RestorePos(Md5*, Md5*) ; -WOLFSSL_API void wc_Md5Free(Md5*); +#if defined(WOLFSSL_TI_HASH) + WOLFSSL_API void wc_Md5Free(Md5*); +#else + #define wc_Md5Free(d) +#endif #endif #ifndef NO_SHA @@ -36,7 +40,11 @@ WOLFSSL_API void wc_Md5Free(Md5*); WOLFSSL_API int wc_ShaGetHash(Sha*, byte*); WOLFSSL_API void wc_ShaRestorePos(Sha*, Sha*) ; WOLFSSL_API int wc_ShaHash(const byte*, word32, byte*); -WOLFSSL_API void wc_ShaFree(Sha*); +#if defined(WOLFSSL_TI_HASH) + WOLFSSL_API void wc_ShaFree(Sha*); +#else + #define wc_ShaFree(d) +#endif #endif #ifndef NO_SHA256 @@ -44,16 +52,28 @@ WOLFSSL_API void wc_ShaFree(Sha*); WOLFSSL_API int wc_Sha256GetHash(Sha256*, byte*); WOLFSSL_API void wc_Sha256RestorePos(Sha256*, Sha256*) ; WOLFSSL_API int wc_Sha256Hash(const byte*, word32, byte*); -WOLFSSL_API void wc_Sha256Free(Sha256*); +#if defined(WOLFSSL_TI_HASH) + WOLFSSL_API void wc_Sha256Free(Sha256*); +#else + #define wc_Sha256Free(d) +#endif #endif #ifdef WOLFSSL_SHA512 #include WOLFSSL_API int wc_Sha512Hash(const byte*, word32, byte*); +#if defined(WOLFSSL_TI_HASH) WOLFSSL_API void wc_Sha512Free(Sha512*); +#else +#define wc_Sha512Free(d) +#endif #if defined(WOLFSSL_SHA384) WOLFSSL_API int wc_Sha384Hash(const byte*, word32, byte*); + #if defined(WOLFSSL_TI_HASH) WOLFSSL_API void wc_Sha384Free(Sha384*); + #else + #define wc_Sha384Free(d) + #endif #endif /* defined(WOLFSSL_SHA384) */ #endif /* WOLFSSL_SHA512 */