Wrong AES Encrypt output on inputs with special characters
ncoder-1 opened this issue · comments
Describe the bug
When using the "AES Encrypt" (input parameter set to Raw
) operation with a UTF-8 input text which has special characters (in this case an é
), the output is different from 3 different sources (openssl
, botan
and the cryptii
online encrypter), all of which produce the same output.
If you perform a "To Hex" operation before the "AES Encrypt" operation, and set the input paramenter to Hex
, it then produces the expected output.
To Reproduce
- Go to CyberChef
- Add an "AES Encrypt" operation
- Set key to
B4294F848BD875E697FAF7CFAF40D102C733066C11C4356029710C9D5EBF26E7
- Set IV to
00000000000000000000000000000000
- In the input, set
input character encoding
toUTF-8
- Add
emporté
in as the input text - The output will then be
d2c844670dcf3ed9fe28f764e631fcb4
which is wrong. - Add a "To Hex" operation before the "AES Encrypt"
- Set the "AES Encrypt" input to
To Hex
- Output will be
1dfbb577dca5a8f207cf9fd4b0da7aee
which is right.
Expected behaviour
I would expect that it accepts special characters within UTF-8 when it is selected as the input encoding, such as below:
With botan
cli:
echo "emporté" > input.txt
truncate -s -1 input.txt
botan cipher --cipher=AES-256/CBC --key=B4294F848BD875E697FAF7CFAF40D102C733066C11C4356029710C9D5EBF26E7 --nonce=00000000000000000000000000000000 input.txt > out.enc
xxd -ps out.enc
Produces: 1dfbb577dca5a8f207cf9fd4b0da7aee
With openssl enc
:
echo "emporté" > input.txt
truncate -s -1 input.txt
openssl enc -aes-256-cbc -nosalt -in input.txt -out out.enc -p -K "B4294F848BD875E697FAF7CFAF40D102C733066C11C4356029710C9D5EBF26E7" -iv "00000000000000000000000000000000"
xxd -ps out.enc
Produces: 1dfbb577dca5a8f207cf9fd4b0da7aee
And obviously the same output with same parameters on cryptii
Desktop (if relevant, please complete the following information):
- OS: Linux 6.7.5
- CyberChef version: 10