Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dbb6114d authored by Janis Danisevskis's avatar Janis Danisevskis Committed by android-build-merger
Browse files

Merge "Fix symmetric key generation in strongbox" into pi-dev

am: 0e43e2ef

Change-Id: I154ab21e8f0d804225f993d187e2aad66a5cdeac
parents eaa77a20 0e43e2ef
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -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,9 +317,13 @@ public abstract class AndroidKeyStoreKeyGeneratorSpi extends KeyGeneratorSpi {
                    flags,
                    resultingKeyCharacteristics);
            if (errorCode != KeyStore.NO_ERROR) {
                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 {
                keyAlgorithmJCA = KeyProperties.KeyAlgorithm.fromKeymasterSecretKeyAlgorithm(