diff --git a/util/fipstools/acvp/acvptool/subprocess/hmac.go b/util/fipstools/acvp/acvptool/subprocess/hmac.go index 3273f3ce9..e4d5e405c 100644 --- a/util/fipstools/acvp/acvptool/subprocess/hmac.go +++ b/util/fipstools/acvp/acvptool/subprocess/hmac.go @@ -119,14 +119,14 @@ func (h *hmacPrimitive) Process(vectorSet []byte, m Transactable) (any, error) { } m.TransactAsync(h.algo, 1, [][]byte{msg, key}, func(result [][]byte) error { - if l := len(result[0]); l < outBytes { - return fmt.Errorf("HMAC result too short: %d bytes but wanted %d", l, outBytes) + if l := len(result[0]); l != outBytes { + return fmt.Errorf("incorrect HMAC length: %d bytes but wanted %d", l, outBytes) } // https://pages.nist.gov/ACVP/draft-fussell-acvp-mac.html#name-test-vectors response.Tests = append(response.Tests, hmacTestResponse{ ID: test.ID, - MACHex: hex.EncodeToString(result[0][:outBytes]), + MACHex: hex.EncodeToString(result[0]), }) return nil }) diff --git a/util/fipstools/acvp/modulewrapper/modulewrapper.cc b/util/fipstools/acvp/modulewrapper/modulewrapper.cc index 7f4d9fa0d..018aceb4b 100644 --- a/util/fipstools/acvp/modulewrapper/modulewrapper.cc +++ b/util/fipstools/acvp/modulewrapper/modulewrapper.cc @@ -442,9 +442,7 @@ static bool GetConfig(const Span args[], "keyLen": [{ "min": 8, "max": 524288, "increment": 8 }], - "macLen": [{ - "min": 32, "max": 160, "increment": 8 - }] + "macLen": [160] }, { "algorithm": "HMAC-SHA2-224", @@ -452,9 +450,7 @@ static bool GetConfig(const Span args[], "keyLen": [{ "min": 8, "max": 524288, "increment": 8 }], - "macLen": [{ - "min": 32, "max": 224, "increment": 8 - }] + "macLen": [224] }, { "algorithm": "HMAC-SHA2-256", @@ -462,9 +458,7 @@ static bool GetConfig(const Span args[], "keyLen": [{ "min": 8, "max": 524288, "increment": 8 }], - "macLen": [{ - "min": 32, "max": 256, "increment": 8 - }] + "macLen": [256] }, { "algorithm": "HMAC-SHA2-384", @@ -472,9 +466,7 @@ static bool GetConfig(const Span args[], "keyLen": [{ "min": 8, "max": 524288, "increment": 8 }], - "macLen": [{ - "min": 32, "max": 384, "increment": 8 - }] + "macLen": [384] }, { "algorithm": "HMAC-SHA2-512", @@ -482,9 +474,7 @@ static bool GetConfig(const Span args[], "keyLen": [{ "min": 8, "max": 524288, "increment": 8 }], - "macLen": [{ - "min": 32, "max": 512, "increment": 8 - }] + "macLen": [512] }, { "algorithm": "HMAC-SHA2-512/256", @@ -492,9 +482,7 @@ static bool GetConfig(const Span args[], "keyLen": [{ "min": 8, "max": 524288, "increment": 8 }], - "macLen": [{ - "min": 32, "max": 256, "increment": 8 - }] + "macLen": [256] }, { "algorithm": "ctrDRBG", @@ -848,11 +836,7 @@ static bool GetConfig(const Span args[], "increment": 8 }], "keyLen": [128, 256], - "macLen": [{ - "min": 8, - "max": 128, - "increment": 8 - }] + "macLen": [128] }] }, { @@ -1966,11 +1950,11 @@ static bool CMAC_AES(const Span args[], return false; } memcpy(&mac_len, args[0].data(), sizeof(mac_len)); - if (mac_len > sizeof(mac)) { + if (mac_len != sizeof(mac)) { return false; } - return write_reply({Span(mac, mac_len)}); + return write_reply({Span(mac, sizeof(mac))}); } static bool CMAC_AESVerify(const Span args[],