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

phex() in test.c printing jibberish for test_encrypt_ecb_verbose #142

Open
wirawan0 opened this issue Jun 14, 2019 · 1 comment
Open

phex() in test.c printing jibberish for test_encrypt_ecb_verbose #142

wirawan0 opened this issue Jun 14, 2019 · 1 comment

Comments

@wirawan0
Copy link

The test_encrypt_ecb_verbose assumes a 128-bit key in test.c. But the overall code is made such that it would take 128, 192, 256 bits. The problem is that phex prints 16, 24, 32 bytes of data, therefore phex will print jibberish (trailing junk bytes) when we define either AES192 or AES256 and run test_encrypt_ecb_verbose(). Worse, the fixing to 128-bit key would also lead to wrong encryption. I think that subroutine should be allowed to run only when AES128 is defined.

@kokke
Copy link
Owner

kokke commented Jun 14, 2019

Hi @wirawan0 and thanks for your interest in this project :)

From a quick glance, you're right that phex only works correctly for 128 bit keys and that test_encrypt_ecb_verbose() doesn't work correctly for larger key sizes. The other test-functions do however. test_encrypt_ecb_verbose() should just be parameterized for different key sizes like the other test functions and all would be good (I'll gladly accept a PR ;))

I have done a lot more testing than what is in test.c and indeed encryption and decryption works as advertised even though the test-file doesn't test very thoroughly.

The test-code is meant to be a quick way for users to verify against the NIST vectors described in SP 800-38. It is not meant to convince you of correctness or robustness.

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

No branches or pull requests

2 participants