summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWonkyu Kwon <wonkyu.kwon@samsung.com>2013-04-08 13:13:28 +0900
committerWonkyu Kwon <wonkyu.kwon@samsung.com>2013-04-11 13:38:49 +0900
commit081f4b13ef79404ff0f8d0c020310a355d7ff37a (patch)
treead42407da659d9076fb1f03bf462de2a6c4bac58
parentc5284d2016000aba5d78b8f0e4f48c7bef4c6caa (diff)
downloadnfc-manager-neard-081f4b13ef79404ff0f8d0c020310a355d7ff37a.tar.gz
nfc-manager-neard-081f4b13ef79404ff0f8d0c020310a355d7ff37a.tar.bz2
nfc-manager-neard-081f4b13ef79404ff0f8d0c020310a355d7ff37a.zip
[RSA] remove unnecessary codes
- remove access control codes Change-Id: I6c9e747a87a24a58a83e5e0f7821eadc267a9699
-rw-r--r--src/manager/include/net_nfc_util_access_control_private.h29
-rw-r--r--src/manager/net_nfc_app_util.c57
-rw-r--r--src/manager/net_nfc_server_dispatcher.c1
-rw-r--r--src/manager/net_nfc_service.c7
-rw-r--r--src/manager/net_nfc_util_access_control.c305
5 files changed, 3 insertions, 396 deletions
diff --git a/src/manager/include/net_nfc_util_access_control_private.h b/src/manager/include/net_nfc_util_access_control_private.h
deleted file mode 100644
index 54845ca..0000000
--- a/src/manager/include/net_nfc_util_access_control_private.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.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://floralicense.org/license/
- *
- * 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_NFC_UTIL_ACCESS_CONTROL_PRIVATE_H
-#define NET_NFC_UTIL_ACCESS_CONTROL_PRIVATE_H
-
-#include "net_nfc_typedef_private.h"
-
-bool net_nfc_util_access_control_is_initialized(void);
-void net_nfc_util_access_control_initialize(void);
-void net_nfc_util_access_control_update_list(void);
-bool net_nfc_util_access_control_is_authorized_package(const char* pkg_name, uint8_t *aid, uint32_t length);
-void net_nfc_util_access_control_release(void);
-
-#endif
diff --git a/src/manager/net_nfc_app_util.c b/src/manager/net_nfc_app_util.c
index 7610e7b..8d09d65 100644
--- a/src/manager/net_nfc_app_util.c
+++ b/src/manager/net_nfc_app_util.c
@@ -43,7 +43,6 @@
#include "net_nfc_util_ndef_record.h"
#include "net_nfc_manager_util_private.h"
#include "net_nfc_app_util_private.h"
-#include "net_nfc_util_access_control_private.h"
//#include "syspopup_caller.h"
static bool _net_nfc_app_util_get_operation_from_record(ndef_record_s *record, char *operation, size_t length);
@@ -792,61 +791,11 @@ void _string_to_binary(const char *input, uint8_t *output, uint32_t *length)
*length = current / 2;
}
-static int _pkglist_iter_fn(const char* pkg_name, void *data)
-{
- int result = 0;
- const char *aid_string = NULL;
- uint8_t aid[1024] = { 0, };
- uint32_t length = sizeof(aid);
-
- aid_string = appsvc_get_uri((bundle *)data);
- DEBUG_SERVER_MSG("package name : %s, aid_string : %s", pkg_name, aid_string);
-
- /* convert aid string to aid */
- _string_to_binary(aid_string, aid, &length);
-
- if (net_nfc_util_access_control_is_authorized_package(pkg_name, aid, length) == true)
- {
- DEBUG_SERVER_MSG("allowed package : %s", pkg_name);
-
- /* launch */
- aul_launch_app(pkg_name, NULL);
-
- result = 1; /* break iterator */
- }
- else
- {
- DEBUG_SERVER_MSG("not allowed package : %s", pkg_name);
- }
-
- return result;
-}
-
-gboolean _invoke_get_list(gpointer data)
-{
- bundle *bd = (bundle *)data;
-
- appsvc_get_list(bd, _pkglist_iter_fn, (bundle *)bd);
-
- bundle_free(bd);
-
- return 0;
-}
-
int net_nfc_app_util_launch_se_transaction_app(uint8_t *aid, uint32_t aid_len, uint8_t *param, uint32_t param_len)
{
+ int result;
bundle *bd = NULL;
-#if 0
- /* initialize and make list */
- if (net_nfc_util_access_control_is_initialized() == false)
- {
- net_nfc_util_access_control_initialize();
- }
-#endif
-
- net_nfc_util_access_control_update_list();
-
/* launch */
bd = bundle_create();
@@ -873,11 +822,11 @@ int net_nfc_app_util_launch_se_transaction_app(uint8_t *aid, uint32_t aid_len, u
appsvc_add_data(bd, "data", param_string);
}
- appsvc_get_list(bd, _pkglist_iter_fn, (bundle *)bd);
+ result = appsvc_run_service(bd, 0, NULL, NULL);
bundle_free(bd);
- return 0;
+ return result;
}
int net_nfc_app_util_encode_base64(uint8_t *buffer, uint32_t buf_len, char *result, uint32_t max_result)
diff --git a/src/manager/net_nfc_server_dispatcher.c b/src/manager/net_nfc_server_dispatcher.c
index 79a9188..b3f7ab3 100644
--- a/src/manager/net_nfc_server_dispatcher.c
+++ b/src/manager/net_nfc_server_dispatcher.c
@@ -37,7 +37,6 @@
#include "net_nfc_service_se_private.h"
#include "net_nfc_service_test_private.h"
#include "net_nfc_manager_util_private.h"
-#include "net_nfc_util_access_control_private.h"
#include "net_nfc_server_context_private.h"
static GQueue *g_dispatcher_queue;
diff --git a/src/manager/net_nfc_service.c b/src/manager/net_nfc_service.c
index 7e16578..786fddf 100644
--- a/src/manager/net_nfc_service.c
+++ b/src/manager/net_nfc_service.c
@@ -33,7 +33,6 @@
#include "net_nfc_service_llcp_private.h"
#include "net_nfc_util_ndef_message.h"
#include "net_nfc_util_ndef_record.h"
-#include "net_nfc_util_access_control_private.h"
#include "net_nfc_server_context_private.h"
/* static variable */
@@ -679,9 +678,6 @@ void net_nfc_service_deinit(net_nfc_request_msg_t *msg)
result = net_nfc_service_se_change_se(SECURE_ELEMENT_TYPE_INVALID);
- /* release access control instance */
- net_nfc_util_access_control_release();
-
net_nfc_server_free_current_tag_info();
if (net_nfc_controller_deinit() == TRUE)
@@ -763,9 +759,6 @@ void net_nfc_service_init(net_nfc_request_msg_t *msg)
DEBUG_ERR_MSG("net_nfc_controller_confiure_discovery failed [%d]", result);
}
- /* initialize access control instance */
- net_nfc_util_access_control_initialize();
-
/*Send the Init Success Response Msg*/
{
net_nfc_response_test_t resp = { 0, };
diff --git a/src/manager/net_nfc_util_access_control.c b/src/manager/net_nfc_util_access_control.c
deleted file mode 100644
index 9f07add..0000000
--- a/src/manager/net_nfc_util_access_control.c
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Flora License, Version 1.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://floralicense.org/license/
- *
- * 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 <stdint.h>
-#include <stdbool.h>
-#include <string.h>
-#include <pthread.h>
-#include <time.h>
-#include <sys/time.h>
-
-#include "package-manager.h"
-#include "pkgmgr-info.h"
-#include "SEService.h"
-#include "Reader.h"
-#include "Session.h"
-#include "ClientChannel.h"
-#include "GPSEACL.h"
-
-#include "net_nfc_debug_private.h"
-#include "net_nfc_util_private.h"
-#include "net_nfc_manager_util_private.h"
-#include "net_nfc_util_openssl_private.h"
-
-static bool initialized = false;
-static se_service_h se_service = NULL;
-static pthread_mutex_t g_access_control_lock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t g_access_control_cond = PTHREAD_COND_INITIALIZER;
-
-#if 0
-static reader_h readers[10] = { NULL, };
-static session_h sessions[10] = { NULL, };
-static channel_h channels[10] = { NULL, };
-static gp_se_acl_h acls[10] = { NULL, };
-#endif
-
-static void _se_service_connected_cb(se_service_h handle, void *data)
-{
- if (handle != NULL)
- {
- se_service = handle;
- initialized = true;
- }
- else
- {
- DEBUG_ERR_MSG("invalid handle");
- }
- pthread_cond_signal(&g_access_control_cond);
-}
-
-bool net_nfc_util_access_control_is_initialized(void)
-{
- return initialized;
-}
-
-void net_nfc_util_access_control_initialize(void)
-{
- struct timeval now;
- struct timespec ts;
-
- if (net_nfc_util_access_control_is_initialized() == false)
- {
- pthread_mutex_lock(&g_access_control_lock);
- if (se_service_create_instance((void *)1, _se_service_connected_cb) == NULL)
- {
- DEBUG_ERR_MSG("se_service_create_instance failed");
- pthread_mutex_unlock(&g_access_control_lock);
- return;
- }
- gettimeofday(&now, NULL);
- ts.tv_sec = now.tv_sec + 1;
- ts.tv_nsec = now.tv_usec * 1000;
-
- pthread_cond_timedwait(&g_access_control_cond, &g_access_control_lock, &ts);
- pthread_mutex_unlock(&g_access_control_lock);
- }
-}
-
-void net_nfc_util_access_control_update_list(void)
-{
-#if 0
- int i;
-
- if (net_nfc_util_access_control_is_initialized() == true)
- {
- for (i = 0; i < (sizeof(acls) / sizeof(gp_se_acl_h)); i++)
- {
- if (acls[i] != NULL)
- {
- gp_se_acl_update_acl(acls[i]);
- }
- }
- }
-#endif
-}
-
-static gp_se_acl_h _get_acl(reader_h reader)
-{
- gp_se_acl_h result = NULL;
- session_h session = NULL;
-
- session = reader_open_session_sync(reader);
- if (session != NULL)
- {
- unsigned char aid[] = { 0xA0, 0x00, 0x00, 0x00, 0x63, 0x50, 0x4B, 0x43, 0x53, 0x2D, 0x31, 0x35 };
- channel_h channel = NULL;
-
- channel = session_open_logical_channel_sync(session, aid, sizeof(aid));
- if (channel != NULL)
- {
- result = gp_se_acl_create_instance(channel);
- if (result != NULL)
- {
- gp_se_acl_update_acl(result, channel);
- }
- channel_close_sync(channel);
- }
- session_close_sync(session);
- }
-
- return result;
-}
-
-static bool _is_authorized_package(gp_se_acl_h acl, const char *value, uint8_t *aid, uint32_t aid_len)
-{
- bool result = false;
- uint32_t decoded_len;
- uint8_t *decoded = NULL;
-
- if (value == NULL)
- {
- return result;
- }
-
- decoded_len = strlen(value);
-
- if (decoded_len == 0)
- {
- return result;
- }
-
- _net_nfc_util_alloc_mem(decoded, decoded_len);
- if (decoded != NULL)
- {
- if (net_nfc_util_openssl_decode_base64(value, decoded, &decoded_len, false) == true)
- {
- uint8_t hash[128];
- uint32_t hash_len = sizeof(hash);
-
- if (net_nfc_util_openssl_digest("sha1", decoded, decoded_len, hash, &hash_len) == true)
- {
- DEBUG_MSG_PRINT_BUFFER(hash, hash_len);
- result = gp_se_acl_is_authorized_access(acl, aid, aid_len, hash, hash_len);
- }
- }
-
- _net_nfc_util_free_mem(decoded);
- }
- else
- {
- DEBUG_ERR_MSG("alloc failed");
- }
-
- return result;
-}
-
-static pkgmgr_certinfo_h _get_cert_info(const char *pkg_name)
-{
- int ret = 0;
- pkgmgr_certinfo_h handle = NULL;
-
- DEBUG_MSG("package name : %s", pkg_name);
-
- if ((ret = pkgmgr_pkginfo_create_certinfo(&handle)) == 0)
- {
- if ((ret = pkgmgr_pkginfo_load_certinfo(pkg_name, handle)) == 0)
- {
- }
- else
- {
- DEBUG_ERR_MSG("pkgmgr_pkginfo_load_certinfo failed [%d]", ret);
- pkgmgr_pkginfo_destroy_certinfo(handle);
- handle = NULL;
- }
- }
- else
- {
- DEBUG_ERR_MSG("pkgmgr_pkginfo_create_certinfo failed [%d]", ret);
- }
-
- return handle;
-}
-
-bool net_nfc_util_access_control_is_authorized_package(const char *pkg_name, uint8_t *aid, uint32_t length)
-{
- bool result = false;
-
- DEBUG_SERVER_MSG("aid : { %02X %02X %02X %02X ... }", aid[0], aid[1], aid[2], aid[3]);
-
- net_nfc_util_access_control_initialize();
- {
- pkgmgr_certinfo_h cert_info = NULL;
- pkgmgrinfo_appinfo_h handle;
- char *pkgid = NULL;
-
- if(pkgmgrinfo_appinfo_get_appinfo(pkg_name, &handle) != PMINFO_R_OK)
- {
- DEBUG_ERR_MSG("pkgmgrinfo_appinfo_get_appinfo fail");
- return result;
- }
-
- if(pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid) != PMINFO_R_OK)
- {
- pkgmgrinfo_appinfo_destroy_appinfo(handle);
- DEBUG_ERR_MSG("pkgmgrinfo_appinfo_get_pkgid fail");
- return result;
- }
- cert_info = _get_cert_info(pkgid);
-
- pkgmgrinfo_appinfo_destroy_appinfo(handle);
-
- if (cert_info != NULL)
- {
- int i;
- reader_h readers[10] = { NULL, };
- int count = (sizeof(readers) / sizeof(reader_h));
-
- se_service_get_readers(se_service, readers, &count);
-
- for (i = 0; i < count && result == false; i++)
- {
- gp_se_acl_h acl = NULL;
-
- acl = _get_acl(readers[i]);
- if (acl != NULL)
- {
- int j;
- const char *value = NULL;
-
- for (j = (int)PM_AUTHOR_ROOT_CERT;
- j <= (int)PM_DISTRIBUTOR2_SIGNER_CERT && result == false;
- j++)
- {
- pkgmgr_pkginfo_get_cert_value(cert_info, (pkgmgr_cert_type)j, &value);
- result = _is_authorized_package(acl, value, aid, length);
- }
- gp_se_acl_destroy_instance(acl);
- }
- }
-
- pkgmgr_pkginfo_destroy_certinfo(cert_info);
- }
- else
- {
- /* hash not found */
- DEBUG_ERR_MSG("hash doesn't exist : %s", pkg_name);
- }
- }
-
- DEBUG_ERR_MSG("net_nfc_util_access_control_is_authorized_package end [%d]", result);
-
- return result;
-}
-
-void net_nfc_util_access_control_release(void)
-{
-#if 0
- int i;
-
- for (i = 0; i < (sizeof(acls) / sizeof(gp_se_acl_h)); i++)
- {
- if (acls[i] != NULL)
- {
- gp_se_acl_destroy_instance(acls[i]);
- acls[i] = NULL;
- }
- }
-#endif
- if (se_service != NULL)
- {
- se_service_destroy_instance(se_service);
- se_service = NULL;
-#if 0
- memset(readers, 0, sizeof(readers));
- memset(sessions, 0, sizeof(sessions));
- memset(channels, 0, sizeof(channels));
-#endif
- }
-
- initialized = false;
-}