blob: 9559106138a95c6d875c2cde9be0f3362f84dc5a [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);
Allen Webbf2e6dcf2018-05-30 14:31:28 -0700100 rpc GetBootInfo (GetBootInfoRequest) returns (GetBootInfoResponse);
Allen Webb4424c2c2018-05-25 08:31:56 -0700101
Janis Danisevskis64a6d542018-05-29 21:56:21 -0700102 /*
103 * Called during provisioning by the CitadelProvision tool.
104 */
105 rpc ProvisionPresharedSecret (ProvisionPresharedSecretRequest) returns (ProvisionPresharedSecretResponse);
Allen Webb4424c2c2018-05-25 08:31:56 -0700106 // These are implemented with a enum, so new RPCs must be appended, and
107 // deprecated RPCs need placeholders.
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700108}
109
110/*
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700111 * KM3 messages.
112 */
113
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700114// AddEntropy
115message AddRngEntropyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100116 bytes data = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700117}
nagendra modadugu36966942017-09-26 15:56:24 -0700118message AddRngEntropyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800119 ErrorCode error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700120}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700121
122// GenerateKey
123message GenerateKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100124 KeyParameters params = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700125}
126message GenerateKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800127 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100128 KeyBlob blob = 2;
129 KeyCharacteristics characteristics = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700130}
131
132// GetKeyCharacteristics
133message GetKeyCharacteristicsRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100134 KeyBlob blob = 1;
135 bytes client_id = 2;
136 bytes app_data = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700137}
138message GetKeyCharacteristicsResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800139 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100140 KeyCharacteristics characteristics = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700141}
142
143// ImportKey
144message ImportKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100145 KeyParameters params = 1;
146 RSAKey rsa = 2;
147 ECKey ec = 3;
148 SymmetricKey symmetric_key = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700149};
150message ImportKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800151 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100152 KeyBlob blob = 2;
153 KeyCharacteristics characteristics = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700154};
155
156// ExportKey
157message ExportKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100158 KeyFormat format = 1;
159 KeyBlob blob = 2;
160 bytes client_id = 3;
161 bytes app_data = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700162};
163message ExportKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800164 ErrorCode error_code = 1;
nagendra modadugu95ac9bb2018-01-24 16:33:03 -0800165 Algorithm algorithm = 2;
166 RSAKey rsa = 3;
167 ECKey ec = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700168};
169
170// AttestKey
171message AttestKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100172 KeyBlob blob = 1;
173 KeyParameters params = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700174}
175message AttestKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800176 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100177 CertificateChain chain = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700178}
179
180// UpgradeKey
181message UpgradeKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100182 KeyBlob blob = 1;
183 KeyParameters params = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700184}
185message UpgradeKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800186 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100187 KeyBlob blob = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700188}
189
190// DeleteKey
191message DeleteKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100192 KeyBlob blob = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700193}
nagendra modadugu36966942017-09-26 15:56:24 -0700194message DeleteKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800195 ErrorCode error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700196}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700197
198// DeleteAllKeys
199message DeleteAllKeysRequest {}
nagendra modadugu36966942017-09-26 15:56:24 -0700200message DeleteAllKeysResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800201 ErrorCode error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700202}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700203
204// DestroyAttestationIds
205message DestroyAttestationIdsRequest {}
nagendra modadugu36966942017-09-26 15:56:24 -0700206message DestroyAttestationIdsResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800207 ErrorCode error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700208}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700209
210// BeginOperation
211message BeginOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100212 KeyPurpose purpose = 1;
213 KeyBlob blob = 2;
214 KeyParameters params = 3;
nagendra modadugu251238b2018-05-07 16:24:49 -0700215 HardwareAuthToken auth_token = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700216}
217message BeginOperationResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800218 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100219 KeyParameters params = 2;
220 OperationHandle handle = 3;
nagendra modaduguf39c9de2018-06-03 02:04:58 -0700221 Algorithm algorithm = 4;
222 uint32 key_bits = 5;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700223}
224
225// UpdateOperation
226message UpdateOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100227 OperationHandle handle = 1;
228 KeyParameters params = 2;
229 bytes input = 3;
nagendra modadugu251238b2018-05-07 16:24:49 -0700230 HardwareAuthToken auth_token = 4;
231 VerificationToken verification_token = 5;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700232}
233message UpdateOperationResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800234 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100235 uint32 consumed = 2;
236 KeyParameters params = 3;
237 bytes output = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700238}
239
240// FinishOperation
241message FinishOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100242 OperationHandle handle = 1;
243 KeyParameters params = 2;
244 bytes input = 3;
245 bytes signature = 4;
nagendra modadugu251238b2018-05-07 16:24:49 -0700246 HardwareAuthToken auth_token = 5;
247 VerificationToken verification_token = 6;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700248};
249message FinishOperationResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800250 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100251 KeyParameters params = 2;
252 bytes output = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700253};
254
255// AbortOperation
256message AbortOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100257 OperationHandle handle = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700258};
nagendra modadugu36966942017-09-26 15:56:24 -0700259message AbortOperationResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800260 ErrorCode error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700261};
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700262
263/*
264 * KM4 messages.
265 */
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800266
267// ImportWrappedKey
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700268message ImportWrappedKeyRequest {
nagendra modadugubdf53cd2017-12-04 21:28:02 -0800269 uint32 key_format = 1;
270 KeyParameters params = 2;
271 bytes rsa_envelope = 3;
272 bytes initialization_vector = 4; // Fixed sized array.
273 bytes encrypted_import_key = 5;
274 bytes aad = 6;
275 bytes gcm_tag = 7; // Fixed sized array.
276 KeyBlob wrapping_key_blob = 8;
277 bytes masking_key = 9; // Fixed sized array.
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700278}
nagendra modadugubdf53cd2017-12-04 21:28:02 -0800279// ImportWrappedKey returns a ImportKeyResponse.
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800280
nagendra modadugu251238b2018-05-07 16:24:49 -0700281// GetHmacSharingParametersRequest
282message GetHmacSharingParametersRequest {
283}
284message GetHmacSharingParametersResponse {
285 ErrorCode error_code = 1;
286 HmacSharingParameters hmac_sharing_params = 2;
287}
288
289// ComputeSharedHmacRequest
290message ComputeSharedHmacRequest {
291 repeated HmacSharingParameters hmac_sharing_params = 1;
292}
293message ComputeSharedHmacResponse {
294 ErrorCode error_code = 1;
295 bytes sharing_check = 2;
296}
297
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800298/*
299 * Vendor HAL.
300 */
301
302// SetRootOfTrustRequest
303// Only callable by the Bootloader.
304message SetRootOfTrustRequest {
nagendra modadugu5f490a72018-05-16 13:02:23 -0700305 bytes digest = 1; // This is a SHA256 digest.
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800306}
307message SetRootOfTrustResponse {
308 // Specified in keymaster_defs.proto:ErrorCode
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800309 ErrorCode error_code = 1;
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800310}
311
312// SetBootStateRequest
313// Only callable by the Bootloader.
314message SetBootStateRequest {
315 bool is_unlocked = 1;
nagendra modadugu5f490a72018-05-16 13:02:23 -0700316 bytes public_key = 2; // This is a SHA256 digest.
nagendra modadugu53158e92018-05-29 12:40:54 -0700317 BootColor color = 3;
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800318 uint32 system_version = 4;
319 uint32 system_security_level = 5;
Allen Webbadfb8a02018-05-25 15:26:13 -0700320 bytes boot_hash = 6; // This is a SHA256 digest.
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800321}
322message SetBootStateResponse {
323 // Specified in keymaster_defs.proto:ErrorCode
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800324 ErrorCode error_code = 1;
nagendra modadugu0121ffb2018-03-08 22:37:33 -0800325}
326
327// ProvisionDeviceIds
328// Only callable at the Device Factory
329message ProvisionDeviceIdsRequest {
330 bytes product_brand = 1;
331 bytes product_device = 2;
332 bytes product_name = 3;
333 bytes serialno = 4;
334 bytes product_manufacturer = 5;
335 bytes product_model = 6;
336 bytes imei = 7;
337 bytes meid = 8;
338}
339message ProvisionDeviceIdsResponse {
340 // Specified in keymaster_defs.proto:ErrorCode
341 ErrorCode error_code = 1;
342}
343
344// ReadTeeBatchCertificate
345// Only callable at the Device Factory
346message ReadTeeBatchCertificateRequest {
347 Algorithm algorithm = 1;
348}
349message ReadTeeBatchCertificateResponse {
350 ErrorCode error_code = 1;
351 RSAKey rsa = 2; // rsa or ec set based on request algorithm selector.
352 ECKey ec = 3;
353 bytes batch_cert = 4;
354}
Janis Danisevskis4f705a72018-04-13 14:52:38 -0700355
Janis Danisevskise0a319a2018-04-11 16:51:44 -0700356message DTupHandshakeRequest {
357 bytes nonce_client = 1;
358}
359
360message DTupHandshakeResponse {
361 DTupError error_code = 1;
362 bytes nonce_citadel = 2;
363 bytes signature = 3;
364}
365
366message DTupFetchInputEventRequest {}
367
368message DTupFetchInputEventResponse {
369 DTupError error_code = 1;
370 DTupKeyEvent event = 2;
371 bytes signature = 3;
372}
Allen Webb4424c2c2018-05-25 08:31:56 -0700373
374message SetSystemVersionInfoRequest {
375 uint32 system_version = 1; // getprop "ro.build.version.release"
376 uint32 system_security_level = 2; // getprop "ro.build.version.security_patch"
377 uint32 vendor_security_level = 3; // getprop "ro.vendor.build.security_patch"
378}
379
380message SetSystemVersionInfoResponse {
381 // Specified in keymaster_defs.proto:ErrorCode
382 ErrorCode error_code = 1;
383}
Allen Webbf2e6dcf2018-05-30 14:31:28 -0700384
385message GetBootInfoRequest {}
386
387message GetBootInfoResponse {
388 ErrorCode error_code = 1;
389 bool is_unlocked = 2;
390 BootColor boot_color = 3;
391 bytes boot_key = 4; // This is a SHA256 digest.
392 bytes boot_hash = 5; // This is a SHA256 digest.
393}
Janis Danisevskis64a6d542018-05-29 21:56:21 -0700394
395message ProvisionPresharedSecretRequest {
396 bytes preshared_secret = 1;
397 bool get_status = 2;
398}
399message ProvisionPresharedSecretResponse {
400 ErrorCode error_code = 1;
401 PresharedSecretStatus status = 2;
402}