GCM_IV_LENGTH should be 12 bytes (96 bits) instead of 128 bytes for AES-GCM
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 41
- Forks
- 92
- PR merge metrics
- No merged PRs in 30d
Description
In SymmetricCipher.java, the IV length constant is set to 128:
private static final int GCM_IV_LENGTH = 128;
This is used as a byte count in getInitializationVector():
byte[] iv = new byte[GCM_IV_LENGTH]; // 128 bytes = 1024 bits
For AES-GCM, NIST SP 800-38D (Section 5.2.1.1) recommends 96-bit (12-byte) IVs. While GCM does support arbitrary-length IVs, any length other than 96 bits triggers an additional GHASH computation to derive the actual IV, which:
- Reduces the security bound of the construction
- Introduces a higher collision probability for the counter block
- Goes against NIST's explicit recommendation
Suggested Fix
private static final int GCM_IV_LENGTH = 12; // 96 bits, per NIST SP 800-38D
References
- NIST SP 800-38D — Recommendation for GCM, Section 5.2.1.1
- RFC 5116 — AES-GCM
Contributor guide
No contributing guide indexed for this repository
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
Open SymmetricCipher.java and inspect getInitializationVector(), where GCM_IV_LENGTH is used to allocate the IV. Change the constant to the requested 12-byte value, then verify that generated AES-GCM IVs use the new length and that the existing project checks still pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- cryptography
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 75/100