mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 15:26:16 -04:00
Tidied up Blowfish tests
This commit is contained in:
parent
875c1019b2
commit
b96394131f
1 changed files with 21 additions and 19 deletions
|
@ -1376,27 +1376,29 @@ DES uses a key length of 8 bytes (64 bits).`,
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
/* The following expectedOutputs are generated with this Python script with pyCryptoDome
|
/*
|
||||||
from Crypto.Cipher import Blowfish
|
The following expectedOutputs are generated with this Python script with pyCryptoDome
|
||||||
import binascii
|
|
||||||
|
|
||||||
input_data = b"The quick brown fox jumps over the lazy dog."
|
from Crypto.Cipher import Blowfish
|
||||||
key = binascii.unhexlify("0011223344556677")
|
import binascii
|
||||||
iv = binascii.unhexlify("0000000000000000")
|
|
||||||
mode = Blowfish.MODE_CBC
|
|
||||||
|
|
||||||
if mode == Blowfish.MODE_ECB or mode == Blowfish.MODE_CBC:
|
input_data = b"The quick brown fox jumps over the lazy dog."
|
||||||
padding_len = 8-(len(input_data) & 7)
|
key = binascii.unhexlify("0011223344556677")
|
||||||
for i in range(padding_len):
|
iv = binascii.unhexlify("0000000000000000")
|
||||||
input_data += bytes([padding_len])
|
mode = Blowfish.MODE_CBC
|
||||||
|
|
||||||
cipher = Blowfish.new(key, mode) # set iv, nonce, segment_size etc. here
|
if mode == Blowfish.MODE_ECB or mode == Blowfish.MODE_CBC:
|
||||||
cipher_text = cipher.encrypt(input_data)
|
padding_len = 8-(len(input_data) & 7)
|
||||||
|
for i in range(padding_len):
|
||||||
|
input_data += bytes([padding_len])
|
||||||
|
|
||||||
cipher_text = binascii.hexlify(cipher_text).decode("UTF-8")
|
cipher = Blowfish.new(key, mode) # set iv, nonce, segment_size etc. here
|
||||||
|
cipher_text = cipher.encrypt(input_data)
|
||||||
|
|
||||||
print("Encrypted: {}".format(cipher_text))
|
cipher_text = binascii.hexlify(cipher_text).decode("UTF-8")
|
||||||
*/
|
|
||||||
|
print("Encrypted: {}".format(cipher_text))
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
name: "Blowfish Encrypt: ECB, ASCII",
|
name: "Blowfish Encrypt: ECB, ASCII",
|
||||||
input: "The quick brown fox jumps over the lazy dog.",
|
input: "The quick brown fox jumps over the lazy dog.",
|
||||||
|
@ -1555,7 +1557,7 @@ DES uses a key length of 8 bytes (64 bits).`,
|
||||||
{
|
{
|
||||||
name: "Blowfish Encrypt: CFB, Binary",
|
name: "Blowfish Encrypt: CFB, Binary",
|
||||||
input: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
|
input: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
|
||||||
// see above. pyCryptoDome produeces a different value with its default settings
|
// see above. pyCryptoDome produces a different value with its default settings
|
||||||
expectedOutput: "e6ac1324d1576beab00e855de3f4ac1f5e3cbf89f4c2a743a5737895067ac5012e5bdb92477e256cc07bf691b58e721179b550e694abb0be7cbdc42586db755bf795f4338f47d356c57453afa6277e46aaeb3405f9744654a477f06c2ad92ede90555759",
|
expectedOutput: "e6ac1324d1576beab00e855de3f4ac1f5e3cbf89f4c2a743a5737895067ac5012e5bdb92477e256cc07bf691b58e721179b550e694abb0be7cbdc42586db755bf795f4338f47d356c57453afa6277e46aaeb3405f9744654a477f06c2ad92ede90555759",
|
||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
|
@ -1574,7 +1576,7 @@ DES uses a key length of 8 bytes (64 bits).`,
|
||||||
name: "Blowfish Decrypt: CFB, ASCII",
|
name: "Blowfish Decrypt: CFB, ASCII",
|
||||||
input: "c8ca123592570c1fcb138d4ec08f7af14ad49363245be1ac25029c8ffc508b3217e75faaa5566426180fec8f",
|
input: "c8ca123592570c1fcb138d4ec08f7af14ad49363245be1ac25029c8ffc508b3217e75faaa5566426180fec8f",
|
||||||
expectedOutput: "The quick brown fox jumps over the lazy dog.",
|
expectedOutput: "The quick brown fox jumps over the lazy dog.",
|
||||||
// see above. pyCryptoDome produeces a different value with its default settings
|
// see above. pyCryptoDome produces a different value with its default settings
|
||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
"op": "Blowfish Decrypt",
|
"op": "Blowfish Decrypt",
|
||||||
|
@ -1592,7 +1594,7 @@ DES uses a key length of 8 bytes (64 bits).`,
|
||||||
name: "Blowfish Decrypt: CFB, Binary",
|
name: "Blowfish Decrypt: CFB, Binary",
|
||||||
input: "e6ac1324d1576beab00e855de3f4ac1f5e3cbf89f4c2a743a5737895067ac5012e5bdb92477e256cc07bf691b58e721179b550e694abb0be7cbdc42586db755bf795f4338f47d356c57453afa6277e46aaeb3405f9744654a477f06c2ad92ede90555759",
|
input: "e6ac1324d1576beab00e855de3f4ac1f5e3cbf89f4c2a743a5737895067ac5012e5bdb92477e256cc07bf691b58e721179b550e694abb0be7cbdc42586db755bf795f4338f47d356c57453afa6277e46aaeb3405f9744654a477f06c2ad92ede90555759",
|
||||||
expectedOutput: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
|
expectedOutput: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
|
||||||
// see above. pyCryptoDome produeces a different value with its default settings
|
// see above. pyCryptoDome produces a different value with its default settings
|
||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
"op": "Blowfish Decrypt",
|
"op": "Blowfish Decrypt",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue