From 7403666a111f0e8e96ad51789ecf2dc3d2672658 Mon Sep 17 00:00:00 2001 From: n1474335 Date: Fri, 25 Nov 2022 16:48:54 +0000 Subject: [PATCH] Tidied up Rabbit operations --- src/core/config/Categories.json | 6 +-- .../{RabbitStreamCipher.mjs => Rabbit.mjs} | 12 ++--- tests/operations/index.mjs | 2 +- .../{RabbitStreamCipher.mjs => Rabbit.mjs} | 44 +++++++++---------- 4 files changed, 32 insertions(+), 32 deletions(-) rename src/core/operations/{RabbitStreamCipher.mjs => Rabbit.mjs} (94%) rename tests/operations/tests/{RabbitStreamCipher.mjs => Rabbit.mjs} (81%) diff --git a/src/core/config/Categories.json b/src/core/config/Categories.json index 43c23c62..307270d2 100644 --- a/src/core/config/Categories.json +++ b/src/core/config/Categories.json @@ -75,7 +75,6 @@ "AES Decrypt", "Blowfish Encrypt", "Blowfish Decrypt", - "ChaCha", "DES Encrypt", "DES Decrypt", "Triple DES Encrypt", @@ -86,6 +85,8 @@ "RC2 Decrypt", "RC4", "RC4 Drop", + "ChaCha", + "Rabbit", "SM4 Encrypt", "SM4 Decrypt", "ROT13", @@ -134,8 +135,7 @@ "Typex", "Lorenz", "Colossus", - "SIGABA", - "Rabbit Stream Cipher" + "SIGABA" ] }, { diff --git a/src/core/operations/RabbitStreamCipher.mjs b/src/core/operations/Rabbit.mjs similarity index 94% rename from src/core/operations/RabbitStreamCipher.mjs rename to src/core/operations/Rabbit.mjs index 7d030a6f..91ff24a3 100644 --- a/src/core/operations/RabbitStreamCipher.mjs +++ b/src/core/operations/Rabbit.mjs @@ -10,19 +10,19 @@ import { toHexFast } from "../lib/Hex.mjs"; import OperationError from "../errors/OperationError.mjs"; /** - * Rabbit Stream Cipher operation + * Rabbit operation */ -class RabbitStreamCipher extends Operation { +class Rabbit extends Operation { /** - * RabbitStreamCipher constructor + * Rabbit constructor */ constructor() { super(); - this.name = "Rabbit Stream Cipher"; + this.name = "Rabbit"; this.module = "Ciphers"; - this.description = "Rabbit Stream Cipher, a stream cipher algorithm defined in RFC4503.

The cipher uses a 128-bit key and an optional 64-bit initialization vector (IV).

big-endian: based on RFC4503 and RFC3447
little-endian: compatible with Crypto++"; + this.description = "Rabbit is a high-speed stream cipher introduced in 2003 and defined in RFC 4503.

The cipher uses a 128-bit key and an optional 64-bit initialization vector (IV).

big-endian: based on RFC4503 and RFC3447
little-endian: compatible with Crypto++"; this.infoURL = "https://wikipedia.org/wiki/Rabbit_(cipher)"; this.inputType = "string"; this.outputType = "string"; @@ -244,4 +244,4 @@ class RabbitStreamCipher extends Operation { } -export default RabbitStreamCipher; +export default Rabbit; diff --git a/tests/operations/index.mjs b/tests/operations/index.mjs index cb410915..7a3361f2 100644 --- a/tests/operations/index.mjs +++ b/tests/operations/index.mjs @@ -129,7 +129,7 @@ import "./tests/Shuffle.mjs"; import "./tests/FletcherChecksum.mjs"; import "./tests/CMAC.mjs"; import "./tests/AESKeyWrap.mjs"; -import "./tests/RabbitStreamCipher.mjs"; +import "./tests/Rabbit.mjs"; // Cannot test operations that use the File type yet // import "./tests/SplitColourChannels.mjs"; diff --git a/tests/operations/tests/RabbitStreamCipher.mjs b/tests/operations/tests/Rabbit.mjs similarity index 81% rename from tests/operations/tests/RabbitStreamCipher.mjs rename to tests/operations/tests/Rabbit.mjs index fd22ffbd..ca3156fa 100644 --- a/tests/operations/tests/RabbitStreamCipher.mjs +++ b/tests/operations/tests/Rabbit.mjs @@ -8,12 +8,12 @@ import TestRegister from "../../lib/TestRegister.mjs"; TestRegister.addTests([ { - name: "Rabbit Stream Cipher: RFC Test vector, without IV 1", + name: "Rabbit: RFC Test vector, without IV 1", input: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", expectedOutput: "b15754f036a5d6ecf56b45261c4af70288e8d815c59c0c397b696c4789c68aa7f416a1c3700cd451da68d1881673d696", recipeConfig: [ { - "op": "Rabbit Stream Cipher", + "op": "Rabbit", "args": [ {"option": "Hex", "string": "00000000000000000000000000000000"}, {"option": "Hex", "string": ""}, @@ -23,12 +23,12 @@ TestRegister.addTests([ ] }, { - name: "Rabbit Stream Cipher: RFC Test vector, without IV 2", + name: "Rabbit: RFC Test vector, without IV 2", input: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", expectedOutput: "3d2df3c83ef627a1e97fc38487e2519cf576cd61f4405b8896bf53aa8554fc19e5547473fbdb43508ae53b20204d4c5e", recipeConfig: [ { - "op": "Rabbit Stream Cipher", + "op": "Rabbit", "args": [ {"option": "Hex", "string": "912813292e3d36fe3bfc62f1dc51c3ac"}, {"option": "Hex", "string": ""}, @@ -38,12 +38,12 @@ TestRegister.addTests([ ] }, { - name: "Rabbit Stream Cipher: RFC Test vector, without IV 3", + name: "Rabbit: RFC Test vector, without IV 3", input: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", expectedOutput: "0cb10dcda041cdac32eb5cfd02d0609b95fc9fca0f17015a7b7092114cff3ead9649e5de8bfc7f3f924147ad3a947428", recipeConfig: [ { - "op": "Rabbit Stream Cipher", + "op": "Rabbit", "args": [ {"option": "Hex", "string": "8395741587e0c733e9e9ab01c09b0043"}, {"option": "Hex", "string": ""}, @@ -53,12 +53,12 @@ TestRegister.addTests([ ] }, { - name: "Rabbit Stream Cipher: RFC Test vector, with IV 1", + name: "Rabbit: RFC Test vector, with IV 1", input: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", expectedOutput: "c6a7275ef85495d87ccd5d376705b7ed5f29a6ac04f5efd47b8f293270dc4a8d2ade822b29de6c1ee52bdb8a47bf8f66", recipeConfig: [ { - "op": "Rabbit Stream Cipher", + "op": "Rabbit", "args": [ {"option": "Hex", "string": "00000000000000000000000000000000"}, {"option": "Hex", "string": "0000000000000000"}, @@ -68,12 +68,12 @@ TestRegister.addTests([ ] }, { - name: "Rabbit Stream Cipher: RFC Test vector, with IV 2", + name: "Rabbit: RFC Test vector, with IV 2", input: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", expectedOutput: "1fcd4eb9580012e2e0dccc9222017d6da75f4e10d12125017b2499ffed936f2eebc112c393e738392356bdd012029ba7", recipeConfig: [ { - "op": "Rabbit Stream Cipher", + "op": "Rabbit", "args": [ {"option": "Hex", "string": "00000000000000000000000000000000"}, {"option": "Hex", "string": "c373f575c1267e59"}, @@ -83,12 +83,12 @@ TestRegister.addTests([ ] }, { - name: "Rabbit Stream Cipher: RFC Test vector, with IV 3", + name: "Rabbit: RFC Test vector, with IV 3", input: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", expectedOutput: "445ad8c805858dbf70b6af23a151104d96c8f27947f42c5baeae67c6acc35b039fcbfc895fa71c17313df034f01551cb", recipeConfig: [ { - "op": "Rabbit Stream Cipher", + "op": "Rabbit", "args": [ {"option": "Hex", "string": "00000000000000000000000000000000"}, {"option": "Hex", "string": "a6eb561ad2f41727"}, @@ -98,12 +98,12 @@ TestRegister.addTests([ ] }, { - name: "Rabbit Stream Cipher: generated stream should be XORed with the input", + name: "Rabbit: generated stream should be XORed with the input", input: "cedda96c054e3ddd93da7ed05e2a4b7bdb0c00fe214f03502e2708b2c2bfc77aa2311b0b9af8aa78d119f92b26db0a6b", expectedOutput: "7f8afd9c33ebeb3166b13bf64260bc7953e4d8ebe4d30f69554e64f54b794ddd5627bac8eaf47e290b7128a330a8dcfd", recipeConfig: [ { - "op": "Rabbit Stream Cipher", + "op": "Rabbit", "args": [ {"option": "Hex", "string": "00000000000000000000000000000000"}, {"option": "Hex", "string": ""}, @@ -113,12 +113,12 @@ TestRegister.addTests([ ] }, { - name: "Rabbit Stream Cipher: least significant bits should be used for the last block", + name: "Rabbit: least significant bits should be used for the last block", input: "0000000000000000", expectedOutput: "f56b45261c4af702", recipeConfig: [ { - "op": "Rabbit Stream Cipher", + "op": "Rabbit", "args": [ {"option": "Hex", "string": "00000000000000000000000000000000"}, {"option": "Hex", "string": ""}, @@ -128,12 +128,12 @@ TestRegister.addTests([ ] }, { - name: "Rabbit Stream Cipher: invalid key length", + name: "Rabbit: invalid key length", input: "", expectedOutput: "Invalid key length: 8 bytes (expected: 16)", recipeConfig: [ { - "op": "Rabbit Stream Cipher", + "op": "Rabbit", "args": [ {"option": "Hex", "string": "0000000000000000"}, {"option": "Hex", "string": ""}, @@ -143,12 +143,12 @@ TestRegister.addTests([ ] }, { - name: "Rabbit Stream Cipher: invalid IV length", + name: "Rabbit: invalid IV length", input: "", expectedOutput: "Invalid IV length: 4 bytes (expected: 0 or 8)", recipeConfig: [ { - "op": "Rabbit Stream Cipher", + "op": "Rabbit", "args": [ {"option": "Hex", "string": "00000000000000000000000000000000"}, {"option": "Hex", "string": "00000000"}, @@ -160,12 +160,12 @@ TestRegister.addTests([ { // this testcase is taken from the first example on Crypto++ Wiki // https://www.cryptopp.com/wiki/Rabbit - name: "Rabbit Stream Cipher: little-endian mode (Crypto++ compatible)", + name: "Rabbit: little-endian mode (Crypto++ compatible)", input: "Rabbit stream cipher test", expectedOutput: "1ae2d4edcf9b6063b00fd6fda0b223aded157e77031cf0440b", recipeConfig: [ { - "op": "Rabbit Stream Cipher", + "op": "Rabbit", "args": [ {"option": "Hex", "string": "23c2731e8b5469fd8dabb5bc592a0f3a"}, {"option": "Hex", "string": "712906405ef03201"},