@Override int doFinalInternal(byte[] output, int outputOffset, int maximumLen) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException { checkInitialization(); final int bytesWritten; try { if (isEncrypting()) { bytesWritten = NativeCrypto.EVP_AEAD_CTX_seal(evpAead, encodedKey, tagLengthInBytes, output, outputOffset, iv, buf, 0, bufCount, aad); } else { bytesWritten = NativeCrypto.EVP_AEAD_CTX_open(evpAead, encodedKey, tagLengthInBytes, output, outputOffset, iv, buf, 0, bufCount, aad); } } catch (BadPaddingException e) { throwAEADBadTagExceptionIfAvailable(e.getMessage(), e.getCause()); throw e; } if (isEncrypting()) { mustInitialize = true; } reset(); return bytesWritten; }
@Override int doFinalInternal(byte[] output, int outputOffset, int maximumLen) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException { checkInitialization(); final int bytesWritten; try { if (isEncrypting()) { bytesWritten = NativeCrypto.EVP_AEAD_CTX_seal(evpAead, encodedKey, tagLengthInBytes, output, outputOffset, iv, buf, 0, bufCount, aad); } else { bytesWritten = NativeCrypto.EVP_AEAD_CTX_open(evpAead, encodedKey, tagLengthInBytes, output, outputOffset, iv, buf, 0, bufCount, aad); } } catch (BadPaddingException e) { throwAEADBadTagExceptionIfAvailable(e.getMessage(), e.getCause()); throw e; } if (isEncrypting()) { mustInitialize = true; } reset(); return bytesWritten; }