• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2017 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
17syntax = "proto3";
18
19package nugget.app.keymaster;
20
21/*
22 * Minimal type definitions required for building protos.  Sourced from:
23 *     ::android::hardware::keymaster::V3_0
24 */
25enum TagType {
26  TAG_TYPE_INVALID = 0x0;  /* 0 << 16 */
27  ENUM = 0x10000;          /* 1 << 16 */
28  ENUM_REP = 0x20000;      /* 2 << 16 */
29  UINT = 0x30000;          /* 3 << 16 */
30  UINT_REP = 0x40000;      /* 4 << 16 */
31  ULONG = 0x50000;         /* 5 << 16 */
32  DATE = 0x60000;          /* 6 << 16 */
33  BOOL = 0x70000;          /* 7 << 16 */
34  /*  BIGNUM = 0x80000;         8 << 16 */  /* Unused. */
35  BYTES = 0x90000;         /* 9 << 16 */
36  ULONG_REP = 0xA0000;     /* 10 << 16 */
37};
38
39enum Tag {
40  TAG_INVALID = 0; // (TagType:INVALID | 0)
41  PURPOSE = 0x20001; // (TagType:ENUM_REP | 1)
42  ALGORITHM = 0x10002; // (TagType:ENUM | 2)
43  KEY_SIZE = 0x30003; // (TagType:UINT | 3)
44  BLOCK_MODE = 0x20004; // (TagType:ENUM_REP | 4)
45  DIGEST = 0x20005; // (TagType:ENUM_REP | 5)
46  PADDING = 0x20006; // (TagType:ENUM_REP | 6)
47  CALLER_NONCE = 0x70007; // (TagType:BOOL | 7)
48  MIN_MAC_LENGTH = 0x30008; // (TagType:UINT | 8)
49  /* RESERVED: KDF = 0x20009; // (TagType:ENUM_REP | 9) */
50  EC_CURVE = 0x1000a; // (TagType:ENUM | 10)
51  RSA_PUBLIC_EXPONENT = 0x500c8; // (TagType:ULONG | 200)
52  /* RESERVED: ECIES_SINGLE_HASH_MODE = 0x700c9; // (TagType:BOOL | 201) */
53  INCLUDE_UNIQUE_ID = 0x700ca; // (TagType:BOOL | 202)
54  BLOB_USAGE_REQUIREMENTS = 0x1012d; // (TagType:ENUM | 301)
55  BOOTLOADER_ONLY = 0x7012e; // (TagType:BOOL | 302)
56  ROLLBACK_RESISTANCE = 0x7012f; // (TagType:BOOL | 303)
57  HARDWARE_TYPE = 0x10130; // TagType:ENUM | 304,
58  ACTIVE_DATETIME = 0x60190; // (TagType:DATE | 400)
59  ORIGINATION_EXPIRE_DATETIME = 0x60191; // (TagType:DATE | 401)
60  USAGE_EXPIRE_DATETIME = 0x60192; // (TagType:DATE | 402)
61  MIN_SECONDS_BETWEEN_OPS = 0x30193; // (TagType:UINT | 403)
62  MAX_USES_PER_BOOT = 0x30194; // (TagType:UINT | 404)
63  /* RESERVED: ALL_USERS = 0x701f4; // (TagType:BOOL | 500) */
64  USER_ID = 0x301f5; // (TagType:UINT | 501)
65  USER_SECURE_ID = 0xa01f6; // (TagType:ULONG_REP | 502)
66  NO_AUTH_REQUIRED = 0x701f7; // (TagType:BOOL | 503)
67  USER_AUTH_TYPE = 0x101f8; // (TagType:ENUM | 504)
68  AUTH_TIMEOUT = 0x301f9; // (TagType:UINT | 505)
69  ALLOW_WHILE_ON_BODY = 0x701fa; // (TagType:BOOL | 506)
70  TRUSTED_USER_PRESENCE_REQUIRED = 0x701fb; // (TagType:BOOL | 507)
71  TRUSTED_CONFIRMATION_REQUIRED = 0x701fc;  // (TagType:BOOL | 508)
72  UNLOCKED_DEVICE_REQUIRED = 0x701fd;  //  (TagType:BOOL | 509)
73  /* RESERVED: ALL_APPLICATIONS = 0x70258; // (TagType:BOOL | 600) */
74  APPLICATION_ID = 0x90259; // (TagType:BYTES | 601)
75  /* RESERVED: EXPORTABLE = 0x7025a; // (TagType:BOOL | 602) */
76  APPLICATION_DATA = 0x902bc; // (TagType:BYTES | 700)
77  CREATION_DATETIME = 0x602bd; // (TagType:DATE | 701)
78  ORIGIN = 0x102be; // (TagType:ENUM | 702)
79  /* RESERVED: ROLLBACK_RESISTANT = 0x702bf; // (TagType:BOOL | 703) */
80  ROOT_OF_TRUST = 0x902c0; // (TagType:BYTES | 704)
81  OS_VERSION = 0x302c1; // (TagType:UINT | 705)
82  OS_PATCHLEVEL = 0x302c2; // (TagType:UINT | 706)
83  UNIQUE_ID = 0x902c3; // (TagType:BYTES | 707)
84  ATTESTATION_CHALLENGE = 0x902c4; // (TagType:BYTES | 708)
85  ATTESTATION_APPLICATION_ID = 0x902c5; // (TagType:BYTES | 709)
86  ATTESTATION_ID_BRAND = 0x902c6; // (TagType:BYTES | 710)
87  ATTESTATION_ID_DEVICE = 0x902c7; // (TagType:BYTES | 711)
88  ATTESTATION_ID_PRODUCT = 0x902c8; // (TagType:BYTES | 712)
89  ATTESTATION_ID_SERIAL = 0x902c9; // (TagType:BYTES | 713)
90  ATTESTATION_ID_IMEI = 0x902ca; // (TagType:BYTES | 714)
91  ATTESTATION_ID_MEID = 0x902cb; // (TagType:BYTES | 715)
92  ATTESTATION_ID_MANUFACTURER = 0x902cc; // (TagType:BYTES | 716)
93  ATTESTATION_ID_MODEL = 0x902cd; // (TagType:BYTES | 717)
94  VENDOR_PATCHLEVEL = 0x302ce; // (TagType:UINT | 718)
95  BOOT_PATCHLEVEL = 0x302cf; // (TagType:UINT | 719)
96  ASSOCIATED_DATA = 0x903e8; // (TagType:BYTES | 1000)
97  NONCE = 0x903e9; // (TagType:BYTES | 1001)
98  /* RESERVED: AUTH_TOKEN = 0x903ea; // (TagType:BYTES | 1002) */
99  MAC_LENGTH = 0x303eb; // (TagType:UINT | 1003)
100  RESET_SINCE_ID_ROTATION = 0x703ec; // (TagType:BOOL | 1004)
101  CONFIRMATION_TOKEN = 0x903ed;// (TagType:BYTES | 1005)
102};
103
104enum Algorithm {
105  RSA = 0;
106  EC = 1;
107  AES = 2;
108  DES = 3;
109  HMAC = 4;
110  ALGORITHM_MAX = 5;
111};
112
113enum BlockMode {
114  ECB = 0;
115  CBC = 1;
116  CTR = 2;
117  GCM = 3;
118  BLOCK_MODE_MAX = 4;
119};
120
121enum PaddingMode {
122  PADDING_NONE = 0;
123  PADDING_RSA_OAEP = 1;
124  PADDING_RSA_PSS = 2;
125  PADDING_RSA_PKCS1_1_5_ENCRYPT = 3;
126  PADDING_RSA_PKCS1_1_5_SIGN = 4;
127  PADDING_PKCS7 = 5;
128  PADDING_MODE_MAX = 6;
129};
130
131enum Digest {
132  DIGEST_NONE = 0;
133  DIGEST_MD5 = 1;
134  DIGEST_SHA1 = 2;
135  DIGEST_SHA_2_224 = 3;
136  DIGEST_SHA_2_256 = 4;
137  DIGEST_SHA_2_384 = 5;
138  DIGEST_SHA_2_512 = 6;
139  DIGEST_MAX = 7;
140};
141
142enum EcCurve {
143  P_224 = 0;
144  P_256 = 1;
145  P_384 = 2;
146  P_521 = 3;
147  EC_CURVE_MAX = 4;
148};
149
150enum KeyOrigin {
151  GENERATED = 0;
152  DERIVED = 1;
153  IMPORTED = 2;
154  UNKNOWN = 3;
155  SECURELY_IMPORTED = 4;
156  KEY_ORIGIN_MAX = 5;
157};
158
159enum KeyBlobUsageRequirements {
160  STANDALONE = 0;
161  REQUIRES_FILE_SYSTEM = 1;
162  KEY_USAGE_MAX = 2;
163};
164
165enum KeyPurpose {
166  ENCRYPT = 0;
167  DECRYPT = 1;
168  SIGN = 2;
169  VERIFY = 3;
170  /* RESERVED: DERIVE_KEY = 4; */
171  WRAP_KEY = 5;
172  PURPOSE_MAX = 6;
173};
174
175enum ErrorCode {
176  OK = 0;
177  ROOT_OF_TRUST_ALREADY_SET = 1;
178  UNSUPPORTED_PURPOSE = 2;
179  INCOMPATIBLE_PURPOSE = 3;
180  UNSUPPORTED_ALGORITHM = 4;
181  INCOMPATIBLE_ALGORITHM = 5;
182  UNSUPPORTED_KEY_SIZE = 6;
183  UNSUPPORTED_BLOCK_MODE = 7;
184  INCOMPATIBLE_BLOCK_MODE = 8;
185  UNSUPPORTED_MAC_LENGTH = 9;
186  UNSUPPORTED_PADDING_MODE = 10;
187  INCOMPATIBLE_PADDING_MODE = 11;
188  UNSUPPORTED_DIGEST = 12;
189  INCOMPATIBLE_DIGEST = 13;
190  INVALID_EXPIRATION_TIME = 14;
191  INVALID_USER_ID = 15;
192  INVALID_AUTHORIZATION_TIMEOUT = 16;
193  UNSUPPORTED_KEY_FORMAT = 17;
194  INCOMPATIBLE_KEY_FORMAT = 18;
195  UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM = 19;
196  UNSUPPORTED_KEY_VERIFICATION_ALGORITHM = 20;
197  INVALID_INPUT_LENGTH = 21;
198  KEY_EXPORT_OPTIONS_INVALID = 22;
199  DELEGATION_NOT_ALLOWED = 23;
200  KEY_NOT_YET_VALID = 24;
201  KEY_EXPIRED = 25;
202  KEY_USER_NOT_AUTHENTICATED = 26;
203  OUTPUT_PARAMETER_NULL = 27;
204  INVALID_OPERATION_HANDLE = 28;
205  INSUFFICIENT_BUFFER_SPACE = 29;
206  VERIFICATION_FAILED = 30;
207  TOO_MANY_OPERATIONS = 31;
208  UNEXPECTED_NULL_POINTER = 32;
209  INVALID_KEY_BLOB = 33;
210  IMPORTED_KEY_NOT_ENCRYPTED = 34;
211  IMPORTED_KEY_DECRYPTION_FAILED = 35;
212  IMPORTED_KEY_NOT_SIGNED = 36;
213  IMPORTED_KEY_VERIFICATION_FAILED = 37;
214  INVALID_ARGUMENT = 38;
215  UNSUPPORTED_TAG = 39;
216  INVALID_TAG = 40;
217  MEMORY_ALLOCATION_FAILED = 41;
218  IMPORT_PARAMETER_MISMATCH = 42;
219  SECURE_HW_ACCESS_DENIED = 43;
220  OPERATION_CANCELLED = 44;
221  CONCURRENT_ACCESS_CONFLICT = 45;
222  SECURE_HW_BUSY = 46;
223  SECURE_HW_COMMUNICATION_FAILED = 47;
224  UNSUPPORTED_EC_FIELD = 48;
225  MISSING_NONCE = 49;
226  INVALID_NONCE = 50;
227  MISSING_MAC_LENGTH = 51;
228  KEY_RATE_LIMIT_EXCEEDED = 52;
229  CALLER_NONCE_PROHIBITED = 53;
230  KEY_MAX_OPS_EXCEEDED = 54;
231  INVALID_MAC_LENGTH = 55;
232  MISSING_MIN_MAC_LENGTH = 56;
233  UNSUPPORTED_MIN_MAC_LENGTH = 57;
234  UNSUPPORTED_KDF = 58;
235  UNSUPPORTED_EC_CURVE = 59;
236  KEY_REQUIRES_UPGRADE = 60;
237  ATTESTATION_CHALLENGE_MISSING = 61;
238  KEYMASTER_NOT_CONFIGURED = 62;
239  ATTESTATION_APPLICATION_ID_MISSING = 63;
240  CANNOT_ATTEST_IDS = 64;
241  UNIMPLEMENTED = 65;
242  VERSION_MISMATCH = 66;
243  ROLLBACK_RESISTANCE_UNAVAILABLE = 67;
244  HARDWARE_TYPE_UNAVAILABLE = 68;
245  PROOF_OF_PRESENCE_REQUIRED = 69;
246  CONCURRENT_PROOF_OF_PRESENCE_REQUESTED = 70;
247  UNKNOWN_ERROR = 71;
248  INVALID_DEVICE_IDS = 72;                // Vendor specific.
249  PRODUCTION_MODE_PROVISIONING = 73;      // Vendor specific.
250  NO_USER_CONFIRMATION = 74;
251  KEY_UPGRADE_NOT_REQUIRED = 75;          // Vendor specific.
252};
253
254enum SecurityLevel {
255  SOFTWARE = 0;
256  TRUSTED_ENVIRONMENT = 1;
257  STRONGBOX = 2;
258};
259
260// NOTE: these enum values must be kept in sync with the HAL,
261// as they are used in an HMAC calculation.
262enum HardwareAuthenticatorType {
263  HW_AUTH_NONE = 0;
264  HW_AUTH_PASSWORD = 1;
265  HW_AUTH_FINGERPRINT = 2;
266  // Additional entries must be powers of 2.
267};
268
269enum KeyFormat {
270  X509 = 0;   /* for public key export */
271  PKCS8 = 1;  /* for asymmetric key pair import */
272  RAW = 3;    /* for symmetric key import and export*/
273}
274
275enum DTupError {
276  DTUP_OK = 0;
277  DTUP_NO_EVENT = 1;
278}
279
280/* matches Linux event device codes */
281enum DTupKeyEvent {
282    DTUP_RESERVED = 0;
283    DTUP_VOL_DOWN = 114;
284    DTUP_VOL_UP = 115;
285    DTUP_PWR = 116;
286}
287
288enum BootColor {
289    BOOT_VERIFIED_GREEN = 0;
290    BOOT_SELFSIGNED_YELLOW = 1;
291    BOOT_UNVERIFIED_ORANGE = 2;
292    BOOT_VERIFY_FAILED_RED = 3;
293}
294
295enum ChipFusing {
296    FUSING_PROTO = 0;
297    FUSING_DVT = 1;
298    FUSING_PVT = 2;
299}
300
301enum CertificateStatus {
302  CERT_PREVIOUSLY_PROVISIONED = 0;
303  CERT_MISSING = 1;
304  CERT_CHECKSUM = 2;
305  CERT_UNKNOWN_ERROR = 3;
306  CERT_WRONG_PACKET = 4;
307}