From 559404137e8bcb2bcad712b786f585d9299b2579 Mon Sep 17 00:00:00 2001 From: Takashi Kojo Date: Wed, 27 May 2015 18:37:19 +0900 Subject: [PATCH] moving xxxGetHash to hash.c --- wolfcrypt/benchmark/benchmark.c | 3 +- wolfcrypt/src/hash.c | 66 +++++++++++++++++++++++++++++++++ wolfcrypt/src/md5.c | 6 --- wolfcrypt/src/sha.c | 9 ----- wolfcrypt/src/sha256.c | 9 ----- 5 files changed, 67 insertions(+), 26 deletions(-) create mode 100644 wolfcrypt/src/hash.c diff --git a/wolfcrypt/benchmark/benchmark.c b/wolfcrypt/benchmark/benchmark.c index bd5fd27f5..838a80e34 100644 --- a/wolfcrypt/benchmark/benchmark.c +++ b/wolfcrypt/benchmark/benchmark.c @@ -1846,9 +1846,8 @@ void bench_ed25519KeySign(void) return ( ns / CLOCK * 2.0); } -#elif defined(WOLFSSL_IAR_ARM_TIME) || defined (WOLFSSL_MDK_ARM) +#elif defined(WOLFSSL_IAR_ARM_TIME) || defined (WOLFSSL_MDK_ARM) || defined(WOLFSSL_USER_TIME) extern double current_time(int reset); - #elif defined FREERTOS diff --git a/wolfcrypt/src/hash.c b/wolfcrypt/src/hash.c new file mode 100644 index 000000000..7a6e51f3b --- /dev/null +++ b/wolfcrypt/src/hash.c @@ -0,0 +1,66 @@ +/* hash.c + * + * Copyright (C) 2006-2015 wolfSSL Inc. + * + * This file is part of wolfSSL. (formerly known as CyaSSL) + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifdef HAVE_CONFIG_H + #include +#endif + +#include + +#if !defined(NO_MD5) && !defined(WOLFSSL_TI_HASH) + +#include +void wc_Md5GetHash(Md5* md5, byte* hash) +{ + Md5 save = *md5 ; + wc_Md5Final(md5, hash) ; + *md5 = save ; +} +#endif + +#if !defined(NO_SHA) && !defined(WOLFSSL_TI_HASH) + +#include + +int wc_ShaGetHash(Sha* sha, byte* hash) +{ + int ret ; + Sha save = *sha ; + ret = wc_ShaFinal(sha, hash) ; + *sha = save ; + return ret ; +} +#endif + +#if !defined(NO_SHA256) && !defined(WOLFSSL_TI_HASH) + +#include + +int wc_Sha256GetHash(Sha256* sha256, byte* hash) +{ + int ret ; + Sha256 save = *sha256 ; + ret = wc_Sha256Final(sha256, hash) ; + *sha256 = save ; + return ret ; +} + +#endif diff --git a/wolfcrypt/src/md5.c b/wolfcrypt/src/md5.c index d5bb17b63..db1e21f87 100644 --- a/wolfcrypt/src/md5.c +++ b/wolfcrypt/src/md5.c @@ -392,10 +392,4 @@ int wc_Md5Hash(const byte* data, word32 len, byte* hash) return 0; } -void wc_Md5GetHash(Md5* md5, byte* hash) -{ - Md5 save = *md5 ; - wc_Md5Final(md5, hash) ; - *md5 = save ; -} #endif /* NO_MD5 */ diff --git a/wolfcrypt/src/sha.c b/wolfcrypt/src/sha.c index 78f2640f0..f67f88ddc 100644 --- a/wolfcrypt/src/sha.c +++ b/wolfcrypt/src/sha.c @@ -452,15 +452,6 @@ int wc_ShaHash(const byte* data, word32 len, byte* hash) } -int wc_ShaGetHash(Sha* sha, byte* hash) -{ - int ret ; - Sha save = *sha ; - ret = wc_ShaFinal(sha, hash) ; - *sha = save ; - return ret ; -} - #endif /* HAVE_FIPS */ #endif /* NO_SHA */ diff --git a/wolfcrypt/src/sha256.c b/wolfcrypt/src/sha256.c index a204637f4..7342d836f 100644 --- a/wolfcrypt/src/sha256.c +++ b/wolfcrypt/src/sha256.c @@ -576,15 +576,6 @@ int wc_Sha256Hash(const byte* data, word32 len, byte* hash) return ret; } -int wc_Sha256GetHash(Sha256* sha256, byte* hash) -{ - int ret ; - Sha256 save = *sha256 ; - ret = wc_Sha256Final(sha256, hash) ; - *sha256 = save ; - return ret ; -} - #if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2) #define _DigestToReg(S_0, S_1, S_2, S_3, S_4, S_5, S_6, S_7 )\