From 96af77d757b8fa29a35abe46838bb8f84d75cf83 Mon Sep 17 00:00:00 2001 From: aidan garske Date: Tue, 16 Jul 2024 11:12:29 -0700 Subject: [PATCH] Hash Type selection changes to `ecc.c`. --- wolfcrypt/src/ecc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index 4bf97bd095..6c6c7e4592 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -7536,8 +7536,9 @@ int wc_ecc_gen_deterministic_k(const byte* hash, word32 hashSz, byte *x = NULL; mp_int *z1 = NULL; #endif - word32 qbits = 0, xSz, VSz, KSz, h1len, qLen; + word32 xSz, VSz, KSz, h1len, qLen; byte intOct; + word32 qbits = 0; if (hash == NULL || k == NULL || order == NULL) { return BAD_FUNC_ARG; @@ -7550,15 +7551,18 @@ int wc_ecc_gen_deterministic_k(const byte* hash, word32 hashSz, /* if none is provided then detect has type based on hash size */ if (hashType == WC_HASH_TYPE_NONE) { - if (hashSz >= 64) { + if (hashSz == 64) { hashType = WC_HASH_TYPE_SHA512; } - else if (hashSz >= 48) { + else if (hashSz == 48) { hashType = WC_HASH_TYPE_SHA384; } - else { + else if (hashSz ==32) { hashType = WC_HASH_TYPE_SHA256; } + else { + return BAD_FUNC_ARG; + } } if (mp_unsigned_bin_size(priv) > MAX_ECC_BYTES) {