Hi, i have a problem with using the javax.crypto.CipherOutputStream-Class in AEAD mode.
I try to encrypt a file andthat seems to work properly.
But if i try to decrypt this file, the file will be created but the size is 0 byte.
I don't know if it's a Bug in the CipherOutputStream-class or have I misunderstood something?
ciper is in AEAD mode...
but if i try to encrypt and to decrypt data without using CipherInputStream and CipherOutputStream it will be works fine...
cipher = Cipher.getInstance("AES/GCM/PKCS5Padding");
cipher.init(cipherMode, secret, new GCMParameterSpec(128, nonce));
....
....
CipherOutputStream cos = new CipherOutputStream(encryptedOutStream, cipher);
int blockSize = cipher.getBlockSize();
while ((n = inputStream.read(byteBuffer)) != -1) {
cos.write(byteBuffer, 0, n);
}
cipher.updateAAD(ad);
cos.close();
encryptedOutStream.close();
inputStream.close();