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 | */ |
| 68 | rpc ImportWrappedKey (ImportWrappedKeyRequest) returns (ImportWrappedKeyResponse); |
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 | /* |
| 71 | * Vendor specific methods (manufacturing, status, factory reset, upgrade). |
| 72 | */ |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | /* |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 76 | * KM3 messages. |
| 77 | */ |
| 78 | |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 79 | // AddEntropy |
| 80 | message AddRngEntropyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 81 | bytes data = 1; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 82 | } |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 83 | message AddRngEntropyResponse { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 84 | // TODO: replace with ErrorCode enum |
| 85 | uint32 error_code = 1; |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 86 | } |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 87 | |
| 88 | // GenerateKey |
| 89 | message GenerateKeyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 90 | KeyParameters params = 1; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 91 | } |
| 92 | message GenerateKeyResponse { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 93 | uint32 error_code = 1; |
| 94 | KeyBlob blob = 2; |
| 95 | KeyCharacteristics characteristics = 3; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | // GetKeyCharacteristics |
| 99 | message GetKeyCharacteristicsRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 100 | KeyBlob blob = 1; |
| 101 | bytes client_id = 2; |
| 102 | bytes app_data = 3; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 103 | } |
| 104 | message GetKeyCharacteristicsResponse { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 105 | uint32 error_code = 1; |
| 106 | KeyCharacteristics characteristics = 2; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | // ImportKey |
| 110 | message ImportKeyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 111 | KeyParameters params = 1; |
| 112 | RSAKey rsa = 2; |
| 113 | ECKey ec = 3; |
| 114 | SymmetricKey symmetric_key = 4; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 115 | }; |
| 116 | message ImportKeyResponse { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 117 | // TODO: include an ErrorCode field |
| 118 | uint32 error_code = 1; |
| 119 | KeyBlob blob = 2; |
| 120 | KeyCharacteristics characteristics = 3; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 121 | }; |
| 122 | |
| 123 | // ExportKey |
| 124 | message ExportKeyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 125 | KeyFormat format = 1; |
| 126 | KeyBlob blob = 2; |
| 127 | bytes client_id = 3; |
| 128 | bytes app_data = 4; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 129 | }; |
| 130 | message ExportKeyResponse { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 131 | uint32 error_code = 1; |
| 132 | bytes key_material = 2; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 133 | }; |
| 134 | |
| 135 | // AttestKey |
| 136 | message AttestKeyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 137 | KeyBlob blob = 1; |
| 138 | KeyParameters params = 2; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 139 | } |
| 140 | message AttestKeyResponse { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 141 | uint32 error_code = 1; |
| 142 | CertificateChain chain = 2; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | // UpgradeKey |
| 146 | message UpgradeKeyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 147 | KeyBlob blob = 1; |
| 148 | KeyParameters params = 2; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 149 | } |
| 150 | message UpgradeKeyResponse { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 151 | uint32 error_code = 1; |
| 152 | KeyBlob blob = 2; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 153 | } |
| 154 | |
| 155 | // DeleteKey |
| 156 | message DeleteKeyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 157 | KeyBlob blob = 1; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 158 | } |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 159 | message DeleteKeyResponse { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 160 | uint32 error_code = 1; |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 161 | } |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 162 | |
| 163 | // DeleteAllKeys |
| 164 | message DeleteAllKeysRequest {} |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 165 | message DeleteAllKeysResponse { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 166 | uint32 error_code = 1; |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 167 | } |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 168 | |
| 169 | // DestroyAttestationIds |
| 170 | message DestroyAttestationIdsRequest {} |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 171 | message DestroyAttestationIdsResponse { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 172 | uint32 error_code = 1; |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 173 | } |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 174 | |
| 175 | // BeginOperation |
| 176 | message BeginOperationRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 177 | KeyPurpose purpose = 1; |
| 178 | KeyBlob blob = 2; |
| 179 | KeyParameters params = 3; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 180 | } |
| 181 | message BeginOperationResponse { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 182 | uint32 error_code = 1; |
| 183 | KeyParameters params = 2; |
| 184 | OperationHandle handle = 3; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | // UpdateOperation |
| 188 | message UpdateOperationRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 189 | OperationHandle handle = 1; |
| 190 | KeyParameters params = 2; |
| 191 | bytes input = 3; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 192 | } |
| 193 | message UpdateOperationResponse { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 194 | uint32 error_code = 1; |
| 195 | uint32 consumed = 2; |
| 196 | KeyParameters params = 3; |
| 197 | bytes output = 4; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | // FinishOperation |
| 201 | message FinishOperationRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 202 | OperationHandle handle = 1; |
| 203 | KeyParameters params = 2; |
| 204 | bytes input = 3; |
| 205 | bytes signature = 4; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 206 | }; |
| 207 | message FinishOperationResponse { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 208 | uint32 error_code = 1; |
| 209 | KeyParameters params = 2; |
| 210 | bytes output = 3; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 211 | }; |
| 212 | |
| 213 | // AbortOperation |
| 214 | message AbortOperationRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 215 | OperationHandle handle = 1; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 216 | }; |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 217 | message AbortOperationResponse { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 218 | uint32 error_code = 1; |
nagendra modadugu | 3696694 | 2017-09-26 15:56:24 -0700 | [diff] [blame] | 219 | }; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 220 | |
| 221 | /* |
| 222 | * KM4 messages. |
| 223 | */ |
| 224 | message ImportWrappedKeyRequest { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 225 | KeyBlob wrapping_key_blob = 1; |
| 226 | bytes wrapped_key = 2; |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 227 | } |
nagendra modadugu | bdcfaa8 | 2017-09-17 17:11:36 -0700 | [diff] [blame] | 228 | message ImportWrappedKeyResponse { |
Andrew Scull | 36ebf2d | 2017-10-10 11:25:21 +0100 | [diff] [blame] | 229 | uint32 error_code = 1; |
| 230 | KeyBlob blob = 2; |
| 231 | KeyCharacteristics characteristics = 3; |
nagendra modadugu | 89e50ed | 2017-10-30 22:13:01 -0700 | [diff] [blame^] | 232 | } |