wso2 / wso2/cipher-tool

GCM_IV_LENGTH should be 12 bytes (96 bits) instead of 128 bytes for AES-GCM

Open Beginner friendly
#103 0 comments 0 reactions 0 assignees View on GitHub

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:

  1. Reduces the security bound of the construction
  2. Introduces a higher collision probability for the counter block
  3. Goes against NIST's explicit recommendation
Suggested Fix
private static final int GCM_IV_LENGTH = 12; // 96 bits, per NIST SP 800-38D
References

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.