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 | */ |
| 43 | option (nugget.protobuf.request_buffer_size) = 2048; |
| 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 | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | /* |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 81 | * KM3 messages. |
| 82 | */ |
| 83 | |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 84 | // AddEntropy |
| 85 | message AddRngEntropyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 86 | bytes data = 1; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 87 | } |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 88 | message AddRngEntropyResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame^] | 89 | ErrorCode error_code = 1; |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 90 | } |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 91 | |
| 92 | // GenerateKey |
| 93 | message GenerateKeyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 94 | KeyParameters params = 1; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 95 | } |
| 96 | message GenerateKeyResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame^] | 97 | ErrorCode error_code = 1; |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 98 | KeyBlob blob = 2; |
| 99 | KeyCharacteristics characteristics = 3; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | // GetKeyCharacteristics |
| 103 | message GetKeyCharacteristicsRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 104 | KeyBlob blob = 1; |
| 105 | bytes client_id = 2; |
| 106 | bytes app_data = 3; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 107 | } |
| 108 | message GetKeyCharacteristicsResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame^] | 109 | ErrorCode error_code = 1; |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 110 | KeyCharacteristics characteristics = 2; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | // ImportKey |
| 114 | message ImportKeyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 115 | KeyParameters params = 1; |
| 116 | RSAKey rsa = 2; |
| 117 | ECKey ec = 3; |
| 118 | SymmetricKey symmetric_key = 4; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 119 | }; |
| 120 | message ImportKeyResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame^] | 121 | ErrorCode error_code = 1; |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 122 | KeyBlob blob = 2; |
| 123 | KeyCharacteristics characteristics = 3; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 124 | }; |
| 125 | |
| 126 | // ExportKey |
| 127 | message ExportKeyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 128 | KeyFormat format = 1; |
| 129 | KeyBlob blob = 2; |
| 130 | bytes client_id = 3; |
| 131 | bytes app_data = 4; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 132 | }; |
| 133 | message ExportKeyResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame^] | 134 | ErrorCode error_code = 1; |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 135 | bytes key_material = 2; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 136 | }; |
| 137 | |
| 138 | // AttestKey |
| 139 | message AttestKeyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 140 | KeyBlob blob = 1; |
| 141 | KeyParameters params = 2; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 142 | } |
| 143 | message AttestKeyResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame^] | 144 | ErrorCode error_code = 1; |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 145 | CertificateChain chain = 2; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | // UpgradeKey |
| 149 | message UpgradeKeyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 150 | KeyBlob blob = 1; |
| 151 | KeyParameters params = 2; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 152 | } |
| 153 | message UpgradeKeyResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame^] | 154 | ErrorCode error_code = 1; |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 155 | KeyBlob blob = 2; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | // DeleteKey |
| 159 | message DeleteKeyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 160 | KeyBlob blob = 1; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 161 | } |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 162 | message DeleteKeyResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame^] | 163 | ErrorCode error_code = 1; |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 164 | } |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 165 | |
| 166 | // DeleteAllKeys |
| 167 | message DeleteAllKeysRequest {} |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 168 | message DeleteAllKeysResponse { |
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 | // DestroyAttestationIds |
| 173 | message DestroyAttestationIdsRequest {} |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 174 | message DestroyAttestationIdsResponse { |
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 | // BeginOperation |
| 179 | message BeginOperationRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 180 | KeyPurpose purpose = 1; |
| 181 | KeyBlob blob = 2; |
| 182 | KeyParameters params = 3; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 183 | } |
| 184 | message BeginOperationResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame^] | 185 | ErrorCode error_code = 1; |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 186 | KeyParameters params = 2; |
| 187 | OperationHandle handle = 3; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | // UpdateOperation |
| 191 | message UpdateOperationRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 192 | OperationHandle handle = 1; |
| 193 | KeyParameters params = 2; |
| 194 | bytes input = 3; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 195 | } |
| 196 | message UpdateOperationResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame^] | 197 | ErrorCode error_code = 1; |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 198 | uint32 consumed = 2; |
| 199 | KeyParameters params = 3; |
| 200 | bytes output = 4; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | // FinishOperation |
| 204 | message FinishOperationRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 205 | OperationHandle handle = 1; |
| 206 | KeyParameters params = 2; |
| 207 | bytes input = 3; |
| 208 | bytes signature = 4; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 209 | }; |
| 210 | message FinishOperationResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame^] | 211 | ErrorCode error_code = 1; |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 212 | KeyParameters params = 2; |
| 213 | bytes output = 3; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 214 | }; |
| 215 | |
| 216 | // AbortOperation |
| 217 | message AbortOperationRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 218 | OperationHandle handle = 1; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 219 | }; |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 220 | message AbortOperationResponse { |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame^] | 221 | ErrorCode error_code = 1; |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 222 | }; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 223 | |
| 224 | /* |
| 225 | * KM4 messages. |
| 226 | */ |
nagendra modadugu | 6023a7d | 2017-11-08 14:40:49 -0800 | [diff] [blame] | 227 | |
| 228 | // ImportWrappedKey |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 229 | message ImportWrappedKeyRequest { |
nagendra modadugu | bdf53cd | 2017-12-04 21:28:02 -0800 | [diff] [blame] | 230 | 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 modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 239 | } |
nagendra modadugu | bdf53cd | 2017-12-04 21:28:02 -0800 | [diff] [blame] | 240 | // ImportWrappedKey returns a ImportKeyResponse. |
nagendra modadugu | 6023a7d | 2017-11-08 14:40:49 -0800 | [diff] [blame] | 241 | |
| 242 | /* |
| 243 | * Vendor HAL. |
| 244 | */ |
| 245 | |
| 246 | // SetRootOfTrustRequest |
| 247 | // Only callable by the Bootloader. |
| 248 | message SetRootOfTrustRequest { |
| 249 | bytes digest = 1; |
| 250 | } |
| 251 | message SetRootOfTrustResponse { |
| 252 | // Specified in keymaster_defs.proto:ErrorCode |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame^] | 253 | ErrorCode error_code = 1; |
nagendra modadugu | 6023a7d | 2017-11-08 14:40:49 -0800 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | // SetBootStateRequest |
| 257 | // Only callable by the Bootloader. |
| 258 | message 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 | } |
| 265 | message SetBootStateResponse { |
| 266 | // Specified in keymaster_defs.proto:ErrorCode |
nagendra modadugu | 4405b6b | 2017-12-28 11:17:18 -0800 | [diff] [blame^] | 267 | ErrorCode error_code = 1; |
nagendra modadugu | 6023a7d | 2017-11-08 14:40:49 -0800 | [diff] [blame] | 268 | } |