Fixed bug of pstat during OTM 07/6107/7
authorjs126.lee <js126.lee@samsung.com>
Sun, 20 Mar 2016 16:18:40 +0000 (01:18 +0900)
committerRandeep Singh <randeep.s@samsung.com>
Mon, 21 Mar 2016 13:44:38 +0000 (13:44 +0000)
Issue: After completed OTM, ISOP is false.
According to Spec, The TAKE_OWNER of CM should be enabled for OTM.

-Patch 1,2: Fixed isOp issue.
-Patch 3: During OTM, CM  is only considered by PT.
-Patch 4: Modify the CM value 0 -> 2 in *.json ant *.dat for OTM.
-Patch 5,6: Fixed build error on Arduino

Change-Id: I6eb625af743adc9f559c2cc085e419d367e78949
Signed-off-by: js126.lee <js126.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/6107
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Kyungsun Cho <goodsun.cho@samsung.com>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
12 files changed:
resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_door.dat
resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_door.json
resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_light.dat
resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_light.json
resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.dat
resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.json [changed mode: 0755->0644]
resource/csdk/security/provisioning/sample/oic_svr_db_server_randompin.dat
resource/csdk/security/provisioning/sample/oic_svr_db_server_randompin.json
resource/csdk/security/provisioning/src/ownershiptransfermanager.c
resource/csdk/security/src/pstatresource.c
resource/csdk/stack/samples/linux/secure/oic_svr_db_client_directpairing.dat
resource/csdk/stack/samples/linux/secure/oic_svr_db_client_directpairing.json

index e6ddaa8..bbe13a6 100644 (file)
Binary files a/resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_door.dat and b/resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_door.dat differ
index 05cc4b0..64b51f0 100644 (file)
@@ -32,7 +32,7 @@
                "isop": false,
                "deviceid":     "ZG9vckRldmljZVVVSUQwMA==",
                "ch": 0,
-               "cm":   0,
+               "cm":   2,
                "tm":   0,
                "om":   3,
                "sm":   [3]
index 0f4653a..8728afd 100644 (file)
Binary files a/resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_light.dat and b/resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_light.dat differ
index 5ec466b..96bd2e9 100644 (file)
@@ -32,7 +32,7 @@
                "isop": false,
                "deviceid":     "bGlnaHREZXZpY2VVVUlEMA==",
                "ch": 0,
-               "cm":   0,
+               "cm":   2,
                "tm":   0,
                "om":   3,
                "sm":   [3]
index 552fdec..7e569f1 100644 (file)
Binary files a/resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.dat and b/resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.dat differ
old mode 100755 (executable)
new mode 100644 (file)
index abb850f..459f269
@@ -42,7 +42,7 @@
                "isop": false,
                "deviceid":     "anVzdHdvcmtzRGV2VVVJRA==",
                "ch": 0,
-               "cm":   0,
+               "cm":   2,
                "tm":   0,
                "om":   3,
                "sm":   [3]
index 5e123bd..3ce3d98 100644 (file)
Binary files a/resource/csdk/security/provisioning/sample/oic_svr_db_server_randompin.dat and b/resource/csdk/security/provisioning/sample/oic_svr_db_server_randompin.dat differ
index 181e105..6cbe777 100644 (file)
@@ -42,7 +42,7 @@
                "isop": false,
                "deviceid":     "cmFuZG9tUGluRGV2VVVJRA==",
                "ch": 0,
-               "cm":   0,
+               "cm":   2,
                "tm":   0,
                "om":   3,
                "sm":   [3]
index b797f98..2659999 100644 (file)
@@ -550,6 +550,12 @@ static OCStackApplicationResult ListMethodsHandler(void *ctx, OCDoHandle UNUSED,
             SetResult(otmCtx, OC_STACK_ERROR);
             return OC_STACK_DELETE_TRANSACTION;
         }
+        if(false == (TAKE_OWNER & pstat->cm))
+        {
+            OIC_LOG(ERROR, TAG, "Device pairing mode enabling owner transfer operations is disabled");
+            SetResult(otmCtx, OC_STACK_ERROR);
+            return OC_STACK_DELETE_TRANSACTION;
+        }
         otmCtx->selectedDeviceInfo->pstat = pstat;
 
         //Select operation mode (Currently supported SINGLE_SERVICE_CLIENT_DRIVEN only)
@@ -1506,9 +1512,9 @@ OCStackResult PutProvisioningStatus(OTMContext_t* otmCtx)
         return OC_STACK_INVALID_PARAM;
     }
 
-    otmCtx->selectedDeviceInfo->pstat->tm = NORMAL;
-    otmCtx->selectedDeviceInfo->pstat->cm = PROVISION_ACLS | PROVISION_CREDENTIALS |
-                                            SECURITY_MANAGEMENT_SERVICES | BOOTSTRAP_SERVICE;
+    //Change the TAKE_OWNER bit of CM to 0.
+    otmCtx->selectedDeviceInfo->pstat->cm &= (~TAKE_OWNER);
+
     OCSecurityPayload *secPayload = (OCSecurityPayload *)OICCalloc(1, sizeof(OCSecurityPayload));
     if (!secPayload)
     {
index 2fb01c0..f51c8c7 100644 (file)
@@ -48,7 +48,7 @@ static OicSecDpom_t gSm = SINGLE_SERVICE_CLIENT_DRIVEN;
 static OicSecPstat_t gDefaultPstat =
 {
     false,                                    // bool isOwned
-    (OicSecDpm_t)(TAKE_OWNER | BOOTSTRAP_SERVICE | SECURITY_MANAGEMENT_SERVICES |
+    (OicSecDpm_t)(BOOTSTRAP_SERVICE | SECURITY_MANAGEMENT_SERVICES |
     PROVISION_CREDENTIALS | PROVISION_ACLS),   // OicSecDpm_t cm
     (OicSecDpm_t)(TAKE_OWNER | BOOTSTRAP_SERVICE | SECURITY_MANAGEMENT_SERVICES |
     PROVISION_CREDENTIALS | PROVISION_ACLS),   // OicSecDpm_t tm
@@ -367,19 +367,15 @@ static OCEntityHandlerResult HandlePstatPutRequest(const OCEntityHandlerRequest
         VERIFY_NON_NULL(TAG, pstat, ERROR);
         if (OC_STACK_OK == ret)
         {
-            if (pstat->tm != NORMAL)
+            if (false == (pstat->cm & TAKE_OWNER))
             {
-                gPstat->tm = pstat->tm;
-                if(0 == pstat->tm && gPstat->commitHash == pstat->commitHash)
-                {
-                    gPstat->isOp = true;
-                    gPstat->cm = NORMAL;
-                    OIC_LOG (INFO, TAG, "CommitHash is valid and isOp is TRUE");
-                }
-                else
-                {
-                    OIC_LOG(DEBUG, TAG, "CommitHash is not valid");
-                }
+                gPstat->isOp = true;
+                gPstat->cm = pstat->cm;
+                OIC_LOG (INFO, TAG, "Taken owner succeed and isOp is TRUE");
+            }
+            else
+            {
+                OIC_LOG(DEBUG, TAG, "Taken owner failed");
             }
             if (pstat->om != MULTIPLE_SERVICE_SERVER_DRIVEN && gPstat)
             {
@@ -545,8 +541,8 @@ void RestorePstatToInitState()
     {
         OIC_LOG(INFO, TAG, "PSTAT resource will revert back to initial status.");
 
-        gPstat->cm = NORMAL;
-        gPstat->tm = NORMAL;
+        gPstat->cm = (OicSecDpm_t)(gPstat->cm | TAKE_OWNER);
+        gPstat->tm = (OicSecDpm_t)(gPstat->tm & (~TAKE_OWNER));
         gPstat->om = SINGLE_SERVICE_CLIENT_DRIVEN;
         if(gPstat->sm && 0 < gPstat->smLen)
         {
@@ -555,7 +551,7 @@ void RestorePstatToInitState()
 
         if (!UpdatePersistentStorage(gPstat))
         {
-            OIC_LOG(ERROR, TAG, "Failed to revert DOXM in persistent storage");
+            OIC_LOG(ERROR, TAG, "Failed to revert PSTAT in persistent storage");
         }
     }
 }
index 917900f..59d7dea 100644 (file)
Binary files a/resource/csdk/stack/samples/linux/secure/oic_svr_db_client_directpairing.dat and b/resource/csdk/stack/samples/linux/secure/oic_svr_db_client_directpairing.dat differ
index 3da1ae9..ad5519d 100644 (file)
@@ -31,7 +31,7 @@
                "isop": false,
                "deviceid":     "ZGlyZWN0cGFpcmluZ0Rldg==",
                "ch": 0,
-               "cm":   0,
+               "cm":   2,
                "tm":   0,
                "om":   3,
                "sm":   [3]