summaryrefslogtreecommitdiff
path: root/keystore
diff options
context:
space:
mode:
authorJanis Danisevskis <jdanis@google.com>2021-04-19 10:47:01 -0700
committerHasini Gunasinghe <hasinitg@google.com>2021-04-22 14:55:45 +0000
commit70cf430ede6a658fa4117bb06054141ba7ca5e20 (patch)
tree83f793a2ef3ba7afdf98c915a06a90799f16e2e2 /keystore
parentc66289ebd2142309f2feaf2906fa30c484f85e7e (diff)
Keystore 2.0 SPI: Fix engineDoFinal with null input.
AndroidKeyStoreCipherSpiBase.engineDoFinal may get called with a null input argument. In the case where we forward the operation to the default provider doFinal() needs to be called instead of doFinal(byte[], int, int). Bug: 183913233 Test: atest android.keystore.cts.CipherTest#testEncryptsAndDecryptsUsingCipherStreams Change-Id: Ia3afaf281be7c8e5493ac8e4155a7aa02d1d37f0
Diffstat (limited to 'keystore')
-rw-r--r--keystore/java/android/security/keystore2/AndroidKeyStoreCipherSpiBase.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/keystore/java/android/security/keystore2/AndroidKeyStoreCipherSpiBase.java b/keystore/java/android/security/keystore2/AndroidKeyStoreCipherSpiBase.java
index 9d8a5effc2d7..e808c5cc51bd 100644
--- a/keystore/java/android/security/keystore2/AndroidKeyStoreCipherSpiBase.java
+++ b/keystore/java/android/security/keystore2/AndroidKeyStoreCipherSpiBase.java
@@ -579,7 +579,11 @@ abstract class AndroidKeyStoreCipherSpiBase extends CipherSpi implements KeyStor
protected final byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen)
throws IllegalBlockSizeException, BadPaddingException {
if (mCipher != null) {
- return mCipher.doFinal(input, inputOffset, inputLen);
+ if (input == null && inputLen == 0) {
+ return mCipher.doFinal();
+ } else {
+ return mCipher.doFinal(input, inputOffset, inputLen);
+ }
}
if (mCachedException != null) {