mirror of
https://github.com/gchq/CyberChef
synced 2024-12-26 04:23:10 +00:00
Merge branch 'feature-key-derivation-hashers'
This commit is contained in:
commit
53d89af459
2 changed files with 33 additions and 8 deletions
|
@ -1401,6 +1401,11 @@ const OperationConfig = {
|
||||||
type: "number",
|
type: "number",
|
||||||
value: Cipher.KDF_ITERATIONS
|
value: Cipher.KDF_ITERATIONS
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Hashing function",
|
||||||
|
type: "option",
|
||||||
|
value: Cipher.HASHERS
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "Salt (hex)",
|
name: "Salt (hex)",
|
||||||
type: "string",
|
type: "string",
|
||||||
|
@ -1434,6 +1439,11 @@ const OperationConfig = {
|
||||||
type: "number",
|
type: "number",
|
||||||
value: Cipher.KDF_ITERATIONS
|
value: Cipher.KDF_ITERATIONS
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Hashing function",
|
||||||
|
type: "option",
|
||||||
|
value: Cipher.HASHERS
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "Salt (hex)",
|
name: "Salt (hex)",
|
||||||
type: "string",
|
type: "string",
|
||||||
|
|
|
@ -309,6 +309,11 @@ const Cipher = {
|
||||||
* @default
|
* @default
|
||||||
*/
|
*/
|
||||||
KDF_ITERATIONS: 1,
|
KDF_ITERATIONS: 1,
|
||||||
|
/**
|
||||||
|
* @constant
|
||||||
|
* @default
|
||||||
|
*/
|
||||||
|
HASHERS: ["MD5", "SHA1", "SHA224", "SHA256", "SHA384", "SHA512", "SHA3", "RIPEMD160"],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Derive PBKDF2 key operation.
|
* Derive PBKDF2 key operation.
|
||||||
|
@ -320,11 +325,16 @@ const Cipher = {
|
||||||
runPbkdf2: function (input, args) {
|
runPbkdf2: function (input, args) {
|
||||||
let keySize = args[0] / 32,
|
let keySize = args[0] / 32,
|
||||||
iterations = args[1],
|
iterations = args[1],
|
||||||
salt = CryptoJS.enc.Hex.parse(args[2] || ""),
|
hasher = args[2],
|
||||||
inputFormat = args[3],
|
salt = CryptoJS.enc.Hex.parse(args[3] || ""),
|
||||||
outputFormat = args[4],
|
inputFormat = args[4],
|
||||||
|
outputFormat = args[5],
|
||||||
passphrase = Utils.format[inputFormat].parse(input),
|
passphrase = Utils.format[inputFormat].parse(input),
|
||||||
key = CryptoJS.PBKDF2(passphrase, salt, { keySize: keySize, iterations: iterations });
|
key = CryptoJS.PBKDF2(passphrase, salt, {
|
||||||
|
keySize: keySize,
|
||||||
|
hasher: CryptoJS.algo[hasher],
|
||||||
|
iterations: iterations,
|
||||||
|
});
|
||||||
|
|
||||||
return key.toString(Utils.format[outputFormat]);
|
return key.toString(Utils.format[outputFormat]);
|
||||||
},
|
},
|
||||||
|
@ -340,11 +350,16 @@ const Cipher = {
|
||||||
runEvpkdf: function (input, args) {
|
runEvpkdf: function (input, args) {
|
||||||
let keySize = args[0] / 32,
|
let keySize = args[0] / 32,
|
||||||
iterations = args[1],
|
iterations = args[1],
|
||||||
salt = CryptoJS.enc.Hex.parse(args[2] || ""),
|
hasher = args[2],
|
||||||
inputFormat = args[3],
|
salt = CryptoJS.enc.Hex.parse(args[3] || ""),
|
||||||
outputFormat = args[4],
|
inputFormat = args[4],
|
||||||
|
outputFormat = args[5],
|
||||||
passphrase = Utils.format[inputFormat].parse(input),
|
passphrase = Utils.format[inputFormat].parse(input),
|
||||||
key = CryptoJS.EvpKDF(passphrase, salt, { keySize: keySize, iterations: iterations });
|
key = CryptoJS.EvpKDF(passphrase, salt, {
|
||||||
|
keySize: keySize,
|
||||||
|
hasher: CryptoJS.algo[hasher],
|
||||||
|
iterations: iterations,
|
||||||
|
});
|
||||||
|
|
||||||
return key.toString(Utils.format[outputFormat]);
|
return key.toString(Utils.format[outputFormat]);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue