1 /* 2 ** 3 ** Copyright 2018, 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 HIDL_android_hardware_keymaster_V3_0_TrustyKeymaster3Device_H_ 19 #define HIDL_android_hardware_keymaster_V3_0_TrustyKeymaster3Device_H_ 20 21 #include <android/hardware/keymaster/3.0/IKeymasterDevice.h> 22 23 #include <hidl/MQDescriptor.h> 24 #include <hidl/Status.h> 25 26 #include <trusty_keymaster/TrustyKeymaster.h> 27 28 namespace keymaster { 29 30 using ::android::sp; 31 using ::android::hardware::hidl_string; 32 using ::android::hardware::hidl_vec; 33 using ::android::hardware::Return; 34 using ::android::hardware::Void; 35 using ::android::hardware::keymaster::V3_0::ErrorCode; 36 using ::android::hardware::keymaster::V3_0::IKeymasterDevice; 37 using ::android::hardware::keymaster::V3_0::KeyCharacteristics; 38 using ::android::hardware::keymaster::V3_0::KeyFormat; 39 using ::android::hardware::keymaster::V3_0::KeyParameter; 40 using ::android::hardware::keymaster::V3_0::KeyPurpose; 41 42 class TrustyKeymaster3Device : public IKeymasterDevice { 43 public: 44 TrustyKeymaster3Device(TrustyKeymaster* impl); 45 virtual ~TrustyKeymaster3Device(); 46 47 Return<void> getHardwareFeatures(getHardwareFeatures_cb _hidl_cb); 48 Return<ErrorCode> addRngEntropy(const hidl_vec<uint8_t>& data) override; 49 Return<void> generateKey(const hidl_vec<KeyParameter>& keyParams, 50 generateKey_cb _hidl_cb) override; 51 Return<void> getKeyCharacteristics(const hidl_vec<uint8_t>& keyBlob, 52 const hidl_vec<uint8_t>& clientId, 53 const hidl_vec<uint8_t>& appData, 54 getKeyCharacteristics_cb _hidl_cb) override; 55 Return<void> importKey(const hidl_vec<KeyParameter>& params, KeyFormat keyFormat, 56 const hidl_vec<uint8_t>& keyData, importKey_cb _hidl_cb) override; 57 Return<void> exportKey(KeyFormat exportFormat, const hidl_vec<uint8_t>& keyBlob, 58 const hidl_vec<uint8_t>& clientId, const hidl_vec<uint8_t>& appData, 59 exportKey_cb _hidl_cb) override; 60 Return<void> attestKey(const hidl_vec<uint8_t>& keyToAttest, 61 const hidl_vec<KeyParameter>& attestParams, 62 attestKey_cb _hidl_cb) override; 63 Return<void> upgradeKey(const hidl_vec<uint8_t>& keyBlobToUpgrade, 64 const hidl_vec<KeyParameter>& upgradeParams, 65 upgradeKey_cb _hidl_cb) override; 66 Return<ErrorCode> deleteKey(const hidl_vec<uint8_t>& keyBlob) override; 67 Return<ErrorCode> deleteAllKeys() override; 68 Return<ErrorCode> destroyAttestationIds() override; 69 Return<void> begin(KeyPurpose purpose, const hidl_vec<uint8_t>& key, 70 const hidl_vec<KeyParameter>& inParams, begin_cb _hidl_cb) override; 71 Return<void> update(uint64_t operationHandle, const hidl_vec<KeyParameter>& inParams, 72 const hidl_vec<uint8_t>& input, update_cb _hidl_cb) override; 73 Return<void> finish(uint64_t operationHandle, const hidl_vec<KeyParameter>& inParams, 74 const hidl_vec<uint8_t>& input, const hidl_vec<uint8_t>& signature, 75 finish_cb _hidl_cb) override; 76 Return<ErrorCode> abort(uint64_t operationHandle) override; 77 78 private: 79 std::unique_ptr<TrustyKeymaster> impl_; 80 }; 81 82 } // namespace keymaster 83 84 #endif // HIDL_android_hardware_keymaster_V3_0_TrustyKeymaster3Device_H_ 85