mirror of
https://github.com/gchq/CyberChef.git
synced 2025-06-18 04:05:25 -04:00
ESM: Ported UUID, OTP, Numberwang and PHP operations
This commit is contained in:
parent
739e06d7d3
commit
eed28f67d5
6 changed files with 466 additions and 2 deletions
69
src/core/operations/GenerateHOTP.mjs
Normal file
69
src/core/operations/GenerateHOTP.mjs
Normal file
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2017
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation";
|
||||
import otp from "otp";
|
||||
import ToBase32 from "./ToBase32";
|
||||
|
||||
/**
|
||||
* Generate HOTP operation
|
||||
*/
|
||||
class GenerateHOTP extends Operation {
|
||||
|
||||
/**
|
||||
* GenerateHOTP constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Generate HOTP";
|
||||
this.module = "Default";
|
||||
this.description = "The HMAC-based One-Time Password algorithm (HOTP) is an algorithm that computes a one-time password from a shared secret key and an incrementing counter. It has been adopted as Internet Engineering Task Force standard RFC 4226, is the cornerstone of Initiative For Open Authentication (OATH), and is used in a number of two-factor authentication systems.<br><br>Enter the secret as the input or leave it blank for a random secret to be generated.";
|
||||
this.inputType = "byteArray";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
"name": "Name",
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"name": "Key size",
|
||||
"type": "number",
|
||||
"value": 32
|
||||
},
|
||||
{
|
||||
"name": "Code length",
|
||||
"type": "number",
|
||||
"value": 6
|
||||
},
|
||||
{
|
||||
"name": "Counter",
|
||||
"type": "number",
|
||||
"value": 0
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {byteArray} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const otpObj = otp({
|
||||
name: args[0],
|
||||
keySize: args[1],
|
||||
codeLength: args[2],
|
||||
secret: (new ToBase32).run(input, []),
|
||||
});
|
||||
const counter = args[3];
|
||||
return `URI: ${otpObj.hotpURL}\n\nPassword: ${otpObj.hotp(counter)}`;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default GenerateHOTP;
|
Loading…
Add table
Add a link
Reference in a new issue