in src/main/java/org/apache/commons/crypto/cipher/OpenSslGaloisCounterMode.java [229:253]
public void init(final int mode, final byte[] key, final AlgorithmParameterSpec params)
throws InvalidAlgorithmParameterException {
if (aadBuffer == null) {
aadBuffer = new ByteArrayOutputStream();
} else {
aadBuffer.reset();
}
this.cipherMode = mode;
final byte[] iv;
if (!(params instanceof GCMParameterSpec)) {
// other AlgorithmParameterSpec is not supported now.
throw new InvalidAlgorithmParameterException("Illegal parameters");
}
final GCMParameterSpec gcmParam = (GCMParameterSpec) params;
iv = gcmParam.getIV();
this.tagBitLen = gcmParam.getTLen();
if (this.cipherMode == OpenSsl.DECRYPT_MODE) {
inBuffer = new ByteArrayOutputStream();
}
context = OpenSslNative.init(context, mode, algorithmMode, padding, key, iv);
}