blob: d5ba61c83f3015b2f8da93d95baa62cc5f2061e6 [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>
Janis Danisevskisc7a9fa22016-10-13 18:43:45 +010022#include <hidl/MQDescriptor.h>
Shawn Willden76f21b22017-02-17 12:29:42 -070023#include <hidl/Status.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;
Shawn Willden76f21b22017-02-17 12:29:42 -070032using ::android::hardware::keymaster::V3_0::HardwareAuthTokenInfo;
Janis Danisevskisc7a9fa22016-10-13 18:43:45 +010033using ::android::hardware::keymaster::V3_0::IKeymasterDevice;
34using ::android::hardware::keymaster::V3_0::KeyCharacteristics;
35using ::android::hardware::keymaster::V3_0::KeyFormat;
36using ::android::hardware::keymaster::V3_0::KeyParameter;
37using ::android::hardware::keymaster::V3_0::KeyPurpose;
38using ::android::hardware::keymaster::V3_0::Tag;
39using ::android::hardware::Return;
40using ::android::hardware::Void;
41using ::android::hardware::hidl_vec;
42using ::android::hardware::hidl_string;
43using ::android::sp;
44
45class LegacyKeymasterDeviceWrapper : public IKeymasterDevice {
46 public:
47 LegacyKeymasterDeviceWrapper(keymaster2_device_t* dev);
48 virtual ~LegacyKeymasterDeviceWrapper();
49
50 // Methods from ::android::hardware::keymaster::V3_0::IKeymasterDevice follow.
51 Return<void> getHardwareFeatures(getHardwareFeatures_cb _hidl_cb);
Shawn Willden76f21b22017-02-17 12:29:42 -070052 Return<void> parseHardwareAuthToken(const hidl_vec<uint8_t>& token,
53 parseHardwareAuthToken_cb _hidl_cb);
Janis Danisevskisc7a9fa22016-10-13 18:43:45 +010054 Return<ErrorCode> addRngEntropy(const hidl_vec<uint8_t>& data) override;
55 Return<void> generateKey(const hidl_vec<KeyParameter>& keyParams,
56 generateKey_cb _hidl_cb) override;
57 Return<void> getKeyCharacteristics(const hidl_vec<uint8_t>& keyBlob,
58 const hidl_vec<uint8_t>& clientId,
59 const hidl_vec<uint8_t>& appData,
60 getKeyCharacteristics_cb _hidl_cb) override;
61 Return<void> importKey(const hidl_vec<KeyParameter>& params, KeyFormat keyFormat,
62 const hidl_vec<uint8_t>& keyData, importKey_cb _hidl_cb) override;
63 Return<void> exportKey(KeyFormat exportFormat, const hidl_vec<uint8_t>& keyBlob,
64 const hidl_vec<uint8_t>& clientId, const hidl_vec<uint8_t>& appData,
65 exportKey_cb _hidl_cb) override;
66 Return<void> attestKey(const hidl_vec<uint8_t>& keyToAttest,
67 const hidl_vec<KeyParameter>& attestParams,
68 attestKey_cb _hidl_cb) override;
69 Return<void> upgradeKey(const hidl_vec<uint8_t>& keyBlobToUpgrade,
70 const hidl_vec<KeyParameter>& upgradeParams,
71 upgradeKey_cb _hidl_cb) override;
72 Return<ErrorCode> deleteKey(const hidl_vec<uint8_t>& keyBlob) override;
73 Return<ErrorCode> deleteAllKeys() override;
Bartosz Fabianowskia9452d92017-01-23 22:21:11 +010074 Return<ErrorCode> destroyAttestationIds() override;
Janis Danisevskisc7a9fa22016-10-13 18:43:45 +010075 Return<void> begin(KeyPurpose purpose, const hidl_vec<uint8_t>& key,
76 const hidl_vec<KeyParameter>& inParams, begin_cb _hidl_cb) override;
77 Return<void> update(uint64_t operationHandle, const hidl_vec<KeyParameter>& inParams,
78 const hidl_vec<uint8_t>& input, update_cb _hidl_cb) override;
79 Return<void> finish(uint64_t operationHandle, const hidl_vec<KeyParameter>& inParams,
80 const hidl_vec<uint8_t>& input, const hidl_vec<uint8_t>& signature,
81 finish_cb _hidl_cb) override;
82 Return<ErrorCode> abort(uint64_t operationHandle) override;
83
84 private:
85 keymaster2_device_t* keymaster_device_;
86};
87
88sp<IKeymasterDevice> makeSoftwareKeymasterDevice();
89
90} // namespace keystore
91} // namespace android
92
93#endif // LEGACY_KEYMASTER_DEVICE_WRAPPER_H_