Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020, 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 | #pragma once |
| 18 | |
| 19 | #include <aidl/android/hardware/security/keymint/BnKeyMintOperation.h> |
Janis Danisevskis | 9d64bc2 | 2021-01-05 10:32:57 -0800 | [diff] [blame] | 20 | #include <aidl/android/hardware/security/secureclock/ISecureClock.h> |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 21 | |
| 22 | #include <hardware/keymaster_defs.h> |
| 23 | |
| 24 | namespace keymaster { |
| 25 | class AndroidKeymaster; |
| 26 | } |
| 27 | |
| 28 | namespace aidl::android::hardware::security::keymint { |
| 29 | |
| 30 | using ::ndk::ScopedAStatus; |
Janis Danisevskis | 9d64bc2 | 2021-01-05 10:32:57 -0800 | [diff] [blame] | 31 | using secureclock::TimeStampToken; |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 32 | using std::optional; |
| 33 | using std::shared_ptr; |
| 34 | using std::string; |
| 35 | using std::vector; |
| 36 | |
| 37 | class AndroidKeyMintOperation : public BnKeyMintOperation { |
| 38 | public: |
| 39 | explicit AndroidKeyMintOperation(const shared_ptr<::keymaster::AndroidKeymaster> implementation, |
| 40 | keymaster_operation_handle_t opHandle); |
| 41 | virtual ~AndroidKeyMintOperation(); |
| 42 | |
Shawn Willden | 2cb22a4 | 2021-02-19 07:50:33 -0700 | [diff] [blame] | 43 | ScopedAStatus updateAad(const vector<uint8_t>& input, |
| 44 | const optional<HardwareAuthToken>& authToken, |
| 45 | const optional<TimeStampToken>& timestampToken) override; |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 46 | |
Shawn Willden | 2cb22a4 | 2021-02-19 07:50:33 -0700 | [diff] [blame] | 47 | ScopedAStatus update(const vector<uint8_t>& input, const optional<HardwareAuthToken>& authToken, |
| 48 | const optional<TimeStampToken>& timestampToken, |
| 49 | vector<uint8_t>* output) override; |
| 50 | |
| 51 | ScopedAStatus finish(const optional<vector<uint8_t>>& input, // |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 52 | const optional<vector<uint8_t>>& signature, // |
| 53 | const optional<HardwareAuthToken>& authToken, // |
Janis Danisevskis | 3405e97 | 2021-01-20 08:19:42 -0800 | [diff] [blame] | 54 | const optional<TimeStampToken>& timestampToken, |
Shawn Willden | 2cb22a4 | 2021-02-19 07:50:33 -0700 | [diff] [blame] | 55 | const optional<vector<uint8_t>>& confirmationToken, |
Shawn Willden | 815e896 | 2020-12-11 13:05:27 +0000 | [diff] [blame] | 56 | vector<uint8_t>* output) override; |
| 57 | |
| 58 | ScopedAStatus abort() override; |
| 59 | |
| 60 | protected: |
| 61 | std::shared_ptr<::keymaster::AndroidKeymaster> impl_; |
| 62 | keymaster_operation_handle_t opHandle_; |
| 63 | }; |
| 64 | |
| 65 | } // namespace aidl::android::hardware::security::keymint |