Support AES/GCM ciphers that don't accept externally generated IV

Issue #216 wontfix
Vladimir Dzhuvinov created an issue

Reported by email to support:

As per RSA JSafeJCE spec for the GCMParameterSpec() constructor. Any constructor that accepts an IV as a byte array "must not be used for encryption, since the IV will be internally generated."

This means for encryption, use the constructor GCMParameterSpec(int tagLen, long authDataLen) or GCMParameterSpec(long authDataLen)

However, the implementation in AESGCM does exactly what RSA forbids :

byte[] iv = ivContainer.get();
...
...
GCMParameterSpec gcmSpec = new GCMParameterSpec(AUTH_TAG_BIT_LENGTH, iv);
cipher.init(Cipher.ENCRYPT_MODE, secretKey, gcmSpec);

This is the reason why cipher.init() errors out when we use RSA security.

Comments (3)

  1. Vladimir Dzhuvinov reporter

    Suggested constructors not available:

    GCMParameterSpec(int tLen, byte[] src)

    Constructs a GCMParameterSpec using the specified authentication tag bit-length and IV buffer.

    GCMParameterSpec(int tLen, byte[] src, int offset, int len)

    Constructs a GCMParameterSpec object using the specified authentication tag bit-length and a subset of the specified buffer as the IV.

  2. Vladimir Dzhuvinov reporter

    RSA Bsafe JCA provider requires its own GCMParameterSpec, not compatible with the JCA framework.

    RSA has its own implementation of GCMParameterSpec and its constructors.

  3. Log in to comment