Keystore: Added missing error codes

All error codes defined in ErrorCode.aidl file are expected to be
mapped in KeymasterDefs.java file, excluding -62 which is handled by
Keystore and not required to define on Jaya layer.
So missing error codes from KeymasterDefs are added and also categorized
in KeyStoreException class.

Bug: 206432492
Test: atest CtsKeystoreTestCases:android.keystore.cts.KeyStoreExceptionTest
Change-Id: I9df69e03379d0437457037e16de76feb27ea8aaf
This commit is contained in:
Prashant Patil
2023-04-13 13:19:42 +01:00
parent a750dcaaa6
commit b15ca79b52
2 changed files with 41 additions and 1 deletions

View File

@@ -337,8 +337,22 @@ public final class KeymasterDefs {
ErrorCode.ROLLBACK_RESISTANCE_UNAVAILABLE; // -67;
public static final int KM_ERROR_HARDWARE_TYPE_UNAVAILABLE =
ErrorCode.HARDWARE_TYPE_UNAVAILABLE; // -68;
public static final int KM_ERROR_PROOF_OF_PRESENCE_REQUIRED =
ErrorCode.PROOF_OF_PRESENCE_REQUIRED; // -69;
public static final int KM_ERROR_CONCURRENT_PROOF_OF_PRESENCE_REQUESTED =
ErrorCode.CONCURRENT_PROOF_OF_PRESENCE_REQUESTED; // -70;
public static final int KM_ERROR_NO_USER_CONFIRMATION =
ErrorCode.NO_USER_CONFIRMATION; // -71;
public static final int KM_ERROR_DEVICE_LOCKED =
ErrorCode.DEVICE_LOCKED; // -72;
public static final int KM_ERROR_EARLY_BOOT_ENDED =
ErrorCode.EARLY_BOOT_ENDED; // -73;
public static final int KM_ERROR_ATTESTATION_KEYS_NOT_PROVISIONED =
ErrorCode.ATTESTATION_KEYS_NOT_PROVISIONED; // -74;
public static final int KM_ERROR_ATTESTATION_IDS_NOT_PROVISIONED =
ErrorCode.ATTESTATION_IDS_NOT_PROVISIONED; // -75;
public static final int KM_ERROR_INVALID_OPERATION =
ErrorCode.INVALID_OPERATION; // -76;
public static final int KM_ERROR_STORAGE_KEY_UNSUPPORTED =
ErrorCode.STORAGE_KEY_UNSUPPORTED; // -77,
public static final int KM_ERROR_INCOMPATIBLE_MGF_DIGEST =
@@ -348,7 +362,13 @@ public final class KeymasterDefs {
public static final int KM_ERROR_MISSING_NOT_BEFORE =
ErrorCode.MISSING_NOT_BEFORE; // -80;
public static final int KM_ERROR_MISSING_NOT_AFTER =
ErrorCode.MISSING_NOT_AFTER; // -80;
ErrorCode.MISSING_NOT_AFTER; // -81;
public static final int KM_ERROR_MISSING_ISSUER_SUBJECT =
ErrorCode.MISSING_ISSUER_SUBJECT; // -82;
public static final int KM_ERROR_INVALID_ISSUER_SUBJECT =
ErrorCode.INVALID_ISSUER_SUBJECT; // -83;
public static final int KM_ERROR_BOOT_LEVEL_EXCEEDED =
ErrorCode.BOOT_LEVEL_EXCEEDED; // -84;
public static final int KM_ERROR_HARDWARE_NOT_YET_AVAILABLE =
ErrorCode.HARDWARE_NOT_YET_AVAILABLE; // -85
public static final int KM_ERROR_UNIMPLEMENTED =

View File

@@ -614,9 +614,23 @@ public class KeyStoreException extends Exception {
KEYMINT_UNIMPLEMENTED_ERROR);
sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_HARDWARE_TYPE_UNAVAILABLE,
KEYMINT_UNIMPLEMENTED_ERROR);
sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_PROOF_OF_PRESENCE_REQUIRED,
KEYMINT_INCORRECT_USAGE_ERROR);
sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_CONCURRENT_PROOF_OF_PRESENCE_REQUESTED,
KEYMINT_INCORRECT_USAGE_ERROR);
sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_NO_USER_CONFIRMATION,
KEYMINT_INCORRECT_USAGE_ERROR);
sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_DEVICE_LOCKED,
new PublicErrorInformation(IS_SYSTEM_ERROR | REQUIRES_USER_AUTHENTICATION,
ERROR_USER_AUTHENTICATION_REQUIRED));
sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_EARLY_BOOT_ENDED,
GENERAL_KEYMINT_ERROR);
sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_ATTESTATION_KEYS_NOT_PROVISIONED,
GENERAL_KEYMINT_ERROR);
sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_ATTESTATION_IDS_NOT_PROVISIONED,
GENERAL_KEYMINT_ERROR);
sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_OPERATION,
GENERAL_KEYMINT_ERROR);
sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_STORAGE_KEY_UNSUPPORTED,
KEYMINT_UNIMPLEMENTED_ERROR);
sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INCOMPATIBLE_MGF_DIGEST,
@@ -627,6 +641,12 @@ public class KeyStoreException extends Exception {
KEYMINT_INCORRECT_USAGE_ERROR);
sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_MISSING_NOT_AFTER,
KEYMINT_INCORRECT_USAGE_ERROR);
sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_MISSING_ISSUER_SUBJECT,
KEYMINT_INCORRECT_USAGE_ERROR);
sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_ISSUER_SUBJECT,
KEYMINT_INCORRECT_USAGE_ERROR);
sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_BOOT_LEVEL_EXCEEDED,
KEYMINT_INCORRECT_USAGE_ERROR);
// This should not be exposed to apps as it's handled by Keystore.
sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_HARDWARE_NOT_YET_AVAILABLE,
GENERAL_KEYMINT_ERROR);