For algorithm test vector evaluation, I am trying to perform an AESGCM encryption and decryption with arbitrary tag length values such as 32 bits.
When I try to initialize my cipher with such an arbitrary tag length as follows:
final Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
GCMParameterSpec parameterSpec = new GCMParameterSpec(tagLen, iv);
cipher.init(Cipher.ENCRYPT_MODE, secretKey, parameterSpec);
I am met with this error:
java.security.InvalidAlgorithmParameterException: Unsupported TLen value; must be one of {128, 120, 112, 104, 96}
Normally, this would be a good thing, because you don't want a tag length of 32. However, for my purposes I do need this tag length.
Is there a way that I can override these restrictions to allow for arbitrary tag lengths?