blob: 0a48aa8bbce4ef15ecb9e5111394fd79018f886c [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 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 {
nagendra modadugu4405b6b2017-12-28 11:17:18 -080089 ErrorCode error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -070090}
nagendra modadugubdcfaa82017-09-17 17:11:36 -070091
92// GenerateKey
93message GenerateKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +010094 KeyParameters params = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -070095}
96message GenerateKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -080097 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +010098 KeyBlob blob = 2;
99 KeyCharacteristics characteristics = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700100}
101
102// GetKeyCharacteristics
103message GetKeyCharacteristicsRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100104 KeyBlob blob = 1;
105 bytes client_id = 2;
106 bytes app_data = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700107}
108message GetKeyCharacteristicsResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800109 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100110 KeyCharacteristics characteristics = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700111}
112
113// ImportKey
114message ImportKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100115 KeyParameters params = 1;
116 RSAKey rsa = 2;
117 ECKey ec = 3;
118 SymmetricKey symmetric_key = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700119};
120message ImportKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800121 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100122 KeyBlob blob = 2;
123 KeyCharacteristics characteristics = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700124};
125
126// ExportKey
127message ExportKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100128 KeyFormat format = 1;
129 KeyBlob blob = 2;
130 bytes client_id = 3;
131 bytes app_data = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700132};
133message ExportKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800134 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100135 bytes key_material = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700136};
137
138// AttestKey
139message AttestKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100140 KeyBlob blob = 1;
141 KeyParameters params = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700142}
143message AttestKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800144 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100145 CertificateChain chain = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700146}
147
148// UpgradeKey
149message UpgradeKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100150 KeyBlob blob = 1;
151 KeyParameters params = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700152}
153message UpgradeKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800154 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100155 KeyBlob blob = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700156}
157
158// DeleteKey
159message DeleteKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100160 KeyBlob blob = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700161}
nagendra modadugu36966942017-09-26 15:56:24 -0700162message DeleteKeyResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800163 ErrorCode error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700164}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700165
166// DeleteAllKeys
167message DeleteAllKeysRequest {}
nagendra modadugu36966942017-09-26 15:56:24 -0700168message DeleteAllKeysResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800169 ErrorCode error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700170}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700171
172// DestroyAttestationIds
173message DestroyAttestationIdsRequest {}
nagendra modadugu36966942017-09-26 15:56:24 -0700174message DestroyAttestationIdsResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800175 ErrorCode error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700176}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700177
178// BeginOperation
179message BeginOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100180 KeyPurpose purpose = 1;
181 KeyBlob blob = 2;
182 KeyParameters params = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700183}
184message BeginOperationResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800185 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100186 KeyParameters params = 2;
187 OperationHandle handle = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700188}
189
190// UpdateOperation
191message UpdateOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100192 OperationHandle handle = 1;
193 KeyParameters params = 2;
194 bytes input = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700195}
196message UpdateOperationResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800197 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100198 uint32 consumed = 2;
199 KeyParameters params = 3;
200 bytes output = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700201}
202
203// FinishOperation
204message FinishOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100205 OperationHandle handle = 1;
206 KeyParameters params = 2;
207 bytes input = 3;
208 bytes signature = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700209};
210message FinishOperationResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800211 ErrorCode error_code = 1;
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100212 KeyParameters params = 2;
213 bytes output = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700214};
215
216// AbortOperation
217message AbortOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100218 OperationHandle handle = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700219};
nagendra modadugu36966942017-09-26 15:56:24 -0700220message AbortOperationResponse {
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800221 ErrorCode error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700222};
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700223
224/*
225 * KM4 messages.
226 */
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800227
228// ImportWrappedKey
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700229message ImportWrappedKeyRequest {
nagendra modadugubdf53cd2017-12-04 21:28:02 -0800230 uint32 key_format = 1;
231 KeyParameters params = 2;
232 bytes rsa_envelope = 3;
233 bytes initialization_vector = 4; // Fixed sized array.
234 bytes encrypted_import_key = 5;
235 bytes aad = 6;
236 bytes gcm_tag = 7; // Fixed sized array.
237 KeyBlob wrapping_key_blob = 8;
238 bytes masking_key = 9; // Fixed sized array.
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700239}
nagendra modadugubdf53cd2017-12-04 21:28:02 -0800240// ImportWrappedKey returns a ImportKeyResponse.
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800241
242/*
243 * Vendor HAL.
244 */
245
246// SetRootOfTrustRequest
247// Only callable by the Bootloader.
248message SetRootOfTrustRequest {
249 bytes digest = 1;
250}
251message SetRootOfTrustResponse {
252 // Specified in keymaster_defs.proto:ErrorCode
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800253 ErrorCode error_code = 1;
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800254}
255
256// SetBootStateRequest
257// Only callable by the Bootloader.
258message SetBootStateRequest {
259 bool is_unlocked = 1;
260 bytes public_key = 2;
261 uint32 color = 3;
262 uint32 system_version = 4;
263 uint32 system_security_level = 5;
264}
265message SetBootStateResponse {
266 // Specified in keymaster_defs.proto:ErrorCode
nagendra modadugu4405b6b2017-12-28 11:17:18 -0800267 ErrorCode error_code = 1;
nagendra modadugu6023a7d2017-11-08 14:40:49 -0800268}