Keystore 2.0 SPI: Small fix to apease CTS test.

* The Keystore SPI needs to return null if getKeyEntry is called on a
  pure certificate entry.
* Also checked the wrong purpose.

Test: Keystore CTS tests.
Change-Id: Ib668447a9ff56fc4cea550f547c6cbfea3590cb3
This commit is contained in:
Janis Danisevskis
2021-01-19 13:41:47 -08:00
parent ba04ef8481
commit 05943c30a1
2 changed files with 6 additions and 1 deletions

View File

@@ -363,6 +363,11 @@ public class AndroidKeyStoreProvider extends Provider {
}
}
if (response.iSecurityLevel == null) {
// This seems to be a pure certificate entry, nothing to return here.
return null;
}
Integer keymasterAlgorithm = null;
// We just need one digest for the algorithm name
int keymasterDigest = -1;

View File

@@ -490,7 +490,7 @@ public class AndroidKeyStoreSpi extends KeyStoreSpi {
int[] keymasterEncryptionPaddings =
KeyProperties.EncryptionPadding.allToKeymaster(
spec.getEncryptionPaddings());
if (((spec.getPurposes() & KeyProperties.PURPOSE_DECRYPT) != 0)
if (((spec.getPurposes() & KeyProperties.PURPOSE_ENCRYPT) != 0)
&& (spec.isRandomizedEncryptionRequired())) {
for (int keymasterPadding : keymasterEncryptionPaddings) {
if (!KeymasterUtils