Max Bires | 33aac2d | 2018-02-23 10:53:10 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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 | #ifndef KEYSTORE_OPERATION_STRUCT_H_ |
| 18 | #define KEYSTORE_OPERATION_STRUCT_H_ |
| 19 | |
| 20 | #include <binder/Binder.h> |
| 21 | #include <binder/IBinder.h> |
| 22 | #include <keymasterV4_0/Keymaster.h> |
| 23 | #include <utils/StrongPointer.h> |
| 24 | |
| 25 | #include <keystore/keymaster_types.h> |
| 26 | #include <keystore/keystore_hidl_support.h> |
Janis Danisevskis | ff3d7f4 | 2018-10-08 07:15:09 -0700 | [diff] [blame] | 27 | #include <keystore/keystore_return_types.h> |
| 28 | |
| 29 | #include <future> |
Max Bires | 33aac2d | 2018-02-23 10:53:10 -0800 | [diff] [blame] | 30 | |
| 31 | namespace keystore { |
| 32 | |
| 33 | using ::android::IBinder; |
| 34 | using ::android::sp; |
| 35 | using keymaster::support::Keymaster; |
| 36 | |
| 37 | struct Operation { |
| 38 | Operation() = default; |
| 39 | Operation(uint64_t handle_, uint64_t keyid_, KeyPurpose purpose_, const sp<Keymaster>& device_, |
| 40 | KeyCharacteristics&& characteristics_, sp<IBinder> appToken_, |
| 41 | const hidl_vec<KeyParameter> params_) |
| 42 | : handle(handle_), keyid(keyid_), purpose(purpose_), device(device_), |
Janis Danisevskis | ff3d7f4 | 2018-10-08 07:15:09 -0700 | [diff] [blame] | 43 | characteristics(characteristics_), appToken(appToken_), authToken(), verificationToken(), |
| 44 | params(params_) {} |
Max Bires | 33aac2d | 2018-02-23 10:53:10 -0800 | [diff] [blame] | 45 | Operation(Operation&&) = default; |
| 46 | Operation(const Operation&) = delete; |
| 47 | |
| 48 | bool hasAuthToken() const { return authToken.mac.size() != 0; } |
| 49 | |
| 50 | uint64_t handle; |
| 51 | uint64_t keyid; |
| 52 | KeyPurpose purpose; |
| 53 | sp<Keymaster> device; |
| 54 | KeyCharacteristics characteristics; |
| 55 | sp<IBinder> appToken; |
Janis Danisevskis | ff3d7f4 | 2018-10-08 07:15:09 -0700 | [diff] [blame] | 56 | std::promise<KeyStoreServiceReturnCode> authTokenPromise; |
| 57 | std::future<KeyStoreServiceReturnCode> authTokenFuture; |
Max Bires | 33aac2d | 2018-02-23 10:53:10 -0800 | [diff] [blame] | 58 | HardwareAuthToken authToken; |
Shawn Willden | 2eef135 | 2018-05-22 16:13:24 -0600 | [diff] [blame] | 59 | VerificationToken verificationToken; |
Max Bires | 33aac2d | 2018-02-23 10:53:10 -0800 | [diff] [blame] | 60 | const hidl_vec<KeyParameter> params; |
| 61 | }; |
| 62 | |
| 63 | } // namespace keystore |
| 64 | |
| 65 | #endif |