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

Why AesCbc encrypted ciphertext is prefixed with IV? #72

Open
carlonzo opened this issue Jun 5, 2023 · 1 comment
Open

Why AesCbc encrypted ciphertext is prefixed with IV? #72

carlonzo opened this issue Jun 5, 2023 · 1 comment

Comments

@carlonzo
Copy link

carlonzo commented Jun 5, 2023

Hi I have a question about the implementation of AesCbc:
I see that the result of encryption is prefixed with the iv and the decryption, instead, removes the iv decrypting.

Is that a reason for this? from the RFC or usage examples of the Cipher dont do anything similar.

Even the tests vectors from https://datatracker.ietf.org/doc/html/rfc3602#section-4 the cipher does not include the iv and the assertions you implemented need to modify the result to match the test vectors.

Thanks for that!

@robxyy
Copy link
Contributor

robxyy commented Jun 6, 2023

The purpose of this design is to facilitate encryption and decryption without requiring the user to understand the process of generating iv (BTW, iv also supports customization), it also refers to the design of Tink. AesSiv.java#L125, AesCtrJceCipher.java#L95 🍺

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