nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | syntax = "proto3"; |
| 18 | |
| 19 | package nugget.app.keymaster; |
| 20 | |
Andrew Scull | b5f24a5 | 2017-10-13 19:46:40 +0100 | [diff] [blame] | 21 | import "nugget/app/keymaster/keymaster_defs.proto"; |
| 22 | import "nugget/app/keymaster/keymaster_types.proto"; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 23 | import "nugget/protobuf/options.proto"; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 24 | |
| 25 | /* |
| 26 | * Keymaster service methods. |
| 27 | * |
| 28 | * TODO: some methods may be implemented in the host side HAL implementation. |
| 29 | */ |
| 30 | service Keymaster { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 31 | option (nugget.protobuf.app_id) = "KEYMASTER"; |
| 32 | option (nugget.protobuf.app_name) = "Keymaster"; |
| 33 | option (nugget.protobuf.app_version) = 1; |
nagendra modadugu | 89e50ed | 2017-10-30 22:13:01 -0700 | [diff] [blame] | 34 | /* |
| 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 modadugu | 4f532bc | 2018-01-23 16:39:04 -0800 | [diff] [blame] | 43 | option (nugget.protobuf.request_buffer_size) = 3072; |
nagendra modadugu | 89e50ed | 2017-10-30 22:13:01 -0700 | [diff] [blame] | 44 | option (nugget.protobuf.response_buffer_size) = 2048; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 45 | |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 46 | /* |
| 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 modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 64 | |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 65 | /* |
| 66 | * KM4 methods. |
| 67 | */ |
nagendra modadugu | bdf53cd | 2017-12-04 21:28:02 -0800 | [diff] [blame] | 68 | rpc ImportWrappedKey (ImportWrappedKeyRequest) returns (ImportKeyResponse); |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 69 | |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 70 | /* |
nagendra modadugu | 6023a7d | 2017-11-08 14:40:49 -0800 | [diff] [blame] | 71 | * Vendor specific methods (bootloader, manufacturing, status, |
| 72 | * factory reset, upgrade). |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 73 | */ |
nagendra modadugu | 6023a7d | 2017-11-08 14:40:49 -0800 | [diff] [blame] | 74 | // Only callable by the Bootloader. |
| 75 | rpc SetRootOfTrust (SetRootOfTrustRequest) returns (SetRootOfTrustResponse); |
| 76 | // Only callable by the Bootloader. |
| 77 | rpc SetBootState (SetBootStateRequest) returns (SetBootStateResponse); |
nagendra modadugu | 0121ffb | 2018-03-08 22:37:33 -0800 | [diff] [blame^] | 78 | // 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); |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | /* |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 85 | * KM3 messages. |
| 86 | */ |
| 87 | |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 88 | // AddEntropy |
| 89 | message AddRngEntropyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 90 | bytes data = 1; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 91 | } |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 92 | message AddRngEntropyResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame] | 93 | ErrorCode error_code = 1; |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 94 | } |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 95 | |
| 96 | // GenerateKey |
| 97 | message GenerateKeyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 98 | KeyParameters params = 1; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 99 | } |
| 100 | message GenerateKeyResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame] | 101 | ErrorCode error_code = 1; |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 102 | KeyBlob blob = 2; |
| 103 | KeyCharacteristics characteristics = 3; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | // GetKeyCharacteristics |
| 107 | message GetKeyCharacteristicsRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 108 | KeyBlob blob = 1; |
| 109 | bytes client_id = 2; |
| 110 | bytes app_data = 3; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 111 | } |
| 112 | message GetKeyCharacteristicsResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame] | 113 | ErrorCode error_code = 1; |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 114 | KeyCharacteristics characteristics = 2; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | // ImportKey |
| 118 | message ImportKeyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 119 | KeyParameters params = 1; |
| 120 | RSAKey rsa = 2; |
| 121 | ECKey ec = 3; |
| 122 | SymmetricKey symmetric_key = 4; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 123 | }; |
| 124 | message ImportKeyResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame] | 125 | ErrorCode error_code = 1; |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 126 | KeyBlob blob = 2; |
| 127 | KeyCharacteristics characteristics = 3; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 128 | }; |
| 129 | |
| 130 | // ExportKey |
| 131 | message ExportKeyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 132 | KeyFormat format = 1; |
| 133 | KeyBlob blob = 2; |
| 134 | bytes client_id = 3; |
| 135 | bytes app_data = 4; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 136 | }; |
| 137 | message ExportKeyResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame] | 138 | ErrorCode error_code = 1; |
nagendra modadugu | 95ac9bb | 2018-01-24 16:33:03 -0800 | [diff] [blame] | 139 | Algorithm algorithm = 2; |
| 140 | RSAKey rsa = 3; |
| 141 | ECKey ec = 4; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 142 | }; |
| 143 | |
| 144 | // AttestKey |
| 145 | message AttestKeyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 146 | KeyBlob blob = 1; |
| 147 | KeyParameters params = 2; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 148 | } |
| 149 | message AttestKeyResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame] | 150 | ErrorCode error_code = 1; |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 151 | CertificateChain chain = 2; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | // UpgradeKey |
| 155 | message UpgradeKeyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 156 | KeyBlob blob = 1; |
| 157 | KeyParameters params = 2; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 158 | } |
| 159 | message UpgradeKeyResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame] | 160 | ErrorCode error_code = 1; |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 161 | KeyBlob blob = 2; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | // DeleteKey |
| 165 | message DeleteKeyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 166 | KeyBlob blob = 1; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 167 | } |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 168 | message DeleteKeyResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame] | 169 | ErrorCode error_code = 1; |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 170 | } |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 171 | |
| 172 | // DeleteAllKeys |
| 173 | message DeleteAllKeysRequest {} |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 174 | message DeleteAllKeysResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame] | 175 | ErrorCode error_code = 1; |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 176 | } |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 177 | |
| 178 | // DestroyAttestationIds |
| 179 | message DestroyAttestationIdsRequest {} |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 180 | message DestroyAttestationIdsResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame] | 181 | ErrorCode error_code = 1; |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 182 | } |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 183 | |
| 184 | // BeginOperation |
| 185 | message BeginOperationRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 186 | KeyPurpose purpose = 1; |
| 187 | KeyBlob blob = 2; |
| 188 | KeyParameters params = 3; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 189 | } |
| 190 | message BeginOperationResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame] | 191 | ErrorCode error_code = 1; |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 192 | KeyParameters params = 2; |
| 193 | OperationHandle handle = 3; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | // UpdateOperation |
| 197 | message UpdateOperationRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 198 | OperationHandle handle = 1; |
| 199 | KeyParameters params = 2; |
| 200 | bytes input = 3; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 201 | } |
| 202 | message UpdateOperationResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame] | 203 | ErrorCode error_code = 1; |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 204 | uint32 consumed = 2; |
| 205 | KeyParameters params = 3; |
| 206 | bytes output = 4; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | // FinishOperation |
| 210 | message FinishOperationRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 211 | OperationHandle handle = 1; |
| 212 | KeyParameters params = 2; |
| 213 | bytes input = 3; |
| 214 | bytes signature = 4; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 215 | }; |
| 216 | message FinishOperationResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame] | 217 | ErrorCode error_code = 1; |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 218 | KeyParameters params = 2; |
| 219 | bytes output = 3; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 220 | }; |
| 221 | |
| 222 | // AbortOperation |
| 223 | message AbortOperationRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 224 | OperationHandle handle = 1; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 225 | }; |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 226 | message AbortOperationResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame] | 227 | ErrorCode error_code = 1; |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 228 | }; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 229 | |
| 230 | /* |
| 231 | * KM4 messages. |
| 232 | */ |
nagendra modadugu | 6023a7d | 2017-11-08 14:40:49 -0800 | [diff] [blame] | 233 | |
| 234 | // ImportWrappedKey |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 235 | message ImportWrappedKeyRequest { |
nagendra modadugu | bdf53cd | 2017-12-04 21:28:02 -0800 | [diff] [blame] | 236 | uint32 key_format = 1; |
| 237 | KeyParameters params = 2; |
| 238 | bytes rsa_envelope = 3; |
| 239 | bytes initialization_vector = 4; // Fixed sized array. |
| 240 | bytes encrypted_import_key = 5; |
| 241 | bytes aad = 6; |
| 242 | bytes gcm_tag = 7; // Fixed sized array. |
| 243 | KeyBlob wrapping_key_blob = 8; |
| 244 | bytes masking_key = 9; // Fixed sized array. |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 245 | } |
nagendra modadugu | bdf53cd | 2017-12-04 21:28:02 -0800 | [diff] [blame] | 246 | // ImportWrappedKey returns a ImportKeyResponse. |
nagendra modadugu | 6023a7d | 2017-11-08 14:40:49 -0800 | [diff] [blame] | 247 | |
| 248 | /* |
| 249 | * Vendor HAL. |
| 250 | */ |
| 251 | |
| 252 | // SetRootOfTrustRequest |
| 253 | // Only callable by the Bootloader. |
| 254 | message SetRootOfTrustRequest { |
| 255 | bytes digest = 1; |
| 256 | } |
| 257 | message SetRootOfTrustResponse { |
| 258 | // Specified in keymaster_defs.proto:ErrorCode |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame] | 259 | ErrorCode error_code = 1; |
nagendra modadugu | 6023a7d | 2017-11-08 14:40:49 -0800 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | // SetBootStateRequest |
| 263 | // Only callable by the Bootloader. |
| 264 | message SetBootStateRequest { |
| 265 | bool is_unlocked = 1; |
| 266 | bytes public_key = 2; |
| 267 | uint32 color = 3; |
| 268 | uint32 system_version = 4; |
| 269 | uint32 system_security_level = 5; |
| 270 | } |
| 271 | message SetBootStateResponse { |
| 272 | // Specified in keymaster_defs.proto:ErrorCode |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame] | 273 | ErrorCode error_code = 1; |
nagendra modadugu | 0121ffb | 2018-03-08 22:37:33 -0800 | [diff] [blame^] | 274 | } |
| 275 | |
| 276 | // ProvisionDeviceIds |
| 277 | // Only callable at the Device Factory |
| 278 | message ProvisionDeviceIdsRequest { |
| 279 | bytes product_brand = 1; |
| 280 | bytes product_device = 2; |
| 281 | bytes product_name = 3; |
| 282 | bytes serialno = 4; |
| 283 | bytes product_manufacturer = 5; |
| 284 | bytes product_model = 6; |
| 285 | bytes imei = 7; |
| 286 | bytes meid = 8; |
| 287 | } |
| 288 | message ProvisionDeviceIdsResponse { |
| 289 | // Specified in keymaster_defs.proto:ErrorCode |
| 290 | ErrorCode error_code = 1; |
| 291 | } |
| 292 | |
| 293 | // ReadTeeBatchCertificate |
| 294 | // Only callable at the Device Factory |
| 295 | message ReadTeeBatchCertificateRequest { |
| 296 | Algorithm algorithm = 1; |
| 297 | } |
| 298 | message ReadTeeBatchCertificateResponse { |
| 299 | ErrorCode error_code = 1; |
| 300 | RSAKey rsa = 2; // rsa or ec set based on request algorithm selector. |
| 301 | ECKey ec = 3; |
| 302 | bytes batch_cert = 4; |
| 303 | } |