Home | History | Annotate | Download | only in default
      1 /*
      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 HIDL_GENERATED_android_hardware_keymaster_V3_0_KeymasterDevice_H_
     19 #define HIDL_GENERATED_android_hardware_keymaster_V3_0_KeymasterDevice_H_
     20 
     21 #include <hardware/keymaster2.h>
     22 
     23 #include <android/hardware/keymaster/3.0/IKeymasterDevice.h>
     24 #include <hidl/Status.h>
     25 
     26 #include <hidl/MQDescriptor.h>
     27 namespace android {
     28 namespace hardware {
     29 namespace keymaster {
     30 namespace V3_0 {
     31 namespace implementation {
     32 
     33 using ::android::hardware::keymaster::V3_0::ErrorCode;
     34 using ::android::hardware::keymaster::V3_0::IKeymasterDevice;
     35 using ::android::hardware::keymaster::V3_0::KeyCharacteristics;
     36 using ::android::hardware::keymaster::V3_0::KeyFormat;
     37 using ::android::hardware::keymaster::V3_0::KeyParameter;
     38 using ::android::hardware::keymaster::V3_0::KeyPurpose;
     39 using ::android::hardware::Return;
     40 using ::android::hardware::Void;
     41 using ::android::hardware::hidl_vec;
     42 using ::android::hardware::hidl_string;
     43 using ::android::sp;
     44 
     45 class KeymasterDevice : public IKeymasterDevice {
     46   public:
     47     KeymasterDevice(keymaster2_device_t* dev, uint32_t hardware_version, bool hardware_supports_ec,
     48                     bool hardware_supports_all_digests)
     49         : keymaster_device_(dev), hardware_version_(hardware_version),
     50           hardware_supports_ec_(hardware_supports_ec),
     51           hardware_supports_all_digests_(hardware_supports_all_digests) {}
     52     virtual ~KeymasterDevice();
     53 
     54     // Methods from ::android::hardware::keymaster::V3_0::IKeymasterDevice follow.
     55     Return<void> getHardwareFeatures(getHardwareFeatures_cb _hidl_cb);
     56     Return<ErrorCode> addRngEntropy(const hidl_vec<uint8_t>& data) override;
     57     Return<void> generateKey(const hidl_vec<KeyParameter>& keyParams,
     58                              generateKey_cb _hidl_cb) override;
     59     Return<void> getKeyCharacteristics(const hidl_vec<uint8_t>& keyBlob,
     60                                        const hidl_vec<uint8_t>& clientId,
     61                                        const hidl_vec<uint8_t>& appData,
     62                                        getKeyCharacteristics_cb _hidl_cb) override;
     63     Return<void> importKey(const hidl_vec<KeyParameter>& params, KeyFormat keyFormat,
     64                            const hidl_vec<uint8_t>& keyData, importKey_cb _hidl_cb) override;
     65     Return<void> exportKey(KeyFormat exportFormat, const hidl_vec<uint8_t>& keyBlob,
     66                            const hidl_vec<uint8_t>& clientId, const hidl_vec<uint8_t>& appData,
     67                            exportKey_cb _hidl_cb) override;
     68     Return<void> attestKey(const hidl_vec<uint8_t>& keyToAttest,
     69                            const hidl_vec<KeyParameter>& attestParams,
     70                            attestKey_cb _hidl_cb) override;
     71     Return<void> upgradeKey(const hidl_vec<uint8_t>& keyBlobToUpgrade,
     72                             const hidl_vec<KeyParameter>& upgradeParams,
     73                             upgradeKey_cb _hidl_cb) override;
     74     Return<ErrorCode> deleteKey(const hidl_vec<uint8_t>& keyBlob) override;
     75     Return<ErrorCode> deleteAllKeys() override;
     76     Return<ErrorCode> destroyAttestationIds() override;
     77     Return<void> begin(KeyPurpose purpose, const hidl_vec<uint8_t>& key,
     78                        const hidl_vec<KeyParameter>& inParams, begin_cb _hidl_cb) override;
     79     Return<void> update(uint64_t operationHandle, const hidl_vec<KeyParameter>& inParams,
     80                         const hidl_vec<uint8_t>& input, update_cb _hidl_cb) override;
     81     Return<void> finish(uint64_t operationHandle, const hidl_vec<KeyParameter>& inParams,
     82                         const hidl_vec<uint8_t>& input, const hidl_vec<uint8_t>& signature,
     83                         finish_cb _hidl_cb) override;
     84     Return<ErrorCode> abort(uint64_t operationHandle) override;
     85 
     86   private:
     87     keymaster2_device_t* keymaster_device_;
     88     uint32_t hardware_version_;
     89     bool hardware_supports_ec_;
     90     bool hardware_supports_all_digests_;
     91 };
     92 
     93 extern "C" IKeymasterDevice* HIDL_FETCH_IKeymasterDevice(const char* name);
     94 
     95 }  // namespace implementation
     96 }  // namespace V3_0
     97 }  // namespace keymaster
     98 }  // namespace hardware
     99 }  // namespace android
    100 
    101 #endif  // HIDL_GENERATED_android_hardware_keymaster_V3_0_KeymasterDevice_H_
    102