CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(smartcard-service CXX C)
MESSAGE("build smartcard-service")
-IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
- SET(CMAKE_BUILD_TYPE "Release")
-ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+SET(CMAKE_VERBOSE_MAKEFILE OFF)
-MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
-
-INCLUDE(FindPkgConfig)
-
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
-
-SET(CMAKE_SHARED_LINKER_FLAGS " -Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
-SET(CMAKE_EXE_LINKER_FLAGS " -Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
-
-FIND_PROGRAM(UNAME NAMES uname)
-EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
-IF("${ARCH}" MATCHES "^arm.*")
- ADD_DEFINITIONS("-DTARGET")
- MESSAGE("add -DTARGET")
- SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mabi=aapcs-linux -fno-common")
-ENDIF("${ARCH}" MATCHES "^arm.*")
-
-# names
-SET(CLIENT_LIB ${PROJECT_NAME})
-SET(COMMON_LIB "smartcard-service-common")
-SET(DAEMON "smartcard-daemon")
-
-# For *.pc files
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+# apply smack
+ADD_DEFINITIONS("-DUSER_SPACE_SMACK")
-# Defines
IF(DEFINED USE_AUTOSTART)
ADD_DEFINITIONS("-DUSE_AUTOSTART")
ENDIF()
-# apply smack
-##ADD_DEFINITIONS("-DUSER_SPACE_SMACK")
+# make string from entire content of byte array
+ADD_DEFINITIONS("-DTO_STRING_ALL")
+
+SET(GC_SECTIONS_FLAGS "-fdata-sections -ffunction-sections -Wl,--gc-sections")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GC_SECTIONS_FLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GC_SECTIONS_FLAGS}")
+
+FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
+EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
+ " \\
+ --generate-c-code ${CMAKE_CURRENT_SOURCE_DIR}/common/smartcard-service-gdbus \\
+ --c-namespace SmartcardService\\
+ --interface-prefix org.tizen.SmartcardService. \\
+ ${CMAKE_CURRENT_SOURCE_DIR}/common/smartcard-service-gdbus.xml \\
+ ")
ADD_SUBDIRECTORY(common)
ADD_SUBDIRECTORY(client)
-INCLUDE_DIRECTORIES(include)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common/include)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/server/include)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(smartcard-service CXX)
+
+SET(LIB_NAME "smartcard-service")
+SET(VERSION_MAJOR 1)
+SET(VERSION ${VERSION_MAJOR}.0.0)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../common)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../common/include)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../server/include)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SRCS)
-pkg_check_modules(pkgs_client REQUIRED glib-2.0 dlog)
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+ SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+# pkg config
+INCLUDE(FindPkgConfig)
+
+SET(PKG_MODULE glib-2.0 dlog)
+
+pkg_check_modules(pkgs_client REQUIRED ${PKG_MODULE})
+
+MESSAGE("${LIB_NAME} ld flag : ${pkgs_client_LDFLAGS}")
+
FOREACH(flag ${pkgs_client_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS}")
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -finstrument-functions -fPIC")
+#SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+#SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS} -finstrument-functions -std=c++0x")
+#SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+#SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+ ADD_DEFINITIONS("-DTARGET")
+ MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+MESSAGE("CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DSLP_DEBUG")
ADD_DEFINITIONS("-DLOG_TAG=\"SMARTCARD_SERVICE_CLIENT\"")
-ADD_LIBRARY(${CLIENT_LIB} SHARED ${SRCS})
-SET_TARGET_PROPERTIES(${CLIENT_LIB} PROPERTIES VERSION ${FULLVER} SOVERSION ${MAJORVER})
-TARGET_LINK_LIBRARIES(${CLIENT_LIB} ${pkgs_client_LDFLAGS})
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
-SET(EXPORT_HEADER
+SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES VERSION ${VERSION})
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_client_LDFLAGS})
+
+SET(EXPORT_HEADER
../common/include/smartcard-types.h
../common/include/ByteArray.h
../common/include/Debug.h
# include/
)
-CONFIGURE_FILE(${CLIENT_LIB}.pc.in ${CLIENT_LIB}.pc @ONLY)
-
-INSTALL(FILES ${CLIENT_LIB}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-INSTALL(TARGETS ${CLIENT_LIB} DESTINATION ${LIB_INSTALL_DIR})
-
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR})
FOREACH(hfile ${EXPORT_HEADER})
- INSTALL(FILES ${hfile} DESTINATION include/${CLIENT_LIB})
+ INSTALL(FILES ${hfile} DESTINATION include/${LIB_NAME})
ENDFOREACH(hfile)
* limitations under the License.
*/
+/* standard library header */
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <glib.h>
+/* SLP library header */
+
+/* local header */
#include "Debug.h"
#include "ClientChannel.h"
#include "ReaderHelper.h"
gint ret;
GError *error = NULL;
+
if (proxy == NULL) {
_ERR("dbus proxy is not initialized yet");
throw ErrorIllegalState(SCARD_ERROR_NOT_INITIALIZED);
GPOINTER_TO_UINT(context),
GPOINTER_TO_UINT(handle),
&ret, NULL, &error) == true) {
- if (ret != SCARD_ERROR_OK) {
+ if (ret == SCARD_ERROR_OK) {
+ channelNum = -1;
+ } else {
_ERR("smartcard_service_channel_call_close_channel_sync failed, [%d]", ret);
THROW_ERROR(ret);
}
NULL, &error) == true) {
if (rv == SCARD_ERROR_OK) {
- GDBusHelper::convertVariantToByteArray(var_response, result);
+ GDBusHelper::convertVariantToByteArray(var_response, transmitResponse);
+ result = transmitResponse;
} else {
- _ERR("smartcard_service_session_call_get_atr_sync failed, [%d]", rv);
+ _ERR("smartcard_service_session_call_transmit failed, [%d]", rv);
THROW_ERROR(rv);
}
} else {
- _ERR("smartcard_service_session_call_get_atr_sync failed, [%s]", error->message);
+ _ERR("smartcard_service_session_call_transmit failed, [%s]", error->message);
g_error_free(error);
throw ErrorIO(SCARD_ERROR_IPC_FAILED);
using namespace smartcard_service_api;
-EXTERN_API int channel_close(channel_h handle, channel_close_cb callback, void *userParam)
+EXTERN_API int channel_close_sync(channel_h handle)
{
- int result = -1;
+ int result = SCARD_ERROR_OK;
CHANNEL_EXTERN_BEGIN;
- result = channel->close((closeChannelCallback)callback, userParam);
+
+ try
+ {
+ channel->closeSync();
+ }
+ catch (ExceptionBase &e)
+ {
+ _ERR("Error occur : %s\n", e.what());
+ result = e.getErrorCode();
+ }
+ catch (...)
+ {
+ _ERR("Error occur : unknown error\n");
+ result = SCARD_ERROR_UNKNOWN;
+ }
+
CHANNEL_EXTERN_END;
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_sync(channel_h handle, unsigned char *command,
+ unsigned int cmd_len, unsigned char **response, unsigned int *resp_len)
{
- int result = -1;
+ int result = SCARD_ERROR_OK;
+
+ if (command == NULL || cmd_len == 0 || response == NULL || resp_len == NULL)
+ return SCARD_ERROR_UNKNOWN;
CHANNEL_EXTERN_BEGIN;
- ByteArray temp;
- temp.assign(command, length);
- result = channel->transmit(temp, (transmitCallback)callback, userParam);
+ try
+ {
+ ByteArray temp, resp;
+
+ temp.assign(command, cmd_len);
+ channel->transmitSync(temp, resp);
+
+ if (resp.size() > 0)
+ {
+ *response = (unsigned char *)calloc(resp.size(), sizeof(unsigned char));
+ *resp_len = resp.size();
+ memcpy(*response, resp.getBuffer(), *resp_len);
+ }
+ }
+ catch (ExceptionBase &e)
+ {
+ _ERR("Error occur : %s\n", e.what());
+ result = e.getErrorCode();
+ *resp_len = 0;
+ }
+ catch (...)
+ {
+ _ERR("Error occur : unknown error\n");
+ result = SCARD_ERROR_UNKNOWN;
+ *resp_len = 0;
+ }
+
CHANNEL_EXTERN_END;
return result;
}
-EXTERN_API void channel_close_sync(channel_h handle)
+EXTERN_API int channel_is_basic_channel(channel_h handle, bool* is_basic_channel)
{
+ int result = SCARD_ERROR_OK;
+
CHANNEL_EXTERN_BEGIN;
+
try
{
- channel->closeSync();
+ *is_basic_channel = channel->isBasicChannel();
+ }
+ catch (ExceptionBase &e)
+ {
+ _ERR("Error occur : %s\n", e.what());
+ result = e.getErrorCode();
}
catch (...)
{
+ _ERR("Error occur : unknown error\n");
+ result = SCARD_ERROR_UNKNOWN;
}
+
CHANNEL_EXTERN_END;
+
+ return result;
}
-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_is_closed(channel_h handle, bool* is_closed)
{
- int result = -1;
+ int result = SCARD_ERROR_OK;
- if (command == NULL || cmd_len == 0 || response == NULL || resp_len == NULL)
- return result;
+ CHANNEL_EXTERN_BEGIN;
+
+ try
+ {
+ *is_closed = channel->isClosed();
+ }
+ catch (ExceptionBase &e)
+ {
+ _ERR("Error occur : %s\n", e.what());
+ result = e.getErrorCode();
+ }
+ catch (...)
+ {
+ _ERR("Error occur : unknown error\n");
+ result = SCARD_ERROR_UNKNOWN;
+ }
+
+ CHANNEL_EXTERN_END;
+
+ return result;
+}
+
+EXTERN_API int channel_get_select_response(channel_h handle,
+ unsigned char **buffer, size_t *length)
+{
+ int result = SCARD_ERROR_OK;
CHANNEL_EXTERN_BEGIN;
- ByteArray temp, resp;
- temp.assign(command, cmd_len);
+ try
+ {
+ ByteArray response = channel->getSelectResponse();
+ uint8_t* get_buffer = response.getBuffer();
+
+ *length = response.size();
+
+ if (*length > 0)
+ {
+ *buffer = (unsigned char *)calloc(*length, sizeof(unsigned char));
+ if(*buffer == NULL || get_buffer == NULL)
+ {
+ *length = 0;
+ return SCARD_ERROR_NOT_ENOUGH_RESOURCE;
+ }
+
+ memcpy(*buffer, get_buffer, *length);
+ }
+ }
+ catch (ExceptionBase &e)
+ {
+ _ERR("Error occur : %s\n", e.what());
+ result = e.getErrorCode();
+ *length = 0;
+ }
+ catch (...)
+ {
+ _ERR("Error occur : unknown error\n");
+ result = SCARD_ERROR_UNKNOWN;
+ *length = 0;
+ }
+
+ CHANNEL_EXTERN_END;
+
+ return result;
+}
+
+EXTERN_API int channel_get_transmit_response(channel_h handle,
+ unsigned char **buffer, size_t *length)
+{
+ int result = SCARD_ERROR_OK;
+
+ CHANNEL_EXTERN_BEGIN;
try
{
- result = channel->transmitSync(temp, resp);
- if (resp.size() > 0)
+ ByteArray response;
+
+ response = channel->getTransmitResponse();
+
+ *length = response.size();
+
+ if (*length > 0)
{
- *resp_len = resp.size();
- *response = (unsigned char *)calloc(1, *resp_len);
- memcpy(*response, resp.getBuffer(), *resp_len);
+ *buffer = (unsigned char *)calloc(*length, sizeof(unsigned char));
+ memcpy(*buffer, response.getBuffer(), *length);
}
}
+ catch (ExceptionBase &e)
+ {
+ _ERR("Error occur : %s\n", e.what());
+ result = e.getErrorCode();
+ *length = 0;
+ }
catch (...)
{
- result = -1;
+ _ERR("Error occur : unknown error\n");
+ result = SCARD_ERROR_UNKNOWN;
+ *length = 0;
}
+
CHANNEL_EXTERN_END;
return result;
}
-EXTERN_API bool channel_is_basic_channel(channel_h handle)
+EXTERN_API int channel_get_session(channel_h handle, int *session_handle)
{
- bool result = false;
+ int result = SCARD_ERROR_OK;
+ session_h session = NULL;
CHANNEL_EXTERN_BEGIN;
- result = channel->isBasicChannel();
+
+ try
+ {
+ session = channel->getSession();
+ //*session_handle = (int)session;
+ }
+ catch (ExceptionBase &e)
+ {
+ _ERR("Error occur : %s\n", e.what());
+ result = e.getErrorCode();
+ }
+ catch (...)
+ {
+ _ERR("Error occur : unknown error\n");
+ result = SCARD_ERROR_UNKNOWN;
+ }
+
CHANNEL_EXTERN_END;
return result;
}
-EXTERN_API bool channel_is_closed(channel_h handle)
+EXTERN_API int channel_select_next(channel_h handle, bool *pSuccess)
{
- bool result = false;
+ int result = SCARD_ERROR_OK;
CHANNEL_EXTERN_BEGIN;
- result = channel->isClosed();
+
+ try
+ {
+ *pSuccess = channel->selectNext();
+ }
+ catch (ExceptionBase &e)
+ {
+ _ERR("Error occur : %s\n", e.what());
+ result = e.getErrorCode();
+ }
+ catch (...)
+ {
+ _ERR("Error occur : unknown error\n");
+ result = SCARD_ERROR_UNKNOWN;
+ }
+
CHANNEL_EXTERN_END;
return result;
return result;
}
-EXTERN_API bool channel_get_select_response(channel_h handle,
- unsigned char *buffer, unsigned int length)
+EXTERN_API int channel_close(channel_h handle, channel_close_cb callback, void *userParam)
{
- bool result = false;
-
- if (buffer == NULL || length == 0)
- {
- return result;
- }
+ int result = -1;
CHANNEL_EXTERN_BEGIN;
- ByteArray response;
-
- response = channel->getSelectResponse();
- if (response.size() > 0)
- {
- memcpy(buffer, response.getBuffer(), MIN(length, response.size()));
- result = true;
- }
+ result = channel->close((closeChannelCallback)callback, userParam);
CHANNEL_EXTERN_END;
return result;
}
-EXTERN_API session_h channel_get_session(channel_h handle)
+EXTERN_API int channel_transmit(channel_h handle, unsigned char *command,
+ unsigned int length, channel_transmit_cb callback, void *userParam)
{
- session_h session = NULL;
+ int result = -1;
CHANNEL_EXTERN_BEGIN;
- session = channel->getSession();
+ ByteArray temp;
+
+ temp.assign(command, length);
+ result = channel->transmit(temp, (transmitCallback)callback, userParam);
CHANNEL_EXTERN_END;
- return session;
+ return result;
}
EXTERN_API void channel_destroy_instance(channel_h handle)
* limitations under the License.
*/
+/* standard library header */
#include <glib.h>
+/* SLP library header */
+
+/* local header */
#include "smartcard-types.h"
#include "Debug.h"
#include "ByteArray.h"
using namespace std;
+/* below functions will be called when dlopen or dlclose is called */
+void __attribute__ ((constructor)) lib_init()
+{
+ g_type_init();
+}
+
+void __attribute__ ((destructor)) lib_fini()
+{
+}
+
namespace smartcard_service_api
{
} /* namespace smartcard_service_api */
* limitations under the License.
*/
+/* standard library header */
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+/* SLP library header */
+
+/* local header */
#include "Debug.h"
#include "Reader.h"
#include "Session.h"
using namespace smartcard_service_api;
-EXTERN_API const char *reader_get_name(reader_h handle)
+EXTERN_API int reader_get_name(reader_h handle, char** reader_name)
{
- const char *name = NULL;
+ int result = SCARD_ERROR_OK;
READER_EXTERN_BEGIN;
- name = reader->getName();
+
+ try
+ {
+ *reader_name = g_strdup(reader->getName());
+ }
+ catch (ExceptionBase &e)
+ {
+ _ERR("Error occur : %s\n", e.what());
+ result = e.getErrorCode();
+ }
+ catch (...)
+ {
+ _ERR("Error occur : unknown error\n");
+ result = SCARD_ERROR_UNKNOWN;
+ }
+
READER_EXTERN_END;
- return name;
+ return result;
}
-EXTERN_API se_service_h reader_get_se_service(reader_h handle)
+EXTERN_API int reader_is_secure_element_present(reader_h handle, bool* is_present)
{
- se_service_h service = NULL;
+ int result = SCARD_ERROR_OK;
READER_EXTERN_BEGIN;
- service = (se_service_h)reader->getSEService();
+
+ try
+ {
+ *is_present = reader->isSecureElementPresent();
+ }
+ catch (...)
+ {
+ _ERR("Error occur : unknown error\n");
+ result = SCARD_ERROR_UNKNOWN;
+ }
+
READER_EXTERN_END;
- return service;
+ return result;
}
-EXTERN_API bool reader_is_secure_element_present(reader_h handle)
+EXTERN_API int reader_open_session_sync(reader_h handle, int *session_handle)
{
- bool result = false;
+ session_h session;
+ int result = SCARD_ERROR_OK;
READER_EXTERN_BEGIN;
- result = reader->isSecureElementPresent();
+
+ try
+ {
+ session = (session_h)reader->openSessionSync();
+ //*session_handle = (int)session;
+ }
+ catch (ExceptionBase &e)
+ {
+ _ERR("Error occur : %s\n", e.what());
+ result = e.getErrorCode();
+ *session_handle = 0;
+ }
+ catch (...)
+ {
+ _ERR("Error occur : unknown error\n");
+ result = SCARD_ERROR_UNKNOWN;
+ *session_handle = 0;
+ }
+
READER_EXTERN_END;
return result;
}
-EXTERN_API int reader_open_session(reader_h handle, reader_open_session_cb callback, void *userData)
+EXTERN_API int reader_close_sessions(reader_h handle)
{
- int result = -1;
+ int result = SCARD_ERROR_OK;
READER_EXTERN_BEGIN;
- result = reader->openSession((openSessionCallback)callback, userData);
+
+ try
+ {
+ reader->closeSessions();
+ }
+ catch (ExceptionBase &e)
+ {
+ _ERR("Error occur : %s\n", e.what());
+ result = e.getErrorCode();
+ }
+ catch (...)
+ {
+ _ERR("Error occur : unknown error\n");
+ result = SCARD_ERROR_UNKNOWN;
+ }
+
READER_EXTERN_END;
return result;
}
-EXTERN_API session_h reader_open_session_sync(reader_h handle)
+
+EXTERN_API se_service_h reader_get_se_service(reader_h handle)
{
- session_h result = NULL;
+ se_service_h service = NULL;
READER_EXTERN_BEGIN;
- result = (session_h)reader->openSessionSync();
+ service = (se_service_h)reader->getSEService();
READER_EXTERN_END;
- return result;
+ return service;
}
-EXTERN_API void reader_close_sessions(reader_h handle)
+EXTERN_API int reader_open_session(reader_h handle, reader_open_session_cb callback, void *userData)
{
+ int result = -1;
+
READER_EXTERN_BEGIN;
- reader->closeSessions();
+ result = reader->openSession((openSessionCallback)callback, userData);
READER_EXTERN_END;
+
+ return result;
}
EXTERN_API void reader_destroy_instance(reader_h handle)
#include <glib.h>
#include <glib-object.h>
-/* SLP library header */
-
/* local header */
#include "Debug.h"
#include "SEService.h"
+#include "ClientChannel.h"
#include "Reader.h"
#include "ClientGDBus.h"
#endif
#define SHUTDOWN_DELAY 500000 /* us */
+#define VERSION "3.0"
namespace smartcard_service_api
{
SEService::SEService() : SEServiceHelper(),
- handle(-1), context(NULL), handler(NULL), listener(NULL)
+ handle(-1), context(NULL), handler(NULL), listener(NULL),
+ version(VERSION)
{
proxy = NULL;
}
SEService::SEService(void *user_data, serviceConnected handler)
throw(ErrorIO &, ErrorIllegalParameter &) :
SEServiceHelper(), handle(-1),
- listener(NULL)
+ listener(NULL), version(VERSION)
{
initialize(user_data, handler);
}
SEService::SEService(void *user_data, SEServiceListener *listener)
throw(ErrorIO &, ErrorIllegalParameter &) :
SEServiceHelper(), handle(-1),
- handler(NULL)
+ handler(NULL), version(VERSION)
{
initialize(user_data, listener);
}
- SEService::~SEService()
+ SEService::SEService(void *user_data)
+ throw(ErrorIO &, ErrorIllegalParameter &, ExceptionBase &) :
+ SEServiceHelper(), handle(-1),
+ handler(NULL), version(VERSION)
{
- uint32_t i;
+ initializeSync(user_data);
+ }
+ SEService::~SEService()
+ {
try
{
+ size_t i;
+
shutdownSync();
+
+ for (i = 0; i < readers.size(); i++)
+ {
+ delete (Reader *)readers[i];
+ }
+
+ readers.clear();
}
- catch(ExceptionBase &e)
+ catch (ExceptionBase &e)
{
_ERR("EXCEPTION : %s", e.what());
}
- catch(...)
+ catch (...)
{
_ERR("EXCEPTION!!!");
}
-
- for (i = 0; i < readers.size(); i++)
- {
- delete (Reader *)readers[i];
- }
- readers.clear();
}
SEService *SEService::createInstance(void *user_data,
return result;
}
+ int SEService::_initialize_sync() throw(ErrorIO &, ExceptionBase &)
+ {
+ gint result;
+ guint handle;
+ GError *error = NULL;
+ GVariant *readers = NULL;
+ SEService *service = (SEService *)this;
+
+ _BEGIN();
+
+ /* init default context */
+
+ proxy = smartcard_service_se_service_proxy_new_for_bus_sync(
+ G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE,
+ "org.tizen.SmartcardService",
+ "/org/tizen/SmartcardService/SeService",
+ NULL, &error);
+ if (proxy == NULL)
+ {
+ _ERR("Can not create proxy : %s", error->message);
+ g_error_free(error);
+ return false;
+ }
+
+ g_signal_connect(proxy, "reader-inserted",
+ G_CALLBACK(&SEService::reader_inserted), this);
+
+ g_signal_connect(proxy, "reader-removed",
+ G_CALLBACK(&SEService::reader_removed), this);
+
+ /* request reader */
+ if(smartcard_service_se_service_call_se_service_sync(
+ (SmartcardServiceSeService *)proxy, &result, &handle, &readers, NULL, &error) == true)
+ {
+ if (result == SCARD_ERROR_OK)
+ {
+ service->connected = true;
+ service->handle = handle;
+ service->parseReaderInformation(readers);
+ }
+ else
+ {
+ throw ExceptionBase(result);
+ }
+ }
+ else
+ {
+ _ERR("smartcard_service_se_service_call_se_service failed, [%s]", error->message);
+ g_error_free(error);
+
+ result = SCARD_ERROR_IPC_FAILED;
+ }
+
+ _END();
+
+ return result;
+ }
+
bool SEService::initialize(void *context, serviceConnected handler)
throw(ErrorIO &, ErrorIllegalParameter &)
{
return _initialize();
}
+ bool SEService::initializeSync(void *context)
+ throw(ErrorIO &, ErrorIllegalParameter &, ExceptionBase &)
+ {
+ this->context = context;
+
+ _initialize_sync();
+ return true;
+ }
+
bool SEService::parseReaderInformation(GVariant *variant)
{
Reader *reader = NULL;
GVariantIter *iter;
- gsize count;
guint handle;
gchar *name;
g_variant_get(variant, "a(us)", &iter);
- count = g_variant_iter_n_children(iter);
while (g_variant_iter_loop(iter, "(us)", &handle, &name) == true)
{
+ SECURE_LOGD("Reader : name [%s], handle [%08x]", name, handle);
+
/* add readers */
reader = new Reader((void *)this->handle, name, GUINT_TO_POINTER(handle));
if (reader == NULL)
void *handle = NULL;
Reader *reader = NULL;
char name[100];
+ const uint8_t *buffer = NULL;
+
for (i = 0; i < count && offset < data.size(); i++)
{
memset(name, 0, sizeof(name));
- memcpy(&len, data.getBuffer(offset), sizeof(len));
+ buffer = data.getBuffer(offset);
+ if(buffer == NULL)
+ continue;
+
+ memcpy(&len, buffer, sizeof(len));
offset += sizeof(len);
- memcpy(name, data.getBuffer(offset), len);
+ buffer = data.getBuffer(offset);
+ if(buffer == NULL)
+ return false;
+
+ memcpy(name, buffer, len);
offset += len;
- memcpy(&handle, data.getBuffer(offset), sizeof(handle));
+ buffer = data.getBuffer(offset);
+ if(buffer == NULL)
+ return false;
+
+ memcpy(&handle, buffer, sizeof(handle));
offset += sizeof(handle);
+ SECURE_LOGD("Reader [%d] : name [%s], handle [%p]", i, name, handle);
+
/* add readers */
reader = new Reader(context, name, handle);
if (reader == NULL)
using namespace smartcard_service_api;
-EXTERN_API se_service_h se_service_create_instance(void *user_data, se_service_connected_cb callback)
+EXTERN_API se_service_h se_service_create_instance(void *user_data,
+ se_service_connected_cb callback)
{
SEService *service;
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;
return (se_service_h)service;
}
+EXTERN_API se_service_h se_service_create_instance_sync(void *user_data,
+ int *result)
+{
+ SEService *service;
+
+ try
+ {
+ service = new SEService(user_data);
+ }
+ catch (ExceptionBase &e)
+ {
+ *result = e.getErrorCode();
+ service = NULL;
+ }
+ catch (...)
+ {
+ *result = SCARD_ERROR_UNKNOWN;
+ service = NULL;
+ }
+
+ return (se_service_h)service;
+}
+
+EXTERN_API int se_service_get_version(se_service_h handle, char **version_str)
+{
+ int ret = 0;
+
+ if (version_str == NULL) {
+ return SCARD_ERROR_ILLEGAL_PARAM;
+ }
+
+ SE_SERVICE_EXTERN_BEGIN;
+
+ *version_str = g_strdup(service->getVersion());
+
+ SE_SERVICE_EXTERN_END;
+
+ return ret;
+}
+
EXTERN_API int se_service_get_readers_count(se_service_h handle)
{
int count = 0;
return count;
}
-EXTERN_API bool se_service_get_readers(se_service_h handle, reader_h *readers, int *count)
+EXTERN_API int se_service_get_readers(se_service_h handle, int **readers, int *count)
{
- bool result = false;
+ int result = 0;
SE_SERVICE_EXTERN_BEGIN;
int temp = 0;
temp_readers = service->getReaders();
-
- for (i = 0; i < temp_readers.size() && i < (size_t)*count; i++)
+ if(temp_readers.size() > 0)
{
- if (temp_readers[i]->isSecureElementPresent())
+ *readers = (int *)calloc(temp_readers.size(), sizeof(int));
+
+ if(*readers == NULL)
+ {
+ *count = 0;
+ return SCARD_ERROR_NOT_ENOUGH_RESOURCE;
+ }
+
+ for (i = 0; i < temp_readers.size(); i++)
{
- readers[i] = (reader_h)temp_readers[i];
- temp++;
+ if (temp_readers[i]->isSecureElementPresent())
+ {
+ //(*readers)[i] = (int)temp_readers[i];
+ temp++;
+ }
}
+ *count = temp;
}
- *count = temp;
SE_SERVICE_EXTERN_END;
SE_SERVICE_EXTERN_END;
}
-EXTERN_API void se_service_destroy_instance(se_service_h handle)
+EXTERN_API int se_service_destroy_instance(se_service_h handle)
{
+ int result = 0;
+
SE_SERVICE_EXTERN_BEGIN;
delete service;
SE_SERVICE_EXTERN_END;
+
+ return result;
}
CallbackParam *param = (CallbackParam *)user_data;
Session *session;
openChannelCallback callback;
- gint result;
+ gint result = SCARD_ERROR_UNKNOWN;
+ gint channel_number;
guint channel_id;
GVariant *var_response;
GError *error = NULL;
- Channel *channel;
+ Channel *channel = NULL;
_INFO("MSG_REQUEST_OPEN_CHANNEL");
if (smartcard_service_session_call_open_channel_finish(
SMARTCARD_SERVICE_SESSION(source_object),
- &result, &channel_id, &var_response,
+ &result, &channel_id, &channel_number, &var_response,
res, &error) == true) {
if (result == SCARD_ERROR_OK) {
ByteArray response;
return count;
}
-
Channel *Session::openChannelSync(int id, const ByteArray &aid)
throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &)
{
+ return openChannelSync(id, aid, 0x00);
+ }
+
+ Channel *Session::openChannelSync(int id, const ByteArray &aid, unsigned char P2)
+ throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ ErrorIllegalParameter &, ErrorSecurity &)
+ {
Channel *channel = NULL;
if (getReader()->isSecureElementPresent() == true)
gint ret;
GVariant *var_aid = NULL, *var_response = NULL;
guint channel_id;
+ gint channel_number;
GError *error = NULL;
var_aid = GDBusHelper::convertByteArrayToVariant(aid);
(SmartcardServiceSession *)proxy,
GPOINTER_TO_UINT(context),
GPOINTER_TO_UINT(handle),
- (guint)id, var_aid, &ret, &channel_id,
+ (guint)id, var_aid, (guint8)P2, &ret, &channel_id, &channel_number,
&var_response, NULL, &error) == true) {
if (ret == SCARD_ERROR_OK && channel_id != 0) {
ByteArray response;
/* create new instance of channel */
channel = new ClientChannel(context,
- this, channel_id,
+ this, channel_number,
response, (void *)channel_id);
if (channel != NULL)
{
(SmartcardServiceSession *)proxy,
GPOINTER_TO_UINT(context),
GPOINTER_TO_UINT(handle),
- (guint)id, var_aid, NULL,
+ (guint)id, var_aid, 0, NULL,
&Session::session_open_channel_cb, param);
result = SCARD_ERROR_OK;
throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &)
{
- return openChannelSync(0, aid);
+ return openChannelSync(0, aid, 0x00);
+ }
+
+ Channel *Session::openBasicChannelSync(const ByteArray &aid, unsigned char P2)
+ throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ ErrorIllegalParameter &, ErrorSecurity &)
+ {
+ return openChannelSync(0, aid, P2);
}
Channel *Session::openBasicChannelSync(const unsigned char *aid, unsigned int length)
{
ByteArray temp(aid, length);
- return openBasicChannelSync(temp);
+ return openBasicChannelSync(temp, 0x00);
+ }
+
+ Channel *Session::openBasicChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
+ throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ ErrorIllegalParameter &, ErrorSecurity &)
+ {
+ ByteArray temp(aid, length);
+
+ return openBasicChannelSync(temp, P2);
}
int Session::openBasicChannel(const ByteArray &aid, openChannelCallback callback, void *userData)
throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &)
{
- return openChannelSync(1, aid);
+ return openChannelSync(1, aid, 0x00);
+ }
+
+ Channel *Session::openLogicalChannelSync(const ByteArray &aid, unsigned char P2)
+ throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ ErrorIllegalParameter &, ErrorSecurity &)
+ {
+ return openChannelSync(1, aid, P2);
}
Channel *Session::openLogicalChannelSync(const unsigned char *aid, unsigned int length)
{
ByteArray temp(aid, length);
- return openLogicalChannelSync(temp);
+ return openLogicalChannelSync(temp, 0x00);
+ }
+
+ Channel *Session::openLogicalChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
+ throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ ErrorIllegalParameter &, ErrorSecurity &)
+ {
+ ByteArray temp(aid, length);
+
+ return openLogicalChannelSync(temp, P2);
}
int Session::openLogicalChannel(const ByteArray &aid, openChannelCallback callback, void *userData)
using namespace smartcard_service_api;
-EXTERN_API reader_h session_get_reader(session_h handle)
+EXTERN_API int session_get_reader(session_h handle, int* reader_handle)
{
+ int result = SCARD_ERROR_OK;
reader_h reader = NULL;
SESSION_EXTERN_BEGIN;
+
+ try
+ {
reader = session->getReader();
+ //*reader_handle = (int)reader;
+ }
+ catch (ExceptionBase &e)
+ {
+ _ERR("Error occur : %s\n", e.what());
+ result = e.getErrorCode();
+ *reader_handle = 0;
+ }
+ catch (...)
+ {
+ _ERR("Error occur : unknown error\n");
+ result = SCARD_ERROR_UNKNOWN;
+ *reader_handle = 0;
+ }
+
SESSION_EXTERN_END;
- return reader;
+ return result;
}
-EXTERN_API int session_get_atr(session_h handle, session_get_atr_cb callback, void *userData)
+EXTERN_API int session_is_closed(session_h handle, bool* is_closed)
{
- int result = -1;
+ int result = SCARD_ERROR_OK;
SESSION_EXTERN_BEGIN;
- result = session->getATR((getATRCallback)callback, userData);
+
+ try
+ {
+ *is_closed = session->isClosed();
+ }
+ catch (ExceptionBase &e)
+ {
+ _ERR("Error occur : %s\n", e.what());
+ result = e.getErrorCode();
+ }
+ catch (...)
+ {
+ _ERR("Error occur : unknown error\n");
+ result = SCARD_ERROR_UNKNOWN;
+ }
+
SESSION_EXTERN_END;
return result;
}
-EXTERN_API int session_close(session_h handle, session_close_session_cb callback, void *userData)
+EXTERN_API int session_close_channels(session_h handle)
{
- int result = -1;
+ int result = SCARD_ERROR_OK;
SESSION_EXTERN_BEGIN;
- result = session->close((closeSessionCallback)callback, userData);
+
+ try
+ {
+ session->closeChannels();
+ }
+ catch (ExceptionBase &e)
+ {
+ _ERR("Error occur : %s\n", e.what());
+ result = e.getErrorCode();
+ }
+ catch (...)
+ {
+ _ERR("Error occur : unknown error\n");
+ result = SCARD_ERROR_UNKNOWN;
+ }
+
SESSION_EXTERN_END;
return result;
}
-EXTERN_API bool session_is_closed(session_h handle)
+EXTERN_API int session_get_atr_sync(session_h handle, unsigned char **buffer, unsigned int *length)
{
- bool result = false;
+ ByteArray temp;
+ int result = SCARD_ERROR_OK;
SESSION_EXTERN_BEGIN;
- result = session->isClosed();
+
+ try
+ {
+ temp = session->getATRSync();
+
+ if (temp.size() > 0)
+ {
+ *buffer = (unsigned char *)calloc(temp.size(), sizeof(char));
+ *length = temp.size();
+
+ memcpy(*buffer, temp.getBuffer(), *length);
+ }
+ }
+ catch (ErrorIllegalState &e)
+ {
+ _ERR("Error occur : %s\n", e.what());
+ result = e.getErrorCode();
+
+ if(result == SCARD_ERROR_OPERATION_NOT_SUPPORTED)
+ {
+ *length = 0;
+ result = SCARD_ERROR_OK;
+ }
+ }
+ catch (ExceptionBase &e)
+ {
+ _ERR("Error occur : %s\n", e.what());
+ result = e.getErrorCode();
+ *length = 0;
+ }
+ catch (...)
+ {
+ _ERR("Error occur : unknown error\n");
+ result = SCARD_ERROR_UNKNOWN;
+ *length = 0;
+ }
+
SESSION_EXTERN_END;
return result;
}
-EXTERN_API void session_close_channels(session_h handle)
+EXTERN_API int session_close_sync(session_h handle)
{
+ int result = SCARD_ERROR_OK;
+
SESSION_EXTERN_BEGIN;
- session->closeChannels();
+
+ try
+ {
+ session->closeSync();
+ }
+ catch (ExceptionBase &e)
+ {
+ _ERR("Error occur : %s\n", e.what());
+ result = e.getErrorCode();
+ }
+ catch (...)
+ {
+ _ERR("Error occur : unknown error\n");
+ result = SCARD_ERROR_UNKNOWN;
+ }
+
SESSION_EXTERN_END;
+
+ return result;
}
-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_sync(session_h handle, unsigned char *aid,
+ unsigned int length, unsigned char P2, int* channel_handle)
{
- int result = -1;
+ int result = SCARD_ERROR_OK;
SESSION_EXTERN_BEGIN;
- result = session->openBasicChannel(aid, length, (openChannelCallback)callback, userData);
+
+ try
+ {
+ //*channel_handle = (int)session->openBasicChannelSync(aid, length, P2);
+ }
+ catch (ExceptionBase &e)
+ {
+ _ERR("Error occur : %s\n", e.what());
+ result = e.getErrorCode();
+ *channel_handle = 0;
+ }
+ catch (...)
+ {
+ _ERR("Error occur : unknown error\n");
+ result = SCARD_ERROR_UNKNOWN;
+ *channel_handle = 0;
+ }
+
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_sync(session_h handle, unsigned char *aid,
+ unsigned int length, unsigned char P2, int* channel_handle)
{
- int result = -1;
+ int result = SCARD_ERROR_OK;
SESSION_EXTERN_BEGIN;
- result = session->openLogicalChannel(aid, length, (openChannelCallback)callback, userData);
+
+ try
+ {
+ //*channel_handle = (int)session->openLogicalChannelSync(aid, length, P2);
+ }
+ catch (ExceptionBase &e)
+ {
+ _ERR("Error occur : %s\n", e.what());
+ result = e.getErrorCode();
+ *channel_handle = 0;
+ }
+ catch (...)
+ {
+ _ERR("Error occur : unknown error\n");
+ result = SCARD_ERROR_UNKNOWN;
+ *channel_handle = 0;
+ }
+
SESSION_EXTERN_END;
return result;
}
-EXTERN_API void session_destroy_instance(session_h handle)
-{
-}
-
-EXTERN_API int session_get_atr_sync(session_h handle, unsigned char **buffer, unsigned int *length)
+EXTERN_API int session_get_atr(session_h handle, session_get_atr_cb callback, void *userData)
{
- ByteArray temp;
int result = -1;
- if (buffer == NULL || length == NULL)
- return result;
-
SESSION_EXTERN_BEGIN;
- temp = session->getATRSync();
- if (temp.size() > 0)
- {
- *length = temp.size();
- *buffer = (unsigned char *)calloc(1, *length);
- memcpy(*buffer, temp.getBuffer(), *length);
-
- result = 0;
- }
+ result = session->getATR((getATRCallback)callback, userData);
SESSION_EXTERN_END;
return result;
}
-EXTERN_API void session_close_sync(session_h handle)
+EXTERN_API int session_close(session_h handle, session_close_session_cb callback, void *userData)
{
+ int result = -1;
+
SESSION_EXTERN_BEGIN;
- session->closeSync();
+ result = session->close((closeSessionCallback)callback, userData);
SESSION_EXTERN_END;
+
+ return result;
}
-EXTERN_API channel_h session_open_basic_channel_sync(session_h handle, unsigned char *aid, unsigned int length)
+EXTERN_API int session_open_basic_channel(session_h handle, unsigned char *aid,
+ unsigned int length, session_open_channel_cb callback, void *userData)
{
- channel_h result = NULL;
+ int result = -1;
SESSION_EXTERN_BEGIN;
- result = session->openBasicChannelSync(aid, length);
+ result = session->openBasicChannel(aid, length, (openChannelCallback)callback, userData);
SESSION_EXTERN_END;
return result;
}
-EXTERN_API channel_h session_open_logical_channel_sync(session_h handle, unsigned char *aid, unsigned int length)
+EXTERN_API int session_open_logical_channel(session_h handle, unsigned char *aid,
+ unsigned int length, session_open_channel_cb callback, void *userData)
{
- channel_h result = NULL;
+ int result = -1;
SESSION_EXTERN_BEGIN;
- result = session->openLogicalChannelSync(aid, length);
+ result = session->openLogicalChannel(aid, length, (openChannelCallback)callback, userData);
SESSION_EXTERN_END;
return result;
return result;
}
+
+EXTERN_API void session_destroy_instance(session_h handle)
+{
+}
+
#ifndef CLIENTCHANNEL_H_
#define CLIENTCHANNEL_H_
-#ifdef USE_AUTOSTART
+/* standard library header */
#include <gio/gio.h>
-#endif
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
#include "smartcard-types.h"
#ifdef __cplusplus
#include "Channel.h"
#ifdef __cplusplus
namespace smartcard_service_api
{
- class EXPORT ClientChannel: public Channel
+ class ClientChannel: public Channel
{
private:
void *context;
ClientChannel(void *context, Session *session, int channelNum,
const ByteArray &selectResponse, void *handle);
~ClientChannel();
-#ifdef USE_AUTOSTART
+
static void channel_transmit_cb(GObject *source_object,
GAsyncResult *res, gpointer user_data);
static void channel_close_cb(GObject *source_object,
GAsyncResult *res, gpointer user_data);
-#endif
+
public:
int close(closeChannelCallback callback, void *userParam);
int transmit(const ByteArray &command,
transmitCallback callback, void *userParam);
+ bool selectNext(){ return false; }
void closeSync()
throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &);
+ void *getHandle(){ return handle; }
+
friend class Session;
};
} /* namespace smartcard_service_api */
{
#endif /* __cplusplus */
-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);
-session_h channel_get_session(channel_h handle);
-void channel_destroy_instance(channel_h handle) __attribute__((deprecated));
+int channel_is_basic_channel(channel_h handle, bool* is_basic_channel);
+int channel_is_closed(channel_h handle, bool* is_closed );
+int channel_get_session(channel_h handle, int *session_handle);
+int 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_get_select_response(channel_h handle,
+ unsigned char **buffer, size_t* length);
+int channel_get_transmit_response(channel_h handle,
+ unsigned char **buffer, size_t* length);
+int channel_select_next(channel_h hChannel, bool *pSuccess);
+////
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);
-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);
+unsigned int channel_get_select_response_length(channel_h handle);
+void channel_destroy_instance(channel_h handle) __attribute__((deprecated));
+
#ifdef __cplusplus
}
#ifndef CLIENTGDBUS_H_
#define CLIENTGDBUS_H_
+/* standard library header */
#include <glib.h>
+/* SLP library header */
+
+/* local header */
#include "GDBusHelper.h"
#include "smartcard-service-gdbus.h"
#ifndef READER_H_
#define READER_H_
-#ifdef USE_AUTOSTART
+/* standard library header */
#include <glib.h>
#include <gio/gio.h>
-#endif
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
#include "smartcard-types.h"
#ifdef __cplusplus
#include "ReaderHelper.h"
#ifdef __cplusplus
namespace smartcard_service_api
{
- class EXPORT Reader: public ReaderHelper
+ class Reader: public ReaderHelper
{
private:
void *context;
~Reader();
inline void unavailable() { present = false; }
-#ifdef USE_AUTOSTART
static void reader_open_session_cb(GObject *source_object,
GAsyncResult *res, gpointer user_data);
-#endif
public:
void closeSessions()
throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &);
+ void *getHandle(){ return handle; }
+
friend class SEService;
};
} /* namespace smartcard_service_api */
{
#endif /* __cplusplus */
-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_get_name(reader_h handle, char** reader_name);
+int reader_is_secure_element_present(reader_h handle, bool* is_present);
+int reader_open_session_sync(reader_h handle, int *session_handle);
+int reader_close_sessions(reader_h handle);
+///
+
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);
+se_service_h reader_get_se_service(reader_h handle);
__attribute__((deprecated)) void reader_destroy_instance(reader_h handle);
#ifdef __cplusplus
#ifndef SESERVICE_H_
#define SESERVICE_H_
-#ifdef USE_AUTOSTART
+/* standard library header */
#include <glib.h>
#include <gio/gio.h>
-#endif
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
#include "smartcard-types.h"
#ifdef __cplusplus
#include "SEServiceListener.h"
{
typedef void (*serviceConnected)(SEServiceHelper *service, void *context);
- class EXPORT SEService : public SEServiceHelper
+ class SEService : public SEServiceHelper
{
private:
unsigned int handle;
serviceConnected handler;
SEServiceListener *listener;
void *proxy;
+ const char *version;
+
SEService();
void addReader(unsigned int handle, const char *name);
bool parseReaderInformation(unsigned int count, const ByteArray &data);
-#ifdef USE_AUTOSTART
bool parseReaderInformation(GVariant *variant);
-#endif
+
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 &);
-#ifdef USE_AUTOSTART
+ int _initialize_sync()
+ throw(ErrorIO &, ExceptionBase &);
+ bool initializeSync(void *context)
+ throw(ErrorIO &, ErrorIllegalParameter &, ExceptionBase &);
+
static void reader_inserted(GObject *source_object,
guint reader_id, gchar *reader_name,
gpointer user_data);
GAsyncResult *res, gpointer user_data);
static void se_service_cb(GObject *source_object,
GAsyncResult *res, gpointer user_data);
-#endif
+
public:
SEService(void *user_data, serviceConnected handler)
throw(ErrorIO &, ErrorIllegalParameter &);
SEService(void *user_data, SEServiceListener *listener)
throw(ErrorIO &, ErrorIllegalParameter &);
+ SEService(void *user_data)
+ throw(ErrorIO &, ErrorIllegalParameter &, ExceptionBase &);
~SEService();
static SEService *createInstance(void *user_data, SEServiceListener *listener)
void shutdown();
void shutdownSync();
+ const char *getVersion() const { return version; }
};
} /* namespace smartcard_service_api */
#endif /* __cplusplus */
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_sync(void *user_data, int* result);
+int se_service_get_version(se_service_h handle, char **version_str);
int se_service_get_readers_count(se_service_h handle);
-bool se_service_get_readers(se_service_h handle, reader_h *readers, int *count);
+int se_service_get_readers(se_service_h handle, int **readers, int *count);
+
bool se_service_is_connected(se_service_h handle);
void se_service_shutdown(se_service_h handle);
-void se_service_destroy_instance(se_service_h handle);
+int se_service_destroy_instance(se_service_h handle);
+
#ifdef __cplusplus
}
#ifndef SESERVICELISTENER_H_
#define SESERVICELISTENER_H_
-#include "Debug.h"
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
namespace smartcard_service_api
{
class SEServiceHelper;
- class EXPORT SEServiceListener
+ class SEServiceListener
{
public:
virtual void serviceConnected(SEServiceHelper *service,
#ifndef SESSION_H_
#define SESSION_H_
-#ifdef USE_AUTOSTART
+/* standard library header */
#include <gio/gio.h>
-#endif
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
#include "smartcard-types.h"
#ifdef __cplusplus
#include "SessionHelper.h"
{
class Reader;
- class EXPORT Session : public SessionHelper
+ class Session : public SessionHelper
{
private:
void *context;
~Session();
int openChannel(int id, const ByteArray &aid, openChannelCallback callback, void *userData);
+
Channel *openChannelSync(int id, const ByteArray &aid)
throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &);
-#ifdef USE_AUTOSTART
+ Channel *openChannelSync(int id, const ByteArray &aid, unsigned char P2)
+ throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ ErrorIllegalParameter &, ErrorSecurity &);
+
static void session_get_atr_cb(GObject *source_object,
GAsyncResult *res, gpointer user_data);
static void session_open_channel_cb(GObject *source_object,
GAsyncResult *res, gpointer user_data);
static void session_close_cb(GObject *source_object,
GAsyncResult *res, gpointer user_data);
-#endif
public:
void closeChannels()
Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length)
throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ ErrorIllegalParameter &, ErrorSecurity &);
+
+ Channel *openBasicChannelSync(const ByteArray &aid, unsigned char P2)
+ throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ ErrorIllegalParameter &, ErrorSecurity &);
+
+ Channel *openBasicChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
+ throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ ErrorIllegalParameter &, ErrorSecurity &);
+
+ Channel *openLogicalChannelSync(const ByteArray &aid, unsigned char P2)
+ throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ ErrorIllegalParameter &, ErrorSecurity &);
+
+ Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
+ throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &);
size_t getChannelCount() const;
+ void *getHandle(){ return handle; }
friend class Reader;
};
{
#endif /* __cplusplus */
-reader_h session_get_reader(session_h handle);
-bool session_is_closed(session_h handle);
-__attribute__((deprecated)) void session_destroy_instance(session_h handle);
-void session_close_channels(session_h handle);
+int session_get_reader(session_h handle, int* reader_handle);
+int session_is_closed(session_h handle, bool* is_closed);
+int session_close_channels(session_h handle);
+int session_get_atr_sync(session_h handle, unsigned char **buffer, unsigned int *length);
+int session_close_sync(session_h handle);
+int session_open_basic_channel_sync(session_h handle, unsigned char *aid,
+ unsigned int length, unsigned char P2, int* channel_handle);
+int session_open_logical_channel_sync(session_h handle, unsigned char *aid,
+ unsigned int length, unsigned char P2, int* channel_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);
+size_t session_get_channel_count(session_h handle);
+__attribute__((deprecated)) void session_destroy_instance(session_h handle);
-int session_get_atr_sync(session_h handle, unsigned char **buffer,
- unsigned int *length);
-void session_close_sync(session_h handle);
-
-channel_h session_open_basic_channel_sync(session_h handle,
- unsigned char *aid, unsigned int length);
-channel_h session_open_logical_channel_sync(session_h handle,
- unsigned char *aid, unsigned int length);
-size_t session_get_channel_count(session_h handle);
#ifdef __cplusplus
}
#define SMARTCARD_SERVICE_H_
#include "smartcard-types.h"
+#ifdef __cplusplus
#include "Exception.h"
+#endif
#include "SEService.h"
#include "Reader.h"
#include "Session.h"
--- /dev/null
+# Package Information for pkg-config
+
+prefix=/usr
+exec_prefix=${prefix}/bin
+includedir=${prefix}/include
+libdir=${prefix}/lib
+
+Name: smartcard-service
+Description: Make flags of Common library of Smartcard service
+Version: 1.0
+Requires: glib-2.0 dlog
+Libs: -L${libdir} -lsmartcard-service
+Cflags: -I${includedir}/smartcard-service
\ No newline at end of file
+++ /dev/null
-prefix=@PREFIX@
-exec_prefix=${prefix}/bin
-libdir=@LIB_INSTALL_DIR@
-includedir=@INCLUDE_INSTALL_DIR@/@PROJECT_NAME@
-
-Name: @PROJECT_NAME@
-Description: library of Smartcard service
-Version: @FULLVER@
-Requires: glib-2.0 dlog
-Libs: -L${libdir} -l@PROJECT_NAME@
-Cflags: -I${includedir}
case (unsigned char)0x92 : /* extra information */
break;
+ /* Warning processing */
+ case (unsigned char)0x62 : /* State of non-volatile memory is unchanged (further qualification in SW2) */
+ break;
+
+ case (unsigned char)0x63 : /* State of non-volatile memory has changed (further qualification in SW2) */
+ break;
+
+#if 0
+ case (unsigned char)0x61 : /* SW2 encodes the number of data bytes still available */
+ break;
+
+
+ /* Execution error */
+ case (unsigned char)0x64 : /* State of non-volatile memory is unchanged (further qualification in SW2) */
+ result = -1;
+ break;
+
+ case (unsigned char)0x65 : /* State of non-volatile memory has changed (further qualification in SW2) */
+ result = -1;
+ break;
+
+ case (unsigned char)0x66 : /* Security-related issues */
+ result = -1;
+ break;
+
+ /* Checking error */
+ case (unsigned char)0x67 : /* SW2:00, Wrong length; no further indication */
+ result = -1;
+ break;
+
+ case (unsigned char)0x68 : /* Functions in CLA not supported (further qualification in SW2) */
+ result = -1;
+ break;
+
+ case (unsigned char)0x69 : /* Command not allowed (further qualification in SW2) */
+ result = -1;
+ break;
+
+ case (unsigned char)0x6A : /* Wrong parameters P1-P2 (further qualification in SW2) */
+ result = -1;
+ break;
+
+ case (unsigned char)0x6B : /* SW2:00, Wrong parameters P1-P2 */
+ result = -1;
+ break;
+
+ case (unsigned char)0x6C : /* Wrong Le field; SW2 encodes the exact number of available data bytes */
+ result = -1;
+ break;
+
+ case (unsigned char)0x6D : /* SW2:00, Instruction code not supported or invalid */
+ result = -1;
+ break;
+
+ case (unsigned char)0x6E : /* SW2:00, Class not supported */
+ result = -1;
+ break;
+
+ case (unsigned char)0x6F : /* SW2:00, No precise diagnosis */
+ result = -1;
+ break;
+#endif
default :
result *= -1;
break;
if (response.size() >= 2)
{
- status = ResponseHelper::parseStatusWord(response.getBuffer((response.size() - 2)));
+ const uint8_t* buffer = response.getBuffer((response.size() - 2));
+ if(buffer != NULL)
+ status = ResponseHelper::parseStatusWord(buffer);
}
return status;
bool APDUCommand::setCommand(const ByteArray &command)
{
bool result = false;
+ const uint8_t *buffer;
uint32_t offset = 0;
uint32_t lengthSize = 1;
return false;
}
- memcpy(&header, command.getBuffer(offset), sizeof(header));
+ buffer = command.getBuffer(offset);
+ if(buffer == NULL)
+ {
+ return false;
+ }
+
+ memcpy(&header, buffer, sizeof(header));
offset += sizeof(header);
if (isExtendedLength)
else
{
length = command.at(offset);
+ if (length == 0) {
+ length = 256;
+ }
offset += 1;
}
else
{
if (command.at(offset) == 0)
- setMaxResponseSize(APDUCommand::LE_MAX);
+ setMaxResponseSize(256);
else
setMaxResponseSize(command.at(offset));
{
case INS_TERMINAL_PROFILE :
case INS_FETCH :
- case INS_ENVELOPE :
case INS_TERMINAL_RESPONSE :
result = true;
break;
switch (command)
{
case COMMAND_OPEN_LOGICAL_CHANNEL :
- apdu.setCommand(0, APDUCommand::INS_MANAGE_CHANNEL, 0, 0, ByteArray::EMPTY, APDUCommand::LE_MAX);
+ apdu.setCommand(0, APDUCommand::INS_MANAGE_CHANNEL, 0, 0, ByteArray::EMPTY, 1);
apdu.getBuffer(result);
break;
break;
case COMMAND_SELECT_BY_DF_NAME :
- apdu.setCommand(0, APDUCommand::INS_SELECT_FILE, APDUCommand::P1_SELECT_BY_DF_NAME, APDUCommand::P2_SELECT_GET_FCP, data, 0);
+ apdu.setCommand(0, APDUCommand::INS_SELECT_FILE, APDUCommand::P1_SELECT_BY_DF_NAME, APDUCommand::P2_SELECT_GET_FCI, data, 0);
apdu.getBuffer(result);
break;
* limitations under the License.
*/
+/* standard library header */
#include <stdio.h>
+/* SLP library header */
+
+/* local header */
#include "Debug.h"
#include "SimpleTLV.h"
#include "AccessControlList.h"
cmd = *(unsigned int *)command.getBuffer();
for (item = listFilters.begin(); item != listFilters.end(); item++)
{
- mask = *(unsigned int *)item->second.getBuffer();
- rule = *(unsigned int *)item->first.getBuffer();
+ unsigned int *temp1 = NULL;
+ unsigned int *temp2 = NULL;
+
+ temp1 = (unsigned int *)item->second.getBuffer();
+ temp2 = (unsigned int *)item->first.getBuffer();
+
+ if(temp1 == NULL || temp2 == NULL)
+ continue;
+
+ mask = *temp1;
+ rule = *temp2;
if ((cmd & mask) == rule)
{
return result;
}
+ void AccessRule::printAccessRules() const
+ {
+ if (listFilters.size() > 0)
+ {
+ vector<pair<ByteArray, ByteArray> >::const_iterator item;
+
+ _DBG(" +---- Granted APDUs");
+
+ for (item = listFilters.begin(); item != listFilters.end(); item++)
+ {
+ _DBG(" +----- APDU : %s, Mask : %s", item->first.toString().c_str(), item->second.toString().c_str());
+ }
+ }
+ else
+ {
+ _DBG(" +---- APDU Access ALLOW : %s", apduRule ? "ALWAYS" : "NEVER");
+ }
+
+ _DBG(" +---- NFC Access ALLOW : %s", nfcRule ? "ALWAYS" : "NEVER");
+ }
+
bool AccessRule::isAuthorizedNFCAccess(void) const
{
return nfcRule;
return result;
}
+ void AccessCondition::printAccessConditions() const
+ {
+ _DBG(" +-- Access Condition");
+
+ if (mapRules.size() > 0)
+ {
+ map<ByteArray, AccessRule>::const_iterator item;
+
+ for (item = mapRules.begin(); item != mapRules.end(); item++)
+ {
+ ByteArray temp = item->first;
+
+ _DBG(" +--- hash : %s", (temp == AccessControlList::ALL_DEVICE_APPS) ? "All device applications" : temp.toString().c_str());
+ item->second.printAccessRules();
+ }
+ }
+ else
+ {
+ _DBG(" +--- no rule found");
+ }
+ }
+
void AccessCondition::setAPDUAccessRule(const ByteArray &certHash,
bool rule)
{
result = rule->isAuthorizedAPDUAccess(command);
}
_INFO("rule found (%s): [%s:%s]", result ? "accept" : "deny", "All SE Applications", "All device applications");
+ goto END;
+ }
+
+ size_t i;
+
+ _INFO("no rule found, aid [%s]", aid.toString().c_str());
+
+ for (i = 0; i < certHashes.size(); i++) {
+ _INFO(" hash[%d] [%s]", i, certHashes[i].toString().c_str());
}
END :
if (rule != NULL) {
result = rule->isAuthorizedNFCAccess();
_INFO("rule found (%s): [%s:%s]", result ? "accept" : "deny", "All SE Applications", "All device applications");
+ goto END;
}
+ size_t i;
+
+ _INFO("no rule found, aid [%s]", aid.toString().c_str());
+
+ for (i = 0; i < certHashes.size(); i++) {
+ _INFO(" hash[%d] [%s]", i, certHashes[i].toString().c_str());
+ }
END :
return result;
}
+
+ void AccessControlList::printAccessControlList() const
+ {
+ ByteArray temp;
+ map<ByteArray, AccessCondition>::const_iterator iterMap;
+
+ _DBG("========================== Access Control Rules ============================");
+ for (iterMap = mapConditions.begin(); iterMap != mapConditions.end(); iterMap++)
+ {
+ temp = iterMap->first;
+
+ _DBG("+ aid : %s", (temp == DEFAULT_SE_APP) ? "Default Application" : (temp == ALL_SE_APPS) ? "All SE Applications" : temp.toString().c_str());
+
+ iterMap->second.printAccessConditions();
+ }
+ _DBG("============================================================================");
+ }
+
} /* namespace smartcard_service_api */
* limitations under the License.
*/
+/* standard library header */
#include <cstdio>
#include <cstring>
#include <cerrno>
#include <sstream>
+/* SLP library header */
+
+/* local header */
#include "Debug.h"
#include "ByteArray.h"
return buffer[index];
}
+
const string ByteArray::toString() const
{
+#ifdef TO_STRING_ALL
+ return toString(true);
+#else
+ return toString(false);
+#endif
+ }
+
+ const string ByteArray::toString(bool entire) const
+ {
stringstream ss;
if (length > 0)
bool ellipsis = false;
count = length;
- if (count > 20)
+ if (entire == false && count > 20)
{
count = 20;
ellipsis = true;
fwrite(buffer, 1, length, file);
fflush(file);
fclose(file);
+
+ SECURE_LOGD("file has written, file [%s], length[%d]", filePath, length);
}
else
{
}
} /* namespace smartcard_service_api */
-
-INCLUDE_DIRECTORIES(include)
-
-FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
-EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
- " --generate-c-code ${CMAKE_CURRENT_SOURCE_DIR}/smartcard-service-gdbus"
- " --c-namespace SmartcardService"
- " --interface-prefix org.tizen.SmartcardService."
- " ${CMAKE_CURRENT_SOURCE_DIR}/smartcard-service-gdbus.xml"
-)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(smartcard-service-common CXX)
+
+SET(LIB_NAME "smartcard-service-common")
+SET(VERSION_MAJOR 1)
+SET(VERSION ${VERSION_MAJOR}.0.0)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} COMMON_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SRCS)
+#IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+# SET(CMAKE_BUILD_TYPE "Debug")
+#ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+#MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs_common REQUIRED glib-2.0 gio-unix-2.0 dlog aul libssl pkgmgr pkgmgr-info)
+
+MESSAGE("${LIB_NAME} ld flag : ${pkgs_common_LDFLAGS}")
+
FOREACH(flag ${pkgs_common_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -finstrument-functions -fPIC")
+#SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+#SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS} -finstrument-functions -std=c++0x")
+#SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+#SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+ ADD_DEFINITIONS("-DTARGET")
+ MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DSLP_DEBUG")
+ADD_DEFINITIONS("-DUSE_UNIX_DOMAIN")
ADD_DEFINITIONS("-DLOG_TAG=\"SMARTCARD_SERVICE_COMMON\"")
-SET(CMAKE_C_FLAGS "${EXTRA_CXXFLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+
+SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES VERSION ${VERSION})
-ADD_LIBRARY(${COMMON_LIB} SHARED ${COMMON_SRCS})
-SET_TARGET_PROPERTIES(${COMMON_LIB} PROPERTIES VERSION ${FULLVER} SOVERSION ${MAJORVER})
-TARGET_LINK_LIBRARIES(${COMMON_LIB} ${pkgs_common_LDFLAGS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_common_LDFLAGS})
-SET(EXPORT_HEADER
+SET(EXPORT_HEADER
include/smartcard-types.h
include/Debug.h
include/Exception.h
include/ByteArray.h
include/Lock.h
- include/Synchronous.h
+ include/Synchronous.h
include/TerminalInterface.h
include/Terminal.h
include/SignatureHelper.h
)
-CONFIGURE_FILE(${COMMON_LIB}.pc.in ${COMMON_LIB}.pc @ONLY)
-INSTALL(FILES ${COMMON_LIB}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-INSTALL(TARGETS ${COMMON_LIB} DESTINATION ${LIB_INSTALL_DIR})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${LIB_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR})
FOREACH(hfile ${EXPORT_HEADER})
- INSTALL(FILES ${hfile} DESTINATION include/${COMMON_LIB})
+ INSTALL(FILES ${hfile} DESTINATION include/${LIB_NAME})
ENDFOREACH(hfile)
* limitations under the License.
*/
+/* standard library header */
#include <stdio.h>
+/* SLP library header */
+
+/* local header */
#include "Debug.h"
#include "EFDIR.h"
#include "APDUHelper.h"
* limitations under the License.
*/
+/* standard library header */
#include <cstdio>
#include <cstring>
#include <sstream>
+/* SLP library header */
+
+/* local header */
#include "Debug.h"
#include "FCI.h"
#include "SimpleTLV.h"
}
/* parse... */
- tlv.setTLVBuffer(fcpBuffer.getBuffer(), fcpBuffer.size());
+ tlv.setTLVBuffer(fcpBuffer);
if (tlv.decodeTLV())
{
case 0x84 : /* DF name */
{
+ SECURE_LOGD("0x%02X : DF name : %s", tlv.getTag(), tlv.getValue().toString().c_str());
// ByteArray value = tlv.getValue();
}
break;
case 0x86 : /* Security attribute in proprietary format */
{
+ SECURE_LOGD("0x%02X : Security attribute in proprietary format : %s", tlv.getTag(), tlv.getValue().toString().c_str());
// ByteArray value = tlv.getValue();
}
break;
case 0x8B : /* Security attribute referencing the expanded format */
{
+ SECURE_LOGD("0x%02X : Security attribute referencing the expanded format : %s", tlv.getTag(), tlv.getValue().toString().c_str());
// ByteArray value = tlv.getValue();
}
break;
case 0x8C : /* Security attribute in compact format */
{
+ SECURE_LOGD("0x%02X : Security attribute in compact format : %s", tlv.getTag(), tlv.getValue().toString().c_str());
// ByteArray value = tlv.getValue();
}
break;
case 0x8D : /* Identifier of an EF containing security environment templates */
{
+ SECURE_LOGD("0x%02X : Identifier of an EF containing security environment templates : %s", tlv.getTag(), tlv.getValue().toString().c_str());
// ByteArray value = tlv.getValue();
}
break;
case 0x8E : /* Channel security attribute */
{
+ SECURE_LOGD("0x%02X : Channel security attribute : %s", tlv.getTag(), tlv.getValue().toString().c_str());
// ByteArray value = tlv.getValue();
}
break;
case 0xA0 : /* Security attribute template for data objects */
{
+ SECURE_LOGD("0x%02X : Security attribute template for data objects : %s", tlv.getTag(), tlv.getValue().toString().c_str());
// ByteArray value = tlv.getValue();
}
break;
case 0xA1 : /* Security attribute template in proprietary format */
{
+ SECURE_LOGD("0x%02X : Security attribute template in proprietary format : %s", tlv.getTag(), tlv.getValue().toString().c_str());
// ByteArray value = tlv.getValue();
}
break;
case 0xAB : /* Security attribute template in expanded format */
{
+ SECURE_LOGD("0x%02X : Security attribute template in expanded format : %s", tlv.getTag(), tlv.getValue().toString().c_str());
// ByteArray value = tlv.getValue();
}
break;
case 0xC6 : /* PIN status template DO */
{
+ SECURE_LOGD("0x%02X : PIN status template DO : %s", tlv.getTag(), tlv.getValue().toString().c_str());
// ByteArray value = tlv.getValue();
}
break;
* limitations under the License.
*/
+/* standard library header */
#include <stdio.h>
+#include <glib.h>
+/* SLP library header */
+
+/* local header */
#include "Debug.h"
#include "FileObject.h"
#include "APDUHelper.h"
ret = resp.getStatus();
- if (setSelectResponse(result) == true)
- {
- opened = true;
- }
+ setSelectResponse(result);
}
else
{
return 0;
}
+#define MAX_SINGLE_LEN 256
+
int FileObject::readBinary(unsigned int sfi, unsigned int offset, unsigned int length, ByteArray &result)
{
ByteArray command, response;
APDUCommand apdu;
int ret;
- apdu.setCommand(0, APDUCommand::INS_READ_BINARY, offset, 0, ByteArray::EMPTY, length);
+ /* FIXME : fix calculating length */
+ apdu.setCommand(0, APDUCommand::INS_READ_BINARY,
+ (offset >> 8) & 0x7F, offset & 0x00FF,
+ ByteArray::EMPTY, (length > MAX_SINGLE_LEN - 1) ? 0 : length);
+
apdu.getBuffer(command);
ret = channel->transmitSync(command, response);
return ret;
}
+ int FileObject::readBinary(unsigned int sfi, unsigned int length, ByteArray &result)
+ {
+ int ret;
+ size_t offset = 0;
+ ByteArray temp;
+
+ do {
+ ret = readBinary(sfi, offset, length - offset, temp);
+ if (ret >= SCARD_ERROR_OK) {
+ result += temp;
+ offset += temp.size();
+ }
+ } while (ret >= SCARD_ERROR_OK && offset < length);
+
+ return ret;
+ }
+
int FileObject::writeBinary(unsigned int sfi, const ByteArray &data, unsigned int offset, unsigned int length)
{
ByteArray command, response;
return ret;
}
+
+ int FileObject::writeBinary(unsigned int sfi, const ByteArray &data)
+ {
+ int result;
+ size_t offset = 0, len;
+ ByteArray temp;
+
+ do {
+ len = MIN(data.size() - offset, MAX_SINGLE_LEN);
+ temp.setBuffer(data.getBuffer(offset), len);
+ result = writeBinary(sfi, temp, offset, len);
+ if (result >= SCARD_ERROR_OK) {
+ offset += len;
+ }
+ } while (result >= SCARD_ERROR_OK && offset < data.size());
+
+ return result;
+ }
+
+ int FileObject::readBinaryAll(unsigned int sfi, ByteArray &result)
+ {
+ int ret;
+
+ ret = readBinary(sfi, getFCP()->getFileSize(), result);
+
+ return ret;
+ }
+
} /* namespace smartcard_service_api */
* limitations under the License.
*/
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "Debug.h"
#include "GPACE.h"
#include "GPARAACL.h"
* limitations under the License.
*/
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "Debug.h"
#include "GPARAACL.h"
#include "GPARAM.h"
{
_INFO("access rules are not changed. skip update");
}
+
+ printAccessControlList();
} else {
_ERR("transmitSync failed, %x", result);
}
* limitations under the License.
*/
+/* standard library header */
+#include <glib.h>
+
+/* SLP library header */
+
+/* local header */
#include "Debug.h"
#include "GPARAM.h"
#include "APDUHelper.h"
namespace smartcard_service_api
{
- static unsigned char aid_aram[] = { 0xA0, 0x00, 0x00, 0x01, 0x51, 0x41, 0x43, 0x4C, 00 };
+ static unsigned char aid_aram[] = { 0xA0, 0x00, 0x00, 0x01, 0x51, 0x41, 0x43, 0x4C, 0x00 };
static ByteArray AID_ARAM(ARRAY_AND_SIZE(aid_aram));
#define GET_DATA_ALL 0
return result;
}
+ int getLengthAndValue(const ByteArray &data, ByteArray &value)
+ {
+ int result = -1;
+ int offset = 0;
+
+ if (data.isEmpty() == true) {
+ return result;
+ }
+
+ if (data.at(offset) == 0xFF && data.at(offset + 1) == 0x40) {
+ uint8_t count;
+
+ offset += 2;
+ count = data.at(offset);
+
+ offset += 1;
+ if (count & 0x80) {
+ int i;
+
+ count &= ~0x80;
+ result = 0;
+
+ for (i = 0; i < count; i++) {
+ result = (result << 8) | data.at(offset + i);
+ }
+
+ offset += i;
+ } else {
+ result = count;
+ }
+
+ if (result > 0) {
+ value.assign(data.getBuffer(offset),
+ MIN((uint32_t)result,
+ data.size() - offset));
+ }
+ } else {
+ _ERR("invalid tag");
+ }
+
+ return result;
+ }
+
int GPARAM::getDataAll(ByteArray &data)
{
int result;
result = doCommand(channel, GET_DATA_ALL, response);
if (result >= SCARD_ERROR_OK) {
- ISO7816BERTLV tlv(response);
-
- if (tlv.decodeTLV() == true &&
- tlv.getTag() == ARAM_TAG_ALL_AR) {
- unsigned int length = tlv.size();
-
- if (length > 0){
- data = tlv.getValue();
-
- while (length > data.size()) {
- result = doCommand(channel, GET_DATA_NEXT, response);
- if (result >= SCARD_ERROR_OK) {
- data += response;
- } else {
- _ERR("generateCommand failed, [%d]", result);
- data.clear();
- break;
- }
+ int length;
+
+ length = getLengthAndValue(response, data);
+ if (length > 0){
+ while (length > (int)data.size()) {
+ result = doCommand(channel, GET_DATA_NEXT, response);
+ if (result >= SCARD_ERROR_OK) {
+ data += response;
+ } else {
+ _ERR("generateCommand failed, [%d]", result);
+ data.clear();
+ break;
}
-
- _DBG("data[%d] : %s", data.size(), data.toString().c_str());
- } else {
- _INFO("Response-ALL-AR-DO is empty");
- data.clear();
}
+
+ _DBG("data[%d] : %s", data.size(), data.toString().c_str());
+ } else if (length == 0) {
+ _INFO("Response-ALL-AR-DO is empty");
+ data.clear();
} else {
- _ERR("decodeTLV failed, %s", response.toString().c_str());
- result = SCARD_ERROR_ILLEGAL_PARAM;
+ _ERR("invalid result, %s", response.toString().c_str());
+ result = SCARD_ERROR_UNAVAILABLE;
}
} else {
- _ERR("generateCommand failed, [%d]", result);
+ _ERR("doCommand failed, [%d]", result);
}
_END();
* limitations under the License.
*/
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "Debug.h"
#include "GPARFACL.h"
#include "PKCS15ODF.h"
PKCS15 pkcs15(channel);
/* basically, all requests will be accepted when PKCS #15 doesn't exist or global platform OID is not placed */
+#if 1 /* FOR ORANGE */
+ /* for Orange, every requests will be denied in same cases */
allGranted = false;
+#else
+ allGranted = true;
+#endif
result = pkcs15.select();
if (result >= SCARD_ERROR_OK)
PKCS15ODF *odf;
result = SCARD_ERROR_OK;
- allGranted = true;
if ((odf = pkcs15.getODF()) != NULL)
{
result = loadAccessControl(channel, dodf);
if (result == SCARD_ERROR_OK)
{
+ printAccessControlList();
}
else
{
+#if 1 /* FOR ORANGE */
+ _ERR("loadAccessControl failed, every request will be denied.");
+#else
_INFO("loadAccessControl failed, every request will be accepted.");
+#endif
result = SCARD_ERROR_OK;
}
}
else
{
+#if 1 /* FOR ORANGE */
+ _ERR("dodf null, every request will be denied.");
+#else
_INFO("dodf null, every request will be accepted.");
+#endif
}
}
else
{
+#if 1 /* FOR ORANGE */
+ _ERR("odf null, every request will be denied.");
+#else
_INFO("odf null, every request will be accepted.");
+#endif
}
}
else
{
- _ERR("failed to open PKCS15, every request will be denied.");
+#if 1 /* FOR ORANGE */
+ _ERR("failed to open PKCS#15, every request will be denied.");
+#else
+ _INFO("failed to open PKCS#15, every request will be accepted.");
+#endif
}
_END();
_DBG("oid path : %s", path.toString().c_str());
file.select(NumberStream::getLittleEndianNumber(path));
- file.readBinary(0, 0, file.getFCP()->getFileSize(), data);
+ file.readBinaryAll(0, data);
_DBG("data : %s", data.toString().c_str());
ByteArray data, aid;
file.select(NumberStream::getLittleEndianNumber(path));
- file.readBinary(0, 0, file.getFCP()->getFileSize(), data);
+ file.readBinaryAll(0, data);
_DBG("data : %s", data.toString().c_str());
}
else
{
- _INFO("access denied for all applications, aid : %s", condition.getAID().toString().c_str());
+ /* empty rule, it means allow for all application */
+ _INFO("access allowed for all applications, aid : %s", condition.getAID().toString().c_str());
- condition.setAccessCondition(false);
+ condition.setAccessCondition(true);
break;
}
}
ByteArray data;
file.select(NumberStream::getLittleEndianNumber(path));
- file.readBinary(0, 0, file.getFCP()->getFileSize(), data);
+ file.readBinaryAll(0, data);
_DBG("data : %s", data.toString().c_str());
* limitations under the License.
*/
+/* standard library header */
#include <stdio.h>
#include <string.h>
+/* SLP library header */
+
+/* local header */
#include "ISO7816BERTLV.h"
namespace smartcard_service_api
int ISO7816BERTLV::decodeLength(const unsigned char *buffer)
{
- if (buffer[0] & 0x80)
+ uint8_t offset = 0;
+ uint8_t count = buffer[offset];
+
+ offset++;
+
+ if (count & 0x80)
{
- uint8_t count = (buffer[0] & 0x7F);
uint8_t i;
+ count &= ~0x80;
+
/* count will be less than 5 */
if (count > 4)
return -1;
- count++;
-
- for (i = 1; i < count; i++)
+ for (i = 0; i < count; i++)
{
/* if big endian */
- currentL = (currentL << 8) | buffer[i];
+ currentL = (currentL << 8) | buffer[offset + i];
/* if little endian */
- /* currentL = currentL | (buffer[i] << (8 * (i - 1))); */
+ /* currentL = currentL | (buffer[offset + i] << (8 * (i - 1))); */
}
- return count;
+ offset += i;
}
else
{
- currentL = buffer[0];
-
- return 1;
+ currentL = count;
}
+
+ return offset;
}
int ISO7816BERTLV::decodeValue(const unsigned char *buffer)
* limitations under the License.
*/
+/* standard library header */
#include <stdio.h>
#include <string.h>
#include <openssl/evp.h>
#include <openssl/bio.h>
#include <openssl/buffer.h>
+/* SLP library header */
+
+/* local header */
#include "Debug.h"
#include "ByteArray.h"
#include "OpensslHelper.h"
}
b64 = BIO_new(BIO_f_base64());
+ if(b64 == NULL)
+ return false;
+
bmem = BIO_new(BIO_s_mem());
if (newLineChar == false)
memset(temp, 0, length);
b64 = BIO_new(BIO_f_base64());
+ if(b64 == NULL)
+ {
+ delete []temp;
+ return false;
+ }
+
bmem = BIO_new_mem_buf((void *)buffer.getBuffer(), length);
if (newLineChar == false)
BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
length = BIO_read(bmem, temp, length);
BIO_free_all(bmem);
-
- result.assign((unsigned char *)temp, length);
+ if(length > 0)
+ {
+ result.assign((unsigned char *)temp, length);
+ ret = true;
+ }
+ else
+ {
+ ret = false;
+ }
delete []temp;
-
- ret = true;
}
else
{
* limitations under the License.
*/
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "Debug.h"
#include "APDUHelper.h"
#include "EFDIR.h"
{
static unsigned char aid[] = { 0xA0, 0x00, 0x00, 0x00, 0x63, 0x50,
0x4B, 0x43, 0x53, 0x2D, 0x31, 0x35 };
- ByteArray PKCS15::PKCS15_AID(ARRAY_AND_SIZE(aid));
+ const ByteArray PKCS15::PKCS15_AID(ARRAY_AND_SIZE(aid));
PKCS15::PKCS15(Channel *channel) :
PKCS15Object(channel), odf(NULL)
{
int ret;
- ret = PKCS15Object::select(PKCS15::PKCS15_AID);
+ ret = PKCS15Object::select(PKCS15_AID);
if (ret >= SCARD_ERROR_OK)
{
_DBG("response : %s", selectResponse.toString().c_str());
--- /dev/null
+/*
+ * 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 "Debug.h"
+#include "NumberStream.h"
+#include "PKCS15CDF.h"
+#include "SimpleTLV.h"
+
+namespace smartcard_service_api
+{
+ PKCS15CDF::PKCS15CDF(unsigned int fid, Channel *channel) :
+ PKCS15Object(channel)
+ {
+ int ret = 0;
+
+ if ((ret = select(fid)) >= SCARD_ERROR_OK)
+ {
+ ByteArray cdfData, extra;
+
+ _DBG("response : %s", selectResponse.toString().c_str());
+
+ ret = readBinaryAll(0, cdfData);
+ if (ret == SCARD_ERROR_OK)
+ {
+ _DBG("cdfData : %s", cdfData.toString().c_str());
+
+ parseData(cdfData);
+ }
+ else
+ {
+ _ERR("readBinary failed, [%d]", ret);
+ }
+ }
+ else
+ {
+ _ERR("select failed, [%d]", ret);
+ }
+ }
+
+ PKCS15CDF::PKCS15CDF(const ByteArray &path, Channel *channel) :
+ PKCS15Object(channel)
+ {
+ int ret = 0;
+
+ if ((ret = select(path)) >= SCARD_ERROR_OK)
+ {
+ ByteArray cdfData, extra;
+
+ _DBG("response : %s", selectResponse.toString().c_str());
+
+ ret = readBinaryAll(0, cdfData);
+ if (ret == SCARD_ERROR_OK)
+ {
+ _DBG("cdfData : %s", cdfData.toString().c_str());
+
+ parseData(cdfData);
+ }
+ else
+ {
+ _ERR("readBinary failed, [%d]", ret);
+ }
+ }
+ else
+ {
+ _ERR("select failed, [%d]", ret);
+ }
+ }
+
+ PKCS15CDF::~PKCS15CDF()
+ {
+ }
+
+ bool PKCS15CDF::parseData(const ByteArray &data)
+ {
+ int result;
+ char* buffer;
+ SimpleTLV tlv(data);
+
+ while (tlv.decodeTLV())
+ {
+ CertificateType *cert;
+
+ _DBG("0x%02X [%d] : %s", tlv.getTag(), tlv.size(), tlv.getValue().toString().c_str());
+
+ cert = new CertificateType();
+
+ tlv.enterToValueTLV();
+ if (tlv.decodeTLV())
+ {
+ _DBG("Common Object Attributes");
+
+ /* Common Object Attributes */
+ tlv.enterToValueTLV();
+ while (tlv.decodeTLV())
+ {
+ switch (tlv.getTag())
+ {
+ case (unsigned int)0x0C : /* label : OCTET STRING */
+ buffer = (char *)tlv.getValue().getBuffer();
+ if(buffer != NULL)
+ {
+ _DBG("label : %s", buffer);
+ cert->label.assign(buffer, tlv.getValue().getLength());
+ }
+ break;
+
+ case (unsigned int)0x03 : /* flags : BIT STRING */
+ /* 0 : private, 1 : modifiable */
+ _DBG("flag : %s", tlv.getValue()[0] ? "modifiable" : "private");
+ cert->modifiable = (tlv.getValue()[0] == 1);
+ break;
+
+ default :
+ _DBG("0x%02X [%d] : %s", tlv.getTag(), tlv.size(), tlv.getValue().toString().c_str());
+ break;
+ }
+ }
+ tlv.returnToParentTLV();
+ }
+
+ if (tlv.decodeTLV())
+ {
+ _DBG("Common Certificate Attributes");
+
+ /* Common Certificate Attributes */
+ tlv.enterToValueTLV();
+ while (tlv.decodeTLV())
+ {
+ switch (tlv.getTag())
+ {
+ case (unsigned int)0x04 : /* iD : OCTET STRING */
+ _DBG("id : %s", tlv.getValue().toString().c_str());
+ cert->id = tlv.getValue();
+ break;
+
+ case (unsigned int)0x01 : /* Authority : BOOLEAN */
+ _DBG("authority : %s", tlv.getValue().toString().c_str());
+ cert->authority = tlv.getValue()[0];
+ break;
+
+ case (unsigned int)0xA1 : /* ??? : ??? */
+ tlv.enterToValueTLV();
+ if (tlv.decodeTLV()) {
+ _DBG(" 0x%02X [%d] : %s", tlv.getTag(), tlv.size(), tlv.getValue().toString().c_str());
+ tlv.enterToValueTLV();
+ if (tlv.decodeTLV()) {
+ _DBG(" 0x%02X [%d] : %s", tlv.getTag(), tlv.size(), tlv.getValue().toString().c_str());
+ tlv.enterToValueTLV();
+ if (tlv.decodeTLV()) {
+ _DBG(" 0x%02X [%d] : %s", tlv.getTag(), tlv.size(), tlv.getValue().toString().c_str());
+ tlv.enterToValueTLV();
+ if (tlv.decodeTLV()) {
+ _DBG(" 0x%02X [%d] : %s", tlv.getTag(), tlv.size(), tlv.getValue().toString().c_str());
+ }
+ tlv.returnToParentTLV();
+ }
+ if (tlv.decodeTLV()) {
+ _DBG(" 0x%02X [%d] : %s", tlv.getTag(), tlv.size(), tlv.getValue().toString().c_str());
+ }
+ tlv.returnToParentTLV();
+ }
+ tlv.returnToParentTLV();
+ }
+ tlv.returnToParentTLV();
+ break;
+
+ default :
+ _DBG("0x%02X [%d] : %s", tlv.getTag(), tlv.size(), tlv.getValue().toString().c_str());
+ break;
+ }
+ }
+ tlv.returnToParentTLV();
+ }
+
+ if (tlv.decodeTLV())
+ {
+ _DBG("Certificate Attributes");
+
+ /* Path or Object */
+ tlv.enterToValueTLV();
+ if (tlv.decodeTLV())
+ {
+ tlv.enterToValueTLV();
+ if (tlv.decodeTLV())
+ {
+ /* PATH */
+ tlv.enterToValueTLV();
+ while (tlv.decodeTLV())
+ {
+ switch (tlv.getTag())
+ {
+ case (unsigned int)0x04 : /* path : OCTET STRING */
+ cert->path = tlv.getValue();
+ _DBG("path : %s", cert->path.toString().c_str());
+ break;
+
+ case (unsigned int)0x02 : /* index : INTEGER */
+ cert->index = NumberStream::getBigEndianNumber(tlv.getValue());
+ _DBG("index : %d", cert->index);
+ break;
+
+ case (unsigned int)0x80 : /* length : INTEGER */
+ cert->length = NumberStream::getBigEndianNumber(tlv.getValue());
+ _DBG("length : %d", cert->length);
+ break;
+ }
+ }
+ tlv.returnToParentTLV();
+
+ FileObject file(channel);
+
+ result = file.select(cert->path, true);
+ if (result >= SCARD_ERROR_OK) {
+ result = file.readBinary(0, cert->length, cert->certificate);
+ if (result >= SCARD_ERROR_OK) {
+ _DBG("certificate[%d] : %s", cert->certificate.size(), cert->certificate.toString().c_str());
+ } else {
+ _ERR("readBinary failed, [%x]", result);
+ }
+ } else {
+ _ERR("select failed, [%x]", result);
+ }
+
+ }
+ tlv.returnToParentTLV();
+ }
+ tlv.returnToParentTLV();
+ }
+ tlv.returnToParentTLV();
+
+ listCertType.push_back(cert);
+ }
+
+ _INFO("listCertType.size() = %d", listCertType.size());
+
+ return (listCertType.size() > 0);
+ }
+
+ const CertificateType *PKCS15CDF::getCertificateType(int index) const
+ {
+ if (index < 0 || index >= (int)listCertType.size())
+ return NULL;
+
+ return listCertType[index];
+ }
+} /* namespace smartcard_service_api */
* limitations under the License.
*/
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "Debug.h"
#include "PKCS15DODF.h"
#include "SimpleTLV.h"
_DBG("response : %s", selectResponse.toString().c_str());
- if ((ret = readBinary(0, 0, getFCP()->getFileSize(), dodfData)) == 0)
+ if ((ret = readBinaryAll(0, dodfData)) == 0)
{
- _DBG("odfData : %s", dodfData.toString().c_str());
+ _DBG("dodfData : %s", dodfData.toString().c_str());
parseData(dodfData);
}
_DBG("response : %s", selectResponse.toString().c_str());
- if ((ret = readBinary(0, 0, getFCP()->getFileSize(), dodfData)) == 0)
+ if ((ret = readBinaryAll(0, dodfData)) == 0)
{
_DBG("dodfData : %s", dodfData.toString().c_str());
* limitations under the License.
*/
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "Debug.h"
#include "PKCS15ODF.h"
#include "SimpleTLV.h"
namespace smartcard_service_api
{
+ static const unsigned int ODF_FID = 0x3150;
+
+ static const unsigned int TAG_DODF = (unsigned int)0xA7;
+ static const unsigned int TAG_CDF = (unsigned int)0xA5;
+
PKCS15ODF::PKCS15ODF(Channel *channel) :
- PKCS15Object(channel), dodf(NULL)
+ PKCS15Object(channel), cdf(NULL), dodf(NULL)
{
int ret = 0;
- if ((ret = select(PKCS15ODF::ODF_FID)) >= SCARD_ERROR_OK)
+ if ((ret = select(ODF_FID)) >= SCARD_ERROR_OK)
{
ByteArray odfData, extra;
_DBG("response : %s", selectResponse.toString().c_str());
- if ((ret = readBinary(0, 0, getFCP()->getFileSize(), odfData)) == 0)
+ if ((ret = readBinaryAll(0, odfData)) == 0)
{
_DBG("odfData : %s", odfData.toString().c_str());
int ret = 0;
ByteArray odfData;
- if ((ret = readBinary(0, 0, 0, odfData)) == 0)
+ if ((ret = readBinaryAll(0, odfData)) == 0)
{
_DBG("odfData : %s", odfData.toString().c_str());
{
switch (tlv.getTag())
{
- case (unsigned int)0xA7 ://PKCS15ODF::TAG_DODF :
+ case TAG_DODF :
{
ByteArray dodf;
}
break;
- case (unsigned int)0xA5 ://PKCS15ODF::TAG_TOKENINFO :
+ case TAG_CDF :
{
ByteArray tokeninfo;
- _DBG("TAG_TOKENINFO");
+ _DBG("TAG_CDF");
tokeninfo = PKCS15Object::getOctetStream(tlv.getValue());
if (dodf == NULL)
{
- item = dataList.find((unsigned int)0xA7/*PKCS15ODF::TAG_DODF*/);
+ item = dataList.find(TAG_DODF);
if (item != dataList.end())
{
NumberStream num(item->second);
unsigned int fid = num.getLittleEndianNumber();
- _DBG("fid [%X]", fid);
+ _DBG("dodf fid [%X]", fid);
dodf = new PKCS15DODF(fid, channel);
if (dodf != NULL && dodf->isClosed() == true)
return dodf;
}
+ PKCS15CDF *PKCS15ODF::getCDF()
+ {
+ map<unsigned int, ByteArray>::iterator item;
+
+ if (cdf == NULL)
+ {
+ item = dataList.find(TAG_CDF);
+ if (item != dataList.end())
+ {
+ NumberStream num(item->second);
+ unsigned int fid = num.getLittleEndianNumber();
+
+ _DBG("cdf fid [%X]", fid);
+
+ cdf = new PKCS15CDF(fid, channel);
+ if (cdf != NULL && cdf->isClosed() == true)
+ {
+ _ERR("failed to open CDF");
+
+ delete cdf;
+ cdf = NULL;
+ }
+ }
+ else
+ {
+ _ERR("[%02X] is not found. total [%d]", TAG_CDF, dataList.size());
+ }
+ }
+
+ _DBG("cdf [%p]", cdf);
+
+ return cdf;
+ }
} /* namespace smartcard_service_api */
* limitations under the License.
*/
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "Debug.h"
#include "PKCS15.h"
#include "PKCS15OID.h"
if (tlv.decodeTLV() == true && tlv.getTag() == 0x0C) /* ?? */
{
name = tlv.getValue();
+ SECURE_LOGD("name : %s", name.toString().c_str());
}
tlv.returnToParentTLV();
}
* limitations under the License.
*/
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "Debug.h"
#include "SimpleTLV.h"
#include "PKCS15Object.h"
* limitations under the License.
*/
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "PKCS15Path.h"
namespace smartcard_service_api
* limitations under the License.
*/
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "PKCS15TokenInfo.h"
namespace smartcard_service_api
* limitations under the License.
*/
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "Serializable.h"
namespace smartcard_service_api
#include <list>
#include <string>
#include <vector>
-#include <sys/stat.h>
/* SLP library header */
-#include "package-manager.h"
#include "pkgmgr-info.h"
#include "aul.h"
namespace smartcard_service_api
{
- uid_t ProcGetUsrBypid(int pid)
- {
- char buf[255];
- int ret;
- uid_t uid;
- struct stat dir_stats;
- snprintf(buf, sizeof(buf), "/proc/%d", pid);
- ret = stat(buf, &dir_stats);
- if (ret < 0)
- uid = (uid_t) - 1;
- else
- uid = dir_stats.st_uid;
- return uid;
- }
-
int SignatureHelper::getPackageName(int pid, char *package, size_t length)
{
return aul_app_get_pkgname_bypid(pid, package, length);
}
- const ByteArray SignatureHelper::getCertificationHash(const char *packageName, uid_t uid)
+ const ByteArray SignatureHelper::getCertificationHash(const char *packageName)
{
ByteArray result;
int ret = 0;
- pkgmgr_certinfo_h handle = NULL;
+ pkgmgrinfo_certinfo_h handle = NULL;
pkgmgrinfo_appinfo_h handle_appinfo;
char *pkgid = NULL;
}
pkgmgrinfo_appinfo_destroy_appinfo(handle_appinfo);
- if ((ret = pkgmgr_pkginfo_create_certinfo(&handle)) == 0)
+ SECURE_LOGD("package name : %s, package id : %s", packageName, pkgid);
+
+ if ((ret = pkgmgrinfo_pkginfo_create_certinfo(&handle)) == 0)
{
- if ((ret = pkgmgr_pkginfo_load_certinfo(pkgid, handle, uid)) == 0)
+ if (0)
{
int type;
- for (type = (int)PM_AUTHOR_ROOT_CERT; type <= (int)PM_DISTRIBUTOR2_SIGNER_CERT; type++)
+ for (type = (int)PMINFO_AUTHOR_ROOT_CERT; type <= (int)PMINFO_DISTRIBUTOR2_SIGNER_CERT; type++)
{
const char *value = NULL;
- if ((ret = pkgmgr_pkginfo_get_cert_value(handle, (pkgmgr_cert_type)type, &value)) == 0)
+ if ((ret = pkgmgrinfo_pkginfo_get_cert_value(handle, (pkgmgrinfo_cert_type)type, &value)) == 0)
{
if (value != NULL && strlen(value) > 0)
{
_ERR("pkgmgr_pkginfo_load_certinfo failed [%d]", ret);
}
- pkgmgr_pkginfo_destroy_certinfo(handle);
+ pkgmgrinfo_pkginfo_destroy_certinfo(handle);
}
else
{
ByteArray result;
int error = 0;
char pkgName[256] = { 0, };
- uid_t uid = ProcGetUsrBypid(pid);
if ((error = aul_app_get_pkgname_bypid(pid, pkgName, sizeof(pkgName))) == 0)
{
- result = getCertificationHash(pkgName, uid);
+ result = getCertificationHash(pkgName);
}
else
{
bool result = false;
int error = 0;
char pkgName[256] = { 0, };
- uid_t uid = ProcGetUsrBypid(pid);
if ((error = aul_app_get_pkgname_bypid(pid, pkgName, sizeof(pkgName))) == 0)
{
- result = getCertificationHashes(pkgName, certHashes, uid);
+ result = getCertificationHashes(pkgName, certHashes);
}
else
{
return result;
}
- bool SignatureHelper::getCertificationHashes(const char *packageName, vector<ByteArray> &certHashes, uid_t uid)
+ bool SignatureHelper::getCertificationHashes(const char *packageName, vector<ByteArray> &certHashes)
{
bool result = false;
int ret = 0;
- pkgmgr_certinfo_h handle = NULL;
+ pkgmgrinfo_certinfo_h handle = NULL;
pkgmgrinfo_appinfo_h handle_appinfo;
char *pkgid = NULL;
- if(pkgmgrinfo_appinfo_get_appinfo(packageName, &handle_appinfo) != PMINFO_R_OK)
+ if (pkgmgrinfo_appinfo_get_appinfo(packageName, &handle_appinfo) != PMINFO_R_OK)
{
_ERR("pkgmgrinfo_appinfo_get_appinfo fail");
return result;
}
- if(pkgmgrinfo_appinfo_get_pkgid(handle_appinfo, &pkgid) != PMINFO_R_OK)
+ if (pkgmgrinfo_appinfo_get_pkgid(handle_appinfo, &pkgid) != PMINFO_R_OK)
{
pkgmgrinfo_appinfo_destroy_appinfo(handle_appinfo);
_ERR("pkgmgrinfo_appinfo_get_pkgid fail");
return result;
}
- if ((ret = pkgmgr_pkginfo_create_certinfo(&handle)) == 0)
+ SECURE_LOGD("package name : %s, package id : %s", packageName, pkgid);
+
+ if ((ret = pkgmgrinfo_pkginfo_create_certinfo(&handle)) == 0)
{
- if ((ret = pkgmgr_pkginfo_load_certinfo(pkgid, handle, uid)) == 0)
+ if (0)
{
int type;
- for (type = (int)PM_AUTHOR_ROOT_CERT; type <= (int)PM_DISTRIBUTOR2_SIGNER_CERT; type++)
+ for (type = (int)PMINFO_AUTHOR_ROOT_CERT; type <= (int)PMINFO_DISTRIBUTOR2_SIGNER_CERT; type++)
{
const char *value = NULL;
- if ((ret = pkgmgr_pkginfo_get_cert_value(handle, (pkgmgr_cert_type)type, &value)) == 0)
+ if ((ret = pkgmgrinfo_pkginfo_get_cert_value(handle, (pkgmgrinfo_cert_type)type, &value)) == 0)
{
if (value != NULL && strlen(value) > 0)
{
pkgmgrinfo_appinfo_destroy_appinfo(handle_appinfo);
- pkgmgr_pkginfo_destroy_certinfo(handle);
+ pkgmgrinfo_pkginfo_destroy_certinfo(handle);
}
else
{
certiHash *__signature_helper_vector_to_linked_list(vector<ByteArray> &certHashes)
{
vector<ByteArray>::iterator item;
- certiHash *head, *tail, *tmp;
+ certiHash *head, *tail;
+ uint8_t* buffer = NULL;
head = tail = NULL;
for (item = certHashes.begin(); item != certHashes.end(); item++)
{
+ certiHash *tmp = NULL;
+
if ((tmp = (certiHash *)calloc(1, sizeof(certiHash))) == NULL)
goto ERROR;
goto ERROR;
}
- memcpy(tmp->value, (*item).getBuffer(), tmp->length);
+ buffer = (*item).getBuffer();
+ if(buffer == NULL)
+ {
+ free(tmp->value);
+ free(tmp);
+ continue;
+ }
+
+ memcpy(tmp->value, buffer, tmp->length);
tmp->next = NULL;
if (head == NULL)
tail = tmp;
}
}
+
return head;
ERROR :
_ERR("alloc fail");
+ certiHash *tmp;
+
while (head)
{
tmp = head;
return NULL;
}
-EXTERN_API int signature_helper_get_certificate_hashes(const char *packageName, uid_t uid, certiHash **hash)
+EXTERN_API int signature_helper_get_certificate_hashes(const char *packageName, certiHash **hash)
{
int ret = -1;
vector<ByteArray> hashes;
if (packageName == NULL)
return ret;
- if (SignatureHelper::getCertificationHashes(packageName, hashes, uid) == true)
+ if (SignatureHelper::getCertificationHashes(packageName, hashes) == true)
{
*hash = __signature_helper_vector_to_linked_list(hashes);
ret = 0;
#ifndef APDUHELPER_H_
#define APDUHELPER_H_
-#include "Debug.h"
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "ByteArray.h"
namespace smartcard_service_api
{
- class EXPORT ResponseHelper
+ class ResponseHelper
{
private:
ByteArray response;
// static char *getErrorString();
};
- class EXPORT APDUCommand
+ class APDUCommand
{
private:
typedef struct _command_header_t
// static const unsigned char P1_ = (unsigned char)0x;
static const unsigned char P2_SELECT_GET_FCP = (unsigned char)0x04;
+ static const unsigned char P2_SELECT_GET_FCI = (unsigned char)0x00;
// static const unsigned char P2_ = (unsigned char)0x;
static const unsigned char CLA_CHANNEL_STANDARD = (unsigned char)0x00;
bool getBuffer(ByteArray &array) const;
};
- class EXPORT APDUHelper
+ class APDUHelper
{
public:
static const int COMMAND_OPEN_LOGICAL_CHANNEL = 1;
#ifndef ACCESSCONDITION_H_
#define ACCESSCONDITION_H_
+/* standard library header */
#include <map>
#include <vector>
+/* SLP library header */
+
+/* local header */
#include "ByteArray.h"
using namespace std;
bool nfcRule;
vector<pair<ByteArray, ByteArray> > listFilters;
+ void printAccessRules() const;
+
public :
AccessRule() : apduRule(true), nfcRule(true) {}
ByteArray aid;
map<ByteArray, AccessRule> mapRules;
+ void printAccessConditions() const;
+
public :
AccessCondition() {}
AccessRule *getAccessRule(const ByteArray &certHash);
const AccessRule *getAccessRule(const ByteArray &certHash) const;
+
friend class AccessControlList;
};
#ifndef ACCESSCONTROLLIST_H_
#define ACCESSCONTROLLIST_H_
+/* standard library header */
#include <vector>
#include <map>
+/* SLP library header */
+
+/* local header */
#include "ByteArray.h"
#include "Channel.h"
#include "AccessCondition.h"
const ByteArray &hash) const;
AccessCondition &getAccessCondition(const ByteArray &aid);
+ void printAccessControlList() const;
+
public:
static ByteArray ALL_SE_APPS;
static ByteArray DEFAULT_SE_APP;
int updateACL(Channel *channel) { return loadACL(channel); }
void releaseACL();
+ /* FIXME ??? */
+ inline bool hasConditions() const { return mapConditions.size() > 0; }
+
virtual bool isAuthorizedAccess(const ByteArray &aid,
const ByteArray &certHash) const;
virtual bool isAuthorizedAccess(const unsigned char *aidBuffer,
#ifndef BYTEARRAY_H_
#define BYTEARRAY_H_
+/* standard library header */
#include <string>
#include <stdint.h>
#include <stddef.h>
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
+//#include "Serializable.h"
#define ARRAY_AND_SIZE(x) (uint8_t *)(&x), sizeof(x)
namespace smartcard_service_api
{
- class EXPORT ByteArray //: public Serializable
+ class ByteArray //: public Serializable
{
protected:
uint8_t *buffer;
uint8_t operator [](size_t index) const;
inline bool isEmpty() const { return (buffer == (void *)0 || length == 0); }
+ const string toString(bool entire) const;
const string toString() const;
};
#ifndef CHANNEL_H_
#define CHANNEL_H_
-#include "Debug.h"
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "Synchronous.h"
#include "ByteArray.h"
#include "Exception.h"
unsigned int length, int error, void *userParam);
typedef void (*closeChannelCallback)(int error, void *userParam);
- class EXPORT Channel : public Synchronous
+ class Channel : public Synchronous
{
protected :
ByteArray selectResponse;
+ ByteArray transmitResponse;
SessionHelper *session;
int channelNum;
inline bool isClosed() const throw() { return (channelNum < 0); }
inline const ByteArray getSelectResponse() const throw() { return selectResponse; }
+ inline const ByteArray getTransmitResponse() const throw() { return transmitResponse; }
inline SessionHelper *getSession() const throw() { return session; }
virtual int close(closeChannelCallback callback, void *userParam) = 0;
#ifndef DEBUG_H_
#define DEBUG_H_
+/* standard library header */
#include <iostream>
+/* SLP library header */
#include "dlog.h"
-#ifndef EXPORT
-#define EXPORT __attribute__((visibility("default")))
-#endif
+/* local header */
#define COLOR_BLACK "\033[0;30m"
#define COLOR_RED "\033[0;31m"
#define _BEGIN() \
do \
{ \
- LOGD(COLOR_BLUE"BEGIN >>>>"COLOR_END); \
+ LOGD(COLOR_BLUE "BEGIN >>>>" COLOR_END); \
} \
while (0)
#define _END() \
do \
{ \
- LOGD(COLOR_BLUE"END <<<<"COLOR_END); \
+ LOGD(COLOR_BLUE "END <<<<" COLOR_END); \
} \
while (0)
#ifndef EFDIR_H_
#define EFDIR_H_
+/* standard library header */
#include <vector>
+/* SLP library header */
+
+/* local header */
#include "FileObject.h"
using namespace std;
#include <exception>
#include <stddef.h>
-#include "Debug.h"
#include "smartcard-types.h"
#define THROW_ERROR(errorCode) \
namespace smartcard_service_api
{
- class EXPORT ExceptionBase : public std::exception
+ class ExceptionBase : public std::exception
{
protected :
int errorCode;
}
};
- class EXPORT ErrorIO : public ExceptionBase
+ class ErrorIO : public ExceptionBase
{
private :
unsigned char sw[2];
}
};
- class EXPORT ErrorSecurity : public ExceptionBase
+ class ErrorSecurity : public ExceptionBase
{
public :
ErrorSecurity(int errorCode) throw()
}
};
- class EXPORT ErrorIllegalState : public ExceptionBase
+ class ErrorIllegalState : public ExceptionBase
{
public :
ErrorIllegalState(int errorCode) throw()
}
};
- class EXPORT ErrorIllegalParameter : public ExceptionBase
+ class ErrorIllegalParameter : public ExceptionBase
{
public :
ErrorIllegalParameter(int errorCode) throw()
}
};
- class EXPORT ThrowError
+ class ThrowError
{
public :
static void throwError(int errorCode)
#ifndef FCI_H_
#define FCI_H_
+/* standard library header */
#include <string>
+/* SLP library header */
+
+/* local header */
#include "ByteArray.h"
namespace smartcard_service_api
#ifndef FILEOBJECT_H_
#define FILEOBJECT_H_
+/* standard library header */
#include <vector>
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
#include "ProviderHelper.h"
#include "ByteArray.h"
#include "FCI.h"
namespace smartcard_service_api
{
- class EXPORT FileObject : public ProviderHelper
+ class FileObject : public ProviderHelper
{
private:
FCI fci;
int searchRecord(unsigned int sfi, const ByteArray &searchParam, vector<int> &result);
int readBinary(unsigned int sfi, unsigned int offset, unsigned int length, ByteArray &result);
+ int readBinary(unsigned int sfi, unsigned int length, ByteArray &result);
int writeBinary(unsigned int sfi, const ByteArray &data, unsigned int offset, unsigned int length);
+ int writeBinary(unsigned int sfi, const ByteArray &data);
+
+ int readBinaryAll(unsigned int sfi, ByteArray &result);
};
} /* namespace smartcard_service_api */
#include <glib.h>
-#include "Debug.h"
#include "ByteArray.h"
namespace smartcard_service_api
void *user_param;
};
- class EXPORT GDBusHelper
+ class GDBusHelper
{
public :
static void convertVariantToByteArray(GVariant *var,
#ifndef GPACE_H_
#define GPACE_H_
-#include "Debug.h"
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "smartcard-types.h"
#ifdef __cplusplus
#include "AccessControlList.h"
#ifdef __cplusplus
namespace smartcard_service_api
{
- class EXPORT GPACE : public AccessControlList
+ class GPACE : public AccessControlList
{
private :
AccessControlList *acl;
#ifndef GPARAACL_H_
#define GPARAACL_H_
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "smartcard-types.h"
#ifdef __cplusplus
#include "AccessControlList.h"
#ifndef GPARAM_H_
#define GPARAM_H_
+/* standard library header */
#include <vector>
+/* SLP library header */
+
+/* local header */
#include "FileObject.h"
using namespace std;
#ifndef GPARFACL_H_
#define GPARFACL_H_
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "smartcard-types.h"
#ifdef __cplusplus
#include "AccessControlList.h"
#ifndef ISO7816BERTLV_H_
#define ISO7816BERTLV_H_
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "ByteArray.h"
#include "TLVHelper.h"
#ifndef LOCK_H_
#define LOCK_H_
-#include <pthread.h>
+/* standard library header */
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
+#include "pthread.h"
namespace smartcard_service_api
{
- class EXPORT Lock
+ class Lock
{
public:
virtual ~Lock() {};
#define TOKENPASTE(x, y) x ## y
#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
#define SCOPE_LOCK(X) \
- if (const AutoLockHelper& TOKENPASTE2(lock_, __LINE__) = makeAutoLock(X))
+ if (AutoLockHelper TOKENPASTE2(lock_, __LINE__) = makeAutoLock(X))
- class EXPORT AutoLockHelper
+ class AutoLockHelper
{
public:
inline operator bool() const
};
template<typename T>
- class EXPORT AutoLock : public AutoLockHelper
+ class AutoLock : public AutoLockHelper
{
private:
T *lock;
#ifndef NUMBERSTREAM_H_
#define NUMBERSTREAM_H_
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "ByteArray.h"
namespace smartcard_service_api
* limitations under the License.
*/
+/* standard library header */
#include <stdint.h>
+/* SLP library header */
+
+/* local header */
#include "ByteArray.h"
#ifndef OPENSSLHELPER_H_
#ifndef PKCS15_H_
#define PKCS15_H_
+/* standard library header */
#include <map>
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
#include "PKCS15Object.h"
#include "PKCS15ODF.h"
namespace smartcard_service_api
{
- class EXPORT PKCS15: public PKCS15Object
+ class PKCS15: public PKCS15Object
{
private:
map<unsigned int, ByteArray> recordElement;
int selectFromEFDIR();
public:
- static ByteArray PKCS15_AID;
+ static const ByteArray PKCS15_AID;
PKCS15(Channel *channel);
PKCS15(Channel *channel, const ByteArray &selectResponse);
--- /dev/null
+/*
+ * 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 PKCS15CDF_H_
+#define PKCS15CDF_H_
+
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
+#include "PKCS15Object.h"
+#include "PKCS15OID.h"
+
+namespace smartcard_service_api
+{
+ class CertificateType
+ {
+ public :
+ /* Common Object Attributes */
+ string label;
+ bool modifiable;
+
+ /* Common Certificate Attributes */
+ ByteArray id;
+ int authority;
+
+ /* Certificate Attributes */
+ ByteArray path;
+ int index;
+ size_t length;
+ ByteArray certificate;
+ };
+
+ class PKCS15CDF : public PKCS15Object
+ {
+ private:
+ vector<CertificateType *> listCertType;
+
+ bool parseData(const ByteArray &data);
+
+ public:
+ PKCS15CDF(unsigned int fid, Channel *channel);
+ PKCS15CDF(const ByteArray &path, Channel *channel);
+ ~PKCS15CDF();
+
+ inline size_t getCount() const { return listCertType.size(); }
+ const CertificateType *getCertificateType(int index) const;
+ };
+
+} /* namespace smartcard_service_api */
+#endif /* PKCS15DODF_H_ */
#ifndef PKCS15DODF_H_
#define PKCS15DODF_H_
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "PKCS15Object.h"
#include "PKCS15OID.h"
#ifndef PKCS15ODF_H_
#define PKCS15ODF_H_
+/* standard library header */
#include <map>
+/* SLP library header */
+
+/* local header */
#include "FileObject.h"
+#include "PKCS15CDF.h"
#include "PKCS15DODF.h"
using namespace std;
class PKCS15ODF : public PKCS15Object
{
private:
- bool parseData(const ByteArray &data);
+ PKCS15CDF *cdf;
PKCS15DODF *dodf;
- public:
- static const unsigned int ODF_FID = 0x3150;
-
- static const unsigned int TAG_DODF = (unsigned int)0xA7;
- static const unsigned int TAG_TOKENINFO = (unsigned int)0xA5;
+ bool parseData(const ByteArray &data);
-// PKCS15ODF();
+ public:
PKCS15ODF(Channel *channel);
PKCS15ODF(Channel *channel, const ByteArray &selectResponse);
~PKCS15ODF();
int getPuKDFPath(ByteArray &path);
int getPrKDFPath(ByteArray &path);
int getAODFPath(ByteArray &path);
- int getCDFFPath(ByteArray &path);
+ int getCDFPath(ByteArray &path);
int getDODFPath(ByteArray &path);
+ PKCS15CDF *getCDF();
PKCS15DODF *getDODF();
};
#ifndef PKCS15OID_H_
#define PKCS15OID_H_
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "ByteArray.h"
namespace smartcard_service_api
#ifndef PKCS15OBJECT_H_
#define PKCS15OBJECT_H_
+/* standard library header */
#include <map>
#include <vector>
+/* SLP library header */
+
+/* local header */
#include "FileObject.h"
#include "PKCS15Path.h"
#ifndef PKCS15Path_H_
#define PKCS15Path_H_
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "ByteArray.h"
namespace smartcard_service_api
#ifndef PKCS15TOKENINFO_H_
#define PKCS15TOKENINFO_H_
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "PKCS15Object.h"
namespace smartcard_service_api
#ifndef PROVIDERHELPER_H_
#define PROVIDERHELPER_H_
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "Channel.h"
namespace smartcard_service_api
#ifndef READERHELPER_H_
#define READERHELPER_H_
+/* standard library header */
#include <vector>
#include <string>
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
#include "Synchronous.h"
#include "SessionHelper.h"
typedef void (*openSessionCallback)(SessionHelper *session, int error,
void *userData);
- class EXPORT ReaderHelper : public Synchronous
+ class ReaderHelper : public Synchronous
{
protected:
SEServiceHelper *seService;
#ifndef SESERVICEHELPER_H_
#define SESERVICEHELPER_H_
+/* standard library header */
#include <vector>
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
#include "Synchronous.h"
#include "ReaderHelper.h"
namespace smartcard_service_api
{
- class EXPORT SEServiceHelper : public Synchronous
+ class SEServiceHelper : public Synchronous
{
protected:
vector<ReaderHelper *> readers;
#ifndef SERIALIZABLE_H_
#define SERIALIZABLE_H_
-#include "Debug.h"
#include "ByteArray.h"
namespace smartcard_service_api
{
- class EXPORT Serializable
+ class Serializable
{
virtual const ByteArray serialize() const = 0;
virtual void deserialize(const ByteArray &buffer) = 0;
#ifndef SESSIONHELPER_H_
#define SESSIONHELPER_H_
+/* standard library header */
#include <vector>
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
#include "Synchronous.h"
#include "ByteArray.h"
#include "Channel.h"
typedef void (*closeSessionCallback)(int error, void *userData);
typedef void (*getChannelCountCallback)(unsigned count, int error, void *userData);
- class EXPORT SessionHelper : public Synchronous
+ class SessionHelper : public Synchronous
{
protected:
ReaderHelper *reader;
virtual Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length)
throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
ErrorIllegalParameter &, ErrorSecurity &) = 0;
+
+ virtual Channel *openBasicChannelSync(const ByteArray &aid, unsigned char P2)
+ throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ ErrorIllegalParameter &, ErrorSecurity &) = 0;
+
+ virtual Channel *openBasicChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
+ throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ ErrorIllegalParameter &, ErrorSecurity &) = 0;
+
+ virtual Channel *openLogicalChannelSync(const ByteArray &aid, unsigned char P2)
+ throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ ErrorIllegalParameter &, ErrorSecurity &) = 0;
+
+ virtual Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
+ throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &,
+ ErrorIllegalParameter &, ErrorSecurity &) = 0;
};
} /* namespace smartcard_service_api */
#ifndef SIGNATUREHELPER_H_
#define SIGNATUREHELPER_H_
+/* standard library header */
#ifdef __cplusplus
#include <vector>
-#include "ByteArray.h"
#endif /* __cplusplus */
-#include <sys/types.h>
+/* SLP library header */
-#include "Debug.h"
+/* local header */
#include "smartcard-types.h"
+#ifdef __cplusplus
+#include "ByteArray.h"
+#endif /* __cplusplus */
#ifdef __cplusplus
using namespace std;
namespace smartcard_service_api
{
- class EXPORT SignatureHelper
+ class SignatureHelper
{
public:
static int getPackageName(int pid, char *package, size_t length);
- static const ByteArray getCertificationHash(const char *packageName, uid_t uid);
+ static const ByteArray getCertificationHash(const char *packageName);
static const ByteArray getCertificationHash(int pid);
static bool getCertificationHashes(int pid, vector<ByteArray> &certHashes);
- static bool getCertificationHashes(const char *packageName, vector<ByteArray> &certHashes, uid_t uid);
+ static bool getCertificationHashes(const char *packageName, vector<ByteArray> &certHashes);
};
} /* namespace smartcard_service_api */
#ifndef SYNCHRONOUS_H_
#define SYNCHRONOUS_H_
+/* standard library header */
#include <pthread.h>
-#include "Debug.h"
+/* SLP library header */
+
+/* local header */
namespace smartcard_service_api
{
- class EXPORT Synchronous
+ class Synchronous
{
protected:
pthread_mutex_t syncMutex;
#ifndef TERMINAL_H_
#define TERMINAL_H_
-#include "Debug.h"
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "ByteArray.h"
#include "Synchronous.h"
typedef void (*terminalTransmitCallback)(const unsigned char *buffer, unsigned int length, int error, void *userParam);
typedef void (*terminalGetATRCallback)(const unsigned char *buffer, unsigned int length, int error, void *userParam);
- class EXPORT Terminal : public Synchronous
+ class Terminal : public Synchronous
{
protected:
terminalNotificationCallback statusCallback;
#ifndef TERMINALINTERFACE_H_
#define TERMINALINTERFACE_H_
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
+
//typedef unsigned int terminal_handle_h;
//
//typedef enum
--- /dev/null
+# Package Information for pkg-config
+
+prefix=/usr
+exec_prefix=${prefix}/bin
+includedir=${prefix}/include
+libdir=${prefix}/lib
+
+Name: smartcard-service-common
+Description: Make flags of Common library of Smartcard service
+Version: 1.0
+Requires: glib-2.0 dlog
+Libs: -L${libdir} -lsmartcard-service-common
+Cflags: -I${includedir}/smartcard-service-common
\ No newline at end of file
+++ /dev/null
-prefix=@PREFIX@
-exec_prefix=${prefix}/bin
-libdir=@LIB_INSTALL_DIR@
-includedir=@INCLUDE_INSTALL_DIR@/@COMMON_LIB@
-
-Name: @COMMON_LIB@
-Description: Common library of Smartcard service
-Version: @FULLVER@
-Requires: glib-2.0 dlog
-Libs: -L${libdir} -l@COMMON_LIB@
-Cflags: -I${includedir}
<arg type="u" name="session_id" direction="in" />
<arg type="u" name="type" direction="in" />
<arg type="a(y)" name="aid" direction="in" />
+ <arg type="y" name="P2" direction="in" />
<arg type="i" name="result" direction="out" />
<arg type="u" name="handle" direction="out" />
+ <arg type="i" name="channel_number" direction="out" />
<arg type="a(y)" name="select_response" direction="out" />
</method>
<!--
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<node name="/org/tizen/smartcard_service">
- <interface name="org.tizen.smartcard_service">
- <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="smartcard_service"/>
- <method name="launch">
- <arg type="i" name="result" direction="out"/>
- </method>
- </interface>
-</node>
-
--- /dev/null
+smartcard-service (0.1.0-3) unstable; urgency=low
+
+ * add an exceptional case when is openning client channel (nfc-manager)
+ * Git: slp/pkgs/s/smartcard-service
+ * Tag: smartcard-service_0.1.0-3
+
+ -- Wonkyu Kwon <wonkyu.kwon@samsung.com> Fri, 20 Apr 2012 11:00:00 +0900
+
+smartcard-service (0.1.0-2) unstable; urgency=low
+
+ * add helpers for openssl and package signature
+ * Git: slp/pkgs/s/smartcard-service
+ * Tag: smartcard-service_0.1.0-2
+
+ -- Wonkyu Kwon <wonkyu.kwon@samsung.com> Fri, 23 Mar 2012 12:40:00 +0900
+
+smartcard-service (0.1.0-1) unstable; urgency=low
+
+ * Upload package
+ * Git: slp/pkgs/s/smartcard-service
+ * Tag: smartcard-service_0.1.0-1
+
+ -- Wonkyu Kwon <wonkyu.kwon@samsung.com> Wed, 14 Mar 2012 13:30:00 +0900
+
+smartcard-service (0.0.0-4) unstable; urgency=low
+
+ * Upload package
+ * Git: slp/pkgs/s/smartcard-service
+ * Tag: smartcard-service_0.0.0-4
+
+ -- Wonkyu Kwon <wonkyu.kwon@samsung.com> Tue, 13 Mar 2012 13:10:00 +0900
+
+smartcard-service (0.0.0-3) unstable; urgency=low
+
+ * namespace and macro name change
+ * Git: slp/pkgs/s/smartcard-service
+ * Tag: smartcard-service_0.0.0-3
+
+ -- Sangsoo Lee <constant.lee@samsung.com> Wed, 07 Mar 2012 19:26:46 +0900
+
+smartcard-service (0.0.0-2) unstable; urgency=low
+
+ * getChannelCount api add
+ * Git: slp/pkgs/s/smartcard-service
+ * Tag: smartcard-service_0.0.0-2
+
+ -- Sangsoo Lee <constant.lee@samsung.com> Thu, 23 Feb 2012 21:10:42 +0900
+
+smartcard-service (0.0.0-1) unstable; urgency=low
+
+ * Initial release
+ * Git: slp/pkgs/s/smartcard-service
+ * Tag: smartcard-service_0.0.0-1
+
+ -- Wonkyu Kwon <wonkyu.kwon@samsung.com> Thu, 31 Jan 2012 00:00:00 +0900
--- /dev/null
+Source: smartcard-service
+Priority: extra
+Maintainer: Wonkyu Kwon <wonkyu.kwon@samsung.com>, Sangsoo Lee <constant.lee@samsung.com>, Sungjae Lim <sungjae.lim@samsung.com>, Junyong Sim <junyong.sim@samsung.com>, Sechang Sohn <sc.sohn@samsung.com>
+Build-Depends: debhelper (>= 8.0.0), libglib2.0-dev, libvconf-dev, libsecurity-server-client-dev, dlog-dev, wrt-commons-dev, libaul-1-dev, libssl-dev
+#Build-Depends: debhelper (>= 8.0.0), libglib2.0-dev, libvconf-dev, libsecurity-server-client-dev, dlog-dev, libpkcs11-helper1-dev, wrt-commons, libaul-dev, libssl-dev
+#Standards-Version: 3.9.2
+Section: mixed
+Homepage: <insert the upstream URL, if relevant>
+#Vcs-Git: git://git.debian.org/collab-maint/smartcard-service.git
+#Vcs-Browser: http://git.debian.org/?p=collab-maint/smartcard-service.git;a=summary
+
+Package: smartcard-service-common
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: Common library of Smart card service
+ Common library of Smart card service
+
+Package: smartcard-service-common-dev
+Section: libdevel
+Architecture: any
+Depends: smartcard-service-common (= ${binary:Version})
+Description: Common library of Smart card service
+ Common library of Smart card service
+
+Package: smartcard-service-common-dbg
+Section: debug
+Architecture: any
+Depends: smartcard-service-common (= ${binary:Version})
+Description: Common library of Smart card service (unstripped)
+ Common library of Smart card service (unstripped)
+
+Package: smartcard-service-server
+Architecture: any
+Depends: smartcard-service-common-dev (= ${binary:Version})
+Description: Main process of Smart card service
+ Main process of Smart card service
+
+Package: smartcard-service-server-dbg
+Section: debug
+Architecture: any
+Depends: smartcard-service-server (= ${binary:Version})
+Description: Main process of Smart card service (unstripped)
+ Main process of Smart card service (unstripped)
+
+Package: smartcard-service
+Section: libs
+Architecture: any
+Depends: smartcard-service-common-dev (= ${binary:Version})
+Description: User library of Smart card service
+ User library of Smart card service
+
+Package: smartcard-service-dev
+Section: libdevel
+Architecture: any
+Depends: smartcard-service (= ${binary:Version})
+Description: User library of Smart card service
+ User library of Smart card service
+
+Package: smartcard-service-dbg
+Section: debug
+Architecture: any
+Depends: smartcard-service (= ${binary:Version})
+Description: User library of Smart card service (unstripped)
+ User library of Smart card service (unstripped)
--- /dev/null
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+override_dh_auto_build:
+
+ cd $(CMAKE_BINARY_DIR)
+ dh_auto_build
+
+override_dh_install:
+
+ mkdir -p $(CURDIR)/debian/tmp/etc/init.d
+ mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/
+ mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc5.d/
+
+ cp -af $(CURDIR)/debian/smartcard-service-server.init $(CURDIR)/debian/tmp/etc/init.d/smartcard-service-server
+ ln -s ../init.d/smartcard-service-server $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/S79smartcard-service-server
+ ln -s ../init.d/smartcard-service-server $(CURDIR)/debian/tmp/etc/rc.d/rc5.d/S79smartcard-service-server
+
+ dh_install
+
+override_dh_installinit:
+
+%:
+ dh $@
+
--- /dev/null
+usr/lib
+usr/include
--- /dev/null
+usr/include/smartcard-service-common/*
+#usr/lib/lib*.a
+usr/lib/libsmartcard-service-common.so
+usr/lib/pkgconfig/smartcard-service-common.pc
+#usr/share/pkgconfig/*
--- /dev/null
+usr/lib/libsmartcard-service-common.so.*
--- /dev/null
+usr/lib
+usr/include
--- /dev/null
+usr/include/smartcard-service/*
+#usr/lib/lib*.a
+usr/lib/libsmartcard-service.so
+usr/lib/pkgconfig/smartcard-service.pc
+#usr/share/pkgconfig/*
--- /dev/null
+usr/bin
+etc
\ No newline at end of file
--- /dev/null
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides: smartcard-service-server
+# Required-Start: $network $local_fs
+# Required-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: <Enter a short description of the sortware>
+# Description: <Enter a long description of the software>
+# <...>
+# <...>
+### END INIT INFO
+
+# Author: Wonkyu Kwon <wonkyu.kwon@samsung.com>
+
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
+PATH=/usr/bin
+DESC=smartcard-daemon # Introduce a short description here
+NAME=smartcard-daemon # Introduce the short server's name here
+DAEMON=/usr/bin/smartcard-daemon # Introduce the server's location here
+DAEMON_ARGS="" # Arguments to run the daemon with
+PIDFILE=/var/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
+
+# Exit if the package is not installed
+[ -x $DAEMON ] || exit 0
+
+$DAEMON $DAEMON_ARGS &
\ No newline at end of file
--- /dev/null
+usr/bin/smartcard-daemon
+etc/*
\ No newline at end of file
--- /dev/null
+usr/lib/libsmartcard-service.so.*
--- /dev/null
+Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+ Apache License\r
+ Version 2.0, January 2004\r
+ http://www.apache.org/licenses/\r
+\r
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+ 1. Definitions.\r
+\r
+ "License" shall mean the terms and conditions for use, reproduction,\r
+ and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+ "Licensor" shall mean the copyright owner or entity authorized by\r
+ the copyright owner that is granting the License.\r
+\r
+ "Legal Entity" shall mean the union of the acting entity and all\r
+ other entities that control, are controlled by, or are under common\r
+ control with that entity. For the purposes of this definition,\r
+ "control" means (i) the power, direct or indirect, to cause the\r
+ direction or management of such entity, whether by contract or\r
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+ outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+ "You" (or "Your") shall mean an individual or Legal Entity\r
+ exercising permissions granted by this License.\r
+\r
+ "Source" form shall mean the preferred form for making modifications,\r
+ including but not limited to software source code, documentation\r
+ source, and configuration files.\r
+\r
+ "Object" form shall mean any form resulting from mechanical\r
+ transformation or translation of a Source form, including but\r
+ not limited to compiled object code, generated documentation,\r
+ and conversions to other media types.\r
+\r
+ "Work" shall mean the work of authorship, whether in Source or\r
+ Object form, made available under the License, as indicated by a\r
+ copyright notice that is included in or attached to the work\r
+ (an example is provided in the Appendix below).\r
+\r
+ "Derivative Works" shall mean any work, whether in Source or Object\r
+ form, that is based on (or derived from) the Work and for which the\r
+ editorial revisions, annotations, elaborations, or other modifications\r
+ represent, as a whole, an original work of authorship. For the purposes\r
+ of this License, Derivative Works shall not include works that remain\r
+ separable from, or merely link (or bind by name) to the interfaces of,\r
+ the Work and Derivative Works thereof.\r
+\r
+ "Contribution" shall mean any work of authorship, including\r
+ the original version of the Work and any modifications or additions\r
+ to that Work or Derivative Works thereof, that is intentionally\r
+ submitted to Licensor for inclusion in the Work by the copyright owner\r
+ or by an individual or Legal Entity authorized to submit on behalf of\r
+ the copyright owner. For the purposes of this definition, "submitted"\r
+ means any form of electronic, verbal, or written communication sent\r
+ to the Licensor or its representatives, including but not limited to\r
+ communication on electronic mailing lists, source code control systems,\r
+ and issue tracking systems that are managed by, or on behalf of, the\r
+ Licensor for the purpose of discussing and improving the Work, but\r
+ excluding communication that is conspicuously marked or otherwise\r
+ designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+ "Contributor" shall mean Licensor and any individual or Legal Entity\r
+ on behalf of whom a Contribution has been received by Licensor and\r
+ subsequently incorporated within the Work.\r
+\r
+ 2. Grant of Copyright License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ copyright license to reproduce, prepare Derivative Works of,\r
+ publicly display, publicly perform, sublicense, and distribute the\r
+ Work and such Derivative Works in Source or Object form.\r
+\r
+ 3. Grant of Patent License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ (except as stated in this section) patent license to make, have made,\r
+ use, offer to sell, sell, import, and otherwise transfer the Work,\r
+ where such license applies only to those patent claims licensable\r
+ by such Contributor that are necessarily infringed by their\r
+ Contribution(s) alone or by combination of their Contribution(s)\r
+ with the Work to which such Contribution(s) was submitted. If You\r
+ institute patent litigation against any entity (including a\r
+ cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+ or a Contribution incorporated within the Work constitutes direct\r
+ or contributory patent infringement, then any patent licenses\r
+ granted to You under this License for that Work shall terminate\r
+ as of the date such litigation is filed.\r
+\r
+ 4. Redistribution. You may reproduce and distribute copies of the\r
+ Work or Derivative Works thereof in any medium, with or without\r
+ modifications, and in Source or Object form, provided that You\r
+ meet the following conditions:\r
+\r
+ (a) You must give any other recipients of the Work or\r
+ Derivative Works a copy of this License; and\r
+\r
+ (b) You must cause any modified files to carry prominent notices\r
+ stating that You changed the files; and\r
+\r
+ (c) You must retain, in the Source form of any Derivative Works\r
+ that You distribute, all copyright, patent, trademark, and\r
+ attribution notices from the Source form of the Work,\r
+ excluding those notices that do not pertain to any part of\r
+ the Derivative Works; and\r
+\r
+ (d) If the Work includes a "NOTICE" text file as part of its\r
+ distribution, then any Derivative Works that You distribute must\r
+ include a readable copy of the attribution notices contained\r
+ within such NOTICE file, excluding those notices that do not\r
+ pertain to any part of the Derivative Works, in at least one\r
+ of the following places: within a NOTICE text file distributed\r
+ as part of the Derivative Works; within the Source form or\r
+ documentation, if provided along with the Derivative Works; or,\r
+ within a display generated by the Derivative Works, if and\r
+ wherever such third-party notices normally appear. The contents\r
+ of the NOTICE file are for informational purposes only and\r
+ do not modify the License. You may add Your own attribution\r
+ notices within Derivative Works that You distribute, alongside\r
+ or as an addendum to the NOTICE text from the Work, provided\r
+ that such additional attribution notices cannot be construed\r
+ as modifying the License.\r
+\r
+ You may add Your own copyright statement to Your modifications and\r
+ may provide additional or different license terms and conditions\r
+ for use, reproduction, or distribution of Your modifications, or\r
+ for any such Derivative Works as a whole, provided Your use,\r
+ reproduction, and distribution of the Work otherwise complies with\r
+ the conditions stated in this License.\r
+\r
+ 5. Submission of Contributions. Unless You explicitly state otherwise,\r
+ any Contribution intentionally submitted for inclusion in the Work\r
+ by You to the Licensor shall be under the terms and conditions of\r
+ this License, without any additional terms or conditions.\r
+ Notwithstanding the above, nothing herein shall supersede or modify\r
+ the terms of any separate license agreement you may have executed\r
+ with Licensor regarding such Contributions.\r
+\r
+ 6. Trademarks. This License does not grant permission to use the trade\r
+ names, trademarks, service marks, or product names of the Licensor,\r
+ except as required for reasonable and customary use in describing the\r
+ origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+ 7. Disclaimer of Warranty. Unless required by applicable law or\r
+ agreed to in writing, Licensor provides the Work (and each\r
+ Contributor provides its Contributions) on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+ implied, including, without limitation, any warranties or conditions\r
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+ PARTICULAR PURPOSE. You are solely responsible for determining the\r
+ appropriateness of using or redistributing the Work and assume any\r
+ risks associated with Your exercise of permissions under this License.\r
+\r
+ 8. Limitation of Liability. In no event and under no legal theory,\r
+ whether in tort (including negligence), contract, or otherwise,\r
+ unless required by applicable law (such as deliberate and grossly\r
+ negligent acts) or agreed to in writing, shall any Contributor be\r
+ liable to You for damages, including any direct, indirect, special,\r
+ incidental, or consequential damages of any character arising as a\r
+ result of this License or out of the use or inability to use the\r
+ Work (including but not limited to damages for loss of goodwill,\r
+ work stoppage, computer failure or malfunction, or any and all\r
+ other commercial damages or losses), even if such Contributor\r
+ has been advised of the possibility of such damages.\r
+\r
+ 9. Accepting Warranty or Additional Liability. While redistributing\r
+ the Work or Derivative Works thereof, You may choose to offer,\r
+ and charge a fee for, acceptance of support, warranty, indemnity,\r
+ or other liability obligations and/or rights consistent with this\r
+ License. However, in accepting such obligations, You may act only\r
+ on Your own behalf and on Your sole responsibility, not on behalf\r
+ of any other Contributor, and only if You agree to indemnify,\r
+ defend, and hold each Contributor harmless for any liability\r
+ incurred by, or claims asserted against, such Contributor by reason\r
+ of your accepting any such warranty or additional liability.\r
+\r
+ END OF TERMS AND CONDITIONS\r
+\r
+ APPENDIX: How to apply the Apache License to your work.\r
+\r
+ To apply the Apache License to your work, attach the following\r
+ boilerplate notice, with the fields enclosed by brackets "[]"\r
+ replaced with your own identifying information. (Don't include\r
+ the brackets!) The text should be enclosed in the appropriate\r
+ comment syntax for the file format. We also recommend that a\r
+ file or class name and description of purpose be included on the\r
+ same "printed page" as the copyright notice for easier\r
+ identification within third-party archives.\r
+\r
+ Copyright [yyyy] [name of copyright owner]\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+\r
+\r
--- /dev/null
+Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+ Apache License\r
+ Version 2.0, January 2004\r
+ http://www.apache.org/licenses/\r
+\r
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+ 1. Definitions.\r
+\r
+ "License" shall mean the terms and conditions for use, reproduction,\r
+ and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+ "Licensor" shall mean the copyright owner or entity authorized by\r
+ the copyright owner that is granting the License.\r
+\r
+ "Legal Entity" shall mean the union of the acting entity and all\r
+ other entities that control, are controlled by, or are under common\r
+ control with that entity. For the purposes of this definition,\r
+ "control" means (i) the power, direct or indirect, to cause the\r
+ direction or management of such entity, whether by contract or\r
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+ outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+ "You" (or "Your") shall mean an individual or Legal Entity\r
+ exercising permissions granted by this License.\r
+\r
+ "Source" form shall mean the preferred form for making modifications,\r
+ including but not limited to software source code, documentation\r
+ source, and configuration files.\r
+\r
+ "Object" form shall mean any form resulting from mechanical\r
+ transformation or translation of a Source form, including but\r
+ not limited to compiled object code, generated documentation,\r
+ and conversions to other media types.\r
+\r
+ "Work" shall mean the work of authorship, whether in Source or\r
+ Object form, made available under the License, as indicated by a\r
+ copyright notice that is included in or attached to the work\r
+ (an example is provided in the Appendix below).\r
+\r
+ "Derivative Works" shall mean any work, whether in Source or Object\r
+ form, that is based on (or derived from) the Work and for which the\r
+ editorial revisions, annotations, elaborations, or other modifications\r
+ represent, as a whole, an original work of authorship. For the purposes\r
+ of this License, Derivative Works shall not include works that remain\r
+ separable from, or merely link (or bind by name) to the interfaces of,\r
+ the Work and Derivative Works thereof.\r
+\r
+ "Contribution" shall mean any work of authorship, including\r
+ the original version of the Work and any modifications or additions\r
+ to that Work or Derivative Works thereof, that is intentionally\r
+ submitted to Licensor for inclusion in the Work by the copyright owner\r
+ or by an individual or Legal Entity authorized to submit on behalf of\r
+ the copyright owner. For the purposes of this definition, "submitted"\r
+ means any form of electronic, verbal, or written communication sent\r
+ to the Licensor or its representatives, including but not limited to\r
+ communication on electronic mailing lists, source code control systems,\r
+ and issue tracking systems that are managed by, or on behalf of, the\r
+ Licensor for the purpose of discussing and improving the Work, but\r
+ excluding communication that is conspicuously marked or otherwise\r
+ designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+ "Contributor" shall mean Licensor and any individual or Legal Entity\r
+ on behalf of whom a Contribution has been received by Licensor and\r
+ subsequently incorporated within the Work.\r
+\r
+ 2. Grant of Copyright License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ copyright license to reproduce, prepare Derivative Works of,\r
+ publicly display, publicly perform, sublicense, and distribute the\r
+ Work and such Derivative Works in Source or Object form.\r
+\r
+ 3. Grant of Patent License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ (except as stated in this section) patent license to make, have made,\r
+ use, offer to sell, sell, import, and otherwise transfer the Work,\r
+ where such license applies only to those patent claims licensable\r
+ by such Contributor that are necessarily infringed by their\r
+ Contribution(s) alone or by combination of their Contribution(s)\r
+ with the Work to which such Contribution(s) was submitted. If You\r
+ institute patent litigation against any entity (including a\r
+ cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+ or a Contribution incorporated within the Work constitutes direct\r
+ or contributory patent infringement, then any patent licenses\r
+ granted to You under this License for that Work shall terminate\r
+ as of the date such litigation is filed.\r
+\r
+ 4. Redistribution. You may reproduce and distribute copies of the\r
+ Work or Derivative Works thereof in any medium, with or without\r
+ modifications, and in Source or Object form, provided that You\r
+ meet the following conditions:\r
+\r
+ (a) You must give any other recipients of the Work or\r
+ Derivative Works a copy of this License; and\r
+\r
+ (b) You must cause any modified files to carry prominent notices\r
+ stating that You changed the files; and\r
+\r
+ (c) You must retain, in the Source form of any Derivative Works\r
+ that You distribute, all copyright, patent, trademark, and\r
+ attribution notices from the Source form of the Work,\r
+ excluding those notices that do not pertain to any part of\r
+ the Derivative Works; and\r
+\r
+ (d) If the Work includes a "NOTICE" text file as part of its\r
+ distribution, then any Derivative Works that You distribute must\r
+ include a readable copy of the attribution notices contained\r
+ within such NOTICE file, excluding those notices that do not\r
+ pertain to any part of the Derivative Works, in at least one\r
+ of the following places: within a NOTICE text file distributed\r
+ as part of the Derivative Works; within the Source form or\r
+ documentation, if provided along with the Derivative Works; or,\r
+ within a display generated by the Derivative Works, if and\r
+ wherever such third-party notices normally appear. The contents\r
+ of the NOTICE file are for informational purposes only and\r
+ do not modify the License. You may add Your own attribution\r
+ notices within Derivative Works that You distribute, alongside\r
+ or as an addendum to the NOTICE text from the Work, provided\r
+ that such additional attribution notices cannot be construed\r
+ as modifying the License.\r
+\r
+ You may add Your own copyright statement to Your modifications and\r
+ may provide additional or different license terms and conditions\r
+ for use, reproduction, or distribution of Your modifications, or\r
+ for any such Derivative Works as a whole, provided Your use,\r
+ reproduction, and distribution of the Work otherwise complies with\r
+ the conditions stated in this License.\r
+\r
+ 5. Submission of Contributions. Unless You explicitly state otherwise,\r
+ any Contribution intentionally submitted for inclusion in the Work\r
+ by You to the Licensor shall be under the terms and conditions of\r
+ this License, without any additional terms or conditions.\r
+ Notwithstanding the above, nothing herein shall supersede or modify\r
+ the terms of any separate license agreement you may have executed\r
+ with Licensor regarding such Contributions.\r
+\r
+ 6. Trademarks. This License does not grant permission to use the trade\r
+ names, trademarks, service marks, or product names of the Licensor,\r
+ except as required for reasonable and customary use in describing the\r
+ origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+ 7. Disclaimer of Warranty. Unless required by applicable law or\r
+ agreed to in writing, Licensor provides the Work (and each\r
+ Contributor provides its Contributions) on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+ implied, including, without limitation, any warranties or conditions\r
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+ PARTICULAR PURPOSE. You are solely responsible for determining the\r
+ appropriateness of using or redistributing the Work and assume any\r
+ risks associated with Your exercise of permissions under this License.\r
+\r
+ 8. Limitation of Liability. In no event and under no legal theory,\r
+ whether in tort (including negligence), contract, or otherwise,\r
+ unless required by applicable law (such as deliberate and grossly\r
+ negligent acts) or agreed to in writing, shall any Contributor be\r
+ liable to You for damages, including any direct, indirect, special,\r
+ incidental, or consequential damages of any character arising as a\r
+ result of this License or out of the use or inability to use the\r
+ Work (including but not limited to damages for loss of goodwill,\r
+ work stoppage, computer failure or malfunction, or any and all\r
+ other commercial damages or losses), even if such Contributor\r
+ has been advised of the possibility of such damages.\r
+\r
+ 9. Accepting Warranty or Additional Liability. While redistributing\r
+ the Work or Derivative Works thereof, You may choose to offer,\r
+ and charge a fee for, acceptance of support, warranty, indemnity,\r
+ or other liability obligations and/or rights consistent with this\r
+ License. However, in accepting such obligations, You may act only\r
+ on Your own behalf and on Your sole responsibility, not on behalf\r
+ of any other Contributor, and only if You agree to indemnify,\r
+ defend, and hold each Contributor harmless for any liability\r
+ incurred by, or claims asserted against, such Contributor by reason\r
+ of your accepting any such warranty or additional liability.\r
+\r
+ END OF TERMS AND CONDITIONS\r
+\r
+ APPENDIX: How to apply the Apache License to your work.\r
+\r
+ To apply the Apache License to your work, attach the following\r
+ boilerplate notice, with the fields enclosed by brackets "[]"\r
+ replaced with your own identifying information. (Don't include\r
+ the brackets!) The text should be enclosed in the appropriate\r
+ comment syntax for the file format. We also recommend that a\r
+ file or class name and description of purpose be included on the\r
+ same "printed page" as the copyright notice for easier\r
+ identification within third-party archives.\r
+\r
+ Copyright [yyyy] [name of copyright owner]\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+\r
+\r
+++ /dev/null
-<manifest>
- <request>
- <domain name="_" />
- </request>
-</manifest>
+++ /dev/null
-<manifest>
- <request>
- <domain name="_" />
- </request>
-</manifest>
+++ /dev/null
-<manifest>
- <request>
- <domain name="_" />
- </request>
-</manifest>
--- /dev/null
+Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+ Apache License\r
+ Version 2.0, January 2004\r
+ http://www.apache.org/licenses/\r
+\r
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+ 1. Definitions.\r
+\r
+ "License" shall mean the terms and conditions for use, reproduction,\r
+ and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+ "Licensor" shall mean the copyright owner or entity authorized by\r
+ the copyright owner that is granting the License.\r
+\r
+ "Legal Entity" shall mean the union of the acting entity and all\r
+ other entities that control, are controlled by, or are under common\r
+ control with that entity. For the purposes of this definition,\r
+ "control" means (i) the power, direct or indirect, to cause the\r
+ direction or management of such entity, whether by contract or\r
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+ outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+ "You" (or "Your") shall mean an individual or Legal Entity\r
+ exercising permissions granted by this License.\r
+\r
+ "Source" form shall mean the preferred form for making modifications,\r
+ including but not limited to software source code, documentation\r
+ source, and configuration files.\r
+\r
+ "Object" form shall mean any form resulting from mechanical\r
+ transformation or translation of a Source form, including but\r
+ not limited to compiled object code, generated documentation,\r
+ and conversions to other media types.\r
+\r
+ "Work" shall mean the work of authorship, whether in Source or\r
+ Object form, made available under the License, as indicated by a\r
+ copyright notice that is included in or attached to the work\r
+ (an example is provided in the Appendix below).\r
+\r
+ "Derivative Works" shall mean any work, whether in Source or Object\r
+ form, that is based on (or derived from) the Work and for which the\r
+ editorial revisions, annotations, elaborations, or other modifications\r
+ represent, as a whole, an original work of authorship. For the purposes\r
+ of this License, Derivative Works shall not include works that remain\r
+ separable from, or merely link (or bind by name) to the interfaces of,\r
+ the Work and Derivative Works thereof.\r
+\r
+ "Contribution" shall mean any work of authorship, including\r
+ the original version of the Work and any modifications or additions\r
+ to that Work or Derivative Works thereof, that is intentionally\r
+ submitted to Licensor for inclusion in the Work by the copyright owner\r
+ or by an individual or Legal Entity authorized to submit on behalf of\r
+ the copyright owner. For the purposes of this definition, "submitted"\r
+ means any form of electronic, verbal, or written communication sent\r
+ to the Licensor or its representatives, including but not limited to\r
+ communication on electronic mailing lists, source code control systems,\r
+ and issue tracking systems that are managed by, or on behalf of, the\r
+ Licensor for the purpose of discussing and improving the Work, but\r
+ excluding communication that is conspicuously marked or otherwise\r
+ designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+ "Contributor" shall mean Licensor and any individual or Legal Entity\r
+ on behalf of whom a Contribution has been received by Licensor and\r
+ subsequently incorporated within the Work.\r
+\r
+ 2. Grant of Copyright License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ copyright license to reproduce, prepare Derivative Works of,\r
+ publicly display, publicly perform, sublicense, and distribute the\r
+ Work and such Derivative Works in Source or Object form.\r
+\r
+ 3. Grant of Patent License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ (except as stated in this section) patent license to make, have made,\r
+ use, offer to sell, sell, import, and otherwise transfer the Work,\r
+ where such license applies only to those patent claims licensable\r
+ by such Contributor that are necessarily infringed by their\r
+ Contribution(s) alone or by combination of their Contribution(s)\r
+ with the Work to which such Contribution(s) was submitted. If You\r
+ institute patent litigation against any entity (including a\r
+ cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+ or a Contribution incorporated within the Work constitutes direct\r
+ or contributory patent infringement, then any patent licenses\r
+ granted to You under this License for that Work shall terminate\r
+ as of the date such litigation is filed.\r
+\r
+ 4. Redistribution. You may reproduce and distribute copies of the\r
+ Work or Derivative Works thereof in any medium, with or without\r
+ modifications, and in Source or Object form, provided that You\r
+ meet the following conditions:\r
+\r
+ (a) You must give any other recipients of the Work or\r
+ Derivative Works a copy of this License; and\r
+\r
+ (b) You must cause any modified files to carry prominent notices\r
+ stating that You changed the files; and\r
+\r
+ (c) You must retain, in the Source form of any Derivative Works\r
+ that You distribute, all copyright, patent, trademark, and\r
+ attribution notices from the Source form of the Work,\r
+ excluding those notices that do not pertain to any part of\r
+ the Derivative Works; and\r
+\r
+ (d) If the Work includes a "NOTICE" text file as part of its\r
+ distribution, then any Derivative Works that You distribute must\r
+ include a readable copy of the attribution notices contained\r
+ within such NOTICE file, excluding those notices that do not\r
+ pertain to any part of the Derivative Works, in at least one\r
+ of the following places: within a NOTICE text file distributed\r
+ as part of the Derivative Works; within the Source form or\r
+ documentation, if provided along with the Derivative Works; or,\r
+ within a display generated by the Derivative Works, if and\r
+ wherever such third-party notices normally appear. The contents\r
+ of the NOTICE file are for informational purposes only and\r
+ do not modify the License. You may add Your own attribution\r
+ notices within Derivative Works that You distribute, alongside\r
+ or as an addendum to the NOTICE text from the Work, provided\r
+ that such additional attribution notices cannot be construed\r
+ as modifying the License.\r
+\r
+ You may add Your own copyright statement to Your modifications and\r
+ may provide additional or different license terms and conditions\r
+ for use, reproduction, or distribution of Your modifications, or\r
+ for any such Derivative Works as a whole, provided Your use,\r
+ reproduction, and distribution of the Work otherwise complies with\r
+ the conditions stated in this License.\r
+\r
+ 5. Submission of Contributions. Unless You explicitly state otherwise,\r
+ any Contribution intentionally submitted for inclusion in the Work\r
+ by You to the Licensor shall be under the terms and conditions of\r
+ this License, without any additional terms or conditions.\r
+ Notwithstanding the above, nothing herein shall supersede or modify\r
+ the terms of any separate license agreement you may have executed\r
+ with Licensor regarding such Contributions.\r
+\r
+ 6. Trademarks. This License does not grant permission to use the trade\r
+ names, trademarks, service marks, or product names of the Licensor,\r
+ except as required for reasonable and customary use in describing the\r
+ origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+ 7. Disclaimer of Warranty. Unless required by applicable law or\r
+ agreed to in writing, Licensor provides the Work (and each\r
+ Contributor provides its Contributions) on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+ implied, including, without limitation, any warranties or conditions\r
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+ PARTICULAR PURPOSE. You are solely responsible for determining the\r
+ appropriateness of using or redistributing the Work and assume any\r
+ risks associated with Your exercise of permissions under this License.\r
+\r
+ 8. Limitation of Liability. In no event and under no legal theory,\r
+ whether in tort (including negligence), contract, or otherwise,\r
+ unless required by applicable law (such as deliberate and grossly\r
+ negligent acts) or agreed to in writing, shall any Contributor be\r
+ liable to You for damages, including any direct, indirect, special,\r
+ incidental, or consequential damages of any character arising as a\r
+ result of this License or out of the use or inability to use the\r
+ Work (including but not limited to damages for loss of goodwill,\r
+ work stoppage, computer failure or malfunction, or any and all\r
+ other commercial damages or losses), even if such Contributor\r
+ has been advised of the possibility of such damages.\r
+\r
+ 9. Accepting Warranty or Additional Liability. While redistributing\r
+ the Work or Derivative Works thereof, You may choose to offer,\r
+ and charge a fee for, acceptance of support, warranty, indemnity,\r
+ or other liability obligations and/or rights consistent with this\r
+ License. However, in accepting such obligations, You may act only\r
+ on Your own behalf and on Your sole responsibility, not on behalf\r
+ of any other Contributor, and only if You agree to indemnify,\r
+ defend, and hold each Contributor harmless for any liability\r
+ incurred by, or claims asserted against, such Contributor by reason\r
+ of your accepting any such warranty or additional liability.\r
+\r
+ END OF TERMS AND CONDITIONS\r
+\r
+ APPENDIX: How to apply the Apache License to your work.\r
+\r
+ To apply the Apache License to your work, attach the following\r
+ boilerplate notice, with the fields enclosed by brackets "[]"\r
+ replaced with your own identifying information. (Don't include\r
+ the brackets!) The text should be enclosed in the appropriate\r
+ comment syntax for the file format. We also recommend that a\r
+ file or class name and description of purpose be included on the\r
+ same "printed page" as the copyright notice for easier\r
+ identification within third-party archives.\r
+\r
+ Copyright [yyyy] [name of copyright owner]\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+\r
+\r
+++ /dev/null
-<manifest>
- <request>
- <domain name="_" />
- </request>
-</manifest>
+++ /dev/null
-* Sun Aug 25 2013 Chengwei Yang <chengwei.yang@intel.com>
-- Remove debian packaging stuff
-
-* Wed May 29 2013 Baptiste DURAND <baptiste.durand@eurogiciel.fr> accepted/tizen/20130523.160330@6952ac6
-- Fix compatibility for x64 arch
-
-* Wed May 22 2013 Rusty Lynch <rusty.lynch@intel.com> accepted/tizen/20130520.101306@173a4a8
-- Cleanup the package spec
-- Fix build for Tizen 3.0
+++ /dev/null
-<manifest>
- <request>
- <domain name="_" />
- </request>
-</manifest>
%global use_autostart "-DUSE_AUTOSTART=1"
#%%global test_client "-DTEST_CLIENT=1"
+################################################################################
+# package : smartcard-service #
+################################################################################
Name: smartcard-service
-Summary: Smartcard Service
-Version: 0.1.30
+Summary: Smartcard Service FW
+Version: 0.1.43
Release: 0
-Group: Network & Connectivity/Service
+Group: libs
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
%if 0%{!?use_autostart:1}
-Source1: smartcard-service-server.init
+Source1: %{name}-server.init
%endif
BuildRequires: cmake
-Source1001: %{name}.manifest
-Source1002: %{name}-devel.manifest
-Source1003: smartcard-service-common.manifest
-Source1004: smartcard-service-common-devel.manifest
-Source1005: smartcard-service-server.manifest
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(gio-unix-2.0)
+BuildRequires: pkgconfig(security-server)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(aul)
BuildRequires: pkgconfig(libssl)
BuildRequires: pkgconfig(pkgmgr-info)
BuildRequires: python
BuildRequires: python-xml
+BuildRequires: hash-signer
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
-Requires: smartcard-service-common = %{version}-%{release}
+Requires: %{name}-common = %{version}-%{release}
%description
-A library for Smartcard applications.
+Smartcard Service FW.
-%prep
-%setup -q
-cp %{SOURCE1001} %{SOURCE1002} %{SOURCE1003} %{SOURCE1004} %{SOURCE1005} .
+%files
+%manifest %{name}.manifest
+%defattr(-,root,root,-)
+%{_libdir}/lib%{name}.so.*
+%{_datadir}/license/%{name}
+
+
+%post
+/sbin/ldconfig
+%postun
+/sbin/ldconfig
+
+
+################################################################################
+# package : smartcard-service-devel #
+################################################################################
%package devel
-Summary: Smartcard service
-Group: Network & Connectivity/Development
+Summary: smartcard service devel
+Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
-%description devel
-For developing Smartcard applications.
+%description devel
+smartcard service.
-%package -n smartcard-service-common
-Summary: Common smartcard service
-Group: Network & Connectivity/Service
-%description -n smartcard-service-common
-Common smartcard service for developing internally
+%files devel
+%manifest %{name}-devel.manifest
+%defattr(-,root,root,-)
+%{_includedir}/%{name}/*
+%{_libdir}/lib%{name}.so
+%{_libdir}/pkgconfig/%{name}.pc
-%package -n smartcard-service-common-devel
-Summary: Common smartcard service
-Group: Network & Connectivity/Development
-Requires: smartcard-service-common = %{version}-%{release}
+################################################################################
+# package : smartcard-service-common #
+################################################################################
+%package common
+Summary: common smartcard service
+Group: Development/Libraries
-%description -n smartcard-service-common-devel
-For developing smartcard services internally.
+%description common
+common smartcard service.
-%package -n smartcard-service-server
-Summary: Smartcard service server
-Group: Network & Connectivity/Service
-Requires: smartcard-service-common = %{version}-%{release}
-%description -n smartcard-service-server
-Server for smartcard service
+%files common
+%manifest %{name}-common.manifest
+%defattr(-,root,root,-)
+%{_libdir}/lib%{name}-common.so.*
+%{_datadir}/license/%{name}-common
-%build
-MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-%cmake . %{?use_autostart} %{?test_client} -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+################################################################################
+# package : smartcard-service-common-devel #
+################################################################################
+%package common-devel
+Summary: common smartcard service
+Group: Development/Libraries
+Requires: %{name}-common = %{version}-%{release}
-%install
-%make_install
-%if 0%{!?use_autostart:1}
- %__mkdir -p %{buildroot}/etc/init.d/
- %__mkdir -p %{buildroot}/etc/rc.d/rc3.d/
- %__mkdir -p %{buildroot}/etc/rc.d/rc5.d/
- %__cp -af %SOURCE1 %{buildroot}/etc/init.d/smartcard-service-server
- chmod 755 %{buildroot}/etc/init.d/smartcard-service-server
-%endif
-%post
-/sbin/ldconfig
-%if 0%{!?use_autostart:1}
- ln -sf /etc/init.d/smartcard-service-server /etc/rc.d/rc3.d/S79smartcard-service-server
- ln -sf /etc/init.d/smartcard-service-server /etc/rc.d/rc5.d/S79smartcard-service-server
-%endif
+%description common-devel
+common smartcard service.
-%postun
-/sbin/ldconfig
-%if 0%{!?use_autostart:1}
- rm -f /etc/rc.d/rc3.d/S79smartcard-service-server
- rm -f /etc/rc.d/rc5.d/S79smartcard-service-server
-%endif
-%post -n smartcard-service-common
-/sbin/ldconfig
+%files common-devel
+%manifest %{name}-common-devel.manifest
+%defattr(-,root,root,-)
+%{_includedir}/%{name}-common/*
+%{_libdir}/lib%{name}-common.so
+%{_libdir}/pkgconfig/%{name}-common.pc
-%postun -n smartcard-service-common
-/sbin/ldconfig
+################################################################################
+# package : smartcard-service-server #
+################################################################################
+%global bindir /usr/apps/%{name}-server
-%files
-%manifest %{name}.manifest
-%defattr(-,root,root,-)
-%{_libdir}/libsmartcard-service.so.*
-%license LICENSE.APLv2
+%package server
+Summary: server smartcard service
+Group: Development/Libraries
+Requires: %{name}-common = %{version}-%{release}
-%files devel
-%manifest smartcard-service-devel.manifest
-%defattr(-,root,root,-)
-%{_includedir}/%{name}/*
-%{_libdir}/libsmartcard-service.so
-%{_libdir}/pkgconfig/%{name}.pc
+%description server
+smartcard service server
-%files -n smartcard-service-common
-%manifest smartcard-service-common.manifest
-%defattr(-,root,root,-)
-%{_libdir}/libsmartcard-service-common.so.*
-%license LICENSE.APLv2
+%post server
+/usr/bin/signing-client/hash-signer-client.sh -a -d -p platform %{bindir}
+%if 0%{!?use_autostart:1}
+ ln -sf /etc/init.d/%{name}-server /etc/rc.d/rc3.d/S79%{name}-server
+ ln -sf /etc/init.d/%{name}-server /etc/rc.d/rc5.d/S79%{name}-server
+%endif
+ln -sf /usr/apps/%{name}-server/bin/smartcard-daemon /usr/bin/smartcard-daemon
+%if 0%{?test_client:1}
+ ln -sf /usr/apps/%{name}-server/bin/smartcard-test-client /usr/bin/smartcard-test-client
+%endif
-%files -n smartcard-service-common-devel
-%manifest smartcard-service-common-devel.manifest
-%defattr(-,root,root,-)
-%{_includedir}/smartcard-service-common/*
-%{_libdir}/libsmartcard-service-common.so
-%{_libdir}/pkgconfig/smartcard-service-common.pc
+%postun server
+%if 0%{!?use_autostart:1}
+ rm -f /etc/rc.d/rc3.d/S79%{name}-server
+ rm -f /etc/rc.d/rc5.d/S79%{name}-server
+%endif
+rm -f /usr/bin/smartcard-daemon
-%files -n smartcard-service-server
-%manifest smartcard-service-server.manifest
+%files server
+%manifest %{name}-server.manifest
%defattr(-,root,root,-)
-%{_bindir}/smartcard-daemon
-%{_datadir}/packages/smartcard-service-server.xml
+%{bindir}/bin/smartcard-daemon
+%{_datadir}/packages/%{name}-server.xml
%if 0%{?test_client:1}
- %{_bindir}/smartcard-test-client
+ %{bindir}/bin/smartcard-test-client
%endif
%if 0%{?use_autostart:1}
- %{_datadir}/dbus-1/system-services/org.tizen.smartcard_service.service
+ %{_datadir}/dbus-1/system-services/org.tizen.SmartcardService.service
%else
- %{_sysconfdir}/init.d/smartcard-service-server
+ %{_sysconfdir}/init.d/%{name}-server
+%endif
+%{bindir}/%{name}-server
+%{bindir}/author-signature.xml
+%{bindir}/signature1.xml
+
+
+################################################################################
+# common... #
+################################################################################
+%prep
+%setup -q
+
+
+%build
+%if 0%{?sec_build_binary_debug_enable}
+export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
+export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
+export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
+%endif
+export LDFLAGS+="-Wl,-Bsymbolic-functions"
+mkdir obj-arm-limux-qnueabi
+cd obj-arm-limux-qnueabi
+%cmake .. -DCMAKE_INSTALL_PREFIX=%{_prefix} %{?use_autostart} %{?use_gdbus} %{?test_client}
+#make %{?jobs:-j%jobs}
+
+
+%install
+cd obj-arm-limux-qnueabi
+%make_install
+%if 0%{!?use_autostart:1}
+ %__mkdir -p %{buildroot}/etc/init.d/
+ %__mkdir -p %{buildroot}/etc/rc.d/rc3.d/
+ %__mkdir -p %{buildroot}/etc/rc.d/rc5.d/
+ %__cp -af %SOURCE1 %{buildroot}/etc/init.d/%{name}-server
+ chmod 755 %{buildroot}/etc/init.d/%{name}-server
%endif
-%license LICENSE.APLv2
+mkdir -p %{buildroot}/usr/share/license
+cp -af %{_builddir}/%{name}-%{version}/packaging/%{name} %{buildroot}/usr/share/license/
+cp -af %{_builddir}/%{name}-%{version}/packaging/%{name}-common %{buildroot}/usr/share/license/
+cp -af %{_builddir}/%{name}-%{version}/packaging/%{name}-server %{buildroot}%{bindir}
+
+%define tizen_sign 1
+%define tizen_sign_base %{bindir}
+%define tizen_sign_level platform
+%define tizen_author_sign 1
+%define tizen_dist_sign 1
-LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
-INCLUDE_DIRECTORIES(include)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common/include)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(smartcard-daemon CXX)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../common)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../common/include)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/ SRCS)
-pkg_check_modules(pkgs_server REQUIRED glib-2.0 gio-2.0 gio-unix-2.0 dlog)
+### for private
+ADD_DEFINITIONS("-D__PRIVATE")
+
+FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
+EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
+ " \\
+ --generate-c-code ${CMAKE_CURRENT_SOURCE_DIR}/private/access-control-gdbus \\
+ --c-namespace SmartcardService\\
+ --interface-prefix org.tizen.SmartcardService. \\
+ ${CMAKE_CURRENT_SOURCE_DIR}/private/access-control-gdbus.xml \\
+ ")
+
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/private SRCS)
+##############
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+ SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+
+# pkg config
+INCLUDE(FindPkgConfig)
+
+SET(PKG_MODULE glib-2.0 gio-2.0 gio-unix-2.0 security-server dlog)
+
+pkg_check_modules(pkgs_server REQUIRED ${PKG_MODULE})
+
FOREACH(flag ${pkgs_server_CFLAGS})
SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} ${flag}")
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS}")
+MESSAGE("CHECK MODULE in ${PROJECT_NAME} ${pkgs_server_LDFLAGS}")
+
+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(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+
+SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} -pipe -fomit-frame-pointer -Wall -Wno-trigraphs -fno-strict-aliasing -Wl,-zdefs -fvisibility=hidden -std=c++0x")
+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} -fPIC")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" MATCHES "^arm.*")
+ ADD_DEFINITIONS("-DTARGET")
+ MESSAGE("add -DTARGET")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARM_CXXFLAGS}")
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARM_CFLAGS}")
+ENDIF()
+
+ADD_DEFINITIONS("-DPREFIX=\"/usr/apps/smartcard-service-server\"")
ADD_DEFINITIONS("-DLOG_TAG=\"SMARTCARD_SERVICE_SERVER\"")
-ADD_EXECUTABLE(${DAEMON} ${SRCS})
-TARGET_LINK_LIBRARIES(${DAEMON} ${pkgs_server_LDFLAGS} ${COMMON_LIB} dl)
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_server_LDFLAGS} "-L../common" "-lsmartcard-service-common" "-pie -ldl")
-INSTALL(TARGETS ${DAEMON} DESTINATION bin)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/apps/smartcard-service-server/bin)
IF("${USE_AUTOSTART}" STREQUAL "1")
- INSTALL(FILES org.tizen.smartcard_service.service DESTINATION share/dbus-1/system-services)
+ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.tizen.SmartcardService.service DESTINATION share/dbus-1/system-services)
ENDIF()
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/smartcard-service-server.xml DESTINATION share/packages)
* limitations under the License.
*/
+/* standard library header */
#include <pthread.h>
+/* SLP library header */
+
+/* local header */
#include "Debug.h"
#include "ClientInstance.h"
#include "ServerResource.h"
* limitations under the License.
*/
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "Debug.h"
#include "ServerChannel.h"
#include "APDUHelper.h"
{
/* close channel */
command = apdu.generateAPDU(APDUHelper::COMMAND_CLOSE_LOGICAL_CHANNEL, channelNum, ByteArray::EMPTY);
+
+ _DBG("command [%d] : %s", command.size(), command.toString().c_str());
+
rv = terminal->transmitSync(command, result);
if (rv == 0 && result.size() >= 2)
* limitations under the License.
*/
+/* standard library header */
#include <unistd.h>
#include <glib.h>
#include <gio/gio.h>
#include <string>
#include <sys/socket.h>
+/* SLP library header */
+#ifdef USER_SPACE_SMACK
+#include "security-server.h"
+#endif
+
+/* local header */
#include "smartcard-types.h"
#include "Debug.h"
#include "ByteArray.h"
using namespace std;
+#ifdef __PRIVATE
+extern "C" bool smartcard_service_init_access_control(void *connection);
+extern "C" void smartcard_service_deinit_access_control();
+#endif
+
namespace smartcard_service_api
{
GDBusDispatcher::GDBusDispatcher() : Synchronous()
initReader();
initSession();
initChannel();
-
+#ifdef __PRIVATE
+ smartcard_service_init_access_control(connection);
+#endif
return true;
}
void ServerGDBus::deinit()
{
+#ifdef __PRIVATE
+ smartcard_service_deinit_access_control();
+#endif
deinitChannel();
deinitSession();
deinitReader();
const char *rights)
{
bool result = true;
- /*TODO : apply cynara api */
+#ifdef USER_SPACE_SMACK
+ pid_t pid;
+ const char *name;
+ ClientInstance *instance;
+
+ name = g_dbus_method_invocation_get_sender(invocation);
+
+ instance = ServerResource::getInstance().getClient(name);
+ if (instance != NULL) {
+ pid = instance->getPID();
+ } else {
+ pid = ServerGDBus::getInstance().getPID(name);
+ }
+
+ result = (security_server_check_privilege_by_pid(
+ pid,
+ "smartcard-service",
+ rights) == SECURITY_SERVER_API_SUCCESS);
+#endif
return result;
}
static gboolean __process_shutdown(SmartcardServiceSeService *object,
GDBusMethodInvocation *invocation,
- intptr_t handle, void *user_data)
+ guint handle, void *user_data)
{
const char *name;
{
SmartcardServiceSeService *object;
GDBusMethodInvocation *invocation;
- intptr_t handle;
+ guint handle;
void *user_data;
if (params.size() != 4) {
object = (SmartcardServiceSeService *)params[0];
invocation = (GDBusMethodInvocation *)params[1];
- handle = (intptr_t)params[2];
+ handle = 0;//(guint)params[2];
user_data = params[3];
__process_shutdown(object, invocation, handle, user_data);
static gboolean _handle_shutdown(SmartcardServiceSeService *object,
GDBusMethodInvocation *invocation,
- intptr_t handle,
+ guint handle,
void *user_data)
{
vector<void *> params;
*
*/
static gboolean __process_open_session(SmartcardServiceReader *object,
- GDBusMethodInvocation *invocation, intptr_t service_id,
- intptr_t reader_id, void *user_data)
+ GDBusMethodInvocation *invocation, guint service_id,
+ guint reader_id, void *user_data)
{
unsigned int handle = IntegerHandle::INVALID_HANDLE;
int result;
{
SmartcardServiceReader *object;
GDBusMethodInvocation *invocation;
- intptr_t service_id;
- intptr_t reader_id;
+ guint service_id;
+ guint reader_id;
void *user_data;
if (params.size() != 5) {
object = (SmartcardServiceReader *)params[0];
invocation = (GDBusMethodInvocation *)params[1];
- service_id = (intptr_t)params[2];
- reader_id = (intptr_t)params[3];
+ service_id = 0;//(guint)params[2];
+ reader_id = 0;//(guint)params[3];
user_data = params[4];
__process_open_session(object, invocation, service_id,
static gboolean _handle_open_session(SmartcardServiceReader *object,
GDBusMethodInvocation *invocation,
- intptr_t service_id,
- intptr_t reader_id, void *user_data)
+ guint service_id,
+ guint reader_id, void *user_data)
{
vector<void *> params;
*
*/
static gboolean __process_close_session(SmartcardServiceSession *object,
- GDBusMethodInvocation *invocation, intptr_t service_id,
- intptr_t session_id, void *user_data)
+ GDBusMethodInvocation *invocation, guint service_id,
+ guint session_id, void *user_data)
{
const char *name;
{
SmartcardServiceSession *object;
GDBusMethodInvocation *invocation;
- intptr_t service_id;
- intptr_t session_id;
+ guint service_id;
+ guint session_id;
void *user_data;
if (params.size() != 5) {
object = (SmartcardServiceSession *)params[0];
invocation = (GDBusMethodInvocation *)params[1];
- service_id = (intptr_t)params[2];
- session_id = (intptr_t)params[3];
+ service_id = 0;//(guint)params[2];
+ session_id = 0;//(guint)params[3];
user_data = params[4];
__process_close_session(object, invocation, service_id,
static gboolean _handle_close_session(SmartcardServiceSession *object,
GDBusMethodInvocation *invocation,
- intptr_t service_id,
- intptr_t session_id, void *user_data)
+ guint service_id,
+ guint session_id, void *user_data)
{
vector<void *> params;
}
static gboolean __process_get_atr(SmartcardServiceSession *object,
- GDBusMethodInvocation *invocation, intptr_t service_id,
- intptr_t session_id, void *user_data)
+ GDBusMethodInvocation *invocation, guint service_id,
+ guint session_id, void *user_data)
{
int result;
ByteArray resp;
terminal = client->getTerminal(session_id);
if (terminal != NULL) {
- int rv;
-
if (terminal->open() == true) {
- rv = terminal->getATRSync(resp);
- if (rv < SCARD_ERROR_OK) {
+ result = terminal->getATRSync(resp);
+ if (result < SCARD_ERROR_OK) {
_ERR("getATRSync failed : name [%s], service_id [%d], session_id [%d]", name, service_id, session_id);
-
- result = rv;
}
terminal->close();
{
SmartcardServiceSession *object;
GDBusMethodInvocation *invocation;
- intptr_t service_id;
- intptr_t session_id;
+ guint service_id;
+ guint session_id;
void *user_data;
if (params.size() != 5) {
object = (SmartcardServiceSession *)params[0];
invocation = (GDBusMethodInvocation *)params[1];
- service_id = (intptr_t)params[2];
- session_id = (intptr_t)params[3];
+ service_id = 0;//(guint)params[2];
+ session_id = 0;//(guint)params[3];
user_data = params[4];
__process_get_atr(object, invocation, service_id,
static gboolean _handle_get_atr(SmartcardServiceSession *object,
GDBusMethodInvocation *invocation,
- intptr_t service_id,
- intptr_t session_id, void *user_data)
+ guint service_id,
+ guint session_id, void *user_data)
{
vector<void *> params;
}
static gboolean __process_open_channel(SmartcardServiceSession *object,
- GDBusMethodInvocation *invocation, intptr_t service_id,
- intptr_t session_id, intptr_t type, GVariant *aid, void *user_data)
+ GDBusMethodInvocation *invocation, guint service_id,
+ guint session_id, guint type, GVariant *aid, guint8 P2, void *user_data)
{
+ int channelNum = -1;
int result = SCARD_ERROR_UNKNOWN;
ByteArray resp;
GVariant *response = NULL;
const char *name;
_INFO("[MSG_REQUEST_OPEN_CHANNEL]");
+ _INFO("P2 is %x", P2);
ServerResource &resource = ServerResource::getInstance();
name, service_id, channelID);
if (temp != NULL) {
resp = temp->getSelectResponse();
-
+ channelNum = temp->getChannelNumber();
result = SCARD_ERROR_OK;
}
+ else{
+ _ERR("getChannel is failed");
+ result = SCARD_ERROR_UNAVAILABLE;
+ }
} else {
_ERR("channel is null.");
/* response to client */
smartcard_service_session_complete_open_channel(object,
- invocation, result, channelID, response);
+ invocation, result, channelID, channelNum, response);
return true;
}
{
SmartcardServiceSession *object;
GDBusMethodInvocation *invocation;
- intptr_t service_id;
- intptr_t session_id;
- intptr_t type;
+ guint service_id;
+ guint session_id;
+ guint type;
+ guint8 P2;
GVariant *aid;
void *user_data;
- if (params.size() != 7) {
+ if (params.size() != 8) {
_ERR("invalid parameter");
return;
object = (SmartcardServiceSession *)params[0];
invocation = (GDBusMethodInvocation *)params[1];
- service_id = (intptr_t)params[2];
- session_id = (intptr_t)params[3];
- type = (intptr_t)params[4];
+ service_id = 0;//(guint)params[2];
+ session_id = 0;//(guint)params[3];
+ type = 0;//(guint)params[4];
aid = (GVariant *)params[5];
- user_data = params[6];
+ P2 = 0;//(guint8)((int)params[6]);
+ user_data = params[7];
__process_open_channel(object, invocation, service_id,
- session_id, type, aid, user_data);
+ session_id, type, aid, P2, user_data);
g_object_unref(object);
g_object_unref(invocation);
- g_object_unref(aid);
+ g_variant_unref(aid);
}
static gboolean _handle_open_channel(SmartcardServiceSession *object,
GDBusMethodInvocation *invocation,
- intptr_t service_id,
- intptr_t session_id, intptr_t type, GVariant *aid, void *user_data)
+ guint service_id,
+ guint session_id, guint type, GVariant *aid, guint8 P2, void *user_data)
{
vector<void *> params;
params.push_back((void *)session_id);
params.push_back((void *)type);
- g_object_ref(aid);
+ g_variant_ref(aid);
params.push_back((void *)aid);
+ params.push_back((void *)((int)P2));
params.push_back(user_data);
GDBusDispatcher::push(_process_open_channel, params);
invocation,
SCARD_ERROR_SECURITY_NOT_ALLOWED,
IntegerHandle::INVALID_HANDLE,
+ -1,
GDBusHelper::convertByteArrayToVariant(resp));
}
*
*/
static gboolean __process_close_channel(SmartcardServiceChannel *object,
- GDBusMethodInvocation *invocation, intptr_t service_id,
- intptr_t channel_id, void *user_data)
+ GDBusMethodInvocation *invocation, guint service_id,
+ guint channel_id, void *user_data)
{
int result;
const char *name;
{
SmartcardServiceChannel *object;
GDBusMethodInvocation *invocation;
- intptr_t service_id;
- intptr_t channel_id;
+ guint service_id;
+ guint channel_id;
void *user_data;
if (params.size() != 5) {
object = (SmartcardServiceChannel *)params[0];
invocation = (GDBusMethodInvocation *)params[1];
- service_id = (intptr_t)params[2];
- channel_id = (intptr_t)params[3];
+ service_id = 0;//(guint)params[2];
+ channel_id = 0;//(guint)params[3];
user_data = params[4];
__process_close_channel(object, invocation, service_id,
static gboolean _handle_close_channel(SmartcardServiceChannel *object,
GDBusMethodInvocation *invocation,
- intptr_t service_id, intptr_t channel_id, void *user_data)
+ guint service_id, guint channel_id, void *user_data)
{
vector<void *> params;
static gboolean __process_transmit(SmartcardServiceChannel *object,
GDBusMethodInvocation *invocation,
- intptr_t service_id,
- intptr_t channel_id,
+ guint service_id,
+ guint channel_id,
GVariant *command,
void *user_data)
{
{
SmartcardServiceChannel *object;
GDBusMethodInvocation *invocation;
- intptr_t service_id;
- intptr_t channel_id;
+ guint service_id;
+ guint channel_id;
GVariant *command;
void *user_data;
object = (SmartcardServiceChannel *)params[0];
invocation = (GDBusMethodInvocation *)params[1];
- service_id = (intptr_t)params[2];
- channel_id = (intptr_t)params[3];
+ service_id = 0;//(guint)params[2];
+ channel_id = 0;//(guint)params[3];
command = (GVariant *)params[4];
user_data = params[5];
static gboolean _handle_transmit(SmartcardServiceChannel *object,
GDBusMethodInvocation *invocation,
- intptr_t service_id,
- intptr_t channel_id,
+ guint service_id,
+ guint channel_id,
GVariant *command,
void *user_data)
{
return (((instance = getService(name, handle)) != NULL) && (instance->isVaildSessionHandle(session)));
}
+ bool ServerResource::isValidChannelHandle(const char *name, unsigned int handle, unsigned int channel)
+ {
+ ServiceInstance *instance = NULL;
+
+ return (((instance = getService(name, handle)) != NULL) && (instance->isVaildChannelHandle(channel)));
+ }
+
unsigned int ServerResource::getChannelCount(const char *name, unsigned int handle, unsigned int sessionID)
{
unsigned int result = -1;
/* open channel */
command = APDUHelper::generateAPDU(APDUHelper::COMMAND_OPEN_LOGICAL_CHANNEL, 0, ByteArray::EMPTY);
+
+ _DBG("command [%d] : %s", command.size(), command.toString().c_str());
+
rv = terminal->transmitSync(command, response);
if (rv == 0 && response.size() >= 2)
{
/* open channel */
command = APDUHelper::generateAPDU(APDUHelper::COMMAND_CLOSE_LOGICAL_CHANNEL, channelNum, ByteArray::EMPTY);
+
+ _DBG("command [%d] : %s", command.size(), command.toString().c_str());
+
rv = terminal->transmitSync(command, response);
if (rv == 0 && response.size() >= 2)
{
}
channel = service->getChannel(result);
+ if(channel == NULL)
+ {
+ _ERR("channel is null.");
+
+ throw ExceptionBase(SCARD_ERROR_OUT_OF_MEMORY);
+ }
/* check */
if (_isAuthorizedAccess(channel, aid,
strncmp(entry->d_name, "..", 2) != 0)
{
char fullPath[1024];
-
/* TODO : need additional name rule :) */
/* append each files */
snprintf(fullPath, sizeof(fullPath),
"%s/%s", OMAPI_SE_PATH, entry->d_name);
+ SECURE_LOGD("se name [%s]", fullPath);
+
result = appendSELibrary(fullPath);
}
}
}
}
+ ServerChannel *ServerResource::createInternalChannel(Terminal *terminal,
+ int channelType)
+ {
+ int channelNum = 0;
+ ServerChannel *channel = NULL;
+
+ /* open logical channel */
+ if (channelType == 1)
+ {
+ channelNum = _openLogicalChannel(terminal);
+ if (channelNum > 0)
+ {
+ _DBG("channelNum [%d]", channelNum);
+ }
+ else
+ {
+ _ERR("_openLogicalChannel failed [%d]", channelNum);
+ throw ExceptionBase(SCARD_ERROR_NOT_ENOUGH_RESOURCE);
+ }
+ }
+
+ /* create channel instance */
+ channel = new ServerChannel(NULL, NULL, channelNum, terminal);
+
+ return channel;
+ }
+
bool ServerResource::isAuthorizedNFCAccess(Terminal *terminal,
const ByteArray &aid, const vector<ByteArray> &hashes)
{
bool result = false;
+ ServerChannel *channel;
if (terminal == NULL) {
return result;
}
- int num = _openLogicalChannel(terminal);
- if (num > 0) {
- /* create channel instance */
- ServerChannel *channel = new ServerChannel(NULL, NULL, num, terminal);
- if (channel != NULL) {
- AccessControlList *acl = getAccessControlList(channel);
- if (acl == NULL) {
-
- /* load access control defined by Global Platform */
- acl = new GPACE();
- if (acl != NULL) {
- int ret;
-
- ret = acl->loadACL(channel);
- if (ret >= SCARD_ERROR_OK) {
- addAccessControlList(channel, acl);
- } else {
- _ERR("unknown error, 0x%x", -ret);
-
- delete acl;
- acl = NULL;
- }
+ channel = createInternalChannel(terminal, 1);
+ if (channel != NULL) {
+ AccessControlList *acl = getAccessControlList(channel);
+ if (acl == NULL) {
+
+ /* load access control defined by Global Platform */
+ acl = new GPACE();
+ if (acl != NULL) {
+ int ret;
+
+ ret = acl->loadACL(channel);
+ if (ret >= SCARD_ERROR_OK) {
+ addAccessControlList(channel, acl);
} else {
- _ERR("alloc failed");
+ _ERR("unknown error, 0x%x", -ret);
+
+ delete acl;
+ acl = NULL;
}
} else {
- acl->updateACL(channel);
+ _ERR("alloc failed");
}
+ } else {
+ acl->updateACL(channel);
+ }
+
+ if (acl != NULL) {
+ result = acl->isAuthorizedNFCAccess(aid, hashes);
+ } else {
+ _ERR("acl is null");
+ }
+
+ delete channel;
+ } else {
+ _ERR("alloc failed");
+ }
+
+ return result;
+ }
+
+ bool ServerResource::isAuthorizedAccess(Terminal *terminal,
+ const ByteArray &aid, const vector<ByteArray> &hashes)
+ {
+ bool result = false;
+ ServerChannel *channel;
+
+ if (terminal == NULL) {
+ return result;
+ }
+ channel = createInternalChannel(terminal, 1);
+ if (channel != NULL) {
+ AccessControlList *acl = getAccessControlList(channel);
+ if (acl == NULL) {
+
+ /* load access control defined by Global Platform */
+ acl = new GPACE();
if (acl != NULL) {
- result = acl->isAuthorizedNFCAccess(aid, hashes);
+ int ret;
+
+ ret = acl->loadACL(channel);
+ if (ret >= SCARD_ERROR_OK) {
+ addAccessControlList(channel, acl);
+ } else {
+ _ERR("unknown error, 0x%x", -ret);
+
+ delete acl;
+ acl = NULL;
+ }
} else {
- _ERR("acl is null");
+ _ERR("alloc failed");
}
+ } else {
+ acl->updateACL(channel);
+ }
- delete channel;
+ if (acl != NULL) {
+ result = acl->isAuthorizedAccess(aid, hashes);
} else {
- _ERR("alloc failed");
+ _ERR("acl is null");
}
+
+ delete channel;
} else {
- _ERR("_openLogicalChannel failed");
+ _ERR("alloc failed");
}
return result;
int ServerSEService::openSELibraries()
{
int result;
- void *libHandle;
DIR *dir = NULL;
struct dirent *entry = NULL;
/* need additional name rule :) */
/* open each files */
- libHandle = NULL;
snprintf(fullPath, sizeof(fullPath), "%s/%s", OMAPI_SE_PATH, entry->d_name);
+ SECURE_LOGD("se name [%s]", fullPath);
+
result = appendSELibrary(fullPath);
}
}
}
}
+#if 0
+ bool ServerSEService::isValidReaderHandle(void *handle)
+ {
+ bool result = false;
+ size_t i;
+
+ for (i = 0; i < readers.size(); i++)
+ {
+ if ((void *)readers[i] == handle)
+ {
+ result = true;
+ break;
+ }
+ }
+
+ return false;
+ }
+#endif
+
void ServerSEService::terminalCallback(const void *terminal, int event, int error, void *user_param)
{
switch (event)
{
case Terminal::NOTIFY_SE_AVAILABLE :
{
- // TODO: add right se reader
+ /* add right se reader */
+// if ((term = ServerResource::getInstance().getTerminal((char *)terminal)) != NULL)
+// {
+// _DBG("terminal : [%s]", (char *)terminal);
+//
+// term->initialize();
+// }
+// else
+// {
+// _DBG("unknown terminal : [%s]", (char *)terminal);
+// }
}
break;
case Terminal::NOTIFY_SE_NOT_AVAILABLE :
{
- // TODO: remove right se reader
+ /* remove right se reader */
+// if ((term = ServerResource::getInstance().getTerminal((char *)terminal)) != NULL)
+// {
+// _DBG("terminal : [%s]", (char *)terminal);
+//
+// term->finalize();
+// }
+// else
+// {
+// _DBG("unknown terminal : [%s]", (char *)terminal);
+// }
}
break;
Channel *ServerSession::openBasicChannelSync(const ByteArray &aid)
throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
- return openBasicChannelSync(aid, NULL);
+ return openBasicChannelSync(aid, (void *)NULL);
+ }
+
+ Channel *ServerSession::openBasicChannelSync(const ByteArray &aid, unsigned char P2)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
+ {
+ return openBasicChannelSync(aid, (void *)NULL);
}
Channel *ServerSession::openBasicChannelSync(const ByteArray &aid, void *caller)
throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
ServerChannel *channel = NULL;
+#if 0
+ AccessControlList *acList = NULL;
+ ByteArray command, result;
+ int channelID = 0;
+ int rv = 0;
+
+ _BEGIN();
+
+ acList = ((ServerReader *)reader)->getAccessControlList();
+ if (acList == NULL)
+ {
+ _ERR("acList is null");
+
+ return channel;
+ }
+
+ if (acList->isAuthorizedAccess(aid, certHashes) == false)
+ {
+ _ERR("unauthorized access, aid : %s", aid.toString().c_str());
+
+ return channel;
+ }
+
+ /* select aid */
+ command = APDUHelper::generateAPDU(APDUHelper::COMMAND_SELECT_BY_DF_NAME, channelID, aid);
+ rv = terminal->transmitSync(command, result);
+ if (rv == 0 && result.size() >= 2)
+ {
+ ResponseHelper resp(result);
+
+ if (resp.getStatus() == 0)
+ {
+ channel = new ServerChannel(this, caller, channelID, terminal);
+ if (channel != NULL)
+ {
+ channel->selectResponse = result;
+
+ channels.push_back(channel);
+ }
+ else
+ {
+ _ERR("alloc failed");
+ }
+ }
+ else
+ {
+ _ERR("status word [ %02X %02X ]", resp.getSW1(), resp.getSW2());
+ }
+ }
+ else
+ {
+ _ERR("select apdu is failed, rv [%d], length [%d]", rv, result.size());
+ }
+#endif
return channel;
}
Channel *ServerSession::openBasicChannelSync(const unsigned char *aid, unsigned int length)
throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
+ unsigned char P2 = 0x00;
+ ByteArray temp(aid, length);
+
+ return openBasicChannelSync(temp, P2);
+ }
+
+ Channel *ServerSession::openBasicChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
+ {
ByteArray temp(aid, length);
- return openBasicChannelSync(temp);
+ return openBasicChannelSync(temp, P2);
}
Channel *ServerSession::openBasicChannelSync(const unsigned char *aid, unsigned int length, void *caller)
Channel *ServerSession::openLogicalChannelSync(const ByteArray &aid)
throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
- return openLogicalChannelSync(aid, NULL);
+ void* caller;
+ return openLogicalChannelSync(aid, caller);
+ }
+
+ Channel *ServerSession::openLogicalChannelSync(const ByteArray &aid, unsigned char P2)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
+ {
+ void* caller;
+ return openLogicalChannelSync(aid, caller);
}
Channel *ServerSession::openLogicalChannelSync(const ByteArray &aid, void *caller)
throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
ServerChannel *channel = NULL;
+#if 0
+ AccessControlList *acList = NULL;
+ ByteArray command, result;
+ int channelID = 1;
+ int rv;
+
+ acList = ((ServerReader *)reader)->getAccessControlList();
+ if (acList == NULL)
+ {
+ _ERR("unauthorized access, aid %s, hash %s");
+
+ return channel;
+ }
+
+ if (acList->isAuthorizedAccess(aid, certHashes) == false)
+ {
+ _ERR("unauthorized access, aid : %s", aid.toString().c_str());
+
+ return channel;
+ }
+
+ /* open channel */
+ command = APDUHelper::generateAPDU(APDUHelper::COMMAND_OPEN_LOGICAL_CHANNEL, 0, ByteArray::EMPTY);
+ rv = terminal->transmitSync(command, result);
+
+ if (rv == 0 && result.size() >= 2)
+ {
+ ResponseHelper resp(result);
+
+ if (resp.getStatus() == 0)
+ {
+ channelID = resp.getDataField()[0];
+ }
+ else
+ {
+ _ERR("status word [ %02X %02X ]", resp.getSW1(), resp.getSW2());
+
+ return channel;
+ }
+ }
+ else
+ {
+ _ERR("select apdu is failed, rv [%d], length [%d]", rv, result.size());
+
+ return channel;
+ }
+
+ /* select aid */
+ command = APDUHelper::generateAPDU(APDUHelper::COMMAND_SELECT_BY_DF_NAME, channelID, aid);
+ rv = terminal->transmitSync(command, result);
+
+ if (rv == 0 && result.size() >= 2)
+ {
+ ResponseHelper resp(result);
+
+ if (resp.getStatus() == 0)
+ {
+ channel = new ServerChannel(this, caller, channelID, terminal);
+ if (channel == NULL)
+ {
+ _ERR("alloc failed");
+
+ return NULL;
+ }
+
+ channel->selectResponse = result;
+
+ channels.push_back(channel);
+ }
+ else
+ {
+ _ERR("status word [ %02X %02X ]", resp.getSW1(), resp.getSW2());
+ }
+ }
+ else
+ {
+ _ERR("select apdu is failed, rv [%d], length [%d]", rv, result.size());
+ }
+#endif
return channel;
}
Channel *ServerSession::openLogicalChannelSync(const unsigned char *aid, unsigned int length)
throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
{
+ unsigned char P2 = 0x00;
+ ByteArray temp(aid, length);
+
+ return openLogicalChannelSync(temp, P2);
+ }
+
+ Channel *ServerSession::openLogicalChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &)
+ {
ByteArray temp(aid, length);
- return openLogicalChannelSync(temp, NULL);
+ return openLogicalChannelSync(temp, P2);
}
Channel *ServerSession::openLogicalChannelSync(const unsigned char *aid, unsigned int length, void *caller)
#ifndef CLIENTINSTANCE_H_
#define CLIENTINSTANCE_H_
+/* standard library header */
#include <map>
#include <vector>
#include <string>
+/* SLP library header */
+
+/* local header */
#include "ServiceInstance.h"
namespace smartcard_service_api
#ifndef SERVERCHANNEL_H_
#define SERVERCHANNEL_H_
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
#include "Channel.h"
#include "Terminal.h"
#include "ServerSession.h"
#ifndef SERVERGDBUS_H_
#define SERVERGDBUS_H_
+/* standard library header */
#include <glib.h>
#include <queue>
#include <vector>
+/* SLP library header */
+
+/* local header */
#include "Synchronous.h"
#include "GDBusHelper.h"
#include "smartcard-service-gdbus.h"
unsigned int getChannelCount(const char *name, unsigned int handle, unsigned int sessionID);
void removeSession(const char *name, unsigned int handle, unsigned int session);
bool isValidSessionHandle(const char *name, unsigned int handle, unsigned int sessionID);
+ bool isValidChannelHandle(const char *name, unsigned int handle, unsigned int channelID);
unsigned int createChannel(const char *name, unsigned int handle,
unsigned int sessionID, int channelType, ByteArray aid)
AccessControlList *getAccessControlList(ServerChannel *channel);
bool isAuthorizedNFCAccess(Terminal *terminal, const ByteArray &aid,
const vector<ByteArray> &hashes);
+ bool isAuthorizedAccess(Terminal *terminal,
+ const ByteArray &aid, const vector<ByteArray> &hashes);
void finish();
+ /* FIXME ??? */
+ ServerChannel *createInternalChannel(Terminal *terminal,
+ int channelType);
+
friend void terminalCallback(void *terminal, int event, int error, void *user_param);
};
public:
static ServerSEService &getInstance();
+#if 0
+ bool isValidReaderHandle(void *handle);
+#endif
+
void shutdown() {}
void shutdownSync() {}
throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
Channel *openBasicChannelSync(const unsigned char *aid, unsigned int length)
throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
+ Channel *openBasicChannelSync(const ByteArray &aid, unsigned char P2)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
+ Channel *openBasicChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
Channel *openBasicChannelSync(const ByteArray &aid, void *caller)
throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
Channel *openBasicChannelSync(const unsigned char *aid, unsigned int length, void *caller)
throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length)
throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
+ Channel *openLogicalChannelSync(const ByteArray &aid, unsigned char P2)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
+ Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length, unsigned char P2)
+ throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
Channel *openLogicalChannelSync(const ByteArray &aid, void *caller)
throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &);
Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length, void *caller)
typedef struct _Smartcard_Service Smartcard_Service;
typedef struct _Smartcard_ServiceClass Smartcard_ServiceClass;
-#define SMARTCARD_SERVICE_NAME "org.tizen.smartcard_service"
-#define SMARTCARD_SERVICE_PATH "/org/tizen/smartcard_service"
+#define SMARTCARD_SERVICE_NAME "org.tizen.SmartcardService"
+#define SMARTCARD_SERVICE_PATH "/org/tizen/SmartcardService"
GType smartcard_service_get_type(void);
--- /dev/null
+[D-BUS Service]
+Name=org.tizen.SmartcardService
+Exec=/usr/apps/smartcard-service-server/bin/smartcard-daemon
+MemoryLimit=10M
+User=root
\ No newline at end of file
+++ /dev/null
-[D-BUS Service]
-Name=org.tizen.SmartcardService
-Exec=/usr/bin/smartcard-daemon
-User=root
--- /dev/null
+/*
+ * 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 <glib.h>
+#include <gio/gio.h>
+#include <map>
+
+/* SLP library header */
+#ifdef USER_SPACE_SMACK
+#include "security-server.h"
+#endif
+
+/* local header */
+#include "Debug.h"
+#include "APDUHelper.h"
+#include "ServerResource.h"
+#include "SignatureHelper.h"
+#include "ServerGDBus.h"
+#include "PKCS15CDFACL.h"
+#include "access-control-gdbus.h"
+
+using namespace std;
+using namespace smartcard_service_api;
+
+static SmartcardServiceAccessControl *access_control;
+static map<string, ByteArray> mapGranted;
+static PKCS15CDFACL cdfAcl;
+
+static void _load_granted_package_info()
+{
+ mapGranted.clear();
+
+ /* TODO : load information form file */
+ mapGranted.insert(make_pair("nfc-manager", ByteArray::EMPTY));
+}
+
+static gboolean _compare_hash(char *package, ByteArray &hash)
+{
+ gboolean result = false;
+ vector<ByteArray> hashes;
+
+ /* get certificate hashes by pid */
+ if (SignatureHelper::getCertificationHashes(package, hashes) == true) {
+ vector<ByteArray>::iterator item;
+
+ for (item = hashes.begin(); item != hashes.end(); item++) {
+ if (*item == hash) {
+ result = true;
+ break;
+ }
+ }
+ } else {
+ _ERR("getCertificationHashes failed, [%s]", package);
+ }
+
+ return result;
+}
+
+static gboolean _check_permission(pid_t pid)
+{
+ gboolean result = false;
+ char package[1024];
+
+ if (SignatureHelper::getPackageName(pid,
+ package, sizeof(package)) == 0) {
+ map<string, ByteArray>::iterator item;
+
+ item = mapGranted.find(package);
+ if (item != mapGranted.end()) {
+ /* TODO : check privilege */
+ if (false) {
+ result = _compare_hash(package, item->second);
+ } else {
+ result = true;
+ }
+ }
+ } else {
+ _ERR("aul_app_get_pkgname_bypid failed");
+ }
+
+ return result;
+}
+
+static bool _get_se_name(unsigned int se_type, char *buf, size_t len)
+{
+ bool result = false;
+
+ switch ((se_type >> 4) & 0x0F) {
+ case 1 :
+ snprintf(buf, len, "SIM%d", (se_type & 0x0F) + 1);
+ result = true;
+ break;
+
+ case 2 :
+ snprintf(buf, len, "eSE");
+ result = true;
+ break;
+
+ default :
+ break;
+ }
+
+ return result;
+}
+
+static bool _is_authorized_request(GDBusMethodInvocation *invocation,
+ const char *rights)
+{
+ bool result = true;
+#ifdef USER_SPACE_SMACK
+ pid_t pid;
+ const char *name;
+
+ name = g_dbus_method_invocation_get_sender(invocation);
+
+ pid = ServerGDBus::getInstance().getPID(name);
+
+ result = (security_server_check_privilege_by_pid(
+ pid,
+ "smartcard-service::priv",
+ rights) == SECURITY_SERVER_API_SUCCESS);
+#endif
+ return result;
+}
+
+static gboolean __process_is_authorized_nfc_access(
+ SmartcardServiceAccessControl *object,
+ GDBusMethodInvocation *invocation,
+ guint se_type,
+ const gchar *package,
+ GVariant *aid,
+ void *user_data)
+{
+ bool result = false;
+ const char *error;
+ const char *name;
+ char se[10];
+ pid_t pid;
+
+ ByteArray temp;
+ Terminal *terminal;
+ vector<ByteArray> hashes;
+
+ _INFO("[MSG_IS_AUTHORIZED_NFC_ACCESS]");
+
+ ServerResource &resource = ServerResource::getInstance();
+
+ name = g_dbus_method_invocation_get_sender(invocation);
+
+ pid = ServerGDBus::getInstance().getPID(name);
+
+ _INFO("service requested, pid [%d]", pid);
+
+ if (pid < 0) {
+ error = "invalid pid";
+
+ _ERR("%s, [%d]", error, pid);
+
+ goto ERR;
+ }
+
+ /* check process permission */
+ if (_check_permission(pid) == false) {
+ error = "permission denied";
+
+ _ERR("%s, [%d]", error, pid);
+
+ goto ERR;
+ }
+
+ /* load secure elements */
+ resource.loadSecureElements();
+
+ if (_get_se_name(se_type, se, sizeof(se)) == false) {
+ error = "unknown SE type";
+
+ _ERR("%s, [%d]", error, se_type);
+
+ goto ERR;
+ }
+
+ _INFO("SE : [%s]", se);
+
+ terminal = resource.getTerminal(se);
+ if (terminal == NULL) {
+ error = "failed getting terminal";
+
+ _ERR("%s, [%d]", error, se_type);
+
+ goto ERR;
+ }
+
+ if (terminal->isSecureElementPresence() == false) {
+ error = "terminal is not available now";
+
+ _ERR("%s, [%d]", error, se_type);
+
+ goto ERR;
+ }
+
+ /* get certificate hashes */
+ if (SignatureHelper::getCertificationHashes(package, hashes) == false) {
+ error = "failed getting certificates";
+
+ _ERR("%s, [%s]", error, package);
+
+ goto ERR;
+ }
+
+ /* convert AID */
+ GDBusHelper::convertVariantToByteArray(aid, temp);
+
+ result = resource.isAuthorizedNFCAccess(terminal, temp, hashes);
+
+ /* response to client */
+ smartcard_service_access_control_complete_is_authorized_nfc_access(
+ object, invocation, result);
+
+ return true;
+
+ERR :
+ g_dbus_method_invocation_return_dbus_error(
+ invocation,
+ "org.tizen.SmartcardService.AccessControl.Error",
+ error);
+
+ return false;
+}
+
+static void _process_is_authorized_nfc_access(vector<void *> ¶ms)
+{
+ SmartcardServiceAccessControl *object;
+ GDBusMethodInvocation *invocation;
+ guint se_type;
+ gchar *package;
+ GVariant *aid;
+ void *user_data;
+
+ if (params.size() != 6) {
+ _ERR("invalid parameter");
+
+ return;
+ }
+
+ object = (SmartcardServiceAccessControl *)params[0];
+ invocation = (GDBusMethodInvocation *)params[1];
+ se_type = 0;//(guint)params[2];
+ package = (gchar *)params[3];
+ aid = (GVariant *)params[4];
+ user_data = params[5];
+
+ __process_is_authorized_nfc_access(object, invocation, se_type,
+ package, aid, user_data);
+
+ g_variant_unref(aid);
+
+ g_free(package);
+
+ g_object_unref(invocation);
+ g_object_unref(object);
+
+ /* FIXME : disable killing process code */
+// ServerResource::getInstance().finish();
+}
+
+static gboolean _handle_is_authorized_nfc_access(
+ SmartcardServiceAccessControl *object,
+ GDBusMethodInvocation *invocation,
+ guint se_type,
+ const gchar *package,
+ GVariant *aid,
+ void *user_data)
+{
+ vector<void *> params;
+
+ /* apply user space smack */
+ if (_is_authorized_request(invocation, "r") == true) {
+ g_object_ref(object);
+ params.push_back((void *)object);
+
+ g_object_ref(invocation);
+ params.push_back((void *)invocation);
+
+ params.push_back((void *)se_type);
+ params.push_back((void *)g_strdup(package));
+
+ g_variant_ref(aid);
+ params.push_back((void *)aid);
+
+ params.push_back((void *)user_data);
+
+ GDBusDispatcher::getInstance().push(
+ _process_is_authorized_nfc_access,
+ params);
+ } else {
+ _ERR("access denied");
+
+ g_dbus_method_invocation_return_dbus_error(
+ invocation,
+ "org.tizen.SmartcardService.AccessControl.Error",
+ "access denied");
+
+ /* FIXME : disable killing process code */
+// ServerResource::getInstance().finish();
+ }
+
+ return true;
+}
+
+static bool __load_cdf_acl(Terminal *terminal)
+{
+ bool result = false;
+ ServerResource &resource = ServerResource::getInstance();
+ ServerChannel *channel;
+
+ if (terminal == NULL) {
+ return result;
+ }
+
+// if (terminal->open() == SCARD_ERROR_OK) {
+ channel = resource.createInternalChannel(terminal, 1);
+ if (channel != NULL) {
+ int ret;
+
+ ret = cdfAcl.updateACL(channel);
+ if (ret == 0) {
+ result = true;
+ } else {
+ _ERR("acl is null");
+ result = false;
+ }
+
+ delete channel;
+ } else {
+ _ERR("alloc failed");
+ }
+//
+// terminal->close();
+// } else {
+// _ERR("terminal open failed");
+// }
+
+ return result;
+}
+
+static gboolean __process_is_authorized_extra_access(
+ SmartcardServiceAccessControl *object,
+ GDBusMethodInvocation *invocation,
+ guint se_type,
+ const gchar *package,
+ void *user_data)
+{
+ bool result = false;
+ const char *error;
+ const char *name;
+ char se[10];
+ pid_t pid;
+
+ ByteArray temp;
+ Terminal *terminal;
+ vector<ByteArray> hashes;
+
+ _INFO("[MSG_IS_AUTHORIZED_EXTRA_ACCESS]");
+
+ ServerResource &resource = ServerResource::getInstance();
+
+ name = g_dbus_method_invocation_get_sender(invocation);
+
+ pid = ServerGDBus::getInstance().getPID(name);
+
+ _INFO("service requested, pid [%d]", pid);
+
+ if (pid < 0) {
+ error = "invalid pid";
+
+ _ERR("%s, [%d]", error, pid);
+
+ goto ERR;
+ }
+
+ /* check process permission */
+ if (_check_permission(pid) == false) {
+ error = "permission denied";
+
+ _ERR("%s, [%d]", error, pid);
+
+ goto ERR;
+ }
+
+ /* load secure elements */
+ resource.loadSecureElements();
+
+ if (_get_se_name(se_type, se, sizeof(se)) == false) {
+ error = "unknown SE type";
+
+ _ERR("%s, [%d]", error, se_type);
+
+ goto ERR;
+ }
+
+ _INFO("SE : [%s]", se);
+
+ terminal = resource.getTerminal(se);
+ if (terminal == NULL) {
+ error = "failed getting terminal";
+
+ _ERR("%s, [%d]", error, se_type);
+
+ goto ERR;
+ }
+
+ if (terminal->isSecureElementPresence() == false) {
+ error = "terminal is not available now";
+
+ _ERR("%s, [%d]", error, se_type);
+
+ goto ERR;
+ }
+
+ /* get certificate hashes */
+ if (SignatureHelper::getCertificationHashes(package, hashes) == false) {
+ error = "failed getting certificates";
+
+ _ERR("%s, [%s]", error, package);
+
+ goto ERR;
+ }
+
+ if ((se_type & 0xF0) == 0x10/* SIM */) {
+ /* load CDF */
+ if (cdfAcl.hasConditions() == false) {
+ _ERR("cdf rule doesn't be load");
+ __load_cdf_acl(terminal);
+ }
+
+ /* check access */
+ result = cdfAcl.isAuthorizedAccess(
+ AccessControlList::ALL_SE_APPS, hashes);
+ } else if ((se_type & 0xF0) == 0x20/* eSE */) {
+ if (terminal->open() == true) {
+ result = resource.isAuthorizedAccess(terminal,
+ AccessControlList::ALL_SE_APPS, hashes);
+
+ terminal->close();
+ }
+ }
+
+ /* response to client */
+ smartcard_service_access_control_complete_is_authorized_extra_access(
+ object, invocation, result);
+
+ return true;
+
+ERR :
+ g_dbus_method_invocation_return_dbus_error(
+ invocation,
+ "org.tizen.SmartcardService.AccessControl.Error",
+ error);
+
+ return false;
+}
+
+static void _process_is_authorized_extra_access(vector<void *> ¶ms)
+{
+ SmartcardServiceAccessControl *object;
+ GDBusMethodInvocation *invocation;
+ guint se_type;
+ gchar *package;
+ void *user_data;
+
+ if (params.size() != 5) {
+ _ERR("invalid parameter");
+
+ return;
+ }
+
+ object = (SmartcardServiceAccessControl *)params[0];
+ invocation = (GDBusMethodInvocation *)params[1];
+ se_type = 0;//(guint)params[2];
+ package = (gchar *)params[3];
+ user_data = params[4];
+
+ __process_is_authorized_extra_access(object, invocation, se_type,
+ package, user_data);
+
+ g_free(package);
+
+ g_object_unref(invocation);
+ g_object_unref(object);
+
+ /* FIXME : disable killing process code */
+// ServerResource::getInstance().finish();
+}
+
+static gboolean _handle_is_authorized_extra_access(
+ SmartcardServiceAccessControl *object,
+ GDBusMethodInvocation *invocation,
+ guint se_type,
+ const gchar *package,
+ void *user_data)
+{
+ vector<void *> params;
+
+ /* apply user space smack */
+ if (_is_authorized_request(invocation, "r") == true) {
+ g_object_ref(object);
+ params.push_back((void *)object);
+
+ g_object_ref(invocation);
+ params.push_back((void *)invocation);
+
+ params.push_back((void *)se_type);
+ params.push_back((void *)g_strdup(package));
+
+ params.push_back((void *)user_data);
+
+ GDBusDispatcher::getInstance().push(
+ _process_is_authorized_extra_access,
+ params);
+ } else {
+ _ERR("access denied");
+
+ g_dbus_method_invocation_return_dbus_error(
+ invocation,
+ "org.tizen.SmartcardService.AccessControl.Error",
+ "access denied");
+
+ /* FIXME : disable killing process code */
+// ServerResource::getInstance().finish();
+ }
+
+ return true;
+}
+
+static bool _init_access_control(void *connection)
+{
+ GError *error = NULL;
+
+ access_control = smartcard_service_access_control_skeleton_new();
+
+ g_signal_connect(access_control,
+ "handle-is-authorized-nfc-access",
+ G_CALLBACK(_handle_is_authorized_nfc_access),
+ NULL);
+
+ g_signal_connect(access_control,
+ "handle-is-authorized-extra-access",
+ G_CALLBACK(_handle_is_authorized_extra_access),
+ NULL);
+
+ if (g_dbus_interface_skeleton_export(
+ G_DBUS_INTERFACE_SKELETON(access_control),
+ (GDBusConnection *)connection,
+ "/org/tizen/SmartcardService/AccessControl",
+ &error) == false)
+ {
+ _ERR("Can not skeleton_export %s", error->message);
+
+ g_error_free(error);
+ g_object_unref(access_control);
+ access_control = NULL;
+
+ return false;
+ }
+
+ return true;
+}
+
+static void _deinit_access_control()
+{
+ if (access_control != NULL) {
+ g_object_unref(access_control);
+ access_control = NULL;
+ }
+}
+
+extern "C" bool smartcard_service_init_access_control(void *connection)
+{
+ _load_granted_package_info();
+
+ return _init_access_control(connection);
+}
+
+extern "C" void smartcard_service_deinit_access_control()
+{
+ _deinit_access_control();
+}
--- /dev/null
+/*
+ * 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 "Debug.h"
+#include "PKCS15CDFACL.h"
+#include "PKCS15ODF.h"
+#include "OpensslHelper.h"
+#include "AccessCondition.h"
+
+#ifndef EXTERN_API
+#define EXTERN_API __attribute__((visibility("default")))
+#endif
+
+namespace smartcard_service_api
+{
+ PKCS15CDFACL::PKCS15CDFACL() : AccessControlList()
+ {
+ }
+
+ PKCS15CDFACL::~PKCS15CDFACL()
+ {
+ }
+
+ int PKCS15CDFACL::loadACL(Channel *channel)
+ {
+ int result = SCARD_ERROR_OK;
+
+ _BEGIN();
+
+ if (channel == NULL)
+ {
+ return SCARD_ERROR_ILLEGAL_PARAM;
+ }
+
+ releaseACL();
+
+ PKCS15 pkcs15(channel);
+
+ result = pkcs15.select();
+ if (result >= SCARD_ERROR_OK)
+ {
+ PKCS15ODF *odf;
+
+ result = SCARD_ERROR_OK;
+
+ if ((odf = pkcs15.getODF()) != NULL)
+ {
+ PKCS15CDF *cdf;
+
+ cdf = odf->getCDF();
+ if (cdf != NULL)
+ {
+ result = loadRules(channel, cdf);
+ if (result == SCARD_ERROR_OK)
+ {
+ printAccessControlList();
+ }
+ else
+ {
+ result = SCARD_ERROR_OK;
+ }
+ }
+ else
+ {
+ _ERR("dodf null, every request will be denied.");
+ }
+ }
+ else
+ {
+ _ERR("odf null, every request will be denied.");
+ }
+ }
+ else
+ {
+ _ERR("failed to open PKCS#15, every request will be denied.");
+ }
+
+ _END();
+
+ return result;
+ }
+
+ int PKCS15CDFACL::loadRules(Channel *channel, PKCS15CDF *cdf)
+ {
+ int result = 0;
+ size_t i;
+ ByteArray hash;
+ const CertificateType *type;
+ AccessCondition condition;
+
+ condition.setAID(AccessControlList::ALL_SE_APPS);
+
+ for (i = 0; i < cdf->getCount(); i++) {
+ type = cdf->getCertificateType(i);
+ if(type == NULL)
+ continue;
+
+ OpensslHelper::digestBuffer("SHA1", type->certificate, hash);
+
+ _INFO("cdf[%d] = %s", i, hash.toString().c_str());
+
+ condition.addAccessRule(hash);
+ }
+
+ pair<ByteArray, AccessCondition> newItem(
+ AccessControlList::ALL_SE_APPS, condition);
+
+ mapConditions.insert(newItem);
+
+ return result;
+ }
+} /* namespace smartcard_service_api */
--- /dev/null
+/*
+ * 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 PKCS15CDFACL_H_
+#define PKCS15CDFACL_H_
+
+/* standard library header */
+
+/* SLP library header */
+
+/* local header */
+#include "smartcard-types.h"
+#ifdef __cplusplus
+#include "AccessControlList.h"
+#include "PKCS15.h"
+#endif /* __cplusplus */
+
+#ifdef __cplusplus
+namespace smartcard_service_api
+{
+ class PKCS15CDFACL : public AccessControlList
+ {
+ private:
+ int loadRules(Channel *channel, PKCS15CDF *cdf);
+
+ public:
+ PKCS15CDFACL();
+ ~PKCS15CDFACL();
+
+ int loadACL(Channel *channel);
+ };
+
+} /* namespace smartcard_service_api */
+#endif /* __cplusplus */
+#endif /* PKCS15CDFACL_H_ */
--- /dev/null
+<!--
+ org.tizen.SmartcardService
+-->
+
+<node>
+ <interface name="org.tizen.SmartcardService.AccessControl">
+ <!--
+ isAuthorizedExtraAccess
+ -->
+ <method name="isAuthorizedExtraAccess">
+ <arg type="u" name="se_type" direction="in" />
+ <arg type="s" name="package" direction="in" />
+ <arg type="b" name="result" direction="out" />
+ </method>
+
+ <!--
+ isAuthorizedNfcAccess
+ -->
+ <method name="isAuthorizedNfcAccess">
+ <arg type="u" name="se_type" direction="in" />
+ <arg type="s" name="package" direction="in" />
+ <arg type="a(y)" name="aid" direction="in" />
+ <arg type="b" name="result" direction="out" />
+ </method>
+ </interface>
+</node>
daemonize();
#endif
+ if (!g_thread_supported()) {
+ g_thread_init(NULL);
+ }
+
+ g_type_init();
+
main_loop = g_main_new(TRUE);
id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
<?xml version="1.0" encoding="UTF-8"?>
-<manifest xmlns="http://tizen.org/ns/packages"
- package="smartcard-service-server"
- version="0.1.20"
- install-location="internal-only"
- type="rpm">
+<manifest xmlns="http://tizen.org/ns/packages" package="smartcard-service-server" version="0.1.20" install-location="internal-only" type="rpm">
<label>Smartcard Service Server</label>
<author email="constant.lee@samsung.com" href="www.samsung.com">Sangsoo Lee</author>
<author email="wonkyu.kwon@samsung.com" href="www.samsung.com">Wonkyu Kwon</author>
<description>Smartcard Service Server</description>
<ui-application appid="smartcard-service-server"
- exec="/usr/bin/smartcard-daemon"
+ exec="/usr/apps/smartcard-service-server/bin/smartcard-daemon"
nodisplay="true"
multiple="false"
type="capp"
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_" />
+ </request>
+</manifest>
+
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_" />
+ </request>
+</manifest>
+
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_" />
+ </request>
+</manifest>
+
--- /dev/null
+<manifest>
+ <define>
+ <domain name="smartcard-service" />
+ <provide>
+ <label name="smartcard-service::priv" />
+ </provide>
+ <request>
+ <smack request="sys-assert::core" type="rwxat" />
+ <smack request="nfc-manager" type="rwx" />
+ <smack request="csc-feature" type="r" />
+ <smack request="security-server::api-privilege-by-pid" type="w" />
+ </request>
+ </define>
+ <assign>
+ <filesystem path="/usr/apps/smartcard-service-server/bin/smartcard-daemon" exec_label="smartcard-service" />
+ <!-- <filesystem path="/usr/apps/smartcard-service-server/bin/smartcard-test-client" exec_label="smartcard-service" /> -->
+ <filesystem path="/usr/share/dbus-1/services/smartcard-service.service" label="_" />
+ </assign>
+ <request>
+ <domain name="smartcard-service" />
+ </request>
+</manifest>
+
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_" />
+ </request>
+</manifest>
+
-LINK_DIRECTORIES(${CMAKE_BINARY_DIR})
-INCLUDE_DIRECTORIES(include)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common/include)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/client/include)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+PROJECT(smartcard-test-client CXX)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../common/include)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../client/include)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
#AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/ SRCS)
SET(SRCS "${CMAKE_CURRENT_SOURCE_DIR}/test-client-sync.cpp")
#SET(SRCS "${CMAKE_CURRENT_SOURCE_DIR}/test-client.cpp")
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+ SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+
+INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs_test_client REQUIRED glib-2.0 dlog)
+
FOREACH(flag ${pkgs_test_client_CFLAGS})
SET(EXTRA_CXXFLAGS "${EXTRA_CXXFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXXFLAGS}")
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 -std=c++0x")
+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")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" MATCHES "^arm.*")
+ ADD_DEFINITIONS("-DTARGET")
+ MESSAGE("add -DTARGET")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARM_CXXFLAGS}")
+ENDIF()
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+#ADD_DEFINITIONS("-DSLP_DEBUG")
ADD_DEFINITIONS("-DLOG_TAG=\"SMARTCARD_SERVICE_TEST\"")
ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_test_client_LDFLAGS} ${COMMON_LIB} ${CLIENT_LIB})
-
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_test_client_LDFLAGS} "-L../common" "-lsmartcard-service-common" "-L../client" "-lsmartcard-service" "-pie -ldl")
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/apps/smartcard-service-server/bin)