blob: 659501dae64f86a56691abf4a643d559c0e1f44e [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 */
68 rpc ImportWrappedKey (ImportWrappedKeyRequest) returns (ImportWrappedKeyResponse);
nagendra modadugubdcfaa82017-09-17 17:11:36 -070069
Andrew Scull36ebf2d2017-10-10 11:25:21 +010070 /*
71 * Vendor specific methods (manufacturing, status, factory reset, upgrade).
72 */
nagendra modadugubdcfaa82017-09-17 17:11:36 -070073}
74
75/*
nagendra modadugubdcfaa82017-09-17 17:11:36 -070076 * KM3 messages.
77 */
78
nagendra modadugubdcfaa82017-09-17 17:11:36 -070079// AddEntropy
80message AddRngEntropyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +010081 bytes data = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -070082}
nagendra modadugu36966942017-09-26 15:56:24 -070083message AddRngEntropyResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +010084 // TODO: replace with ErrorCode enum
85 uint32 error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -070086}
nagendra modadugubdcfaa82017-09-17 17:11:36 -070087
88// GenerateKey
89message GenerateKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +010090 KeyParameters params = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -070091}
92message GenerateKeyResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +010093 uint32 error_code = 1;
94 KeyBlob blob = 2;
95 KeyCharacteristics characteristics = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -070096}
97
98// GetKeyCharacteristics
99message GetKeyCharacteristicsRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100100 KeyBlob blob = 1;
101 bytes client_id = 2;
102 bytes app_data = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700103}
104message GetKeyCharacteristicsResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100105 uint32 error_code = 1;
106 KeyCharacteristics characteristics = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700107}
108
109// ImportKey
110message ImportKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100111 KeyParameters params = 1;
112 RSAKey rsa = 2;
113 ECKey ec = 3;
114 SymmetricKey symmetric_key = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700115};
116message ImportKeyResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100117 // TODO: include an ErrorCode field
118 uint32 error_code = 1;
119 KeyBlob blob = 2;
120 KeyCharacteristics characteristics = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700121};
122
123// ExportKey
124message ExportKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100125 KeyFormat format = 1;
126 KeyBlob blob = 2;
127 bytes client_id = 3;
128 bytes app_data = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700129};
130message ExportKeyResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100131 uint32 error_code = 1;
132 bytes key_material = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700133};
134
135// AttestKey
136message AttestKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100137 KeyBlob blob = 1;
138 KeyParameters params = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700139}
140message AttestKeyResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100141 uint32 error_code = 1;
142 CertificateChain chain = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700143}
144
145// UpgradeKey
146message UpgradeKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100147 KeyBlob blob = 1;
148 KeyParameters params = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700149}
150message UpgradeKeyResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100151 uint32 error_code = 1;
152 KeyBlob blob = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700153}
154
155// DeleteKey
156message DeleteKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100157 KeyBlob blob = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700158}
nagendra modadugu36966942017-09-26 15:56:24 -0700159message DeleteKeyResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100160 uint32 error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700161}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700162
163// DeleteAllKeys
164message DeleteAllKeysRequest {}
nagendra modadugu36966942017-09-26 15:56:24 -0700165message DeleteAllKeysResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100166 uint32 error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700167}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700168
169// DestroyAttestationIds
170message DestroyAttestationIdsRequest {}
nagendra modadugu36966942017-09-26 15:56:24 -0700171message DestroyAttestationIdsResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100172 uint32 error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700173}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700174
175// BeginOperation
176message BeginOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100177 KeyPurpose purpose = 1;
178 KeyBlob blob = 2;
179 KeyParameters params = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700180}
181message BeginOperationResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100182 uint32 error_code = 1;
183 KeyParameters params = 2;
184 OperationHandle handle = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700185}
186
187// UpdateOperation
188message UpdateOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100189 OperationHandle handle = 1;
190 KeyParameters params = 2;
191 bytes input = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700192}
193message UpdateOperationResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100194 uint32 error_code = 1;
195 uint32 consumed = 2;
196 KeyParameters params = 3;
197 bytes output = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700198}
199
200// FinishOperation
201message FinishOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100202 OperationHandle handle = 1;
203 KeyParameters params = 2;
204 bytes input = 3;
205 bytes signature = 4;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700206};
207message FinishOperationResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100208 uint32 error_code = 1;
209 KeyParameters params = 2;
210 bytes output = 3;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700211};
212
213// AbortOperation
214message AbortOperationRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100215 OperationHandle handle = 1;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700216};
nagendra modadugu36966942017-09-26 15:56:24 -0700217message AbortOperationResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100218 uint32 error_code = 1;
nagendra modadugu36966942017-09-26 15:56:24 -0700219};
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700220
221/*
222 * KM4 messages.
223 */
224message ImportWrappedKeyRequest {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100225 KeyBlob wrapping_key_blob = 1;
226 bytes wrapped_key = 2;
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700227}
nagendra modadugubdcfaa82017-09-17 17:11:36 -0700228message ImportWrappedKeyResponse {
Andrew Scull36ebf2d2017-10-10 11:25:21 +0100229 uint32 error_code = 1;
230 KeyBlob blob = 2;
231 KeyCharacteristics characteristics = 3;
nagendra modadugu89e50ed2017-10-30 22:13:01 -0700232}