1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.security; 18 19 import android.annotation.IntDef; 20 import android.annotation.Nullable; 21 import android.annotation.TestApi; 22 import android.security.keymaster.KeymasterDefs; 23 import android.system.keystore2.ResponseCode; 24 import android.util.Log; 25 26 import java.lang.annotation.Retention; 27 import java.lang.annotation.RetentionPolicy; 28 import java.util.HashMap; 29 import java.util.Map; 30 31 /** 32 * Exception containing information about the failure at the Keystore / KeyMint layer while 33 * generating or using a key. 34 * 35 * The public error codes indicate the cause of the error and the methods indicate whether 36 * it's a system/key issue and whether re-trying the operation (with the same key or a new key) 37 * is likely to succeed. 38 */ 39 public class KeyStoreException extends Exception { 40 private static final String TAG = "KeyStoreException"; 41 42 /** 43 * This error code is for mapping errors that the caller will not know about. If the caller is 44 * targeting an API level earlier than the one the error was introduced in, then the error will 45 * be mapped to this one. 46 * In API level 33 no errors map to this error. 47 */ 48 public static final int ERROR_OTHER = 1; 49 /** 50 * Indicating the key could not be used because the user needs to authenticate first. 51 * See 52 * {@link android.security.keystore.KeyGenParameterSpec.Builder#setUserAuthenticationRequired(boolean)}. 53 */ 54 public static final int ERROR_USER_AUTHENTICATION_REQUIRED = 2; 55 /** 56 * Indicating that {@code load()} has not been called on the Keystore instance, or an attempt 57 * has been made to generate an authorization bound key while the user has not set a lock 58 * screen knowledge factor (LSKF). Instruct the user to set an LSKF and retry. 59 */ 60 public static final int ERROR_KEYSTORE_UNINITIALIZED = 3; 61 /** 62 * An internal system error - refer to {@link #isTransientFailure()} to determine whether 63 * re-trying the operation is likely to yield different results. 64 */ 65 public static final int ERROR_INTERNAL_SYSTEM_ERROR = 4; 66 /** 67 * The caller has requested key parameters or operation which are only available to system 68 * or privileged apps. 69 */ 70 public static final int ERROR_PERMISSION_DENIED = 5; 71 /** 72 * The key the operation refers to doesn't exist. 73 */ 74 public static final int ERROR_KEY_DOES_NOT_EXIST = 6; 75 /** 76 * The key is corrupted and could not be recovered. 77 */ 78 public static final int ERROR_KEY_CORRUPTED = 7; 79 /** 80 * The error related to inclusion of device identifiers in the attestation record. 81 */ 82 public static final int ERROR_ID_ATTESTATION_FAILURE = 8; 83 /** 84 * The attestation challenge specified is too large. 85 */ 86 public static final int ERROR_ATTESTATION_CHALLENGE_TOO_LARGE = 9; 87 /** 88 * General error in the KeyMint layer. 89 */ 90 public static final int ERROR_KEYMINT_FAILURE = 10; 91 /** 92 * Failure in the Keystore layer. 93 */ 94 public static final int ERROR_KEYSTORE_FAILURE = 11; 95 /** 96 * The feature the caller is trying to use is not implemented by the underlying 97 * KeyMint implementation. 98 * This could happen when an unsupported algorithm is requested, or when trying to import 99 * a key in a format other than raw or PKCS#8. 100 */ 101 public static final int ERROR_UNIMPLEMENTED = 12; 102 /** 103 * The feature the caller is trying to use is not compatible with the parameters used to 104 * generate the key. For example, trying to use a key generated for a different signature 105 * algorithm, or a digest not specified during key creation. 106 * Another case is the attempt to generate a symmetric AES key and requesting key attestation. 107 */ 108 public static final int ERROR_INCORRECT_USAGE = 13; 109 /** 110 * The key is not currently valid: Either at has expired or it will be valid for use in the 111 * future. 112 */ 113 public static final int ERROR_KEY_NOT_TEMPORALLY_VALID = 14; 114 /** 115 * The crypto object the caller has been using held a reference to a KeyMint operation that 116 * has been evacuated (likely due to other concurrent operations taking place). 117 * The caller should re-create the crypto object and try again. 118 */ 119 public static final int ERROR_KEY_OPERATION_EXPIRED = 15; 120 /** 121 * There are no keys available for attestation. 122 * This error is returned only on devices that rely solely on remotely-provisioned keys (see 123 * <a href= 124 * "https://android-developers.googleblog.com/2022/03/upgrading-android-attestation-remote.html" 125 * >Remote Key Provisioning</a>). 126 * 127 * <p>On such a device, if the caller requests key generation and includes an attestation 128 * challenge (indicating key attestation is required), the error will be returned in one of 129 * the following cases: 130 * <ul> 131 * <li>The pool of remotely-provisioned keys has been exhausted.</li> 132 * <li>The device is not registered with the key provisioning server.</li> 133 * </ul> 134 * </p> 135 * 136 * <p>This error is a transient one if the pool of remotely-provisioned keys has been 137 * exhausted. However, if the device is not registered with the server, or the key 138 * provisioning server refuses key issuance, this is a permanent error.</p> 139 */ 140 public static final int ERROR_ATTESTATION_KEYS_UNAVAILABLE = 16; 141 /** 142 * This device requires a software upgrade to use the key provisioning server. The software 143 * is outdated and this error is returned only on devices that rely solely on 144 * remotely-provisioned keys (see <a href= 145 * "https://android-developers.googleblog.com/2022/03/upgrading-android-attestation-remote.html" 146 * >Remote Key Provisioning</a>). 147 * 148 * @hide 149 */ 150 public static final int ERROR_DEVICE_REQUIRES_UPGRADE_FOR_ATTESTATION = 17; 151 152 /** @hide */ 153 @Retention(RetentionPolicy.SOURCE) 154 @IntDef(flag = true, prefix = {"ERROR_"}, value = { 155 ERROR_OTHER, 156 ERROR_USER_AUTHENTICATION_REQUIRED, 157 ERROR_KEYSTORE_UNINITIALIZED, 158 ERROR_INTERNAL_SYSTEM_ERROR, 159 ERROR_PERMISSION_DENIED, 160 ERROR_KEY_DOES_NOT_EXIST, 161 ERROR_KEY_CORRUPTED, 162 ERROR_ID_ATTESTATION_FAILURE, 163 ERROR_ATTESTATION_CHALLENGE_TOO_LARGE, 164 ERROR_KEYMINT_FAILURE, 165 ERROR_KEYSTORE_FAILURE, 166 ERROR_UNIMPLEMENTED, 167 ERROR_INCORRECT_USAGE, 168 ERROR_KEY_NOT_TEMPORALLY_VALID, 169 ERROR_KEY_OPERATION_EXPIRED, 170 ERROR_ATTESTATION_KEYS_UNAVAILABLE, 171 ERROR_DEVICE_REQUIRES_UPGRADE_FOR_ATTESTATION, 172 }) 173 public @interface PublicErrorCode { 174 } 175 176 /** 177 * Never re-try the operation that led to this error, since it's a permanent error. 178 * 179 * This value is always returned when {@link #isTransientFailure()} is {@code false}. 180 */ 181 public static final int RETRY_NEVER = 1; 182 /** 183 * Re-try the operation that led to this error with an exponential back-off delay. 184 * The first delay should be between 5 to 30 seconds, and each subsequent re-try should double 185 * the delay time. 186 * 187 * This value is returned when {@link #isTransientFailure()} is {@code true}. 188 */ 189 public static final int RETRY_WITH_EXPONENTIAL_BACKOFF = 2; 190 /** 191 * Re-try the operation that led to this error when the device regains connectivity. 192 * Remote provisioning of keys requires reaching the remote server, and the device is 193 * currently unable to due that due to lack of network connectivity. 194 * 195 * This value is returned when {@link #isTransientFailure()} is {@code true}. 196 */ 197 public static final int RETRY_WHEN_CONNECTIVITY_AVAILABLE = 3; 198 /** 199 * Re-try the operation that led to this error when the device has a software update 200 * downloaded and on the next reboot. The Remote provisioning server recognizes 201 * the device, but refuses issuance of attestation keys because it contains a software 202 * version that could potentially be vulnerable and needs an update. Re-trying after the 203 * device has upgraded and rebooted may alleviate the problem. 204 * 205 * <p>This value is returned when {@link #isTransientFailure()} is {@code true}. 206 */ 207 public static final int RETRY_AFTER_NEXT_REBOOT = 4; 208 209 /** @hide */ 210 @Retention(RetentionPolicy.SOURCE) 211 @IntDef(flag = true, prefix = {"RETRY_"}, value = { 212 RETRY_NEVER, 213 RETRY_WITH_EXPONENTIAL_BACKOFF, 214 RETRY_WHEN_CONNECTIVITY_AVAILABLE, 215 RETRY_AFTER_NEXT_REBOOT, 216 }) 217 public @interface RetryPolicy { 218 } 219 220 // RKP-specific error information. 221 /** 222 * Remote provisioning of attestation keys has completed successfully. 223 * @hide */ 224 public static final int RKP_SUCCESS = 0; 225 /** 226 * Remotely-provisioned keys are temporarily unavailable. This could be because of RPC 227 * error when talking to the remote provisioner or keys are being currently fetched and will 228 * be available soon. 229 * @hide */ 230 public static final int RKP_TEMPORARILY_UNAVAILABLE = 1; 231 /** 232 * Permanent failure: The RKP server has declined issuance of keys to this device. Either 233 * because the device is not registered with the server or the server considers the device 234 * not to be trustworthy. 235 * @hide */ 236 public static final int RKP_SERVER_REFUSED_ISSUANCE = 2; 237 /** 238 * The RKP server is unavailable due to lack of connectivity. The caller should re-try 239 * when the device has connectivity again. 240 * @hide */ 241 public static final int RKP_FETCHING_PENDING_CONNECTIVITY = 3; 242 /** 243 * The RKP server recognizes the device, but the device may be running vulnerable software, 244 * and thus refusing issuance of RKP keys to it. 245 * 246 * @hide 247 */ 248 public static final int RKP_FETCHING_PENDING_SOFTWARE_REBOOT = 4; 249 250 // Constants for encoding information about the error encountered: 251 // Whether the error relates to the system state/implementation as a whole, or a specific key. 252 private static final int IS_SYSTEM_ERROR = 1 << 1; 253 // Whether the error is permanent. 254 private static final int IS_TRANSIENT_ERROR = 1 << 2; 255 // Whether the cause of the error is the user not having authenticated recently. 256 private static final int REQUIRES_USER_AUTHENTICATION = 1 << 3; 257 258 // The internal error code. NOT to be returned directly to callers or made part of the 259 // public API. 260 private final int mErrorCode; 261 // The Remote Key Provisioning status. Applicable if and only if {@link #mErrorCode} is equal 262 // to {@link ResponseCode.OUT_OF_KEYS}. 263 private final int mRkpStatus; 264 initializeRkpStatusForRegularErrors(int errorCode)265 private static int initializeRkpStatusForRegularErrors(int errorCode) { 266 // Check if the system code mistakenly called a constructor of KeyStoreException with 267 // the OUT_OF_KEYS error code but without RKP status. 268 if (errorCode == ResponseCode.OUT_OF_KEYS) { 269 Log.e(TAG, "RKP error code without RKP status"); 270 // Set RKP status to RKP_SERVER_REFUSED_ISSUANCE so that the caller never retries. 271 return RKP_SERVER_REFUSED_ISSUANCE; 272 } else { 273 return RKP_SUCCESS; 274 } 275 } 276 277 /** 278 * @hide 279 */ KeyStoreException(int errorCode, @Nullable String message)280 public KeyStoreException(int errorCode, @Nullable String message) { 281 super(message); 282 mErrorCode = errorCode; 283 mRkpStatus = initializeRkpStatusForRegularErrors(errorCode); 284 } 285 286 /** 287 * @hide 288 */ KeyStoreException(int errorCode, @Nullable String message, @Nullable String keystoreErrorMessage)289 public KeyStoreException(int errorCode, @Nullable String message, 290 @Nullable String keystoreErrorMessage) { 291 super(message + " (internal Keystore code: " + errorCode + " message: " 292 + keystoreErrorMessage + ")"); 293 mErrorCode = errorCode; 294 mRkpStatus = initializeRkpStatusForRegularErrors(errorCode); 295 } 296 297 /** 298 * @hide 299 */ KeyStoreException(int errorCode, @Nullable String message, int rkpStatus)300 public KeyStoreException(int errorCode, @Nullable String message, int rkpStatus) { 301 super(message); 302 mErrorCode = errorCode; 303 mRkpStatus = rkpStatus; 304 if (mErrorCode != ResponseCode.OUT_OF_KEYS) { 305 Log.e(TAG, "Providing RKP status for error code " + errorCode + " has no effect."); 306 } 307 } 308 309 /** 310 * Returns the internal error code. Only for use by the platform. 311 * 312 * @hide 313 */ 314 @TestApi getErrorCode()315 public int getErrorCode() { 316 return mErrorCode; 317 } 318 319 /** 320 * Returns one of the error codes exported by the class. 321 * 322 * @return a public error code 323 */ 324 @PublicErrorCode getNumericErrorCode()325 public int getNumericErrorCode() { 326 PublicErrorInformation failureInfo = getErrorInformation(mErrorCode); 327 return failureInfo.errorCode; 328 } 329 330 /** 331 * Returns true if the failure is a transient failure - that is, performing the same operation 332 * again at a late time is likely to succeed. 333 * 334 * If {@link #isSystemError()} returns true, the transient nature of the failure relates to the 335 * device, otherwise relates to the key (so a permanent failure with an existing key likely 336 * requires creating another key to repeat the operation with). 337 */ isTransientFailure()338 public boolean isTransientFailure() { 339 PublicErrorInformation failureInfo = getErrorInformation(mErrorCode); 340 // Special-case handling for RKP failures: 341 if (mRkpStatus != RKP_SUCCESS && mErrorCode == ResponseCode.OUT_OF_KEYS) { 342 switch (mRkpStatus) { 343 case RKP_TEMPORARILY_UNAVAILABLE: 344 case RKP_FETCHING_PENDING_CONNECTIVITY: 345 case RKP_FETCHING_PENDING_SOFTWARE_REBOOT: 346 return true; 347 case RKP_SERVER_REFUSED_ISSUANCE: 348 default: 349 return false; 350 } 351 } 352 return (failureInfo.indicators & IS_TRANSIENT_ERROR) != 0; 353 } 354 355 /** 356 * Indicates whether the failure is due to the device being locked. 357 * 358 * @return true if the key operation failed because the user has to authenticate 359 * (e.g. by unlocking the device). 360 */ requiresUserAuthentication()361 public boolean requiresUserAuthentication() { 362 PublicErrorInformation failureInfo = getErrorInformation(mErrorCode); 363 return (failureInfo.indicators & REQUIRES_USER_AUTHENTICATION) != 0; 364 } 365 366 /** 367 * Indicates whether the error related to the Keystore/KeyMint implementation and not 368 * a specific key. 369 * 370 * @return true if the error is related to the system, not the key in use. System 371 * errors indicate a feature isn't working, whereas key-related errors are likely 372 * to succeed with a new key. 373 */ isSystemError()374 public boolean isSystemError() { 375 PublicErrorInformation failureInfo = getErrorInformation(mErrorCode); 376 return (failureInfo.indicators & IS_SYSTEM_ERROR) != 0; 377 } 378 379 /** 380 * Returns the re-try policy for transient failures. Valid only if 381 * {@link #isTransientFailure()} returns {@code True}. 382 */ 383 @RetryPolicy getRetryPolicy()384 public int getRetryPolicy() { 385 PublicErrorInformation failureInfo = getErrorInformation(mErrorCode); 386 // Special-case handling for RKP failures (To be removed in API 34) 387 if (mRkpStatus != RKP_SUCCESS) { 388 switch (mRkpStatus) { 389 case RKP_TEMPORARILY_UNAVAILABLE: 390 return RETRY_WITH_EXPONENTIAL_BACKOFF; 391 case RKP_FETCHING_PENDING_CONNECTIVITY: 392 return RETRY_WHEN_CONNECTIVITY_AVAILABLE; 393 case RKP_SERVER_REFUSED_ISSUANCE: 394 return RETRY_NEVER; 395 case RKP_FETCHING_PENDING_SOFTWARE_REBOOT: 396 return RETRY_AFTER_NEXT_REBOOT; 397 default: 398 return (failureInfo.indicators & IS_TRANSIENT_ERROR) != 0 399 ? RETRY_WITH_EXPONENTIAL_BACKOFF : RETRY_NEVER; 400 } 401 } 402 switch (mErrorCode) { 403 case ResponseCode.OUT_OF_KEYS_REQUIRES_SYSTEM_UPGRADE: 404 return RETRY_AFTER_NEXT_REBOOT; 405 case ResponseCode.OUT_OF_KEYS_PENDING_INTERNET_CONNECTIVITY: 406 return RETRY_WHEN_CONNECTIVITY_AVAILABLE; 407 default: 408 return (failureInfo.indicators & IS_TRANSIENT_ERROR) != 0 409 ? RETRY_WITH_EXPONENTIAL_BACKOFF : RETRY_NEVER; 410 } 411 } 412 413 @Override toString()414 public String toString() { 415 String errorCodes = String.format(" (public error code: %d internal Keystore code: %d)", 416 getNumericErrorCode(), mErrorCode); 417 return super.toString() + errorCodes; 418 } 419 getErrorInformation(int internalErrorCode)420 private static PublicErrorInformation getErrorInformation(int internalErrorCode) { 421 PublicErrorInformation errorInfo = sErrorCodeToFailureInfo.get(internalErrorCode); 422 if (errorInfo != null) { 423 return errorInfo; 424 } 425 426 /** 427 * KeyStore/keymaster exception with positive error codes coming from the KeyStore and 428 * negative ones from keymaster. 429 * This is a safety fall-back: All error codes should be present in the map. 430 */ 431 if (internalErrorCode > 0) { 432 return GENERAL_KEYSTORE_ERROR; 433 } else { 434 return GENERAL_KEYMINT_ERROR; 435 } 436 } 437 438 private static final class PublicErrorInformation { 439 public final int indicators; 440 public final int errorCode; 441 PublicErrorInformation(int indicators, @PublicErrorCode int errorCode)442 PublicErrorInformation(int indicators, @PublicErrorCode int errorCode) { 443 this.indicators = indicators; 444 this.errorCode = errorCode; 445 } 446 } 447 448 private static final PublicErrorInformation GENERAL_KEYMINT_ERROR = 449 new PublicErrorInformation(0, ERROR_KEYMINT_FAILURE); 450 451 private static final PublicErrorInformation GENERAL_KEYSTORE_ERROR = 452 new PublicErrorInformation(0, ERROR_KEYSTORE_FAILURE); 453 454 private static final PublicErrorInformation KEYMINT_UNIMPLEMENTED_ERROR = 455 new PublicErrorInformation(IS_SYSTEM_ERROR, ERROR_UNIMPLEMENTED); 456 457 private static final PublicErrorInformation KEYMINT_RETRYABLE_ERROR = 458 new PublicErrorInformation(IS_SYSTEM_ERROR | IS_TRANSIENT_ERROR, 459 ERROR_KEYMINT_FAILURE); 460 461 private static final PublicErrorInformation KEYMINT_INCORRECT_USAGE_ERROR = 462 new PublicErrorInformation(0, ERROR_INCORRECT_USAGE); 463 464 private static final PublicErrorInformation KEYMINT_TEMPORAL_VALIDITY_ERROR = 465 new PublicErrorInformation(0, ERROR_KEY_NOT_TEMPORALLY_VALID); 466 467 468 private static final Map<Integer, PublicErrorInformation> sErrorCodeToFailureInfo = 469 new HashMap(); 470 471 /** 472 * @hide 473 */ 474 @TestApi hasFailureInfoForError(int internalErrorCode)475 public static boolean hasFailureInfoForError(int internalErrorCode) { 476 return sErrorCodeToFailureInfo.containsKey(internalErrorCode); 477 } 478 479 static { 480 // KeyMint error codes sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_OK, GENERAL_KEYMINT_ERROR)481 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_OK, GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_ROOT_OF_TRUST_ALREADY_SET, GENERAL_KEYMINT_ERROR)482 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_ROOT_OF_TRUST_ALREADY_SET, 483 GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_PURPOSE, KEYMINT_INCORRECT_USAGE_ERROR)484 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_PURPOSE, 485 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INCOMPATIBLE_PURPOSE, KEYMINT_INCORRECT_USAGE_ERROR)486 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INCOMPATIBLE_PURPOSE, 487 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_ALGORITHM, KEYMINT_UNIMPLEMENTED_ERROR)488 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_ALGORITHM, 489 KEYMINT_UNIMPLEMENTED_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INCOMPATIBLE_ALGORITHM, KEYMINT_INCORRECT_USAGE_ERROR)490 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INCOMPATIBLE_ALGORITHM, 491 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_KEY_SIZE, KEYMINT_UNIMPLEMENTED_ERROR)492 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_KEY_SIZE, 493 KEYMINT_UNIMPLEMENTED_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_BLOCK_MODE, KEYMINT_UNIMPLEMENTED_ERROR)494 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_BLOCK_MODE, 495 KEYMINT_UNIMPLEMENTED_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INCOMPATIBLE_BLOCK_MODE, KEYMINT_INCORRECT_USAGE_ERROR)496 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INCOMPATIBLE_BLOCK_MODE, 497 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_MAC_LENGTH, KEYMINT_UNIMPLEMENTED_ERROR)498 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_MAC_LENGTH, 499 KEYMINT_UNIMPLEMENTED_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_PADDING_MODE, KEYMINT_INCORRECT_USAGE_ERROR)500 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_PADDING_MODE, 501 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INCOMPATIBLE_PADDING_MODE, KEYMINT_INCORRECT_USAGE_ERROR)502 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INCOMPATIBLE_PADDING_MODE, 503 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_DIGEST, KEYMINT_UNIMPLEMENTED_ERROR)504 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_DIGEST, 505 KEYMINT_UNIMPLEMENTED_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INCOMPATIBLE_DIGEST, KEYMINT_INCORRECT_USAGE_ERROR)506 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INCOMPATIBLE_DIGEST, 507 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_EXPIRATION_TIME, KEYMINT_INCORRECT_USAGE_ERROR)508 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_EXPIRATION_TIME, 509 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_USER_ID, GENERAL_KEYMINT_ERROR)510 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_USER_ID, 511 GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_AUTHORIZATION_TIMEOUT, KEYMINT_INCORRECT_USAGE_ERROR)512 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_AUTHORIZATION_TIMEOUT, 513 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_KEY_FORMAT, KEYMINT_INCORRECT_USAGE_ERROR)514 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_KEY_FORMAT, 515 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INCOMPATIBLE_KEY_FORMAT, KEYMINT_INCORRECT_USAGE_ERROR)516 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INCOMPATIBLE_KEY_FORMAT, 517 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM, KEYMINT_UNIMPLEMENTED_ERROR)518 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM, 519 KEYMINT_UNIMPLEMENTED_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_KEY_VERIFICATION_ALGORITHM, KEYMINT_UNIMPLEMENTED_ERROR)520 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_KEY_VERIFICATION_ALGORITHM, 521 KEYMINT_UNIMPLEMENTED_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_INPUT_LENGTH, KEYMINT_INCORRECT_USAGE_ERROR)522 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_INPUT_LENGTH, 523 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_KEY_EXPORT_OPTIONS_INVALID, KEYMINT_INCORRECT_USAGE_ERROR)524 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_KEY_EXPORT_OPTIONS_INVALID, 525 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_DELEGATION_NOT_ALLOWED, GENERAL_KEYMINT_ERROR)526 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_DELEGATION_NOT_ALLOWED, 527 GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_KEY_NOT_YET_VALID, KEYMINT_TEMPORAL_VALIDITY_ERROR)528 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_KEY_NOT_YET_VALID, 529 KEYMINT_TEMPORAL_VALIDITY_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_KEY_EXPIRED, KEYMINT_TEMPORAL_VALIDITY_ERROR)530 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_KEY_EXPIRED, 531 KEYMINT_TEMPORAL_VALIDITY_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_KEY_USER_NOT_AUTHENTICATED, new PublicErrorInformation(REQUIRES_USER_AUTHENTICATION, ERROR_USER_AUTHENTICATION_REQUIRED))532 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_KEY_USER_NOT_AUTHENTICATED, 533 new PublicErrorInformation(REQUIRES_USER_AUTHENTICATION, 534 ERROR_USER_AUTHENTICATION_REQUIRED)); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_OUTPUT_PARAMETER_NULL, GENERAL_KEYMINT_ERROR)535 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_OUTPUT_PARAMETER_NULL, 536 GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_OPERATION_HANDLE, new PublicErrorInformation(IS_SYSTEM_ERROR | IS_TRANSIENT_ERROR, ERROR_KEY_OPERATION_EXPIRED))537 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_OPERATION_HANDLE, 538 new PublicErrorInformation(IS_SYSTEM_ERROR | IS_TRANSIENT_ERROR, 539 ERROR_KEY_OPERATION_EXPIRED)); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INSUFFICIENT_BUFFER_SPACE, GENERAL_KEYMINT_ERROR)540 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INSUFFICIENT_BUFFER_SPACE, 541 GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_VERIFICATION_FAILED, GENERAL_KEYMINT_ERROR)542 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_VERIFICATION_FAILED, 543 GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_TOO_MANY_OPERATIONS, GENERAL_KEYMINT_ERROR)544 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_TOO_MANY_OPERATIONS, 545 GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNEXPECTED_NULL_POINTER, GENERAL_KEYMINT_ERROR)546 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNEXPECTED_NULL_POINTER, 547 GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_KEY_BLOB, GENERAL_KEYMINT_ERROR)548 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_KEY_BLOB, 549 GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_IMPORTED_KEY_NOT_ENCRYPTED, KEYMINT_INCORRECT_USAGE_ERROR)550 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_IMPORTED_KEY_NOT_ENCRYPTED, 551 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_IMPORTED_KEY_DECRYPTION_FAILED, KEYMINT_INCORRECT_USAGE_ERROR)552 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_IMPORTED_KEY_DECRYPTION_FAILED, 553 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_IMPORTED_KEY_NOT_SIGNED, KEYMINT_INCORRECT_USAGE_ERROR)554 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_IMPORTED_KEY_NOT_SIGNED, 555 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_IMPORTED_KEY_VERIFICATION_FAILED, KEYMINT_INCORRECT_USAGE_ERROR)556 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_IMPORTED_KEY_VERIFICATION_FAILED, 557 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_ARGUMENT, GENERAL_KEYMINT_ERROR)558 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_ARGUMENT, 559 GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_TAG, KEYMINT_UNIMPLEMENTED_ERROR)560 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_TAG, 561 KEYMINT_UNIMPLEMENTED_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_TAG, KEYMINT_INCORRECT_USAGE_ERROR)562 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_TAG, 563 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_MEMORY_ALLOCATION_FAILED, GENERAL_KEYMINT_ERROR)564 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_MEMORY_ALLOCATION_FAILED, 565 GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_IMPORT_PARAMETER_MISMATCH, GENERAL_KEYMINT_ERROR)566 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_IMPORT_PARAMETER_MISMATCH, 567 GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_SECURE_HW_ACCESS_DENIED, GENERAL_KEYMINT_ERROR)568 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_SECURE_HW_ACCESS_DENIED, 569 GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_OPERATION_CANCELLED, GENERAL_KEYMINT_ERROR)570 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_OPERATION_CANCELLED, 571 GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_CONCURRENT_ACCESS_CONFLICT, GENERAL_KEYMINT_ERROR)572 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_CONCURRENT_ACCESS_CONFLICT, 573 GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_SECURE_HW_BUSY, KEYMINT_RETRYABLE_ERROR)574 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_SECURE_HW_BUSY, 575 KEYMINT_RETRYABLE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_SECURE_HW_COMMUNICATION_FAILED, KEYMINT_RETRYABLE_ERROR)576 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_SECURE_HW_COMMUNICATION_FAILED, 577 KEYMINT_RETRYABLE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_EC_FIELD, KEYMINT_UNIMPLEMENTED_ERROR)578 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_EC_FIELD, 579 KEYMINT_UNIMPLEMENTED_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_MISSING_NONCE, KEYMINT_INCORRECT_USAGE_ERROR)580 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_MISSING_NONCE, 581 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_NONCE, KEYMINT_INCORRECT_USAGE_ERROR)582 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_NONCE, 583 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_MISSING_MAC_LENGTH, KEYMINT_INCORRECT_USAGE_ERROR)584 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_MISSING_MAC_LENGTH, 585 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_KEY_RATE_LIMIT_EXCEEDED, KEYMINT_RETRYABLE_ERROR)586 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_KEY_RATE_LIMIT_EXCEEDED, 587 KEYMINT_RETRYABLE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_CALLER_NONCE_PROHIBITED, GENERAL_KEYMINT_ERROR)588 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_CALLER_NONCE_PROHIBITED, 589 GENERAL_KEYMINT_ERROR); 590 // Error related to MAX_USES_PER_BOOT, restricting the number of uses per boot. 591 // It is not re-tryable. sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_KEY_MAX_OPS_EXCEEDED, GENERAL_KEYMINT_ERROR)592 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_KEY_MAX_OPS_EXCEEDED, 593 GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_MAC_LENGTH, KEYMINT_INCORRECT_USAGE_ERROR)594 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_MAC_LENGTH, 595 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_MISSING_MIN_MAC_LENGTH, KEYMINT_INCORRECT_USAGE_ERROR)596 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_MISSING_MIN_MAC_LENGTH, 597 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_MIN_MAC_LENGTH, KEYMINT_INCORRECT_USAGE_ERROR)598 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_MIN_MAC_LENGTH, 599 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_KDF, KEYMINT_UNIMPLEMENTED_ERROR)600 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_KDF, 601 KEYMINT_UNIMPLEMENTED_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_EC_CURVE, KEYMINT_UNIMPLEMENTED_ERROR)602 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_EC_CURVE, 603 KEYMINT_UNIMPLEMENTED_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_ATTESTATION_CHALLENGE_MISSING, KEYMINT_INCORRECT_USAGE_ERROR)604 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_ATTESTATION_CHALLENGE_MISSING, 605 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_KEYMINT_NOT_CONFIGURED, new PublicErrorInformation(IS_SYSTEM_ERROR, ERROR_KEYMINT_FAILURE))606 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_KEYMINT_NOT_CONFIGURED, 607 new PublicErrorInformation(IS_SYSTEM_ERROR, ERROR_KEYMINT_FAILURE)); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_ATTESTATION_APPLICATION_ID_MISSING, KEYMINT_RETRYABLE_ERROR)608 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_ATTESTATION_APPLICATION_ID_MISSING, 609 KEYMINT_RETRYABLE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_CANNOT_ATTEST_IDS, new PublicErrorInformation(IS_SYSTEM_ERROR, ERROR_ID_ATTESTATION_FAILURE))610 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_CANNOT_ATTEST_IDS, 611 new PublicErrorInformation(IS_SYSTEM_ERROR, 612 ERROR_ID_ATTESTATION_FAILURE)); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_ROLLBACK_RESISTANCE_UNAVAILABLE, KEYMINT_UNIMPLEMENTED_ERROR)613 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_ROLLBACK_RESISTANCE_UNAVAILABLE, 614 KEYMINT_UNIMPLEMENTED_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_HARDWARE_TYPE_UNAVAILABLE, KEYMINT_UNIMPLEMENTED_ERROR)615 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_HARDWARE_TYPE_UNAVAILABLE, 616 KEYMINT_UNIMPLEMENTED_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_PROOF_OF_PRESENCE_REQUIRED, KEYMINT_INCORRECT_USAGE_ERROR)617 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_PROOF_OF_PRESENCE_REQUIRED, 618 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_CONCURRENT_PROOF_OF_PRESENCE_REQUESTED, KEYMINT_INCORRECT_USAGE_ERROR)619 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_CONCURRENT_PROOF_OF_PRESENCE_REQUESTED, 620 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_NO_USER_CONFIRMATION, KEYMINT_INCORRECT_USAGE_ERROR)621 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_NO_USER_CONFIRMATION, 622 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_DEVICE_LOCKED, new PublicErrorInformation(IS_SYSTEM_ERROR | REQUIRES_USER_AUTHENTICATION, ERROR_USER_AUTHENTICATION_REQUIRED))623 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_DEVICE_LOCKED, 624 new PublicErrorInformation(IS_SYSTEM_ERROR | REQUIRES_USER_AUTHENTICATION, 625 ERROR_USER_AUTHENTICATION_REQUIRED)); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_EARLY_BOOT_ENDED, GENERAL_KEYMINT_ERROR)626 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_EARLY_BOOT_ENDED, 627 GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_ATTESTATION_KEYS_NOT_PROVISIONED, GENERAL_KEYMINT_ERROR)628 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_ATTESTATION_KEYS_NOT_PROVISIONED, 629 GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_ATTESTATION_IDS_NOT_PROVISIONED, GENERAL_KEYMINT_ERROR)630 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_ATTESTATION_IDS_NOT_PROVISIONED, 631 GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_OPERATION, GENERAL_KEYMINT_ERROR)632 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_OPERATION, 633 GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_STORAGE_KEY_UNSUPPORTED, KEYMINT_UNIMPLEMENTED_ERROR)634 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_STORAGE_KEY_UNSUPPORTED, 635 KEYMINT_UNIMPLEMENTED_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INCOMPATIBLE_MGF_DIGEST, KEYMINT_INCORRECT_USAGE_ERROR)636 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INCOMPATIBLE_MGF_DIGEST, 637 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_MGF_DIGEST, KEYMINT_UNIMPLEMENTED_ERROR)638 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNSUPPORTED_MGF_DIGEST, 639 KEYMINT_UNIMPLEMENTED_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_MISSING_NOT_BEFORE, KEYMINT_INCORRECT_USAGE_ERROR)640 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_MISSING_NOT_BEFORE, 641 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_MISSING_NOT_AFTER, KEYMINT_INCORRECT_USAGE_ERROR)642 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_MISSING_NOT_AFTER, 643 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_MISSING_ISSUER_SUBJECT, KEYMINT_INCORRECT_USAGE_ERROR)644 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_MISSING_ISSUER_SUBJECT, 645 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_ISSUER_SUBJECT, KEYMINT_INCORRECT_USAGE_ERROR)646 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_INVALID_ISSUER_SUBJECT, 647 KEYMINT_INCORRECT_USAGE_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_BOOT_LEVEL_EXCEEDED, KEYMINT_INCORRECT_USAGE_ERROR)648 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_BOOT_LEVEL_EXCEEDED, 649 KEYMINT_INCORRECT_USAGE_ERROR); 650 // 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)651 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_HARDWARE_NOT_YET_AVAILABLE, 652 GENERAL_KEYMINT_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNIMPLEMENTED, KEYMINT_UNIMPLEMENTED_ERROR)653 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNIMPLEMENTED, 654 KEYMINT_UNIMPLEMENTED_ERROR); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNKNOWN_ERROR, new PublicErrorInformation(IS_SYSTEM_ERROR, ERROR_KEYMINT_FAILURE))655 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_UNKNOWN_ERROR, 656 new PublicErrorInformation(IS_SYSTEM_ERROR, 657 ERROR_KEYMINT_FAILURE)); sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_VERSION_MISMATCH, GENERAL_KEYMINT_ERROR)658 sErrorCodeToFailureInfo.put(KeymasterDefs.KM_ERROR_VERSION_MISMATCH, GENERAL_KEYMINT_ERROR); 659 660 // Keystore error codes sErrorCodeToFailureInfo.put(ResponseCode.LOCKED, new PublicErrorInformation(REQUIRES_USER_AUTHENTICATION, ERROR_USER_AUTHENTICATION_REQUIRED))661 sErrorCodeToFailureInfo.put(ResponseCode.LOCKED, 662 new PublicErrorInformation(REQUIRES_USER_AUTHENTICATION, 663 ERROR_USER_AUTHENTICATION_REQUIRED)); sErrorCodeToFailureInfo.put(ResponseCode.UNINITIALIZED, new PublicErrorInformation(IS_SYSTEM_ERROR, ERROR_KEYSTORE_UNINITIALIZED))664 sErrorCodeToFailureInfo.put(ResponseCode.UNINITIALIZED, 665 new PublicErrorInformation(IS_SYSTEM_ERROR, ERROR_KEYSTORE_UNINITIALIZED)); sErrorCodeToFailureInfo.put(ResponseCode.SYSTEM_ERROR, new PublicErrorInformation(IS_SYSTEM_ERROR, ERROR_INTERNAL_SYSTEM_ERROR))666 sErrorCodeToFailureInfo.put(ResponseCode.SYSTEM_ERROR, 667 new PublicErrorInformation(IS_SYSTEM_ERROR, 668 ERROR_INTERNAL_SYSTEM_ERROR)); sErrorCodeToFailureInfo.put(ResponseCode.PERMISSION_DENIED, new PublicErrorInformation(0, ERROR_PERMISSION_DENIED))669 sErrorCodeToFailureInfo.put(ResponseCode.PERMISSION_DENIED, 670 new PublicErrorInformation(0, ERROR_PERMISSION_DENIED)); sErrorCodeToFailureInfo.put(ResponseCode.KEY_NOT_FOUND, new PublicErrorInformation(0, ERROR_KEY_DOES_NOT_EXIST))671 sErrorCodeToFailureInfo.put(ResponseCode.KEY_NOT_FOUND, 672 new PublicErrorInformation(0, ERROR_KEY_DOES_NOT_EXIST)); sErrorCodeToFailureInfo.put(ResponseCode.VALUE_CORRUPTED, new PublicErrorInformation(0, ERROR_KEY_CORRUPTED))673 sErrorCodeToFailureInfo.put(ResponseCode.VALUE_CORRUPTED, 674 new PublicErrorInformation(0, ERROR_KEY_CORRUPTED)); sErrorCodeToFailureInfo.put(ResponseCode.KEY_PERMANENTLY_INVALIDATED, new PublicErrorInformation(0, ERROR_KEY_DOES_NOT_EXIST))675 sErrorCodeToFailureInfo.put(ResponseCode.KEY_PERMANENTLY_INVALIDATED, 676 new PublicErrorInformation(0, ERROR_KEY_DOES_NOT_EXIST)); sErrorCodeToFailureInfo.put(ResponseCode.OUT_OF_KEYS, new PublicErrorInformation(IS_SYSTEM_ERROR, ERROR_ATTESTATION_KEYS_UNAVAILABLE))677 sErrorCodeToFailureInfo.put(ResponseCode.OUT_OF_KEYS, 678 new PublicErrorInformation(IS_SYSTEM_ERROR, ERROR_ATTESTATION_KEYS_UNAVAILABLE)); sErrorCodeToFailureInfo.put(ResponseCode.OUT_OF_KEYS_REQUIRES_SYSTEM_UPGRADE, new PublicErrorInformation(IS_SYSTEM_ERROR | IS_TRANSIENT_ERROR, ERROR_DEVICE_REQUIRES_UPGRADE_FOR_ATTESTATION))679 sErrorCodeToFailureInfo.put(ResponseCode.OUT_OF_KEYS_REQUIRES_SYSTEM_UPGRADE, 680 new PublicErrorInformation(IS_SYSTEM_ERROR | IS_TRANSIENT_ERROR, 681 ERROR_DEVICE_REQUIRES_UPGRADE_FOR_ATTESTATION)); sErrorCodeToFailureInfo.put(ResponseCode.GET_ATTESTATION_APPLICATION_ID_FAILED, new PublicErrorInformation(IS_SYSTEM_ERROR | IS_TRANSIENT_ERROR, ERROR_INTERNAL_SYSTEM_ERROR))682 sErrorCodeToFailureInfo.put(ResponseCode.GET_ATTESTATION_APPLICATION_ID_FAILED, 683 new PublicErrorInformation(IS_SYSTEM_ERROR | IS_TRANSIENT_ERROR, 684 ERROR_INTERNAL_SYSTEM_ERROR)); sErrorCodeToFailureInfo.put(ResponseCode.OUT_OF_KEYS_PENDING_INTERNET_CONNECTIVITY, new PublicErrorInformation(IS_SYSTEM_ERROR | IS_TRANSIENT_ERROR, ERROR_ATTESTATION_KEYS_UNAVAILABLE))685 sErrorCodeToFailureInfo.put(ResponseCode.OUT_OF_KEYS_PENDING_INTERNET_CONNECTIVITY, 686 new PublicErrorInformation(IS_SYSTEM_ERROR | IS_TRANSIENT_ERROR, 687 ERROR_ATTESTATION_KEYS_UNAVAILABLE)); sErrorCodeToFailureInfo.put(ResponseCode.OUT_OF_KEYS_TRANSIENT_ERROR, new PublicErrorInformation(IS_SYSTEM_ERROR | IS_TRANSIENT_ERROR, ERROR_ATTESTATION_KEYS_UNAVAILABLE))688 sErrorCodeToFailureInfo.put(ResponseCode.OUT_OF_KEYS_TRANSIENT_ERROR, 689 new PublicErrorInformation(IS_SYSTEM_ERROR | IS_TRANSIENT_ERROR, 690 ERROR_ATTESTATION_KEYS_UNAVAILABLE)); sErrorCodeToFailureInfo.put(ResponseCode.OUT_OF_KEYS_PERMANENT_ERROR, new PublicErrorInformation(IS_SYSTEM_ERROR, ERROR_ATTESTATION_KEYS_UNAVAILABLE))691 sErrorCodeToFailureInfo.put(ResponseCode.OUT_OF_KEYS_PERMANENT_ERROR, 692 new PublicErrorInformation(IS_SYSTEM_ERROR, ERROR_ATTESTATION_KEYS_UNAVAILABLE)); 693 } 694 } 695