blob: 84265b6096aecdfee19fdd5e0a92913d447fe1c7 [file] [log] [blame]
Max Bires33aac2d2018-02-23 10:53:10 -08001/*
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 Danisevskisff3d7f42018-10-08 07:15:09 -070027#include <keystore/keystore_return_types.h>
28
29#include <future>
Max Bires33aac2d2018-02-23 10:53:10 -080030
31namespace keystore {
32
33using ::android::IBinder;
34using ::android::sp;
35using keymaster::support::Keymaster;
36
37struct 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 Danisevskisff3d7f42018-10-08 07:15:09 -070043 characteristics(characteristics_), appToken(appToken_), authToken(), verificationToken(),
44 params(params_) {}
Max Bires33aac2d2018-02-23 10:53:10 -080045 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 Danisevskisff3d7f42018-10-08 07:15:09 -070056 std::promise<KeyStoreServiceReturnCode> authTokenPromise;
57 std::future<KeyStoreServiceReturnCode> authTokenFuture;
Max Bires33aac2d2018-02-23 10:53:10 -080058 HardwareAuthToken authToken;
Shawn Willden2eef1352018-05-22 16:13:24 -060059 VerificationToken verificationToken;
Max Bires33aac2d2018-02-23 10:53:10 -080060 const hidl_vec<KeyParameter> params;
61};
62
63} // namespace keystore
64
65#endif