From a1b92dc8091acf2e11f1b0c55b038fecea2889b8 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Sat, 12 Nov 2016 11:17:35 +1000 Subject: [PATCH] Tidy up CPU Id check not not reference SHA384 --- wolfcrypt/src/sha512.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/wolfcrypt/src/sha512.c b/wolfcrypt/src/sha512.c index 226482e16..95d8cdb30 100644 --- a/wolfcrypt/src/sha512.c +++ b/wolfcrypt/src/sha512.c @@ -231,17 +231,15 @@ static word32 cpuid_flag(word32 leaf, word32 sub, word32 num, word32 bit) { return 0 ; } -#define CHECK_SHA512 0x1 -#define CHECK_SHA384 0x2 -static int set_cpuid_flags(int sha) { - if((cpuid_check & sha) ==0) { +static int set_cpuid_flags() { + if(cpuid_check ==0) { if(cpuid_flag(1, 0, ECX, 28)){ cpuid_flags |= CPUID_AVX1 ;} if(cpuid_flag(7, 0, EBX, 5)){ cpuid_flags |= CPUID_AVX2 ; } if(cpuid_flag(7, 0, EBX, 8)) { cpuid_flags |= CPUID_BMI2 ; } if(cpuid_flag(1, 0, ECX, 30)){ cpuid_flags |= CPUID_RDRAND ; } if(cpuid_flag(7, 0, EBX, 18)){ cpuid_flags |= CPUID_RDSEED ; } - cpuid_check |= sha ; + cpuid_check = 1 ; return 0 ; } return 1 ; @@ -270,7 +268,7 @@ static int (*Transform_p)(Sha512* sha512) = _Transform ; #define Transform(sha512) (*Transform_p)(sha512) static void set_Transform(void) { - if(set_cpuid_flags(CHECK_SHA512)) return ; + if(set_cpuid_flags()) return ; #if defined(HAVE_INTEL_AVX2) if(IS_INTEL_AVX2 && IS_INTEL_BMI2){