From 5bf880665586a580d7adaec25780f85489f99a43 Mon Sep 17 00:00:00 2001 From: Chris Conlon Date: Thu, 1 Sep 2016 15:05:27 -0600 Subject: [PATCH] add wc_Sha384/512GetHash() functions --- wolfcrypt/src/hash.c | 30 ++++++++++++++++++++++++++++++ wolfssl/wolfcrypt/hash.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/wolfcrypt/src/hash.c b/wolfcrypt/src/hash.c index 28d04e76b..7cda03024 100644 --- a/wolfcrypt/src/hash.c +++ b/wolfcrypt/src/hash.c @@ -324,6 +324,21 @@ int wc_Sha256Hash(const byte* data, word32 len, byte* hash) #endif /* !defined(WOLFSSL_TI_HASH) */ #if defined(WOLFSSL_SHA512) +int wc_Sha512GetHash(Sha512* sha512, byte* hash) +{ + int ret; + Sha512 save; + + if (sha512 == NULL || hash == NULL) + return BAD_FUNC_ARG; + + save= *sha512; + ret = wc_Sha512Final(sha512, hash); + *sha512 = save; + + return ret; +} + int wc_Sha512Hash(const byte* data, word32 len, byte* hash) { int ret = 0; @@ -357,6 +372,21 @@ int wc_Sha512Hash(const byte* data, word32 len, byte* hash) } #if defined(WOLFSSL_SHA384) +int wc_Sha384GetHash(Sha384* sha384, byte* hash) +{ + int ret; + Sha384 save; + + if (sha384 == NULL || hash == NULL) + return BAD_FUNC_ARG; + + save= *sha384; + ret = wc_Sha384Final(sha384, hash); + *sha384 = save; + + return ret; +} + int wc_Sha384Hash(const byte* data, word32 len, byte* hash) { int ret = 0; diff --git a/wolfssl/wolfcrypt/hash.h b/wolfssl/wolfcrypt/hash.h index a2d2eca92..1296c56f5 100644 --- a/wolfssl/wolfcrypt/hash.h +++ b/wolfssl/wolfcrypt/hash.h @@ -105,10 +105,12 @@ WOLFSSL_API int wc_Sha256Hash(const byte*, word32, byte*); #ifdef WOLFSSL_SHA512 #include +WOLFSSL_API int wc_Sha512GetHash(Sha512*, byte*); WOLFSSL_API int wc_Sha512Hash(const byte*, word32, byte*); #define wc_Sha512Free(d) #if defined(WOLFSSL_SHA384) + WOLFSSL_API int wc_Sha384GetHash(Sha384*, byte*); WOLFSSL_API int wc_Sha384Hash(const byte*, word32, byte*); #define wc_Sha384Free(d) #endif /* defined(WOLFSSL_SHA384) */