1
0
mirror of synced 2024-11-15 02:37:40 +01:00

Added HAS-160 and Whirlpool hashing operations

This commit is contained in:
n1474335 2017-09-20 09:43:14 +00:00
parent 83d258c396
commit d79a0e737a
6 changed files with 109 additions and 4 deletions

6
package-lock.json generated
View File

@ -1661,9 +1661,9 @@
}
},
"crypto-api": {
"version": "0.7.3",
"resolved": "https://registry.npmjs.org/crypto-api/-/crypto-api-0.7.3.tgz",
"integrity": "sha1-nHMgTE73lxYjIkOYuDS6fJ2B9uU="
"version": "0.7.4",
"resolved": "https://registry.npmjs.org/crypto-api/-/crypto-api-0.7.4.tgz",
"integrity": "sha1-wuiM1WOWxJ0A75uA40lGUKdIKoE="
},
"crypto-browserify": {
"version": "3.11.1",

View File

@ -67,7 +67,7 @@
"bootstrap": "^3.3.7",
"bootstrap-colorpicker": "^2.5.1",
"bootstrap-switch": "^3.3.4",
"crypto-api": "^0.7.3",
"crypto-api": "^0.7.4",
"crypto-js": "^3.1.9-1",
"diff": "^3.3.1",
"escodegen": "^1.9.0",

View File

@ -255,6 +255,8 @@ const Categories = [
"Keccak",
"Shake",
"RIPEMD",
"HAS-160",
"Whirlpool",
"HMAC",
"Fletcher-8 Checksum",
"Fletcher-16 Checksum",

View File

@ -2990,6 +2990,26 @@ const OperationConfig = {
}
]
},
"HAS-160": {
description: "HAS-160 is a cryptographic hash function designed for use with the Korean KCDSA digital signature algorithm. It is derived from SHA-1, with assorted changes intended to increase its security. It produces a 160-bit output.<br><br>HAS-160 is used in the same way as SHA-1. First it divides input in blocks of 512 bits each and pads the final block. A digest function updates the intermediate hash value by processing the input blocks in turn.<br><br>The message digest algorithm consists of 80 rounds.",
run: Hash.runHAS,
inputType: "string",
outputType: "string",
args: []
},
"Whirlpool": {
description: "Whirlpool is a cryptographic hash function designed by Vincent Rijmen (co-creator of AES) and Paulo S. L. M. Barreto, who first described it in 2000.<br><br>Several variants exist:<ul><li>Whirlpool-0 is the original version released in 2000.</li><li>Whirlpool-T is the first revision, released in 2001, improving the generation of the s-box.</li><li>Wirlpool is the latest revision, released in 2003, fixing a flaw in the difusion matrix.</li></ul>",
run: Hash.runWhirlpool,
inputType: "string",
outputType: "string",
args: [
{
name: "Variant",
type: "option",
value: Hash.WHIRLPOOL_VARIANT
}
]
},
"HMAC": {
description: "Keyed-Hash Message Authentication Codes (HMAC) are a mechanism for message authentication using cryptographic hash functions.",
run: Hash.runHMAC,

View File

@ -263,6 +263,37 @@ const Hash = {
},
/**
* HAS-160 operation.
*
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
runHAS: function (input, args) {
return CryptoApi.hash("has160", input, {}).stringify("hex");
},
/**
* @constant
* @default
*/
WHIRLPOOL_VARIANT: ["Whirlpool", "Whirlpool-T", "Whirlpool-0"],
/**
* Whirlpool operation.
*
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
runWhirlpool: function (input, args) {
const variant = args[0].toLowerCase();
return CryptoApi.hash(variant, input, {}).stringify("hex");
},
/**
* @constant
* @default
@ -283,6 +314,10 @@ const Hash = {
"RIPEMD160",
"RIPEMD256",
"RIPEMD320",
"HAS160",
"Whirlpool",
"Whirlpool-0",
"Whirlpool-T"
],
/**
@ -335,6 +370,10 @@ const Hash = {
"\nRIPEMD-160: " + Hash.runRIPEMD(input, ["160"]) +
"\nRIPEMD-256: " + Hash.runRIPEMD(input, ["256"]) +
"\nRIPEMD-320: " + Hash.runRIPEMD(input, ["320"]) +
"\nHAS-160: " + Hash.runHAS(input, []) +
"\nWhirlpool-0: " + Hash.runWhirlpool(input, ["Whirlpool-0"]) +
"\nWhirlpool-T: " + Hash.runWhirlpool(input, ["Whirlpool-T"]) +
"\nWhirlpool: " + Hash.runWhirlpool(input, ["Whirlpool"]) +
"\n\nChecksums:" +
"\nFletcher-8: " + Checksum.runFletcher8(byteArray, []) +
"\nFletcher-16: " + Checksum.runFletcher16(byteArray, []) +

View File

@ -294,6 +294,50 @@ TestRegister.addTests([
}
]
},
{
name: "HAS-160",
input: "Hello, World!",
expectedOutput: "8f6dd8d7c8a04b1cb3831adc358b1e4ac2ed5984",
recipeConfig: [
{
"op": "HAS-160",
"args": []
}
]
},
{
name: "Whirlpool-0",
input: "Hello, World!",
expectedOutput: "1c327026f565a0105a827efbfb3d3635cdb042c0aabb8416e96deb128e6c5c8684b13541cf31c26c1488949df050311c6999a12eb0e7002ad716350f5c7700ca",
recipeConfig: [
{
"op": "Whirlpool",
"args": ["Whirlpool-0"]
}
]
},
{
name: "Whirlpool-T",
input: "Hello, World!",
expectedOutput: "16c581089b6a6f356ae56e16a63a4c613eecd82a2a894b293f5ee45c37a31d09d7a8b60bfa7e414bd4a7166662cea882b5cf8c96b7d583fc610ad202591bcdb1",
recipeConfig: [
{
"op": "Whirlpool",
"args": ["Whirlpool-T"]
}
]
},
{
name: "Whirlpool",
input: "Hello, World!",
expectedOutput: "3d837c9ef7bb291bd1dcfc05d3004af2eeb8c631dd6a6c4ba35159b8889de4b1ec44076ce7a8f7bfa497e4d9dcb7c29337173f78d06791f3c3d9e00cc6017f0b",
recipeConfig: [
{
"op": "Whirlpool",
"args": ["Whirlpool"]
}
]
},
{
name: "HMAC SHA256",
input: "Hello, World!",