Merge "Keystore 2.0 SPI: Fix various CTS failures."

This commit is contained in:
Janis Danisevskis
2021-02-09 16:41:10 +00:00
committed by Gerrit Code Review
4 changed files with 6 additions and 12 deletions

View File

@@ -190,7 +190,7 @@ public class KeyStoreSecurityLevel {
keyDescriptor.blob = wrappedKey;
keyDescriptor.domain = wrappedKeyDescriptor.domain;
return handleExceptions(() -> mSecurityLevel.importWrappedKey(wrappedKeyDescriptor,
return handleExceptions(() -> mSecurityLevel.importWrappedKey(keyDescriptor,
wrappingKeyDescriptor, maskingKey,
args.toArray(new KeyParameter[args.size()]), authenticatorSpecs));
}

View File

@@ -163,6 +163,9 @@ public abstract class AndroidKeyStoreHmacSpi extends MacSpi implements KeyStoreC
}
List<KeyParameter> parameters = new ArrayList<>();
parameters.add(KeyStore2ParameterUtils.makeEnum(
KeymasterDefs.KM_TAG_PURPOSE, KeymasterDefs.KM_PURPOSE_SIGN
));
parameters.add(KeyStore2ParameterUtils.makeEnum(
KeymasterDefs.KM_TAG_ALGORITHM, KeymasterDefs.KM_ALGORITHM_HMAC
));

View File

@@ -21,7 +21,6 @@ import android.security.KeyStoreSecurityLevel;
import android.system.keystore2.Authorization;
import android.system.keystore2.Domain;
import android.system.keystore2.KeyDescriptor;
import android.util.Log;
import java.security.Key;
@@ -127,15 +126,6 @@ public class AndroidKeyStoreKey implements Key {
return false;
}
// If the key ids are equal and the class matches all the other fields cannot differ
// unless we have a bug.
if (!mAlgorithm.equals(other.mAlgorithm)
|| !mAuthorizations.equals(other.mAuthorizations)
|| !mDescriptor.equals(other.mDescriptor)) {
Log.e("AndroidKeyStoreKey", "Bug: key ids are identical, but key metadata"
+ "differs.");
return false;
}
return true;
}
}

View File

@@ -866,7 +866,8 @@ public class AndroidKeyStoreSpi extends KeyStoreSpi {
try {
response = mKeyStore.getKeyEntry(wrappingkey);
} catch (android.security.KeyStoreException e) {
throw new KeyStoreException("Failed to load wrapping key.", e);
throw new KeyStoreException("Failed to import wrapped key. Keystore error code: "
+ e.getErrorCode(), e);
}
KeyDescriptor wrappedKey = makeKeyDescriptor(alias);