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 #pragma once 18 19 #include <memory> 20 #include <vector> 21 22 #include <hardware/keymaster_defs.h> 23 24 namespace keymint::javacard { 25 using std::shared_ptr; 26 using std::vector; 27 28 /** 29 * ITransport is an interface with a set of virtual methods that allow communication between the 30 * HAL and the applet on the secure element. 31 */ 32 class ITransport { 33 public: ~ITransport()34 virtual ~ITransport() {} 35 36 /** 37 * Opens connection. 38 */ 39 virtual keymaster_error_t openConnection() = 0; 40 /** 41 * Send data over communication channel and receives data back from the remote end. 42 */ 43 virtual keymaster_error_t sendData(const vector<uint8_t>& inData, vector<uint8_t>& output) = 0; 44 /** 45 * Closes the connection. 46 */ 47 virtual keymaster_error_t closeConnection() = 0; 48 /** 49 * Returns the state of the connection status. Returns true if the connection is active, false 50 * if connection is broken. 51 */ 52 virtual bool isConnected() = 0; 53 }; 54 55 } // namespace keymint::javacard 56