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 Encryption with cipher text of null string appended? #392

Closed
jiegec opened this issue Oct 15, 2018 · 2 comments
Closed

Bug report: AES Encryption with cipher text of null string appended? #392

jiegec opened this issue Oct 15, 2018 · 2 comments

Comments

@jiegec
Copy link

jiegec commented Oct 15, 2018

Summary

Encrypting a 16-byte text results in its own 16-byte cipher text with cipher text of null string appended.

Example

Recipe 1

Encrypt hex "00000000000000000000000000000000" with AES-128-ECB with key hex "00000000000000000000000000000000" results in "66e94bd4ef8a2c3b884cfa59ca342b2e0143db63ee66b0cdff9f69917680151e".

Expected output was "66e94bd4ef8a2c3b884cfa59ca342b2e". But the output was "66e94bd4ef8a2c3b884cfa59ca342b2e" + "0143db63ee66b0cdff9f69917680151e". It can be confirmed that "0143db63ee66b0cdff9f69917680151e" is the cipher text of a null string.

Recipe 2

@imhotepisinvisible
Copy link
Contributor

This doesn't appear to be a bug. Forge, the crypto library used by this operation, explicitly states that "CBC and ECB modes use PKCS#7 padding as default" which is typical for these operation modes. It can be seen that 0143db63ee66b0cdff9f69917680151e is the cipher text of a full padding block of 0x10 bytes: recipe

It might be useful though if these operations included the option to disable padding.

@jiegec
Copy link
Author

jiegec commented Jan 3, 2019

Many thanks. Padding mode should be changeable then.

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