Merge branch 'qistoph-HmacToggleStr'

feature-extract-files
n1474335 2018-11-07 14:21:18 +00:00
commit 5eb7e00eac
2 changed files with 5 additions and 4 deletions

View File

@ -28,8 +28,9 @@ class HMAC extends Operation {
this.args = [ this.args = [
{ {
"name": "Key", "name": "Key",
"type": "binaryString", "type": "toggleString",
"value": "" "value": "",
"toggleValues": ["Hex", "Decimal", "Base64", "UTF8", "Latin1"]
}, },
{ {
"name": "Hashing function", "name": "Hashing function",
@ -66,7 +67,7 @@ class HMAC extends Operation {
* @returns {string} * @returns {string}
*/ */
run(input, args) { run(input, args) {
const key = args[0], const key = Utils.convertToByteString(args[0].string || "", args[0].option),
hashFunc = args[1].toLowerCase(), hashFunc = args[1].toLowerCase(),
msg = Utils.arrayBufferToStr(input, false), msg = Utils.arrayBufferToStr(input, false),
hasher = CryptoApi.getHasher(hashFunc); hasher = CryptoApi.getHasher(hashFunc);

View File

@ -411,7 +411,7 @@ TestRegister.addTests([
recipeConfig: [ recipeConfig: [
{ {
"op": "HMAC", "op": "HMAC",
"args": ["test", "SHA256"] "args": [{"option": "Latin1", "string": "test"}, "SHA256"]
} }
] ]
}, },