From be2b4663760147e0d1c878b721295b2b79f2f167 Mon Sep 17 00:00:00 2001 From: Chris van Marle Date: Fri, 12 Oct 2018 13:05:32 +0200 Subject: [PATCH 1/2] Use toggleString for Key in HMAC #263 --- src/core/operations/HMAC.mjs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/operations/HMAC.mjs b/src/core/operations/HMAC.mjs index c825f5ff..6fdc4fed 100644 --- a/src/core/operations/HMAC.mjs +++ b/src/core/operations/HMAC.mjs @@ -28,8 +28,9 @@ class HMAC extends Operation { this.args = [ { "name": "Key", - "type": "binaryString", - "value": "" + "type": "toggleString", + "value": "", + "toggleValues": ["Hex", "Decimal", "Base64", "UTF8", "Latin1"] }, { "name": "Hashing function", @@ -66,7 +67,7 @@ class HMAC extends Operation { * @returns {string} */ run(input, args) { - const key = args[0], + const key = Utils.convertToByteString(args[0].string || "", args[0].option), hashFunc = args[1].toLowerCase(), msg = Utils.arrayBufferToStr(input, false), hasher = CryptoApi.getHasher(hashFunc); From b76aa1614365767eb423c925ef6154947ab198fb Mon Sep 17 00:00:00 2001 From: Chris van Marle Date: Fri, 12 Oct 2018 13:41:37 +0200 Subject: [PATCH 2/2] Fix Hash test --- test/tests/operations/Hash.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tests/operations/Hash.mjs b/test/tests/operations/Hash.mjs index 7105945c..8e774329 100644 --- a/test/tests/operations/Hash.mjs +++ b/test/tests/operations/Hash.mjs @@ -411,7 +411,7 @@ TestRegister.addTests([ recipeConfig: [ { "op": "HMAC", - "args": ["test", "SHA256"] + "args": [{"option": "Latin1", "string": "test"}, "SHA256"] } ] },