From abcdc21134010c39cdeb827f414777f55ff5adcd Mon Sep 17 00:00:00 2001 From: Manasij Sur Roy Date: Fri, 12 May 2017 13:42:36 +0530 Subject: [PATCH 01/16] SVACE issue fix Change-Id: Ie38b89e8eca7acebd6bd84cc59af5362e87b7934 Signed-off-by: Manasij Sur Roy --- common/uafv1tlvutil/src/AttBasicFullTlvEncoder.cpp | 6 +++++- common/uafv1tlvutil/src/AttBasicSurrTlvEncoder.cpp | 6 +++++- common/uafv1tlvutil/src/DeRegReqTlvEncoder.cpp | 6 +++++- common/uafv1tlvutil/src/DeRegRespTlvEncoder.cpp | 6 +++++- common/uafv1tlvutil/src/GetInfoRespTlvEncoder.cpp | 5 ++++- common/uafv1tlvutil/src/RegAuthAssertionTlvEncoder.cpp | 4 ++++ common/uafv1tlvutil/src/RegReqTlvEncoder.cpp | 1 + common/uafv1tlvutil/src/RegRespTlvEncoder.cpp | 1 + common/uafv1tlvutil/src/SignAuthAssertionTlvEncoder.cpp | 7 ++++++- common/uafv1tlvutil/src/SignReqTlvEncoder.cpp | 6 +++++- common/uafv1tlvutil/src/Uafv1KrdTlvEncoder.cpp | 6 +++++- common/uiutil/src/PinAuthUiAdaptor.cpp | 3 ++- 12 files changed, 48 insertions(+), 9 deletions(-) diff --git a/common/uafv1tlvutil/src/AttBasicFullTlvEncoder.cpp b/common/uafv1tlvutil/src/AttBasicFullTlvEncoder.cpp index b93cc5e..233d16b 100644 --- a/common/uafv1tlvutil/src/AttBasicFullTlvEncoder.cpp +++ b/common/uafv1tlvutil/src/AttBasicFullTlvEncoder.cpp @@ -63,7 +63,11 @@ AttBasicFullTlvEncoder::decode(const unsigned char *rawData) tlv_s *root = tlv_decode(rawData); RET_IF_FAIL(root != NULL, NULL); - RET_IF_FAIL(root->tag == TAG_ATTESTATION_BASIC_FULL, NULL); + if (root->tag != TAG_ATTESTATION_BASIC_FULL) { + SAFE_DELETE(root->val); + SAFE_DELETE(root); + return NULL; + } int rawIter = 2 + 2; int endIter = rawIter + root->len; diff --git a/common/uafv1tlvutil/src/AttBasicSurrTlvEncoder.cpp b/common/uafv1tlvutil/src/AttBasicSurrTlvEncoder.cpp index 540223c..7b37eaf 100644 --- a/common/uafv1tlvutil/src/AttBasicSurrTlvEncoder.cpp +++ b/common/uafv1tlvutil/src/AttBasicSurrTlvEncoder.cpp @@ -60,7 +60,11 @@ AttBasicSurrTlvEncoder::decode(const unsigned char *rawData) tlv_s *root = tlv_decode(rawData); RET_IF_FAIL(root != NULL, NULL); - RET_IF_FAIL(root->tag == TAG_ATTESTATION_BASIC_SURROGATE, NULL); + if (root->tag != TAG_ATTESTATION_BASIC_SURROGATE) { + SAFE_DELETE(root->val); + SAFE_DELETE(root); + return NULL; + } int rawIter = 2 + 2; int endIter = rawIter + root->len; diff --git a/common/uafv1tlvutil/src/DeRegReqTlvEncoder.cpp b/common/uafv1tlvutil/src/DeRegReqTlvEncoder.cpp index 830f1d4..d4ff376 100644 --- a/common/uafv1tlvutil/src/DeRegReqTlvEncoder.cpp +++ b/common/uafv1tlvutil/src/DeRegReqTlvEncoder.cpp @@ -75,7 +75,11 @@ DeRegReqTlvEncoder::decode(const unsigned char *rawData) tlv_s *root = tlv_decode(rawData); RET_IF_FAIL(root != NULL, NULL); - RET_IF_FAIL(root->tag == TAG_UAFV1_DEREGISTER_CMD, NULL); + if (root->tag != TAG_UAFV1_DEREGISTER_CMD) { + SAFE_DELETE(root->val); + SAFE_DELETE(root); + return NULL; + } int rawIter = 2 + 2; int endIter = rawIter + root->len; diff --git a/common/uafv1tlvutil/src/DeRegRespTlvEncoder.cpp b/common/uafv1tlvutil/src/DeRegRespTlvEncoder.cpp index 1302893..e6a8ac5 100644 --- a/common/uafv1tlvutil/src/DeRegRespTlvEncoder.cpp +++ b/common/uafv1tlvutil/src/DeRegRespTlvEncoder.cpp @@ -59,7 +59,11 @@ DeRegRespTlvEncoder::decode(const unsigned char *rawData) tlv_s *root = tlv_decode(rawData); RET_IF_FAIL(root != NULL, NULL); - RET_IF_FAIL(root->tag == TAG_UAFV1_DEREGISTER_CMD_RESPONSE, NULL); + if (root->tag != TAG_UAFV1_DEREGISTER_CMD_RESPONSE) { + SAFE_DELETE(root->val); + SAFE_DELETE(root); + return NULL; + } DeregResp *getDeRegRespInfo = ALLOC(DeregResp); diff --git a/common/uafv1tlvutil/src/GetInfoRespTlvEncoder.cpp b/common/uafv1tlvutil/src/GetInfoRespTlvEncoder.cpp index 7485cd6..132a586 100644 --- a/common/uafv1tlvutil/src/GetInfoRespTlvEncoder.cpp +++ b/common/uafv1tlvutil/src/GetInfoRespTlvEncoder.cpp @@ -459,6 +459,9 @@ AuthInfoTlvEncoder::decode(const unsigned char *rawData) if (rawIter >= end_iter) break; + SAFE_DELETE(child->val); + SAFE_DELETE(child); + child = tlv_decode(rawData + rawIter); } @@ -637,8 +640,8 @@ GetInfoRespTlvEncoder::decode(const unsigned char *rawData) int end_iter = rawIter + root->len; _INFO("GetInfoRespTlvEncoder TOTAL LEN = [%d] bytes", end_iter); - RET_IF_FAIL(root->tag == TAG_UAFV1_GETINFO_CMD_RESPONSE, NULL); if (root->tag != TAG_UAFV1_GETINFO_CMD_RESPONSE) { + SAFE_DELETE(root->val); SAFE_DELETE(root); return NULL; } diff --git a/common/uafv1tlvutil/src/RegAuthAssertionTlvEncoder.cpp b/common/uafv1tlvutil/src/RegAuthAssertionTlvEncoder.cpp index a848d6d..49e1aa8 100644 --- a/common/uafv1tlvutil/src/RegAuthAssertionTlvEncoder.cpp +++ b/common/uafv1tlvutil/src/RegAuthAssertionTlvEncoder.cpp @@ -52,6 +52,7 @@ RegAuthAssertionTlvEncoder::encode(const void *authData) regAssertionKrdBuff->data = getRegAssertionKrdTlv->val; tlv_builder_add_buffer(builder, TAG_UAFV1_KRD, regAssertionKrdBuff); SAFE_DELETE(regAssertionKrdBuff); + SAFE_DELETE(getRegAssertionKrdTlv); } if(getRegAssertion->attFull != NULL) { @@ -68,6 +69,7 @@ RegAuthAssertionTlvEncoder::encode(const void *authData) tlv_builder_add_buffer(builder, TAG_ATTESTATION_BASIC_FULL, attBasicFullBuff); SAFE_DELETE(attBasicFullBuff); SAFE_DELETE(getAttBasicFullBuffInfo); + SAFE_DELETE(getAttBasicFullInfoTlv); } else if(getRegAssertion->attSur != NULL) { @@ -83,6 +85,7 @@ RegAuthAssertionTlvEncoder::encode(const void *authData) tlv_builder_add_buffer(builder, TAG_ATTESTATION_BASIC_SURROGATE, attBasicSurrBuff); SAFE_DELETE(attBasicSurrBuff); SAFE_DELETE(getAttBasicSurrInfoBuff); + SAFE_DELETE(getAttBasicSurrInfoTlv); } else { @@ -110,6 +113,7 @@ RegAuthAssertionTlvEncoder::decode(const unsigned char *rawData) tlv_s *root = tlv_decode(rawData); RET_IF_FAIL(root != NULL, NULL); if (root->tag != TAG_UAFV1_REG_ASSERTION) { + SAFE_DELETE(root->val); SAFE_DELETE(root); return NULL; } diff --git a/common/uafv1tlvutil/src/RegReqTlvEncoder.cpp b/common/uafv1tlvutil/src/RegReqTlvEncoder.cpp index 0f7b4c2..3226efd 100644 --- a/common/uafv1tlvutil/src/RegReqTlvEncoder.cpp +++ b/common/uafv1tlvutil/src/RegReqTlvEncoder.cpp @@ -88,6 +88,7 @@ RegAssertionTlvEncoder::decode(const unsigned char *rawData) tlv_s* root = tlv_decode(rawData); RET_IF_FAIL(root != NULL, NULL); if (root->tag != TAG_UAFV1_REGISTER_CMD) { + SAFE_DELETE(root->val); SAFE_DELETE(root); return NULL; } diff --git a/common/uafv1tlvutil/src/RegRespTlvEncoder.cpp b/common/uafv1tlvutil/src/RegRespTlvEncoder.cpp index a72c8a4..ef1322e 100644 --- a/common/uafv1tlvutil/src/RegRespTlvEncoder.cpp +++ b/common/uafv1tlvutil/src/RegRespTlvEncoder.cpp @@ -74,6 +74,7 @@ RegRespTlvEncoder::decode(const unsigned char *rawData) tlv_s *root = tlv_decode(rawData); RET_IF_FAIL(root != NULL, NULL); if (root->tag != TAG_UAFV1_REGISTER_CMD_RESPONSE) { + SAFE_DELETE(root->val); SAFE_DELETE(root); return NULL; } diff --git a/common/uafv1tlvutil/src/SignAuthAssertionTlvEncoder.cpp b/common/uafv1tlvutil/src/SignAuthAssertionTlvEncoder.cpp index cb08bcf..1032219 100644 --- a/common/uafv1tlvutil/src/SignAuthAssertionTlvEncoder.cpp +++ b/common/uafv1tlvutil/src/SignAuthAssertionTlvEncoder.cpp @@ -53,6 +53,7 @@ SignAuthAssertionTlvEncoder::encode(const void *authData) tlv_builder_add_buffer(builder, TAG_UAFV1_SIGNED_DATA, getSigDataBuff); SAFE_DELETE(getSigDataBuff); + SAFE_DELETE(getSigDataInfoTlv); /*1.2 end*/ } @@ -78,7 +79,11 @@ SignAuthAssertionTlvEncoder::decode(const unsigned char *rawData) tlv_s *root = tlv_decode(rawData); RET_IF_FAIL(root != NULL, NULL); - RET_IF_FAIL(root->tag == TAG_UAFV1_AUTH_ASSERTION, NULL); + if (root->tag != TAG_UAFV1_AUTH_ASSERTION) { + SAFE_DELETE(root->val); + SAFE_DELETE(root); + return NULL; + } int rawIter = 2 + 2; AuthAssertion *getAuthAssInfo = ALLOC(AuthAssertion); diff --git a/common/uafv1tlvutil/src/SignReqTlvEncoder.cpp b/common/uafv1tlvutil/src/SignReqTlvEncoder.cpp index 42c6de3..65c82fe 100644 --- a/common/uafv1tlvutil/src/SignReqTlvEncoder.cpp +++ b/common/uafv1tlvutil/src/SignReqTlvEncoder.cpp @@ -100,7 +100,11 @@ SignReqTlvEncoder::decode(const unsigned char *rawData) tlv_s *root = tlv_decode(rawData); RET_IF_FAIL(root != NULL, NULL); - RET_IF_FAIL(root->tag == TAG_UAFV1_SIGN_CMD, NULL); + if (root->tag != TAG_UAFV1_SIGN_CMD) { + SAFE_DELETE(root->val); + SAFE_DELETE(root); + return NULL; + } int rawIter = 2 + 2; int endIter = rawIter + root->len; diff --git a/common/uafv1tlvutil/src/Uafv1KrdTlvEncoder.cpp b/common/uafv1tlvutil/src/Uafv1KrdTlvEncoder.cpp index e040fae..d70db73 100644 --- a/common/uafv1tlvutil/src/Uafv1KrdTlvEncoder.cpp +++ b/common/uafv1tlvutil/src/Uafv1KrdTlvEncoder.cpp @@ -89,7 +89,11 @@ Uafv1KrdTlvEncoder::decode(const unsigned char *rawData) tlv_s* root = tlv_decode(rawData); RET_IF_FAIL(root != NULL, NULL); - RET_IF_FAIL(root->tag == TAG_UAFV1_KRD, NULL); + if (root->tag != TAG_UAFV1_KRD) { + SAFE_DELETE(root->val); + SAFE_DELETE(root); + return NULL; + } int rawIter = 2 + 2; int endIter = rawIter + root->len; diff --git a/common/uiutil/src/PinAuthUiAdaptor.cpp b/common/uiutil/src/PinAuthUiAdaptor.cpp index f8c436c..38f0d62 100644 --- a/common/uiutil/src/PinAuthUiAdaptor.cpp +++ b/common/uiutil/src/PinAuthUiAdaptor.cpp @@ -105,7 +105,6 @@ PinAuthUiAdaptor::getTokenFromUi(pin_auth_mode_e type, const std::string& appId, for (int i = 0; i < 10; i++) { uiPid = aul_launch_app_for_uid(ASM_UI_APP_NAME, b, OWNER_UID); _INFO("aul_launch_app = [%d]", uiPid); - bundle_free(b); if (uiPid < 0) { if (uiPid == AUL_R_EINVAL) _INFO("AUL_R_EINVAL"); @@ -122,6 +121,8 @@ PinAuthUiAdaptor::getTokenFromUi(pin_auth_mode_e type, const std::string& appId, } } + bundle_free(b); + if (uiPid < 0) { *err = -1; return ""; -- 2.7.4 From 5117c9eebb22663eab9c7f8dc879250cba91ea9a Mon Sep 17 00:00:00 2001 From: Manasij Sur Roy Date: Wed, 17 May 2017 10:34:22 +0530 Subject: [PATCH 02/16] SVACE issue fix Change-Id: I7f25c8ee5e4455db7e76ecee5e74a0a85fd8d751 Signed-off-by: Manasij Sur Roy --- common/uafv1tlvutil/src/GetInfoRespTlvEncoder.cpp | 16 ++++++++++++++++ common/uafv1tlvutil/src/SignedDataTlvEncoder.cpp | 2 +- common/uafv1tlvutil/src/Uafv1KrdTlvEncoder.cpp | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/common/uafv1tlvutil/src/GetInfoRespTlvEncoder.cpp b/common/uafv1tlvutil/src/GetInfoRespTlvEncoder.cpp index 132a586..10d3983 100644 --- a/common/uafv1tlvutil/src/GetInfoRespTlvEncoder.cpp +++ b/common/uafv1tlvutil/src/GetInfoRespTlvEncoder.cpp @@ -463,8 +463,16 @@ AuthInfoTlvEncoder::decode(const unsigned char *rawData) SAFE_DELETE(child); child = tlv_decode(rawData + rawIter); + if (child == NULL) { + SAFE_DELETE(tlv->val); + SAFE_DELETE(tlv); + SAFE_DELETE(authInfo); + + return NULL; + } } + SAFE_DELETE(child->val); SAFE_DELETE(child); SAFE_DELETE(tlv->val); SAFE_DELETE(tlv); @@ -648,6 +656,7 @@ GetInfoRespTlvEncoder::decode(const unsigned char *rawData) tlv_s *child = tlv_decode(rawData + rawIter); if (child == NULL) { + SAFE_DELETE(root->val); SAFE_DELETE(root); return NULL; } @@ -692,6 +701,13 @@ GetInfoRespTlvEncoder::decode(const unsigned char *rawData) SAFE_DELETE(child->val); SAFE_DELETE(child); child = tlv_decode(rawData + rawIter); + if (child == NULL) { + SAFE_DELETE(root->val); + SAFE_DELETE(root); + SAFE_DELETE(getInfoResp); + + return NULL; + } } SAFE_DELETE(child->val); diff --git a/common/uafv1tlvutil/src/SignedDataTlvEncoder.cpp b/common/uafv1tlvutil/src/SignedDataTlvEncoder.cpp index 94829f0..528cd27 100644 --- a/common/uafv1tlvutil/src/SignedDataTlvEncoder.cpp +++ b/common/uafv1tlvutil/src/SignedDataTlvEncoder.cpp @@ -90,7 +90,7 @@ SignedDataTlvEncoder::decode(const unsigned char *rawData) RET_IF_FAIL(rawData != NULL, NULL); tlv_s *root = tlv_decode(rawData); - RET_IF_FAIL(rawData != NULL, NULL); + RET_IF_FAIL(root != NULL, NULL); int rawIter = 2 + 2; int endIter = rawIter + root->len; diff --git a/common/uafv1tlvutil/src/Uafv1KrdTlvEncoder.cpp b/common/uafv1tlvutil/src/Uafv1KrdTlvEncoder.cpp index d70db73..0f8640e 100644 --- a/common/uafv1tlvutil/src/Uafv1KrdTlvEncoder.cpp +++ b/common/uafv1tlvutil/src/Uafv1KrdTlvEncoder.cpp @@ -103,6 +103,7 @@ Uafv1KrdTlvEncoder::decode(const unsigned char *rawData) tlv_s *child = tlv_decode(rawData + rawIter); if (child == NULL) { free(getKrdInfo); + SAFE_DELETE(root->val); SAFE_DELETE(root); return NULL; } -- 2.7.4 From 15352499792177be948da246cac4f5bf673dbede Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Fri, 2 Jun 2017 08:20:54 +0900 Subject: [PATCH 03/16] Remove deprecated D-bus smack policies Change-Id: I1866a86eab06d7131ef7fdef9bb00b9cfdd40b69 --- packaging/org.tizen.fido-asm.conf | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/packaging/org.tizen.fido-asm.conf b/packaging/org.tizen.fido-asm.conf index 5a5fb04..d7b8b47 100644 --- a/packaging/org.tizen.fido-asm.conf +++ b/packaging/org.tizen.fido-asm.conf @@ -7,18 +7,6 @@ - - - - - - - - - - - - -- 2.7.4 From fb8ffabc2d9465d9da4c0de2192462591dc4bfdb Mon Sep 17 00:00:00 2001 From: jkjo92 Date: Mon, 12 Jun 2017 20:43:29 +0900 Subject: [PATCH 04/16] Changed to non-root deamon Change-Id: Ic8456a3eec8eb8bf95364318d70efb8eb1f50fc4 Signed-off-by: jkjo92 --- packaging/fido-asm.service | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packaging/fido-asm.service b/packaging/fido-asm.service index 132bf2a..4e34663 100644 --- a/packaging/fido-asm.service +++ b/packaging/fido-asm.service @@ -8,3 +8,6 @@ ExecStart=/usr/bin/fido-asm [Install] WantedBy=multi-user.target + +User=service_fw +Group=service_fw -- 2.7.4 From 5efdadd345418819f01d1a387c240367d85e0d3e Mon Sep 17 00:00:00 2001 From: Manasij Sur Roy Date: Fri, 16 Jun 2017 17:07:38 +0530 Subject: [PATCH 05/16] Added missing title and description support Change-Id: I68e3004a330d7bbb217df168f4360aac377e9001 Signed-off-by: Manasij Sur Roy --- server/auth_discovery/src/BAuthStub.cpp | 4 ++-- silent_auth/silent_auth_entry.cpp | 16 ++++++++++++++++ silent_auth/silent_auth_entry.h | 5 +++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/server/auth_discovery/src/BAuthStub.cpp b/server/auth_discovery/src/BAuthStub.cpp index a4eb035..88bc19d 100644 --- a/server/auth_discovery/src/BAuthStub.cpp +++ b/server/auth_discovery/src/BAuthStub.cpp @@ -79,8 +79,8 @@ BAuthStub::getInfo(void) /*Fill-up additional data*/ __cachedData->attach_hint = ATTACHMENT_HINT_INTERNAL; /*__cachedData->attach_hint = __pluginHandle->conn->attach_hint();*/ - /*__cachedData->title = __pluginHandle->conn->title();*/ - /*__cachedData->description = __pluginHandle->conn->description();*/ + __cachedData->title = __pluginHandle->conn->title(); + __cachedData->description = __pluginHandle->conn->description(); } /*Resetting fields altered during last RA operation*/ diff --git a/silent_auth/silent_auth_entry.cpp b/silent_auth/silent_auth_entry.cpp index ac23823..ac3718f 100644 --- a/silent_auth/silent_auth_entry.cpp +++ b/silent_auth/silent_auth_entry.cpp @@ -1114,6 +1114,22 @@ fido_auth_plugin_de_init(void) return 0; } +EXPORT_API char * +fido_auth_plugin_get_title(void) +{ + char *title = (char *)calloc(128, sizeof(char)); + snprintf(title, 128 - 1, "%s", "Tizen FIDO Authenticator"); + return title; +} + +EXPORT_API char * +fido_auth_plugin_get_description(void) +{ + char *desc = (char *)calloc(128, sizeof(char)); + snprintf(desc, 128 - 1, "%s", "Tizen FIDO PIN Authenticator"); + return desc; +} + /*int fido_auth_plugin_get_assertion_scheme(char **scheme); unsigned char* fido_auth_plugin_encode_assertion(int tag, const void *data); void* fido_auth_plugin_decode_assertion(int tag, unsigned char *assrt);*/ diff --git a/silent_auth/silent_auth_entry.h b/silent_auth/silent_auth_entry.h index 3c65036..3486943 100644 --- a/silent_auth/silent_auth_entry.h +++ b/silent_auth/silent_auth_entry.h @@ -29,6 +29,11 @@ fido_auth_plugin_is_connected(void); EXPORT_API int fido_auth_plugin_de_init(void); +EXPORT_API char * +fido_auth_plugin_get_title(void); + +EXPORT_API char * +fido_auth_plugin_get_description(void); //int fido_auth_plugin_get_assertion_scheme(char **scheme); //unsigned char* fido_auth_plugin_encode_assertion(int tag, const void *data); //void* fido_auth_plugin_decode_assertion(int tag, unsigned char *assrt); -- 2.7.4 From 2649ce10558f2f0eb80f4f7f8469c0788f58c7d9 Mon Sep 17 00:00:00 2001 From: Manasij Sur Roy Date: Mon, 19 Jun 2017 13:22:27 +0530 Subject: [PATCH 06/16] KONA reported issues fixed, removed unused components Change-Id: Ic063876bb15268eceb837e646a2f8067612617a0 Signed-off-by: Manasij Sur Roy --- CMakeLists.txt | 6 - ble_roaming_agent/CMakeLists.txt | 45 --- ble_roaming_agent/inc/BTRoamingKeys.h | 18 - ble_roaming_agent/src/bt_ragent_main.c | 41 --- ble_roaming_agent/src/fido_gatt_server.c | 312 ----------------- ble_roaming_agent/src/fido_gatt_server.h | 9 - bt_roaming_agent/src/bt_server.c | 2 + common/cryptoutil/src/AsmCrypto.cpp | 13 + fido-ble-ragent.manifest | 5 - packaging/fido-asm.spec | 68 ---- roaming_agent/CMakeLists.txt | 47 --- roaming_agent/inc/RoamingKeys.h | 16 - roaming_agent/src/iotcon_handler.c | 504 ---------------------------- roaming_agent/src/iotcon_handler.h | 15 - roaming_agent/src/ragent_main.c | 43 --- server/CMakeLists.txt | 1 - server/auth_discovery/inc/BleAdProvider.h | 39 --- server/auth_discovery/inc/BleCon.h | 48 --- server/auth_discovery/inc/BtAdProvider.h | 1 + server/auth_discovery/inc/IoTCon.h | 28 -- server/auth_discovery/inc/IotADProvider.h | 57 ---- server/auth_discovery/inc/RoamingUtil.h | 4 - server/auth_discovery/src/AuthManager.cpp | 25 -- server/auth_discovery/src/BleAdProvider.cpp | 415 ----------------------- server/auth_discovery/src/BleCon.cpp | 106 ------ server/auth_discovery/src/BtADProvider.cpp | 12 +- server/auth_discovery/src/BtCon.cpp | 1 - server/auth_discovery/src/IoTCon.cpp | 121 ------- server/auth_discovery/src/IotADProvider.cpp | 217 ------------ server/auth_discovery/src/RAuthStub.cpp | 1 - server/auth_discovery/src/RoamingUtil.cpp | 66 ---- 31 files changed, 23 insertions(+), 2263 deletions(-) delete mode 100644 ble_roaming_agent/CMakeLists.txt delete mode 100644 ble_roaming_agent/inc/BTRoamingKeys.h delete mode 100644 ble_roaming_agent/src/bt_ragent_main.c delete mode 100644 ble_roaming_agent/src/fido_gatt_server.c delete mode 100644 ble_roaming_agent/src/fido_gatt_server.h delete mode 100644 fido-ble-ragent.manifest delete mode 100644 roaming_agent/CMakeLists.txt delete mode 100644 roaming_agent/inc/RoamingKeys.h delete mode 100644 roaming_agent/src/iotcon_handler.c delete mode 100644 roaming_agent/src/iotcon_handler.h delete mode 100644 roaming_agent/src/ragent_main.c delete mode 100644 server/auth_discovery/inc/BleAdProvider.h delete mode 100644 server/auth_discovery/inc/BleCon.h delete mode 100644 server/auth_discovery/inc/IoTCon.h delete mode 100644 server/auth_discovery/inc/IotADProvider.h delete mode 100644 server/auth_discovery/src/BleAdProvider.cpp delete mode 100644 server/auth_discovery/src/BleCon.cpp delete mode 100644 server/auth_discovery/src/IoTCon.cpp delete mode 100644 server/auth_discovery/src/IotADProvider.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 1aabe10..1807ca2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,17 +5,11 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "\${prefix}") SET(INCLUDEDIR "\${prefix}/include ") -##ADD_SUBDIRECTORY(common) ADD_SUBDIRECTORY(server) -##ADD_SUBDIRECTORY(test/shell_tc) ADD_SUBDIRECTORY(silent_auth) ADD_SUBDIRECTORY(ui) -ADD_SUBDIRECTORY(roaming_agent) ADD_SUBDIRECTORY(common/dbus_interfaces) ADD_SUBDIRECTORY(bt_roaming_agent) -##ADD_SUBDIRECTORY(ble_roaming_agent) ADD_DEPENDENCIES(fido-asm fido-asm-dbus) ADD_DEPENDENCIES(fido-bt-ragent-service fido-asm-dbus) -##ADD_DEPENDENCIES(fido-ble-ragent-service fido-asm-dbus) -ADD_DEPENDENCIES(fido-roaming-agent-service fido-asm-dbus) ADD_DEPENDENCIES(asmui fido-asm-dbus) diff --git a/ble_roaming_agent/CMakeLists.txt b/ble_roaming_agent/CMakeLists.txt deleted file mode 100644 index f11cdcd..0000000 --- a/ble_roaming_agent/CMakeLists.txt +++ /dev/null @@ -1,45 +0,0 @@ -SET(BLE_RAGENT_DAEMON fido-ble-ragent-service) - -INCLUDE(FindPkgConfig) -pkg_check_modules(BLE_RAGENT_DAEMON_PKGS REQUIRED - dlog - glib-2.0 - capi-base-common - pkgmgr-info - gio-2.0 - gio-unix-2.0 - gmodule-2.0 - cynara-client - cynara-session - cynara-creds-gdbus - capi-network-connection - capi-base-common - capi-appfw-application - capi-appfw-app-manager - aul - json-glib-1.0 - capi-system-info - capi-system-system-settings - capi-network-bluetooth -) - -FOREACH(flag ${BLE_RAGENT_DAEMON_PKGS_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE") -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}") -SET(PKGS_LDFLAGS "${BLE_RAGENT_DAEMON_PKGS_LDFLAGS} -pie") - -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/ble_roaming_agent/inc/) - -FILE( GLOB BLE_RAGENT_DAEMON_SRCS_CC - src/*.c -) - -ADD_EXECUTABLE(${BLE_RAGENT_DAEMON} ${BLE_RAGENT_DAEMON_SRCS_CC}) - -TARGET_LINK_LIBRARIES(${BLE_RAGENT_DAEMON} ${BLE_RAGENT_DAEMON_PKGS_LDFLAGS} fido-asm-dbus "-ldl") - -INSTALL(TARGETS ${BLE_RAGENT_DAEMON} DESTINATION bin) diff --git a/ble_roaming_agent/inc/BTRoamingKeys.h b/ble_roaming_agent/inc/BTRoamingKeys.h deleted file mode 100644 index 5c066b8..0000000 --- a/ble_roaming_agent/inc/BTRoamingKeys.h +++ /dev/null @@ -1,18 +0,0 @@ -#include - -#ifndef _BT_ROAMINGKEYS_H -#define _BT_ROAMINGKEYS_H - -#define RA_BLE_FRAME_MAX_SIZE 20 -/*TODO: Change to some other uids*/ -#define RA_BLE_ADVERTISING_UUID "89D3502B-0F36-433A-8EF4-C502AD55F8DC" -#define RA_BLE_SERVICE_UUID "89D3502B-0F36-433A-8EF4-C502AD55F8DC" -#define RA_BLE_UUID_REQUEST "9B3C81D8-57B1-4A8A-B8DF-0E56F7CA51C2" -#define RA_BLE_UUID_RESPONSE "2F7CABCE-808D-411F-9A0C-BB92BA96C102" -#define RA_BLE_SERVICE_REVISION "1.0" -#define RA_BLE_FRAME_MAX_SIZE 20 -#define RA_BLE_DATA_MAX_SIZE 65536 - -#define BT_DISC_TIMEOUT_SEC 5 - -#endif // _BT_ROAMINGKEYS_H diff --git a/ble_roaming_agent/src/bt_ragent_main.c b/ble_roaming_agent/src/bt_ragent_main.c deleted file mode 100644 index 01f52f4..0000000 --- a/ble_roaming_agent/src/bt_ragent_main.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2014 - 2015 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 -#include - -#include "fido_gatt_server.h" -#include "AsmHelper.h" - -int -main(int argc, char *argv[]) -{ - _INFO("Starting BT Roaming Agent Service"); - - GMainLoop *mainloop = g_main_loop_new(NULL, FALSE); - - int ret = fido_gatt_server_init(); - _INFO("fido_gatt_server_init=[%d]", ret); - - g_main_loop_run(mainloop); - - _INFO("Stopping BT Roaming Agent Service"); - ret = fido_gatt_server_shutdown(); - _INFO("[%d]", ret); - - return 0; -} diff --git a/ble_roaming_agent/src/fido_gatt_server.c b/ble_roaming_agent/src/fido_gatt_server.c deleted file mode 100644 index d53328e..0000000 --- a/ble_roaming_agent/src/fido_gatt_server.c +++ /dev/null @@ -1,312 +0,0 @@ - -#include -#include -#include -#include - -#include - -#include "fido_gatt_server.h" -#include "BTRoamingKeys.h" -#include "AsmHelper.h" -#include "fido-client-ipc-stub.h" - -#include -#include -#include -#include - -static bool __isStarted = false; - -static Fidoasm* -__asm_get_dbus_proxy(void) -{ -#if !GLIB_CHECK_VERSION(2, 35, 0) - g_type_init(); -#endif - - GDBusConnection *connection = NULL; - GError *error = NULL; - - connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); - - /* Create the object */ - Fidoasm *dbus_proxy = fidoasm_proxy_new_sync(connection, - G_DBUS_PROXY_FLAGS_NONE, - "org.tizen.fidoasm", - "/org/tizen/fidoasm", - NULL, - &error); - - if (error != NULL) - _ERR("bluetooth fidoasm_proxy_new_sync failed %s", error->message); - - return dbus_proxy; -} - -static void -__ra_notify_cb(int result, const char *remote_address, bt_gatt_server_h server, - bt_gatt_h characteristic, bool completed, void *user_data) -{ - _INFO("bluetooth ragent __ra_notify_cb=[%d]", result); -} - -static void -__ra__write_value_requested_cb(const char *remote_address, int request_id, bt_gatt_server_h server, - bt_gatt_h gatt_handle, int offset, - const char *value, int len, void *user_data) -{ - _INFO("bluetooth ragent __ra__write_value_requested_cb=[%s]", value); - - /*Call ASM dbus and receive the response*/ - Fidoasm *asm_proxy = __asm_get_dbus_proxy(); - if (asm_proxy == NULL) { - _ERR("bluetooth Failed to get ASM proxy"); - bt_gatt_server_send_response(request_id, BT_GATT_REQUEST_TYPE_WRITE, - offset, -1, NULL, 0); - return; - } - - - const char *tlvReqB64 = value; - char *tlvRespB64 = NULL; - GError *gErr = NULL; - int tz_err = 0; - fidoasm_call_asm_request_sync(asm_proxy, tlvReqB64, - &tz_err, &tlvRespB64, NULL, &gErr); - if (gErr != NULL) { - - bt_gatt_server_send_response(request_id, BT_GATT_REQUEST_TYPE_WRITE, - offset, -1, NULL, 0); - _ERR("bluetooth Failed returned from ASM"); - return; - } - - int ret = bt_gatt_set_value(gatt_handle, tlvRespB64, strlen(tlvRespB64)); - _INFO("bluetooth ragent bt_gatt_set_value=[%d]", ret); - - bt_gatt_server_send_response(request_id, BT_GATT_REQUEST_TYPE_WRITE, offset, 0, NULL, 0); - - ret = bt_gatt_server_notify_characteristic_changed_value(gatt_handle, __ra_notify_cb, remote_address, NULL); - _INFO("bluetooth ragent bt_gatt_server_notify_characteristic_changed_value=[%d]", ret); -} - -static void -__advertising_state_changed_cb(int result, bt_advertiser_h advertiser, - bt_adapter_le_advertising_state_e adv_state, void* user_data) -{ - _INFO("bluetooth ragent __advertising_state_changed_cb=[%d]", adv_state); -} - -#define MAX_BLE_SIZE 1024 - -static void -onGattConchanged(int result, bool connected, const char *remote_address, void *user_data) -{ - _INFO("remote_address=[%s]", remote_address); - _INFO("connected=[%d]", connected); - _INFO("[%d]", result); -} - -static int -__fido_gatt_server_start(void) -{ - _INFO("bluetooth Request to start GATT server"); - - if (__isStarted == true) { - _INFO("bluetooth Already started"); - return 0; - } - - _INFO("bluetooth New GATT server"); - __isStarted = true; - - bt_gatt_set_connection_state_changed_cb(onGattConchanged, NULL); - - int ret = BT_ERROR_NONE; - bt_gatt_server_h server = NULL; - bt_gatt_h service = NULL; - bt_gatt_h ctrl_pt_write_req = NULL; - bt_gatt_h ctrl_pt_notif_resp = NULL; - int permissions = BT_GATT_PERMISSION_READ | BT_GATT_PERMISSION_WRITE; - - /*Notification enabled */ - char *reqVal = (char*)calloc(MAX_BLE_SIZE, sizeof(char)); - char *respVal = (char*)calloc(MAX_BLE_SIZE, sizeof(char)); - - ret = bt_gatt_server_initialize(); - if (ret != BT_ERROR_NONE) { - _ERR("bluetooth ragent bt_gatt_server_initialize=[%d]", ret); - goto FAIL; - } - - ret = bt_gatt_server_create(&server); - if (ret != BT_ERROR_NONE) { - _ERR("bluetooth ragent bt_gatt_server_create=[%d]", ret); - goto FAIL; - } - - _INFO("bluetooth ragent gatt service create"); - ret = bt_gatt_service_create(RA_BLE_SERVICE_UUID, BT_GATT_SERVICE_TYPE_PRIMARY, &service); - if (ret != BT_ERROR_NONE) - goto FAIL; - - _INFO("bluetooth ragent Create GATT Characteristic"); - /* Create GATT Characteristic */ - ret = bt_gatt_characteristic_create(RA_BLE_UUID_REQUEST, - permissions, - BT_GATT_PROPERTY_WRITE, - reqVal, - MAX_BLE_SIZE, - &ctrl_pt_write_req); - if (ret != BT_ERROR_NONE) - goto FAIL; - - ret = bt_gatt_characteristic_create(RA_BLE_UUID_RESPONSE, - permissions, - BT_GATT_PROPERTY_NOTIFY, - respVal, - MAX_BLE_SIZE, - &ctrl_pt_notif_resp); - - _INFO("bluetooth ragent set GATT Characterisitic Callback"); - - ret = bt_gatt_server_set_write_value_requested_cb(ctrl_pt_write_req, - __ra__write_value_requested_cb, NULL); - if (ret != BT_ERROR_NONE) - goto FAIL; - - _INFO("bluetooth ragent Add GATT Characteristic in service"); - /* add GATT Characteristic in service */ - ret = bt_gatt_service_add_characteristic(service, ctrl_pt_write_req); - if (ret != BT_ERROR_NONE) - goto FAIL; - - ret = bt_gatt_service_add_characteristic(service, ctrl_pt_notif_resp); - if (ret != BT_ERROR_NONE) - goto FAIL; - - _INFO("bluetooth ragent Register GATT Service"); - ret = bt_gatt_server_register_service(server, service); - if (ret != BT_ERROR_NONE) { - _INFO("bluetooth ragent can not register gatt service."); - goto FAIL; - } - - - _INFO("bluetooth ragent GATT Server Done"); - - ret = bt_gatt_server_start(); - if (ret != BT_ERROR_NONE) { - _INFO("bluetooth ragent bt_gatt_server_start failed = [%d]", ret); - goto FAIL; - } - - _INFO("bluetooth ragent GATT Server started"); - - _INFO("bluetooth ragent starting LE adv"); - bt_advertiser_h adv_handle = NULL; - ret = bt_adapter_le_create_advertiser(&adv_handle); - if (ret != BT_ERROR_NONE) { - _INFO("bluetooth ragent bt_adapter_le_create_advertiser failed = [%d]", ret); - goto FAIL; - } - - _INFO("bluetooth ragent after bt_adapter_le_create_advertiser"); - - ret = bt_adapter_le_set_advertising_connectable(adv_handle, true); - if (ret != BT_ERROR_NONE) { - _INFO("bluetooth ragent bt_adapter_le_set_advertising_connectable failed = [%d]", ret); - goto FAIL; - } - - _INFO("bluetooth ragent after bt_adapter_le_set_advertising_connectable"); - - ret = bt_adapter_le_add_advertising_service_uuid(adv_handle, - BT_ADAPTER_LE_PACKET_ADVERTISING, RA_BLE_ADVERTISING_UUID); - if (ret != BT_ERROR_NONE) { - _INFO("bluetooth ragent bt_adapter_le_add_advertising_service_uuid failed = [%d]", ret); - goto FAIL; - } - - _INFO("bluetooth ragent after bt_adapter_le_add_advertising_service_uuid"); - - ret = bt_adapter_le_set_advertising_device_name(adv_handle, - BT_ADAPTER_LE_PACKET_SCAN_RESPONSE, true); - if (ret != BT_ERROR_NONE) { - _INFO("bluetooth ragent bt_adapter_le_set_advertising_device_name failed = [%d]", ret); - goto FAIL; - } - - _INFO("bluetooth ragent after bt_adapter_le_set_advertising_device_name"); - - ret = bt_adapter_le_start_advertising_new(adv_handle, - __advertising_state_changed_cb, adv_handle); - if (ret != BT_ERROR_NONE) { - _INFO("bluetooth ragent bt_adapter_le_start_advertising_new failed = [%d]", ret); - goto FAIL; - } - - _INFO("bluetooth ragent LE adv done"); - return 0; - -FAIL: - _INFO("bluetooth ragent ERROR"); - bt_gatt_characteristic_destroy(ctrl_pt_write_req); - bt_gatt_characteristic_destroy(ctrl_pt_notif_resp); - bt_gatt_service_destroy(service); - bt_gatt_server_destroy(server); - - return -1; -} - -static int -__fido_gatt_server_stop(void) -{ - _INFO("bluetooth Stopping GATT server"); - __isStarted = false; - bt_gatt_server_deinitialize(); - return 0; -} - -static void -__bt_state_changed_cb(int result, bt_adapter_state_e adapter_state, void* user_data) -{ - _INFO("bluetooth __bt_state_changed_cb=[%d]", adapter_state); - if (adapter_state == BT_ADAPTER_ENABLED) { - __fido_gatt_server_start(); - } -} - -int -fido_gatt_server_shutdown(void) -{ - return __fido_gatt_server_stop(); -} - -int -fido_gatt_server_init(void) -{ - int ret = bt_initialize(); - if ((ret != BT_ERROR_NONE) && (ret != BT_ERROR_ALREADY_DONE)) { - _ERR("bluetooth bt_init failed = [%d]", ret); - return -1; - } - - __isStarted = false; - - bt_adapter_set_state_changed_cb(__bt_state_changed_cb, NULL); - - bt_adapter_state_e adapter_state = BT_ADAPTER_DISABLED; - ret = bt_adapter_get_state(&adapter_state); - if (ret != BT_ERROR_NONE) { - _ERR("bluetooth bt_adapter_get_state failed = [%d]", ret); - return -1; - } - - if (adapter_state == BT_ADAPTER_ENABLED) { - return __fido_gatt_server_start(); - } - - return 0; -} diff --git a/ble_roaming_agent/src/fido_gatt_server.h b/ble_roaming_agent/src/fido_gatt_server.h deleted file mode 100644 index b03954b..0000000 --- a/ble_roaming_agent/src/fido_gatt_server.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _FIDO_GATT_SERVER_H_ -#define _FIDO_GATT_SERVER_H_ - - -int fido_gatt_server_init(void); -int fido_gatt_server_shutdown(void); - - -#endif /* _FIDO_GATT_SERVER_H_ */ diff --git a/bt_roaming_agent/src/bt_server.c b/bt_roaming_agent/src/bt_server.c index ce0ed1a..0154dd6 100644 --- a/bt_roaming_agent/src/bt_server.c +++ b/bt_roaming_agent/src/bt_server.c @@ -503,5 +503,7 @@ bt_server_stop(void) bt_socket_destroy_rfcomm(server->server_socket_fd); __destroy_server_handle(server); server = NULL; + int ret = bt_deinitialize(); + _INFO("bt_deinitialize=[%d]", ret); return 0; } diff --git a/common/cryptoutil/src/AsmCrypto.cpp b/common/cryptoutil/src/AsmCrypto.cpp index c42d9cb..24eb33d 100644 --- a/common/cryptoutil/src/AsmCrypto.cpp +++ b/common/cryptoutil/src/AsmCrypto.cpp @@ -156,6 +156,8 @@ AsmCrypto::getAsmToken(void) _INFO("%s", macStr.c_str()); asmTok = strdup(macClone); SAFE_DELETE(macClone); + + bt_deinitialize(); return macStr; } } else { @@ -172,6 +174,8 @@ AsmCrypto::getAsmToken(void) _INFO("%s", macStr.c_str()); asmTok = strdup(macClone); SAFE_DELETE(macClone); + + bt_deinitialize(); return macStr; } @@ -214,6 +218,7 @@ AsmCrypto::getAsmToken(void) asmTok = strdup(mac); SAFE_DELETE(mac); + bt_deinitialize(); return tok; } else { @@ -222,11 +227,15 @@ AsmCrypto::getAsmToken(void) if (size <= 0) { fclose(file); _END; + + bt_deinitialize(); return std::string(); } else if (size > 1000) { _ERR("Too big config file, size=[%d], allowed=[1000]", size); fclose(file); _END; + + bt_deinitialize(); return std::string(); } @@ -238,6 +247,8 @@ AsmCrypto::getAsmToken(void) free(config); fclose(file); _END; + + bt_deinitialize(); return std::string(); } @@ -249,6 +260,8 @@ AsmCrypto::getAsmToken(void) _END; asmTok = strdup(config); SAFE_DELETE(config); + + bt_deinitialize(); return tok; } } diff --git a/fido-ble-ragent.manifest b/fido-ble-ragent.manifest deleted file mode 100644 index 97e8c31..0000000 --- a/fido-ble-ragent.manifest +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/packaging/fido-asm.spec b/packaging/fido-asm.spec index 83ef1df..d327014 100644 --- a/packaging/fido-asm.spec +++ b/packaging/fido-asm.spec @@ -9,8 +9,6 @@ Source0: fido-asm-%{version}.tar.gz Source1: org.tizen.fido-asm.service Source2: org.tizen.fido-asm.conf Source3: fido-asm.service -Source4: fido-roaming-agent.service -##Source5: fido-ble-roaming-agent.service Source6: fido-bt-roaming-agent.service BuildRequires: cmake @@ -91,10 +89,6 @@ install -m 644 %SOURCE3 %{buildroot}%{_unitdir}/fido-asm.service mkdir -p %{buildroot}%{_libdir}/fido/asm/auth mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants -install -m 0644 %SOURCE4 %{buildroot}%{_unitdir}/fido-roaming-agent.service -%install_service multi-user.target.wants fido-roaming-agent.service - -mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants install -m 0644 %SOURCE6 %{buildroot}%{_unitdir}/fido-bt-roaming-agent.service %install_service multi-user.target.wants fido-bt-roaming-agent.service @@ -261,68 +255,6 @@ rm -r /opt/usr/data/silent_auth/ /opt/usr/data/silent_auth/fido_tizen_auth.key ################################################################################# -# FIDO IoT Roaming Agent -################################################################################# -%package -n fido_roaming_agent -Summary: FIDO Roaming Agent -Group: Account - -BuildRequires: cmake -BuildRequires: pkgconfig(capi-appfw-application) -BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(bundle) -BuildRequires: pkgconfig(json-glib-1.0) -BuildRequires: pkgconfig(glib-2.0) >= 2.26 -BuildRequires: pkgconfig(gio-unix-2.0) -BuildRequires: pkgconfig(capi-network-connection) - - -%description -n fido_roaming_agent -FIDO Roaming Agent IoTivity Server - -%post -n fido_roaming_agent -mkdir -p /opt/data/fido-ra/ -chown -R service_fw:service_fw /opt/data/fido-ra/ -chsmack -a '_' /opt/data/fido-ra/ - -chown -R service_fw:service_fw /opt/data/fido-ra/*.dat -chsmack -a '_' /opt/data/fido-ra/*.dat - -%files -n fido_roaming_agent -%manifest fido-roaming-agent.manifest -%{_bindir}/* -%{_unitdir}/fido-roaming-agent.service -%{_unitdir}/multi-user.target.wants/fido-roaming-agent.service -%attr(0777,service_fw,service_fw)/opt/data/fido-ra/*.dat - -################################################################################# -# FIDO BLE Roaming Agent -################################################################################# -##%package -n fido_ble_roaming_agent -##Summary: FIDO BLE Roaming Agent -##Group: Account - -##BuildRequires: cmake -##BuildRequires: pkgconfig(capi-appfw-application) -##BuildRequires: pkgconfig(dlog) -##BuildRequires: pkgconfig(bundle) -##BuildRequires: pkgconfig(json-glib-1.0) -##BuildRequires: pkgconfig(glib-2.0) >= 2.26 -##BuildRequires: pkgconfig(gio-unix-2.0) -##BuildRequires: pkgconfig(capi-network-connection) -##BuildRequires: pkgconfig(capi-network-bluetooth) - - -##%description -n fido_ble_roaming_agent -##FIDO BT Roaming Agent GATT Server - -##%files -n fido_ble_roaming_agent -##%manifest fido-ble-ragent.manifest -##%{_bindir}/fido-ble-ragent-service -##%{_unitdir}/fido-ble-roaming-agent.service -##%{_unitdir}/multi-user.target.wants/fido-ble-roaming-agent.service - -################################################################################# # FIDO BT Roaming Agent ################################################################################# %package -n fido_bt_roaming_agent diff --git a/roaming_agent/CMakeLists.txt b/roaming_agent/CMakeLists.txt deleted file mode 100644 index 3039ec9..0000000 --- a/roaming_agent/CMakeLists.txt +++ /dev/null @@ -1,47 +0,0 @@ -SET(RAGENT_DAEMON fido-roaming-agent-service) - -INCLUDE(FindPkgConfig) -pkg_check_modules(RAGENT_DAEMON_PKGS REQUIRED - dlog - db-util - glib-2.0 - capi-base-common - pkgmgr-info - gio-2.0 - gio-unix-2.0 - gmodule-2.0 - cynara-client - cynara-session - cynara-creds-gdbus - capi-network-connection - capi-base-common - capi-appfw-application - capi-appfw-app-manager - aul - json-glib-1.0 - iotcon - capi-system-info - capi-system-system-settings -) - -FOREACH(flag ${RAGENT_DAEMON_PKGS_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE") -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}") -SET(PKGS_LDFLAGS "${RAGENT_DAEMON_PKGS_LDFLAGS} -pie") - -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/common) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/roaming_agent/inc/) - -FILE( GLOB RAGENT_DAEMON_SRCS_CC - src/*.c -) - -ADD_EXECUTABLE(${RAGENT_DAEMON} ${RAGENT_DAEMON_SRCS_CC}) - -TARGET_LINK_LIBRARIES(${RAGENT_DAEMON} ${RAGENT_DAEMON_PKGS_LDFLAGS} fido-asm-dbus "-ldl") - -INSTALL(TARGETS ${RAGENT_DAEMON} DESTINATION bin) -INSTALL(FILES ${CMAKE_SOURCE_DIR}/common/fido-ra-acl-server.dat DESTINATION /opt/data/fido-ra) diff --git a/roaming_agent/inc/RoamingKeys.h b/roaming_agent/inc/RoamingKeys.h deleted file mode 100644 index 3b23bf9..0000000 --- a/roaming_agent/inc/RoamingKeys.h +++ /dev/null @@ -1,16 +0,0 @@ -#include - -#ifndef ROAMINGKEYS_H -#define ROAMINGKEYS_H - -#define RA_RESOURCE_URI "/fido/auth/roaming/pin" -#define RA_RESOURCE_TYPE "org.tizen.fidoauthroamingpin" - -#define RA_QUERY_KEY_REQUEST "ra_query_prcoess_tlv" -#define RA_QUERY_KEY_SERVER_ID "ra_query_server_id" -#define RA_QUERY_KEY_RESPONSE "ra_response" - -#define RA_ACL_SERVER tzplatform_mkpath(TZ_SYS_DATA, "fido-ra/fido-ra-acl-server.dat") -#define RA_ACL_CLIENT tzplatform_mkpath(TZ_SYS_DATA, "fido-asm/fido-ra-acl-client.dat") - -#endif // ROAMINGKEYS_H diff --git a/roaming_agent/src/iotcon_handler.c b/roaming_agent/src/iotcon_handler.c deleted file mode 100644 index 1703d64..0000000 --- a/roaming_agent/src/iotcon_handler.c +++ /dev/null @@ -1,504 +0,0 @@ -/* - * iotcon_handler.c - * - * Created on: May 16, 2016 - * Author: manasij.r - */ - -#include -#include -#include -#include - -#include -#include - -#include "iotcon_handler.h" -#include "RoamingKeys.h" -#include "AsmHelper.h" -#include "fido-client-ipc-stub.h" - -#include -#include -#include - -#define IC_FEATURE_OIC "http://tizen.org/feature/iot.oic" -#define IC_FEATURE_OCF "http://tizen.org/feature/iot.ocf" - -#include - -//#define ASM_GET_INFO_RESP "{\"responseData\":{\"Authenticators\":[{\"aaid\":\"R001#8001\",\"asmVersions\":[{\"major\":1,\"minor\":0}],\"assertionScheme\":\"UAFV1TLV\",\"title\":\"UAF PIN Roaming\",\"attestationTypes\":[15879],\"tcDisplayContentType\":\"text/plain\",\"description\":\"Tizen Roaming PIN Authenticator\",\"supportedExtensionIDs\":[\"abc\"],\"icon\":\"data:image/png;base64,iVBORw0KGgoAAA\",\"isRoamingAuthenticator\":true,\"isSecondFactorOnly\":false,\"isUserEnrolled\":true,\"keyProtection\":1,\"matcherProtection\":1,\"hasSettings\":true,\"tcDisplay\":1,\"authenticatorIndex\":9,\"authenticationAlgorithm\":1,\"attachmentHint\":2,\"userVerification\":4}]},\"statusCode\":0}" - -/* ra Resource */ -typedef struct _ra_resource_s { - bool state; - char *uri_path; - char *type; - iotcon_resource_interfaces_h ifaces; - int properties; - iotcon_resource_h handle; - iotcon_observers_h observers; - iotcon_representation_h repr; -} ra_resource_s; - -static void _request_handler(iotcon_resource_h resource, iotcon_request_h request, - void *user_data); - -static Fidoasm* -__asm_get_dbus_proxy(void) -{ -#if !GLIB_CHECK_VERSION(2, 35, 0) - g_type_init(); -#endif - - GDBusConnection *connection = NULL; - GError *error = NULL; - - connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); - - /* Create the object */ - Fidoasm *dbus_proxy = fidoasm_proxy_new_sync(connection, - G_DBUS_PROXY_FLAGS_NONE, - "org.tizen.fidoasm", - "/org/tizen/fidoasm", - NULL, - &error); - - if (error != NULL) - _ERR("fidoasm_proxy_new_sync failed %s", error->message); - - return dbus_proxy; -} - -static int -_set_ra_resource(ra_resource_s *ra) -{ - _INFO("_set_ra_resource"); - - int ret; - - ra->state = false; - - ra->uri_path = strdup(RA_RESOURCE_URI); - if (NULL == ra->uri_path) { - return -1; - } - - ra->type = strdup(RA_RESOURCE_TYPE); - if (NULL == ra->type) { - free(ra->uri_path); - return -1; - } - - ret = iotcon_resource_interfaces_create(&ra->ifaces); - if (IOTCON_ERROR_NONE != ret) { - free(ra->type); - free(ra->uri_path); - return -1; - } - - ret = iotcon_resource_interfaces_add(ra->ifaces, IOTCON_INTERFACE_DEFAULT); - if (IOTCON_ERROR_NONE != ret) { - iotcon_resource_interfaces_destroy(ra->ifaces); - free(ra->type); - free(ra->uri_path); - return -1; - } - - ra->properties = IOTCON_RESOURCE_DISCOVERABLE; - -// ret = iotcon_observers_create(&ra->observers); -// if (IOTCON_ERROR_NONE != ret) { -// iotcon_resource_interfaces_destroy(ra->ifaces); -// free(ra->type); -// free(ra->uri_path); -// return -1; -// } - - _INFO("_set_ra_resource end"); - - return 0; -} - -static void _free_ra_resource(ra_resource_s *ra) -{ - iotcon_observers_destroy(ra->observers); - iotcon_resource_interfaces_destroy(ra->ifaces); - free(ra->type); - free(ra->uri_path); -} - -static iotcon_resource_h -_create_ra_resource(char *uri_path, char *type, - iotcon_resource_interfaces_h ifaces, int properties, void *user_data) -{ - _INFO("_create_ra_resource start"); - - int ret; - iotcon_resource_h handle; - iotcon_resource_types_h resource_types; - - ret = iotcon_resource_types_create(&resource_types); - if (IOTCON_ERROR_NONE != ret) { - return NULL; - } - - ret = iotcon_resource_types_add(resource_types, type); - if (IOTCON_ERROR_NONE != ret) { - iotcon_resource_types_destroy(resource_types); - return NULL; - } - - /* register ra resource */ - ret = iotcon_resource_create(uri_path, resource_types, ifaces, properties, - _request_handler, user_data, &handle); - if (IOTCON_ERROR_NONE != ret) { - iotcon_resource_types_destroy(resource_types); - return NULL; - } - - iotcon_resource_types_destroy(resource_types); - - _INFO("_create_ra_resource end"); - - return handle; -} - -static int -_send_response(iotcon_request_h request, iotcon_representation_h repr, - iotcon_response_result_e result) -{ - _INFO("_send_response start"); - - int ret; - iotcon_response_h response; - - ret = iotcon_response_create(request, &response); - if (IOTCON_ERROR_NONE != ret) { - return -1; - } - - ret = iotcon_response_set_result(response, result); - if (IOTCON_ERROR_NONE != ret) { - iotcon_response_destroy(response); - return -1; - } - - ret = iotcon_response_set_representation(response, repr); - if (IOTCON_ERROR_NONE != ret) { - iotcon_response_destroy(response); - return -1; - } - - /* send Representation to the client */ - ret = iotcon_response_send(response); - if (IOTCON_ERROR_NONE != ret) { - iotcon_response_destroy(response); - return -1; - } - - iotcon_response_destroy(response); - - _INFO("_send_response end"); - - return 0; -} - -static iotcon_representation_h -_create_ra_representation(ra_resource_s *ra, char *tlvRespB64) -{ - _INFO("_get_ra_representation start"); - - int ret; - iotcon_attributes_h state = NULL; - iotcon_representation_h repr = NULL; - - /* create a ra Representation */ - ret = iotcon_representation_create(&repr); - if (IOTCON_ERROR_NONE != ret) { - return NULL; - } - - _INFO("After iotcon_representation_create"); - - /* create a ra state */ - ret = iotcon_attributes_create(&state); - if (IOTCON_ERROR_NONE != ret) { - iotcon_representation_destroy(repr); - return NULL; - } - - _INFO("After iotcon_attributes_create"); - - ret = iotcon_representation_set_uri_path(repr, RA_RESOURCE_URI/*ra->uri_path*/); - if (IOTCON_ERROR_NONE != ret) { - iotcon_attributes_destroy(state); - iotcon_representation_destroy(repr); - return NULL; - } - - _INFO("After iotcon_representation_set_uri_path"); - - /*TODO:Call Mobile ASM with the incoming query (Base64 decoded TLV)*/ - //char tlv_b64_dec[5000] = {0,}; - //snprintf(tlv_b64_dec, 4999, "%s", ASM_GET_INFO_RESP); - ret = iotcon_attributes_add_str(state, RA_QUERY_KEY_RESPONSE, tlvRespB64); - if (IOTCON_ERROR_NONE != ret) { - iotcon_attributes_destroy(state); - iotcon_representation_destroy(repr); - return NULL; - } - - _INFO("After iotcon_attributes_add_str"); - ret = iotcon_representation_set_attributes(repr, state); - if (IOTCON_ERROR_NONE != ret) { - iotcon_attributes_destroy(state); - iotcon_representation_destroy(repr); - return NULL; - } - - //iotcon_attributes_destroy(state); - - _INFO("After end [%p]", repr); - return repr; -} - -char* -__getServerId(void) -{ - connection_h conn = NULL; - connection_create(&conn); - - static char *mac = NULL; - if (mac != NULL) - return mac; - - /*Try: Ethernet*/ - int ret = connection_get_mac_address(conn, CONNECTION_TYPE_ETHERNET, &mac); - - /*Try: Wifi*/ - if (ret != CONNECTION_ERROR_NONE) - ret = connection_get_mac_address(conn, CONNECTION_TYPE_WIFI, &mac); - - /*Try: BT*/ - if (ret != CONNECTION_ERROR_NONE) - ret = connection_get_mac_address(conn, CONNECTION_TYPE_BT, &mac); - - return mac; -} - -static int -_request_handler_put(ra_resource_s *ra, iotcon_request_h request) -{ - _INFO("_request_handler_put start"); - - int ret = 0; - - iotcon_representation_h repr = NULL; - iotcon_request_get_representation(request, &repr); - if (repr == NULL) { - _ERR("iotcon_request_get_representation failed"); - return -1; - } - - iotcon_attributes_h attr = NULL; - iotcon_representation_get_attributes(repr, &attr); - if (attr == NULL) { - _ERR("iotcon_representation_get_attributes failed"); - return -1; - } - - char *tlvReqB64 = NULL; - iotcon_attributes_get_str(attr, RA_QUERY_KEY_REQUEST, &tlvReqB64); - if (tlvReqB64 == NULL) { - _ERR("[%s] key missing", RA_QUERY_KEY_REQUEST); - _send_response(request, NULL, IOTCON_RESPONSE_ERROR); - - return -1; - } - - char *serverId = NULL; - iotcon_attributes_get_str(attr, RA_QUERY_KEY_SERVER_ID, &serverId); - if (serverId == NULL) { - _ERR("[%s] key missing", RA_QUERY_KEY_SERVER_ID); - _send_response(request, NULL, IOTCON_RESPONSE_ERROR); - - return -1; - } - - if (strcmp(serverId, __getServerId()) == 0) { - _ERR("Request from same Device is ignored"); - _send_response(request, NULL, IOTCON_RESPONSE_ERROR); - - return -1; - } - - - /*Call ASM dbus and receive the response*/ - Fidoasm *asm_proxy = __asm_get_dbus_proxy(); - if (asm_proxy == NULL) { - _ERR("Failed to get ASM proxy"); - _send_response(request, NULL, IOTCON_RESPONSE_ERROR); - return -1; - } - - - char *tlvRespB64 = NULL; - GError *gErr = NULL; - int tz_err = 0; - fidoasm_call_asm_request_sync(asm_proxy, tlvReqB64, - &tz_err, &tlvRespB64, NULL, &gErr); - if (gErr != NULL) { - - _send_response(request, NULL, IOTCON_RESPONSE_ERROR); - _ERR("Failed returned from ASM"); - return -1; - } - - iotcon_representation_h resp_repr; - - resp_repr = _create_ra_representation(ra, tlvRespB64); - if (NULL == resp_repr) { - _send_response(request, NULL, IOTCON_RESPONSE_ERROR); - _ERR("RA representation create failed"); - return -1; - } - - ret = _send_response(request, resp_repr, IOTCON_RESPONSE_OK); - if (0 != ret) { - iotcon_representation_destroy(resp_repr); - return -1; - } - - iotcon_representation_destroy(resp_repr); - - return 0; -} - -//static bool -//_query_cb(const char *key, const char *value, void *user_data) -//{ -// return IOTCON_FUNC_CONTINUE; -//} - -static void -_request_handler(iotcon_resource_h resource, iotcon_request_h request, - void *user_data) -{ - _INFO("_request_handler start"); - - /*TODO: Only allow if request is not coming from the same device*/ - - ra_resource_s *ra; - iotcon_query_h query; - //int ret, observe_id; - iotcon_request_type_e type; - //iotcon_observe_type_e observe_type; - //char *host_address; - - if (request == NULL) - return; - - int ret = iotcon_request_get_query(request, &query); - if (IOTCON_ERROR_NONE != ret) { - _send_response(request, NULL, IOTCON_RESPONSE_ERROR); - return; - } -// if (query) -// iotcon_query_foreach(query, _query_cb, NULL); - - ret = iotcon_request_get_request_type(request, &type); - if (IOTCON_ERROR_NONE != ret) { - _send_response(request, NULL, IOTCON_RESPONSE_ERROR); - return; - } - - - ra = user_data; - - - if (IOTCON_REQUEST_PUT == type) { - ret = _request_handler_put(ra, request); - } - else { - _send_response(request, NULL, IOTCON_RESPONSE_ERROR); - } - -} - -static bool -__iotcon_handler_is_supported(void) -{ - bool raSupported = false; - system_info_get_platform_bool(IC_FEATURE_OIC, &raSupported); - if (raSupported == false) - system_info_get_platform_bool(IC_FEATURE_OCF, &raSupported); - - return raSupported; -} - -int -iotcon_handler_init(void) -{ - _INFO("iotcon_handler_init"); - if (__iotcon_handler_is_supported() == false) { - _ERR("RA not supported"); - return -1; - } - - int ret; - ra_resource_s ra = {0}; - - - /* initialize iotcon */ - ret = iotcon_initialize(RA_ACL_SERVER); - if (IOTCON_ERROR_NONE != ret) { - return -1; - } - - /* set local ra resource */ - ret = _set_ra_resource(&ra); - if (0 != ret) { - iotcon_deinitialize(); - return -1; - } - - /* add resource options */ - ret = iotcon_resource_interfaces_add(ra.ifaces, IOTCON_INTERFACE_BATCH); - if (IOTCON_ERROR_NONE != ret) { - _free_ra_resource(&ra); - iotcon_deinitialize(); - - return -1; - } - //ra.properties |= IOTCON_RESOURCE_OBSERVABLE; - - /* add presence */ - //g_timeout_add_seconds(10, _presence_timer, NULL); - //iotcon_start_presence(10); - - /* create new ra resource */ - ra.handle = _create_ra_resource(ra.uri_path, ra.type, ra.ifaces, - ra.properties, &ra); - if (NULL == ra.handle) { - - _free_ra_resource(&ra); - iotcon_deinitialize(); - return -1; - } - - //_check_ra_state(my_ra); - - - //iotcon_resource_destroy(ra.handle); - - //_free_ra_resource(&ra); - - /* deinitialize iotcon */ - //iotcon_deinitialize(); - - return 0; -} - - - diff --git a/roaming_agent/src/iotcon_handler.h b/roaming_agent/src/iotcon_handler.h deleted file mode 100644 index 6513123..0000000 --- a/roaming_agent/src/iotcon_handler.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * iotcon_handler.h - * - * Created on: May 16, 2016 - * Author: manasij.r - */ - -#ifndef IOTCON_HANDLER_H_ -#define IOTCON_HANDLER_H_ - - -int iotcon_handler_init(void); - - -#endif /* IOTCON_HANDLER_H_ */ diff --git a/roaming_agent/src/ragent_main.c b/roaming_agent/src/ragent_main.c deleted file mode 100644 index 512f4d9..0000000 --- a/roaming_agent/src/ragent_main.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2014 - 2015 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 -#include - -#include "iotcon_handler.h" -#include "AsmHelper.h" - -int -main(int argc, char *argv[]) -{ - _INFO("Starting Roaming Agent Service"); - - int ret = iotcon_handler_init(); - if (ret != 0) { - _ERR("iotcon init failed [%d]", ret); - - return 0; - } - - GMainLoop *mainloop = g_main_loop_new(NULL, FALSE); - - g_main_loop_run(mainloop); - - _INFO("Stopping Roaming Agent Service"); - - return 0; -} diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 3ad6f4a..b72b411 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -22,7 +22,6 @@ pkg_check_modules(SERVICE_PKGS REQUIRED openssl aul json-glib-1.0 - iotcon openssl capi-system-info capi-system-system-settings diff --git a/server/auth_discovery/inc/BleAdProvider.h b/server/auth_discovery/inc/BleAdProvider.h deleted file mode 100644 index c59a96b..0000000 --- a/server/auth_discovery/inc/BleAdProvider.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef _BLE_AD_PROVIDER_H -#define _BLE_AD_PROVIDER_H - -#include - -#include "IADProvider.h" -#include - -class BleAdProvider : public IADProvider { - friend class AuthManager; -public: - virtual int init(void); - virtual auth_type_e getType(void); - virtual std::vector *getAuthStubList(void); - virtual void setCache(std::map *stubCache); - virtual IAuthStub* getStubFromCache(int mappedIdx); - - virtual ~BleAdProvider(void); - -private: - BleAdProvider(void); - - static void onGattConchanged(int result, bool connected, - const char *remote_address, void *user_data); - static void onBtStateChanged(int result, bt_adapter_state_e adapter_state, - void *user_data); - static void onLEScanResult(int result, bt_adapter_le_device_scan_result_info_s *info, - void *user_data); - static void finishDiscovery(gpointer data); - static gboolean discoverTimeOutCb(gpointer user_data); - -private: - std::map *__stubCache; - - GMainLoop *__waitLoop; - bool __isValidInst; -}; - -#endif // _BLE_AD_PROVIDER_H diff --git a/server/auth_discovery/inc/BleCon.h b/server/auth_discovery/inc/BleCon.h deleted file mode 100644 index 221deb2..0000000 --- a/server/auth_discovery/inc/BleCon.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef _BLE_CON_H -#define _BLE_CON_H - -#include "IAuthConnection.h" -#include -#include - -class GattClient { -public: - GattClient(void) - { - __btClientInfo = NULL; - __btClient = NULL; - __btClientSvc = NULL; - __btClientChrReq = NULL; - __btClientChrResp = NULL; - } - -public: - /*bt_adapter_le_device_scan_result_info_s *__btClientInfo;*/ - char *__btClientInfo; - bt_gatt_client_h __btClient; - bt_gatt_h __btClientSvc; - bt_gatt_h __btClientChrReq; - bt_gatt_h __btClientChrResp; -}; - -class BleCon : public IAuthConnection { -public: - BleCon(void); - ~BleCon(void); - - virtual int init(void *handle); - virtual StringMap* sendReqSync(StringMap *reqData); - virtual int shutdown(void); - virtual char* getInfo(void); -private: - static void onGattServerResponse(bt_gatt_h characteristic, char *value, - int len, void *user_data); - static void onGattWriteComplete(int result, bt_gatt_h request_handle, - void *user_data); -private: - GattClient *__gClient; - GMainLoop *__waitLoop; - StringMap *__resp; -}; - -#endif // _BLE_CON_H diff --git a/server/auth_discovery/inc/BtAdProvider.h b/server/auth_discovery/inc/BtAdProvider.h index 6925333..bfce2d9 100644 --- a/server/auth_discovery/inc/BtAdProvider.h +++ b/server/auth_discovery/inc/BtAdProvider.h @@ -34,6 +34,7 @@ private: bool __isDiscovering; char *__sAddr; bool __isConCbSet; + int __btInitResult; }; #endif // BTADPROVIDER_H diff --git a/server/auth_discovery/inc/IoTCon.h b/server/auth_discovery/inc/IoTCon.h deleted file mode 100644 index f337023..0000000 --- a/server/auth_discovery/inc/IoTCon.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef IOTCON_H -#define IOTCON_H - -#include "IAuthConnection.h" -#include -#include - -class IoTCon : public IAuthConnection { -public: - - IoTCon(void); - ~IoTCon(void); - - virtual int init(void *handle); - virtual StringMap* sendReqSync(StringMap *reqData); - virtual int shutdown(void); - virtual char* getInfo(void); - -private: - static void onResponsePut(iotcon_remote_resource_h resource, iotcon_error_e err, - iotcon_request_type_e request_type, iotcon_response_h response, void *user_data); -private: - GMainLoop *__waitLoop; - iotcon_remote_resource_h __iotClient; - StringMap* __resp; -}; - -#endif // IOTCON_H diff --git a/server/auth_discovery/inc/IotADProvider.h b/server/auth_discovery/inc/IotADProvider.h deleted file mode 100644 index cc1dc28..0000000 --- a/server/auth_discovery/inc/IotADProvider.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2014 - 2015 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 _IOT_ADP_H_ -#define _IOT_ADP_H_ - -#include -#include -#include -#include - -#include "IADProvider.h" - -class IAuthStub; - -class IotADProvider : public IADProvider { - - friend class AuthManager; -public: - virtual int init(void); - virtual auth_type_e getType(void); - virtual std::vector *getAuthStubList(void); - virtual void setCache(std::map *stubCache); - virtual IAuthStub* getStubFromCache(int mappedIdx); - - virtual ~IotADProvider(void); - static void finishDiscovery(gpointer data); - static gboolean discoverTimeOutCb(gpointer user_data); - static bool resourceFoundCb(iotcon_remote_resource_h resource, iotcon_error_e result, - void *user_data); -private: - IotADProvider(void); - -private: - /*std::vector *__authList;*/ - std::map *__stubCache; - - GMainLoop *__waitLoop; - bool __isValidInst; - -}; - -#endif /* _IOT_ADP_H_ */ diff --git a/server/auth_discovery/inc/RoamingUtil.h b/server/auth_discovery/inc/RoamingUtil.h index a67e891..24e88aa 100644 --- a/server/auth_discovery/inc/RoamingUtil.h +++ b/server/auth_discovery/inc/RoamingUtil.h @@ -31,10 +31,6 @@ public: static bool isRASupported(void); - static std::string getBTMACAddr(void); - static std::string getDevName(void); - static std::string getP2PMACAddr(void); - static char *getServerId(void); private: RoamingUtil(void) {} diff --git a/server/auth_discovery/src/AuthManager.cpp b/server/auth_discovery/src/AuthManager.cpp index adfb8cb..65bc999 100644 --- a/server/auth_discovery/src/AuthManager.cpp +++ b/server/auth_discovery/src/AuthManager.cpp @@ -21,9 +21,7 @@ #include #include "BoundADProvider.h" -#include "IotADProvider.h" #include "RoamingUtil.h" -#include "BleAdProvider.h" #include "BtAdProvider.h" AuthManager* AuthManager::__this = NULL; @@ -37,29 +35,6 @@ AuthManager::initProviders(void) _INFO("Bound Provider=[%p]", badPro); __providerList.push_back(badPro); - -// if (RoamingUtil::isRASupported() == true) { -// IADProvider *radPro = new IotADProvider(); -// int retRa = radPro->init(); -// if (retRa == 0) { -// _INFO("Roaming Provider=[%p]", radPro); -// __providerList.push_back(radPro); -// } else { -// _INFO("RA not supported"); -// delete radPro; -// } -// } - -// IADProvider *blePro = new BleAdProvider(); -// int retBle = blePro->init(); -// if (retBle == 0) { -// _INFO("BLE Provider=[%p]", blePro); -// __providerList.push_back(blePro); -// } else { -// _INFO("BLE Provider not supported"); -// delete blePro; -// } - IADProvider *btPro = new BtAdProvider(); int retBt = btPro->init(); if (retBt == 0) { diff --git a/server/auth_discovery/src/BleAdProvider.cpp b/server/auth_discovery/src/BleAdProvider.cpp deleted file mode 100644 index 1f66ec7..0000000 --- a/server/auth_discovery/src/BleAdProvider.cpp +++ /dev/null @@ -1,415 +0,0 @@ - -#include "BleAdProvider.h" -#include "IAuthConnection.h" -#include "BleCon.h" -#include "RAuthStub.h" -#include "AsmHelper.h" -#include "BTRoamingKeys.h" - -/*BLE is not working on 3.0*/ -#define DISABLE_BLE - -void -BleAdProvider::onBtStateChanged(int result, bt_adapter_state_e adapter_state, - void *user_data) -{ - _INFO("bluetooth onBtStateChanged=[%d]", adapter_state); - BleAdProvider *btPro = (BleAdProvider*)user_data; - if (adapter_state == BT_ADAPTER_DISABLED) { - if (btPro->__stubCache != NULL) { - _INFO("bluetooth Deletting cache=[%p]", btPro->__stubCache); - delete btPro->__stubCache; - btPro->__stubCache = NULL; - } - } -} - -int -BleAdProvider::init(void) -{ -#ifdef DISABLE_BLE - _INFO("BLE is disabled by ASM"); - return -1; -#endif - - _INFO("bluetooth "); - __stubCache = NULL; - int ret = bt_initialize(); - if(ret != BT_ERROR_NONE && ret != BT_ERROR_ALREADY_DONE) { - _ERR("bluetooth rclient bluetooth service can not initialize=[%d]", ret); - return -1; - } - - bt_adapter_set_state_changed_cb(onBtStateChanged, this); - _INFO("bluetooth "); - return 0; -} - -auth_type_e -BleAdProvider::getType(void) -{ - return AUTH_TYPE_ROAMING; -} - -static bool -__bt_gatt_client_foreach_desc_cb(int total, int index, bt_gatt_h desc_handle, void *data) -{ - char *uuid = NULL; - - bt_gatt_get_uuid(desc_handle, &uuid); - - _INFO("bluetooth [%d / %d] uuid: (%s)", index, total, uuid); - - g_free(uuid); - - return true; -} - -static bool -__bt_gatt_client_foreach_chr_cb(int total, int index, bt_gatt_h chr_handle, void *data) -{ - int ret; - char *uuid = NULL; - - bt_gatt_get_uuid(chr_handle, &uuid); - - _INFO("bluetooth [%d / %d] uuid: (%s)", index, total, uuid); - - g_free(uuid); - - ret = bt_gatt_characteristic_foreach_descriptors(chr_handle, - __bt_gatt_client_foreach_desc_cb, NULL); - if (ret != BT_ERROR_NONE) - _INFO("bluetooth bt_gatt_characteristic_foreach_descriptors failed: %d", ret); - - return true; -} - -static bool -__svcCb(int total, int index, bt_gatt_h gatt_handle, - void *user_data) -{ - int ret; - char *uuid = NULL; - - bt_gatt_get_uuid(gatt_handle, &uuid); - _INFO("bluetooth [%d / %d] uuid: (%s)", index, total, uuid); - - g_free(uuid); - - ret = bt_gatt_service_foreach_characteristics(gatt_handle, - __bt_gatt_client_foreach_chr_cb, NULL); - if (ret != BT_ERROR_NONE) - _INFO("bluetooth bt_gatt_service_foreach_characteristics failed: %d", ret); - - return true; -} - -#define printIfAndRet(e1, e2, str) \ - if (e1 == e2) {\ - _INFO("bluetooth fido asm bt error=[%s]", str);\ - return; \ - }\ - -static void -printBTError(bt_error_e e) -{ - printIfAndRet(e, BT_ERROR_NONE, "BT_ERROR_NONE"); - printIfAndRet(e, BT_ERROR_CANCELLED, "BT_ERROR_CANCELLED"); - printIfAndRet(e, BT_ERROR_INVALID_PARAMETER, "BT_ERROR_INVALID_PARAMETER"); - printIfAndRet(e, BT_ERROR_OUT_OF_MEMORY, "BT_ERROR_OUT_OF_MEMORY"); - printIfAndRet(e, BT_ERROR_RESOURCE_BUSY, "BT_ERROR_RESOURCE_BUSY"); - printIfAndRet(e, BT_ERROR_TIMED_OUT, "BT_ERROR_TIMED_OUT"); - printIfAndRet(e, BT_ERROR_NOW_IN_PROGRESS, "BT_ERROR_NOW_IN_PROGRESS"); - printIfAndRet(e, BT_ERROR_NOT_SUPPORTED, "BT_ERROR_NOT_SUPPORTED"); - printIfAndRet(e, BT_ERROR_PERMISSION_DENIED, "BT_ERROR_PERMISSION_DENIED"); - printIfAndRet(e, BT_ERROR_QUOTA_EXCEEDED, "BT_ERROR_QUOTA_EXCEEDED"); - printIfAndRet(e, BT_ERROR_NO_DATA, "BT_ERROR_NO_DATA"); - printIfAndRet(e, BT_ERROR_DEVICE_POLICY_RESTRICTION, "BT_ERROR_DEVICE_POLICY_RESTRICTION"); - printIfAndRet(e, BT_ERROR_NOT_INITIALIZED, "BT_ERROR_NOT_INITIALIZED"); - printIfAndRet(e, BT_ERROR_NOT_ENABLED, "BT_ERROR_NOT_ENABLED"); - printIfAndRet(e, BT_ERROR_ALREADY_DONE, "BT_ERROR_ALREADY_DONE"); - printIfAndRet(e, BT_ERROR_ALREADY_DONE, "BT_ERROR_ALREADY_DONE"); - printIfAndRet(e, BT_ERROR_OPERATION_FAILED, "BT_ERROR_OPERATION_FAILED"); - printIfAndRet(e, BT_ERROR_NOT_IN_PROGRESS, "BT_ERROR_NOT_IN_PROGRESS"); - printIfAndRet(e, BT_ERROR_REMOTE_DEVICE_NOT_BONDED, "BT_ERROR_REMOTE_DEVICE_NOT_BONDED"); - printIfAndRet(e, BT_ERROR_AUTH_REJECTED, "BT_ERROR_AUTH_REJECTED"); - printIfAndRet(e, BT_ERROR_AUTH_FAILED, "BT_ERROR_AUTH_FAILED"); - printIfAndRet(e, BT_ERROR_REMOTE_DEVICE_NOT_FOUND, "BT_ERROR_REMOTE_DEVICE_NOT_FOUND"); - printIfAndRet(e, BT_ERROR_SERVICE_SEARCH_FAILED, "BT_ERROR_SERVICE_SEARCH_FAILED"); - printIfAndRet(e, BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED, "BT_ERROR_REMOTE_DEVICE_NOT_CONNECTED"); - printIfAndRet(e, BT_ERROR_AGAIN, "BT_ERROR_AGAIN"); - printIfAndRet(e, BT_ERROR_SERVICE_NOT_FOUND, "BT_ERROR_SERVICE_NOT_FOUND"); - printIfAndRet(e, e, "Unknown"); -} - -void -BleAdProvider::onGattConchanged(int result, bool connected, const char *remote_address, void *user_data) -{ - _INFO("bluetooth remote_address=[%s]", remote_address); - _INFO("bluetooth connected=[%d]", connected); - _INFO("bluetooth [%d]", result); - printBTError(static_cast(result)); - if (connected == false) { - _ERR("bluetooth GATT disconnected"); - return; - } - - bt_gatt_h svc = NULL; - bt_gatt_h chrReq = NULL; - bt_gatt_h chrResp = NULL; - bt_gatt_client_h client = NULL; - - _INFO("bluetooth "); - int ret = bt_gatt_client_create(remote_address, &client); - if (ret != BT_ERROR_NONE) { - _ERR("bluetooth rclient bt_gatt_client_create failed=[%d]", ret); - return; - } - - ret = bt_gatt_client_foreach_services(client, __svcCb, NULL); - printBTError(static_cast(ret)); - - char *cRAddr = NULL; - ret = bt_gatt_client_get_remote_address(client, &cRAddr); - printBTError(static_cast(ret)); - - _INFO("bluetooth bt_gatt_client_get_remote_address=[%s]", cRAddr); - ret = bt_gatt_client_get_service(client, RA_BLE_SERVICE_UUID, &svc); - if (ret != BT_ERROR_NONE) { - _ERR("bluetooth rclient bt_gatt_client_get_service failed=[%d]", ret); - printBTError(static_cast(ret)); - return; - } - - _INFO("bluetooth "); - ret = bt_gatt_service_get_characteristic(svc, RA_BLE_UUID_REQUEST, &chrReq); - if (ret != BT_ERROR_NONE) { - _ERR("bluetooth rclient bt_gatt_service_get_characteristic failed=[%d]", ret); - return; - } - - _INFO("bluetooth "); - ret = bt_gatt_service_get_characteristic(svc, RA_BLE_UUID_RESPONSE, &chrResp); - if (ret != BT_ERROR_NONE) { - _ERR("bluetooth rclient bt_gatt_service_get_characteristic failed=[%d]", ret); - return; - } - - _INFO("bluetooth "); - GattClient *gC = new GattClient(); - gC->__btClientInfo = _SAFE_DUP(remote_address); - gC->__btClient = client; - gC->__btClientSvc = svc; - gC->__btClientChrReq = chrReq; - gC->__btClientChrResp = chrResp; - - IAuthConnection *bleClient = new BleCon(); - bleClient->init(gC); - - IAuthStub *raStub = new RAuthStub(); - raStub->initRemote(bleClient); - - BleAdProvider *blePro = (BleAdProvider*)user_data; - if (blePro->__stubCache == NULL) { - blePro->__stubCache = new std::map(); - } - - /*Index auto incremented, set properly during setCache*/ - blePro->__stubCache->insert(std::make_pair(blePro->__stubCache->size(), raStub)); - - BleAdProvider::finishDiscovery(user_data); -} - -void -BleAdProvider::onLEScanResult(int result, bt_adapter_le_device_scan_result_info_s *info, - void *user_data) -{ - _INFO("bluetooth rclient __bt_adapter_le_scan_result_cb=[%d]", result); - _INFO("bluetooth remote_address=[%s]", info->remote_address); - _INFO("bluetooth address_type=[%d]", info->address_type); - /*_INFO("bluetooth adv_data=[%s]", info->adv_data); - _INFO("bluetooth scan_data=[%s]", info->scan_data);*/ - - if (info->adv_data_len > 31 || info->scan_data_len > 31) { - _INFO("bluetooth ###################"); - bt_adapter_le_stop_scan(); - _INFO("bluetooth ###################"); - return; - } - - bt_adapter_le_packet_type_e pkt_type = BT_ADAPTER_LE_PACKET_ADVERTISING; - int i = 0; - for (i = 0; i < 2; i++) { - char **uuids; - char *device_name; - int tx_power_level; - bt_adapter_le_service_data_s *data_list; - int appearance; - int manufacturer_id; - char *manufacturer_data; - int manufacturer_data_len; - int count; - - pkt_type = static_cast(static_cast(pkt_type) + i); - if (pkt_type == BT_ADAPTER_LE_PACKET_ADVERTISING && info->adv_data == NULL) - continue; - if (pkt_type == BT_ADAPTER_LE_PACKET_SCAN_RESPONSE && info->scan_data == NULL) - break; - - if (bt_adapter_le_get_scan_result_service_uuids(info, pkt_type, &uuids, &count) == BT_ERROR_NONE) { - int i; - for (i = 0; i < count; i++) { - _INFO("bluetooth UUID[%d] = %s", i + 1, uuids[i]); - g_free(uuids[i]); - } - g_free(uuids); - } - if (bt_adapter_le_get_scan_result_device_name(info, pkt_type, &device_name) == BT_ERROR_NONE) { - _INFO("bluetooth Device name = %s", device_name); - g_free(device_name); - } - if (bt_adapter_le_get_scan_result_tx_power_level(info, pkt_type, &tx_power_level) == BT_ERROR_NONE) - _INFO("bluetooth TX Power level = %d", tx_power_level); - if (bt_adapter_le_get_scan_result_service_solicitation_uuids(info, pkt_type, &uuids, &count) == BT_ERROR_NONE) { - int i; - for (i = 0; i < count; i++) { - _INFO("bluetooth Solicitation UUID[%d] = %s", i + 1, uuids[i]); - g_free(uuids[i]); - } - g_free(uuids); - } - if (bt_adapter_le_get_scan_result_service_data_list(info, pkt_type, &data_list, &count) == BT_ERROR_NONE) { - int i; - for (i = 0; i < count; i++) { - _INFO("bluetooth Service Data[%d] = [0x%2.2X%2.2X:0x%.2X...]", i + 1, - data_list[i].service_uuid[0], data_list[i].service_uuid[1], data_list[i].service_data[0]); - } - bt_adapter_le_free_service_data_list(data_list, count); - } - if (bt_adapter_le_get_scan_result_appearance(info, pkt_type, &appearance) == BT_ERROR_NONE) - _INFO("bluetooth Appearance = %d", appearance); - if (bt_adapter_le_get_scan_result_manufacturer_data(info, pkt_type, &manufacturer_id, - &manufacturer_data, &manufacturer_data_len) == BT_ERROR_NONE) { - _INFO("bluetooth Manufacturer data[ID:%.4X, 0x%.2X%.2X...(len:%d)]", - manufacturer_id, manufacturer_data[0], manufacturer_data[1], manufacturer_data_len); - g_free(manufacturer_data); - } - } - - /*RA_BLE_ADVERTISING_UUID*/ - - /*_INFO("bluetooth [%d] sec timeout starting", BT_DISC_TIMEOUT_SEC); - g_timeout_add_seconds_full(G_PRIORITY_DEFAULT, BT_DISC_TIMEOUT_SEC, discoverTimeOutCb, user_data, - finishDiscovery);*/ - - _INFO("bluetooth Before bt_gatt_connect"); - - int ret = bt_gatt_connect(info->remote_address, false); - if (ret != BT_ERROR_NONE) { - _ERR("bluetooth rclient bt_gatt_connect failed=[%d]", ret); - return; - } - - _INFO("bluetooth bt_gatt_connect=[%d]", ret); -} - -void -BleAdProvider::finishDiscovery(gpointer data) -{ - _INFO("bluetooth "); - bt_adapter_le_stop_scan(); - - BleAdProvider *btPro = (BleAdProvider*)(data); - g_main_loop_quit(btPro->__waitLoop); -} - -gboolean -BleAdProvider::discoverTimeOutCb(gpointer user_data) -{ - _INFO("bluetooth discoverTimeOutCb"); - - return G_SOURCE_REMOVE; -} - -std::vector * -BleAdProvider::getAuthStubList(void) -{ - _INFO("bluetooth getAuthStubList"); - delete __stubCache; - __stubCache = NULL; - - __waitLoop = g_main_loop_new(NULL, FALSE); - - bt_gatt_set_connection_state_changed_cb(onGattConchanged, this); - - _INFO("bluetooth starting LE scan"); - int ret = bt_adapter_le_start_scan(onLEScanResult, this); - if (ret != BT_ERROR_NONE) { - bt_gatt_unset_connection_state_changed_cb(); - _ERR("bluetooth rclient bt_adapter_le_start_scan failed."); - bt_adapter_le_stop_scan(); - - return NULL; - } - - _INFO("bluetooth starting wait loop"); - g_main_loop_run(__waitLoop); - - _INFO("bluetooth After waitloop"); - - g_main_loop_unref(__waitLoop); - __waitLoop = NULL; - - if (__stubCache != NULL) { - _INFO("bluetooth BT Roaming Auth Count=[%d]", __stubCache->size()); - } else { - _ERR("bluetooth BT Roaming Auth List is NULL"); - return NULL; - } - - std::vector *stubList = NULL; - - std::map::iterator it = __stubCache->begin(); - for (; it != __stubCache->end(); ++it) { - if (stubList == NULL) - stubList = new std::vector(); - - stubList->push_back(it->second); - } - _INFO("bluetooth "); - return stubList; -} - -void -BleAdProvider::setCache(std::map *stubCache) -{ - _INFO("bluetooth BleAdProvider::setCache"); - if (stubCache != NULL) - _INFO("bluetooth New cache set size =[%d]", stubCache->size()); - - __stubCache = stubCache; -} - -IAuthStub* -BleAdProvider::getStubFromCache(int mappedIdx) -{ - if (__stubCache == NULL) { - _ERR("bluetooth Stub cache NULL"); - return NULL; - } - - return __stubCache->find(mappedIdx)->second; -} - -BleAdProvider::~BleAdProvider(void) -{ - -} - -BleAdProvider::BleAdProvider(void) -{ - __stubCache = NULL; - __waitLoop = NULL; - __isValidInst = false; -} diff --git a/server/auth_discovery/src/BleCon.cpp b/server/auth_discovery/src/BleCon.cpp deleted file mode 100644 index 0636df2..0000000 --- a/server/auth_discovery/src/BleCon.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "BleCon.h" -#include "AsmHelper.h" -#include "BTRoamingKeys.h" -#include "RoamingKeys.h" - -BleCon::BleCon(void) -{ - __gClient = NULL; - __waitLoop = NULL; - __resp = NULL; -} - -BleCon::~BleCon(void) -{ - -} - -int -BleCon::init(void *handle) -{ - __gClient = (GattClient*)handle; - - return 0; -} - -void -BleCon::onGattServerResponse(bt_gatt_h characteristic, char *value, - int len, void *user_data) -{ - _INFO("Response length = [%d]", len); - - BleCon *btCon = (BleCon*)user_data; - btCon->__resp = new StringMap(); - - std::string k(RA_QUERY_KEY_RESPONSE); - std::string v(value); - btCon->__resp->insert(std::make_pair(k, v)); - - g_main_loop_quit(btCon->__waitLoop); -} - -void -BleCon::onGattWriteComplete(int result, bt_gatt_h request_handle, void *user_data) -{ - _INFO("[%d]", result); - BleCon *btCon = (BleCon*)user_data; - if (result != 0) { - g_main_loop_quit(btCon->__waitLoop); - } -} - -StringMap* -BleCon::sendReqSync(StringMap *reqData) -{ - _INFO("sendReqSync start"); - - RET_IF_FAIL(reqData != NULL, NULL); - RET_IF_FAIL(__gClient != NULL, NULL); - - __resp = NULL; - std::string reqTlvB64 = (reqData->find(RA_QUERY_KEY_REQUEST)->second); - char *reqTlvB64Copy = strdup(reqTlvB64.c_str()); - - __waitLoop = g_main_loop_new(NULL, FALSE); - - int ret = bt_gatt_client_set_characteristic_value_changed_cb(__gClient->__btClientChrResp, - onGattServerResponse, this); - _ERR("rclient bt_gatt_client_set_characteristic_value_changed_cb failed=[%d]", ret); - - - ret = bt_gatt_set_value(__gClient->__btClientChrReq, reqTlvB64Copy, strlen(reqTlvB64Copy)); - if (ret != BT_ERROR_NONE) { - _ERR("rclient bt_gatt_set_value failed=[%d]", ret); - goto CATCH; - } - - ret = bt_gatt_client_write_value(__gClient->__btClientChrReq, onGattWriteComplete, this); - if (ret != BT_ERROR_NONE) { - _ERR("rclient bt_gatt_client_write_value failed=[%d]", ret); - goto CATCH; - } - - _INFO("bt_gatt_client_write_value=[%d]", ret); - g_main_loop_run(__waitLoop); - -CATCH: - SAFE_DELETE(reqTlvB64Copy); - g_main_loop_unref(__waitLoop); - bt_gatt_client_unset_characteristic_value_changed_cb(__gClient->__btClientChrResp); - _INFO("sendReqSync=%s", __resp); - return __resp; -} - -int -BleCon::shutdown(void) -{ - return -1; -} - -char* -BleCon::getInfo(void) -{ - RET_IF_FAIL(__gClient != NULL, NULL); - - return __gClient->__btClientInfo; -} diff --git a/server/auth_discovery/src/BtADProvider.cpp b/server/auth_discovery/src/BtADProvider.cpp index c9d370b..ed14653 100644 --- a/server/auth_discovery/src/BtADProvider.cpp +++ b/server/auth_discovery/src/BtADProvider.cpp @@ -5,7 +5,6 @@ #include "RAuthStub.h" #include "AsmHelper.h" #include "BTRoamingKeys.h" -//#include #include #define RA_BT_SERVICE_UUID "00001101-0000-1000-8000-00805F9B34FB" @@ -16,9 +15,9 @@ BtAdProvider::init(void) __isDiscovering = false; __sAddr = NULL; - int ret = bt_initialize(); - _INFO("bt_initialize=[%d]", ret); - if (ret != BT_ERROR_NONE) + __btInitResult = bt_initialize(); + _INFO("bt_initialize=[%d]", __btInitResult); + if (__btInitResult != BT_ERROR_NONE) return -1; __stubCache = NULL; @@ -222,7 +221,10 @@ BtAdProvider::getStubFromCache(int mappedIdx) BtAdProvider::~BtAdProvider(void) { - + if (__btInitResult == BT_ERROR_NONE) { + int ret = bt_deinitialize(); + _INFO("bt_deinitialize=[%d]", ret); + } } BtAdProvider::BtAdProvider(void) diff --git a/server/auth_discovery/src/BtCon.cpp b/server/auth_discovery/src/BtCon.cpp index 01ac26b..3987316 100644 --- a/server/auth_discovery/src/BtCon.cpp +++ b/server/auth_discovery/src/BtCon.cpp @@ -1,7 +1,6 @@ #include "BtCon.h" #include "BTRoamingKeys.h" -#include "RoamingKeys.h" #include "AsmHelper.h" #include #include diff --git a/server/auth_discovery/src/IoTCon.cpp b/server/auth_discovery/src/IoTCon.cpp deleted file mode 100644 index 38bf0f2..0000000 --- a/server/auth_discovery/src/IoTCon.cpp +++ /dev/null @@ -1,121 +0,0 @@ - -#include "IoTCon.h" -#include "AuthnrTypes.h" -#include "AsmHelper.h" -#include "RoamingKeys.h" - -IoTCon::IoTCon(void) -{ - __waitLoop = NULL; - __iotClient = NULL; - __resp = NULL; -} - -IoTCon::~IoTCon(void) -{ - -} - -int -IoTCon::init(void *handle) -{ - __iotClient = (iotcon_remote_resource_h)handle; - - return 0; -} - -void -IoTCon::onResponsePut(iotcon_remote_resource_h resource, iotcon_error_e err, - iotcon_request_type_e request_type, iotcon_response_h response, void *user_data) -{ - _INFO(""); - - IoTCon *conn = (IoTCon*)user_data; - _INFO("onResponsePut [%p]", conn); - - iotcon_representation_h repr = NULL; - iotcon_attributes_h state = NULL; - - iotcon_response_get_representation(response, &repr); - - iotcon_representation_get_attributes(repr, &state); - - char *asm_resp = NULL; - iotcon_attributes_get_str(state, RA_QUERY_KEY_RESPONSE, &asm_resp); - if (asm_resp != NULL) { - _INFO("%s=%s", RA_QUERY_KEY_RESPONSE, asm_resp); - - conn->__resp = new StringMap(); - std::string k(RA_QUERY_KEY_RESPONSE); - std::string v(asm_resp); - conn->__resp->insert(std::make_pair(k, v)); - } else { - _ERR("Failed to get %s", RA_QUERY_KEY_RESPONSE); - conn->__resp = NULL; - } - - _INFO("Before g_main_loop_quit"); - g_main_loop_quit(conn->__waitLoop); -} - -StringMap * -IoTCon::sendReqSync(StringMap *reqData) -{ - RET_IF_FAIL(reqData != NULL, NULL); - - std::string reqTlvB64 = (reqData->find(RA_QUERY_KEY_REQUEST)->second); - std::string svrId = (reqData->find(RA_QUERY_KEY_SERVER_ID)->second); - - iotcon_attributes_h attr = NULL; - iotcon_attributes_create(&attr); - - char *reqTlvB64Copy = strdup(reqTlvB64.c_str()); - char *svrIdCopy = strdup(svrId.c_str()); - iotcon_attributes_add_str(attr, RA_QUERY_KEY_REQUEST, reqTlvB64Copy); - iotcon_attributes_add_str(attr, RA_QUERY_KEY_SERVER_ID, svrIdCopy); - - iotcon_representation_h repr = NULL; - iotcon_representation_create(&repr); - - iotcon_representation_set_attributes(repr, attr); - - - __waitLoop = g_main_loop_new(NULL, FALSE); - int ret = iotcon_remote_resource_put(__iotClient, repr, NULL, onResponsePut, this); - if (ret != IOTCON_ERROR_NONE) { - _ERR("iotcon_remote_resource_get failed"); - iotcon_representation_destroy(repr); - SAFE_DELETE(reqTlvB64Copy); - SAFE_DELETE(svrIdCopy); - return NULL; - } - - iotcon_representation_destroy(repr); - SAFE_DELETE(reqTlvB64Copy); - SAFE_DELETE(svrIdCopy); - _INFO("iotcon_remote_resource_get=[%d]", ret); - g_main_loop_run(__waitLoop); - - _INFO("sendReqSync end"); - - return __resp; -} - -char* -IoTCon::getInfo(void) -{ - char *devId = NULL; - int ret = iotcon_remote_resource_get_device_id(__iotClient, &devId); - if (ret == IOTCON_ERROR_NONE && devId != NULL) { - _INFO("Device Id = [%s]", devId); - return devId; - } - - return NULL; -} - -int -IoTCon::shutdown(void) -{ - return 0; -} diff --git a/server/auth_discovery/src/IotADProvider.cpp b/server/auth_discovery/src/IotADProvider.cpp deleted file mode 100644 index 570a6fe..0000000 --- a/server/auth_discovery/src/IotADProvider.cpp +++ /dev/null @@ -1,217 +0,0 @@ - -#include "IotADProvider.h" - -#include -#include "IoTCon.h" -#include "AsmHelper.h" -#include "RAuthStub.h" -#include "RoamingKeys.h" -#include "AuthIndexHanlder.h" -#include "RoamingUtil.h" - -#define EMPTY_STUB_LIST std::vector() - -#define AUTH_INDEX_START 5 - -void -IotADProvider::finishDiscovery(gpointer data) -{ - _INFO(""); - IotADProvider *rAuthManager = (IotADProvider*)(data); - g_main_loop_quit(rAuthManager->__waitLoop); -} - -gboolean -IotADProvider::discoverTimeOutCb(gpointer user_data) -{ - _INFO("discoverTimeOutCb"); - - return G_SOURCE_REMOVE; -} - -bool -IotADProvider::resourceFoundCb(iotcon_remote_resource_h resource, iotcon_error_e result, - void *user_data) -{ - _INFO(""); - - if (result != IOTCON_ERROR_NONE) { - _ERR("No remote resource found"); - return false; - //return; - } - - char *rDevId = NULL; - iotcon_remote_resource_get_device_id(resource, &rDevId); - if (rDevId == NULL) { - _ERR("iotcon_remote_resource_get_device_id failed"); - return false; - //return; - } - - char *rHostAddr = NULL; - iotcon_remote_resource_get_host_address(resource, &rHostAddr); - if (rHostAddr == NULL) { - _ERR("iotcon_remote_resource_get_host_address failed"); - return false; - //return; - } - - std::string p2pMacAddr = RoamingUtil::getP2PMACAddr(); - std::string btMacAddr = RoamingUtil::getBTMACAddr(); - - _INFO("[%s][%s]", p2pMacAddr.c_str(), btMacAddr.c_str()); - _INFO("[%s]", rDevId); - _INFO("[%s]", rHostAddr); - - if (p2pMacAddr.empty() == false) { - - if (strcmp(rDevId, p2pMacAddr.c_str()) == 0) { - _INFO("Ignoring request from same device"); - return false; - //return; - } - - } else if (btMacAddr.empty() == false) { - if (strcmp(rDevId, btMacAddr.c_str()) == 0) { - _INFO("Ignoring request from same device"); - return false; - //return; - } - } - - IotADProvider *radPro = (IotADProvider*)user_data; - _INFO("this=[%p]", radPro); - - iotcon_remote_resource_h resourceClone = NULL; - - _INFO("Before iotcon_remote_resource_clone"); - int ret = iotcon_remote_resource_clone(resource, &resourceClone); - _INFO("After iotcon_remote_resource_clone"); - if (ret != IOTCON_ERROR_NONE) { - _ERR("Failed to clone remote resource"); - return false; - //return; - } - - IAuthStub *stub = new RAuthStub(); - IAuthConnection *conH = new IoTCon(); - conH->init(resourceClone); - stub->initRemote(conH); - - if (radPro->__stubCache == NULL) { - radPro->__stubCache = new std::map(); - } - - /*Index auto incremented, set properly during setCache*/ - radPro->__stubCache->insert(std::make_pair(radPro->__stubCache->size(), stub)); - - return true; -} - -std::vector* -IotADProvider::getAuthStubList(void) -{ - delete __stubCache; - __stubCache = NULL; - - __waitLoop = g_main_loop_new(NULL, FALSE); - - g_timeout_add_seconds_full(G_PRIORITY_DEFAULT, 1, discoverTimeOutCb, this, - finishDiscovery); - - - iotcon_query_h iotQ = NULL; - iotcon_query_create(&iotQ); - - int ret = iotcon_query_set_resource_type(iotQ, RA_RESOURCE_TYPE); - - ret = iotcon_find_resource(IOTCON_MULTICAST_ADDRESS, IOTCON_CONNECTIVITY_ALL, - iotQ, resourceFoundCb, this); - if (IOTCON_ERROR_NONE != ret) { - _ERR("iotcon_find_resource failed"); - iotcon_query_destroy(iotQ); - return NULL; - } - - iotcon_query_destroy(iotQ); - g_main_loop_run(__waitLoop); - - _INFO("After g_main_loop_run"); - - g_main_loop_unref(__waitLoop); - __waitLoop = NULL; - - if (__stubCache != NULL) { - _INFO("Roaming Auth Count=[%d]", __stubCache->size()); - } else { - _ERR("Roaming Auth List is NULL"); - return NULL; - } - - std::vector *stubList = NULL; - - std::map::iterator it = __stubCache->begin(); - for (; it != __stubCache->end(); ++it) { - if (stubList == NULL) - stubList = new std::vector(); - - stubList->push_back(it->second); - } - _INFO(""); - return stubList; -} - -void -IotADProvider::setCache(std::map *stubCache) -{ - _INFO("IotADProvider::setCache"); - if (stubCache != NULL) - _INFO("New cache set size =[%d]", stubCache->size()); - - __stubCache = stubCache; -} - -IAuthStub* -IotADProvider::getStubFromCache(int mappedIdx) -{ - if (__stubCache == NULL) { - _ERR("Stub cache NULL"); - return NULL; - } - - return __stubCache->find(mappedIdx)->second; -} - -IotADProvider::~IotADProvider(void) -{ - if (__isValidInst == true) - iotcon_deinitialize(); -} - -int -IotADProvider::init(void) -{ - int ret = iotcon_initialize(RA_ACL_CLIENT); - if (IOTCON_ERROR_NONE != ret) { - __isValidInst = false; - return -1; - } - - __isValidInst = true; - return 0; -} - -auth_type_e -IotADProvider::getType(void) -{ - return AUTH_TYPE_ROAMING; -} - -IotADProvider::IotADProvider(void) - : __isValidInst(false) -{ - __stubCache = NULL; - __waitLoop = NULL; - __isValidInst = false; -} diff --git a/server/auth_discovery/src/RAuthStub.cpp b/server/auth_discovery/src/RAuthStub.cpp index 922815f..a2319b4 100644 --- a/server/auth_discovery/src/RAuthStub.cpp +++ b/server/auth_discovery/src/RAuthStub.cpp @@ -1,7 +1,6 @@ #include "RAuthStub.h" #include "AsmHelper.h" -#include "RoamingKeys.h" #include "RoamingUtil.h" #include "TlvData.h" #include "AuthIndexHanlder.h" diff --git a/server/auth_discovery/src/RoamingUtil.cpp b/server/auth_discovery/src/RoamingUtil.cpp index cbb3193..9fd6b76 100644 --- a/server/auth_discovery/src/RoamingUtil.cpp +++ b/server/auth_discovery/src/RoamingUtil.cpp @@ -340,48 +340,6 @@ RoamingUtil::isRASupported(void) return raSupported;*/ } -std::string -RoamingUtil::getBTMACAddr(void) -{ - static std::string g_mac_address; - if(g_mac_address.empty() == true) { - bt_initialize(); - char* mac_address = NULL; - bt_adapter_enable(); - int ret = bt_adapter_get_address(&mac_address); - if (ret != 0) { - _ERR("bt_adapter_get_address failed"); - return g_mac_address; - } - - _INFO("bluetooth get mac address : %s", mac_address); - g_mac_address = mac_address; - free(mac_address); - bt_deinitialize(); - } - _INFO("mac address:%s", g_mac_address.c_str()); - - return g_mac_address; -} - - -std::string -RoamingUtil::getDevName(void) -{ - static std::string g_device_name; - if(g_device_name.empty()) { - char* device_name = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR); - if (device_name == NULL) { - g_device_name = "Tizen"; - } else { - g_device_name = device_name; - } - _INFO("device_name: %s", g_device_name.c_str()); - } - - return g_device_name; -} - char RoamingUtil::makeP2PMAC(char c) { @@ -400,30 +358,6 @@ RoamingUtil::makeP2PMAC(char c) return convert_c; } -std::string -RoamingUtil::getP2PMACAddr(void) -{ - static std::string g_p2p_mac_address; - if(g_p2p_mac_address.empty()) { - char p2p_mac[MAC_ADDR_STR_LEN]; - memset(p2p_mac, 0x0, MAC_ADDR_STR_LEN); - - char* temp_addr = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS); - if (temp_addr == NULL) { - _ERR("vconf_get_str Failed for %s", VCONFKEY_WIFI_BSSID_ADDRESS); - } else { - memcpy(p2p_mac, temp_addr, MAC_ADDR_STR_LEN-1); - p2p_mac[1] = makeP2PMAC(p2p_mac[1]); - _INFO("P2P mac is %s", p2p_mac); - free(temp_addr); - - g_p2p_mac_address = p2p_mac; - } - } - _INFO("p2p mac address:%s", g_p2p_mac_address.c_str()); - return g_p2p_mac_address; -} - char* RoamingUtil::getServerId(void) { -- 2.7.4 From 67d580dfe4c3bfa74ca80a92e153c5bc971035f2 Mon Sep 17 00:00:00 2001 From: INSUN PYO Date: Fri, 23 Jun 2017 14:18:34 +0900 Subject: [PATCH 07/16] Fix fido-asm.service : User & Group is in wrong session. Signed-off-by: INSUN PYO Change-Id: I7aa42f521dbbcc356561f88c53a470f42422500b --- packaging/fido-asm.service | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packaging/fido-asm.service b/packaging/fido-asm.service index 4e34663..9cfc861 100644 --- a/packaging/fido-asm.service +++ b/packaging/fido-asm.service @@ -5,9 +5,8 @@ Requires=tizen-runtime.target [Service] ExecStart=/usr/bin/fido-asm - -[Install] -WantedBy=multi-user.target - User=service_fw Group=service_fw + +[Install] +WantedBy=multi-user.target \ No newline at end of file -- 2.7.4 From 6b450d4f323367db34cf692648cf81afd470f59c Mon Sep 17 00:00:00 2001 From: jkjo92 Date: Fri, 23 Jun 2017 19:16:44 +0900 Subject: [PATCH 08/16] [Kona Issue] Disable temporary UUID Change-Id: I3ee84889bef504981a0f5b4bc8b6fab9996bcf94 Signed-off-by: jkjo92 --- server/auth_discovery/src/BtADProvider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 server/auth_discovery/src/BtADProvider.cpp diff --git a/server/auth_discovery/src/BtADProvider.cpp b/server/auth_discovery/src/BtADProvider.cpp old mode 100644 new mode 100755 index ed14653..9d096ac --- a/server/auth_discovery/src/BtADProvider.cpp +++ b/server/auth_discovery/src/BtADProvider.cpp @@ -7,7 +7,7 @@ #include "BTRoamingKeys.h" #include -#define RA_BT_SERVICE_UUID "00001101-0000-1000-8000-00805F9B34FB" +#define RA_BT_SERVICE_UUID "8F5E6268-CFCD-4474-AFA2-0FEBFED72D73" int BtAdProvider::init(void) -- 2.7.4 From 7caa832110640db90719707e595dab3aef07266c Mon Sep 17 00:00:00 2001 From: jkjo92 Date: Fri, 23 Jun 2017 19:16:44 +0900 Subject: [PATCH 09/16] [Kona Issue] Change to Random generated UUID Change-Id: I3ee84889bef504981a0f5b4bc8b6fab9996bcf94 Signed-off-by: jkjo92 --- server/auth_discovery/src/BtADProvider.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 server/auth_discovery/src/BtADProvider.cpp diff --git a/server/auth_discovery/src/BtADProvider.cpp b/server/auth_discovery/src/BtADProvider.cpp old mode 100644 new mode 100755 index ed14653..9d096ac --- a/server/auth_discovery/src/BtADProvider.cpp +++ b/server/auth_discovery/src/BtADProvider.cpp @@ -7,7 +7,7 @@ #include "BTRoamingKeys.h" #include -#define RA_BT_SERVICE_UUID "00001101-0000-1000-8000-00805F9B34FB" +#define RA_BT_SERVICE_UUID "8F5E6268-CFCD-4474-AFA2-0FEBFED72D73" int BtAdProvider::init(void) -- 2.7.4 From a354df0b8d9c867dcd0f7013b08d6874bbc355e0 Mon Sep 17 00:00:00 2001 From: jkjo92 Date: Mon, 3 Jul 2017 19:39:46 +0900 Subject: [PATCH 10/16] Use random generated BT UUID for Roaming Authentictor Change-Id: Ibe1931fee8709ad878ec46423a1969a04ba62b93 Signed-off-by: jkjo92 --- bt_roaming_agent/src/bt_server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 bt_roaming_agent/src/bt_server.c diff --git a/bt_roaming_agent/src/bt_server.c b/bt_roaming_agent/src/bt_server.c old mode 100644 new mode 100755 index 0154dd6..d94e877 --- a/bt_roaming_agent/src/bt_server.c +++ b/bt_roaming_agent/src/bt_server.c @@ -13,7 +13,7 @@ #include #include -#define RA_BT_SERVICE_UUID "00001101-0000-1000-8000-00805F9B34FB" +#define RA_BT_SERVICE_UUID "8F5E6268-CFCD-4474-AFA2-0FEBFED72D73" #define RA_LEN_DELIM ':' #define RA_LEN_DELIM_STR ":" #define DELIM_LEN 2 -- 2.7.4 From d2d972c1932bd4e1b5cbc4b2ba03d7eddea06cd7 Mon Sep 17 00:00:00 2001 From: jkjo92 Date: Tue, 4 Jul 2017 19:53:35 +0900 Subject: [PATCH 11/16] fix memory leak Change-Id: I6d9772ee2a55911623b2f034ae9be028f60bb410 Signed-off-by: jkjo92 --- ui/src/asm_ui.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) mode change 100644 => 100755 ui/src/asm_ui.c diff --git a/ui/src/asm_ui.c b/ui/src/asm_ui.c old mode 100644 new mode 100755 index 77eebd3..7a84fa4 --- a/ui/src/asm_ui.c +++ b/ui/src/asm_ui.c @@ -627,43 +627,43 @@ app_control(app_control_h app_control, void *data) { dlog_print(DLOG_INFO, "org.tizen.asmui", "fido asm ui app_control"); - __ad->mode = NULL; + SAFE_DELETE(__ad->mode); app_control_get_extra_data(app_control, TC_UI_KEY_MODE, &(__ad->mode)); - __ad->nonce = NULL; + SAFE_DELETE(__ad->nonce); app_control_get_extra_data(app_control, TC_UI_KEY_NONCE, &(__ad->nonce)); if (strcmp(__ad->mode, TC_UI_VAL_MODE_TC) == 0) { - __ad->app_id_in = NULL; + SAFE_DELETE(__ad->app_id_in); app_control_get_extra_data(app_control, TC_UI_KEY_APP, &(__ad->app_id_in)); - __ad->text_in = NULL; + SAFE_DELETE(__ad->text_in); app_control_get_extra_data(app_control, TC_UI_KEY_TEXT, &(__ad->text_in)); show_tc_ui(); } else if (strcmp(__ad->mode, TC_UI_VAL_MODE_ACCOUNT) == 0) { - __ad->app_id_in = NULL; + SAFE_DELETE(__ad->app_id_in); app_control_get_extra_data(app_control, TC_UI_KEY_APP, &(__ad->app_id_in)); - __ad->text_list_in = NULL; + SAFE_DELETE(__ad->text_list_in); __ad->text_list_in_len = 0; app_control_get_extra_data_array(app_control, TC_UI_KEY_ACC_LIST, &(__ad->text_list_in), &(__ad->text_list_in_len)); show_account_ui(); - } else if (strcmp(__ad->mode, TC_UI_VAL_MODE_PIN_ENROLL) == 0) { - __ad->app_id_in = NULL; + } else if (strcmp(__ad->mode, TC_UI_VAL_MODE_PIN_ENROLL) == 0) { + SAFE_DELETE(__ad->app_id_in); app_control_get_extra_data(app_control, TC_UI_KEY_APP, &(__ad->app_id_in)); show_pin_ui_enroll(); } else if (strcmp(__ad->mode, TC_UI_VAL_MODE_PIN_VERIFY) == 0) { - __ad->app_id_in = NULL; + SAFE_DELETE(__ad->app_id_in); app_control_get_extra_data(app_control, TC_UI_KEY_APP, &(__ad->app_id_in)); - __ad->token_in = NULL; + SAFE_DELETE(__ad->token_in); app_control_get_extra_data(app_control, TC_UI_KEY_TOK, &(__ad->token_in)); show_pin_ui_verify(); @@ -686,6 +686,12 @@ static void app_terminate(void *data) { dlog_print(DLOG_INFO, "org.tizen.asmui", "fido asm ui app_terminate"); + SAFE_DELETE(__ad->mode); + SAFE_DELETE(__ad->nonce); + SAFE_DELETE(__ad->app_id_in); + SAFE_DELETE(__ad->text_in); + SAFE_DELETE(__ad->text_list_in); + SAFE_DELETE(__ad->token_in); } static void -- 2.7.4 From ebdef115122447652a8b6583c90565ed876da846 Mon Sep 17 00:00:00 2001 From: jkjo92 Date: Fri, 14 Jul 2017 16:26:49 +0900 Subject: [PATCH 12/16] change uid/gid to service_fw Change-Id: Ia2cd51ba3b603052c5e1f04a7415edaef898a134 Signed-off-by: jkjo92 --- packaging/fido-bt-roaming-agent.service | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/fido-bt-roaming-agent.service b/packaging/fido-bt-roaming-agent.service index da82014..054fcb0 100644 --- a/packaging/fido-bt-roaming-agent.service +++ b/packaging/fido-bt-roaming-agent.service @@ -3,8 +3,8 @@ Description=FIDO BT Agent Service for Roaming Authenticator [Service] ExecStart=/usr/bin/fido-bt-ragent-service -User=system -Group=system +User=service_fw +Group=service_fw [Install] WantedBy=multi-user.target -- 2.7.4 From 7f2119e3814d7f37fb4ae971dcbec1afaf5daff5 Mon Sep 17 00:00:00 2001 From: jkjo92 Date: Fri, 21 Jul 2017 12:23:40 +0900 Subject: [PATCH 13/16] fix security defect Change-Id: Ia79761f53cacaba88f415cff1b53380b34e092dc Signed-off-by: jkjo92 --- common/cryptoutil/inc/asmcrypto.h | 0 common/cryptoutil/src/AsmCrypto.cpp | 18 ++++++++++++++++++ server/auth_discovery/src/RoamingUtil.cpp | 2 ++ test/shell_tc/fido_asm_shell_tc.cpp | 0 4 files changed, 20 insertions(+) mode change 100644 => 100755 common/cryptoutil/inc/asmcrypto.h mode change 100644 => 100755 common/cryptoutil/src/AsmCrypto.cpp mode change 100644 => 100755 server/auth_discovery/src/RoamingUtil.cpp mode change 100644 => 100755 test/shell_tc/fido_asm_shell_tc.cpp diff --git a/common/cryptoutil/inc/asmcrypto.h b/common/cryptoutil/inc/asmcrypto.h old mode 100644 new mode 100755 diff --git a/common/cryptoutil/src/AsmCrypto.cpp b/common/cryptoutil/src/AsmCrypto.cpp old mode 100644 new mode 100755 index 24eb33d..8abdfe5 --- a/common/cryptoutil/src/AsmCrypto.cpp +++ b/common/cryptoutil/src/AsmCrypto.cpp @@ -40,8 +40,13 @@ void AsmCrypto::logDataToFile(const char *file_name_prefix, const char *data, int data_len) { char fn[128] = {0, }; + char resolved_path[128]; snprintf(fn, 127, "%s%s", LOG_FILE_PATH, file_name_prefix); + if(realpath(fn, resolved_path) == NULL) { + _ERR("realpath error"); + return; + } FILE *fp = fopen(fn, "w+"); if (fp == NULL) return; @@ -57,8 +62,14 @@ void AsmCrypto::logRawDataToFile(const char *file_name_prefix, const unsigned char *data, int data_len) { char fn[128] = {0, }; + char resolved_path[128]; snprintf(fn, 127, "%s%s", LOG_FILE_PATH, file_name_prefix); + if(realpath(fn, resolved_path) == NULL) { + _ERR("realpath error"); + return; + } + FILE *fp = fopen(fn, "w+"); if (fp == NULL) return; @@ -179,6 +190,13 @@ AsmCrypto::getAsmToken(void) return macStr; } + char resolved_path[128]; + + if(realpath(ASM_CONFIG_FILE, resolved_path) == NULL) { + _ERR("realpath error"); + return std::string(); + } + FILE *file = fopen(ASM_CONFIG_FILE, "r"); if (file == NULL) { diff --git a/server/auth_discovery/src/RoamingUtil.cpp b/server/auth_discovery/src/RoamingUtil.cpp old mode 100644 new mode 100755 index 9fd6b76..dd48827 --- a/server/auth_discovery/src/RoamingUtil.cpp +++ b/server/auth_discovery/src/RoamingUtil.cpp @@ -279,6 +279,8 @@ RoamingUtil::composeAuthGetInfoResponce(std::vector *infoList) Buffer *getinfoRespBuff = encoderResp.encode(); _INFO("RoamingUtil after TLV encode"); + SAFE_DELETE(infoList); + /*B64 encode*/ return b64Encode(getinfoRespBuff->data, getinfoRespBuff->len); diff --git a/test/shell_tc/fido_asm_shell_tc.cpp b/test/shell_tc/fido_asm_shell_tc.cpp old mode 100644 new mode 100755 -- 2.7.4 From 9ddbe84a1def2bbaadf189ffb94d893a1a773319 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 26 Jul 2017 14:05:55 +0900 Subject: [PATCH 14/16] Add explicit dependency Requires: - aul Change-Id: Ief03a83655b3c73cdf635eaa4816551ba0693b8f Signed-off-by: Hwankyu Jhun --- packaging/fido-asm.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/fido-asm.spec b/packaging/fido-asm.spec index d327014..8991840 100644 --- a/packaging/fido-asm.spec +++ b/packaging/fido-asm.spec @@ -36,6 +36,7 @@ BuildRequires: pkgconfig(capi-network-bluetooth) BuildRequires: pkgconfig(capi-network-wifi-direct) BuildRequires: pkgconfig(capi-network-connection) BuildRequires: pkgconfig(db-util) +BuildRequires: pkgconfig(aul) Requires(post): /sbin/ldconfig Requires(post): /usr/bin/sqlite3 -- 2.7.4 From 3843896488b0b895cff033456630954108d7a1d3 Mon Sep 17 00:00:00 2001 From: jkjo92 Date: Thu, 27 Jul 2017 11:37:51 +0900 Subject: [PATCH 15/16] fix security svace issue Change-Id: Ic3f37794e46d4db03f57973257bacfe3d75c18d9 Signed-off-by: jkjo92 --- server/auth_discovery/src/BoundADProvider.cpp | 1 + server/src/AsmStorage.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) mode change 100644 => 100755 server/auth_discovery/src/BoundADProvider.cpp mode change 100644 => 100755 server/src/AsmStorage.cpp diff --git a/server/auth_discovery/src/BoundADProvider.cpp b/server/auth_discovery/src/BoundADProvider.cpp old mode 100644 new mode 100755 index 0a2bd7b..f2a26b8 --- a/server/auth_discovery/src/BoundADProvider.cpp +++ b/server/auth_discovery/src/BoundADProvider.cpp @@ -54,6 +54,7 @@ BoundADProvider::getAuthStubList(void) stubList->push_back(it->second); _INFO(""); } + delete __stubCache; _INFO(""); return stubList; } diff --git a/server/src/AsmStorage.cpp b/server/src/AsmStorage.cpp old mode 100644 new mode 100755 index add6a9f..604402d --- a/server/src/AsmStorage.cpp +++ b/server/src/AsmStorage.cpp @@ -799,6 +799,7 @@ AsmStorage::searchData(IStorageParcel *parcel) char q[BUFFLEN] = {0}; char *value = NULL; char query[BUFFLEN] = {0}; + char execquery[BUFFLEN] = {0}; SearchCbData cbData; @@ -1029,7 +1030,8 @@ AsmStorage::searchData(IStorageParcel *parcel) cbData.resList = resultList; _INFO("AsmStorage::searchData:: query = [%s]", query); - int ret = sqlite3_exec(dbHandle, query, searchItemCb, &cbData, &errMsg); + sqlite3_mprintf(execquery, query); + int ret = sqlite3_exec(dbHandle, execquery, searchItemCb, &cbData, &errMsg); _INFO("AsmStorage::searchData:: ERROR MSG : [%s]", errMsg); CATCH_IF_FAIL(ret == SQLITE_OK); @@ -1057,6 +1059,7 @@ AsmStorage::deleteData(IStorageParcel *parcel) char *errMsg = NULL; char q[BUFFLEN] = {0}; char *value = NULL; + char execquery[BUFFLEN] = {0}; char query[BUFFLEN] = {0}; RET_IF_FAIL(parcel != NULL, SQLITE_ERROR); int ret = 0; @@ -1154,8 +1157,8 @@ AsmStorage::deleteData(IStorageParcel *parcel) _ERR("AUTHLIST does not allow deletion of entries"); goto CATCH; } - - ret = sqlite3_exec(dbHandle, query, NULL, 0, &errMsg); + sqlite3_mprintf(execquery, query); + ret = sqlite3_exec(dbHandle, execquery, NULL, 0, &errMsg); _INFO("AsmStorage::deleteData:: ERROR MSG : [%s]", errMsg); CATCH_IF_FAIL(ret == SQLITE_OK); -- 2.7.4 From bbb8a5ebbba408305d0b306a214e284d80ca328f Mon Sep 17 00:00:00 2001 From: jkjo92 Date: Wed, 2 Aug 2017 20:49:08 +0900 Subject: [PATCH 16/16] Apply on-demand lauch and fix svace issue Change-Id: I1737f44e46bac9776f165bba3f5444b68e55cfc9 Signed-off-by: jkjo92 --- packaging/fido-asm.service | 5 +++-- packaging/fido-asm.spec | 4 +--- packaging/org.tizen.fido-asm.service | 5 ++--- server/auth_discovery/src/BoundADProvider.cpp | 1 + silent_auth/silent_auth_entry.cpp | 3 +++ 5 files changed, 10 insertions(+), 8 deletions(-) mode change 100644 => 100755 packaging/fido-asm.service mode change 100644 => 100755 packaging/fido-asm.spec mode change 100644 => 100755 packaging/org.tizen.fido-asm.service mode change 100644 => 100755 silent_auth/silent_auth_entry.cpp diff --git a/packaging/fido-asm.service b/packaging/fido-asm.service old mode 100644 new mode 100755 index 9cfc861..a786557 --- a/packaging/fido-asm.service +++ b/packaging/fido-asm.service @@ -1,10 +1,11 @@ [Unit] Description=FIDO ASM service -After=tizen-runtime.target -Requires=tizen-runtime.target [Service] ExecStart=/usr/bin/fido-asm +SmackProcessLabel=System +Type=dbus +BusName=org.tizen.fidoasm User=service_fw Group=service_fw diff --git a/packaging/fido-asm.spec b/packaging/fido-asm.spec old mode 100644 new mode 100755 index 8991840..a558177 --- a/packaging/fido-asm.spec +++ b/packaging/fido-asm.spec @@ -83,9 +83,8 @@ install -m 0644 %SOURCE1 %{buildroot}/usr/share/dbus-1/system-services/org.tizen mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d install -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/dbus-1/system.d/ -mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants +mkdir -p %{buildroot}%{_unitdir} install -m 644 %SOURCE3 %{buildroot}%{_unitdir}/fido-asm.service -%install_service multi-user.target.wants fido-asm.service mkdir -p %{buildroot}%{_libdir}/fido/asm/auth @@ -166,7 +165,6 @@ rm /opt/dbspace/.fido* %{_bindir}/fido-asm %config %{_sysconfdir}/dbus-1/system.d/org.tizen.fido-asm.conf %attr(0644,root,root) %{_unitdir}/fido-asm.service -%attr(0644,root,root) %{_unitdir}/multi-user.target.wants/fido-asm.service %attr(0644,root,root) /usr/share/dbus-1/system-services/org.tizen.fido-asm.service %{_libdir}/fido/asm/fido_asm.json diff --git a/packaging/org.tizen.fido-asm.service b/packaging/org.tizen.fido-asm.service old mode 100644 new mode 100755 index 3b72f51..148009d --- a/packaging/org.tizen.fido-asm.service +++ b/packaging/org.tizen.fido-asm.service @@ -3,6 +3,5 @@ Description=FIDO ASM Service D-BUS [D-BUS Service] Name=org.tizen.fidoasm -Exec=/usr/bin/fido-asm -User=service_fw -Group=service_fw +Exec=/bin/false +SystemdService=fido-asm.service diff --git a/server/auth_discovery/src/BoundADProvider.cpp b/server/auth_discovery/src/BoundADProvider.cpp index f2a26b8..cf1121f 100755 --- a/server/auth_discovery/src/BoundADProvider.cpp +++ b/server/auth_discovery/src/BoundADProvider.cpp @@ -298,6 +298,7 @@ BoundADProvider::loadPlugins(const std::string& dirName) __stubCache->insert(std::make_pair(auth_plugin->id, stub)); } + dlclose(mod); diff --git a/silent_auth/silent_auth_entry.cpp b/silent_auth/silent_auth_entry.cpp old mode 100644 new mode 100755 index ac3718f..b454eb2 --- a/silent_auth/silent_auth_entry.cpp +++ b/silent_auth/silent_auth_entry.cpp @@ -881,6 +881,7 @@ processRegister(unsigned char *assert_req) if (sign_raw == NULL) { _ERR("FIDO SignWithPrivateKeyFile failed"); + SAFE_DELETE(krdStr); SAFE_DELETE(getRegRespInfo); return NULL; } @@ -916,6 +917,7 @@ processRegister(unsigned char *assert_req) } else { _INFO("setEncoder EID_UAFV1_REGISTER_RESP FAIL \n"); + SAFE_DELETE(krdStr); SAFE_DELETE(getRegRespInfo->kh); SAFE_DELETE(getRegRespInfo); return NULL; @@ -927,6 +929,7 @@ processRegister(unsigned char *assert_req) } else { _INFO("decode EID_UAFV1_REGISTER_RESP FAIL \n"); + SAFE_DELETE(krdStr); SAFE_DELETE(getRegRespInfo); return NULL; } -- 2.7.4