From 5598580b1bc3b31c1f26dd6995ae12d2f027bb23 Mon Sep 17 00:00:00 2001 From: Hayden Roche Date: Mon, 12 Jul 2021 15:25:37 -0700 Subject: [PATCH] Modify hashes.py to use correct hash type values when FIPS is enabled. --- src/wolfcrypt/hashes.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/wolfcrypt/hashes.py b/src/wolfcrypt/hashes.py index 8cd8c62..be94317 100644 --- a/src/wolfcrypt/hashes.py +++ b/src/wolfcrypt/hashes.py @@ -260,10 +260,17 @@ if _lib.SHA3_ENABLED: # Hmac types -_TYPE_SHA = 4 -_TYPE_SHA256 = 6 -_TYPE_SHA384 = 7 -_TYPE_SHA512 = 8 +if _lib.FIPS_ENABLED: + _TYPE_SHA = 1 + _TYPE_SHA256 = 2 + _TYPE_SHA384 = 5 + _TYPE_SHA512 = 4 +else: + _TYPE_SHA = 4 + _TYPE_SHA256 = 6 + _TYPE_SHA384 = 7 + _TYPE_SHA512 = 8 + _HMAC_TYPES = [_TYPE_SHA, _TYPE_SHA256, _TYPE_SHA384, _TYPE_SHA512]