blob: 092603c9d65b119ef0dba40e8bfc3427a6ddd988 [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 */
nagendra modadugu4f532bc2018-01-23 16:39:04 -080043 option (nugget.protobuf.request_buffer_size) = 3072;
nagendra modadugu89e50ed2017-10-30 22:13:01 -070044 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 modadugu0121ffb2018-03-08 22:37:33 -080078 // Only callable at the Device Factory.
79 rpc ProvisionDeviceIds (ProvisionDeviceIdsRequest) returns (ProvisionDeviceIdsResponse);
80 // Only callable at the Device Factory.
81 rpc ReadTeeBatchCertificate (ReadTeeBatchCertificateRequest) returns (ReadTeeBatchCertificateResponse);
Janis Danisevskis4f705a72018-04-13 14:52:38 -070082
83 /*
84 * More KM4 methods.
85 */
86 rpc GetHmacSharingParameters (GetHmacSharingParametersRequest) returns (GetHmacSharingParametersResponse);
87 rpc ComputeSharedHmac (ComputeSharedHmacRequest) returns (ComputeSharedHmacResponse);
Janis Danisevskise0a319a2018-04-11 16:51:44 -070088
89 /*
90 * DTup input session methods.
91 */
92 rpc HandshakeDTup (DTupHandshakeRequest) returns (DTupHandshakeResponse);
93 rpc FetchDTupInputEvent (DTupFetchInputEventRequest) returns (DTupFetchInputEventResponse);
nagendra modadugubdcfaa82017-09-17 17:11:36 -070094}
95
96/*
nagendra modadugubdcfaa82017-09-17 17:11:36 -070097 * KM3 messages.
98 */
99
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700100// AddEntropy
101message AddRngEntropyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100102 bytes data = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700103}
nagendra modadugu36966942017-09-26 15:56:24 -0700104message AddRngEntropyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800105 ErrorCode error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700106}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700107
108// GenerateKey
109message GenerateKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100110 KeyParameters params = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700111}
112message GenerateKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800113 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100114 KeyBlob blob = 2;
115 KeyCharacteristics characteristics = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700116}
117
118// GetKeyCharacteristics
119message GetKeyCharacteristicsRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100120 KeyBlob blob = 1;
121 bytes client_id = 2;
122 bytes app_data = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700123}
124message GetKeyCharacteristicsResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800125 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100126 KeyCharacteristics characteristics = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700127}
128
129// ImportKey
130message ImportKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100131 KeyParameters params = 1;
132 RSAKey rsa = 2;
133 ECKey ec = 3;
134 SymmetricKey symmetric_key = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700135};
136message ImportKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800137 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100138 KeyBlob blob = 2;
139 KeyCharacteristics characteristics = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700140};
141
142// ExportKey
143message ExportKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100144 KeyFormat format = 1;
145 KeyBlob blob = 2;
146 bytes client_id = 3;
147 bytes app_data = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700148};
149message ExportKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800150 ErrorCode error_code = 1;
nagendra modadugu95ac9bb2018-01-24 16:33:03 -0800151 Algorithm algorithm = 2;
152 RSAKey rsa = 3;
153 ECKey ec = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700154};
155
156// AttestKey
157message AttestKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100158 KeyBlob blob = 1;
159 KeyParameters params = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700160}
161message AttestKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800162 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100163 CertificateChain chain = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700164}
165
166// UpgradeKey
167message UpgradeKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100168 KeyBlob blob = 1;
169 KeyParameters params = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700170}
171message UpgradeKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800172 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100173 KeyBlob blob = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700174}
175
176// DeleteKey
177message DeleteKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100178 KeyBlob blob = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700179}
nagendra modadugu36966942017-09-26 15:56:24 -0700180message DeleteKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800181 ErrorCode error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700182}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700183
184// DeleteAllKeys
185message DeleteAllKeysRequest {}
nagendra modadugu36966942017-09-26 15:56:24 -0700186message DeleteAllKeysResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800187 ErrorCode error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700188}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700189
190// DestroyAttestationIds
191message DestroyAttestationIdsRequest {}
nagendra modadugu36966942017-09-26 15:56:24 -0700192message DestroyAttestationIdsResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800193 ErrorCode error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700194}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700195
196// BeginOperation
197message BeginOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100198 KeyPurpose purpose = 1;
199 KeyBlob blob = 2;
200 KeyParameters params = 3;
nagendra modadugu251238b2018-05-07 16:24:49 -0700201 HardwareAuthToken auth_token = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700202}
203message BeginOperationResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800204 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100205 KeyParameters params = 2;
206 OperationHandle handle = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700207}
208
209// UpdateOperation
210message UpdateOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100211 OperationHandle handle = 1;
212 KeyParameters params = 2;
213 bytes input = 3;
nagendra modadugu251238b2018-05-07 16:24:49 -0700214 HardwareAuthToken auth_token = 4;
215 VerificationToken verification_token = 5;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700216}
217message UpdateOperationResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800218 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100219 uint32 consumed = 2;
220 KeyParameters params = 3;
221 bytes output = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700222}
223
224// FinishOperation
225message FinishOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100226 OperationHandle handle = 1;
227 KeyParameters params = 2;
228 bytes input = 3;
229 bytes signature = 4;
nagendra modadugu251238b2018-05-07 16:24:49 -0700230 HardwareAuthToken auth_token = 5;
231 VerificationToken verification_token = 6;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700232};
233message FinishOperationResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800234 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100235 KeyParameters params = 2;
236 bytes output = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700237};
238
239// AbortOperation
240message AbortOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100241 OperationHandle handle = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700242};
nagendra modadugu36966942017-09-26 15:56:24 -0700243message AbortOperationResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800244 ErrorCode error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700245};
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700246
247/*
248 * KM4 messages.
249 */
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800250
251// ImportWrappedKey
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700252message ImportWrappedKeyRequest {
nagendra modadugubdf53cd2017-12-04 21:28:02 -0800253 uint32 key_format = 1;
254 KeyParameters params = 2;
255 bytes rsa_envelope = 3;
256 bytes initialization_vector = 4; // Fixed sized array.
257 bytes encrypted_import_key = 5;
258 bytes aad = 6;
259 bytes gcm_tag = 7; // Fixed sized array.
260 KeyBlob wrapping_key_blob = 8;
261 bytes masking_key = 9; // Fixed sized array.
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700262}
nagendra modadugubdf53cd2017-12-04 21:28:02 -0800263// ImportWrappedKey returns a ImportKeyResponse.
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800264
nagendra modadugu251238b2018-05-07 16:24:49 -0700265// GetHmacSharingParametersRequest
266message GetHmacSharingParametersRequest {
267}
268message GetHmacSharingParametersResponse {
269 ErrorCode error_code = 1;
270 HmacSharingParameters hmac_sharing_params = 2;
271}
272
273// ComputeSharedHmacRequest
274message ComputeSharedHmacRequest {
275 repeated HmacSharingParameters hmac_sharing_params = 1;
276}
277message ComputeSharedHmacResponse {
278 ErrorCode error_code = 1;
279 bytes sharing_check = 2;
280}
281
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800282/*
283 * Vendor HAL.
284 */
285
286// SetRootOfTrustRequest
287// Only callable by the Bootloader.
288message SetRootOfTrustRequest {
nagendra modadugu5f490a72018-05-16 13:02:23 -0700289 bytes digest = 1; // This is a SHA256 digest.
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800290}
291message SetRootOfTrustResponse {
292 // Specified in keymaster_defs.proto:ErrorCode
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800293 ErrorCode error_code = 1;
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800294}
295
296// SetBootStateRequest
297// Only callable by the Bootloader.
298message SetBootStateRequest {
299 bool is_unlocked = 1;
nagendra modadugu5f490a72018-05-16 13:02:23 -0700300 bytes public_key = 2; // This is a SHA256 digest.
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800301 uint32 color = 3;
302 uint32 system_version = 4;
303 uint32 system_security_level = 5;
304}
305message SetBootStateResponse {
306 // Specified in keymaster_defs.proto:ErrorCode
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800307 ErrorCode error_code = 1;
nagendra modadugu0121ffb2018-03-08 22:37:33 -0800308}
309
310// ProvisionDeviceIds
311// Only callable at the Device Factory
312message ProvisionDeviceIdsRequest {
313 bytes product_brand = 1;
314 bytes product_device = 2;
315 bytes product_name = 3;
316 bytes serialno = 4;
317 bytes product_manufacturer = 5;
318 bytes product_model = 6;
319 bytes imei = 7;
320 bytes meid = 8;
321}
322message ProvisionDeviceIdsResponse {
323 // Specified in keymaster_defs.proto:ErrorCode
324 ErrorCode error_code = 1;
325}
326
327// ReadTeeBatchCertificate
328// Only callable at the Device Factory
329message ReadTeeBatchCertificateRequest {
330 Algorithm algorithm = 1;
331}
332message ReadTeeBatchCertificateResponse {
333 ErrorCode error_code = 1;
334 RSAKey rsa = 2; // rsa or ec set based on request algorithm selector.
335 ECKey ec = 3;
336 bytes batch_cert = 4;
337}
Janis Danisevskis4f705a72018-04-13 14:52:38 -0700338
Janis Danisevskise0a319a2018-04-11 16:51:44 -0700339message DTupHandshakeRequest {
340 bytes nonce_client = 1;
341}
342
343message DTupHandshakeResponse {
344 DTupError error_code = 1;
345 bytes nonce_citadel = 2;
346 bytes signature = 3;
347}
348
349message DTupFetchInputEventRequest {}
350
351message DTupFetchInputEventResponse {
352 DTupError error_code = 1;
353 DTupKeyEvent event = 2;
354 bytes signature = 3;
355}