blob: 99a18ef5d3be80dcb6ee7075945f4364d00b6219 [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);
Allen Webb4424c2c2018-05-25 08:31:56 -070094
95 /*
96 * More vendor specific methods.
97 */
98 // Only callable once per boot.
99 rpc SetSystemVersionInfo (SetSystemVersionInfoRequest) returns (SetSystemVersionInfoResponse);
100
101 // These are implemented with a enum, so new RPCs must be appended, and
102 // deprecated RPCs need placeholders.
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700103}
104
105/*
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700106 * KM3 messages.
107 */
108
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700109// AddEntropy
110message AddRngEntropyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100111 bytes data = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700112}
nagendra modadugu36966942017-09-26 15:56:24 -0700113message AddRngEntropyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800114 ErrorCode error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700115}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700116
117// GenerateKey
118message GenerateKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100119 KeyParameters params = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700120}
121message GenerateKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800122 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100123 KeyBlob blob = 2;
124 KeyCharacteristics characteristics = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700125}
126
127// GetKeyCharacteristics
128message GetKeyCharacteristicsRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100129 KeyBlob blob = 1;
130 bytes client_id = 2;
131 bytes app_data = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700132}
133message GetKeyCharacteristicsResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800134 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100135 KeyCharacteristics characteristics = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700136}
137
138// ImportKey
139message ImportKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100140 KeyParameters params = 1;
141 RSAKey rsa = 2;
142 ECKey ec = 3;
143 SymmetricKey symmetric_key = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700144};
145message ImportKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800146 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100147 KeyBlob blob = 2;
148 KeyCharacteristics characteristics = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700149};
150
151// ExportKey
152message ExportKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100153 KeyFormat format = 1;
154 KeyBlob blob = 2;
155 bytes client_id = 3;
156 bytes app_data = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700157};
158message ExportKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800159 ErrorCode error_code = 1;
nagendra modadugu95ac9bb2018-01-24 16:33:03 -0800160 Algorithm algorithm = 2;
161 RSAKey rsa = 3;
162 ECKey ec = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700163};
164
165// AttestKey
166message AttestKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100167 KeyBlob blob = 1;
168 KeyParameters params = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700169}
170message AttestKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800171 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100172 CertificateChain chain = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700173}
174
175// UpgradeKey
176message UpgradeKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100177 KeyBlob blob = 1;
178 KeyParameters params = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700179}
180message UpgradeKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800181 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100182 KeyBlob blob = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700183}
184
185// DeleteKey
186message DeleteKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100187 KeyBlob blob = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700188}
nagendra modadugu36966942017-09-26 15:56:24 -0700189message DeleteKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800190 ErrorCode error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700191}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700192
193// DeleteAllKeys
194message DeleteAllKeysRequest {}
nagendra modadugu36966942017-09-26 15:56:24 -0700195message DeleteAllKeysResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800196 ErrorCode error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700197}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700198
199// DestroyAttestationIds
200message DestroyAttestationIdsRequest {}
nagendra modadugu36966942017-09-26 15:56:24 -0700201message DestroyAttestationIdsResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800202 ErrorCode error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700203}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700204
205// BeginOperation
206message BeginOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100207 KeyPurpose purpose = 1;
208 KeyBlob blob = 2;
209 KeyParameters params = 3;
nagendra modadugu251238b2018-05-07 16:24:49 -0700210 HardwareAuthToken auth_token = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700211}
212message BeginOperationResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800213 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100214 KeyParameters params = 2;
215 OperationHandle handle = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700216}
217
218// UpdateOperation
219message UpdateOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100220 OperationHandle handle = 1;
221 KeyParameters params = 2;
222 bytes input = 3;
nagendra modadugu251238b2018-05-07 16:24:49 -0700223 HardwareAuthToken auth_token = 4;
224 VerificationToken verification_token = 5;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700225}
226message UpdateOperationResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800227 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100228 uint32 consumed = 2;
229 KeyParameters params = 3;
230 bytes output = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700231}
232
233// FinishOperation
234message FinishOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100235 OperationHandle handle = 1;
236 KeyParameters params = 2;
237 bytes input = 3;
238 bytes signature = 4;
nagendra modadugu251238b2018-05-07 16:24:49 -0700239 HardwareAuthToken auth_token = 5;
240 VerificationToken verification_token = 6;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700241};
242message FinishOperationResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800243 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100244 KeyParameters params = 2;
245 bytes output = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700246};
247
248// AbortOperation
249message AbortOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100250 OperationHandle handle = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700251};
nagendra modadugu36966942017-09-26 15:56:24 -0700252message AbortOperationResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800253 ErrorCode error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700254};
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700255
256/*
257 * KM4 messages.
258 */
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800259
260// ImportWrappedKey
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700261message ImportWrappedKeyRequest {
nagendra modadugubdf53cd2017-12-04 21:28:02 -0800262 uint32 key_format = 1;
263 KeyParameters params = 2;
264 bytes rsa_envelope = 3;
265 bytes initialization_vector = 4; // Fixed sized array.
266 bytes encrypted_import_key = 5;
267 bytes aad = 6;
268 bytes gcm_tag = 7; // Fixed sized array.
269 KeyBlob wrapping_key_blob = 8;
270 bytes masking_key = 9; // Fixed sized array.
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700271}
nagendra modadugubdf53cd2017-12-04 21:28:02 -0800272// ImportWrappedKey returns a ImportKeyResponse.
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800273
nagendra modadugu251238b2018-05-07 16:24:49 -0700274// GetHmacSharingParametersRequest
275message GetHmacSharingParametersRequest {
276}
277message GetHmacSharingParametersResponse {
278 ErrorCode error_code = 1;
279 HmacSharingParameters hmac_sharing_params = 2;
280}
281
282// ComputeSharedHmacRequest
283message ComputeSharedHmacRequest {
284 repeated HmacSharingParameters hmac_sharing_params = 1;
285}
286message ComputeSharedHmacResponse {
287 ErrorCode error_code = 1;
288 bytes sharing_check = 2;
289}
290
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800291/*
292 * Vendor HAL.
293 */
294
295// SetRootOfTrustRequest
296// Only callable by the Bootloader.
297message SetRootOfTrustRequest {
nagendra modadugu5f490a72018-05-16 13:02:23 -0700298 bytes digest = 1; // This is a SHA256 digest.
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800299}
300message SetRootOfTrustResponse {
301 // Specified in keymaster_defs.proto:ErrorCode
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800302 ErrorCode error_code = 1;
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800303}
304
305// SetBootStateRequest
306// Only callable by the Bootloader.
307message SetBootStateRequest {
308 bool is_unlocked = 1;
nagendra modadugu5f490a72018-05-16 13:02:23 -0700309 bytes public_key = 2; // This is a SHA256 digest.
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800310 uint32 color = 3;
311 uint32 system_version = 4;
312 uint32 system_security_level = 5;
313}
314message SetBootStateResponse {
315 // Specified in keymaster_defs.proto:ErrorCode
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800316 ErrorCode error_code = 1;
nagendra modadugu0121ffb2018-03-08 22:37:33 -0800317}
318
319// ProvisionDeviceIds
320// Only callable at the Device Factory
321message ProvisionDeviceIdsRequest {
322 bytes product_brand = 1;
323 bytes product_device = 2;
324 bytes product_name = 3;
325 bytes serialno = 4;
326 bytes product_manufacturer = 5;
327 bytes product_model = 6;
328 bytes imei = 7;
329 bytes meid = 8;
330}
331message ProvisionDeviceIdsResponse {
332 // Specified in keymaster_defs.proto:ErrorCode
333 ErrorCode error_code = 1;
334}
335
336// ReadTeeBatchCertificate
337// Only callable at the Device Factory
338message ReadTeeBatchCertificateRequest {
339 Algorithm algorithm = 1;
340}
341message ReadTeeBatchCertificateResponse {
342 ErrorCode error_code = 1;
343 RSAKey rsa = 2; // rsa or ec set based on request algorithm selector.
344 ECKey ec = 3;
345 bytes batch_cert = 4;
346}
Janis Danisevskis4f705a72018-04-13 14:52:38 -0700347
Janis Danisevskise0a319a2018-04-11 16:51:44 -0700348message DTupHandshakeRequest {
349 bytes nonce_client = 1;
350}
351
352message DTupHandshakeResponse {
353 DTupError error_code = 1;
354 bytes nonce_citadel = 2;
355 bytes signature = 3;
356}
357
358message DTupFetchInputEventRequest {}
359
360message DTupFetchInputEventResponse {
361 DTupError error_code = 1;
362 DTupKeyEvent event = 2;
363 bytes signature = 3;
364}
Allen Webb4424c2c2018-05-25 08:31:56 -0700365
366message SetSystemVersionInfoRequest {
367 uint32 system_version = 1; // getprop "ro.build.version.release"
368 uint32 system_security_level = 2; // getprop "ro.build.version.security_patch"
369 uint32 vendor_security_level = 3; // getprop "ro.vendor.build.security_patch"
370}
371
372message SetSystemVersionInfoResponse {
373 // Specified in keymaster_defs.proto:ErrorCode
374 ErrorCode error_code = 1;
375}