We're using Cipher
and CipherInputStream
in an Android app to decrypt files downloaded from a server.
For some reason, all the calls to Cipher.update
return an empty block and the call to Cipher.doFinal
returns the entire file in one block.
This causes OOM on large files.
This is the code we use to initialize the cipher:
final Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
SecretKeySpec key = new SecretKeySpec(keyData, "AES");
GCMParameterSpec nonce = new GCMParameterSpec(128, nonceData);
cipher.init(Cipher.DECRYPT_MODE, key, nonce);
- Why is this happening?
- Is this something that can be fixed on the client side?
Note: I don't currently have access to the server's code. When I have I will post it too. Note 2: This happens on Android API 25.0.1