Fixed bug of pstat during OTM
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 e6ddaa80ee03b78e3718c2e6ac1cd360b4b3dca1..bbe13a6305c0ac115fbb3cfd2e408ab28235844e 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 05cc4b04171a70f6777823a915b1f0b314eed0cc..64b51f09cc57e6140abed94b19622e4eec9f82ce 100644 (file)
@@ -32,7 +32,7 @@
                "isop": false,
                "deviceid":     "ZG9vckRldmljZVVVSUQwMA==",
                "ch": 0,
-               "cm":   0,
+               "cm":   2,
                "tm":   0,
                "om":   3,
                "sm":   [3]
index 0f4653aa92b5908d8dae36c1ad58456e8b9525b9..8728afd9f6a5740c131f41b919f7333b3d7f6179 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 5ec466bcaaee9c2d8c6a28bff1718f1205e59391..96bd2e979e6911815d408d57675d889464d972d1 100644 (file)
@@ -32,7 +32,7 @@
                "isop": false,
                "deviceid":     "bGlnaHREZXZpY2VVVUlEMA==",
                "ch": 0,
-               "cm":   0,
+               "cm":   2,
                "tm":   0,
                "om":   3,
                "sm":   [3]
index 552fdec1087a3d167521586fa9b057594e6d31f2..7e569f10f6c4a2dee010ca5afb23bfc089af9503 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 5e123bdf2efcdcd529889eeff133f212c0b72cf8..3ce3d988e9dd7be9805b4c6080ad5c822d419079 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 181e1057cca2c7b3e3ad026e5da0c911c2f9b84d..6cbe7775be400bb9002ff8ea3cd12ff54b040b77 100644 (file)
@@ -42,7 +42,7 @@
                "isop": false,
                "deviceid":     "cmFuZG9tUGluRGV2VVVJRA==",
                "ch": 0,
-               "cm":   0,
+               "cm":   2,
                "tm":   0,
                "om":   3,
                "sm":   [3]
index b797f98af5d04d58df5b0d256c933b1cb6319b98..2659999fea583e39af8c075e8b1c7ce84176f36c 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 2fb01c066e0ba61e5a40d16a19b154b9cb854a75..f51c8c7ccd11b6f18ec3f4c1012596dd2a807b04 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 917900f9c3b5e04f24323073f4d3524a8c144d43..59d7dea27a57eed99d7e701f3c2b826bbb5bafcb 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 3da1ae9b19d57a46aa5e9e85ad829866ffd631c3..ad5519de6d3a9110f1a960c2561d22b3213e0835 100644 (file)
@@ -31,7 +31,7 @@
                "isop": false,
                "deviceid":     "ZGlyZWN0cGFpcmluZ0Rldg==",
                "ch": 0,
-               "cm":   0,
+               "cm":   2,
                "tm":   0,
                "om":   3,
                "sm":   [3]