code sync
authorSangSoo Lee <constant.lee@samsung.com>
Tue, 11 Dec 2012 07:55:24 +0000 (16:55 +0900)
committerSangSoo Lee <constant.lee@samsung.com>
Tue, 11 Dec 2012 07:55:24 +0000 (16:55 +0900)
Change-Id: Ic551a76f2ec79d60e3bb43d42aa836298ecc825d

common/IPCHelper.cpp
common/SignatureHelper.cpp
common/include/IPCHelper.h
common/include/SignatureHelper.h
packaging/smartcard-service.spec

index b8a8993..f06dd43 100644 (file)
@@ -201,21 +201,18 @@ ERROR :
 
                        for (i = 0; i < events; i++)
                        {
-                               if (pollEvents[i].data.fd == fdPoll)
-                               {
-                                       SCARD_DEBUG("pollEvents[%d].events [%X]", i, pollEvents[i].events);
+                               SCARD_DEBUG("pollEvents[%d].events [%X]", i, pollEvents[i].events);
 
-                                       if ((pollEvents[i].events & EPOLLHUP) || (pollEvents[i].events & EPOLLERR))
-                                       {
-                                               SCARD_DEBUG_ERR("connection is closed");
-                                               result = 0;
-                                               break;
-                                       }
-                                       else if (pollEvents[i].events & EPOLLIN)
-                                       {
-                                               result = 1;
-                                               break;
-                                       }
+                               if ((pollEvents[i].events & EPOLLHUP) || (pollEvents[i].events & EPOLLERR))
+                               {
+                                       SCARD_DEBUG_ERR("connection is closed");
+                                       result = 0;
+                                       break;
+                               }
+                               else if (pollEvents[i].events & EPOLLIN)
+                               {
+                                       result = 1;
+                                       break;
                                }
                        }
                }
@@ -369,7 +366,7 @@ ERROR :
                struct epoll_event ev;
 
                ev.events = EPOLLIN | EPOLLHUP | EPOLLERR;
-               ev.data.fd = fdPoll;
+               ev.data.fd = ipcSocket;
 
                epoll_ctl(fdPoll, EPOLL_CTL_ADD, ipcSocket, &ev);
 #else
index a5dd4d6..cf59387 100644 (file)
@@ -18,6 +18,7 @@
 /* standard library header */
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 #include <unistd.h>
 #include <list>
 #include <string>
@@ -183,14 +184,17 @@ namespace smartcard_service_api
                                        {
                                                if (value != NULL && strlen(value) > 0)
                                                {
-                                                       ByteArray hash;
+                                                       ByteArray decodeValue, hash;
 
-                                                       OpensslHelper::decodeBase64String(value, hash, false);
-                                                       if (hash.getLength() > 0)
+                                                       OpensslHelper::decodeBase64String(value, decodeValue, false);
+                                                       if (decodeValue.getLength() > 0)
                                                        {
-                                                               SCARD_DEBUG("type [%d] hash [%d] : %s", type, hash.getLength(), hash.toString());
-
-                                                               certHashes.push_back(hash);
+                                                               OpensslHelper::digestBuffer("sha1", decodeValue.getBuffer(), decodeValue.getLength(), hash);
+                                                               if(hash.getLength() > 0)
+                                                               {
+                                                                       SCARD_DEBUG("type [%d] hash [%d] : %s", type, hash.getLength(), hash.toString());
+                                                                       certHashes.push_back(hash);
+                                                               }
                                                        }
                                                }
                                        }
@@ -217,54 +221,52 @@ namespace smartcard_service_api
 /* export C API */
 using namespace smartcard_service_api;
 
-EXTERN_API int signature_helper_get_certificate_hash(const char *packageName, uint8_t *hash, uint32_t *length)
+certiHash* __signature_helper_vector_to_linked_list(vector<ByteArray> &certHashes)
 {
-       int ret = -1;
-       ByteArray result;
+       vector<ByteArray>::iterator item;
+       certiHash *head, *tail, *tmp;
 
-       if (packageName == NULL || strlen(packageName) == 0 || hash == NULL || length == NULL || *length < 20)
-               return ret;
+       head = tail = NULL;
 
-       result = SignatureHelper::getCertificationHash(packageName);
-
-       if (result.isEmpty() == false)
+       for (item = certHashes.begin(); item != certHashes.end(); item++)
        {
-               memcpy(hash, result.getBuffer(), (result.getLength() < *length) ? result.getLength() : *length);
-               *length = result.getLength();
+               if((tmp = (certiHash*)calloc(1, sizeof(certiHash)))== NULL)
+                       goto ERROR;
 
-               ret = 0;
-       }
-       else
-       {
-               ret = -1;
-       }
+               tmp->length = (*item).getLength();
 
-       return ret;
-}
+               if((tmp->value = (uint8_t*)calloc(tmp->length, sizeof(uint8_t))) == NULL)
+                       goto ERROR;
 
-EXTERN_API int signature_helper_get_certificate_hash_by_pid(int pid, uint8_t *hash, uint32_t *length)
-{
-       int ret = -1;
-       ByteArray result;
+               memcpy(tmp->value, (*item).getBuffer(), tmp->length);
+               tmp->next = NULL;
 
-       if (pid < 0 || hash == NULL || length == NULL || *length < 20)
-               return ret;
+               if(head == NULL)
+               {
+                       head = tail = tmp;
+               }
+               else
+               {
+                       tail->next = tmp;
+                       tail = tmp;
+               }
+       }
+       return head;
 
-       result = SignatureHelper::getCertificationHash(pid);
+ERROR :
+               SCARD_DEBUG_ERR("mem alloc fail");
 
-       if (result.isEmpty() == false && result.getLength() < *length)
-       {
-               memcpy(hash, result.getBuffer(), result.getLength());
-               *length = result.getLength();
+               while(head)
+               {
+                       tmp = head;
+                       head = head->next;
+                       if(tmp->value != NULL)
+                               free(tmp->value);
+                       free(tmp);
+               }
 
-               ret = 0;
-       }
-       else
-       {
-               ret = -1;
-       }
+               return NULL;
 
-       return ret;
 }
 
 EXTERN_API int signature_helper_get_process_name(int pid, char *processName, uint32_t length)
@@ -279,48 +281,37 @@ EXTERN_API int signature_helper_get_process_name(int pid, char *processName, uin
        return ret;
 }
 
-EXTERN_API int signature_helper_get_certificate_hashes(const char *packageName, signature_helper_get_certificate_hashes_cb cb, void *user_param)
+EXTERN_API int signature_helper_get_certificate_hashes(const char *packageName, certiHash **hash)
 {
        int ret = -1;
        vector<ByteArray> hashes;
 
-       if (packageName == NULL || cb == NULL)
+       if (packageName == NULL)
                return ret;
 
        if (SignatureHelper::getCertificationHashes(packageName, hashes) == true)
        {
-               vector<ByteArray>::iterator item;
-
-               for (item = hashes.begin(); item != hashes.end(); item++)
-               {
-                       cb(user_param, (*item).getBuffer(), (*item).getLength());
-               }
-
+               *hash = __signature_helper_vector_to_linked_list(hashes);
                ret = 0;
        }
 
        return ret;
 }
 
-EXTERN_API int signature_helper_get_certificate_hashes_by_pid(int pid, signature_helper_get_certificate_hashes_cb cb, void *user_param)
+EXTERN_API int signature_helper_get_certificate_hashes_by_pid(int pid, certiHash **hash)
 {
        int ret = -1;
        vector<ByteArray> hashes;
 
-       if (pid <= 0 || cb == NULL)
+       if (pid <= 0)
                return ret;
 
        if (SignatureHelper::getCertificationHashes(pid, hashes) == true)
        {
-               vector<ByteArray>::iterator item;
-
-               for (item = hashes.begin(); item != hashes.end(); item++)
-               {
-                       cb(user_param, (*item).getBuffer(), (*item).getLength());
-               }
-
+               *hash = __signature_helper_vector_to_linked_list(hashes);
                ret = 0;
        }
 
        return ret;
 }
+
index c7e18bc..2826563 100644 (file)
@@ -46,7 +46,7 @@ namespace smartcard_service_api
                DispatcherHelper *dispatcher;
 #ifdef CLIENT_IPC_THREAD
 #ifdef USE_IPC_EPOLL
-               static const int EPOLL_SIZE = 128;
+               static const int EPOLL_SIZE = 5;
                int fdPoll;
                struct epoll_event *pollEvents;
 #else
index 01353b8..2d3613e 100644 (file)
@@ -55,13 +55,18 @@ extern "C"
 {
 #endif /* __cplusplus */
 
+typedef struct _certiHash
+{
+   uint8_t *value;
+   uint32_t length;
+   struct _certiHash *next;
+}certiHash;
+
 typedef void (*signature_helper_get_certificate_hashes_cb)(void *user_param, uint8_t *hash, uint32_t length);
 
 int signature_helper_get_process_name(int pid, char *processName, uint32_t length);
-int signature_helper_get_certificate_hash(const char *packageName, uint8_t *hash, uint32_t *length);
-int signature_helper_get_certificate_hash_by_pid(int pid, uint8_t *hash, uint32_t *length);
-int signature_helper_get_certificate_hashes(const char *packageName, signature_helper_get_certificate_hashes_cb cb, void *user_param);
-int signature_helper_get_certificate_hashes_by_pid(int pid, signature_helper_get_certificate_hashes_cb cb, void *user_param);
+int signature_helper_get_certificate_hashes(const char *packageName, certiHash **hash);
+int signature_helper_get_certificate_hashes_by_pid(int pid, certiHash **hash);
 
 #ifdef __cplusplus
 }
index 1ff1891..6347749 100644 (file)
@@ -1,7 +1,7 @@
 Name:       smartcard-service
 Summary:    Smartcard Service FW
-Version:    0.1.0
-Release:    28
+Version:    0.1.4
+Release:    2
 Group:      libs
 License:    Samsung Proprietary License
 Source0:    %{name}-%{version}.tar.gz