mirror of
https://github.com/gchq/CyberChef
synced 2025-01-09 11:08:47 +00:00
Added support for hashing version 1994 and 2012. Added S-Box selection for 1994 version. Added length selection
This commit is contained in:
parent
aef65620da
commit
37389a62c1
6 changed files with 78 additions and 33 deletions
|
@ -26,7 +26,36 @@ class Streebog extends Operation {
|
||||||
this.infoURL = "https://en.wikipedia.org/wiki/Streebog";
|
this.infoURL = "https://en.wikipedia.org/wiki/Streebog";
|
||||||
this.inputType = "string";
|
this.inputType = "string";
|
||||||
this.outputType = "string";
|
this.outputType = "string";
|
||||||
this.args = [];
|
this.args = [
|
||||||
|
{
|
||||||
|
"name": "Version",
|
||||||
|
"type": "option",
|
||||||
|
"value": ["2012", "1994"]
|
||||||
|
},
|
||||||
|
// Paramset sBox for GOST 28147-89. Used only if version = 1994
|
||||||
|
{
|
||||||
|
"name": "S-Box",
|
||||||
|
"type": "option",
|
||||||
|
"value": [
|
||||||
|
"D-A",
|
||||||
|
"D-SC",
|
||||||
|
"E-TEST",
|
||||||
|
"E-A",
|
||||||
|
"E-B",
|
||||||
|
"E-C",
|
||||||
|
"E-D",
|
||||||
|
"E-SC",
|
||||||
|
"E-Z",
|
||||||
|
"D-TEST"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
// 512 bits digest, valid only for algorithm "Streebog"
|
||||||
|
{
|
||||||
|
"name": "Length",
|
||||||
|
"type": "option",
|
||||||
|
"value": ["256", "512"]
|
||||||
|
}
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,16 +65,29 @@ class Streebog extends Operation {
|
||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
try {
|
try {
|
||||||
const gostDigest = new GostDigest({name: 'GOST R 34.11', version: 1994});
|
const version = parseInt(args[0], 10);
|
||||||
|
let sBox = args[1];
|
||||||
|
let length = parseInt(args[2], 10);
|
||||||
|
|
||||||
|
// 1994 old-style 256 bits digest based on GOST 28147-89
|
||||||
|
if (version === 1994) {
|
||||||
|
length = 256;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (version === 2012) {
|
||||||
|
sBox = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
const gostDigest = new GostDigest({name: "GOST R 34.11", version, sBox, length });
|
||||||
const gostCoding = new GostCoding();
|
const gostCoding = new GostCoding();
|
||||||
|
|
||||||
const decode = gostCoding.Chars.decode(input, 'utf8');
|
|
||||||
let hexEncode = gostCoding.Hex.encode(gostDigest.digest(decode))
|
const decode = gostCoding.Chars.decode(input);
|
||||||
|
const hexEncode = gostCoding.Hex.encode(gostDigest.digest(decode));
|
||||||
return hexEncode.replace(/[^\-A-Fa-f0-9]/g, '').toLowerCase();;
|
|
||||||
|
return hexEncode.replace(/[^\-A-Fa-f0-9]/g, "").toLowerCase();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err)
|
throw new OperationError(`Invalid Input, Details ${err.message}`);
|
||||||
throw new OperationError("Test");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
8
src/core/vendor/streebog/gostCipher.js
vendored
8
src/core/vendor/streebog/gostCipher.js
vendored
|
@ -1,7 +1,9 @@
|
||||||
/**
|
/**
|
||||||
* @file GOST 28147-89/GOST R 34.12-2015/GOST R 32.13-2015 Encryption Algorithm
|
* GOST 28147-89/GOST R 34.12-2015/GOST R 32.13-2015 Encryption Algorithm
|
||||||
* @version 1.76
|
* 1.76
|
||||||
* @copyright 2014-2016, Rudolf Nickolaev. All rights reserved.
|
* 2014-2016, Rudolf Nickolaev. All rights reserved.
|
||||||
|
*
|
||||||
|
* Exported for CyberChef by mshwed [m@ttshwed.com]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
12
src/core/vendor/streebog/gostCoding.js
vendored
12
src/core/vendor/streebog/gostCoding.js
vendored
|
@ -1,7 +1,9 @@
|
||||||
/**
|
/**
|
||||||
* @file Coding algorithms: Base64, Hex, Int16, Chars, BER and PEM
|
* Coding algorithms: Base64, Hex, Int16, Chars, BER and PEM
|
||||||
* @version 1.76
|
* version 1.76
|
||||||
* @copyright 2014-2016, Rudolf Nickolaev. All rights reserved.
|
* 2014-2016, Rudolf Nickolaev. All rights reserved.
|
||||||
|
*
|
||||||
|
* Exported for CyberChef by mshwed [m@ttshwed.com]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -36,9 +38,7 @@
|
||||||
* Module imports and exports
|
* Module imports and exports
|
||||||
*
|
*
|
||||||
*/ // <editor-fold defaultstate="collapsed">
|
*/ // <editor-fold defaultstate="collapsed">
|
||||||
if (typeof exports === 'object') {
|
module.exports = factory(require('./gostCrypto'));
|
||||||
module.exports = factory(require('./gostCrypto'));
|
|
||||||
}
|
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
|
|
||||||
}(this, function (gostCrypto) {
|
}(this, function (gostCrypto) {
|
||||||
|
|
9
src/core/vendor/streebog/gostCrypto.js
vendored
9
src/core/vendor/streebog/gostCrypto.js
vendored
|
@ -1,7 +1,9 @@
|
||||||
/**
|
/**
|
||||||
* @file Implementation Web Crypto interfaces for GOST algorithms
|
* Implementation Web Crypto interfaces for GOST algorithms
|
||||||
* @version 1.76
|
* 1.76
|
||||||
* @copyright 2014-2016, Rudolf Nickolaev. All rights reserved.
|
* 2014-2016, Rudolf Nickolaev. All rights reserved.
|
||||||
|
*
|
||||||
|
* Exported for CyberChef by mshwed [m@ttshwed.com]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -37,7 +39,6 @@
|
||||||
*
|
*
|
||||||
*/ // <editor-fold defaultstate="collapsed">
|
*/ // <editor-fold defaultstate="collapsed">
|
||||||
module.exports = factory(require('./gostRandom'));
|
module.exports = factory(require('./gostRandom'));
|
||||||
|
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
|
|
||||||
}(this, function (GostRandom) {
|
}(this, function (GostRandom) {
|
||||||
|
|
12
src/core/vendor/streebog/gostDigest.js
vendored
12
src/core/vendor/streebog/gostDigest.js
vendored
|
@ -1,7 +1,9 @@
|
||||||
/**
|
/**
|
||||||
* @file GOST R 34.11-94 / GOST R 34.11-12 implementation
|
* GOST R 34.11-94 / GOST R 34.11-12 implementation
|
||||||
* @version 1.76
|
* 1.76
|
||||||
* @copyright 2014-2016, Rudolf Nickolaev. All rights reserved.
|
* 2014-2016, Rudolf Nickolaev. All rights reserved.
|
||||||
|
*
|
||||||
|
* Exported for CyberChef by mshwed [m@ttshwed.com]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -40,9 +42,7 @@
|
||||||
* Module imports and exports
|
* Module imports and exports
|
||||||
*
|
*
|
||||||
*/ // <editor-fold defaultstate="collapsed">
|
*/ // <editor-fold defaultstate="collapsed">
|
||||||
if (typeof exports === 'object') {
|
module.exports = factory(require('./gostRandom'), require('./gostCipher'));
|
||||||
module.exports = factory(require('./gostRandom'), require('./gostCipher'));
|
|
||||||
}
|
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
|
|
||||||
}(this, function (GostRandom, GostCipher) {
|
}(this, function (GostRandom, GostCipher) {
|
||||||
|
|
12
src/core/vendor/streebog/gostRandom.js
vendored
12
src/core/vendor/streebog/gostRandom.js
vendored
|
@ -1,7 +1,9 @@
|
||||||
/**
|
/**
|
||||||
* @file Implementation Web Crypto random generatore for GOST algorithms
|
* Implementation Web Crypto random generatore for GOST algorithms
|
||||||
* @version 1.76
|
* 1.76
|
||||||
* @copyright 2014-2016, Rudolf Nickolaev. All rights reserved.
|
* 2014-2016, Rudolf Nickolaev. All rights reserved.
|
||||||
|
*
|
||||||
|
* Exported for CyberChef by mshwed [m@ttshwed.com]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -36,9 +38,7 @@
|
||||||
* Module imports and exports
|
* Module imports and exports
|
||||||
*
|
*
|
||||||
*/ // <editor-fold defaultstate="collapsed">
|
*/ // <editor-fold defaultstate="collapsed">
|
||||||
if (typeof exports === 'object') {
|
module.exports = factory();
|
||||||
module.exports = factory();
|
|
||||||
}
|
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
|
|
||||||
}(this, function () {
|
}(this, function () {
|
||||||
|
|
Loading…
Reference in a new issue