1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "se_impl.h"
17 #include <hdf_base.h>
18 #include <hdf_log.h>
19 #include <vector>
20
21 #define HDF_LOG_TAG hdf_se
22
23 namespace OHOS {
24 namespace HDI {
25 namespace SecureElement {
26
SecureElementInterfaceImplGetInstance(void)27 extern "C" ISecureElementInterface *SecureElementInterfaceImplGetInstance(void)
28 {
29 using OHOS::HDI::SecureElement::SeImpl;
30 SeImpl* service = new (std::nothrow) SeImpl();
31 if (service == nullptr) {
32 return nullptr;
33 }
34 return service;
35 }
36
init(const sptr<ISecureElementCallback> & clientCallback,SecureElementStatus & status)37 int32_t SeImpl::init(const sptr<ISecureElementCallback>& clientCallback, SecureElementStatus& status)
38 {
39 return adaptor_.init(clientCallback, status);
40 }
41
getAtr(std::vector<uint8_t> & response)42 int32_t SeImpl::getAtr(std::vector<uint8_t>& response)
43 {
44 return adaptor_.getAtr(response);
45 }
46
isSecureElementPresent(bool & present)47 int32_t SeImpl::isSecureElementPresent(bool& present)
48 {
49 return adaptor_.isSecureElementPresent(present);
50 }
51
openLogicalChannel(const std::vector<uint8_t> & aid,uint8_t p2,std::vector<uint8_t> & response,uint8_t & channelNumber,SecureElementStatus & status)52 int32_t SeImpl::openLogicalChannel(const std::vector<uint8_t>& aid, uint8_t p2, std::vector<uint8_t>& response,
53 uint8_t& channelNumber, SecureElementStatus& status)
54 {
55 return adaptor_.openLogicalChannel(aid, p2, response, channelNumber, status);
56 }
57
openBasicChannel(const std::vector<uint8_t> & aid,uint8_t p2,std::vector<uint8_t> & response,SecureElementStatus & status)58 int32_t SeImpl::openBasicChannel(const std::vector<uint8_t>& aid, uint8_t p2, std::vector<uint8_t>& response,
59 SecureElementStatus& status)
60 {
61 return adaptor_.openBasicChannel(aid, p2, response, status);
62 }
63
closeChannel(uint8_t channelNumber,SecureElementStatus & status)64 int32_t SeImpl::closeChannel(uint8_t channelNumber, SecureElementStatus& status)
65 {
66 return adaptor_.closeChannel(channelNumber, status);
67 }
68
transmit(const std::vector<uint8_t> & command,std::vector<uint8_t> & response,SecureElementStatus & status)69 int32_t SeImpl::transmit(const std::vector<uint8_t>& command, std::vector<uint8_t>& response,
70 SecureElementStatus& status)
71 {
72 return adaptor_.transmit(command, response, status);
73 }
74
reset(SecureElementStatus & status)75 int32_t SeImpl::reset(SecureElementStatus& status)
76 {
77 return adaptor_.reset(status);
78 }
79 } // SecureElement
80 } // HDI
81 } // OHOS
82