From ca9f56072393c2dda88655ae9c4167c576adb2f6 Mon Sep 17 00:00:00 2001 From: Jinkun Jang Date: Sat, 16 Mar 2013 01:18:25 +0900 Subject: [PATCH] merge with master --- client/CMakeLists.txt | 2 + client/ClientChannel.cpp | 112 ++++++++++++++-------- client/ClientDispatcher.cpp | 29 +++--- client/ClientIPC.cpp | 67 +++++++------- client/Reader.cpp | 50 ++++------ client/SEService.cpp | 155 ++++++++++++++++++++----------- client/Session.cpp | 184 ++++++++++++++++++++----------------- client/include/ClientChannel.h | 56 ++++++----- client/include/ClientDispatcher.h | 28 +++--- client/include/ClientIPC.h | 28 +++--- client/include/Reader.h | 47 +++++----- client/include/SEService.h | 57 +++++++----- client/include/SEServiceListener.h | 39 ++++---- client/include/Session.h | 69 ++++++++------ client/include/smartcard-service.h | 27 ++++++ common/APDUHelper.cpp | 70 ++++++++------ common/AccessCondition.cpp | 29 +++--- common/AccessControlList.cpp | 29 +++--- common/ByteArray.cpp | 28 +++--- common/CMakeLists.txt | 3 +- common/DispatcherHelper.cpp | 28 +++--- common/EFDIR.cpp | 117 +++++++++++++++++++++++ common/Exception.cpp | 21 +++++ common/FCI.cpp | 28 +++--- common/FileObject.cpp | 95 +++++++++++-------- common/GPSEACL.cpp | 29 +++--- common/IPCHelper.cpp | 60 +++++++----- common/ISO7816BERTLV.cpp | 29 +++--- common/Message.cpp | 29 +++--- common/NumberStream.cpp | 29 +++--- common/PKCS15.cpp | 90 +++++++++++++----- common/PKCS15DODF.cpp | 29 +++--- common/PKCS15ODF.cpp | 43 ++++----- common/PKCS15OID.cpp | 29 +++--- common/PKCS15Object.cpp | 28 +++--- common/PKCS15Path.cpp | 29 +++--- common/PKCS15TokenInfo.cpp | 29 +++--- common/ProviderHelper.cpp | 28 +++--- common/ReaderHelper.cpp | 33 +++---- common/Record.cpp | 34 ------- common/SEServiceHelper.cpp | 29 +++--- common/Serializable.cpp | 28 +++--- common/SessionHelper.cpp | 40 ++++---- common/SignatureHelper.cpp | 70 ++++++++++---- common/SimpleTLV.cpp | 29 +++--- common/Synchronous.cpp | 29 +++--- common/TLVHelper.cpp | 47 +++++----- common/include/APDUHelper.h | 58 ++++++++---- common/include/AccessCondition.h | 29 +++--- common/include/AccessControlList.h | 29 +++--- common/include/ByteArray.h | 29 +++--- common/include/Channel.h | 60 ++++++------ common/include/Debug.h | 29 +++--- common/include/DispatcherHelper.h | 29 +++--- common/include/DispatcherMsg.h | 29 +++--- common/include/EFDIR.h | 47 ++++++++++ common/include/Exception.h | 178 +++++++++++++++++++++++++++++++++++ common/include/FCI.h | 28 +++--- common/include/FileObject.h | 32 ++++--- common/include/GPSEACL.h | 29 +++--- common/include/IPCHelper.h | 29 +++--- common/include/ISO7816BERTLV.h | 29 +++--- common/include/Lock.h | 28 +++--- common/include/Message.h | 29 +++--- common/include/NumberStream.h | 29 +++--- common/include/OpensslHelper.h | 28 +++--- common/include/PKCS15.h | 31 ++++--- common/include/PKCS15DODF.h | 29 +++--- common/include/PKCS15ODF.h | 28 +++--- common/include/PKCS15OID.h | 28 +++--- common/include/PKCS15Object.h | 29 +++--- common/include/PKCS15Path.h | 28 +++--- common/include/PKCS15TokenInfo.h | 28 +++--- common/include/ProviderHelper.h | 29 +++--- common/include/ReaderHelper.h | 38 ++++---- common/include/Record.h | 42 ++++----- common/include/SEServiceHelper.h | 28 +++--- common/include/Serializable.h | 29 +++--- common/include/SessionHelper.h | 58 +++++++----- common/include/SignatureHelper.h | 29 +++--- common/include/SimpleTLV.h | 29 +++--- common/include/Synchronous.h | 29 +++--- common/include/TLVHelper.h | 29 +++--- common/include/Terminal.h | 29 +++--- common/include/TerminalInterface.h | 29 +++--- common/include/smartcard-types.h | 58 +++++++----- packaging/smartcard-service.spec | 7 +- server/CMakeLists.txt | 4 +- server/ClientInstance.cpp | 29 +++--- server/ServerChannel.cpp | 50 ++++++---- server/ServerDispatcher.cpp | 31 ++++--- server/ServerIPC.cpp | 30 +++--- server/ServerReader.cpp | 35 +++---- server/ServerResource.cpp | 150 ++++++++++++++++-------------- server/ServerSEService.cpp | 98 ++++++++++---------- server/ServerSession.cpp | 39 +++++--- server/ServiceInstance.cpp | 29 +++--- server/include/ClientInstance.h | 29 +++--- server/include/ServerChannel.h | 35 +++---- server/include/ServerDispatcher.h | 29 +++--- server/include/ServerIPC.h | 28 +++--- server/include/ServerReader.h | 41 +++++---- server/include/ServerResource.h | 30 +++--- server/include/ServerSEService.h | 28 +++--- server/include/ServerSession.h | 68 ++++++++------ server/include/ServiceInstance.h | 29 +++--- server/smartcard-daemon.cpp | 32 ++++--- smartcard-service-server.manifest | 3 + test-client/CMakeLists.txt | 2 +- test-client/test-client-sync.cpp | 29 +++--- test-client/test-client.cpp | 29 +++--- 111 files changed, 2617 insertions(+), 1950 deletions(-) create mode 100644 client/include/smartcard-service.h create mode 100644 common/EFDIR.cpp create mode 100644 common/Exception.cpp delete mode 100644 common/Record.cpp create mode 100644 common/include/EFDIR.h create mode 100644 common/include/Exception.h diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 08f2b32..b766051 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -62,6 +62,7 @@ SET(EXPORT_HEADER ../common/include/smartcard-types.h ../common/include/ByteArray.h ../common/include/Debug.h + ../common/include/Exception.h ../common/include/Synchronous.h ../common/include/APDUHelper.h ../common/include/Channel.h @@ -76,6 +77,7 @@ SET(EXPORT_HEADER include/Reader.h include/Session.h include/ClientChannel.h + include/smartcard-service.h # include/ ) diff --git a/client/ClientChannel.cpp b/client/ClientChannel.cpp index eb2d177..b74ba0f 100644 --- a/client/ClientChannel.cpp +++ b/client/ClientChannel.cpp @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include @@ -27,6 +27,7 @@ #include "ClientIPC.h" #include "ClientChannel.h" #include "ReaderHelper.h" +#include "APDUHelper.h" #ifndef EXTERN_API #define EXTERN_API __attribute__((visibility("default"))) @@ -34,7 +35,9 @@ namespace smartcard_service_api { - ClientChannel::ClientChannel(void *context, Session *session, int channelNum, ByteArray selectResponse, void *handle):Channel(session) + ClientChannel::ClientChannel(void *context, Session *session, + int channelNum, ByteArray selectResponse, void *handle) + : Channel(session) { this->channelNum = -1; this->handle = NULL; @@ -58,7 +61,7 @@ namespace smartcard_service_api closeSync(); } - void ClientChannel::closeSync() + void ClientChannel::closeSync() throw(ErrorIO &, ErrorIllegalState &) { #ifdef CLIENT_IPC_THREAD if (isClosed() == false) @@ -75,20 +78,30 @@ namespace smartcard_service_api msg.caller = (void *)this; msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */ - syncLock(); - if (ClientIPC::getInstance().sendMessage(&msg) == true) + try { - rv = waitTimedCondition(0); - if (rv < 0) + syncLock(); + if (ClientIPC::getInstance().sendMessage(&msg) == true) + { + rv = waitTimedCondition(0); + if (rv < 0) + { + SCARD_DEBUG_ERR("closeSync failed [%d]", rv); + } + } + else { - SCARD_DEBUG_ERR("closeSync failed [%d]", rv); + SCARD_DEBUG_ERR("sendMessage failed"); + throw ErrorIO(SCARD_ERROR_IPC_FAILED); } + syncUnlock(); } - else + catch (ExceptionBase &e) { - SCARD_DEBUG_ERR("sendMessage failed"); + syncUnlock(); + + throw e; } - syncUnlock(); channelNum = -1; } @@ -140,6 +153,7 @@ namespace smartcard_service_api } int ClientChannel::transmitSync(ByteArray command, ByteArray &result) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) { int rv = -1; @@ -169,7 +183,7 @@ namespace smartcard_service_api } else { - SCARD_DEBUG_ERR("clientIPC is null"); + SCARD_DEBUG_ERR("timeout"); rv = -1; } @@ -184,6 +198,7 @@ namespace smartcard_service_api else { SCARD_DEBUG_ERR("unavailable channel"); + throw ErrorIllegalState(SCARD_ERROR_UNAVAILABLE); } return rv; @@ -245,6 +260,14 @@ namespace smartcard_service_api /* transmit result */ SCARD_DEBUG("MSG_REQUEST_TRANSMIT"); + if (msg->error == 0 && + ResponseHelper::getStatus(msg->data) == 0) + { + /* store select response */ + if (msg->data.getAt(1) == APDUCommand::INS_SELECT_FILE) + channel->setSelectResponse(msg->data); + } + if (msg->isSynchronousCall() == true) /* synchronized call */ { /* sync call */ @@ -326,7 +349,8 @@ EXTERN_API int channel_close(channel_h handle, channel_close_cb callback, void * return result; } -EXTERN_API int channel_transmit(channel_h handle, unsigned char *command, unsigned int length, channel_transmit_cb callback, void *userParam) +EXTERN_API int channel_transmit(channel_h handle, unsigned char *command, + unsigned int length, channel_transmit_cb callback, void *userParam) { int result = -1; @@ -344,12 +368,19 @@ EXTERN_API void channel_close_sync(channel_h handle) { #ifdef CLIENT_IPC_THREAD CHANNEL_EXTERN_BEGIN; - channel->closeSync(); + try + { + channel->closeSync(); + } + catch (...) + { + } CHANNEL_EXTERN_END; #endif } -EXTERN_API int channel_transmit_sync(channel_h handle, unsigned char *command, unsigned int cmd_len, unsigned char **response, unsigned int *resp_len) +EXTERN_API int channel_transmit_sync(channel_h handle, unsigned char *command, + unsigned int cmd_len, unsigned char **response, unsigned int *resp_len) { int result = -1; @@ -361,12 +392,20 @@ EXTERN_API int channel_transmit_sync(channel_h handle, unsigned char *command, u ByteArray temp, resp; temp.setBuffer(command, cmd_len); - result = channel->transmitSync(temp, resp); - if (resp.getLength() > 0) + + try { - *resp_len = resp.getLength(); - *response = (unsigned char *)calloc(1, *resp_len); - memcpy(*response, resp.getBuffer(), *resp_len); + result = channel->transmitSync(temp, resp); + if (resp.getLength() > 0) + { + *resp_len = resp.getLength(); + *response = (unsigned char *)calloc(1, *resp_len); + memcpy(*response, resp.getBuffer(), *resp_len); + } + } + catch (...) + { + result = -1; } CHANNEL_EXTERN_END; #endif @@ -407,7 +446,8 @@ EXTERN_API unsigned int channel_get_select_response_length(channel_h handle) return result; } -EXTERN_API bool channel_get_select_response(channel_h handle, unsigned char *buffer, unsigned int length) +EXTERN_API bool channel_get_select_response(channel_h handle, + unsigned char *buffer, unsigned int length) { bool result = false; @@ -443,7 +483,5 @@ EXTERN_API session_h channel_get_session(channel_h handle) EXTERN_API void channel_destroy_instance(channel_h handle) { - CHANNEL_EXTERN_BEGIN; - delete channel; - CHANNEL_EXTERN_END; + /* do nothing */ } diff --git a/client/ClientDispatcher.cpp b/client/ClientDispatcher.cpp index 9872d93..158689e 100644 --- a/client/ClientDispatcher.cpp +++ b/client/ClientDispatcher.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include diff --git a/client/ClientIPC.cpp b/client/ClientIPC.cpp index e57ab6e..de28bba 100644 --- a/client/ClientIPC.cpp +++ b/client/ClientIPC.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include @@ -37,7 +36,7 @@ namespace smartcard_service_api _launch_daemon(); #endif #ifdef SECURITY_SERVER - int length = 0; + int length; if ((length = security_server_get_cookie_size()) > 0) { @@ -46,9 +45,10 @@ namespace smartcard_service_api buffer = new uint8_t[length]; if (buffer != NULL) { - int error = 0; + int error; - if ((error = security_server_request_cookie(buffer, length)) == SECURITY_SERVER_API_SUCCESS) + if ((error = security_server_request_cookie(buffer, length)) + == SECURITY_SERVER_API_SUCCESS) { cookie.setBuffer(buffer, length); @@ -83,10 +83,8 @@ namespace smartcard_service_api #ifdef USE_AUTOSTART void ClientIPC::_launch_daemon() { - DBusGConnection *connection = NULL; - DBusGProxy *proxy = NULL; + DBusGConnection *connection; GError *error = NULL; - gint result = 0; SCARD_BEGIN(); @@ -97,10 +95,16 @@ namespace smartcard_service_api connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error); if (error == NULL) { - proxy = dbus_g_proxy_new_for_name(connection, "org.tizen.smartcard_service", "/org/tizen/smartcard_service", "org.tizen.smartcard_service"); + DBusGProxy *proxy; + + proxy = dbus_g_proxy_new_for_name(connection, "org.tizen.smartcard_service", + "/org/tizen/smartcard_service", "org.tizen.smartcard_service"); if (proxy != NULL) { - if (dbus_g_proxy_call(proxy, "launch", &error, G_TYPE_INVALID, G_TYPE_INT, &result, G_TYPE_INVALID) == false) + gint result = 0; + + if (dbus_g_proxy_call(proxy, "launch", &error, G_TYPE_INVALID, + G_TYPE_INT, &result, G_TYPE_INVALID) == false) { SCARD_DEBUG_ERR("org_tizen_smartcard_service_launch failed"); if (error != NULL) @@ -130,7 +134,7 @@ namespace smartcard_service_api bool ClientIPC::sendMessage(Message *msg) { ByteArray stream; - unsigned int length = 0; + unsigned int length; if (ipcSocket == -1) return false; @@ -142,23 +146,24 @@ namespace smartcard_service_api #endif length = stream.getLength(); - SCARD_DEBUG(">>>[SEND]>>> socket [%d], msg [%d], length [%d]", ipcSocket, msg->message, stream.getLength()); + SCARD_DEBUG(">>>[SEND]>>> socket [%d], msg [%d], length [%d]", + ipcSocket, msg->message, stream.getLength()); return IPCHelper::sendMessage(ipcSocket, stream); } int ClientIPC::handleIOErrorCondition(void *channel, GIOCondition condition) { - DispatcherMsg dispMsg; - SCARD_BEGIN(); - /* push or process disconnect message */ - dispMsg.message = Message::MSG_OPERATION_RELEASE_CLIENT; - dispMsg.error = -1; - if (dispatcher != NULL) { + DispatcherMsg dispMsg; + + /* push or process disconnect message */ + dispMsg.message = Message::MSG_OPERATION_RELEASE_CLIENT; + dispMsg.error = -1; + #ifdef CLIENT_IPC_THREAD dispatcher->processMessage(&dispMsg); #else diff --git a/client/Reader.cpp b/client/Reader.cpp index 248c895..4382de9 100644 --- a/client/Reader.cpp +++ b/client/Reader.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include @@ -28,7 +27,6 @@ #include "ClientIPC.h" #include "Reader.h" #include "Session.h" -#include "SignatureHelper.h" #ifndef EXTERN_API #define EXTERN_API __attribute__((visibility("default"))) @@ -36,7 +34,7 @@ namespace smartcard_service_api { - Reader::Reader(void *context, const char *name, void *handle):ReaderHelper() + Reader::Reader(void *context, const char *name, void *handle) : ReaderHelper() { unsigned int length = 0; @@ -61,10 +59,6 @@ namespace smartcard_service_api present = true; -#if 0 - getPackageCert(); -#endif - SCARD_END(); } @@ -83,6 +77,7 @@ namespace smartcard_service_api } void Reader::closeSessions() + throw(ErrorIO &, ErrorIllegalState &) { size_t i; @@ -92,12 +87,8 @@ namespace smartcard_service_api } } - void Reader::getPackageCert() - { - packageCert = SignatureHelper::getCertificationHash(getpid()); - } - SessionHelper *Reader::openSessionSync() + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) { openedSession = NULL; @@ -110,7 +101,6 @@ namespace smartcard_service_api /* request channel handle from server */ msg.message = Message::MSG_REQUEST_OPEN_SESSION; msg.param1 = (unsigned int)handle; - msg.data = packageCert; msg.error = (unsigned int)context; /* using error to context */ msg.caller = (void *)this; msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */ @@ -152,9 +142,6 @@ namespace smartcard_service_api /* request channel handle from server */ msg.message = Message::MSG_REQUEST_OPEN_SESSION; msg.param1 = (unsigned int)handle; -#if 0 - msg.data = packageCert; -#endif msg.error = (unsigned int)context; /* using error to context */ msg.caller = (void *)this; msg.callback = (void *)callback; @@ -332,7 +319,4 @@ EXTERN_API void reader_close_sessions(reader_h handle) EXTERN_API void reader_destroy_instance(reader_h handle) { - READER_EXTERN_BEGIN; - delete reader; - READER_EXTERN_END; } diff --git a/client/SEService.cpp b/client/SEService.cpp index 366e9dc..2cb27e8 100644 --- a/client/SEService.cpp +++ b/client/SEService.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include @@ -36,40 +35,32 @@ namespace smartcard_service_api { - SEService::SEService():SEServiceHelper() + SEService::SEService() : + SEServiceHelper() { - pid = -1; this->context = NULL; this->handler = NULL; this->listener = NULL; connected = false; - - pid = getpid(); } - SEService::SEService(void *user_data, serviceConnected handler):SEServiceHelper() + SEService::SEService(void *user_data, serviceConnected handler) + throw(ErrorIO &, ErrorIllegalParameter &) : + SEServiceHelper() { - pid = -1; - this->context = NULL; - this->handler = NULL; this->listener = NULL; connected = false; - pid = getpid(); - initialize(user_data, handler); } - SEService::SEService(void *user_data, SEServiceListener *listener):SEServiceHelper() + SEService::SEService(void *user_data, SEServiceListener *listener) + throw(ErrorIO &, ErrorIllegalParameter &) : + SEServiceHelper() { - pid = -1; - this->context = NULL; this->handler = NULL; - this->listener = NULL; connected = false; - pid = getpid(); - initialize(user_data, listener); } @@ -77,7 +68,18 @@ namespace smartcard_service_api { uint32_t i; - shutdownSync(); + try + { + shutdownSync(); + } + catch(ExceptionBase &e) + { + SCARD_DEBUG_ERR("EXCEPTION : %s", e.what()); + } + catch(...) + { + SCARD_DEBUG_ERR("EXCEPTION!!!"); + } for (i = 0; i < readers.size(); i++) { @@ -86,6 +88,18 @@ namespace smartcard_service_api readers.clear(); } + SEService *SEService::createInstance(void *user_data, SEServiceListener *listener) + throw(ErrorIO &, ErrorIllegalParameter &) + { + return new SEService(user_data, listener); + } + + SEService *SEService::createInstance(void *user_data, serviceConnected handler) + throw(ErrorIO &, ErrorIllegalParameter &) + { + return new SEService(user_data, handler); + } + void SEService::shutdown() { if (connected == true) @@ -102,7 +116,7 @@ namespace smartcard_service_api msg.message = Message::MSG_REQUEST_SHUTDOWN; msg.error = (unsigned int)this; /* using error to context */ msg.caller = (void *)this; - msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */ + msg.callback = (void *)NULL; if (ClientIPC::getInstance().sendMessage(&msg) == false) { @@ -124,7 +138,6 @@ namespace smartcard_service_api } /* send message to load se */ - int rv; Message msg; msg.message = Message::MSG_REQUEST_SHUTDOWN; @@ -135,6 +148,8 @@ namespace smartcard_service_api syncLock(); if (ClientIPC::getInstance().sendMessage(&msg) == true) { + int rv; + rv = waitTimedCondition(0); if (rv == 0) @@ -157,11 +172,11 @@ namespace smartcard_service_api #endif } - bool SEService::_initialize() + bool SEService::_initialize() throw(ErrorIO &) { bool result = false; - ClientIPC *clientIPC = NULL; - ClientDispatcher *clientDispatcher = NULL; + ClientIPC *clientIPC; + ClientDispatcher *clientDispatcher; SCARD_BEGIN(); @@ -199,7 +214,7 @@ namespace smartcard_service_api Message msg; msg.message = Message::MSG_REQUEST_READERS; - msg.error = pid; /* using error to pid */ + msg.error = getpid(); /* using error to pid */ msg.caller = (void *)this; msg.userParam = context; @@ -212,11 +227,13 @@ namespace smartcard_service_api } bool SEService::initialize(void *context, serviceConnected handler) + throw(ErrorIO &, ErrorIllegalParameter &) { if (context == NULL) { - SCARD_DEBUG_ERR("invalid param"); - return false; + ErrorIllegalParameter e(0); + + throw e; } this->context = context; @@ -226,11 +243,13 @@ namespace smartcard_service_api } bool SEService::initialize(void *context, SEServiceListener *listener) + throw(ErrorIO &, ErrorIllegalParameter &) { if (context == NULL) { - SCARD_DEBUG_ERR("invalid param"); - return false; + ErrorIllegalParameter e(0); + + throw e; } this->context = context; @@ -324,16 +343,12 @@ namespace smartcard_service_api /* copy result */ // service->error = msg->error; - service->signalCondition(); service->syncUnlock(); } else { -// openSessionCallback cb = (openSessionCallback)msg->callback; -// -// /* async call */ -// cb(session, msg->error, msg->userParam); + /* Do nothing... */ } break; @@ -344,7 +359,8 @@ namespace smartcard_service_api SCARD_DEBUG("[MSG_NOTIFY_SE_INSERTED]"); /* add readers */ - reader = new Reader(service->context, (char *)msg->data.getBuffer(), (void *)msg->param1); + reader = new Reader(service->context, + (char *)msg->data.getBuffer(), (void *)msg->param1); if (reader != NULL) { service->readers.push_back(reader); @@ -356,7 +372,8 @@ namespace smartcard_service_api if (service->listener != NULL) { - service->listener->eventHandler(service, (char *)msg->data.getBuffer(), 1, service->context); + service->listener->eventHandler(service, + (char *)msg->data.getBuffer(), 1, service->context); } else { @@ -382,7 +399,8 @@ namespace smartcard_service_api if (service->listener != NULL) { - service->listener->eventHandler(service, (char *)msg->data.getBuffer(), 2, service->context); + service->listener->eventHandler(service, + (char *)msg->data.getBuffer(), 2, service->context); } else { @@ -407,7 +425,7 @@ namespace smartcard_service_api } break; - default: + default : SCARD_DEBUG("unknown message [%s]", msg->toString()); break; } @@ -436,14 +454,33 @@ using namespace smartcard_service_api; EXTERN_API se_service_h se_service_create_instance(void *user_data, se_service_connected_cb callback) { - SEService *service = new SEService(user_data, (serviceConnected)callback); + SEService *service; + + try + { + service = new SEService(user_data, (serviceConnected)callback); + } + catch (...) + { + service = NULL; + } return (se_service_h)service; } -EXTERN_API se_service_h se_service_create_instance_with_event_callback(void *user_data, se_service_connected_cb connected, se_service_event_cb event, se_sesrvice_error_cb error) +EXTERN_API se_service_h se_service_create_instance_with_event_callback(void *user_data, + se_service_connected_cb connected, se_service_event_cb event, se_sesrvice_error_cb error) { - SEService *service = new SEService(user_data, (serviceConnected)connected); + SEService *service; + + try + { + service = new SEService(user_data, (serviceConnected)connected); + } + catch (...) + { + service = NULL; + } return (se_service_h)service; } @@ -453,10 +490,12 @@ EXTERN_API int se_service_get_readers_count(se_service_h handle) int count = 0; SE_SERVICE_EXTERN_BEGIN; + vector temp_readers; temp_readers = service->getReaders(); count = temp_readers.size(); + SE_SERVICE_EXTERN_END; return count; @@ -467,6 +506,7 @@ EXTERN_API bool se_service_get_readers(se_service_h handle, reader_h *readers, i bool result = false; SE_SERVICE_EXTERN_BEGIN; + vector temp_readers; size_t i; int temp = 0; @@ -482,6 +522,7 @@ EXTERN_API bool se_service_get_readers(se_service_h handle, reader_h *readers, i } } *count = temp; + SE_SERVICE_EXTERN_END; return result; @@ -492,7 +533,9 @@ EXTERN_API bool se_service_is_connected(se_service_h handle) bool result = false; SE_SERVICE_EXTERN_BEGIN; + result = service->isConnected(); + SE_SERVICE_EXTERN_END; return result; @@ -501,13 +544,17 @@ EXTERN_API bool se_service_is_connected(se_service_h handle) EXTERN_API void se_service_shutdown(se_service_h handle) { SE_SERVICE_EXTERN_BEGIN; + service->shutdown(); + SE_SERVICE_EXTERN_END; } EXTERN_API void se_service_destroy_instance(se_service_h handle) { SE_SERVICE_EXTERN_BEGIN; + delete service; + SE_SERVICE_EXTERN_END; } diff --git a/client/Session.cpp b/client/Session.cpp index 2213d83..5bbe5a4 100644 --- a/client/Session.cpp +++ b/client/Session.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include @@ -36,7 +35,8 @@ namespace smartcard_service_api { - Session::Session(void *context, Reader *reader, void *handle):SessionHelper(reader) + Session::Session(void *context, Reader *reader, void *handle) : + SessionHelper(reader) { this->context = NULL; @@ -66,7 +66,7 @@ namespace smartcard_service_api channels.clear(); } - void Session::closeChannels() + void Session::closeChannels() throw (ErrorIO &, ErrorIllegalState &) { size_t i; @@ -76,45 +76,50 @@ namespace smartcard_service_api } } - ByteArray Session::getATRSync() + ByteArray Session::getATRSync() throw (ErrorIO &, ErrorIllegalState &) { - atr.releaseBuffer(); + ByteArray result; if (getReader()->isSecureElementPresent() == true) { - Message msg; - int rv; + if (atr.isEmpty() == true) + { + Message msg; + int rv; #ifdef CLIENT_IPC_THREAD - /* request channel handle from server */ - msg.message = Message::MSG_REQUEST_GET_ATR; - msg.param1 = (unsigned int)handle; - msg.error = (unsigned int)context; /* using error to context */ - msg.caller = (void *)this; - msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */ - - syncLock(); - if (ClientIPC::getInstance().sendMessage(&msg) == true) - { - rv = waitTimedCondition(0); - if (rv != 0) + /* request channel handle from server */ + msg.message = Message::MSG_REQUEST_GET_ATR; + msg.param1 = (unsigned int)handle; + msg.error = (unsigned int)context; /* using error to context */ + msg.caller = (void *)this; + msg.callback = (void *)this; /* if callback is class instance, it means synchronized call */ + + syncLock(); + if (ClientIPC::getInstance().sendMessage(&msg) == true) { - SCARD_DEBUG_ERR("time over"); + rv = waitTimedCondition(0); + if (rv != 0) + { + SCARD_DEBUG_ERR("time over"); + } } - } - else - { - SCARD_DEBUG_ERR("sendMessage failed"); - } - syncUnlock(); + else + { + SCARD_DEBUG_ERR("sendMessage failed"); + } + syncUnlock(); #endif + } + + result = atr; } else { SCARD_DEBUG_ERR("unavailable session"); } - return atr; + return result; } int Session::getATR(getATRCallback callback, void *userData) @@ -123,19 +128,27 @@ namespace smartcard_service_api if (getReader()->isSecureElementPresent() == true) { - Message msg; + if (atr.isEmpty() == true) + { + Message msg; - /* request channel handle from server */ - msg.message = Message::MSG_REQUEST_GET_ATR; - msg.param1 = (unsigned int)handle; - msg.error = (unsigned int)context; /* using error to context */ - msg.caller = (void *)this; - msg.callback = (void *)callback; - msg.userParam = userData; + /* request channel handle from server */ + msg.message = Message::MSG_REQUEST_GET_ATR; + msg.param1 = (unsigned int)handle; + msg.error = (unsigned int)context; /* using error to context */ + msg.caller = (void *)this; + msg.callback = (void *)callback; + msg.userParam = userData; - if (ClientIPC::getInstance().sendMessage(&msg) == true) + if (ClientIPC::getInstance().sendMessage(&msg) == true) + { + result = 0; + } + } + else { - result = 0; + /* TODO : invoke callback directly */ + callback(atr.getBuffer(), atr.getLength(), 0, userData); } } else @@ -146,7 +159,7 @@ namespace smartcard_service_api return result; } - void Session::closeSync() + void Session::closeSync() throw (ErrorIO &, ErrorIllegalState &) { Message msg; int rv; @@ -282,6 +295,7 @@ namespace smartcard_service_api } Channel *Session::openChannelSync(int id, ByteArray aid) + throw (ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) { openedChannel = NULL; @@ -356,11 +370,13 @@ namespace smartcard_service_api } Channel *Session::openBasicChannelSync(ByteArray aid) + throw (ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) { return openChannelSync(0, aid); } Channel *Session::openBasicChannelSync(unsigned char *aid, unsigned int length) + throw (ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) { return openBasicChannelSync(ByteArray(aid, length)); } @@ -370,17 +386,20 @@ namespace smartcard_service_api return openChannel(0, aid, callback, userData); } - int Session::openBasicChannel(unsigned char *aid, unsigned int length, openChannelCallback callback, void *userData) + int Session::openBasicChannel(unsigned char *aid, unsigned int length, + openChannelCallback callback, void *userData) { return openBasicChannel(ByteArray(aid, length), callback, userData); } Channel *Session::openLogicalChannelSync(ByteArray aid) + throw (ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) { return openChannelSync(1, aid); } Channel *Session::openLogicalChannelSync(unsigned char *aid, unsigned int length) + throw (ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) { return openLogicalChannelSync(ByteArray(aid, length)); } @@ -390,7 +409,8 @@ namespace smartcard_service_api return openChannel(1, aid, callback, userData); } - int Session::openLogicalChannel(unsigned char *aid, unsigned int length, openChannelCallback callback, void *userData) + int Session::openLogicalChannel(unsigned char *aid, unsigned int length, + openChannelCallback callback, void *userData) { return openLogicalChannel(ByteArray(aid, length), callback, userData); } @@ -420,7 +440,8 @@ namespace smartcard_service_api if (msg->param1 != 0) { /* create new instance of channel */ - channel = new ClientChannel(session->context, session, msg->param2, msg->data, (void *)msg->param1); + channel = new ClientChannel(session->context, + session, msg->param2, msg->data, (void *)msg->param1); if (channel != NULL) { session->channels.push_back(channel); @@ -529,7 +550,7 @@ namespace smartcard_service_api } break; - default: + default : SCARD_DEBUG("unknown message : %s", msg->toString()); break; } @@ -558,7 +579,7 @@ EXTERN_API reader_h session_get_reader(session_h handle) reader_h reader = NULL; SESSION_EXTERN_BEGIN; - reader = session->getReader(); + reader = session->getReader(); SESSION_EXTERN_END; return reader; @@ -569,7 +590,7 @@ EXTERN_API int session_get_atr(session_h handle, session_get_atr_cb callback, vo int result = -1; SESSION_EXTERN_BEGIN; - result = session->getATR((getATRCallback)callback, userData); + result = session->getATR((getATRCallback)callback, userData); SESSION_EXTERN_END; return result; @@ -580,7 +601,7 @@ EXTERN_API int session_close(session_h handle, session_close_session_cb callback int result = -1; SESSION_EXTERN_BEGIN; - result = session->close((closeSessionCallback)callback, userData); + result = session->close((closeSessionCallback)callback, userData); SESSION_EXTERN_END; return result; @@ -591,7 +612,7 @@ EXTERN_API bool session_is_closed(session_h handle) bool result = false; SESSION_EXTERN_BEGIN; - result = session->isClosed(); + result = session->isClosed(); SESSION_EXTERN_END; return result; @@ -600,27 +621,29 @@ EXTERN_API bool session_is_closed(session_h handle) EXTERN_API void session_close_channels(session_h handle) { SESSION_EXTERN_BEGIN; - session->closeChannels(); + session->closeChannels(); SESSION_EXTERN_END; } -EXTERN_API int session_open_basic_channel(session_h handle, unsigned char *aid, unsigned int length, session_open_channel_cb callback, void *userData) +EXTERN_API int session_open_basic_channel(session_h handle, unsigned char *aid, + unsigned int length, session_open_channel_cb callback, void *userData) { int result = -1; SESSION_EXTERN_BEGIN; - result = session->openBasicChannel(aid, length, (openChannelCallback)callback, userData); + result = session->openBasicChannel(aid, length, (openChannelCallback)callback, userData); SESSION_EXTERN_END; return result; } -EXTERN_API int session_open_logical_channel(session_h handle, unsigned char *aid, unsigned int length, session_open_channel_cb callback, void *userData) +EXTERN_API int session_open_logical_channel(session_h handle, unsigned char *aid, + unsigned int length, session_open_channel_cb callback, void *userData) { int result = -1; SESSION_EXTERN_BEGIN; - result = session->openLogicalChannel(aid, length, (openChannelCallback)callback, userData); + result = session->openLogicalChannel(aid, length, (openChannelCallback)callback, userData); SESSION_EXTERN_END; return result; @@ -631,7 +654,7 @@ EXTERN_API int session_get_channel_count(session_h handle, session_get_channel_c int result = -1; SESSION_EXTERN_BEGIN; - result = session->getChannelCount((getChannelCountCallback)callback, userData); + result = session->getChannelCount((getChannelCountCallback)callback, userData); SESSION_EXTERN_END; return result; @@ -639,9 +662,6 @@ EXTERN_API int session_get_channel_count(session_h handle, session_get_channel_c EXTERN_API void session_destroy_instance(session_h handle) { - SESSION_EXTERN_BEGIN; - delete session; - SESSION_EXTERN_END; } EXTERN_API int session_get_atr_sync(session_h handle, unsigned char **buffer, unsigned int *length) @@ -654,16 +674,16 @@ EXTERN_API int session_get_atr_sync(session_h handle, unsigned char **buffer, un return result; SESSION_EXTERN_BEGIN; - temp = session->getATRSync(); - if (temp.getLength() > 0) - { - *length = temp.getLength(); - *buffer = (unsigned char *)calloc(1, *length); - memcpy(*buffer, temp.getBuffer(), *length); + temp = session->getATRSync(); + if (temp.getLength() > 0) + { + *length = temp.getLength(); + *buffer = (unsigned char *)calloc(1, *length); + memcpy(*buffer, temp.getBuffer(), *length); - result = 0; - } - SESSION_EXTERN_END; + result = 0; + } + SESSION_EXTERN_END; #endif return result; @@ -673,7 +693,7 @@ EXTERN_API void session_close_sync(session_h handle) { #ifdef CLIENT_IPC_THREAD SESSION_EXTERN_BEGIN; - session->closeSync(); + session->closeSync(); SESSION_EXTERN_END; #endif } @@ -684,7 +704,7 @@ EXTERN_API channel_h session_open_basic_channel_sync(session_h handle, unsigned #ifdef CLIENT_IPC_THREAD SESSION_EXTERN_BEGIN; - result = session->openBasicChannelSync(aid, length); + result = session->openBasicChannelSync(aid, length); SESSION_EXTERN_END; #endif @@ -697,7 +717,7 @@ EXTERN_API channel_h session_open_logical_channel_sync(session_h handle, unsigne #ifdef CLIENT_IPC_THREAD SESSION_EXTERN_BEGIN; - result = session->openLogicalChannelSync(aid, length); + result = session->openLogicalChannelSync(aid, length); SESSION_EXTERN_END; #endif @@ -710,7 +730,7 @@ EXTERN_API unsigned int session_get_channel_count_sync(session_h handle) #ifdef CLIENT_IPC_THREAD SESSION_EXTERN_BEGIN; - result = session->getChannelCountSync(); + result = session->getChannelCountSync(); SESSION_EXTERN_END; #endif diff --git a/client/include/ClientChannel.h b/client/include/ClientChannel.h index 53866c0..bbd5194 100644 --- a/client/include/ClientChannel.h +++ b/client/include/ClientChannel.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef CLIENTCHANNEL_H_ #define CLIENTCHANNEL_H_ @@ -41,18 +40,22 @@ namespace smartcard_service_api int error; ByteArray response; - ClientChannel(void *context, Session *session, int channelNum, ByteArray selectResponse, void *handle); + ClientChannel(void *context, Session *session, int channelNum, + ByteArray selectResponse, void *handle); + ~ClientChannel(); static bool dispatcherCallback(void *message); public: - ~ClientChannel(); - int close(closeCallback callback, void *userParam); - int transmit(ByteArray command, transmitCallback callback, void *userParam); + int transmit(ByteArray command, transmitCallback callback, + void *userParam); - void closeSync(); - int transmitSync(ByteArray command, ByteArray &result); + void closeSync() + throw(ErrorIO &, ErrorIllegalState &); + int transmitSync(ByteArray command, ByteArray &result) + throw(ErrorIO &, ErrorIllegalState &, + ErrorIllegalParameter &, ErrorSecurity &); friend class ClientDispatcher; friend class Session; @@ -71,14 +74,17 @@ bool channel_is_basic_channel(channel_h handle); bool channel_is_closed(channel_h handle); unsigned int channel_get_select_response_length(channel_h handle); -bool channel_get_select_response(channel_h handle, unsigned char *buffer, unsigned int length); +bool channel_get_select_response(channel_h handle, unsigned char *buffer, + unsigned int length); session_h channel_get_session(channel_h handle); -void channel_destroy_instance(channel_h handle); +void channel_destroy_instance(channel_h handle) __attribute__((deprecated)) ; int channel_close(channel_h handle, channel_close_cb callback, void *userParam); -int channel_transmit(channel_h handle, unsigned char *command, unsigned int length, channel_transmit_cb callback, void *userParam); +int channel_transmit(channel_h handle, unsigned char *command, + unsigned int length, channel_transmit_cb callback, void *userParam); void channel_close_sync(channel_h handle); -int channel_transmit_sync(channel_h handle, unsigned char *command, unsigned int cmd_len, unsigned char **response, unsigned int *resp_len); +int channel_transmit_sync(channel_h handle, unsigned char *command, + unsigned int cmd_len, unsigned char **response, unsigned int *resp_len); #ifdef __cplusplus } diff --git a/client/include/ClientDispatcher.h b/client/include/ClientDispatcher.h index 54d306a..3305b28 100644 --- a/client/include/ClientDispatcher.h +++ b/client/include/ClientDispatcher.h @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef CLIENTDISPATCHER_H_ #define CLIENTDISPATCHER_H_ diff --git a/client/include/ClientIPC.h b/client/include/ClientIPC.h index 354cd5d..4dbbc76 100644 --- a/client/include/ClientIPC.h +++ b/client/include/ClientIPC.h @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef CLIENTIPC_H_ #define CLIENTIPC_H_ diff --git a/client/include/Reader.h b/client/include/Reader.h index 8916bce..d80d1ed 100644 --- a/client/include/Reader.h +++ b/client/include/Reader.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef READER_H_ #define READER_H_ @@ -37,30 +36,29 @@ namespace smartcard_service_api private: void *context; void *handle; - ByteArray packageCert; /* temporary data for sync function */ int error; Session *openedSession; Reader(void *context, const char *name, void *handle); + ~Reader(); void unavailable(); static bool dispatcherCallback(void *message); - void getPackageCert(); public: - ~Reader(); - - void closeSessions(); + void closeSessions() + throw(ErrorIO &, ErrorIllegalState &); int openSession(openSessionCallback callback, void *userData); - SessionHelper *openSessionSync(); + SessionHelper *openSessionSync() + throw(ErrorIO &, ErrorIllegalState &, + ErrorIllegalParameter &, ErrorSecurity &); friend class SEService; friend class ClientDispatcher; }; - } /* namespace smartcard_service_api */ #endif /* __cplusplus */ @@ -73,10 +71,11 @@ extern "C" const char *reader_get_name(reader_h handle); se_service_h reader_get_se_service(reader_h handle); bool reader_is_secure_element_present(reader_h handle); -int reader_open_session(reader_h handle, reader_open_session_cb callback, void *userData); +int reader_open_session(reader_h handle, reader_open_session_cb callback, + void *userData); session_h reader_open_session_sync(reader_h handle); void reader_close_sessions(reader_h handle); -void reader_destroy_instance(reader_h handle); +__attribute__((deprecated)) void reader_destroy_instance(reader_h handle); #ifdef __cplusplus } diff --git a/client/include/SEService.h b/client/include/SEService.h index 18bdd35..0070fe3 100644 --- a/client/include/SEService.h +++ b/client/include/SEService.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef SESERVICE_H_ #define SESERVICE_H_ @@ -49,23 +48,32 @@ namespace smartcard_service_api static bool dispatcherCallback(void *message); bool parseReaderInformation(unsigned int count, ByteArray data); - bool _initialize(); - - bool initialize(void *context, serviceConnected handler); - bool initialize(void *context, SEServiceListener *listener); - SEService *initializeSync(void *context, serviceConnected handler); + bool _initialize() + throw(ErrorIO &); + bool initialize(void *context, serviceConnected handler) + throw(ErrorIO &, ErrorIllegalParameter &); + bool initialize(void *context, SEServiceListener *listener) + throw(ErrorIO &, ErrorIllegalParameter &); + SEService *initializeSync(void *context, serviceConnected handler) + throw(ErrorIO &, ErrorIllegalParameter &); public: - SEService(void *user_data, serviceConnected handler); - SEService(void *user_data, SEServiceListener *listener); + SEService(void *user_data, serviceConnected handler) + throw(ErrorIO &, ErrorIllegalParameter &); + SEService(void *user_data, SEServiceListener *listener) + throw(ErrorIO &, ErrorIllegalParameter &); ~SEService(); + static SEService *createInstance(void *user_data, SEServiceListener *listener) + throw(ErrorIO &, ErrorIllegalParameter &); + static SEService *createInstance(void *user_data, serviceConnected handler) + throw(ErrorIO &, ErrorIllegalParameter &); + void shutdown(); void shutdownSync(); friend class ClientDispatcher; }; - } /* namespace smartcard_service_api */ #endif /* __cplusplus */ @@ -76,7 +84,8 @@ extern "C" #endif /* __cplusplus */ se_service_h se_service_create_instance(void *user_data, se_service_connected_cb callback); -se_service_h se_service_create_instance_with_event_callback(void *user_data, se_service_connected_cb connected, se_service_event_cb event, se_sesrvice_error_cb error); +se_service_h se_service_create_instance_with_event_callback(void *user_data, + se_service_connected_cb connected, se_service_event_cb event, se_sesrvice_error_cb error); int se_service_get_readers_count(se_service_h handle); bool se_service_get_readers(se_service_h handle, reader_h *readers, int *count); bool se_service_is_connected(se_service_h handle); diff --git a/client/include/SEServiceListener.h b/client/include/SEServiceListener.h index 1b8d4ea..9cfc01b 100644 --- a/client/include/SEServiceListener.h +++ b/client/include/SEServiceListener.h @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef SESERVICELISTENER_H_ #define SESERVICELISTENER_H_ @@ -30,10 +30,13 @@ namespace smartcard_service_api class SEServiceListener { public: - virtual void serviceConnected(SEServiceHelper *service, void *context) = 0; - virtual void eventHandler(SEServiceHelper *service, char *seName, int event, void *context) = 0; - virtual void errorHandler(SEServiceHelper *service, int error, void *context) = 0; + virtual void serviceConnected(SEServiceHelper *service, + void *context) = 0; + virtual void eventHandler(SEServiceHelper *service, + char *seName, int event, void *context) = 0; + virtual void errorHandler(SEServiceHelper *service, int error, + void *context) = 0; }; - } /* namespace open_mobile_api */ + #endif /* SESERVICELISTENER_H_ */ diff --git a/client/include/Session.h b/client/include/Session.h index e4ec77f..ad91ce8 100644 --- a/client/include/Session.h +++ b/client/include/Session.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef SESSION_H_ #define SESSION_H_ @@ -44,16 +43,17 @@ namespace smartcard_service_api unsigned int channelCount; Session(void *context, Reader *reader, void *handle); + ~Session(); int openChannel(int id, ByteArray aid, openChannelCallback callback, void *userData); static bool dispatcherCallback(void *message); - Channel *openChannelSync(int id, ByteArray aid); + Channel *openChannelSync(int id, ByteArray aid) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &); public: - ~Session(); - - void closeChannels(); + void closeChannels() + throw(ErrorIO &, ErrorIllegalState &); int getATR(getATRCallback callback, void *userData); int close(closeSessionCallback callback, void *userData); @@ -64,13 +64,24 @@ namespace smartcard_service_api int openLogicalChannel(unsigned char *aid, unsigned int length, openChannelCallback callback, void *userData); int getChannelCount(getChannelCountCallback callback, void * userData); - ByteArray getATRSync(); - void closeSync(); + ByteArray getATRSync() + throw(ErrorIO &, ErrorIllegalState &); + + void closeSync() + throw(ErrorIO &, ErrorIllegalState &); + + Channel *openBasicChannelSync(ByteArray aid) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &); + + Channel *openBasicChannelSync(unsigned char *aid, unsigned int length) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &); + + Channel *openLogicalChannelSync(ByteArray aid) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &); + + Channel *openLogicalChannelSync(unsigned char *aid, unsigned int length) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &); - Channel *openBasicChannelSync(ByteArray aid); - Channel *openBasicChannelSync(unsigned char *aid, unsigned int length); - Channel *openLogicalChannelSync(ByteArray aid); - Channel *openLogicalChannelSync(unsigned char *aid, unsigned int length); unsigned int getChannelCountSync(); friend class ClientDispatcher; @@ -88,14 +99,16 @@ extern "C" reader_h session_get_reader(session_h handle); bool session_is_closed(session_h handle); -void session_destroy_instance(session_h handle); +__attribute__((deprecated)) void session_destroy_instance(session_h handle); void session_close_channels(session_h handle); int session_get_atr(session_h handle, session_get_atr_cb callback, void *userData); int session_close(session_h handle, session_close_session_cb callback, void *userData); -int session_open_basic_channel(session_h handle, unsigned char *aid, unsigned int length, session_open_channel_cb callback, void *userData); -int session_open_logical_channel(session_h handle, unsigned char *aid, unsigned int length, session_open_channel_cb callback, void *userData); +int session_open_basic_channel(session_h handle, unsigned char *aid, + unsigned int length, session_open_channel_cb callback, void *userData); +int session_open_logical_channel(session_h handle, unsigned char *aid, + unsigned int length, session_open_channel_cb callback, void *userData); int session_get_channel_count(session_h handle, session_get_channel_count_cb callback, void * userData); int session_get_atr_sync(session_h handle, unsigned char **buffer, unsigned int *length); diff --git a/client/include/smartcard-service.h b/client/include/smartcard-service.h new file mode 100644 index 0000000..a79163d --- /dev/null +++ b/client/include/smartcard-service.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SMARTCARD_SERVICE_H_ +#define SMARTCARD_SERVICE_H_ + +#include "smartcard-types.h" +#include "Exception.h" +#include "SEService.h" +#include "Reader.h" +#include "Session.h" +#include "ClientChannel.h" + +#endif /* SMARTCARD_SERVICE_H_ */ diff --git a/common/APDUHelper.cpp b/common/APDUHelper.cpp index 09c0883..f94bfdd 100644 --- a/common/APDUHelper.cpp +++ b/common/APDUHelper.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include @@ -29,6 +28,7 @@ namespace smartcard_service_api { /* ResponseHelper class */ ResponseHelper::ResponseHelper() + : status(0) { } @@ -58,7 +58,8 @@ namespace smartcard_service_api if (response.getLength() > 2) { - dataField.setBuffer(response.getBuffer(), response.getLength() - 2); + dataField.setBuffer(response.getBuffer(), + response.getLength() - 2); } result = true; @@ -69,17 +70,18 @@ namespace smartcard_service_api int ResponseHelper::parseStatusWord(unsigned char *sw) { - int result = 0; + int result = sw[0] << 8 | sw[1]; switch (sw[0]) { /* Normal processing */ case (unsigned char)0x90 : /* SW2:00, No further qualification */ - break; - case (unsigned char)0x91 : /* extra information */ + case (unsigned char)0x92 : /* extra information */ + result = 0; break; +#if 0 case (unsigned char)0x61 : /* SW2 encodes the number of data bytes still available */ break; @@ -139,9 +141,9 @@ namespace smartcard_service_api case (unsigned char)0x6F : /* SW2:00, No precise diagnosis */ result = -1; break; - +#endif default : - result = -1; + result *= -1; break; } @@ -204,7 +206,8 @@ namespace smartcard_service_api { } - bool APDUCommand::setCommand(unsigned char cla, unsigned char ins, unsigned char p1, unsigned char p2, ByteArray commandData, unsigned int maxResponseSize) + bool APDUCommand::setCommand(unsigned char cla, unsigned char ins, unsigned char p1, + unsigned char p2, ByteArray commandData, unsigned int maxResponseSize) { setCLA(cla); setINS(ins); @@ -259,12 +262,25 @@ namespace smartcard_service_api { if (isExtendedLength) { - /* TODO */ + unsigned int temp; + + temp = command.getAt(offset) << 8; + temp |= command.getAt(offset + 1); + + if (temp == 0) + setMaxResponseSize(APDUCommand::LE_MAX); + else + setMaxResponseSize(temp); + offset += 2; } else { - setMaxResponseSize(command.getAt(offset)); + if (command.getAt(offset) == 0) + setMaxResponseSize(APDUCommand::LE_MAX); + else + setMaxResponseSize(command.getAt(offset)); + offset += 1; } } @@ -404,7 +420,7 @@ namespace smartcard_service_api this->maxResponseSize = maxResponseSize; } - unsigned int APDUCommand::setMaxResponseSize() + unsigned int APDUCommand::getMaxResponseSize() { return maxResponseSize; } @@ -464,7 +480,7 @@ namespace smartcard_service_api } else { - if (maxResponseSize != 256) + if (maxResponseSize < 256) le[0] = maxResponseSize & 0x000000FF; le_len = 1; @@ -513,7 +529,7 @@ namespace smartcard_service_api switch (command) { case COMMAND_OPEN_LOGICAL_CHANNEL : - apdu.setCommand(0, APDUCommand::INS_MANAGE_CHANNEL, 0, 0, ByteArray::EMPTY, 1); + apdu.setCommand(0, APDUCommand::INS_MANAGE_CHANNEL, 0, 0, ByteArray::EMPTY, APDUCommand::LE_MAX); apdu.getBuffer(result); break; diff --git a/common/AccessCondition.cpp b/common/AccessCondition.cpp index 7075ae2..703d0de 100644 --- a/common/AccessCondition.cpp +++ b/common/AccessCondition.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include diff --git a/common/AccessControlList.cpp b/common/AccessControlList.cpp index e4a13be..9ed93f1 100644 --- a/common/AccessControlList.cpp +++ b/common/AccessControlList.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include diff --git a/common/ByteArray.cpp b/common/ByteArray.cpp index 8e825c2..745800f 100644 --- a/common/ByteArray.cpp +++ b/common/ByteArray.cpp @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 4b36681..7b28e5c 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -15,7 +15,7 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SRCS) #MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs_common REQUIRED dlog glib-2.0 aul libssl pkgmgr) +pkg_check_modules(pkgs_common REQUIRED dlog glib-2.0 aul libssl pkgmgr pkgmgr-info) MESSAGE("${LIB_NAME} ld flag : ${pkgs_common_LDFLAGS}") @@ -59,6 +59,7 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_common_LDFLAGS}) SET(EXPORT_HEADER include/Debug.h + include/Exception.h include/ByteArray.h include/Lock.h include/Synchronous.h diff --git a/common/DispatcherHelper.cpp b/common/DispatcherHelper.cpp index 40bd670..a4b5510 100644 --- a/common/DispatcherHelper.cpp +++ b/common/DispatcherHelper.cpp @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include diff --git a/common/EFDIR.cpp b/common/EFDIR.cpp new file mode 100644 index 0000000..16dfc54 --- /dev/null +++ b/common/EFDIR.cpp @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* standard library header */ +#include + +/* SLP library header */ + +/* local header */ +#include "Debug.h" +#include "EFDIR.h" +#include "APDUHelper.h" +#include "SimpleTLV.h" + +namespace smartcard_service_api +{ + EFDIR::EFDIR(Channel *channel) : FileObject(channel) + { + unsigned char path[] = { 0x2f, 0x00 }; + ByteArray dirPath(ARRAY_AND_SIZE(path)); + int ret; + + ret = select(dirPath, false); + if (ret == FileObject::SUCCESS) + { + SCARD_DEBUG("response : %s", selectResponse.toString()); + } + else + { + SCARD_DEBUG_ERR("EFDIR select failed, [%d]", ret); + } + } + + EFDIR::EFDIR(Channel *channel, ByteArray selectResponse) + : FileObject(channel, selectResponse) + { + } + + EFDIR::~EFDIR() + { + } + + ByteArray EFDIR::parseRecord(Record &record, ByteArray &aid) + { + bool matched = false; + ByteArray result; + SimpleTLV tlv(record.getData()); + + if (tlv.decodeTLV() == true && tlv.getTag() == 0x61) + { + tlv.enterToValueTLV(); + while (tlv.decodeTLV() == true) + { + switch (tlv.getTag()) + { + case 0x4F : /* aid */ + if (tlv.getValue() == aid) + matched = true; + break; + case 0x50 : /* label */ + break; + case 0x51 : /* path */ + result = tlv.getValue(); + break; + case 0x53 : /* ddo */ + break; + } + } + tlv.returnToParentTLV(); + + if (matched == true) + { + SCARD_DEBUG("Found!! : path %s", result.toString()); + } + else + { + result.setBuffer(NULL, 0); + } + } + + return result; + } + + ByteArray EFDIR::getPathByAID(ByteArray &aid) + { + ByteArray result; + Record record; + unsigned int id; + int status = 0; + + for (id = 1; status >= 0; id++) + { + status = readRecord(0, id, record); + if (status >= 0) + { + result = parseRecord(record, aid); + if (result.getLength() > 0) + break; + } + } + + return result; + } +} /* namespace smartcard_service_api */ diff --git a/common/Exception.cpp b/common/Exception.cpp new file mode 100644 index 0000000..53a6b0e --- /dev/null +++ b/common/Exception.cpp @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "Exception.h" + +namespace smartcard_service_api +{ +} /* namespace smartcard_service_api */ diff --git a/common/FCI.cpp b/common/FCI.cpp index 214f75e..1771dea 100644 --- a/common/FCI.cpp +++ b/common/FCI.cpp @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include diff --git a/common/FileObject.cpp b/common/FileObject.cpp index 51c8c38..e93e459 100644 --- a/common/FileObject.cpp +++ b/common/FileObject.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include @@ -27,12 +26,14 @@ namespace smartcard_service_api { - FileObject::FileObject(Channel *channel):ProviderHelper(channel) + FileObject::FileObject(Channel *channel) + : ProviderHelper(channel) { opened = false; } - FileObject::FileObject(Channel *channel, ByteArray selectResponse):ProviderHelper(channel) + FileObject::FileObject(Channel *channel, ByteArray selectResponse) + : ProviderHelper(channel) { opened = false; setSelectResponse(selectResponse); @@ -40,6 +41,13 @@ namespace smartcard_service_api FileObject::~FileObject() { + close(); + } + + void FileObject::close() + { + opened = false; + selectResponse.releaseBuffer(); } bool FileObject::setSelectResponse(ByteArray &response) @@ -64,7 +72,8 @@ namespace smartcard_service_api } else { - SCARD_DEBUG_ERR("status word [%d][ %02X %02X ]", resp.getStatus(), resp.getSW1(), resp.getSW2()); + SCARD_DEBUG_ERR("status word [%d][ %02X %02X ]", + resp.getStatus(), resp.getSW1(), resp.getSW2()); } } else @@ -87,23 +96,34 @@ namespace smartcard_service_api return ret; } - opened = false; + close(); ret = channel->transmitSync(command, result); if (ret == 0) { - if (setSelectResponse(result) == true) + ResponseHelper resp(result); + + if (resp.getStatus() == 0) { - ret = SUCCESS; + if (setSelectResponse(result) == true) + { + opened = true; + ret = SUCCESS; + } + else + { + ret = ERROR_ILLEGAL_STATE; + } } - else + else if (resp.getStatus() == ResponseHelper::ERROR_FILE_NOT_FOUND) { - ret = ERROR_ILLEGAL_STATE; + ret = ResponseHelper::ERROR_FILE_NOT_FOUND; } } else { - SCARD_DEBUG_ERR("select apdu is failed, rv [%d], length [%d]", ret, result.getLength()); + SCARD_DEBUG_ERR("select apdu is failed, rv [%d], length [%d]", + ret, result.getLength()); ret = ERROR_ILLEGAL_STATE; } @@ -118,7 +138,6 @@ namespace smartcard_service_api /* make apdu command */ command = APDUHelper::generateAPDU(APDUHelper::COMMAND_SELECT_BY_DF_NAME, 0, aid); - SCARD_DEBUG("command : %s", command.toString()); ret = _select(command); @@ -137,9 +156,16 @@ namespace smartcard_service_api } else { - command = APDUHelper::generateAPDU(APDUHelper::COMMAND_SELECT_BY_PATH, 0, path); + ByteArray temp(path); + + if (path.getLength() > 2 && path[0] == 0x3f && path[1] == 0x00) /* check MF */ + { + /* remove MF from path */ + temp.setBuffer(path.getBuffer(2), path.getLength() - 2); + } + + command = APDUHelper::generateAPDU(APDUHelper::COMMAND_SELECT_BY_PATH, 0, temp); } - SCARD_DEBUG("command : %s", command.toString()); ret = _select(command); @@ -153,7 +179,6 @@ namespace smartcard_service_api /* make apdu command */ command = APDUHelper::generateAPDU(APDUHelper::COMMAND_SELECT_BY_ID, 0, fidData); - SCARD_DEBUG("command : %s", command.toString()); ret = _select(command); @@ -167,7 +192,6 @@ namespace smartcard_service_api /* make apdu command */ command = APDUHelper::generateAPDU(APDUHelper::COMMAND_SELECT_PARENT_DF, 0, ByteArray::EMPTY); - SCARD_DEBUG("command : %s", command.toString()); ret = _select(command); @@ -190,22 +214,20 @@ namespace smartcard_service_api APDUCommand apdu; int ret; - apdu.setCommand(0, APDUCommand::INS_READ_RECORD, recordId, 4, ByteArray::EMPTY, 0); + apdu.setCommand(0, APDUCommand::INS_READ_RECORD, recordId, 4, ByteArray::EMPTY, APDUCommand::LE_MAX); apdu.getBuffer(command); - SCARD_DEBUG("command : %s", command.toString()); ret = channel->transmitSync(command, response); if (ret == 0 && response.getLength() >= 2) { ResponseHelper resp(response); - if (resp.getStatus() == 0) + ret = resp.getStatus(); + if (ret == 0) { SCARD_DEBUG("response [%d] : %s", response.getLength(), response.toString()); -// result = resp.getDataField(); - - ret = SUCCESS; + result = Record(recordId, resp.getDataField()); } else { @@ -238,7 +260,6 @@ namespace smartcard_service_api apdu.setCommand(0, APDUCommand::INS_READ_BINARY, offset, 0, ByteArray::EMPTY, length); apdu.getBuffer(command); - SCARD_DEBUG("command : %s", command.toString()); ret = channel->transmitSync(command, response); if (ret == 0 && response.getLength() >= 2) @@ -274,7 +295,6 @@ namespace smartcard_service_api apdu.setCommand(0, APDUCommand::INS_WRITE_BINARY, offset, 0, data, 0); apdu.getBuffer(command); - SCARD_DEBUG("command : %s", command.toString()); ret = channel->transmitSync(command, response); if (ret == 0 && response.getLength() >= 2) @@ -299,5 +319,4 @@ namespace smartcard_service_api return ret; } - } /* namespace smartcard_service_api */ diff --git a/common/GPSEACL.cpp b/common/GPSEACL.cpp index ed8f041..a6eb0f7 100644 --- a/common/GPSEACL.cpp +++ b/common/GPSEACL.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ diff --git a/common/IPCHelper.cpp b/common/IPCHelper.cpp index 3302fcb..708575a 100644 --- a/common/IPCHelper.cpp +++ b/common/IPCHelper.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include @@ -160,7 +159,10 @@ namespace smartcard_service_api } #ifdef SECURITY_SERVER - gid = security_server_get_gid(NET_NFC_MANAGER_OBJECT); + int gid, cookies_size; + char *cookies; + + gid = security_server_get_gid("smartcard-service"); if(gid == 0) { SCARD_DEBUG("get gid from security server is failed. this object is not allowed by security server"); @@ -216,6 +218,16 @@ ERROR : } } } + else if (errno == EINTR) + { + SCARD_DEBUG_ERR("epoll_wait interrupted"); + } + else + { + char buffer[1024]; + + SCARD_DEBUG_ERR("epoll_wait failed, errno [%d], %s", errno, strerror_r(errno, buffer, sizeof(buffer))); + } #else if (select(ipcSocket + 1, &fdSetRead, NULL, NULL, NULL) > 0) { @@ -296,8 +308,7 @@ ERROR : } else { - helper->handleInvalidSocketCondition(NULL, G_IO_NVAL); - condition = false; + /* skip other error case */ } } @@ -313,6 +324,7 @@ ERROR : GIOCondition condition = (GIOCondition)(G_IO_ERR | G_IO_HUP | G_IO_IN); #endif int result = 0; + char err[200] = { 0, }; SCARD_BEGIN(); @@ -329,7 +341,8 @@ ERROR : ipcSocket = socket(AF_UNIX, SOCK_STREAM, 0); if (ipcSocket == -1) { - SCARD_DEBUG_ERR("get socket is failed"); + SCARD_DEBUG_ERR("get socket is failed [%d, %s]", + errno, strerror_r(errno, err, sizeof(err))); goto ERROR; } @@ -344,7 +357,8 @@ ERROR : if ((result = connect(ipcSocket, (struct sockaddr *)&saddrun_rv, len_saddr)) < 0) { - SCARD_DEBUG_ERR("connect failed [%d]", result); + SCARD_DEBUG_ERR("connect failed [%d, %s]", + errno, strerror_r(errno, err, sizeof(err))); goto ERROR; } @@ -352,7 +366,8 @@ ERROR : #ifdef USE_IPC_EPOLL if((fdPoll = epoll_create1(EPOLL_CLOEXEC)) == -1) { - SCARD_DEBUG_ERR("epoll_create1 failed"); + SCARD_DEBUG_ERR("epoll_create1 failed [%d, %s]", + errno, strerror_r(errno, err, sizeof(err))); goto ERROR; } @@ -509,7 +524,8 @@ ERROR : stream = msg->serialize(); length = stream.getLength(); - SCARD_DEBUG(">>>[SEND]>>> socket [%d], msg [%d], length [%d]", socket, msg->message, stream.getLength()); + SCARD_DEBUG(">>>[SEND]>>> socket [%d], msg [%d], length [%d]", + socket, msg->message, stream.getLength()); return sendMessage(socket, stream); } diff --git a/common/ISO7816BERTLV.cpp b/common/ISO7816BERTLV.cpp index abe8d2f..425376a 100644 --- a/common/ISO7816BERTLV.cpp +++ b/common/ISO7816BERTLV.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include diff --git a/common/Message.cpp b/common/Message.cpp index 5f9cae5..a9b815e 100644 --- a/common/Message.cpp +++ b/common/Message.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include diff --git a/common/NumberStream.cpp b/common/NumberStream.cpp index 6e3bda1..455ce16 100644 --- a/common/NumberStream.cpp +++ b/common/NumberStream.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #include "NumberStream.h" diff --git a/common/PKCS15.cpp b/common/PKCS15.cpp index 4a94c9f..46236d7 100644 --- a/common/PKCS15.cpp +++ b/common/PKCS15.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ @@ -21,28 +20,47 @@ /* local header */ #include "Debug.h" +#include "APDUHelper.h" +#include "EFDIR.h" #include "PKCS15.h" namespace smartcard_service_api { - static unsigned char aid[] = { 0xA0, 0x00, 0x00, 0x00, 0x63, 0x50, 0x4B, 0x43, 0x53, 0x2D, 0x31, 0x35 }; + static unsigned char aid[] = { 0xA0, 0x00, 0x00, 0x00, 0x63, 0x50, + 0x4B, 0x43, 0x53, 0x2D, 0x31, 0x35 }; ByteArray PKCS15::PKCS15_AID(ARRAY_AND_SIZE(aid)); - PKCS15::PKCS15(Channel *channel):PKCS15Object(channel), odf(NULL) + PKCS15::PKCS15(Channel *channel) + : PKCS15Object(channel), odf(NULL) { - int ret = 0; + int ret; - if ((ret = select(PKCS15::PKCS15_AID)) == 0) + ret = select(PKCS15::PKCS15_AID); + if (ret == FileObject::SUCCESS) { SCARD_DEBUG("response : %s", selectResponse.toString()); } + else if (ret == ResponseHelper::ERROR_FILE_NOT_FOUND) + { + SCARD_DEBUG_ERR("PKCS15 AID not found, search in EF DIR"); + + if (selectFromEFDIR() == true) + { + SCARD_DEBUG("response : %s", selectResponse.toString()); + } + else + { + SCARD_DEBUG_ERR("PKCS15 select failed, [%d]", ret); + } + } else { - SCARD_DEBUG_ERR("select failed, [%d]", ret); + SCARD_DEBUG_ERR("PKCS15 select failed, [%d]", ret); } } - PKCS15::PKCS15(Channel *channel, ByteArray selectResponse):PKCS15Object(channel, selectResponse), odf(NULL) + PKCS15::PKCS15(Channel *channel, ByteArray selectResponse) + : PKCS15Object(channel, selectResponse), odf(NULL) { } @@ -55,6 +73,35 @@ namespace smartcard_service_api } } + bool PKCS15::selectFromEFDIR() + { + bool result = false; + ByteArray path; + EFDIR dir(channel); + + path = dir.getPathByAID(PKCS15_AID); + if (path.getLength() > 0) + { + int ret; + + ret = select(path, false); + if (ret == FileObject::SUCCESS) + { + result = true; + } + else + { + SCARD_DEBUG_ERR("path select failed, [%d]", ret); + } + } + else + { + SCARD_DEBUG_ERR("PKCS15 not found"); + } + + return result; + } + PKCS15ODF *PKCS15::getODF() { if (odf == NULL) @@ -74,5 +121,4 @@ namespace smartcard_service_api return odf; } - } /* namespace smartcard_service_api */ diff --git a/common/PKCS15DODF.cpp b/common/PKCS15DODF.cpp index c613775..7009957 100644 --- a/common/PKCS15DODF.cpp +++ b/common/PKCS15DODF.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ diff --git a/common/PKCS15ODF.cpp b/common/PKCS15ODF.cpp index ce6646c..686cef6 100644 --- a/common/PKCS15ODF.cpp +++ b/common/PKCS15ODF.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ @@ -27,12 +26,8 @@ namespace smartcard_service_api { -// PKCS15ODF::PKCS15ODF():PKCS15Object() -// { -// -// } - - PKCS15ODF::PKCS15ODF(Channel *channel):PKCS15Object(channel), dodf(NULL) + PKCS15ODF::PKCS15ODF(Channel *channel) + : PKCS15Object(channel), dodf(NULL) { int ret = 0; @@ -59,7 +54,8 @@ namespace smartcard_service_api } } - PKCS15ODF::PKCS15ODF(Channel *channel, ByteArray selectResponse):PKCS15Object(channel, selectResponse), dodf(NULL) + PKCS15ODF::PKCS15ODF(Channel *channel, ByteArray selectResponse) + : PKCS15Object(channel, selectResponse), dodf(NULL) { int ret = 0; ByteArray odfData; @@ -125,7 +121,8 @@ namespace smartcard_service_api break; default : - SCARD_DEBUG("Unknown tlv : t [%X], l [%d], v %s", tlv.getTag(), tlv.getLength(), tlv.getValue().toString()); + SCARD_DEBUG("Unknown tlv : t [%X], l [%d], v %s", + tlv.getTag(), tlv.getLength(), tlv.getValue().toString()); break; } diff --git a/common/PKCS15OID.cpp b/common/PKCS15OID.cpp index b4cd282..86a7923 100644 --- a/common/PKCS15OID.cpp +++ b/common/PKCS15OID.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ diff --git a/common/PKCS15Object.cpp b/common/PKCS15Object.cpp index dbc65a3..debc182 100644 --- a/common/PKCS15Object.cpp +++ b/common/PKCS15Object.cpp @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ diff --git a/common/PKCS15Path.cpp b/common/PKCS15Path.cpp index 33266d7..b3664bf 100644 --- a/common/PKCS15Path.cpp +++ b/common/PKCS15Path.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ diff --git a/common/PKCS15TokenInfo.cpp b/common/PKCS15TokenInfo.cpp index 4508ba5..58bcef7 100644 --- a/common/PKCS15TokenInfo.cpp +++ b/common/PKCS15TokenInfo.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ diff --git a/common/ProviderHelper.cpp b/common/ProviderHelper.cpp index c1f7f33..39817be 100644 --- a/common/ProviderHelper.cpp +++ b/common/ProviderHelper.cpp @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ diff --git a/common/ReaderHelper.cpp b/common/ReaderHelper.cpp index bf625e8..1583a9b 100644 --- a/common/ReaderHelper.cpp +++ b/common/ReaderHelper.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include @@ -27,10 +26,8 @@ namespace smartcard_service_api { - ReaderHelper::ReaderHelper() + ReaderHelper::ReaderHelper() : seService(NULL), present(false) { memset(name, 0, sizeof(name)); - seService = NULL; - present = false; } } /* namespace smartcard_service_api */ diff --git a/common/Record.cpp b/common/Record.cpp deleted file mode 100644 index fcef62a..0000000 --- a/common/Record.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* standard library header */ - -/* SLP library header */ - -/* local header */ -#include "Record.h" - -namespace smartcard_service_api -{ - Record::Record() - { - } - - Record::~Record() - { - } - -} /* namespace smartcard_service_api */ diff --git a/common/SEServiceHelper.cpp b/common/SEServiceHelper.cpp index 80bc53b..85ce608 100644 --- a/common/SEServiceHelper.cpp +++ b/common/SEServiceHelper.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include diff --git a/common/Serializable.cpp b/common/Serializable.cpp index 06c3c01..f4daec8 100644 --- a/common/Serializable.cpp +++ b/common/Serializable.cpp @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ diff --git a/common/SessionHelper.cpp b/common/SessionHelper.cpp index dec604e..fde6560 100644 --- a/common/SessionHelper.cpp +++ b/common/SessionHelper.cpp @@ -1,39 +1,31 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ -#include /* SLP library header */ /* local header */ -#include "Debug.h" -#include "SessionHelper.h" #include "ReaderHelper.h" namespace smartcard_service_api { - SessionHelper::SessionHelper(ReaderHelper *reader) : closed(true) + SessionHelper::SessionHelper(ReaderHelper *reader) : + closed(true) { this->reader = reader; } - -// ByteArray SessionHelper::getATR() -// { -// return atr; -// } } /* namespace smartcard_service_api */ diff --git a/common/SignatureHelper.cpp b/common/SignatureHelper.cpp index ee3f52e..c9fe8ae 100644 --- a/common/SignatureHelper.cpp +++ b/common/SignatureHelper.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include @@ -26,6 +25,7 @@ /* SLP library header */ #include "package-manager.h" +#include "pkgmgr-info.h" #include "aul.h" /* local header */ @@ -83,13 +83,28 @@ namespace smartcard_service_api ByteArray result; int ret = 0; pkgmgr_certinfo_h handle = NULL; + pkgmgrinfo_appinfo_h handle_appinfo; + char *pkgid = NULL; + if(pkgmgrinfo_appinfo_get_appinfo(packageName, &handle_appinfo) != PMINFO_R_OK) + { + SCARD_DEBUG_ERR("pkgmgrinfo_appinfo_get_appinfo fail"); + return result; + } - SCARD_DEBUG("package name : %s", packageName); + if(pkgmgrinfo_appinfo_get_pkgid(handle_appinfo, &pkgid) != PMINFO_R_OK) + { + pkgmgrinfo_appinfo_destroy_appinfo(handle_appinfo); + SCARD_DEBUG_ERR("pkgmgrinfo_appinfo_get_pkgid fail"); + return result; + } + pkgmgrinfo_appinfo_destroy_appinfo(handle_appinfo); + + SCARD_DEBUG("package name : %s", pkgid); if ((ret = pkgmgr_pkginfo_create_certinfo(&handle)) == 0) { - if ((ret = pkgmgr_pkginfo_load_certinfo(packageName, handle)) == 0) + if ((ret = pkgmgr_pkginfo_load_certinfo(pkgid, handle)) == 0) { int type; @@ -167,12 +182,27 @@ namespace smartcard_service_api bool result = false; int ret = 0; pkgmgr_certinfo_h handle = NULL; + pkgmgrinfo_appinfo_h handle_appinfo; + char *pkgid = NULL; - SCARD_DEBUG("package name : %s", packageName); + if(pkgmgrinfo_appinfo_get_appinfo(packageName, &handle_appinfo) != PMINFO_R_OK) + { + SCARD_DEBUG_ERR("pkgmgrinfo_appinfo_get_appinfo fail"); + return result; + } + + if(pkgmgrinfo_appinfo_get_pkgid(handle_appinfo, &pkgid) != PMINFO_R_OK) + { + pkgmgrinfo_appinfo_destroy_appinfo(handle_appinfo); + SCARD_DEBUG_ERR("pkgmgrinfo_appinfo_get_pkgid fail"); + return result; + } + + SCARD_DEBUG("package name : %s", pkgid); if ((ret = pkgmgr_pkginfo_create_certinfo(&handle)) == 0) { - if ((ret = pkgmgr_pkginfo_load_certinfo(packageName, handle)) == 0) + if ((ret = pkgmgr_pkginfo_load_certinfo(pkgid, handle)) == 0) { int type; @@ -207,6 +237,8 @@ namespace smartcard_service_api SCARD_DEBUG_ERR("pkgmgr_pkginfo_load_certinfo failed [%d]", ret); } + pkgmgrinfo_appinfo_destroy_appinfo(handle_appinfo); + pkgmgr_pkginfo_destroy_certinfo(handle); } else diff --git a/common/SimpleTLV.cpp b/common/SimpleTLV.cpp index 2110e30..638e6c7 100644 --- a/common/SimpleTLV.cpp +++ b/common/SimpleTLV.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include diff --git a/common/Synchronous.cpp b/common/Synchronous.cpp index 6781467..03ff05c 100644 --- a/common/Synchronous.cpp +++ b/common/Synchronous.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include diff --git a/common/TLVHelper.cpp b/common/TLVHelper.cpp index 2a8adb7..b577996 100644 --- a/common/TLVHelper.cpp +++ b/common/TLVHelper.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include @@ -81,6 +80,7 @@ namespace smartcard_service_api bool TLVHelper::_decodeTLV() { int result; + int temp = 0; currentT = 0; currentL = 0; @@ -90,26 +90,31 @@ namespace smartcard_service_api return false; /* T */ - if ((result = decodeTag(tlvBuffer.getBuffer(offset))) < 0) + if ((result = decodeTag(tlvBuffer.getBuffer(offset + temp))) < 0) return false; - offset += result; + temp += result; /* L */ - if ((result = decodeLength(tlvBuffer.getBuffer(offset))) < 0) + if ((result = decodeLength(tlvBuffer.getBuffer(offset + temp))) < 0) return false; - offset += result; + temp += result; if (currentL > 0) { + if (currentL > (tlvBuffer.getLength() - (offset + temp))) + return false; + /* V */ - if ((result = decodeValue(tlvBuffer.getBuffer(offset))) < 0) + if ((result = decodeValue(tlvBuffer.getBuffer(offset + temp))) < 0) return false; - offset += result; + temp += result; } + offset += temp; + return true; } diff --git a/common/include/APDUHelper.h b/common/include/APDUHelper.h index 61cdd56..0f24ac8 100644 --- a/common/include/APDUHelper.h +++ b/common/include/APDUHelper.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef APDUHELPER_H_ #define APDUHELPER_H_ @@ -36,7 +35,29 @@ namespace smartcard_service_api ByteArray dataField; static int parseStatusWord(unsigned char *sw); + public: + static const int SUCCESS = 0; + + static const int ERROR_UNKNOWN = -1; + + static const int ERROR_NO_INFORMATION = -(0x6900); + static const int ERROR_COMMAND_INCOMPATIBLE = -(0x6981); + static const int ERROR_SECURITY_NOT_SATISFIED = -(0x6982); + static const int ERROR_AUTH_PIN_BLOCKED = -(0x6983); + static const int ERROR_REF_DATA_INVALID = -(0x6984); + static const int ERROR_CONDITION_NOT_SATIFIED = -(0x6985); + static const int ERROR_COMMAND_NOT_ALLOW = -(0x6986); + + static const int ERROR_INCORRECT_PARAMETER = -(0x6a80); + static const int ERROR_FUNCTION_NOT_SUPPORT = -(0x6a81); + static const int ERROR_FILE_NOT_FOUND = -(0x6a82); + static const int ERROR_RECORD_NOT_FOUND = -(0x6a83); + static const int ERROR_NOT_ENOUGH_MEMORY = -(0x6a84); + static const int ERROR_INCORRECT_P1_P2 = -(0x6a86); + static const int ERROR_LC_INCONSISTENT = -(0x6a87); + static const int ERROR_REF_DATA_NOT_FOUND = -(0x6a88); + ResponseHelper(); ResponseHelper(const ByteArray &response); ~ResponseHelper(); @@ -118,10 +139,13 @@ namespace smartcard_service_api static const unsigned char CLA_CHANNEL_STANDARD = (unsigned char)0x00; static const unsigned char CLA_CHANNEL_EXTENDED = (unsigned char)0x01; + static const unsigned int LE_MAX = -1; + APDUCommand(); ~APDUCommand(); - bool setCommand(unsigned char cla, unsigned char ins, unsigned char p1, unsigned char p2, ByteArray commandData, unsigned int maxResponseSize); + bool setCommand(unsigned char cla, unsigned char ins, unsigned char p1, + unsigned char p2, ByteArray commandData, unsigned int maxResponseSize); bool setCommand(const ByteArray &command); bool setChannel(int type, int channelNum); @@ -142,7 +166,7 @@ namespace smartcard_service_api ByteArray getCommandData(); void setMaxResponseSize(unsigned int maxResponseSize); - unsigned int setMaxResponseSize(); + unsigned int getMaxResponseSize(); bool getBuffer(ByteArray &array); }; diff --git a/common/include/AccessCondition.h b/common/include/AccessCondition.h index 56dcea3..20ca90a 100644 --- a/common/include/AccessCondition.h +++ b/common/include/AccessCondition.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef ACCESSCONDITION_H_ #define ACCESSCONDITION_H_ diff --git a/common/include/AccessControlList.h b/common/include/AccessControlList.h index 892d890..1bbbb76 100644 --- a/common/include/AccessControlList.h +++ b/common/include/AccessControlList.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef ACCESSCONTROLLIST_H_ #define ACCESSCONTROLLIST_H_ diff --git a/common/include/ByteArray.h b/common/include/ByteArray.h index e7a9534..cc08c5b 100644 --- a/common/include/ByteArray.h +++ b/common/include/ByteArray.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef BYTEARRAY_H_ #define BYTEARRAY_H_ diff --git a/common/include/Channel.h b/common/include/Channel.h index 5813165..a6a5dc9 100644 --- a/common/include/Channel.h +++ b/common/include/Channel.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef CHANNEL_H_ #define CHANNEL_H_ @@ -25,12 +24,14 @@ /* local header */ #include "Synchronous.h" #include "ByteArray.h" +#include "Exception.h" namespace smartcard_service_api { class SessionHelper; /* explicit declaration */ - typedef void (*transmitCallback)(unsigned char *buffer, unsigned int length, int error, void *userParam); + typedef void (*transmitCallback)(unsigned char *buffer, unsigned int length, + int error, void *userParam); typedef void (*closeCallback)(int error, void *userParam); class Channel : public Synchronous @@ -40,29 +41,28 @@ namespace smartcard_service_api SessionHelper *session; int channelNum; - Channel() : Synchronous() - { - channelNum = -1; - } - Channel(SessionHelper *session) : Synchronous() - { - this->session = session; - } + Channel() : Synchronous() { channelNum = -1; } + Channel(SessionHelper *session) : Synchronous() { this->session = session; } + + inline void setSelectResponse(ByteArray &response) { selectResponse = response; } public : virtual ~Channel() {}; - inline bool isBasicChannel() const { return (channelNum == 0); } - inline bool isClosed() const { return (channelNum < 0); } + inline bool isBasicChannel() const throw() { return (channelNum == 0); } + inline bool isClosed() const throw() { return (channelNum < 0); } - inline ByteArray getSelectResponse() const { return selectResponse; } - inline SessionHelper *getSession() const { return session; } + inline ByteArray getSelectResponse() const throw() { return selectResponse; } + inline SessionHelper *getSession() const throw() { return session; } virtual int close(closeCallback callback, void *userParam) = 0; virtual int transmit(ByteArray command, transmitCallback callback, void *userData) = 0; - virtual void closeSync() = 0; - virtual int transmitSync(ByteArray command, ByteArray &result) = 0; + virtual void closeSync() + throw(ErrorIO &, ErrorIllegalState &) = 0; + + virtual int transmitSync(ByteArray command, ByteArray &result) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) = 0; }; } /* namespace smartcard_service_api */ diff --git a/common/include/Debug.h b/common/include/Debug.h index a7dc03f..7cba0dc 100644 --- a/common/include/Debug.h +++ b/common/include/Debug.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef DEBUG_H_ #define DEBUG_H_ diff --git a/common/include/DispatcherHelper.h b/common/include/DispatcherHelper.h index 647e3c5..2703f43 100644 --- a/common/include/DispatcherHelper.h +++ b/common/include/DispatcherHelper.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef DISPATCHERHELPER_H_ #define DISPATCHERHELPER_H_ diff --git a/common/include/DispatcherMsg.h b/common/include/DispatcherMsg.h index 534d549..69138ba 100644 --- a/common/include/DispatcherMsg.h +++ b/common/include/DispatcherMsg.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef DISPATCHERMSG_H_ #define DISPATCHERMSG_H_ diff --git a/common/include/EFDIR.h b/common/include/EFDIR.h new file mode 100644 index 0000000..c2fd9f1 --- /dev/null +++ b/common/include/EFDIR.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef EFDIR_H_ +#define EFDIR_H_ + +/* standard library header */ +#include + +/* SLP library header */ + +/* local header */ +#include "FileObject.h" + +using namespace std; + +namespace smartcard_service_api +{ + class EFDIR : public FileObject + { + private: + ByteArray parseRecord(Record &record, ByteArray &aid); + + public: + static const unsigned int EFDIR_FID = 0x002f; + + EFDIR(Channel *channel); + EFDIR(Channel *channel, ByteArray selectResponse); + ~EFDIR(); + + ByteArray getPathByAID(ByteArray &aid); + }; +} /* namespace smartcard_service_api */ +#endif /* EFDIR_H_ */ diff --git a/common/include/Exception.h b/common/include/Exception.h new file mode 100644 index 0000000..2ff91d8 --- /dev/null +++ b/common/include/Exception.h @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef EXCEPTION_H_ +#define EXCEPTION_H_ + +#include +#include + +#include "smartcard-types.h" + +namespace smartcard_service_api +{ + class ExceptionBase : public std::exception + { + protected : + int errorCode; + + public : + ExceptionBase(int errorCode) throw() + : errorCode(errorCode) {} + virtual ~ExceptionBase() throw() {} + + int getErrorCode() throw() { return errorCode; } + virtual const char *what() const throw() + { + return "Unknown exception"; + } + }; + + class ErrorIO : public ExceptionBase + { + private : + unsigned char sw[2]; + + public : + ErrorIO(int errorCode) throw() + : ExceptionBase(errorCode) {} + ErrorIO(int errorCode, unsigned char *sw) throw() + : ExceptionBase(errorCode) + { + if (sw != NULL) + { + this->sw[0] = sw[0]; + this->sw[1] = sw[1]; + } + } + virtual ~ErrorIO() throw() {} + + unsigned short getSW() throw() + { return (unsigned short)(sw[0] << 8 | sw[1]); } + unsigned char getSW1() throw() { return sw[0]; } + unsigned char getSW2() throw() { return sw[1]; } + + virtual const char *what() const throw() + { + const char *result = NULL; + + switch (errorCode) + { + case SCARD_ERROR_IPC_FAILED : + result = "Failed to communicate with server"; + break; + + case SCARD_ERROR_IO_FAILED : + result = "IO Operation failed"; + break; + + default : + result = ExceptionBase::what(); + break; + } + + return result; + } + }; + + class ErrorSecurity : public ExceptionBase + { + public : + ErrorSecurity(int errorCode) throw() + : ExceptionBase(errorCode) {} + virtual ~ErrorSecurity() throw() {} + + virtual const char *what() const throw() + { + const char *result = NULL; + + switch (errorCode) + { + case SCARD_ERROR_SECURITY_NOT_ALLOWED : + result = "Access denied"; + break; + + default : + result = ExceptionBase::what(); + break; + } + + return result; + } + }; + + class ErrorIllegalState : public ExceptionBase + { + public : + ErrorIllegalState(int errorCode) throw() + : ExceptionBase(errorCode) {} + virtual ~ErrorIllegalState() throw() {} + + virtual const char *what() const throw() + { + const char *result = NULL; + + switch (errorCode) + { + case SCARD_ERROR_UNAVAILABLE : + result = "Closed instance"; + break; + + case SCARD_ERROR_NOT_INITIALIZED : + result = "Need to initialize IPC"; + break; + + case SCARD_ERROR_SE_NOT_INITIALIZED : + result = "Need to initialize SE"; + break; + + default : + result = ExceptionBase::what(); + break; + } + + return result; + } + }; + + class ErrorIllegalParameter : public ExceptionBase + { + public : + ErrorIllegalParameter(int errorCode) throw() + : ExceptionBase(errorCode) {} + virtual ~ErrorIllegalParameter() throw() {} + + virtual const char *what() const throw() + { + const char *result = NULL; + + switch (errorCode) + { + case SCARD_ERROR_ILLEGAL_PARAM : + result = "Incorrect format of parameter"; + break; + + default : + result = ExceptionBase::what(); + break; + } + + return result; + } + }; +} /* namespace smartcard_service_api */ + +#endif /* EXCEPTIONBASE_H_ */ diff --git a/common/include/FCI.h b/common/include/FCI.h index 6f993a3..78917d0 100644 --- a/common/include/FCI.h +++ b/common/include/FCI.h @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef FCI_H_ #define FCI_H_ diff --git a/common/include/FileObject.h b/common/include/FileObject.h index 628eed0..ec9e90b 100644 --- a/common/include/FileObject.h +++ b/common/include/FileObject.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef FILEOBJECT_H_ #define FILEOBJECT_H_ @@ -56,10 +55,13 @@ namespace smartcard_service_api static const int ERROR_IO = -6; static const int ERROR_UNKNOWN = -99; + static const unsigned int MF_FID = 0x003F; + FileObject(Channel *channel); FileObject(Channel *channel, ByteArray selectResponse); ~FileObject(); + void close(); inline bool isClosed() { return (opened == false); } int select(ByteArray aid); int select(ByteArray path, bool fromCurrentDF); diff --git a/common/include/GPSEACL.h b/common/include/GPSEACL.h index c5ecd03..4e1bb8e 100644 --- a/common/include/GPSEACL.h +++ b/common/include/GPSEACL.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef GPSEACL_H_ #define GPSEACL_H_ diff --git a/common/include/IPCHelper.h b/common/include/IPCHelper.h index 1168058..de6e931 100644 --- a/common/include/IPCHelper.h +++ b/common/include/IPCHelper.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef IPCHELPER_H_ #define IPCHELPER_H_ diff --git a/common/include/ISO7816BERTLV.h b/common/include/ISO7816BERTLV.h index 75fc526..45340ec 100644 --- a/common/include/ISO7816BERTLV.h +++ b/common/include/ISO7816BERTLV.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef ISO7816BERTLV_H_ #define ISO7816BERTLV_H_ diff --git a/common/include/Lock.h b/common/include/Lock.h index f67a3df..4d9e0e4 100644 --- a/common/include/Lock.h +++ b/common/include/Lock.h @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef LOCK_H_ #define LOCK_H_ diff --git a/common/include/Message.h b/common/include/Message.h index 22bd531..a911800 100644 --- a/common/include/Message.h +++ b/common/include/Message.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef MESSAGE_H_ #define MESSAGE_H_ diff --git a/common/include/NumberStream.h b/common/include/NumberStream.h index eef1587..2df1185 100644 --- a/common/include/NumberStream.h +++ b/common/include/NumberStream.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef NUMBERSTREAM_H_ #define NUMBERSTREAM_H_ diff --git a/common/include/OpensslHelper.h b/common/include/OpensslHelper.h index 4f18a29..b914701 100644 --- a/common/include/OpensslHelper.h +++ b/common/include/OpensslHelper.h @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include diff --git a/common/include/PKCS15.h b/common/include/PKCS15.h index 0c07780..b761eba 100644 --- a/common/include/PKCS15.h +++ b/common/include/PKCS15.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef PKCS15_H_ #define PKCS15_H_ @@ -37,6 +36,8 @@ namespace smartcard_service_api map recordElement; PKCS15ODF *odf; + bool selectFromEFDIR(); + public: static ByteArray PKCS15_AID; diff --git a/common/include/PKCS15DODF.h b/common/include/PKCS15DODF.h index aa53551..3860b54 100644 --- a/common/include/PKCS15DODF.h +++ b/common/include/PKCS15DODF.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef PKCS15DODF_H_ #define PKCS15DODF_H_ diff --git a/common/include/PKCS15ODF.h b/common/include/PKCS15ODF.h index e1a17c9..3139959 100644 --- a/common/include/PKCS15ODF.h +++ b/common/include/PKCS15ODF.h @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef PKCS15ODF_H_ #define PKCS15ODF_H_ diff --git a/common/include/PKCS15OID.h b/common/include/PKCS15OID.h index a218ad4..86b1312 100644 --- a/common/include/PKCS15OID.h +++ b/common/include/PKCS15OID.h @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef PKCS15OID_H_ #define PKCS15OID_H_ diff --git a/common/include/PKCS15Object.h b/common/include/PKCS15Object.h index 2f8f9a1..8a0653e 100644 --- a/common/include/PKCS15Object.h +++ b/common/include/PKCS15Object.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef PKCS15OBJECT_H_ #define PKCS15OBJECT_H_ diff --git a/common/include/PKCS15Path.h b/common/include/PKCS15Path.h index 71dda37..c57dfe9 100644 --- a/common/include/PKCS15Path.h +++ b/common/include/PKCS15Path.h @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef PKCS15Path_H_ #define PKCS15Path_H_ diff --git a/common/include/PKCS15TokenInfo.h b/common/include/PKCS15TokenInfo.h index 62e748b..44a86f3 100644 --- a/common/include/PKCS15TokenInfo.h +++ b/common/include/PKCS15TokenInfo.h @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef PKCS15TOKENINFO_H_ #define PKCS15TOKENINFO_H_ diff --git a/common/include/ProviderHelper.h b/common/include/ProviderHelper.h index 1321ed2..ef6dab4 100644 --- a/common/include/ProviderHelper.h +++ b/common/include/ProviderHelper.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef PROVIDERHELPER_H_ #define PROVIDERHELPER_H_ diff --git a/common/include/ReaderHelper.h b/common/include/ReaderHelper.h index 84e5e7a..9a42d2b 100644 --- a/common/include/ReaderHelper.h +++ b/common/include/ReaderHelper.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef READERHELPER_H_ #define READERHELPER_H_ @@ -44,18 +43,19 @@ namespace smartcard_service_api bool present; ReaderHelper(); - - public: virtual ~ReaderHelper() {} + public: inline const char *getName() { return name; } inline SEServiceHelper *getSEService() { return seService; } inline bool isSecureElementPresent() { return present; } - virtual void closeSessions() = 0; + virtual void closeSessions() + throw(ErrorIO &, ErrorIllegalState &) = 0; virtual int openSession(openSessionCallback callback, void *userData) = 0; - virtual SessionHelper *openSessionSync() = 0; + virtual SessionHelper *openSessionSync() + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)= 0; }; } /* namespace smartcard_service_api */ diff --git a/common/include/Record.h b/common/include/Record.h index dcf79cb..0044d4d 100644 --- a/common/include/Record.h +++ b/common/include/Record.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef RECORD_H_ #define RECORD_H_ @@ -25,16 +24,17 @@ namespace smartcard_service_api class Record { private: - ByteArray data; unsigned int id; + ByteArray data; public: - Record(); - Record(unsigned int id, ByteArray buffer); - ~Record(); + Record() : id(0) {} + Record(unsigned int id, ByteArray buffer) + : id(id), data(buffer) {}; + ~Record() {} - unsigned int getID(); - int getData(ByteArray &buffer); + inline unsigned int getID() { return id; } + inline ByteArray getData() { return data; } }; } /* namespace smartcard_service_api */ diff --git a/common/include/SEServiceHelper.h b/common/include/SEServiceHelper.h index b39c2cb..f95270b 100644 --- a/common/include/SEServiceHelper.h +++ b/common/include/SEServiceHelper.h @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef SESERVICEHELPER_H_ #define SESERVICEHELPER_H_ diff --git a/common/include/Serializable.h b/common/include/Serializable.h index 8db4f4d..564f80d 100644 --- a/common/include/Serializable.h +++ b/common/include/Serializable.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef SERIALIZABLE_H_ #define SERIALIZABLE_H_ diff --git a/common/include/SessionHelper.h b/common/include/SessionHelper.h index 8a9e0f1..8599612 100644 --- a/common/include/SessionHelper.h +++ b/common/include/SessionHelper.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef SESSIONHELPER_H_ #define SESSIONHELPER_H_ @@ -51,10 +50,11 @@ namespace smartcard_service_api SessionHelper(ReaderHelper *reader); virtual ~SessionHelper() {} - ReaderHelper *getReader() { return reader; } - bool isClosed() { return closed; } + ReaderHelper *getReader() const throw() { return reader; } + bool isClosed() const throw() { return closed; } - virtual void closeChannels() = 0; + virtual void closeChannels() + throw(ErrorIO &, ErrorIllegalState &) = 0; virtual int getATR(getATRCallback callback, void *userData) = 0; virtual int close(closeSessionCallback callback, void *userData) = 0; @@ -64,13 +64,23 @@ namespace smartcard_service_api virtual int openLogicalChannel(ByteArray aid, openChannelCallback callback, void *userData) = 0; virtual int openLogicalChannel(unsigned char *aid, unsigned int length, openChannelCallback callback, void *userData) = 0; - virtual ByteArray getATRSync() = 0; - virtual void closeSync() = 0; + virtual ByteArray getATRSync() + throw(ErrorIO &, ErrorIllegalState &) = 0; + + virtual void closeSync() + throw(ErrorIO &, ErrorIllegalState &) = 0; + + virtual Channel *openBasicChannelSync(ByteArray aid) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) = 0; + + virtual Channel *openBasicChannelSync(unsigned char *aid, unsigned int length) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) = 0; + + virtual Channel *openLogicalChannelSync(ByteArray aid) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) = 0; - virtual Channel *openBasicChannelSync(ByteArray aid) = 0; - virtual Channel *openBasicChannelSync(unsigned char *aid, unsigned int length) = 0; - virtual Channel *openLogicalChannelSync(ByteArray aid) = 0; - virtual Channel *openLogicalChannelSync(unsigned char *aid, unsigned int length) = 0; + virtual Channel *openLogicalChannelSync(unsigned char *aid, unsigned int length) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) = 0; }; } /* namespace smartcard_service_api */ diff --git a/common/include/SignatureHelper.h b/common/include/SignatureHelper.h index 45fbaf9..d5abc22 100644 --- a/common/include/SignatureHelper.h +++ b/common/include/SignatureHelper.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef SIGNATUREHELPER_H_ #define SIGNATUREHELPER_H_ diff --git a/common/include/SimpleTLV.h b/common/include/SimpleTLV.h index bcaa743..a31d182 100644 --- a/common/include/SimpleTLV.h +++ b/common/include/SimpleTLV.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef SIMPLETLV_H_ #define SIMPLETLV_H_ diff --git a/common/include/Synchronous.h b/common/include/Synchronous.h index 4fa7ef8..479b902 100644 --- a/common/include/Synchronous.h +++ b/common/include/Synchronous.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef SYNCHRONOUS_H_ #define SYNCHRONOUS_H_ diff --git a/common/include/TLVHelper.h b/common/include/TLVHelper.h index 63f0a94..55e64ca 100644 --- a/common/include/TLVHelper.h +++ b/common/include/TLVHelper.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef TLVHELPER_H_ #define TLVHELPER_H_ diff --git a/common/include/Terminal.h b/common/include/Terminal.h index ad0ddff..dccc9bf 100644 --- a/common/include/Terminal.h +++ b/common/include/Terminal.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef TERMINAL_H_ #define TERMINAL_H_ diff --git a/common/include/TerminalInterface.h b/common/include/TerminalInterface.h index 15c6831..311b43a 100644 --- a/common/include/TerminalInterface.h +++ b/common/include/TerminalInterface.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef TERMINALINTERFACE_H_ #define TERMINALINTERFACE_H_ diff --git a/common/include/smartcard-types.h b/common/include/smartcard-types.h index 055756d..6b03bd0 100644 --- a/common/include/smartcard-types.h +++ b/common/include/smartcard-types.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef SMARTCARD_TYPES_H_ #define SMARTCARD_TYPES_H_ @@ -21,28 +20,33 @@ #include #include +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + enum { - SCARD_ERROR_OK = 0, + SCARD_ERROR_OK = 0, - SCARD_ERROR_NOT_INITIALIZED = -(0x10), + SCARD_ERROR_NOT_INITIALIZED = -(0x10), SCARD_ERROR_SE_NOT_INITIALIZED = -(0x11), SCARD_ERROR_OPERATION_NOT_SUPPORTED = -(0x12), - SCARD_ERROR_IPC_FAILED = -(0x13), - SCARD_ERROR_OUT_OF_MEMORY = -(0x14), + SCARD_ERROR_IPC_FAILED = -(0x13), + SCARD_ERROR_OUT_OF_MEMORY = -(0x14), SCARD_ERROR_NOT_ENOUGH_RESOURCE = -(0x15), SCARD_ERROR_OPERATION_TIMEOUT = -(0x16), SCARD_ERROR_NEED_MORE_BUFFER = -(0x17), - SCARD_ERROR_NOT_SUPPORTED = -(0x18), - SCARD_ERROR_UNAVAILABLE = -(0x19), + SCARD_ERROR_NOT_SUPPORTED = -(0x18), + SCARD_ERROR_UNAVAILABLE = -(0x19), - SCARD_ERROR_IO_FAILED = -(0x50), + SCARD_ERROR_IO_FAILED = -(0x50), SCARD_ERROR_SECURITY_NOT_ALLOWED = -(0x51), - SCARD_ERROR_ILLEGAL_STATE = -(0x52), - SCARD_ERROR_ILLEGAL_PARAM = -(0x53), + SCARD_ERROR_ILLEGAL_STATE = -(0x52), + SCARD_ERROR_ILLEGAL_PARAM = -(0x53), SCARD_ERROR_ILLEGAL_REFERENCE = -(0x54), - SCARD_ERROR_UNKNOWN = -(0x99), + SCARD_ERROR_UNKNOWN = -(0x99), }; typedef void *se_service_h; @@ -64,4 +68,8 @@ typedef void (*session_get_channel_count_cb)(unsigned count, int error, void *us typedef void (*channel_transmit_cb)(unsigned char *buffer, unsigned int length, int error, void *user_data); typedef void (*channel_close_cb)(int error, void *user_data); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + #endif /* SMARTCARD_TYPES_H_ */ diff --git a/packaging/smartcard-service.spec b/packaging/smartcard-service.spec index 66032cf..2a49cde 100644 --- a/packaging/smartcard-service.spec +++ b/packaging/smartcard-service.spec @@ -1,6 +1,6 @@ Name: smartcard-service Summary: Smartcard Service FW -Version: 0.1.11 +Version: 0.1.15 Release: 0 Group: libs License: Apache License, Version 2.0 @@ -11,11 +11,12 @@ Source0: %{name}-%{version}.tar.gz BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(security-server) BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(vconf) +BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(libssl) BuildRequires: pkgconfig(dbus-glib-1) BuildRequires: pkgconfig(pkgmgr) -BuildRequires: pkgconfig(vconf) -BuildRequires: pkgconfig(aul) +BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: cmake BuildRequires: gettext-tools diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 901d085..0814195 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -27,12 +27,12 @@ IF("${USE_AUTOSTART}" STREQUAL "1") ENDIF() SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} -pipe -fomit-frame-pointer -Wall -Wno-trigraphs -fno-strict-aliasing -Wl,-zdefs -fvisibility=hidden") -SET(ARM_CXXFLAGS "${ARM_CXXLAGS} -mapcs -mno-sched-prolog -mabi=aapcs-linux -Uarm -fno-common -fPIC") +SET(ARM_CXXFLAGS "${ARM_CXXLAGS} -mapcs -mno-sched-prolog -mabi=aapcs-linux -Uarm -fno-common -fpic") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS}") SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -pipe -fomit-frame-pointer -Wall -Wno-trigraphs -fno-strict-aliasing -Wl,-zdefs -fvisibility=hidden") -SET(ARM_CFLAGS "${ARM_CLAGS} -mapcs -mno-sched-prolog -mabi=aapcs-linux -Uarm -fno-common -fPIC") +SET(ARM_CFLAGS "${ARM_CLAGS} -mapcs -mno-sched-prolog -mabi=aapcs-linux -Uarm -fno-common -fpic") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") diff --git a/server/ClientInstance.cpp b/server/ClientInstance.cpp index 0dc84c4..6c141b9 100644 --- a/server/ClientInstance.cpp +++ b/server/ClientInstance.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include diff --git a/server/ServerChannel.cpp b/server/ServerChannel.cpp index 2bac293..d0f880a 100644 --- a/server/ServerChannel.cpp +++ b/server/ServerChannel.cpp @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ @@ -25,7 +25,9 @@ namespace smartcard_service_api { - ServerChannel::ServerChannel(ServerSession *session, void *caller, int channelNum, Terminal *terminal):Channel(session) + ServerChannel::ServerChannel(ServerSession *session, void *caller, + int channelNum, Terminal *terminal) + : Channel(session) { this->terminal = terminal; this->caller = caller; @@ -42,6 +44,7 @@ namespace smartcard_service_api } void ServerChannel::closeSync() + throw(ErrorIO &, ErrorIllegalState &) { ByteArray command, result; APDUHelper apdu; @@ -76,12 +79,14 @@ namespace smartcard_service_api } int ServerChannel::transmitSync(ByteArray command, ByteArray &result) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) { + int ret = -1; APDUCommand helper; if (isClosed() == true) { - return -1; + return ret; } helper.setCommand(command); @@ -89,7 +94,8 @@ namespace smartcard_service_api /* filter command */ if (privilege == false) { - if ((helper.getINS() == APDUCommand::INS_SELECT_FILE && helper.getP1() == APDUCommand::P1_SELECT_BY_DF_NAME) || + if ((helper.getINS() == APDUCommand::INS_SELECT_FILE && + helper.getP1() == APDUCommand::P1_SELECT_BY_DF_NAME) || (helper.getINS() == APDUCommand::INS_MANAGE_CHANNEL)) { return -4; /* security reason */ @@ -103,7 +109,15 @@ namespace smartcard_service_api SCARD_DEBUG("command [%d] : %s", command.getLength(), command.toString()); - return terminal->transmitSync(command, result); + ret = terminal->transmitSync(command, result); + if (ret == 0 && ResponseHelper::getStatus(result) == 0) + { + /* store select response */ + if (helper.getINS() == APDUCommand::INS_SELECT_FILE) + setSelectResponse(result); + } + + return ret; } } /* namespace smartcard_service_api */ diff --git a/server/ServerDispatcher.cpp b/server/ServerDispatcher.cpp index 0069c58..c502f8a 100644 --- a/server/ServerDispatcher.cpp +++ b/server/ServerDispatcher.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include @@ -87,6 +86,8 @@ namespace smartcard_service_api ByteArray info; ClientInstance *instance = NULL; + resource->loadSecureElements(); + if ((instance = resource->getClient(socket)) != NULL) { /* update client PID */ diff --git a/server/ServerIPC.cpp b/server/ServerIPC.cpp index fae1809..eb25f24 100644 --- a/server/ServerIPC.cpp +++ b/server/ServerIPC.cpp @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include @@ -245,7 +245,7 @@ ERROR : if (peerSocket >= 0) { - Message *msg = NULL; + Message *msg; /* read message */ if ((msg = retrieveMessage(peerSocket)) != NULL) diff --git a/server/ServerReader.cpp b/server/ServerReader.cpp index 2aace13..fa51f1a 100644 --- a/server/ServerReader.cpp +++ b/server/ServerReader.cpp @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include @@ -30,7 +30,8 @@ namespace smartcard_service_api { - ServerReader::ServerReader(ServerSEService *seService, char *name, Terminal *terminal):ReaderHelper() + ServerReader::ServerReader(ServerSEService *seService, char *name, Terminal *terminal) : + ReaderHelper() { unsigned int length = 0; @@ -76,6 +77,7 @@ namespace smartcard_service_api } void ServerReader::closeSessions() + throw(ErrorIO &, ErrorIllegalState &) { size_t i; @@ -108,14 +110,15 @@ namespace smartcard_service_api } ServerSession *ServerReader::openSessionSync() + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) { vector temp; return openSessionSync(temp, NULL); } - ServerSession *ServerReader::openSessionSync(vector &certHashes, void *caller) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) { ServerSession *session = NULL; diff --git a/server/ServerResource.cpp b/server/ServerResource.cpp index ab43d2b..064f765 100644 --- a/server/ServerResource.cpp +++ b/server/ServerResource.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include @@ -79,16 +78,14 @@ namespace smartcard_service_api #define OMAPI_SE_PATH "/usr/lib/se" - ServerResource::ServerResource() : mainLoop(NULL) + ServerResource::ServerResource() + : mainLoop(NULL), seLoaded(false) { SCARD_BEGIN(); serverIPC = ServerIPC::getInstance(); serverDispatcher = ServerDispatcher::getInstance(); -#if 1 - loadSecureElements(); -#endif SCARD_END(); } @@ -578,7 +575,7 @@ namespace smartcard_service_api channelNum = _openLogicalChannel(terminal); if (channelNum > 0) { - SCARD_DEBUG("channelNum [%d]", result); + SCARD_DEBUG("channelNum [%d]", channelNum); } else { @@ -608,30 +605,42 @@ namespace smartcard_service_api aid, service->getParent()->getCertificationHashes()) == true) { int rv = 0; - ByteArray command; - ByteArray response; /* select aid */ - command = APDUHelper::generateAPDU(APDUHelper::COMMAND_SELECT_BY_DF_NAME, channelNum, aid); - rv = channel->transmitSync(command, response); - if (rv == 0 && response.getLength() >= 2) + if (aid == PKCS15::PKCS15_AID) { - ResponseHelper resp(response); + PKCS15 pkcs15(channel); - if (resp.getStatus() == 0) + if (pkcs15.isClosed() == false) { - channel->selectResponse = response; /* remove privilege mode */ channel->unsetPrivilegeMode(); } else { - SCARD_DEBUG_ERR("status word [%d][ %02X %02X ]", resp.getStatus(), resp.getSW1(), resp.getSW2()); + SCARD_DEBUG_ERR("select failed"); + + service->closeChannel(result); + result = IntegerHandle::INVALID_HANDLE; } } else { - SCARD_DEBUG_ERR("select apdu is failed, rv [%d], length [%d]", rv, response.getLength()); + FileObject file(channel); + + rv = file.select(aid); + if (rv == FileObject::SUCCESS) + { + /* remove privilege mode */ + channel->unsetPrivilegeMode(); + } + else + { + SCARD_DEBUG_ERR("select failed [%d]", rv); + + service->closeChannel(result); + result = IntegerHandle::INVALID_HANDLE; + } } } else @@ -642,7 +651,6 @@ namespace smartcard_service_api result = IntegerHandle::INVALID_HANDLE; } - return result; } #endif @@ -843,39 +851,42 @@ namespace smartcard_service_api int ServerResource::loadSecureElements() { - int result; - void *libHandle; - DIR *dir = NULL; - struct dirent *entry = NULL; + int result = 0; - if ((dir = opendir(OMAPI_SE_PATH)) != NULL) + if (seLoaded == false) { - while ((entry = readdir(dir)) != NULL) + DIR *dir; + struct dirent *entry; + + if ((dir = opendir(OMAPI_SE_PATH)) != NULL) { - if (strncmp(entry->d_name, ".", 1) != 0 && strncmp(entry->d_name, "..", 2) != 0) + while ((entry = readdir(dir)) != NULL) { - char fullPath[1024] = { 0, }; - - /* TODO : need additional name rule :) */ + if (strncmp(entry->d_name, ".", 1) != 0 && + strncmp(entry->d_name, "..", 2) != 0) + { + char fullPath[1024]; - /* open each files */ - libHandle = NULL; + /* TODO : need additional name rule :) */ - snprintf(fullPath, sizeof(fullPath), "%s/%s", OMAPI_SE_PATH, entry->d_name); + /* append each files */ + snprintf(fullPath, sizeof(fullPath), + "%s/%s", OMAPI_SE_PATH, entry->d_name); - SCARD_DEBUG("se name [%s]", fullPath); + SCARD_DEBUG("se name [%s]", fullPath); - result = appendSELibrary(fullPath); + result = appendSELibrary(fullPath); + } } - } - closedir(dir); + closedir(dir); - result = 0; - } - else - { - result = -1; + seLoaded = true; + } + else + { + result = -1; + } } return result; @@ -883,25 +894,30 @@ namespace smartcard_service_api void ServerResource::unloadSecureElements() { - size_t i; - map::iterator item; - - for (item = mapTerminals.begin(); item != mapTerminals.end(); item++) + if (seLoaded == true) { - item->second->finalize(); + size_t i; + map::iterator item; - IntegerHandle::releaseHandle(item->first); - } + for (item = mapTerminals.begin(); item != mapTerminals.end(); item++) + { + item->second->finalize(); - mapTerminals.clear(); + IntegerHandle::releaseHandle(item->first); + } - for (i = 0; i < libraries.size(); i++) - { - if (libraries[i] != NULL) - dlclose(libraries[i]); - } + mapTerminals.clear(); - libraries.clear(); + for (i = 0; i < libraries.size(); i++) + { + if (libraries[i] != NULL) + dlclose(libraries[i]); + } + + libraries.clear(); + + seLoaded = false; + } } bool ServerResource::isValidReaderHandle(unsigned int reader) diff --git a/server/ServerSEService.cpp b/server/ServerSEService.cpp index 4b3b5bc..3ab859c 100644 --- a/server/ServerSEService.cpp +++ b/server/ServerSEService.cpp @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ @@ -345,47 +345,45 @@ namespace smartcard_service_api switch (event) { case Terminal::NOTIFY_SE_AVAILABLE : - { - /* add right se reader */ -// if ((term = ServerResource::getInstance().getTerminal((char *)terminal)) != NULL) -// { -// SCARD_DEBUG("terminal : [%s]", (char *)terminal); + /* add right se reader */ +// if ((term = ServerResource::getInstance().getTerminal((char *)terminal)) != NULL) +// { +// SCARD_DEBUG("terminal : [%s]", (char *)terminal); // -// term->initialize(); -// } -// else -// { -// SCARD_DEBUG("unknown terminal : [%s]", (char *)terminal); -// } - - /* send all client to refresh reader */ - msg.message = msg.MSG_NOTIFY_SE_INSERTED; - msg.data.setBuffer((unsigned char *)terminal, strlen((char *)terminal) + 1); - - ServerResource::getInstance().sendMessageToAllClients(msg); - } +// term->initialize(); +// } +// else +// { +// SCARD_DEBUG("unknown terminal : [%s]", (char *)terminal); +// } + + /* send all client to refresh reader */ + msg.message = msg.MSG_NOTIFY_SE_INSERTED; + msg.data.setBuffer((unsigned char *)terminal, + strlen((char *)terminal) + 1); + + ServerResource::getInstance().sendMessageToAllClients(msg); break; case Terminal::NOTIFY_SE_NOT_AVAILABLE : - { - /* remove right se reader */ -// if ((term = ServerResource::getInstance().getTerminal((char *)terminal)) != NULL) -// { -// SCARD_DEBUG("terminal : [%s]", (char *)terminal); + /* remove right se reader */ +// if ((term = ServerResource::getInstance().getTerminal((char *)terminal)) != NULL) +// { +// SCARD_DEBUG("terminal : [%s]", (char *)terminal); // -// term->finalize(); -// } -// else -// { -// SCARD_DEBUG("unknown terminal : [%s]", (char *)terminal); -// } - - /* send all client to refresh reader */ - msg.message = msg.MSG_NOTIFY_SE_REMOVED; - msg.data.setBuffer((unsigned char *)terminal, strlen((char *)terminal) + 1); - - ServerResource::getInstance().sendMessageToAllClients(msg); - } +// term->finalize(); +// } +// else +// { +// SCARD_DEBUG("unknown terminal : [%s]", (char *)terminal); +// } + + /* send all client to refresh reader */ + msg.message = msg.MSG_NOTIFY_SE_REMOVED; + msg.data.setBuffer((unsigned char *)terminal, + strlen((char *)terminal) + 1); + + ServerResource::getInstance().sendMessageToAllClients(msg); break; default : diff --git a/server/ServerSession.cpp b/server/ServerSession.cpp index da1e044..1fe84d3 100644 --- a/server/ServerSession.cpp +++ b/server/ServerSession.cpp @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include @@ -54,12 +54,14 @@ namespace smartcard_service_api } ByteArray ServerSession::getATRSync() + throw(ErrorIO &, ErrorIllegalState &) { /* call get atr to terminal */ return atr; } void ServerSession::closeSync() + throw(ErrorIO &, ErrorIllegalState &) { if (isClosed() == false) { @@ -69,6 +71,7 @@ namespace smartcard_service_api } void ServerSession::closeChannels() + throw(ErrorIO &, ErrorIllegalState &) { size_t i; @@ -82,11 +85,13 @@ namespace smartcard_service_api } Channel *ServerSession::openBasicChannelSync(ByteArray aid) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) { return openBasicChannelSync(aid, NULL); } Channel *ServerSession::openBasicChannelSync(ByteArray aid, void *caller) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) { ServerChannel *channel = NULL; #if 0 @@ -147,21 +152,25 @@ namespace smartcard_service_api } Channel *ServerSession::openBasicChannelSync(unsigned char *aid, unsigned int length) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) { return openBasicChannelSync(ByteArray(aid, length)); } Channel *ServerSession::openBasicChannelSync(unsigned char *aid, unsigned int length, void *caller) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) { return openBasicChannelSync(ByteArray(aid, length), caller); } Channel *ServerSession::openLogicalChannelSync(ByteArray aid) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) { return openLogicalChannelSync(aid, NULL); } Channel *ServerSession::openLogicalChannelSync(ByteArray aid, void *caller) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) { ServerChannel *channel = NULL; #if 0 @@ -247,11 +256,13 @@ namespace smartcard_service_api } Channel *ServerSession::openLogicalChannelSync(unsigned char *aid, unsigned int length) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) { return openLogicalChannelSync(ByteArray(aid, length), NULL); } Channel *ServerSession::openLogicalChannelSync(unsigned char *aid, unsigned int length, void *caller) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) { return openLogicalChannelSync(ByteArray(aid, length), caller); } diff --git a/server/ServiceInstance.cpp b/server/ServiceInstance.cpp index 3643311..94979dd 100644 --- a/server/ServiceInstance.cpp +++ b/server/ServiceInstance.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ diff --git a/server/include/ClientInstance.h b/server/include/ClientInstance.h index 666d4b7..9787ed7 100644 --- a/server/include/ClientInstance.h +++ b/server/include/ClientInstance.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef CLIENTINSTANCE_H_ #define CLIENTINSTANCE_H_ diff --git a/server/include/ServerChannel.h b/server/include/ServerChannel.h index bcb8bd6..aecef89 100644 --- a/server/include/ServerChannel.h +++ b/server/include/ServerChannel.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef SERVERCHANNEL_H_ #define SERVERCHANNEL_H_ @@ -41,8 +40,10 @@ namespace smartcard_service_api void unsetPrivilegeMode() { this->privilege = false; } protected: - void closeSync(); - int transmitSync(ByteArray command, ByteArray &result); + void closeSync() + throw(ErrorIO &, ErrorIllegalState &); + int transmitSync(ByteArray command, ByteArray &result) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &); public: ~ServerChannel(); diff --git a/server/include/ServerDispatcher.h b/server/include/ServerDispatcher.h index 7f3f9a8..785860f 100644 --- a/server/include/ServerDispatcher.h +++ b/server/include/ServerDispatcher.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef SERVERDISPATCHER_H_ #define SERVERDISPATCHER_H_ diff --git a/server/include/ServerIPC.h b/server/include/ServerIPC.h index c1b6556..a1f7b70 100644 --- a/server/include/ServerIPC.h +++ b/server/include/ServerIPC.h @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef SERVERIPC_H_ #define SERVERIPC_H_ diff --git a/server/include/ServerReader.h b/server/include/ServerReader.h index 523300f..307473a 100644 --- a/server/include/ServerReader.h +++ b/server/include/ServerReader.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef SERVERREADER_H_ #define SERVERREADER_H_ @@ -44,19 +43,21 @@ namespace smartcard_service_api AccessControlList *acList; ServerReader(ServerSEService *seService, char *name, Terminal *terminal); + ~ServerReader(); int openSession(openSessionCallback callback, void *userData) { return -1; } int openSession(void *caller, openSessionCallback callback, void *userData) { return -1; } public: - ~ServerReader(); - - void closeSessions(); + void closeSessions() + throw(ErrorIO &, ErrorIllegalState &); AccessControlList *getAccessControlList(); - ServerSession *openSessionSync(); - ServerSession *openSessionSync(vector &certHashes, void *caller); + ServerSession *openSessionSync() + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &); + ServerSession *openSessionSync(vector &certHashes, void *caller) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &); friend class ServerSEService; }; diff --git a/server/include/ServerResource.h b/server/include/ServerResource.h index f30b9f5..0f345d8 100644 --- a/server/include/ServerResource.h +++ b/server/include/ServerResource.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef SERVERRESOURCE_H_ #define SERVERRESOURCE_H_ @@ -70,6 +69,7 @@ namespace smartcard_service_api void *mainLoop; ServerIPC *serverIPC; ServerDispatcher *serverDispatcher; + bool seLoaded; ServerResource(); ~ServerResource(); diff --git a/server/include/ServerSEService.h b/server/include/ServerSEService.h index 1ae9301..7e459c1 100644 --- a/server/include/ServerSEService.h +++ b/server/include/ServerSEService.h @@ -1,18 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef SERVERSESERVICE_H_ #define SERVERSESERVICE_H_ diff --git a/server/include/ServerSession.h b/server/include/ServerSession.h index 45b6368..eb0767b 100644 --- a/server/include/ServerSession.h +++ b/server/include/ServerSession.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef SERVERSESSION_H_ #define SERVERSESSION_H_ @@ -55,20 +54,31 @@ namespace smartcard_service_api public: ~ServerSession(); - ByteArray getATRSync(); - void closeSync(); - - void closeChannels(); - - Channel *openBasicChannelSync(ByteArray aid); - Channel *openBasicChannelSync(unsigned char *aid, unsigned int length); - Channel *openBasicChannelSync(ByteArray aid, void *caller); - Channel *openBasicChannelSync(unsigned char *aid, unsigned int length, void *caller); - - Channel *openLogicalChannelSync(ByteArray aid); - Channel *openLogicalChannelSync(unsigned char *aid, unsigned int length); - Channel *openLogicalChannelSync(ByteArray aid, void *caller); - Channel *openLogicalChannelSync(unsigned char *aid, unsigned int length, void *caller); + ByteArray getATRSync() + throw(ErrorIO &, ErrorIllegalState &); + void closeSync() + throw(ErrorIO &, ErrorIllegalState &); + + void closeChannels() + throw(ErrorIO &, ErrorIllegalState &); + + Channel *openBasicChannelSync(ByteArray aid) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &); + Channel *openBasicChannelSync(unsigned char *aid, unsigned int length) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &); + Channel *openBasicChannelSync(ByteArray aid, void *caller) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &); + Channel *openBasicChannelSync(unsigned char *aid, unsigned int length, void *caller) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &); + + Channel *openLogicalChannelSync(ByteArray aid) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &); + Channel *openLogicalChannelSync(unsigned char *aid, unsigned int length) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &); + Channel *openLogicalChannelSync(ByteArray aid, void *caller) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &); + Channel *openLogicalChannelSync(unsigned char *aid, unsigned int length, void *caller) + throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &); friend class ServerReader; friend class ServerResource; diff --git a/server/include/ServiceInstance.h b/server/include/ServiceInstance.h index 277ae4e..51f7a77 100644 --- a/server/include/ServiceInstance.h +++ b/server/include/ServiceInstance.h @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #ifndef SERVICEINSTANCE_H_ #define SERVICEINSTANCE_H_ diff --git a/server/smartcard-daemon.cpp b/server/smartcard-daemon.cpp index 595b8dc..4309bab 100644 --- a/server/smartcard-daemon.cpp +++ b/server/smartcard-daemon.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /* standard library header */ #include @@ -234,5 +233,8 @@ int main() #ifdef USE_AUTOSTART _finalize_dbus(); #endif + /* release secure element.. (pure virtual function problem..) */ + ServerResource::getInstance().unloadSecureElements(); + return 0; } diff --git a/smartcard-service-server.manifest b/smartcard-service-server.manifest index 5a301a4..1dcbee0 100644 --- a/smartcard-service-server.manifest +++ b/smartcard-service-server.manifest @@ -1,6 +1,9 @@ + + + diff --git a/test-client/CMakeLists.txt b/test-client/CMakeLists.txt index 0fc3b91..42b40b7 100644 --- a/test-client/CMakeLists.txt +++ b/test-client/CMakeLists.txt @@ -26,7 +26,7 @@ MESSAGE("CHECK MODULE in ${PROJECT_NAME} ${pkgs_test_client_LDFLAGS}") # this for NFC flag SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} -pipe -fomit-frame-pointer -Wall -Wno-trigraphs -fno-strict-aliasing -Wl,-zdefs -fvisibility=hidden") -SET(ARM_CXXFLAGS "${ARM_CXXLAGS} -mapcs -mno-sched-prolog -mabi=aapcs-linux -Uarm -fno-common -fPIC") +SET(ARM_CXXFLAGS "${ARM_CXXLAGS} -mapcs -mno-sched-prolog -mabi=aapcs-linux -Uarm -fno-common -fpic") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS}") SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") diff --git a/test-client/test-client-sync.cpp b/test-client/test-client-sync.cpp index f95b26e..69bb32e 100644 --- a/test-client/test-client-sync.cpp +++ b/test-client/test-client-sync.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #include #include diff --git a/test-client/test-client.cpp b/test-client/test-client.cpp index e7a579f..1f6c14f 100644 --- a/test-client/test-client.cpp +++ b/test-client/test-client.cpp @@ -1,19 +1,18 @@ /* -* Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - + * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ #include #include -- 2.7.4