| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.security.keymaster; |
| 18 |
|
| 19 |
import android.hardware.security.keymint.Algorithm; |
| 20 |
import android.hardware.security.keymint.BlockMode; |
| 21 |
import android.hardware.security.keymint.Digest; |
| 22 |
import android.hardware.security.keymint.ErrorCode; |
| 23 |
import android.hardware.security.keymint.HardwareAuthenticatorType; |
| 24 |
import android.hardware.security.keymint.KeyFormat; |
| 25 |
import android.hardware.security.keymint.KeyOrigin; |
| 26 |
import android.hardware.security.keymint.KeyPurpose; |
| 27 |
import android.hardware.security.keymint.PaddingMode; |
| 28 |
import android.hardware.security.keymint.SecurityLevel; |
| 29 |
import android.hardware.security.keymint.Tag; |
| 30 |
import android.hardware.security.keymint.TagType; |
| 31 |
|
| 32 |
import java.util.HashMap; |
| 33 |
import java.util.Map; |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
public final class KeymasterDefs { |
| 42 |
|
| 43 |
private KeymasterDefs() {} |
| 44 |
|
| 45 |
|
| 46 |
public static final int KM_INVALID = TagType.INVALID; |
| 47 |
public static final int KM_ENUM = TagType.ENUM; |
| 48 |
public static final int KM_ENUM_REP = TagType.ENUM_REP; |
| 49 |
public static final int KM_UINT = TagType.UINT; |
| 50 |
public static final int KM_UINT_REP = TagType.UINT_REP; |
| 51 |
public static final int KM_ULONG = TagType.ULONG; |
| 52 |
public static final int KM_DATE = TagType.DATE; |
| 53 |
public static final int KM_BOOL = TagType.BOOL; |
| 54 |
public static final int KM_BIGNUM = TagType.BIGNUM; |
| 55 |
public static final int KM_BYTES = TagType.BYTES; |
| 56 |
public static final int KM_ULONG_REP = TagType.ULONG_REP; |
| 57 |
|
| 58 |
|
| 59 |
public static final int KM_TAG_INVALID = Tag.INVALID; |
| 60 |
public static final int KM_TAG_PURPOSE = Tag.PURPOSE; |
| 61 |
public static final int KM_TAG_ALGORITHM = Tag.ALGORITHM; |
| 62 |
public static final int KM_TAG_KEY_SIZE = Tag.KEY_SIZE; |
| 63 |
public static final int KM_TAG_BLOCK_MODE = Tag.BLOCK_MODE; |
| 64 |
public static final int KM_TAG_DIGEST = Tag.DIGEST; |
| 65 |
public static final int KM_TAG_PADDING = Tag.PADDING; |
| 66 |
public static final int KM_TAG_CALLER_NONCE = Tag.CALLER_NONCE; |
| 67 |
public static final int KM_TAG_MIN_MAC_LENGTH = Tag.MIN_MAC_LENGTH; |
| 68 |
public static final int KM_TAG_EC_CURVE = Tag.EC_CURVE; |
| 69 |
|
| 70 |
public static final int KM_TAG_RSA_PUBLIC_EXPONENT = Tag.RSA_PUBLIC_EXPONENT; |
| 71 |
public static final int KM_TAG_INCLUDE_UNIQUE_ID = Tag.INCLUDE_UNIQUE_ID; |
| 72 |
public static final int KM_TAG_RSA_OAEP_MGF_DIGEST = Tag.RSA_OAEP_MGF_DIGEST; |
| 73 |
|
| 74 |
|
| 75 |
public static final int KM_TAG_ACTIVE_DATETIME = Tag.ACTIVE_DATETIME; |
| 76 |
public static final int KM_TAG_ORIGINATION_EXPIRE_DATETIME = |
| 77 |
Tag.ORIGINATION_EXPIRE_DATETIME; |
| 78 |
public static final int KM_TAG_USAGE_EXPIRE_DATETIME = |
| 79 |
Tag.USAGE_EXPIRE_DATETIME; |
| 80 |
public static final int KM_TAG_MIN_SECONDS_BETWEEN_OPS = |
| 81 |
Tag.MIN_SECONDS_BETWEEN_OPS; |
| 82 |
public static final int KM_TAG_MAX_USES_PER_BOOT = Tag.MAX_USES_PER_BOOT; |
| 83 |
public static final int KM_TAG_USAGE_COUNT_LIMIT = Tag.USAGE_COUNT_LIMIT; |
| 84 |
|
| 85 |
public static final int KM_TAG_USER_ID = Tag.USER_ID; |
| 86 |
public static final int KM_TAG_USER_SECURE_ID = Tag.USER_SECURE_ID; |
| 87 |
public static final int KM_TAG_NO_AUTH_REQUIRED = Tag.NO_AUTH_REQUIRED; |
| 88 |
public static final int KM_TAG_USER_AUTH_TYPE = Tag.USER_AUTH_TYPE; |
| 89 |
public static final int KM_TAG_AUTH_TIMEOUT = Tag.AUTH_TIMEOUT; |
| 90 |
public static final int KM_TAG_ALLOW_WHILE_ON_BODY = Tag.ALLOW_WHILE_ON_BODY; |
| 91 |
public static final int KM_TAG_TRUSTED_USER_PRESENCE_REQUIRED = |
| 92 |
Tag.TRUSTED_USER_PRESENCE_REQUIRED; |
| 93 |
public static final int KM_TAG_TRUSTED_CONFIRMATION_REQUIRED = |
| 94 |
Tag.TRUSTED_CONFIRMATION_REQUIRED; |
| 95 |
public static final int KM_TAG_UNLOCKED_DEVICE_REQUIRED = |
| 96 |
Tag.UNLOCKED_DEVICE_REQUIRED; |
| 97 |
|
| 98 |
public static final int KM_TAG_APPLICATION_ID = Tag.APPLICATION_ID; |
| 99 |
|
| 100 |
public static final int KM_TAG_CREATION_DATETIME = Tag.CREATION_DATETIME; |
| 101 |
public static final int KM_TAG_ORIGIN = Tag.ORIGIN; |
| 102 |
public static final int KM_TAG_ROLLBACK_RESISTANT = Tag.ROLLBACK_RESISTANCE; |
| 103 |
public static final int KM_TAG_ROOT_OF_TRUST = Tag.ROOT_OF_TRUST; |
| 104 |
public static final int KM_TAG_UNIQUE_ID = Tag.UNIQUE_ID; |
| 105 |
public static final int KM_TAG_ATTESTATION_CHALLENGE = |
| 106 |
Tag.ATTESTATION_CHALLENGE; |
| 107 |
public static final int KM_TAG_ATTESTATION_ID_BRAND = |
| 108 |
Tag.ATTESTATION_ID_BRAND; |
| 109 |
public static final int KM_TAG_ATTESTATION_ID_DEVICE = |
| 110 |
Tag.ATTESTATION_ID_DEVICE; |
| 111 |
public static final int KM_TAG_ATTESTATION_ID_PRODUCT = |
| 112 |
Tag.ATTESTATION_ID_PRODUCT; |
| 113 |
public static final int KM_TAG_ATTESTATION_ID_SERIAL = |
| 114 |
Tag.ATTESTATION_ID_SERIAL; |
| 115 |
public static final int KM_TAG_ATTESTATION_ID_IMEI = |
| 116 |
Tag.ATTESTATION_ID_IMEI; |
| 117 |
public static final int KM_TAG_ATTESTATION_ID_MEID = |
| 118 |
Tag.ATTESTATION_ID_MEID; |
| 119 |
public static final int KM_TAG_ATTESTATION_ID_MANUFACTURER = |
| 120 |
Tag.ATTESTATION_ID_MANUFACTURER; |
| 121 |
public static final int KM_TAG_ATTESTATION_ID_MODEL = |
| 122 |
Tag.ATTESTATION_ID_MODEL; |
| 123 |
public static final int KM_TAG_VENDOR_PATCHLEVEL = |
| 124 |
Tag.VENDOR_PATCHLEVEL; |
| 125 |
public static final int KM_TAG_BOOT_PATCHLEVEL = |
| 126 |
Tag.BOOT_PATCHLEVEL; |
| 127 |
public static final int KM_TAG_DEVICE_UNIQUE_ATTESTATION = |
| 128 |
Tag.DEVICE_UNIQUE_ATTESTATION; |
| 129 |
public static final int KM_TAG_ATTESTATION_ID_SECOND_IMEI = |
| 130 |
Tag.ATTESTATION_ID_SECOND_IMEI; |
| 131 |
|
| 132 |
public static final int KM_TAG_NONCE = Tag.NONCE; |
| 133 |
public static final int KM_TAG_MAC_LENGTH = Tag.MAC_LENGTH; |
| 134 |
public static final int KM_TAG_RESET_SINCE_ID_ROTATION = |
| 135 |
Tag.RESET_SINCE_ID_ROTATION; |
| 136 |
public static final int KM_TAG_CONFIRMATION_TOKEN = Tag.CONFIRMATION_TOKEN; |
| 137 |
public static final int KM_TAG_CERTIFICATE_SERIAL = Tag.CERTIFICATE_SERIAL; |
| 138 |
public static final int KM_TAG_CERTIFICATE_SUBJECT = Tag.CERTIFICATE_SUBJECT; |
| 139 |
public static final int KM_TAG_CERTIFICATE_NOT_BEFORE = |
| 140 |
Tag.CERTIFICATE_NOT_BEFORE; |
| 141 |
public static final int KM_TAG_CERTIFICATE_NOT_AFTER = |
| 142 |
Tag.CERTIFICATE_NOT_AFTER; |
| 143 |
|
| 144 |
|
| 145 |
public static final int KM_ALGORITHM_RSA = Algorithm.RSA; |
| 146 |
public static final int KM_ALGORITHM_EC = Algorithm.EC; |
| 147 |
public static final int KM_ALGORITHM_AES = Algorithm.AES; |
| 148 |
public static final int KM_ALGORITHM_3DES = Algorithm.TRIPLE_DES; |
| 149 |
public static final int KM_ALGORITHM_HMAC = Algorithm.HMAC; |
| 150 |
|
| 151 |
|
| 152 |
public static final int KM_MODE_ECB = BlockMode.ECB; |
| 153 |
public static final int KM_MODE_CBC = BlockMode.CBC; |
| 154 |
public static final int KM_MODE_CTR = BlockMode.CTR; |
| 155 |
public static final int KM_MODE_GCM = BlockMode.GCM; |
| 156 |
|
| 157 |
|
| 158 |
public static final int KM_PAD_NONE = PaddingMode.NONE; |
| 159 |
public static final int KM_PAD_RSA_OAEP = PaddingMode.RSA_OAEP; |
| 160 |
public static final int KM_PAD_RSA_PSS = PaddingMode.RSA_PSS; |
| 161 |
public static final int KM_PAD_RSA_PKCS1_1_5_ENCRYPT = PaddingMode.RSA_PKCS1_1_5_ENCRYPT; |
| 162 |
public static final int KM_PAD_RSA_PKCS1_1_5_SIGN = PaddingMode.RSA_PKCS1_1_5_SIGN; |
| 163 |
public static final int KM_PAD_PKCS7 = PaddingMode.PKCS7; |
| 164 |
|
| 165 |
|
| 166 |
public static final int KM_DIGEST_NONE = Digest.NONE; |
| 167 |
public static final int KM_DIGEST_MD5 = Digest.MD5; |
| 168 |
public static final int KM_DIGEST_SHA1 = Digest.SHA1; |
| 169 |
public static final int KM_DIGEST_SHA_2_224 = Digest.SHA_2_224; |
| 170 |
public static final int KM_DIGEST_SHA_2_256 = Digest.SHA_2_256; |
| 171 |
public static final int KM_DIGEST_SHA_2_384 = Digest.SHA_2_384; |
| 172 |
public static final int KM_DIGEST_SHA_2_512 = Digest.SHA_2_512; |
| 173 |
|
| 174 |
|
| 175 |
public static final int KM_ORIGIN_GENERATED = KeyOrigin.GENERATED; |
| 176 |
public static final int KM_ORIGIN_DERIVED = KeyOrigin.DERIVED; |
| 177 |
public static final int KM_ORIGIN_IMPORTED = KeyOrigin.IMPORTED; |
| 178 |
public static final int KM_ORIGIN_UNKNOWN = KeyOrigin.RESERVED; |
| 179 |
public static final int KM_ORIGIN_SECURELY_IMPORTED = KeyOrigin.SECURELY_IMPORTED; |
| 180 |
|
| 181 |
|
| 182 |
public static final int KM_BLOB_STANDALONE = 0; |
| 183 |
public static final int KM_BLOB_REQUIRES_FILE_SYSTEM = 1; |
| 184 |
|
| 185 |
|
| 186 |
public static final int KM_PURPOSE_ENCRYPT = KeyPurpose.ENCRYPT; |
| 187 |
public static final int KM_PURPOSE_DECRYPT = KeyPurpose.DECRYPT; |
| 188 |
public static final int KM_PURPOSE_SIGN = KeyPurpose.SIGN; |
| 189 |
public static final int KM_PURPOSE_VERIFY = KeyPurpose.VERIFY; |
| 190 |
public static final int KM_PURPOSE_WRAP = KeyPurpose.WRAP_KEY; |
| 191 |
public static final int KM_PURPOSE_AGREE_KEY = KeyPurpose.AGREE_KEY; |
| 192 |
public static final int KM_PURPOSE_ATTEST_KEY = KeyPurpose.ATTEST_KEY; |
| 193 |
|
| 194 |
|
| 195 |
public static final int KM_KEY_FORMAT_X509 = KeyFormat.X509; |
| 196 |
public static final int KM_KEY_FORMAT_PKCS8 = KeyFormat.PKCS8; |
| 197 |
public static final int KM_KEY_FORMAT_RAW = KeyFormat.RAW; |
| 198 |
|
| 199 |
|
| 200 |
public static final int HW_AUTH_PASSWORD = HardwareAuthenticatorType.PASSWORD; |
| 201 |
public static final int HW_AUTH_BIOMETRIC = HardwareAuthenticatorType.FINGERPRINT; |
| 202 |
|
| 203 |
|
| 204 |
public static final int KM_SECURITY_LEVEL_SOFTWARE = SecurityLevel.SOFTWARE; |
| 205 |
public static final int KM_SECURITY_LEVEL_TRUSTED_ENVIRONMENT = |
| 206 |
SecurityLevel.TRUSTED_ENVIRONMENT; |
| 207 |
public static final int KM_SECURITY_LEVEL_STRONGBOX = SecurityLevel.STRONGBOX; |
| 208 |
|
| 209 |
|
| 210 |
public static final int KM_ERROR_OK = ErrorCode.OK; |
| 211 |
public static final int KM_ERROR_ROOT_OF_TRUST_ALREADY_SET = |
| 212 |
ErrorCode.ROOT_OF_TRUST_ALREADY_SET; |
| 213 |
public static final int KM_ERROR_UNSUPPORTED_PURPOSE = |
| 214 |
ErrorCode.UNSUPPORTED_PURPOSE; |
| 215 |
public static final int KM_ERROR_INCOMPATIBLE_PURPOSE = |
| 216 |
ErrorCode.INCOMPATIBLE_PURPOSE; |
| 217 |
public static final int KM_ERROR_UNSUPPORTED_ALGORITHM = |
| 218 |
ErrorCode.UNSUPPORTED_ALGORITHM; |
| 219 |
public static final int KM_ERROR_INCOMPATIBLE_ALGORITHM = |
| 220 |
ErrorCode.INCOMPATIBLE_ALGORITHM; |
| 221 |
public static final int KM_ERROR_UNSUPPORTED_KEY_SIZE = |
| 222 |
ErrorCode.UNSUPPORTED_KEY_SIZE; |
| 223 |
public static final int KM_ERROR_UNSUPPORTED_BLOCK_MODE = |
| 224 |
ErrorCode.UNSUPPORTED_BLOCK_MODE; |
| 225 |
public static final int KM_ERROR_INCOMPATIBLE_BLOCK_MODE = |
| 226 |
ErrorCode.INCOMPATIBLE_BLOCK_MODE; |
| 227 |
public static final int KM_ERROR_UNSUPPORTED_MAC_LENGTH = |
| 228 |
ErrorCode.UNSUPPORTED_MAC_LENGTH; |
| 229 |
public static final int KM_ERROR_UNSUPPORTED_PADDING_MODE = |
| 230 |
ErrorCode.UNSUPPORTED_PADDING_MODE; |
| 231 |
public static final int KM_ERROR_INCOMPATIBLE_PADDING_MODE = |
| 232 |
ErrorCode.INCOMPATIBLE_PADDING_MODE; |
| 233 |
public static final int KM_ERROR_UNSUPPORTED_DIGEST = |
| 234 |
ErrorCode.UNSUPPORTED_DIGEST; |
| 235 |
public static final int KM_ERROR_INCOMPATIBLE_DIGEST = |
| 236 |
ErrorCode.INCOMPATIBLE_DIGEST; |
| 237 |
public static final int KM_ERROR_INVALID_EXPIRATION_TIME = |
| 238 |
ErrorCode.INVALID_EXPIRATION_TIME; |
| 239 |
public static final int KM_ERROR_INVALID_USER_ID = |
| 240 |
ErrorCode.INVALID_USER_ID; |
| 241 |
public static final int KM_ERROR_INVALID_AUTHORIZATION_TIMEOUT = |
| 242 |
ErrorCode.INVALID_AUTHORIZATION_TIMEOUT; |
| 243 |
public static final int KM_ERROR_UNSUPPORTED_KEY_FORMAT = |
| 244 |
ErrorCode.UNSUPPORTED_KEY_FORMAT; |
| 245 |
public static final int KM_ERROR_INCOMPATIBLE_KEY_FORMAT = |
| 246 |
ErrorCode.INCOMPATIBLE_KEY_FORMAT; |
| 247 |
public static final int KM_ERROR_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM = |
| 248 |
ErrorCode.UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM; |
| 249 |
public static final int KM_ERROR_UNSUPPORTED_KEY_VERIFICATION_ALGORITHM = |
| 250 |
ErrorCode.UNSUPPORTED_KEY_VERIFICATION_ALGORITHM; |
| 251 |
public static final int KM_ERROR_INVALID_INPUT_LENGTH = |
| 252 |
ErrorCode.INVALID_INPUT_LENGTH; |
| 253 |
public static final int KM_ERROR_KEY_EXPORT_OPTIONS_INVALID = |
| 254 |
ErrorCode.KEY_EXPORT_OPTIONS_INVALID; |
| 255 |
public static final int KM_ERROR_DELEGATION_NOT_ALLOWED = |
| 256 |
ErrorCode.DELEGATION_NOT_ALLOWED; |
| 257 |
public static final int KM_ERROR_KEY_NOT_YET_VALID = |
| 258 |
ErrorCode.KEY_NOT_YET_VALID; |
| 259 |
public static final int KM_ERROR_KEY_EXPIRED = |
| 260 |
ErrorCode.KEY_EXPIRED; |
| 261 |
public static final int KM_ERROR_KEY_USER_NOT_AUTHENTICATED = |
| 262 |
ErrorCode.KEY_USER_NOT_AUTHENTICATED; |
| 263 |
public static final int KM_ERROR_OUTPUT_PARAMETER_NULL = |
| 264 |
ErrorCode.OUTPUT_PARAMETER_NULL; |
| 265 |
public static final int KM_ERROR_INVALID_OPERATION_HANDLE = |
| 266 |
ErrorCode.INVALID_OPERATION_HANDLE; |
| 267 |
public static final int KM_ERROR_INSUFFICIENT_BUFFER_SPACE = |
| 268 |
ErrorCode.INSUFFICIENT_BUFFER_SPACE; |
| 269 |
public static final int KM_ERROR_VERIFICATION_FAILED = |
| 270 |
ErrorCode.VERIFICATION_FAILED; |
| 271 |
public static final int KM_ERROR_TOO_MANY_OPERATIONS = |
| 272 |
ErrorCode.TOO_MANY_OPERATIONS; |
| 273 |
public static final int KM_ERROR_UNEXPECTED_NULL_POINTER = |
| 274 |
ErrorCode.UNEXPECTED_NULL_POINTER; |
| 275 |
public static final int KM_ERROR_INVALID_KEY_BLOB = |
| 276 |
ErrorCode.INVALID_KEY_BLOB; |
| 277 |
public static final int KM_ERROR_IMPORTED_KEY_NOT_ENCRYPTED = |
| 278 |
ErrorCode.IMPORTED_KEY_NOT_ENCRYPTED; |
| 279 |
public static final int KM_ERROR_IMPORTED_KEY_DECRYPTION_FAILED = |
| 280 |
ErrorCode.IMPORTED_KEY_DECRYPTION_FAILED; |
| 281 |
public static final int KM_ERROR_IMPORTED_KEY_NOT_SIGNED = |
| 282 |
ErrorCode.IMPORTED_KEY_NOT_SIGNED; |
| 283 |
public static final int KM_ERROR_IMPORTED_KEY_VERIFICATION_FAILED = |
| 284 |
ErrorCode.IMPORTED_KEY_VERIFICATION_FAILED; |
| 285 |
public static final int KM_ERROR_INVALID_ARGUMENT = |
| 286 |
ErrorCode.INVALID_ARGUMENT; |
| 287 |
public static final int KM_ERROR_UNSUPPORTED_TAG = |
| 288 |
ErrorCode.UNSUPPORTED_TAG; |
| 289 |
public static final int KM_ERROR_INVALID_TAG = |
| 290 |
ErrorCode.INVALID_TAG; |
| 291 |
public static final int KM_ERROR_MEMORY_ALLOCATION_FAILED = |
| 292 |
ErrorCode.MEMORY_ALLOCATION_FAILED; |
| 293 |
public static final int KM_ERROR_IMPORT_PARAMETER_MISMATCH = |
| 294 |
ErrorCode.IMPORT_PARAMETER_MISMATCH; |
| 295 |
public static final int KM_ERROR_SECURE_HW_ACCESS_DENIED = |
| 296 |
ErrorCode.SECURE_HW_ACCESS_DENIED; |
| 297 |
public static final int KM_ERROR_OPERATION_CANCELLED = |
| 298 |
ErrorCode.OPERATION_CANCELLED; |
| 299 |
public static final int KM_ERROR_CONCURRENT_ACCESS_CONFLICT = |
| 300 |
ErrorCode.CONCURRENT_ACCESS_CONFLICT; |
| 301 |
public static final int KM_ERROR_SECURE_HW_BUSY = |
| 302 |
ErrorCode.SECURE_HW_BUSY; |
| 303 |
public static final int KM_ERROR_SECURE_HW_COMMUNICATION_FAILED = |
| 304 |
ErrorCode.SECURE_HW_COMMUNICATION_FAILED; |
| 305 |
public static final int KM_ERROR_UNSUPPORTED_EC_FIELD = |
| 306 |
ErrorCode.UNSUPPORTED_EC_FIELD; |
| 307 |
public static final int KM_ERROR_MISSING_NONCE = |
| 308 |
ErrorCode.MISSING_NONCE; |
| 309 |
public static final int KM_ERROR_INVALID_NONCE = |
| 310 |
ErrorCode.INVALID_NONCE; |
| 311 |
public static final int KM_ERROR_MISSING_MAC_LENGTH = |
| 312 |
ErrorCode.MISSING_MAC_LENGTH; |
| 313 |
public static final int KM_ERROR_KEY_RATE_LIMIT_EXCEEDED = |
| 314 |
ErrorCode.KEY_RATE_LIMIT_EXCEEDED; |
| 315 |
public static final int KM_ERROR_CALLER_NONCE_PROHIBITED = |
| 316 |
ErrorCode.CALLER_NONCE_PROHIBITED; |
| 317 |
public static final int KM_ERROR_KEY_MAX_OPS_EXCEEDED = |
| 318 |
ErrorCode.KEY_MAX_OPS_EXCEEDED; |
| 319 |
public static final int KM_ERROR_INVALID_MAC_LENGTH = |
| 320 |
ErrorCode.INVALID_MAC_LENGTH; |
| 321 |
public static final int KM_ERROR_MISSING_MIN_MAC_LENGTH = |
| 322 |
ErrorCode.MISSING_MIN_MAC_LENGTH; |
| 323 |
public static final int KM_ERROR_UNSUPPORTED_MIN_MAC_LENGTH = |
| 324 |
ErrorCode.UNSUPPORTED_MIN_MAC_LENGTH; |
| 325 |
public static final int KM_ERROR_UNSUPPORTED_KDF = ErrorCode.UNSUPPORTED_KDF; |
| 326 |
public static final int KM_ERROR_UNSUPPORTED_EC_CURVE = ErrorCode.UNSUPPORTED_EC_CURVE; |
| 327 |
|
| 328 |
public static final int KM_ERROR_ATTESTATION_CHALLENGE_MISSING = |
| 329 |
ErrorCode.ATTESTATION_CHALLENGE_MISSING; |
| 330 |
public static final int KM_ERROR_KEYMINT_NOT_CONFIGURED = |
| 331 |
ErrorCode.KEYMINT_NOT_CONFIGURED; |
| 332 |
public static final int KM_ERROR_ATTESTATION_APPLICATION_ID_MISSING = |
| 333 |
ErrorCode.ATTESTATION_APPLICATION_ID_MISSING; |
| 334 |
public static final int KM_ERROR_CANNOT_ATTEST_IDS = |
| 335 |
ErrorCode.CANNOT_ATTEST_IDS; |
| 336 |
public static final int KM_ERROR_ROLLBACK_RESISTANCE_UNAVAILABLE = |
| 337 |
ErrorCode.ROLLBACK_RESISTANCE_UNAVAILABLE; |
| 338 |
public static final int KM_ERROR_HARDWARE_TYPE_UNAVAILABLE = |
| 339 |
ErrorCode.HARDWARE_TYPE_UNAVAILABLE; |
| 340 |
public static final int KM_ERROR_DEVICE_LOCKED = |
| 341 |
ErrorCode.DEVICE_LOCKED; |
| 342 |
public static final int KM_ERROR_STORAGE_KEY_UNSUPPORTED = |
| 343 |
ErrorCode.STORAGE_KEY_UNSUPPORTED; |
| 344 |
public static final int KM_ERROR_INCOMPATIBLE_MGF_DIGEST = |
| 345 |
ErrorCode.INCOMPATIBLE_MGF_DIGEST; |
| 346 |
public static final int KM_ERROR_UNSUPPORTED_MGF_DIGEST = |
| 347 |
ErrorCode.UNSUPPORTED_MGF_DIGEST; |
| 348 |
public static final int KM_ERROR_MISSING_NOT_BEFORE = |
| 349 |
ErrorCode.MISSING_NOT_BEFORE; |
| 350 |
public static final int KM_ERROR_MISSING_NOT_AFTER = |
| 351 |
ErrorCode.MISSING_NOT_AFTER; |
| 352 |
public static final int KM_ERROR_HARDWARE_NOT_YET_AVAILABLE = |
| 353 |
ErrorCode.HARDWARE_NOT_YET_AVAILABLE; |
| 354 |
public static final int KM_ERROR_UNIMPLEMENTED = |
| 355 |
ErrorCode.UNIMPLEMENTED; |
| 356 |
public static final int KM_ERROR_VERSION_MISMATCH = |
| 357 |
ErrorCode.VERSION_MISMATCH; |
| 358 |
public static final int KM_ERROR_UNKNOWN_ERROR = |
| 359 |
ErrorCode.UNKNOWN_ERROR; |
| 360 |
|
| 361 |
public static final Map<Integer, String> sErrorCodeToString = new HashMap<Integer, String>(); |
| 362 |
static { |
| 363 |
sErrorCodeToString.put(KM_ERROR_OK, "OK"); |
| 364 |
sErrorCodeToString.put(KM_ERROR_UNSUPPORTED_PURPOSE, "Unsupported purpose"); |
| 365 |
sErrorCodeToString.put(KM_ERROR_INCOMPATIBLE_PURPOSE, "Incompatible purpose"); |
| 366 |
sErrorCodeToString.put(KM_ERROR_UNSUPPORTED_ALGORITHM, "Unsupported algorithm"); |
| 367 |
sErrorCodeToString.put(KM_ERROR_INCOMPATIBLE_ALGORITHM, "Incompatible algorithm"); |
| 368 |
sErrorCodeToString.put(KM_ERROR_UNSUPPORTED_KEY_SIZE, "Unsupported key size"); |
| 369 |
sErrorCodeToString.put(KM_ERROR_UNSUPPORTED_BLOCK_MODE, "Unsupported block mode"); |
| 370 |
sErrorCodeToString.put(KM_ERROR_INCOMPATIBLE_BLOCK_MODE, "Incompatible block mode"); |
| 371 |
sErrorCodeToString.put(KM_ERROR_UNSUPPORTED_MAC_LENGTH, |
| 372 |
"Unsupported MAC or authentication tag length"); |
| 373 |
sErrorCodeToString.put(KM_ERROR_UNSUPPORTED_PADDING_MODE, "Unsupported padding mode"); |
| 374 |
sErrorCodeToString.put(KM_ERROR_INCOMPATIBLE_PADDING_MODE, "Incompatible padding mode"); |
| 375 |
sErrorCodeToString.put(KM_ERROR_UNSUPPORTED_DIGEST, "Unsupported digest"); |
| 376 |
sErrorCodeToString.put(KM_ERROR_INCOMPATIBLE_DIGEST, "Incompatible digest"); |
| 377 |
sErrorCodeToString.put(KM_ERROR_INVALID_EXPIRATION_TIME, "Invalid expiration time"); |
| 378 |
sErrorCodeToString.put(KM_ERROR_INVALID_USER_ID, "Invalid user ID"); |
| 379 |
sErrorCodeToString.put(KM_ERROR_INVALID_AUTHORIZATION_TIMEOUT, |
| 380 |
"Invalid user authorization timeout"); |
| 381 |
sErrorCodeToString.put(KM_ERROR_UNSUPPORTED_KEY_FORMAT, "Unsupported key format"); |
| 382 |
sErrorCodeToString.put(KM_ERROR_INCOMPATIBLE_KEY_FORMAT, "Incompatible key format"); |
| 383 |
sErrorCodeToString.put(KM_ERROR_INVALID_INPUT_LENGTH, "Invalid input length"); |
| 384 |
sErrorCodeToString.put(KM_ERROR_KEY_NOT_YET_VALID, "Key not yet valid"); |
| 385 |
sErrorCodeToString.put(KM_ERROR_KEY_EXPIRED, "Key expired"); |
| 386 |
sErrorCodeToString.put(KM_ERROR_KEY_USER_NOT_AUTHENTICATED, "Key user not authenticated"); |
| 387 |
sErrorCodeToString.put(KM_ERROR_INVALID_OPERATION_HANDLE, "Invalid operation handle"); |
| 388 |
sErrorCodeToString.put(KM_ERROR_VERIFICATION_FAILED, "Signature/MAC verification failed"); |
| 389 |
sErrorCodeToString.put(KM_ERROR_TOO_MANY_OPERATIONS, "Too many operations"); |
| 390 |
sErrorCodeToString.put(KM_ERROR_INVALID_KEY_BLOB, "Invalid key blob"); |
| 391 |
sErrorCodeToString.put(KM_ERROR_INVALID_ARGUMENT, "Invalid argument"); |
| 392 |
sErrorCodeToString.put(KM_ERROR_UNSUPPORTED_TAG, "Unsupported tag"); |
| 393 |
sErrorCodeToString.put(KM_ERROR_INVALID_TAG, "Invalid tag"); |
| 394 |
sErrorCodeToString.put(KM_ERROR_MEMORY_ALLOCATION_FAILED, "Memory allocation failed"); |
| 395 |
sErrorCodeToString.put(KM_ERROR_UNSUPPORTED_EC_FIELD, "Unsupported EC field"); |
| 396 |
sErrorCodeToString.put(KM_ERROR_MISSING_NONCE, "Required IV missing"); |
| 397 |
sErrorCodeToString.put(KM_ERROR_INVALID_NONCE, "Invalid IV"); |
| 398 |
sErrorCodeToString.put(KM_ERROR_CALLER_NONCE_PROHIBITED, |
| 399 |
"Caller-provided IV not permitted"); |
| 400 |
sErrorCodeToString.put(KM_ERROR_INVALID_MAC_LENGTH, |
| 401 |
"Invalid MAC or authentication tag length"); |
| 402 |
sErrorCodeToString.put(KM_ERROR_CANNOT_ATTEST_IDS, "Unable to attest device ids"); |
| 403 |
sErrorCodeToString.put(KM_ERROR_HARDWARE_TYPE_UNAVAILABLE, "Requested security level " |
| 404 |
+ "(likely Strongbox) is not available."); |
| 405 |
sErrorCodeToString.put(KM_ERROR_DEVICE_LOCKED, "Device locked"); |
| 406 |
sErrorCodeToString.put(KM_ERROR_UNIMPLEMENTED, "Not implemented"); |
| 407 |
sErrorCodeToString.put(KM_ERROR_UNKNOWN_ERROR, "Unknown error"); |
| 408 |
} |
| 409 |
|
| 410 |
public static int getTagType(int tag) { |
| 411 |
return tag & (0xF << 28); |
| 412 |
} |
| 413 |
|
| 414 |
public static String getErrorMessage(int errorCode) { |
| 415 |
String result = sErrorCodeToString.get(errorCode); |
| 416 |
if (result != null) { |
| 417 |
return result; |
| 418 |
} |
| 419 |
return String.valueOf(errorCode); |
| 420 |
} |
| 421 |
} |