• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  **
3  ** Copyright 2020, 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 **
19 ** The original Work has been changed by NXP.
20 **
21 ** Licensed under the Apache License, Version 2.0 (the "License");
22 ** you may not use this file except in compliance with the License.
23 ** You may obtain a copy of the License at
24 **
25 ** http://www.apache.org/licenses/LICENSE-2.0
26 **
27 ** Unless required by applicable law or agreed to in writing, software
28 ** distributed under the License is distributed on an "AS IS" BASIS,
29 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30 ** See the License for the specific language governing permissions and
31 ** limitations under the License.
32 **
33 ** Copyright 2021-2023 NXP
34 **
35 *********************************************************************************/
36 #pragma once
37 #include <memory>
38 #include <vector>
39 
40 namespace keymint::javacard {
41 using std::shared_ptr;
42 using std::vector;
43 
44 /**
45  * ITransport is an interface with a set of virtual methods that allow communication between the
46  * HAL and the applet on the secure element.
47  */
48 class ITransport {
49   public:
~ITransport()50     virtual ~ITransport() {}
51 
ITransport(const std::vector<uint8_t> & mAppletAID)52     explicit ITransport(__attribute__((unused))
53                         const std::vector<uint8_t> &mAppletAID){};
54 
55 #ifdef NXP_EXTNS
56     /**
57      * Sets Applet AID.
58      */
setAppletAid(const vector<uint8_t> & aid)59     virtual bool setAppletAid(const vector<uint8_t> &aid) {
60       (void)aid;
61       return false;
62     }
63 #endif
64     /**
65      * Opens connection.
66      */
67     virtual bool openConnection() = 0;
68     /**
69      * Send data over communication channel and receives data back from the remote end.
70      */
71     virtual bool sendData(const vector<uint8_t>& inData, vector<uint8_t>& output) = 0;
72     /**
73      * Closes the connection.
74      */
75     virtual bool closeConnection() = 0;
76     /**
77      * Returns the state of the connection status. Returns true if the connection is active, false
78      * if connection is broken.
79      */
80     virtual bool isConnected() = 0;
81 };
82 }  // namespace keymint::javacard
83