• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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>
20 #include <aidl/android/hardware/security/secureclock/ISecureClock.h>
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;
31 using secureclock::TimeStampToken;
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 
43     ScopedAStatus updateAad(const vector<uint8_t>& input,
44                             const optional<HardwareAuthToken>& authToken,
45                             const optional<TimeStampToken>& timestampToken) override;
46 
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,        //
52                          const optional<vector<uint8_t>>& signature,    //
53                          const optional<HardwareAuthToken>& authToken,  //
54                          const optional<TimeStampToken>& timestampToken,
55                          const optional<vector<uint8_t>>& confirmationToken,
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
66