Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug report: AES CTR results differ from expected #1740

Open
dsmouse opened this issue Feb 28, 2024 · 2 comments
Open

Bug report: AES CTR results differ from expected #1740

dsmouse opened this issue Feb 28, 2024 · 2 comments
Labels

Comments

@dsmouse
Copy link

dsmouse commented Feb 28, 2024

I was working on cryptopals challenge, https://cryptopals.com/sets/3/challenges/18
It provided me an AES Key for CTR mode and a base64 encoded message to decrypt,
key=YELLOW SUBMARINE
nonce=0
format=64 bit unsigned little endian nonce,
64 bit little endian block count (byte count / 16)
The string: L77na/nrFsKvynd6HzOoG7GHTLXsTVu9qvY/2syLXzhPweyyMTJULu/6/kXX0KSvoOLSFQ==

The code I used to decrypt it worked, but when I used it on Cyberchief encrypted strings, it did not. I implemented behavior to work with cyberchief encrypted strings and found that the CTR was computed differently for non-zero block numbers, 00000000000000000100000000000000 for cryptopals and 00000000000000000000000000000001 for cyberchief.

What should happen
Given the key, nonce/IV, it should decrypt

  • CyberChef version: cyberchief.org version

Additional context

This could legitly be two different implementations, if so the option to choose one or the other would be in order.

@dsmouse dsmouse added the bug label Feb 28, 2024
@zb3
Copy link
Contributor

zb3 commented Apr 1, 2024

Seems like you want little-endian counters in AES CTR.. I see CyberChef uses node-forge which doesn't offer this feature so it's not simply a matter of passing different options

@zb3
Copy link
Contributor

zb3 commented Apr 1, 2024

It seems an option like "CTR LE" would not even be enough since for Little Endian counters you also need to know the counter size which can vary (64 bit in your example, but node-forge uses 32-bit counters)
So this isn't any standard algorithm and IMO implementing this doesn't make any sense, practically no library does it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants