blob: 1bbf2c7c0ad90341399abcdbff714477399272bb
1 | /* |
2 | * Copyright (C) 2012 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 | #pragma once |
18 | |
19 | // clang-format off |
20 | |
21 | #define KEYMASTER_PORT "com.android.trusty.keymaster" |
22 | #define KEYMASTER_MAX_BUFFER_LENGTH 4096 |
23 | |
24 | /* This UUID is generated with uuidgen |
25 | the ITU-T UUID generator at http://www.itu.int/ITU-T/asn1/uuid.html */ |
26 | #define TA_KEYMASTER_UUID {0x8efb1e1c, 0x37e5, 0x4326, \ |
27 | { 0xa5, 0xd6, 0x8c, 0x33, 0x72, 0x6c, 0x7d, 0x57} } |
28 | |
29 | // Commands |
30 | enum keymaster_command : uint32_t { |
31 | KEYMASTER_RESP_BIT = 1, |
32 | KEYMASTER_STOP_BIT = 2, |
33 | KEYMASTER_REQ_SHIFT = 2, |
34 | |
35 | KM_GENERATE_KEY = (0 << KEYMASTER_REQ_SHIFT), |
36 | KM_BEGIN_OPERATION = (1 << KEYMASTER_REQ_SHIFT), |
37 | KM_UPDATE_OPERATION = (2 << KEYMASTER_REQ_SHIFT), |
38 | KM_FINISH_OPERATION = (3 << KEYMASTER_REQ_SHIFT), |
39 | KM_ABORT_OPERATION = (4 << KEYMASTER_REQ_SHIFT), |
40 | KM_IMPORT_KEY = (5 << KEYMASTER_REQ_SHIFT), |
41 | KM_EXPORT_KEY = (6 << KEYMASTER_REQ_SHIFT), |
42 | KM_GET_VERSION = (7 << KEYMASTER_REQ_SHIFT), |
43 | KM_ADD_RNG_ENTROPY = (8 << KEYMASTER_REQ_SHIFT), |
44 | KM_GET_SUPPORTED_ALGORITHMS = (9 << KEYMASTER_REQ_SHIFT), |
45 | KM_GET_SUPPORTED_BLOCK_MODES = (10 << KEYMASTER_REQ_SHIFT), |
46 | KM_GET_SUPPORTED_PADDING_MODES = (11 << KEYMASTER_REQ_SHIFT), |
47 | KM_GET_SUPPORTED_DIGESTS = (12 << KEYMASTER_REQ_SHIFT), |
48 | KM_GET_SUPPORTED_IMPORT_FORMATS = (13 << KEYMASTER_REQ_SHIFT), |
49 | KM_GET_SUPPORTED_EXPORT_FORMATS = (14 << KEYMASTER_REQ_SHIFT), |
50 | KM_GET_KEY_CHARACTERISTICS = (15 << KEYMASTER_REQ_SHIFT), |
51 | KM_ATTEST_KEY = (16 << KEYMASTER_REQ_SHIFT), |
52 | KM_UPGRADE_KEY = (17 << KEYMASTER_REQ_SHIFT), |
53 | KM_CONFIGURE = (18 << KEYMASTER_REQ_SHIFT), |
54 | |
55 | KM_SET_BOOT_PARAMS = (0x1000 << KEYMASTER_REQ_SHIFT), |
56 | KM_SET_ATTESTATION_KEY = (0x2000 << KEYMASTER_REQ_SHIFT), |
57 | KM_APPEND_ATTESTATION_CERT_CHAIN = (0x3000 << KEYMASTER_REQ_SHIFT), |
58 | |
59 | KM_TA_INIT = (0x10000 << KEYMASTER_REQ_SHIFT), |
60 | KM_TA_TERM = (0x10001 << KEYMASTER_REQ_SHIFT), |
61 | }; |
62 | |
63 | #ifdef __ANDROID__ |
64 | |
65 | /** |
66 | * keymaster_message - Serial header for communicating with KM server |
67 | * @cmd: the command, one of keymaster_command. |
68 | * @payload: start of the serialized command specific payload |
69 | */ |
70 | struct keymaster_message { |
71 | uint32_t cmd; |
72 | uint8_t payload[0]; |
73 | }; |
74 | |
75 | #endif |
76 |