Fix for Roaming mode Authentication 59/122159/1
authorManasij Sur Roy <manasij.r@samsung.com>
Thu, 30 Mar 2017 09:51:30 +0000 (15:21 +0530)
committerManasij Sur Roy <manasij.r@samsung.com>
Thu, 30 Mar 2017 09:51:30 +0000 (15:21 +0530)
Change-Id: Ia24440083427ed5d96c024dce2baf76a81dff761
Signed-off-by: Manasij Sur Roy <manasij.r@samsung.com>
server/auth_discovery/src/BAuthStub.cpp
server/auth_discovery/src/RoamingUtil.cpp
server/states/src/AuthenticateState.cpp
server/states/src/DeregState.cpp
silent_auth/instructions.txt

index acd527d..229382d 100644 (file)
@@ -27,26 +27,35 @@ BAuthStub::getInfo(void)
                RET_IF_FAIL(__pluginHandle->process != NULL, NULL);
                RET_IF_FAIL(__pluginHandle->process->process != NULL, NULL);
 
+               _INFO("");
+
                TlvEncodable<GetInfoReq> encodableReq;
                encodableReq.setEncoder(EID_UAFV1_GETINFO_REQ);
 
+               _INFO("");
                TlvEncodable<GetAuthInfoResp> encodableResp;
                encodableResp.setEncoder(EID_UAFV1_GETINFO_RESP);
 
+               _INFO("");
                Buffer *authReq = encodableReq.encode();
                unsigned char *authRespRaw = NULL;
 
+               _INFO("");
                __pluginHandle->process->process(authReq->data, &authRespRaw);
 
+               _INFO("");
                __cachedData = encodableResp.decode(authRespRaw);
                /*Map AuthIndex*/
                /*TODO: Find Device ID logic used by IoTCon*/
 
+               _INFO("");
                if (__cachedData->authList != NULL) {
 
+                       _INFO("");
                        GList *authListIter = g_list_first(__cachedData->authList);
                        while (authListIter != NULL) {
 
+                               _INFO("");
                                AuthenticatorInfo *authInfo = (AuthenticatorInfo*)(authListIter->data);
                                /*TODO: Find Device ID logic used by IoTCon*/
                                _INFO("Before calling getMappedIndex");
@@ -56,14 +65,17 @@ BAuthStub::getInfo(void)
 
                                _INFO("After calling getMappedIndex");
                                authInfo->__devId = strdup(AsmCrypto::getDeviceId().c_str());
+                               _INFO("");
                                authInfo->__isUserEnrolled = isEnrolled();
                                authInfo->__isRoamingAuthenticator = false;
+                               _INFO("");
                                authListIter = authListIter->next;
                        }
 
                }
 
 
+               _INFO("");
                /*Fill-up additional data*/
                __cachedData->attach_hint = ATTACHMENT_HINT_INTERNAL;
                /*__cachedData->attach_hint = __pluginHandle->conn->attach_hint();*/
@@ -71,6 +83,17 @@ BAuthStub::getInfo(void)
                /*__cachedData->description = __pluginHandle->conn->description();*/
        }
 
+       /*Resetting fields altered during last RA operation*/
+       else if (__cachedData->authList != NULL) {
+               _INFO("");
+               GList *authListIter = g_list_first(__cachedData->authList);
+               while (authListIter != NULL) {
+                       AuthenticatorInfo *authInfo = (AuthenticatorInfo*)(authListIter->data);
+                       authInfo->__isRoamingAuthenticator = false;
+                       authListIter = authListIter->next;
+               }
+       }
+
        _INFO("Returning __cachedData");
        return __cachedData;
 }
index 94e0227..8633d9c 100644 (file)
@@ -166,6 +166,7 @@ RoamingUtil::createAuthReq(const char *tlvB64)
 
        default:
                /*Rest are not supported for Roaming operations*/
+               /*https://fidoalliance.org/specs/fido-uaf-v1.0-ps-20141208/fido-uaf-asm-api-v1.0-ps-20141208.html#access-control-for-asm-apis*/
                _ERR("");
                delete asmReq;
                return NULL;
index 1170927..cd95e1b 100644 (file)
@@ -364,8 +364,65 @@ AuthenticateState::handle(IAuthStub *stub, AsmRequest *asmReq, const char *str,
                                signAuthReq->khHList = storedKhList;
                                _INFO("Matched khlist count =[%d]", g_list_length(signAuthReq->khHList));
                        } else {
-                               signAuthReq->khHList = NULL;
-                               _ERR("NO Matched khlist");
+                               _ERR("NO Matched khlist, trying with direct keyid");
+
+                               /*Temp fix to not use b64 encode of keyid*/
+
+
+                               IStorageParcel *searchParcel = new AsmStorageParcel();
+                               std::string appIdStr(signAuthReq->appId);
+                               searchParcel->setString(STR_PROP_APP_ID, appIdStr);
+
+                               GList *storedKhList = NULL;
+                               GList *recvdKhListIter = g_list_first(signAuthReq->khHList);
+
+                               while (recvdKhListIter != NULL) {
+
+                                               char *recvKh = (char*)(recvdKhListIter->data);
+                                               /*unsigned char *recvKhDec = AsmCrypto::ToBase64Url((unsigned char*)recvKh, strlen(recvKh));*/
+                                               if (recvKh != NULL) {
+
+                                                       std::string kIdStr((char*)recvKh);
+                                                       searchParcel->setString(STR_PROP_KEY_ID, kIdStr);
+                                                       _INFO("search=[%s][%s]", appIdStr.c_str(), kIdStr.c_str());
+
+                                                       std::vector<IStorageParcel*> *searchRes = AsmStorage::getInstance()->searchData(searchParcel);
+                                                       if (searchRes != NULL) {
+
+                                                               int recFound = searchRes->size();
+                                                               _INFO("Records found in database corresponding to appId = [%d]", recFound);
+                                                               if (recFound <= 0) {
+                                                                       _INFO("No key registered for this app");
+                                                               }
+
+                                                               std::vector<IStorageParcel*>::iterator searchResIter = searchRes->begin();
+
+                                                               for (; searchResIter != searchRes->end(); ++searchResIter) {
+
+                                                                       IStorageParcel *parcel = *searchResIter;
+                                                                       char *kh = NULL;
+                                                                       int res = parcel->getString(STR_PROP_KEY_HANDLE, &kh);
+
+                                                                       if (res == 0) {
+                                                                               _INFO("Length of b64 encoded keyHandle : [%d]", strlen(kh));
+                                                                               storedKhList = g_list_append(storedKhList, kh);
+                                                                       }
+                                                               }
+                                                       }
+                                       }
+
+                                       recvdKhListIter = recvdKhListIter->next;
+                               }
+
+                               if (storedKhList == NULL) {
+                                       _ERR("No matching keyid found");
+                                       return -1;
+                               }
+
+                               storedKhList = g_list_first(storedKhList);
+                               signAuthReq->khHList = storedKhList;
+                               _INFO("Matched khlist count =[%d]", g_list_length(signAuthReq->khHList));
+
                        }
                }
 
index fcf5b48..88ffdd6 100644 (file)
@@ -118,6 +118,10 @@ DeregState::handle(IAuthStub *authStub, AsmRequest *asmReq, const char *str, cha
                if(deleteRecord == -1)
                        return -1;
 
+               /*Temp fix: try to delete b64enc keyid too*/
+               _INFO("About to delete non-b64-enc too=[%s][%s]", deRegAuthReq->appId, deRegAuthReq->keyId);
+               deleteRecord = deleteAsmRecord(deRegAuthReq->appId, deRegAuthReq->keyId);
+
                DeregResp *stubResp = authStub->processDeregister(deRegAuthReq);
                RET_IF_FAIL(stubResp != NULL, -1);
 
index 1bc48bb..4b19393 100644 (file)
@@ -17,9 +17,8 @@ Setup:-
        - echo "User::Pkg::org.tizen.fido-syspopup" >> /etc/auth-fw/client-whitelist
 6. Install rademotv from IDE
 If IDE does not recognize TM1 then:
-sdb push org.example.rademotv-1.0.0-arm.tpk /opt/usr/home/owner/apps_rw/tmp
+sdb push org.example.rademotv-1.0.0-arm.tpk /opt/usr/home/owner/apps_rw/tmp/
 sdb shell tpk-backend -i /opt/usr/home/owner/apps_rw/tmp/org.example.rademotv-1.0.0-arm.tpk
-sdb shell tpk-backend -i /opt/usr/home/owner/apps_rw/tmp/org.example.rademotv-1.0.0-arm.tpk --preload
 
 6. Reboot