Loading core/java/android/security/keymaster/KeymasterArgument.java +4 −4 Original line number Diff line number Diff line Loading @@ -38,11 +38,11 @@ abstract class KeymasterArgument implements Parcelable { switch (KeymasterDefs.getTagType(tag)) { case KeymasterDefs.KM_ENUM: case KeymasterDefs.KM_ENUM_REP: case KeymasterDefs.KM_INT: case KeymasterDefs.KM_INT_REP: case KeymasterDefs.KM_UINT: case KeymasterDefs.KM_UINT_REP: return new KeymasterIntArgument(tag, in); case KeymasterDefs.KM_LONG: case KeymasterDefs.KM_LONG_REP: case KeymasterDefs.KM_ULONG: case KeymasterDefs.KM_ULONG_REP: return new KeymasterLongArgument(tag, in); case KeymasterDefs.KM_DATE: return new KeymasterDateArgument(tag, in); Loading core/java/android/security/keymaster/KeymasterArguments.java +9 −9 Original line number Diff line number Diff line /** * Copyright (c) 2015, The Android Open Source Project /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -101,9 +101,9 @@ public class KeymasterArguments implements Parcelable { public int getInt(int tag, int defaultValue) { switch (KeymasterDefs.getTagType(tag)) { case KeymasterDefs.KM_ENUM: case KeymasterDefs.KM_INT: case KeymasterDefs.KM_UINT: break; // Accepted types case KeymasterDefs.KM_INT_REP: case KeymasterDefs.KM_UINT_REP: case KeymasterDefs.KM_ENUM_REP: throw new IllegalArgumentException("Repeatable tags must use getInts: " + tag); default: Loading @@ -118,9 +118,9 @@ public class KeymasterArguments implements Parcelable { public long getLong(int tag, long defaultValue) { switch (KeymasterDefs.getTagType(tag)) { case KeymasterDefs.KM_LONG: case KeymasterDefs.KM_ULONG: break; // Accepted type case KeymasterDefs.KM_LONG_REP: case KeymasterDefs.KM_ULONG_REP: throw new IllegalArgumentException("Repeatable tags must use getLongs: " + tag); default: throw new IllegalArgumentException("Tag is not a long type: " + tag); Loading Loading @@ -171,7 +171,7 @@ public class KeymasterArguments implements Parcelable { public List<Integer> getInts(int tag) { switch (KeymasterDefs.getTagType(tag)) { case KeymasterDefs.KM_INT_REP: case KeymasterDefs.KM_UINT_REP: case KeymasterDefs.KM_ENUM_REP: break; // Allowed types. default: Loading @@ -187,7 +187,7 @@ public class KeymasterArguments implements Parcelable { } public List<Long> getLongs(int tag) { if (KeymasterDefs.getTagType(tag) != KeymasterDefs.KM_LONG_REP) { if (KeymasterDefs.getTagType(tag) != KeymasterDefs.KM_ULONG_REP) { throw new IllegalArgumentException("Tag is not a repeating long: " + tag); } List<Long> values = new ArrayList<Long>(); Loading core/java/android/security/keymaster/KeymasterDefs.java +32 −26 Original line number Diff line number Diff line /** * Copyright (c) 2015, The Android Open Source Project /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -33,43 +33,43 @@ public final class KeymasterDefs { public static final int KM_INVALID = 0 << 28; public static final int KM_ENUM = 1 << 28; public static final int KM_ENUM_REP = 2 << 28; public static final int KM_INT = 3 << 28; public static final int KM_INT_REP = 4 << 28; public static final int KM_LONG = 5 << 28; public static final int KM_UINT = 3 << 28; public static final int KM_UINT_REP = 4 << 28; public static final int KM_ULONG = 5 << 28; public static final int KM_DATE = 6 << 28; public static final int KM_BOOL = 7 << 28; public static final int KM_BIGNUM = 8 << 28; public static final int KM_BYTES = 9 << 28; public static final int KM_LONG_REP = 10 << 28; public static final int KM_ULONG_REP = 10 << 28; // Tag values. public static final int KM_TAG_INVALID = KM_INVALID | 0; public static final int KM_TAG_PURPOSE = KM_ENUM_REP | 1; public static final int KM_TAG_ALGORITHM = KM_ENUM | 2; public static final int KM_TAG_KEY_SIZE = KM_INT | 3; public static final int KM_TAG_KEY_SIZE = KM_UINT | 3; public static final int KM_TAG_BLOCK_MODE = KM_ENUM_REP | 4; public static final int KM_TAG_DIGEST = KM_ENUM_REP | 5; public static final int KM_TAG_PADDING = KM_ENUM_REP | 6; public static final int KM_TAG_RETURN_UNAUTHED = KM_BOOL | 7; public static final int KM_TAG_CALLER_NONCE = KM_BOOL | 8; public static final int KM_TAG_CALLER_NONCE = KM_BOOL | 7; public static final int KM_TAG_MIN_MAC_LENGTH = KM_UINT | 8; public static final int KM_TAG_RESCOPING_ADD = KM_ENUM_REP | 101; public static final int KM_TAG_RESCOPING_DEL = KM_ENUM_REP | 102; public static final int KM_TAG_BLOB_USAGE_REQUIREMENTS = KM_ENUM | 705; public static final int KM_TAG_RSA_PUBLIC_EXPONENT = KM_LONG | 200; public static final int KM_TAG_RSA_PUBLIC_EXPONENT = KM_ULONG | 200; public static final int KM_TAG_ACTIVE_DATETIME = KM_DATE | 400; public static final int KM_TAG_ORIGINATION_EXPIRE_DATETIME = KM_DATE | 401; public static final int KM_TAG_USAGE_EXPIRE_DATETIME = KM_DATE | 402; public static final int KM_TAG_MIN_SECONDS_BETWEEN_OPS = KM_INT | 403; public static final int KM_TAG_MAX_USES_PER_BOOT = KM_INT | 404; public static final int KM_TAG_MIN_SECONDS_BETWEEN_OPS = KM_UINT | 403; public static final int KM_TAG_MAX_USES_PER_BOOT = KM_UINT | 404; public static final int KM_TAG_ALL_USERS = KM_BOOL | 500; public static final int KM_TAG_USER_ID = KM_INT | 501; public static final int KM_TAG_USER_SECURE_ID = KM_LONG_REP | 502; public static final int KM_TAG_USER_ID = KM_UINT | 501; public static final int KM_TAG_USER_SECURE_ID = KM_ULONG_REP | 502; public static final int KM_TAG_NO_AUTH_REQUIRED = KM_BOOL | 503; public static final int KM_TAG_USER_AUTH_TYPE = KM_ENUM | 504; public static final int KM_TAG_AUTH_TIMEOUT = KM_INT | 505; public static final int KM_TAG_AUTH_TIMEOUT = KM_UINT | 505; public static final int KM_TAG_ALL_APPLICATIONS = KM_BOOL | 600; public static final int KM_TAG_APPLICATION_ID = KM_BYTES | 601; Loading @@ -82,9 +82,8 @@ public final class KeymasterDefs { public static final int KM_TAG_ASSOCIATED_DATA = KM_BYTES | 1000; public static final int KM_TAG_NONCE = KM_BYTES | 1001; public static final int KM_TAG_CHUNK_LENGTH = KM_INT | 1002; public static final int KM_TAG_AUTH_TOKEN = KM_BYTES | 1003; public static final int KM_TAG_MAC_LENGTH = KM_INT | 1004; public static final int KM_TAG_AUTH_TOKEN = KM_BYTES | 1002; public static final int KM_TAG_MAC_LENGTH = KM_UINT | 1003; // Algorithm values. public static final int KM_ALGORITHM_RSA = 1; Loading @@ -93,12 +92,10 @@ public final class KeymasterDefs { public static final int KM_ALGORITHM_HMAC = 128; // Block modes. public static final int KM_MODE_FIRST_UNAUTHENTICATED = 1; public static final int KM_MODE_ECB = KM_MODE_FIRST_UNAUTHENTICATED; public static final int KM_MODE_ECB = 1; public static final int KM_MODE_CBC = 2; public static final int KM_MODE_CTR = 4; public static final int KM_MODE_FIRST_AUTHENTICATED = 32; public static final int KM_MODE_GCM = KM_MODE_FIRST_AUTHENTICATED; public static final int KM_MODE_CTR = 3; public static final int KM_MODE_GCM = 32; // Padding modes. public static final int KM_PAD_NONE = 1; Loading Loading @@ -139,6 +136,7 @@ public final class KeymasterDefs { // User authenticators. public static final int HW_AUTH_PASSWORD = 1 << 0; public static final int HW_AUTH_FINGERPRINT = 1 << 1; // Error codes. public static final int KM_ERROR_OK = 0; Loading Loading @@ -193,9 +191,13 @@ public final class KeymasterDefs { public static final int KM_ERROR_UNSUPPORTED_EC_FIELD = -50; public static final int KM_ERROR_MISSING_NONCE = -51; public static final int KM_ERROR_INVALID_NONCE = -52; public static final int KM_ERROR_UNSUPPORTED_CHUNK_LENGTH = -53; public static final int KM_ERROR_RESCOPABLE_KEY_NOT_USABLE = -54; public static final int KM_ERROR_MISSING_MAC_LENGTH = -53; public static final int KM_ERROR_KEY_RATE_LIMIT_EXCEEDED = -54; public static final int KM_ERROR_CALLER_NONCE_PROHIBITED = -55; public static final int KM_ERROR_KEY_MAX_OPS_EXCEEDED = -56; public static final int KM_ERROR_INVALID_MAC_LENGTH = -57; public static final int KM_ERROR_MISSING_MIN_MAC_LENGTH = -58; public static final int KM_ERROR_UNSUPPORTED_MIN_MAC_LENGTH = -59; public static final int KM_ERROR_UNIMPLEMENTED = -100; public static final int KM_ERROR_VERSION_MISMATCH = -101; public static final int KM_ERROR_UNKNOWN_ERROR = -1000; Loading Loading @@ -237,6 +239,10 @@ public final class KeymasterDefs { sErrorCodeToString.put(KM_ERROR_UNSUPPORTED_EC_FIELD, "Unsupported EC field"); sErrorCodeToString.put(KM_ERROR_MISSING_NONCE, "Required IV missing"); sErrorCodeToString.put(KM_ERROR_INVALID_NONCE, "Invalid IV"); sErrorCodeToString.put(KM_ERROR_CALLER_NONCE_PROHIBITED, "Caller-provided IV not permitted"); sErrorCodeToString.put(KM_ERROR_INVALID_MAC_LENGTH, "Invalid MAC or authentication tag length"); sErrorCodeToString.put(KM_ERROR_UNIMPLEMENTED, "Not implemented"); sErrorCodeToString.put(KM_ERROR_UNKNOWN_ERROR, "Unknown error"); } Loading core/java/android/security/keymaster/KeymasterIntArgument.java +2 −2 Original line number Diff line number Diff line Loading @@ -28,8 +28,8 @@ class KeymasterIntArgument extends KeymasterArgument { public KeymasterIntArgument(int tag, int value) { super(tag); switch (KeymasterDefs.getTagType(tag)) { case KeymasterDefs.KM_INT: case KeymasterDefs.KM_INT_REP: case KeymasterDefs.KM_UINT: case KeymasterDefs.KM_UINT_REP: case KeymasterDefs.KM_ENUM: case KeymasterDefs.KM_ENUM_REP: break; // OK. Loading core/java/android/security/keymaster/KeymasterLongArgument.java +2 −2 Original line number Diff line number Diff line Loading @@ -28,8 +28,8 @@ class KeymasterLongArgument extends KeymasterArgument { public KeymasterLongArgument(int tag, long value) { super(tag); switch (KeymasterDefs.getTagType(tag)) { case KeymasterDefs.KM_LONG: case KeymasterDefs.KM_LONG_REP: case KeymasterDefs.KM_ULONG: case KeymasterDefs.KM_ULONG_REP: break; // OK. default: throw new IllegalArgumentException("Bad long tag " + tag); Loading Loading
core/java/android/security/keymaster/KeymasterArgument.java +4 −4 Original line number Diff line number Diff line Loading @@ -38,11 +38,11 @@ abstract class KeymasterArgument implements Parcelable { switch (KeymasterDefs.getTagType(tag)) { case KeymasterDefs.KM_ENUM: case KeymasterDefs.KM_ENUM_REP: case KeymasterDefs.KM_INT: case KeymasterDefs.KM_INT_REP: case KeymasterDefs.KM_UINT: case KeymasterDefs.KM_UINT_REP: return new KeymasterIntArgument(tag, in); case KeymasterDefs.KM_LONG: case KeymasterDefs.KM_LONG_REP: case KeymasterDefs.KM_ULONG: case KeymasterDefs.KM_ULONG_REP: return new KeymasterLongArgument(tag, in); case KeymasterDefs.KM_DATE: return new KeymasterDateArgument(tag, in); Loading
core/java/android/security/keymaster/KeymasterArguments.java +9 −9 Original line number Diff line number Diff line /** * Copyright (c) 2015, The Android Open Source Project /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -101,9 +101,9 @@ public class KeymasterArguments implements Parcelable { public int getInt(int tag, int defaultValue) { switch (KeymasterDefs.getTagType(tag)) { case KeymasterDefs.KM_ENUM: case KeymasterDefs.KM_INT: case KeymasterDefs.KM_UINT: break; // Accepted types case KeymasterDefs.KM_INT_REP: case KeymasterDefs.KM_UINT_REP: case KeymasterDefs.KM_ENUM_REP: throw new IllegalArgumentException("Repeatable tags must use getInts: " + tag); default: Loading @@ -118,9 +118,9 @@ public class KeymasterArguments implements Parcelable { public long getLong(int tag, long defaultValue) { switch (KeymasterDefs.getTagType(tag)) { case KeymasterDefs.KM_LONG: case KeymasterDefs.KM_ULONG: break; // Accepted type case KeymasterDefs.KM_LONG_REP: case KeymasterDefs.KM_ULONG_REP: throw new IllegalArgumentException("Repeatable tags must use getLongs: " + tag); default: throw new IllegalArgumentException("Tag is not a long type: " + tag); Loading Loading @@ -171,7 +171,7 @@ public class KeymasterArguments implements Parcelable { public List<Integer> getInts(int tag) { switch (KeymasterDefs.getTagType(tag)) { case KeymasterDefs.KM_INT_REP: case KeymasterDefs.KM_UINT_REP: case KeymasterDefs.KM_ENUM_REP: break; // Allowed types. default: Loading @@ -187,7 +187,7 @@ public class KeymasterArguments implements Parcelable { } public List<Long> getLongs(int tag) { if (KeymasterDefs.getTagType(tag) != KeymasterDefs.KM_LONG_REP) { if (KeymasterDefs.getTagType(tag) != KeymasterDefs.KM_ULONG_REP) { throw new IllegalArgumentException("Tag is not a repeating long: " + tag); } List<Long> values = new ArrayList<Long>(); Loading
core/java/android/security/keymaster/KeymasterDefs.java +32 −26 Original line number Diff line number Diff line /** * Copyright (c) 2015, The Android Open Source Project /* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -33,43 +33,43 @@ public final class KeymasterDefs { public static final int KM_INVALID = 0 << 28; public static final int KM_ENUM = 1 << 28; public static final int KM_ENUM_REP = 2 << 28; public static final int KM_INT = 3 << 28; public static final int KM_INT_REP = 4 << 28; public static final int KM_LONG = 5 << 28; public static final int KM_UINT = 3 << 28; public static final int KM_UINT_REP = 4 << 28; public static final int KM_ULONG = 5 << 28; public static final int KM_DATE = 6 << 28; public static final int KM_BOOL = 7 << 28; public static final int KM_BIGNUM = 8 << 28; public static final int KM_BYTES = 9 << 28; public static final int KM_LONG_REP = 10 << 28; public static final int KM_ULONG_REP = 10 << 28; // Tag values. public static final int KM_TAG_INVALID = KM_INVALID | 0; public static final int KM_TAG_PURPOSE = KM_ENUM_REP | 1; public static final int KM_TAG_ALGORITHM = KM_ENUM | 2; public static final int KM_TAG_KEY_SIZE = KM_INT | 3; public static final int KM_TAG_KEY_SIZE = KM_UINT | 3; public static final int KM_TAG_BLOCK_MODE = KM_ENUM_REP | 4; public static final int KM_TAG_DIGEST = KM_ENUM_REP | 5; public static final int KM_TAG_PADDING = KM_ENUM_REP | 6; public static final int KM_TAG_RETURN_UNAUTHED = KM_BOOL | 7; public static final int KM_TAG_CALLER_NONCE = KM_BOOL | 8; public static final int KM_TAG_CALLER_NONCE = KM_BOOL | 7; public static final int KM_TAG_MIN_MAC_LENGTH = KM_UINT | 8; public static final int KM_TAG_RESCOPING_ADD = KM_ENUM_REP | 101; public static final int KM_TAG_RESCOPING_DEL = KM_ENUM_REP | 102; public static final int KM_TAG_BLOB_USAGE_REQUIREMENTS = KM_ENUM | 705; public static final int KM_TAG_RSA_PUBLIC_EXPONENT = KM_LONG | 200; public static final int KM_TAG_RSA_PUBLIC_EXPONENT = KM_ULONG | 200; public static final int KM_TAG_ACTIVE_DATETIME = KM_DATE | 400; public static final int KM_TAG_ORIGINATION_EXPIRE_DATETIME = KM_DATE | 401; public static final int KM_TAG_USAGE_EXPIRE_DATETIME = KM_DATE | 402; public static final int KM_TAG_MIN_SECONDS_BETWEEN_OPS = KM_INT | 403; public static final int KM_TAG_MAX_USES_PER_BOOT = KM_INT | 404; public static final int KM_TAG_MIN_SECONDS_BETWEEN_OPS = KM_UINT | 403; public static final int KM_TAG_MAX_USES_PER_BOOT = KM_UINT | 404; public static final int KM_TAG_ALL_USERS = KM_BOOL | 500; public static final int KM_TAG_USER_ID = KM_INT | 501; public static final int KM_TAG_USER_SECURE_ID = KM_LONG_REP | 502; public static final int KM_TAG_USER_ID = KM_UINT | 501; public static final int KM_TAG_USER_SECURE_ID = KM_ULONG_REP | 502; public static final int KM_TAG_NO_AUTH_REQUIRED = KM_BOOL | 503; public static final int KM_TAG_USER_AUTH_TYPE = KM_ENUM | 504; public static final int KM_TAG_AUTH_TIMEOUT = KM_INT | 505; public static final int KM_TAG_AUTH_TIMEOUT = KM_UINT | 505; public static final int KM_TAG_ALL_APPLICATIONS = KM_BOOL | 600; public static final int KM_TAG_APPLICATION_ID = KM_BYTES | 601; Loading @@ -82,9 +82,8 @@ public final class KeymasterDefs { public static final int KM_TAG_ASSOCIATED_DATA = KM_BYTES | 1000; public static final int KM_TAG_NONCE = KM_BYTES | 1001; public static final int KM_TAG_CHUNK_LENGTH = KM_INT | 1002; public static final int KM_TAG_AUTH_TOKEN = KM_BYTES | 1003; public static final int KM_TAG_MAC_LENGTH = KM_INT | 1004; public static final int KM_TAG_AUTH_TOKEN = KM_BYTES | 1002; public static final int KM_TAG_MAC_LENGTH = KM_UINT | 1003; // Algorithm values. public static final int KM_ALGORITHM_RSA = 1; Loading @@ -93,12 +92,10 @@ public final class KeymasterDefs { public static final int KM_ALGORITHM_HMAC = 128; // Block modes. public static final int KM_MODE_FIRST_UNAUTHENTICATED = 1; public static final int KM_MODE_ECB = KM_MODE_FIRST_UNAUTHENTICATED; public static final int KM_MODE_ECB = 1; public static final int KM_MODE_CBC = 2; public static final int KM_MODE_CTR = 4; public static final int KM_MODE_FIRST_AUTHENTICATED = 32; public static final int KM_MODE_GCM = KM_MODE_FIRST_AUTHENTICATED; public static final int KM_MODE_CTR = 3; public static final int KM_MODE_GCM = 32; // Padding modes. public static final int KM_PAD_NONE = 1; Loading Loading @@ -139,6 +136,7 @@ public final class KeymasterDefs { // User authenticators. public static final int HW_AUTH_PASSWORD = 1 << 0; public static final int HW_AUTH_FINGERPRINT = 1 << 1; // Error codes. public static final int KM_ERROR_OK = 0; Loading Loading @@ -193,9 +191,13 @@ public final class KeymasterDefs { public static final int KM_ERROR_UNSUPPORTED_EC_FIELD = -50; public static final int KM_ERROR_MISSING_NONCE = -51; public static final int KM_ERROR_INVALID_NONCE = -52; public static final int KM_ERROR_UNSUPPORTED_CHUNK_LENGTH = -53; public static final int KM_ERROR_RESCOPABLE_KEY_NOT_USABLE = -54; public static final int KM_ERROR_MISSING_MAC_LENGTH = -53; public static final int KM_ERROR_KEY_RATE_LIMIT_EXCEEDED = -54; public static final int KM_ERROR_CALLER_NONCE_PROHIBITED = -55; public static final int KM_ERROR_KEY_MAX_OPS_EXCEEDED = -56; public static final int KM_ERROR_INVALID_MAC_LENGTH = -57; public static final int KM_ERROR_MISSING_MIN_MAC_LENGTH = -58; public static final int KM_ERROR_UNSUPPORTED_MIN_MAC_LENGTH = -59; public static final int KM_ERROR_UNIMPLEMENTED = -100; public static final int KM_ERROR_VERSION_MISMATCH = -101; public static final int KM_ERROR_UNKNOWN_ERROR = -1000; Loading Loading @@ -237,6 +239,10 @@ public final class KeymasterDefs { sErrorCodeToString.put(KM_ERROR_UNSUPPORTED_EC_FIELD, "Unsupported EC field"); sErrorCodeToString.put(KM_ERROR_MISSING_NONCE, "Required IV missing"); sErrorCodeToString.put(KM_ERROR_INVALID_NONCE, "Invalid IV"); sErrorCodeToString.put(KM_ERROR_CALLER_NONCE_PROHIBITED, "Caller-provided IV not permitted"); sErrorCodeToString.put(KM_ERROR_INVALID_MAC_LENGTH, "Invalid MAC or authentication tag length"); sErrorCodeToString.put(KM_ERROR_UNIMPLEMENTED, "Not implemented"); sErrorCodeToString.put(KM_ERROR_UNKNOWN_ERROR, "Unknown error"); } Loading
core/java/android/security/keymaster/KeymasterIntArgument.java +2 −2 Original line number Diff line number Diff line Loading @@ -28,8 +28,8 @@ class KeymasterIntArgument extends KeymasterArgument { public KeymasterIntArgument(int tag, int value) { super(tag); switch (KeymasterDefs.getTagType(tag)) { case KeymasterDefs.KM_INT: case KeymasterDefs.KM_INT_REP: case KeymasterDefs.KM_UINT: case KeymasterDefs.KM_UINT_REP: case KeymasterDefs.KM_ENUM: case KeymasterDefs.KM_ENUM_REP: break; // OK. Loading
core/java/android/security/keymaster/KeymasterLongArgument.java +2 −2 Original line number Diff line number Diff line Loading @@ -28,8 +28,8 @@ class KeymasterLongArgument extends KeymasterArgument { public KeymasterLongArgument(int tag, long value) { super(tag); switch (KeymasterDefs.getTagType(tag)) { case KeymasterDefs.KM_LONG: case KeymasterDefs.KM_LONG_REP: case KeymasterDefs.KM_ULONG: case KeymasterDefs.KM_ULONG_REP: break; // OK. default: throw new IllegalArgumentException("Bad long tag " + tag); Loading