Merge "Fix symmetric key generation in strongbox" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0e43e2ef96
@@ -301,6 +301,9 @@ public abstract class AndroidKeyStoreKeyGeneratorSpi extends KeyGeneratorSpi {
|
||||
KeyStoreCryptoOperationUtils.getRandomBytesToMixIntoKeystoreRng(
|
||||
mRng, (mKeySizeBits + 7) / 8);
|
||||
int flags = 0;
|
||||
if (spec.isStrongBoxBacked()) {
|
||||
flags |= KeyStore.FLAG_STRONGBOX;
|
||||
}
|
||||
String keyAliasInKeystore = Credentials.USER_PRIVATE_KEY + spec.getKeystoreAlias();
|
||||
KeyCharacteristics resultingKeyCharacteristics = new KeyCharacteristics();
|
||||
boolean success = false;
|
||||
@@ -314,8 +317,12 @@ public abstract class AndroidKeyStoreKeyGeneratorSpi extends KeyGeneratorSpi {
|
||||
flags,
|
||||
resultingKeyCharacteristics);
|
||||
if (errorCode != KeyStore.NO_ERROR) {
|
||||
throw new ProviderException(
|
||||
"Keystore operation failed", KeyStore.getKeyStoreException(errorCode));
|
||||
if (errorCode == KeyStore.HARDWARE_TYPE_UNAVAILABLE) {
|
||||
throw new StrongBoxUnavailableException("Failed to generate key");
|
||||
} else {
|
||||
throw new ProviderException(
|
||||
"Keystore operation failed", KeyStore.getKeyStoreException(errorCode));
|
||||
}
|
||||
}
|
||||
@KeyProperties.KeyAlgorithmEnum String keyAlgorithmJCA;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user