blob: 0edf748613461511844a2a45f91e1be563cba118 [file] [log] [blame]
nagendra modadugubdcfaa82017-09-17 17:11:36 -07001/*
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
Andrew Scullb5f24a52017-10-13 19:46:40 +010021import "nugget/app/keymaster/keymaster_defs.proto";
22import "nugget/app/keymaster/keymaster_types.proto";
nagendra modadugubdcfaa82017-09-17 17:11:36 -070023import "nugget/protobuf/options.proto";
nagendra modadugubdcfaa82017-09-17 17:11:36 -070024
25/*
26 * Keymaster service methods.
27 *
28 * TODO: some methods may be implemented in the host side HAL implementation.
29 */
30service Keymaster {
Andrew Scull36ebf2d2017-10-10 11:25:21 +010031 option (nugget.protobuf.app_id) = "KEYMASTER";
32 option (nugget.protobuf.app_name) = "Keymaster";
33 option (nugget.protobuf.app_version) = 1;
nagendra modadugu89e50ed2017-10-30 22:13:01 -070034 /*
35 * Both request and response buffers are sized such
36 * that a key-blob may be fully contained.
37 *
38 * TODO: revisit this choice in the event that memory
39 * is running out. Supporting smaller buffers will
40 * require that the keymaster app switch from the
41 * transport API to the datagram API.
42 */
43 option (nugget.protobuf.request_buffer_size) = 2048;
44 option (nugget.protobuf.response_buffer_size) = 2048;
nagendra modadugubdcfaa82017-09-17 17:11:36 -070045
Andrew Scull36ebf2d2017-10-10 11:25:21 +010046 /*
47 * KM3 methods, from:
48 * ::android::hardware::keymaster::V3_0::IKeymasterDevice
49 */
50 rpc AddRngEntropy (AddRngEntropyRequest) returns (AddRngEntropyResponse);
51 rpc GenerateKey (GenerateKeyRequest) returns (GenerateKeyResponse);
52 rpc GetKeyCharacteristics (GetKeyCharacteristicsRequest) returns (GetKeyCharacteristicsResponse);
53 rpc ImportKey (ImportKeyRequest) returns (ImportKeyResponse);
54 rpc ExportKey (ExportKeyRequest) returns (ExportKeyResponse);
55 rpc AttestKey (AttestKeyRequest) returns (AttestKeyResponse);
56 rpc UpgradeKey (UpgradeKeyRequest) returns (UpgradeKeyResponse);
57 rpc DeleteKey (DeleteKeyRequest) returns (DeleteKeyResponse);
58 rpc DeleteAllKeys (DeleteAllKeysRequest) returns (DeleteAllKeysResponse);
59 rpc DestroyAttestationIds (DestroyAttestationIdsRequest) returns (DestroyAttestationIdsResponse);
60 rpc BeginOperation (BeginOperationRequest) returns (BeginOperationResponse);
61 rpc UpdateOperation (UpdateOperationRequest) returns (UpdateOperationResponse);
62 rpc FinishOperation (FinishOperationRequest) returns (FinishOperationResponse);
63 rpc AbortOperation (AbortOperationRequest) returns (AbortOperationResponse);
nagendra modadugubdcfaa82017-09-17 17:11:36 -070064
Andrew Scull36ebf2d2017-10-10 11:25:21 +010065 /*
66 * KM4 methods.
67 */
nagendra modadugubdf53cd2017-12-04 21:28:02 -080068 rpc ImportWrappedKey (ImportWrappedKeyRequest) returns (ImportKeyResponse);
nagendra modadugubdcfaa82017-09-17 17:11:36 -070069
Andrew Scull36ebf2d2017-10-10 11:25:21 +010070 /*
nagendra modadugu6023a7d2017-11-08 14:40:49 -080071 * Vendor specific methods (bootloader, manufacturing, status,
72 * factory reset, upgrade).
Andrew Scull36ebf2d2017-10-10 11:25:21 +010073 */
nagendra modadugu6023a7d2017-11-08 14:40:49 -080074 // Only callable by the Bootloader.
75 rpc SetRootOfTrust (SetRootOfTrustRequest) returns (SetRootOfTrustResponse);
76 // Only callable by the Bootloader.
77 rpc SetBootState (SetBootStateRequest) returns (SetBootStateResponse);
nagendra modadugubdcfaa82017-09-17 17:11:36 -070078}
79
80/*
nagendra modadugubdcfaa82017-09-17 17:11:36 -070081 * KM3 messages.
82 */
83
nagendra modadugubdcfaa82017-09-17 17:11:36 -070084// AddEntropy
85message AddRngEntropyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +010086 bytes data = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -070087}
nagendra modadugu36966942017-09-26 15:56:24 -070088message AddRngEntropyResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +010089 // TODO: replace with ErrorCode enum
90 uint32 error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -070091}
nagendra modadugubdcfaa82017-09-17 17:11:36 -070092
93// GenerateKey
94message GenerateKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +010095 KeyParameters params = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -070096}
97message GenerateKeyResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +010098 uint32 error_code = 1;
99 KeyBlob blob = 2;
100 KeyCharacteristics characteristics = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700101}
102
103// GetKeyCharacteristics
104message GetKeyCharacteristicsRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100105 KeyBlob blob = 1;
106 bytes client_id = 2;
107 bytes app_data = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700108}
109message GetKeyCharacteristicsResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100110 uint32 error_code = 1;
111 KeyCharacteristics characteristics = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700112}
113
114// ImportKey
115message ImportKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100116 KeyParameters params = 1;
117 RSAKey rsa = 2;
118 ECKey ec = 3;
119 SymmetricKey symmetric_key = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700120};
121message ImportKeyResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100122 uint32 error_code = 1;
123 KeyBlob blob = 2;
124 KeyCharacteristics characteristics = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700125};
126
127// ExportKey
128message ExportKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100129 KeyFormat format = 1;
130 KeyBlob blob = 2;
131 bytes client_id = 3;
132 bytes app_data = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700133};
134message ExportKeyResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100135 uint32 error_code = 1;
136 bytes key_material = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700137};
138
139// AttestKey
140message AttestKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100141 KeyBlob blob = 1;
142 KeyParameters params = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700143}
144message AttestKeyResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100145 uint32 error_code = 1;
146 CertificateChain chain = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700147}
148
149// UpgradeKey
150message UpgradeKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100151 KeyBlob blob = 1;
152 KeyParameters params = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700153}
154message UpgradeKeyResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100155 uint32 error_code = 1;
156 KeyBlob blob = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700157}
158
159// DeleteKey
160message DeleteKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100161 KeyBlob blob = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700162}
nagendra modadugu36966942017-09-26 15:56:24 -0700163message DeleteKeyResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100164 uint32 error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700165}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700166
167// DeleteAllKeys
168message DeleteAllKeysRequest {}
nagendra modadugu36966942017-09-26 15:56:24 -0700169message DeleteAllKeysResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100170 uint32 error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700171}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700172
173// DestroyAttestationIds
174message DestroyAttestationIdsRequest {}
nagendra modadugu36966942017-09-26 15:56:24 -0700175message DestroyAttestationIdsResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100176 uint32 error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700177}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700178
179// BeginOperation
180message BeginOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100181 KeyPurpose purpose = 1;
182 KeyBlob blob = 2;
183 KeyParameters params = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700184}
185message BeginOperationResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100186 uint32 error_code = 1;
187 KeyParameters params = 2;
188 OperationHandle handle = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700189}
190
191// UpdateOperation
192message UpdateOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100193 OperationHandle handle = 1;
194 KeyParameters params = 2;
195 bytes input = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700196}
197message UpdateOperationResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100198 uint32 error_code = 1;
199 uint32 consumed = 2;
200 KeyParameters params = 3;
201 bytes output = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700202}
203
204// FinishOperation
205message FinishOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100206 OperationHandle handle = 1;
207 KeyParameters params = 2;
208 bytes input = 3;
209 bytes signature = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700210};
211message FinishOperationResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100212 uint32 error_code = 1;
213 KeyParameters params = 2;
214 bytes output = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700215};
216
217// AbortOperation
218message AbortOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100219 OperationHandle handle = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700220};
nagendra modadugu36966942017-09-26 15:56:24 -0700221message AbortOperationResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100222 uint32 error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700223};
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700224
225/*
226 * KM4 messages.
227 */
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800228
229// ImportWrappedKey
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700230message ImportWrappedKeyRequest {
nagendra modadugubdf53cd2017-12-04 21:28:02 -0800231 uint32 key_format = 1;
232 KeyParameters params = 2;
233 bytes rsa_envelope = 3;
234 bytes initialization_vector = 4; // Fixed sized array.
235 bytes encrypted_import_key = 5;
236 bytes aad = 6;
237 bytes gcm_tag = 7; // Fixed sized array.
238 KeyBlob wrapping_key_blob = 8;
239 bytes masking_key = 9; // Fixed sized array.
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700240}
nagendra modadugubdf53cd2017-12-04 21:28:02 -0800241// ImportWrappedKey returns a ImportKeyResponse.
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800242
243/*
244 * Vendor HAL.
245 */
246
247// SetRootOfTrustRequest
248// Only callable by the Bootloader.
249message SetRootOfTrustRequest {
250 bytes digest = 1;
251}
252message SetRootOfTrustResponse {
253 // Specified in keymaster_defs.proto:ErrorCode
254 uint32 error_code = 1;
255}
256
257// SetBootStateRequest
258// Only callable by the Bootloader.
259message SetBootStateRequest {
260 bool is_unlocked = 1;
261 bytes public_key = 2;
262 uint32 color = 3;
263 uint32 system_version = 4;
264 uint32 system_security_level = 5;
265}
266message SetBootStateResponse {
267 // Specified in keymaster_defs.proto:ErrorCode
268 uint32 error_code = 1;
269}