blob: cd2e5a7777440e69c35e86a294cdcce83576b059 [file] [log] [blame]
Janis Danisevskisc7a9fa22016-10-13 18:43:45 +01001/*
2 **
3 ** Copyright 2016, The Android Open Source Project
4 **
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
8 **
9 ** http://www.apache.org/licenses/LICENSE-2.0
10 **
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 */
17
18#ifndef LEGACY_KEYMASTER_DEVICE_WRAPPER_H_
19#define LEGACY_KEYMASTER_DEVICE_WRAPPER_H_
20
21#include <android/hardware/keymaster/3.0/IKeymasterDevice.h>
Shawn Willden76f21b22017-02-17 12:29:42 -070022#include <hidl/Status.h>
Shawn Willdend3ed3a22017-03-28 00:39:16 +000023#include <hidl/MQDescriptor.h>
Janis Danisevskisc7a9fa22016-10-13 18:43:45 +010024
25struct keymaster2_device;
26typedef struct keymaster2_device keymaster2_device_t;
27
28namespace android {
29namespace keystore {
30
31using ::android::hardware::keymaster::V3_0::ErrorCode;
32using ::android::hardware::keymaster::V3_0::IKeymasterDevice;
33using ::android::hardware::keymaster::V3_0::KeyCharacteristics;
34using ::android::hardware::keymaster::V3_0::KeyFormat;
35using ::android::hardware::keymaster::V3_0::KeyParameter;
36using ::android::hardware::keymaster::V3_0::KeyPurpose;
37using ::android::hardware::keymaster::V3_0::Tag;
38using ::android::hardware::Return;
39using ::android::hardware::Void;
40using ::android::hardware::hidl_vec;
41using ::android::hardware::hidl_string;
42using ::android::sp;
43
44class LegacyKeymasterDeviceWrapper : public IKeymasterDevice {
45 public:
Chih-Hung Hsieh4fa39ef2019-01-04 13:34:17 -080046 explicit LegacyKeymasterDeviceWrapper(keymaster2_device_t* dev);
Janis Danisevskisc7a9fa22016-10-13 18:43:45 +010047 virtual ~LegacyKeymasterDeviceWrapper();
48
49 // Methods from ::android::hardware::keymaster::V3_0::IKeymasterDevice follow.
50 Return<void> getHardwareFeatures(getHardwareFeatures_cb _hidl_cb);
51 Return<ErrorCode> addRngEntropy(const hidl_vec<uint8_t>& data) override;
52 Return<void> generateKey(const hidl_vec<KeyParameter>& keyParams,
53 generateKey_cb _hidl_cb) override;
54 Return<void> getKeyCharacteristics(const hidl_vec<uint8_t>& keyBlob,
55 const hidl_vec<uint8_t>& clientId,
56 const hidl_vec<uint8_t>& appData,
57 getKeyCharacteristics_cb _hidl_cb) override;
58 Return<void> importKey(const hidl_vec<KeyParameter>& params, KeyFormat keyFormat,
59 const hidl_vec<uint8_t>& keyData, importKey_cb _hidl_cb) override;
60 Return<void> exportKey(KeyFormat exportFormat, const hidl_vec<uint8_t>& keyBlob,
61 const hidl_vec<uint8_t>& clientId, const hidl_vec<uint8_t>& appData,
62 exportKey_cb _hidl_cb) override;
63 Return<void> attestKey(const hidl_vec<uint8_t>& keyToAttest,
64 const hidl_vec<KeyParameter>& attestParams,
65 attestKey_cb _hidl_cb) override;
66 Return<void> upgradeKey(const hidl_vec<uint8_t>& keyBlobToUpgrade,
67 const hidl_vec<KeyParameter>& upgradeParams,
68 upgradeKey_cb _hidl_cb) override;
69 Return<ErrorCode> deleteKey(const hidl_vec<uint8_t>& keyBlob) override;
70 Return<ErrorCode> deleteAllKeys() override;
Bartosz Fabianowskia9452d92017-01-23 22:21:11 +010071 Return<ErrorCode> destroyAttestationIds() override;
Janis Danisevskisc7a9fa22016-10-13 18:43:45 +010072 Return<void> begin(KeyPurpose purpose, const hidl_vec<uint8_t>& key,
73 const hidl_vec<KeyParameter>& inParams, begin_cb _hidl_cb) override;
74 Return<void> update(uint64_t operationHandle, const hidl_vec<KeyParameter>& inParams,
75 const hidl_vec<uint8_t>& input, update_cb _hidl_cb) override;
76 Return<void> finish(uint64_t operationHandle, const hidl_vec<KeyParameter>& inParams,
77 const hidl_vec<uint8_t>& input, const hidl_vec<uint8_t>& signature,
78 finish_cb _hidl_cb) override;
79 Return<ErrorCode> abort(uint64_t operationHandle) override;
80
81 private:
82 keymaster2_device_t* keymaster_device_;
83};
84
85sp<IKeymasterDevice> makeSoftwareKeymasterDevice();
86
87} // namespace keystore
88} // namespace android
89
90#endif // LEGACY_KEYMASTER_DEVICE_WRAPPER_H_