blob: 064d05d44389ba61224cbd0e2a474a100ed73cd8 [file] [log] [blame]
Shawn Willden815e8962020-12-11 13:05:27 +00001/*
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 Danisevskis9d64bc22021-01-05 10:32:57 -080020#include <aidl/android/hardware/security/secureclock/ISecureClock.h>
Shawn Willden815e8962020-12-11 13:05:27 +000021
22#include <hardware/keymaster_defs.h>
23
24namespace keymaster {
25class AndroidKeymaster;
26}
27
28namespace aidl::android::hardware::security::keymint {
29
30using ::ndk::ScopedAStatus;
Janis Danisevskis9d64bc22021-01-05 10:32:57 -080031using secureclock::TimeStampToken;
Shawn Willden815e8962020-12-11 13:05:27 +000032using std::optional;
33using std::shared_ptr;
34using std::string;
35using std::vector;
36
37class 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 Willden2cb22a42021-02-19 07:50:33 -070043 ScopedAStatus updateAad(const vector<uint8_t>& input,
44 const optional<HardwareAuthToken>& authToken,
45 const optional<TimeStampToken>& timestampToken) override;
Shawn Willden815e8962020-12-11 13:05:27 +000046
Shawn Willden2cb22a42021-02-19 07:50:33 -070047 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 Willden815e8962020-12-11 13:05:27 +000052 const optional<vector<uint8_t>>& signature, //
53 const optional<HardwareAuthToken>& authToken, //
Janis Danisevskis3405e972021-01-20 08:19:42 -080054 const optional<TimeStampToken>& timestampToken,
Shawn Willden2cb22a42021-02-19 07:50:33 -070055 const optional<vector<uint8_t>>& confirmationToken,
Shawn Willden815e8962020-12-11 13:05:27 +000056 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