${CMAKE_CURRENT_SOURCE_DIR}/common/smartcard-service-gdbus.xml \\
")
+SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/common/smartcard-service-gdbus.c PROPERTIES GENERATED TRUE)
+
ADD_SUBDIRECTORY(common)
-ADD_SUBDIRECTORY(server)
+IF(BUILD_GCOV)
+ ADD_DEFINITIONS(-DBUILD_GCOV)
+ENDIF(BUILD_GCOV)
+ADD_SUBDIRECTORY(server)
+IF(BUILD_GTESTS)
+ ADD_SUBDIRECTORY(gtest)
+ ADD_DEFINITIONS(-DBUILD_GTEST)
+ENDIF(BUILD_GTESTS)
IF(DEFINED TEST_CLIENT)
ADD_SUBDIRECTORY(test-client)
ENDIF()
#include "Debug.h"
#include "APDUHelper.h"
+/* LCOV_EXCL_START */
namespace smartcard_service_api
{
/* ResponseHelper class */
}
} /* namespace smartcard_service_api */
+/* LCOV_EXCL_STOP */
#include "AccessControlList.h"
#include "AccessCondition.h"
+/* LCOV_EXCL_START */
namespace smartcard_service_api
{
void AccessRule::addAPDUAccessRule(const ByteArray &apdu,
return result;
}
} /* namespace smartcard_service_api */
+/* LCOV_EXCL_STOP */
allGranted = false;
}
+/* LCOV_EXCL_START */
AccessCondition &AccessControlList::getAccessCondition(const ByteArray &aid)
{
map<ByteArray, AccessCondition>::iterator item;
}
_DBG("============================================================================");
}
-
+/* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
buffer = new uint8_t[size];
if (buffer == NULL)
{
+ /* LCOV_EXCL_START */
_ERR("alloc failed");
return false;
}
+ /* LCOV_EXCL_STOP */
memcpy(buffer, array, size);
length = size;
return true;
}
+ /* LCOV_EXCL_START */
bool ByteArray::_assign(uint8_t *array, size_t size)
{
if (array == NULL || size == 0)
}
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES VERSION ${VERSION})
+SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/smartcard-service-gdbus.c PROPERTIES GENERATED TRUE)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_common_LDFLAGS})
static unsigned char path_efdir[] = { 0x2f, 0x00 };
static ByteArray PATH_EFDIR(ARRAY_AND_SIZE(path_efdir));
+ /* LCOV_EXCL_START */
EFDIR::EFDIR(Channel *channel) : FileObject(channel)
{
}
return result;
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
namespace smartcard_service_api
{
/* FCP class method */
+ /* LCOV_EXCL_START */
FCP::FCP()
{
resetMemberVar();
case 0x84 : /* DF name */
{
- SECURE_LOGD("0x%02X : DF name : %s", tlv.getTag(), tlv.getValue().toString().c_str());
+ SECURE_LOGD("0x%02X : DF name : %s", tlv.getTag(), tlv.getValue().toString().c_str()); //LCOV_EXCL_LINE
// 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());
+ SECURE_LOGD("0x%02X : Security attribute in proprietary format : %s", tlv.getTag(), tlv.getValue().toString().c_str()); //LCOV_EXCL_LINE
// 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());
+ SECURE_LOGD("0x%02X : Security attribute referencing the expanded format : %s", tlv.getTag(), tlv.getValue().toString().c_str()); //LCOV_EXCL_LINE
// 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());
+ SECURE_LOGD("0x%02X : Security attribute in compact format : %s", tlv.getTag(), tlv.getValue().toString().c_str()); //LCOV_EXCL_LINE
// 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());
+ SECURE_LOGD("0x%02X : Identifier of an EF containing security environment templates : %s", tlv.getTag(), tlv.getValue().toString().c_str()); //LCOV_EXCL_LINE
// 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());
+ SECURE_LOGD("0x%02X : Channel security attribute : %s", tlv.getTag(), tlv.getValue().toString().c_str()); //LCOV_EXCL_LINE
// 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());
+ SECURE_LOGD("0x%02X : Security attribute template for data objects : %s", tlv.getTag(), tlv.getValue().toString().c_str()); //LCOV_EXCL_LINE
// 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());
+ SECURE_LOGD("0x%02X : Security attribute template in proprietary format : %s", tlv.getTag(), tlv.getValue().toString().c_str()); //LCOV_EXCL_LINE
// 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());
+ SECURE_LOGD("0x%02X : Security attribute template in expanded format : %s", tlv.getTag(), tlv.getValue().toString().c_str()); //LCOV_EXCL_LINE
// 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());
+ SECURE_LOGD("0x%02X : PIN status template DO : %s", tlv.getTag(), tlv.getValue().toString().c_str()); //LCOV_EXCL_LINE
// ByteArray value = tlv.getValue();
}
break;
return result;
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
FileObject::FileObject(Channel *channel)
: ProviderHelper(channel)
{
return ret;
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
GPACE::GPACE() : AccessControlList(), acl(NULL)
{
}
return (acl != NULL) ? acl->isAuthorizedNFCAccess(aid, certHashes) : false;
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#define DO_TAG_REF_AR 0x000000E2
#define DO_TAG_AR 0x000000E3
+ /* LCOV_EXCL_START */
GPARAACL::GPARAACL() : AccessControlList()
{
}
return result;
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#define DO_TAG_REF_AR 0x000000E2
#define DO_TAG_AR 0x000000E3
+ /* LCOV_EXCL_START */
GPARAM::GPARAM(Channel *channel)
: FileObject(channel)
{
return result;
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
static unsigned char oid_globalplatform[] = { 0x2A, 0x86, 0x48, 0x86, 0xFC, 0x6B, 0x81, 0x48, 0x01, 0x01 };
static ByteArray OID_GLOBALPLATFORM(ARRAY_AND_SIZE(oid_globalplatform));
return 0;
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
ISO7816BERTLV::ISO7816BERTLV() : TLVHelper(), firstByte(0), tagClass(0),
encoding(0)
{
return (TLVHelper *)childTLV;
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
NumberStream::NumberStream(const ByteArray &T)
{
assign(T.getBuffer(), T.size());
return result;
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
bool OpensslHelper::encodeBase64String(const ByteArray &buffer, ByteArray &result, bool newLineChar)
{
bool ret = false;
return ret;
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
0x4B, 0x43, 0x53, 0x2D, 0x31, 0x35 };
const ByteArray PKCS15::PKCS15_AID(ARRAY_AND_SIZE(aid));
+ /* LCOV_EXCL_START */
PKCS15::PKCS15(Channel *channel) :
PKCS15Object(channel), odf(NULL)
{
return odf;
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
PKCS15CDF::PKCS15CDF(unsigned int fid, Channel *channel) :
PKCS15Object(channel)
{
return listCertType[index];
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
PKCS15DODF::PKCS15DODF(unsigned int fid, Channel *channel) :
PKCS15Object(channel)
{
return result;
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
static const unsigned int ODF_FID = 0x3150;
static const unsigned int TAG_DODF = (unsigned int)0xA7;
return cdf;
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
PKCS15OID::PKCS15OID(const ByteArray &data)
{
parseOID(data);
return result;
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
// PKCS15Object::PKCS15Object():FileObject()
// {
// }
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
PKCS15Path::PKCS15Path() : index(-1), length(0)
{
}
return 0;
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
PKCS15TokenInfo::PKCS15TokenInfo(Channel *channel) :
PKCS15Object(channel)
{
{
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#define EXTERN_API __attribute__((visibility("default")))
#endif
+/* LCOV_EXCL_START */
namespace smartcard_service_api
{
int SignatureHelper::getPackageName(int pid, char *package, size_t length)
}
pkgmgrinfo_appinfo_destroy_appinfo(handle_appinfo);
- SECURE_LOGD("package name : %s, package id : %s", packageName, pkgid);
+ SECURE_LOGD("package name : %s, package id : %s", packageName, pkgid); //LCOV_EXCL_LINE
if ((ret = pkgmgrinfo_pkginfo_create_certinfo(&handle)) == 0)
{
return result;
}
- SECURE_LOGD("package name : %s, package id : %s", packageName, pkgid);
+ SECURE_LOGD("package name : %s, package id : %s", packageName, pkgid); //LCOV_EXCL_LINE
if ((ret = pkgmgrinfo_pkginfo_create_certinfo(&handle)) == 0) {
if (0) {
return ret;
}
+/* LCOV_EXCL_STOP */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
SimpleTLV::SimpleTLV() : TLVHelper()
{
}
return result;
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
pthread_mutex_unlock(&syncMutex);
}
+ /* LCOV_EXCL_START */
int Synchronous::waitTimedCondition(int second)
{
struct timeval now;
pthread_cond_signal(&syncCondition);
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
TLVHelper::TLVHelper() : currentTLV(this), parentTLV(NULL),
childTLV(NULL), offset(0), currentT(0), currentL(0)
{
return result;
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class ResponseHelper
{
private:
int channel, const ByteArray &data);
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* APDUHELPER_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class AccessRule
{
private :
friend class AccessControlList;
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* ACCESSCONDITION_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class AccessControlList
{
protected:
const vector<ByteArray> &certHashes) const;
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* ACCESSCONTROLLIST_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class ByteArray //: public Serializable
{
protected:
const string toString() const;
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* BYTEARRAY_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class SessionHelper; /* explicit declaration */
typedef void (*transmitCallback)(unsigned char *buffer,
ErrorIllegalParameter &, ErrorSecurity &) = 0;
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* CHANNEL_H_ */
-/* LCOV_EXCL_STOP */
-
#define _ERR(fmt, ...) \
do \
+ /* LCOV_EXCL_START */ \
{ \
LOGE(COLOR_RED fmt COLOR_END, ##__VA_ARGS__); \
} \
+ /* LCOV_EXCL_STOP */ \
while (0)
#define _INFO(fmt, ...) \
+ /* LCOV_EXCL_START */ \
do \
{ \
LOGI(COLOR_GREEN fmt COLOR_END, ##__VA_ARGS__); \
} \
+ /* LCOV_EXCL_STOP */ \
while (0)
#define _WARN(fmt, ...) \
+ /* LCOV_EXCL_START */ \
do \
{ \
LOGI(COLOR_BROWN fmt COLOR_END, ##__VA_ARGS__); \
} \
+ /* LCOV_EXCL_STOP */ \
while (0)
#define _DBG(fmt, ...) \
+ /* LCOV_EXCL_START */ \
do \
{ \
LOGD(fmt, ##__VA_ARGS__); \
} \
+ /* LCOV_EXCL_STOP */ \
while (0)
#define _BEGIN() \
+ /* LCOV_EXCL_START */ \
do \
{ \
LOGD(COLOR_BLUE "BEGIN >>>>" COLOR_END); \
} \
+ /* LCOV_EXCL_STOP */ \
while (0)
#define _END() \
+ /* LCOV_EXCL_START */ \
do \
{ \
LOGD(COLOR_BLUE "END <<<<" COLOR_END); \
} \
+ /* LCOV_EXCL_STOP */ \
while (0)
#endif /* DEBUG_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class EFDIR : public FileObject
{
private:
const ByteArray getPathByAID(const ByteArray &aid);
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* EFDIR_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class FileObject : public ProviderHelper
{
private:
int readBinaryAll(unsigned int sfi, ByteArray &result);
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* FILEOBJECT_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class GPARAM : public FileObject
{
public:
int writeBinary(unsigned int sfi, const ByteArray &data, unsigned int offset, unsigned int length) { return SCARD_ERROR_NOT_SUPPORTED; }
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* GPARAM_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class NumberStream : public ByteArray
{
public:
NumberStream &operator =(const NumberStream &T);
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* NUMBERSTREAM_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class CertificateType
{
public :
const CertificateType *getCertificateType(int index) const;
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* PKCS15DODF_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class PKCS15OID
{
private:
inline const ByteArray getPath() const { return path; }
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* PKCS15OID_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class ProviderHelper
{
protected:
inline Channel *getChannel() { return channel; }
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* PROVIDERHELPER_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class SEServiceHelper;
typedef void (*openSessionCallback)(SessionHelper *session, int error,
ErrorIllegalParameter &, ErrorSecurity &)= 0;
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* READERHELPER_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class Record
{
private:
inline const ByteArray getData() const { return data; }
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* RECORD_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class SEServiceHelper : public Synchronous
{
protected:
virtual void shutdownSync() = 0;
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* SESERVICEHELPER_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class ReaderHelper;
typedef void (*openChannelCallback)(Channel *channel, int error, void *userData);
ErrorIllegalParameter &, ErrorSecurity &) = 0;
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* SESSIONHELPER_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class TLVHelper
{
protected:
bool returnToParentTLV();
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* TLVHELPER_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
typedef void (*terminalNotificationCallback)(const void *terminal, int event, int error, void *user_param);
typedef void (*terminalTransmitCallback)(const unsigned char *buffer, unsigned int length, int error, void *userParam);
virtual int getATR(terminalGetATRCallback callback, void *userData) = 0;
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* TERMINAL_H_ */
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(gtest-smartcard-service C CXX)
+
+SET(GTEST_TEST "gtest-smartcard-service")
+ADD_DEFINITIONS("-DUSE_DLOG")
+
+SET(REQUIRES_LIST ${REQUIRES_LIST}
+ glib-2.0
+ gio-2.0
+ gmock
+ dlog
+ capi-system-info
+)
+
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(GTEST_TEST_PKG REQUIRED ${REQUIRES_LIST})
+
+FOREACH(flag ${GTEST_TEST_PKG_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -fPIE")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+FILE(GLOB GTEST_TEST_SRCS *.cpp)
+SET(GTEST_TEST_SRCS ${GTEST_TEST_SRCS})
+
+ADD_EXECUTABLE(${GTEST_TEST} ${GTEST_TEST_SRCS})
+TARGET_LINK_LIBRARIES(${GTEST_TEST} ${GTEST_TEST_LDFLAGS} ${GTEST_TEST_PKG_LDFLAGS} -ldl -lgcov)
+
+INSTALL(TARGETS ${GTEST_TEST} RUNTIME DESTINATION bin)
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __SMARTCARD_CONF_H__
+#define __SMARTCARD_CONF_H__
+
+#include <glib.h>
+
+#ifdef USE_DLOG
+#include <dlog.h>
+#undef LOG_TAG
+#define LOG_TAG "SMARTCARD_SERVICE_GTEST"
+#define GLOGD(format, args...) LOGD(format, ##args)
+#else
+#define GLOGD(format, args...)
+#endif
+
+#define SE_FEATURE "http://tizen.org/feature/network.secure_element"
+#define SE_UICC_FEATURE "http://tizen.org/feature/network.secure_element.uicc"
+#define SE_ESE_FEATURE "http://tizen.org/feature/network.secure_element.ese"
+
+
+typedef enum {
+ ERROR_NONE = 0,
+ ERROR_NOT_PERMITTED = -1,
+ ERROR_OUT_OF_MEMORY = -2,
+ ERROR_PERMISSION_DENIED = -3,
+ ERROR_RESOURCE_BUSY = -4,
+ ERROR_INVALID_OPERATION = -5,
+ ERROR_INVALID_PARAMETER = -6,
+ ERROR_NOT_SUPPORTED = -7,
+ ERROR_OPERATION_FAILED = -8,
+ ERROR_NOT_INITIALIZED = -9,
+ ERROR_ALREADY_INITIALIZED = -10,
+ ERROR_IN_PROGRESS = -11,
+} error_e;
+#endif /* __SMARTCARD_CONF_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include "gdbus.h"
+
+GDbus::GDbus()
+{
+ this->m_pConnection = NULL;
+ this->m_pCancellable = NULL;
+}
+
+GDbus::~GDbus()
+{
+ GDBusConnection *conn = this->m_pConnection;
+ GCancellable *cancel = this->m_pCancellable;
+
+ if (cancel) {
+ g_cancellable_cancel(cancel);
+ g_object_unref(cancel);
+ cancel = NULL;
+ }
+
+ if (conn) {
+ g_object_unref(conn);
+ conn = NULL;
+ }
+}
+
+error_e GDbus::Create(void)
+{
+ GError *err = NULL;
+
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
+#endif
+
+ this->m_pConnection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+ if (this->m_pConnection == NULL) {
+ if (err != NULL) {
+ GLOGD("Failed to connect to the D-BUS daemon [%s]", err->message);
+ g_error_free(err);
+ }
+
+ return ERROR_OPERATION_FAILED;
+ }
+
+ this->m_pCancellable = g_cancellable_new();
+
+ return ERROR_NONE;
+}
+
+error_e GDbus::Destroy(void)
+{
+ g_cancellable_cancel(this->m_pCancellable);
+ g_object_unref(this->m_pCancellable);
+ this->m_pCancellable = NULL;
+
+ g_object_unref(this->m_pConnection);
+ this->m_pConnection = NULL;
+
+ return ERROR_NONE;
+}
+
+GDBusConnection *GDbus::GetConnection(void)
+{
+ return this->m_pConnection;
+}
+
+GCancellable *GDbus::GetCancellable(void)
+{
+ return this->m_pCancellable;
+}
+
+error_e GDbus::ConvertErrorStringToEnum(const char *error)
+{
+ if (NULL != strstr(error, "NoReply"))
+ return ERROR_INVALID_OPERATION;
+ else if (NULL != strstr(error, "Failed"))
+ return ERROR_OPERATION_FAILED;
+ else if (NULL != strstr(error, "UnknownMethod"))
+ return ERROR_INVALID_OPERATION;
+ else if (NULL != strstr(error, "InvalidArguments"))
+ return ERROR_INVALID_PARAMETER;
+ else if (NULL != strstr(error, "AccessDenied"))
+ return ERROR_PERMISSION_DENIED;
+ else if (NULL != strstr(error, "PermissionDenied"))
+ return ERROR_PERMISSION_DENIED;
+ else if (NULL != strstr(error, "NotSupported"))
+ return ERROR_NOT_SUPPORTED;
+ else if (NULL != strstr(error, "InProgress"))
+ return ERROR_IN_PROGRESS;
+
+ return ERROR_OPERATION_FAILED;
+}
+
+GVariant *GDbus::InvokeMethod(const char *dest, const char *path,
+ const char *iface_name, const char *method, GVariant *params, error_e *dbus_error)
+{
+ GError *error = NULL;
+ GVariant *reply = NULL;
+ GDBusConnection *connection = NULL;
+ *dbus_error = ERROR_NONE;
+
+ connection = GetConnection();
+ if (connection == NULL) {
+ GLOGD("GDBusconnection is NULL");
+ *dbus_error = ERROR_NOT_INITIALIZED;
+ return reply;
+ }
+
+ reply = g_dbus_connection_call_sync(connection,
+ dest,
+ path,
+ iface_name,
+ method,
+ params,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ DBUS_REPLY_TIMEOUT,
+ GetCancellable(),
+ &error);
+
+ if (reply == NULL) {
+ if (error != NULL) {
+ GLOGD("g_dbus_connection_call_sync() failed "
+ "error [%d: %s]", error->code, error->message);
+ *dbus_error = ConvertErrorStringToEnum(error->message);
+ g_error_free(error);
+ } else {
+ GLOGD("g_dbus_connection_call_sync() failed");
+ *dbus_error = ERROR_OPERATION_FAILED;
+ }
+
+ return NULL;
+ }
+
+ return reply;
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __NET_CONFIG_GDBUS_H__
+#define __NET_CONFIG_GDBUS_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "common.h"
+
+#define GMAINTIMEOUT 10000
+#define DBUS_REPLY_TIMEOUT (120 * 1000)
+
+#define SMARTCARD_SERVICE "org.tizen.SmartcardService"
+
+#define SMARTCARD_SE_SERVICE_PATH "/org/tizen/SmartcardService/SeService"
+#define SMARTCARD_SE_SERVICE_INTERFACE "org.tizen.SmartcardService.SeService"
+
+#define SMARTCARD_READER_PATH "/org/tizen/SmartcardService/Reader"
+#define SMARTCARD_READER_INTERFACE "org.tizen.SmartcardService.Reader"
+
+#define SMARTCARD_SESSION_PATH "/org/tizen/SmartcardService/Session"
+#define SMARTCARD_SESSION_INTERFACE "org.tizen.SmartcardService.Session"
+
+#define SMARTCARD_CHANNEL_PATH "/org/tizen/SmartcardService/Channel"
+#define SMARTCARD_CHANNEL_INTERFACE "org.tizen.SmartcardService.Channel"
+
+#define SMARTCARD_ACCESS_CONTROL_PATH "/org/tizen/SmartcardService/AccessControl"
+#define SMARTCARD_ACCESS_CONTROL_INTERFACE "org.tizen.SmartcardService.AccessControl"
+
+#define SE_SERVICE "SeService"
+#define SHUTDOWN "shutdown"
+#define READER_INSERTED "ReaderInserted"
+#define READER_REMOVED "ReaderRemoved"
+
+#define OPEN_SESSION "openSession"
+#define GET_ATR "getATR"
+#define OPEN_CHANNEL "openChannel"
+#define CLOSE_SESSION "closeSession"
+
+#define TRANSMIT "transmit"
+#define CLOSE_CHANNEL "closeChannel"
+
+#define IS_AUTHORIZED_EXTRA_ACCESS "isAuthorizedExtraAccess"
+#define IS_AUTHORIZED_NFC_ACCESS "isAuthorizedNfcAccess"
+
+class GDbus {
+ private:
+ GDBusConnection *m_pConnection;
+ GCancellable *m_pCancellable;
+ public:
+ GDbus();
+ ~GDbus();
+ error_e Create(void);
+ error_e Destroy(void);
+ GDBusConnection *GetConnection(void);
+ GCancellable *GetCancellable(void);
+ error_e ConvertErrorStringToEnum(const char *error);
+ GVariant *InvokeMethod(const char *dest, const char *path,
+ const char *iface_name, const char *method, GVariant *params, error_e *dbus_error);
+ error_e InvokeMethodNonblock(const char *dest, const char *path,
+ const char *iface_name, const char *method, GVariant *params, int timeout,
+ GAsyncReadyCallback notify_func, void *user_data);
+ GVariant *InvokeMethod_with_fd(GUnixFDList *fd_list, const char *dest, const char *path,
+ const char *iface_name, const char *method, GVariant *params, error_e *dbus_error);
+};
+#endif /* __NET_CONFIG_GDBUS_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include "smartcardService.h"
+
+smartcardService::smartcardService(void)
+{
+ Create();
+}
+
+smartcardService::~smartcardService(void)
+{
+ Destroy();
+}
+
+static void parseReaderInformation(GVariant *variant)
+{
+ GLOGD("+");
+ GVariantIter *iter;
+ guint handle;
+ gchar *name;
+
+ g_variant_get(variant, "a(us)", &iter);
+
+ while (g_variant_iter_loop(iter, "(us)", &handle, &name) == true)
+ {
+ GLOGD("Reader : name [%s], handle [%08x]", name, handle);
+
+ }
+
+ g_variant_iter_free(iter);
+
+}
+
+error_e smartcardService::SeService(guint *handle)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+ GVariant *readers = NULL;
+ gint result;
+
+ message = InvokeMethod(SMARTCARD_SERVICE,
+ SMARTCARD_SE_SERVICE_PATH,
+ SMARTCARD_SE_SERVICE_INTERFACE,
+ SE_SERVICE,
+ NULL,
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ g_variant_get(message, "(iu@a(us))", &result, handle, &readers);
+ parseReaderInformation(readers);
+ g_variant_unref(message);
+
+ return ERROR_NONE;
+}
+
+error_e smartcardService::shutdown(guint handle)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+ gint result;
+
+ message = InvokeMethod(SMARTCARD_SERVICE,
+ SMARTCARD_SE_SERVICE_PATH,
+ SMARTCARD_SE_SERVICE_INTERFACE,
+ SHUTDOWN,
+ g_variant_new("(u)", handle),
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ g_variant_get(message, "(i)", &result);
+ g_variant_unref(message);
+
+ return ERROR_NONE;
+}
+
+error_e smartcardService::openSession(guint service_id, guint reader_id, guint *reader_handle)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+ gint result;
+
+ message = InvokeMethod(SMARTCARD_SERVICE,
+ SMARTCARD_READER_PATH,
+ SMARTCARD_READER_INTERFACE,
+ OPEN_SESSION,
+ g_variant_new("(uu)", service_id, reader_id),
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ g_variant_get(message, "(iu)", &result, &reader_handle);
+ g_variant_unref(message);
+
+ return ERROR_NONE;
+}
+
+error_e smartcardService::getATR(guint service_id, guint session_id)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(SMARTCARD_SERVICE,
+ SMARTCARD_SESSION_PATH,
+ SMARTCARD_SESSION_INTERFACE,
+ GET_ATR,
+ g_variant_new("(uu)", service_id, session_id),
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ g_variant_unref(message);
+
+ return ERROR_NONE;
+}
+
+error_e smartcardService::openChannel(guint service_id, guint session_id, guint type)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ GVariant *atr;
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+ g_variant_builder_add(builder, "(y)", 0x00);
+ g_variant_builder_add(builder, "(y)", 0x00);
+ atr = g_variant_new("a(y)", builder);
+ g_variant_builder_unref(builder);
+
+ unsigned char p2 = 0x00;
+
+ message = InvokeMethod(SMARTCARD_SERVICE,
+ SMARTCARD_SESSION_PATH,
+ SMARTCARD_SESSION_INTERFACE,
+ OPEN_CHANNEL,
+ g_variant_new("(uuu@a(y)y)", service_id, session_id, type, atr, p2),
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ g_variant_unref(message);
+
+ return ERROR_NONE;
+}
+
+error_e smartcardService::closeSession(guint service_id, guint session_id)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(SMARTCARD_SERVICE,
+ SMARTCARD_SESSION_PATH,
+ SMARTCARD_SESSION_INTERFACE,
+ CLOSE_SESSION,
+ g_variant_new("(uu)", service_id, session_id),
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ g_variant_unref(message);
+
+ return ERROR_NONE;
+}
+
+error_e smartcardService::closeChannel(guint service_id, guint channel_id)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ message = InvokeMethod(SMARTCARD_SERVICE,
+ SMARTCARD_CHANNEL_PATH,
+ SMARTCARD_CHANNEL_INTERFACE,
+ CLOSE_CHANNEL,
+ g_variant_new("(uu)", service_id, channel_id),
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ g_variant_unref(message);
+
+ return ERROR_NONE;
+}
+
+error_e smartcardService::transmit(guint service_id, guint channel_id)
+{
+ GVariant *message = NULL;
+ error_e error = ERROR_NONE;
+
+ GVariant *command;
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+ g_variant_builder_add(builder, "(y)", 0x00);
+ g_variant_builder_add(builder, "(y)", 0x00);
+ command = g_variant_new("a(y)", builder);
+ g_variant_builder_unref(builder);
+
+ message = InvokeMethod(SMARTCARD_SERVICE,
+ SMARTCARD_CHANNEL_PATH,
+ SMARTCARD_CHANNEL_INTERFACE,
+ TRANSMIT,
+ g_variant_new("(uu@a(y))", service_id, channel_id, command),
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ g_variant_unref(message);
+
+ return ERROR_NONE;
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __SMARTCARD_SERVICE_H__
+#define __SMARTCARD_SERVICE_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "gdbus.h"
+
+class smartcardService:public GDbus {
+ private:
+ public:
+ smartcardService(void);
+ ~smartcardService(void);
+ error_e shutdown(guint handle);
+ error_e SeService(guint *handle);
+ error_e openSession(guint service_id, guint reader_id, guint *reader_handle);
+ error_e getATR(guint service_id, guint session_id);
+ error_e openChannel(guint service_id, guint session_id, guint type);
+ error_e transmit(guint service_id, guint channel_id);
+ error_e closeChannel(guint service_id, guint channel_id);
+ error_e closeSession(guint service_id, guint session_id);
+};
+
+#endif /* __SMARTCARD_SERVICE_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <unistd.h>
+#include <glib.h>
+#include <system_info.h>
+
+#include "smartcardService.h"
+
+using ::testing::InitGoogleTest;
+using ::testing::Test;
+using ::testing::TestCase;
+
+static guint handle = 0;
+static guint reader_handle = 0;
+
+bool _is_support_smartcard()
+{
+ bool ret = false;
+ bool is_supported_se = false;
+ bool is_supported_se_uicc = false;
+ bool is_supported_se_ese = false;
+
+ system_info_get_platform_bool(SE_FEATURE, &is_supported_se);
+ system_info_get_platform_bool(SE_UICC_FEATURE, &is_supported_se_uicc);
+ system_info_get_platform_bool(SE_ESE_FEATURE, &is_supported_se_ese);
+
+ if(is_supported_se && (is_supported_se_uicc || is_supported_se_ese))
+ ret = true;
+
+ return ret;
+}
+
+TEST(smartcardServiceSeService_t, SeService_p)
+{
+ ASSERT_EQ(_is_support_smartcard(), true);
+
+ int ret = 0;
+ smartcardService S;
+
+ ret = S.SeService(&handle);
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+
+TEST(smartcardServiceReader_t, openSession_p)
+{
+ ASSERT_EQ(_is_support_smartcard(), true);
+
+ int ret = 0;
+ smartcardService S;
+
+ ret = S.openSession(handle, 0, &reader_handle);
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(smartcardServiceReader_t, getATR_p)
+{
+ ASSERT_EQ(_is_support_smartcard(), true);
+
+ int ret = 0;
+ smartcardService S;
+
+ ret = S.getATR(handle, reader_handle);
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(smartcardServiceReader_t, openChannel_p)
+{
+ ASSERT_EQ(_is_support_smartcard(), true);
+
+ int ret = 0;
+ smartcardService S;
+
+ ret = S.openChannel(handle, reader_handle, 0);
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(smartcardServiceChannel, transmit_p)
+{
+ ASSERT_EQ(_is_support_smartcard(), true);
+
+ int ret = 0;
+ smartcardService S;
+
+ ret = S.transmit(handle, 0);
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(smartcardServiceChannel, closeChannel_p)
+{
+ ASSERT_EQ(_is_support_smartcard(), true);
+
+ int ret = 0;
+ smartcardService S;
+
+ ret = S.closeChannel(handle, 0);
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+
+TEST(smartcardServiceReader_t, closeSession_p)
+{
+ ASSERT_EQ(_is_support_smartcard(), true);
+
+ int ret = 0;
+ smartcardService S;
+
+ ret = S.closeSession(handle, reader_handle);
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(smartcardServiceSeService_t, shutdown_p)
+{
+ ASSERT_EQ(_is_support_smartcard(), true);
+
+ int ret = 0;
+ smartcardService S;
+
+ ret = S.shutdown(handle);
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+int main(int argc, char **argv)
+{
+ InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
BuildRequires: pkgconfig(cynara-client)
BuildRequires: pkgconfig(cynara-creds-gdbus)
BuildRequires: pkgconfig(cynara-session)
+BuildRequires: pkgconfig(capi-system-info)
BuildRequires: python
BuildRequires: python-xml
Requires: %{name}-common = %{version}-%{release}
Requires: security-config
+%if 0%{?gtests:1}
+BuildRequires: pkgconfig(gmock)
+%endif
%description
Smartcard Service FW.
%{bindir}/author-signature.xml
%{bindir}/signature1.xml
/etc/dbus-1/system.d/org.tizen.SmartcardService.conf
-
+%if 0%{?gtests:1}
+%{_bindir}/gtest*
+%endif
%post
/usr/bin/signing-client/hash-signer-client.sh -a -d -p platform %{bindir}
%build
+%if 0%{?gcov:1}
+export CFLAGS+=" -fprofile-arcs -ftest-coverage"
+export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
+export LDFLAGS+=" -lgcov "
+%endif
+
%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}
+%cmake .. -DCMAKE_INSTALL_PREFIX=%{_prefix} %{?use_autostart} %{?use_gdbus} %{?test_client} \
+ -DBUILD_GTESTS=%{?gtests:1}%{!?gtests:0} \
+ -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0}
%install
cd obj-arm-limux-qnueabi
### for private
ADD_DEFINITIONS("-D__PRIVATE")
+IF(BUILD_GTESTS)
+ ADD_DEFINITIONS(-DBUILD_GTEST)
+ENDIF(BUILD_GTESTS)
+
FIND_PROGRAM(GDBUS_CODEGEN NAMES gdbus-codegen)
EXEC_PROGRAM(${GDBUS_CODEGEN} ARGS
" \\
if (result != NULL) {
mapServices.insert(make_pair(result->getHandle(), result));
} else {
- _ERR("alloc failed");
+ _ERR("alloc failed"); //LCOV_EXCL_LINE
}
return result;
ServiceInstance *ClientInstance::getService(unsigned int handle)
{
+ /* LCOV_EXCL_START */
ServiceInstance *result = NULL;
map<unsigned int, ServiceInstance *>::iterator item;
}
return result;
+ /* LCOV_EXCL_STOP */
}
void ClientInstance::removeService(unsigned int handle)
{
+ /* LCOV_EXCL_START */
map<unsigned int, ServiceInstance *>::iterator item;
if ((item = mapServices.find(handle)) != mapServices.end())
delete item->second;
mapServices.erase(item);
}
+ /* LCOV_EXCL_STOP */
}
void ClientInstance::removeServices()
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
ServerChannel::ServerChannel(ServerSession *session, void *caller,
int channelNum, Terminal *terminal) :
Channel(session), terminal(terminal), caller(caller),
return ret;
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
dispatcher->syncLock();
dispatcher->q.pop();
+ /* LCOV_EXCL_START */
if (dispatcher->q.size() > 0) {
_INFO("remaining messages : %d", dispatcher->q.size());
result = true;
+ /* LCOV_EXCL_STOP */
} else {
_INFO("dispatch finished");
}
const gchar *name, const gchar *old_owner,
const gchar *new_owner, void *user_data)
{
+ /* LCOV_EXCL_START */
if (name == NULL || old_owner == NULL || new_owner == NULL) {
_ERR("invalid parameter");
return;
}
-
+ /* LCOV_EXCL_STOP */
if (strlen(new_owner) == 0) {
ClientInstance *client;
&error);
if (dbus_proxy == NULL)
{
+ /* LCOV_EXCL_START */
_ERR("Can not create proxy : %s", error->message);
g_error_free(error);
return false;
+ /* LCOV_EXCL_STOP */
}
/* subscribe signal */
connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
if (connection != NULL) {
+ /* LCOV_EXCL_START */
} else {
_ERR("Can not get connection %s", error->message);
g_error_free(error);
return false;
}
+ /* LCOV_EXCL_STOP */
_init();
if (_call_get_connection_unix_process_id_sync(
(GDBusProxy *)dbus_proxy, name,
&pid, NULL, &error) == true) {
+ /* LCOV_EXCL_START */
} else {
_ERR("_g_freedesktop_dbus_call_get_connection_unix_process_id_sync failed : %s", error->message);
g_error_free(error);
}
+ /* LCOV_EXCL_STOP */
return pid;
}
pid = ServerGDBus::getInstance().getPID(sender_unique_name);
ret = cynara_initialize(&p_cynara, NULL);
+ /* LCOV_EXCL_START */
if (ret != CYNARA_API_SUCCESS) {
_ERR("cynara_initialize() failed");
return false;
}
+ /* LCOV_EXCL_STOP */
ret = cynara_creds_gdbus_get_user(connection, sender_unique_name, USER_METHOD_DEFAULT, &user);
+ /* LCOV_EXCL_START */
if (ret != CYNARA_API_SUCCESS) {
_ERR("cynara_creds_gdbus_get_user() failed");
return false;
}
+ /* LCOV_EXCL_STOP */
ret = cynara_creds_gdbus_get_client(connection, sender_unique_name, CLIENT_METHOD_DEFAULT, &client);
+ /* LCOV_EXCL_START */
if (ret != CYNARA_API_SUCCESS) {
_ERR("cynara_creds_gdbus_get_client() failed");
g_free(user);
return false;
}
+ /* LCOV_EXCL_STOP */
_ERR("user :%s , client :%s ,unique_name : %s, pid() : %d", user, client, sender_unique_name, pid);
client_session = cynara_session_from_pid(pid);
+ /* LCOV_EXCL_START */
if (!client_session) {
_ERR("cynara_session_from_pid() failed");
g_free(client);
g_free(user);
return false;
}
+ /* LCOV_EXCL_STOP */
ret = cynara_check(p_cynara, client, client_session, user, SMARTCARD_PRIVILEGE);
if ( ret == CYNARA_API_ACCESS_ALLOWED ) {
/* generate certification hashes */
instance->generateCertificationHashes();
} else {
- _ERR("createClient failed");
+ _ERR("createClient failed"); /* LCOV_EXCL_LINE */
}
}
if (list.size() == 0) {
_INFO("no secure elements");
}
+ /* LCOV_EXCL_START */
} else {
_ERR("createService failed");
result = SCARD_ERROR_IPC_FAILED;
}
+ /* LCOV_EXCL_STOP */
readers = _reader_to_variant(list);
GDBusMethodInvocation *invocation;
void *user_data;
+ /* LCOV_EXCL_START */
if (params.size() != 3) {
_ERR("invalid parameter");
return;
}
+ /* LCOV_EXCL_STOP */
object = (SmartcardServiceSeService *)params[0];
invocation = (GDBusMethodInvocation *)params[1];
params.push_back((void *)user_data);
GDBusDispatcher::push(_process_se_service, params);
+ /* LCOV_EXCL_START */
} else {
vector<pair<unsigned int, string> > list;
IntegerHandle::INVALID_HANDLE,
_reader_to_variant(list));
}
+ /* LCOV_EXCL_STOP */
return true;
}
guint handle;
void *user_data;
+ /* LCOV_EXCL_START */
if (params.size() != 4) {
_ERR("invalid parameter");
return;
}
+ /* LCOV_EXCL_STOP */
object = (SmartcardServiceSeService *)params[0];
invocation = (GDBusMethodInvocation *)params[1];
params.push_back(user_data);
GDBusDispatcher::push(_process_shutdown, params);
+ /* LCOV_EXCL_START */
} else {
_ERR("access denied");
smartcard_service_se_service_complete_shutdown(object,
invocation, SCARD_ERROR_SECURITY_NOT_ALLOWED);
}
+ /* LCOV_EXCL_STOP */
return true;
}
G_CALLBACK(_handle_shutdown),
this);
+ /* LCOV_EXCL_START */
if (g_dbus_interface_skeleton_export(
G_DBUS_INTERFACE_SKELETON(seService),
connection,
return false;
}
+ /* LCOV_EXCL_STOP */
return true;
}
void ServerGDBus::emitReaderInserted(unsigned int reader_id,
const char *reader_name)
{
+ /* LCOV_EXCL_START */
smartcard_service_se_service_emit_reader_inserted(
SMARTCARD_SERVICE_SE_SERVICE(seService),
reader_id, reader_name);
+ /* LCOV_EXCL_STOP */
}
void ServerGDBus::emitReaderRemoved(unsigned int reader_id,
const char *reader_name)
{
+ /* LCOV_EXCL_START */
smartcard_service_se_service_emit_reader_removed(
SMARTCARD_SERVICE_SE_SERVICE(seService),
reader_id, reader_name);
+ /* LCOV_EXCL_STOP */
}
/* Reader *
if (handle != IntegerHandle::INVALID_HANDLE) {
result = SCARD_ERROR_OK;
} else {
+ /* LCOV_EXCL_START */
_ERR("createSession failed [%d]", handle);
result = SCARD_ERROR_OUT_OF_MEMORY;
_ERR("request invalid reader handle [%d]", reader_id);
result = SCARD_ERROR_ILLEGAL_PARAM;
+ /* LCOV_EXCL_STOP */
}
/* response to client */
void *user_data;
if (params.size() != 5) {
+ /* LCOV_EXCL_START */
_ERR("invalid parameter");
return;
+ /* LCOV_EXCL_STOP */
}
object = (SmartcardServiceReader *)params[0];
GDBusDispatcher::push(_process_open_session, params);
} else {
+ /* LCOV_EXCL_START */
_ERR("access denied");
/* response to client */
invocation,
SCARD_ERROR_SECURITY_NOT_ALLOWED,
IntegerHandle::INVALID_HANDLE);
+ /* LCOV_EXCL_STOP */
}
return true;
"/org/tizen/SmartcardService/Reader",
&error) == false)
{
+ /* LCOV_EXCL_START */
_ERR("Can not skeleton_export %s", error->message);
g_error_free(error);
reader = NULL;
return false;
+ /* LCOV_EXCL_STOP */
}
return true;
void ServerGDBus::deinitReader()
{
+ /* LCOV_EXCL_START */
if (reader != NULL) {
g_object_unref(reader);
reader = NULL;
}
+ /* LCOV_EXCL_STOP */
}
/* Session *
resource.removeSession(name, service_id,
session_id);
} else {
- _ERR("invalid parameters");
+ _ERR("invalid parameters"); //LCOV_EXCL_LINE
}
/* response to client */
void *user_data;
if (params.size() != 5) {
+ /* LCOV_EXCL_START */
_ERR("invalid parameter");
return;
+ /* LCOV_EXCL_STOP */
}
object = (SmartcardServiceSession *)params[0];
GDBusDispatcher::push(_process_close_session, params);
} else {
+ /* LCOV_EXCL_START */
_ERR("access denied");
/* response to client */
smartcard_service_session_complete_close_session(object,
invocation, SCARD_ERROR_SECURITY_NOT_ALLOWED);
+ /* LCOV_EXCL_STOP */
}
return true;
name = g_dbus_method_invocation_get_sender(invocation);
client = resource.getService(name, service_id);
+ /* LCOV_EXCL_START */
if (client != NULL) {
Terminal *terminal;
result = SCARD_ERROR_UNAVAILABLE;
}
+ /* LCOV_EXCL_STOP */
atr = GDBusHelper::convertByteArrayToVariant(resp);
void *user_data;
if (params.size() != 5) {
+ /* LCOV_EXCL_START */
_ERR("invalid parameter");
return;
+ /* LCOV_EXCL_STOP */
}
object = (SmartcardServiceSession *)params[0];
GDBusDispatcher::push(_process_get_atr, params);
} else {
+ /* LCOV_EXCL_START */
ByteArray resp;
_ERR("access denied");
invocation,
SCARD_ERROR_SECURITY_NOT_ALLOWED,
GDBusHelper::convertByteArrayToVariant(resp));
+ /* LCOV_EXCL_STOP */
}
return true;
channelID = resource.createChannel(name,
service_id, session_id, type, tempAid);
+ /* LCOV_EXCL_START */
if (channelID != IntegerHandle::INVALID_HANDLE) {
ServerChannel *temp;
/* set error value */
result = SCARD_ERROR_UNAVAILABLE;
}
+ /* LCOV_EXCL_STOP */
}
catch (ExceptionBase &e)
{
void *user_data;
if (params.size() != 8) {
+ /* LCOV_EXCL_START */
_ERR("invalid parameter");
return;
+ /* LCOV_EXCL_STOP */
}
object = (SmartcardServiceSession *)params[0];
GDBusDispatcher::push(_process_open_channel, params);
} else {
+ /* LCOV_EXCL_START */
ByteArray resp;
_ERR("access denied");
IntegerHandle::INVALID_HANDLE,
-1,
GDBusHelper::convertByteArrayToVariant(resp));
+ /* LCOV_EXCL_STOP */
}
return true;
"/org/tizen/SmartcardService/Session",
&error) == false)
{
+ /* LCOV_EXCL_START */
_ERR("Can not skeleton_export %s", error->message);
g_error_free(error);
session = NULL;
return false;
+ /* LCOV_EXCL_STOP */
}
return true;
void *user_data;
if (params.size() != 5) {
+ /* LCOV_EXCL_START */
_ERR("invalid parameter");
return;
+ /* LCOV_EXCL_STOP */
}
object = (SmartcardServiceChannel *)params[0];
GDBusDispatcher::push(_process_close_channel, params);
} else {
+ /* LCOV_EXCL_START */
_ERR("access denied");
/* response to client */
object,
invocation,
SCARD_ERROR_SECURITY_NOT_ALLOWED);
+ /* LCOV_EXCL_STOP */
}
return true;
name = g_dbus_method_invocation_get_sender(invocation);
channel = resource.getChannel(name, service_id, channel_id);
+ /* LCOV_EXCL_START */
if (channel != NULL) {
int rv;
ByteArray cmd;
result = SCARD_ERROR_UNAVAILABLE;
}
+ /* LCOV_EXCL_STOP */
response = GDBusHelper::convertByteArrayToVariant(resp);
void *user_data;
if (params.size() != 6) {
+ /* LCOV_EXCL_START */
_ERR("invalid parameter");
return;
+ /* LCOV_EXCL_STOP */
}
object = (SmartcardServiceChannel *)params[0];
GDBusDispatcher::push(_process_transmit, params);
} else {
+ /* LCOV_EXCL_START */
ByteArray resp;
_ERR("access denied");
invocation,
SCARD_ERROR_SECURITY_NOT_ALLOWED,
GDBusHelper::convertByteArrayToVariant(resp));
+ /* LCOV_EXCL_STOP */
}
return true;
"/org/tizen/SmartcardService/Channel",
&error) == false)
{
+ /* LCOV_EXCL_START */
_ERR("Can not skeleton_export %s", error->message);
g_error_free(error);
channel = NULL;
return false;
+ /* LCOV_EXCL_STOP */
}
return true;
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
ServerReader::ServerReader(ServerSEService *seService,
const char *name, Terminal *terminal) : ReaderHelper()
{
return session;
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
mapClients.insert(make_pair(name, instance));
result = true;
} else {
- _ERR("alloc failed");
+ _ERR("alloc failed"); //LCOV_EXCL_LINE
}
} else {
- _ERR("client already exist, name [%s]", name);
+ _ERR("client already exist, name [%s]", name); //LCOV_EXCL_LINE
}
return result;
delete item->second;
mapClients.erase(item);
} else {
- _DBG("client removed already, name [%s]", name);
+ _DBG("client removed already, name [%s]", name); //LCOV_EXCL_LINE
}
}
+ /* LCOV_EXCL_START */
void ServerResource::removeClients()
{
map<string, ClientInstance *>::iterator item;
snprintf(fullPath, sizeof(fullPath),
"%s/%s", OMAPI_SE_PATH, entry->d_name);
- SECURE_LOGD("se name [%s]", fullPath);
+ SECURE_LOGD("se name [%s]", fullPath); //LCOV_EXCL_LINE
result = appendSELibrary(fullPath);
}
return result;
}
+ /* LCOV_EXCL_STOP */
void ServerResource::finish()
{
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
#define OMAPI_SE_PATH "/usr/lib/se"
ServerSEService::ServerSEService():SEServiceHelper()
}
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
ServerSession::ServerSession(ServerReader *reader,
const vector<ByteArray> &certHashes,
void *caller, Terminal *terminal) : SessionHelper(reader)
return openLogicalChannelSync(temp, caller);
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
}
}
+ /* LCOV_EXCL_START */
unsigned int ServiceInstance::openSession(Terminal *terminal, const vector<ByteArray> &certHashes, void *caller)
{
unsigned int handle = IntegerHandle::assignHandle();
mapChannels.clear();
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class ClientInstance
{
private :
inline vector<ByteArray> &getCertificationHashes() { return certHashes; }
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* CLIENTINSTANCE_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class ServerChannel: public Channel
{
private:
friend class ServerResource;
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* SERVERCHANNEL_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class ServerSEService;
class ServerReader : public ReaderHelper
friend class ServerSEService;
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* SERVERREADER_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class ServerSEService : public SEServiceHelper
{
private:
friend class ServerDispatcher;
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* SERVERSESERVICE_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class ServerReader;
class ServerSession : public SessionHelper
friend class ServiceInstance;
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* SERVERSESSION_H_ */
namespace smartcard_service_api
{
+ /* LCOV_EXCL_START */
class ClientInstance;
class ServiceInstance
void closeChannels();
};
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
#endif /* SERVICEINSTANCE_H_ */
mapGranted.insert(make_pair("nfc-manager", ByteArray::EMPTY));
}
+/* LCOV_EXCL_START */
static gboolean _compare_hash(char *package, ByteArray &hash)
{
gboolean result = false;
static gboolean _check_permission(pid_t pid)
{
+#if (BUILD_GTEST != 0)
+ return true;
+#endif
+
gboolean result = false;
char package[1024];
static bool _get_se_name(unsigned int se_type, char *buf, size_t len)
{
+
bool result = false;
switch ((se_type >> 4) & 0x0F) {
return true;
}
+/* LCOV_EXCL_STOP */
static bool _init_access_control(void *connection)
{
"/org/tizen/SmartcardService/AccessControl",
&error) == false)
{
+ /* LCOV_EXCL_START */
_ERR("Can not skeleton_export %s", error->message);
g_error_free(error);
access_control = NULL;
return false;
+ /* LCOV_EXCL_STOP */
}
return true;
{
}
+ /* LCOV_EXCL_START */
int PKCS15CDFACL::loadACL(Channel *channel)
{
int result = SCARD_ERROR_OK;
return result;
}
+ /* LCOV_EXCL_STOP */
} /* namespace smartcard_service_api */
/* global variable */
GMainLoop *main_loop = NULL;
+#if (BUILD_GCOV != 0)
+extern "C" void __gcov_flush(void);
+#endif
+
#ifndef USE_AUTOSTART
static void daemonize(void)
{
_DBG("name : %s", name);
}
+/* LCOV_EXCL_START */
static void _name_lost_cb(GDBusConnection *connnection,
const gchar *name, gpointer user_data)
{
static void __sighandler(int sig)
{
_DBG("signal!! [%d]", sig);
+#if (BUILD_GCOV != 0)
+ __gcov_flush();
+#endif
}
+/* LCOV_EXCL_STOP */
int main(int argc, char *argv[])
{
daemonize();
#endif
+#if (BUILD_GCOV != 0)
+ setenv("GCOV_PREFIX", "/tmp/", 1);
+#endif
+
main_loop = g_main_loop_new(NULL, FALSE);
id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
/* release secure element.. (pure virtual function problem..) */
ServerResource::getInstance().unloadSecureElements();
+#if (BUILD_GCOV != 0)
+ __gcov_flush();
+#endif
+
return 0;
}