spring-projects / spring-projects/spring-security
The default initialization vector size of the AesBytesEncryptor should be 12 bytes for GCM
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 6.3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 52
Description
Summary
When trying to decrypt data with Node.js (AES256, GCM), I realized the initialization vector was of 12 bytes while it's 16 bytes length in the AesBytesEncryptor: https://github.com/spring-projects/spring-security/blob/master/crypto/src/main/java/org/springframework/security/crypto/encrypt/AesBytesEncryptor.java#L63
The spec recommends to use initialization vectors of 96 bits length: http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/gcm-revised-spec.pdf
An initialization vector IV , that can have any number of bits between 1 and 264. For a fixed
value of the key, each IV value must be distinct, but need not have equal lengths. 96-bit
IV values can be processed more efficiently, so that length is recommended for situations in
which efficiency is critical.
Actual Behavior
Default size of the initialization vector for GCM cipher algorithm: 16 bytes
Expected Behavior
Default size of the initialization vector for GCM cipher algorithm: 12 bytes. Use: KeyGenerators.secureRandom(12).
Version
4.0.2.RELEASE
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with crypto/src/main/java/org/springframework/security/crypto/encrypt/AesBytesEncryptor.java at the initialization-vector setup referenced in the issue. Check the current default and the KeyGenerators.secureRandom call, then verify that GCM uses a 12-byte default initialization vector as described in the expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- cryptography, security
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100