From 29c48cb5501b24db6a8e4c9113706d111f4cb23c Mon Sep 17 00:00:00 2001 From: "js126.lee" Date: Mon, 21 Mar 2016 01:18:40 +0900 Subject: [PATCH] Fixed bug of pstat during OTM 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 Reviewed-on: https://gerrit.iotivity.org/gerrit/6107 Tested-by: jenkins-iotivity Reviewed-by: Kyungsun Cho Reviewed-by: Randeep Singh --- .../ck_manager/sample/oic_svr_db_door.dat | Bin 366 -> 366 bytes .../ck_manager/sample/oic_svr_db_door.json | 2 +- .../ck_manager/sample/oic_svr_db_light.dat | Bin 366 -> 366 bytes .../ck_manager/sample/oic_svr_db_light.json | 2 +- .../sample/oic_svr_db_server_justworks.dat | Bin 431 -> 431 bytes .../sample/oic_svr_db_server_justworks.json | 2 +- .../sample/oic_svr_db_server_randompin.dat | Bin 432 -> 432 bytes .../sample/oic_svr_db_server_randompin.json | 2 +- .../provisioning/src/ownershiptransfermanager.c | 12 ++++++--- resource/csdk/security/src/pstatresource.c | 28 +++++++++------------ .../secure/oic_svr_db_client_directpairing.dat | Bin 353 -> 353 bytes .../secure/oic_svr_db_client_directpairing.json | 2 +- 12 files changed, 26 insertions(+), 24 deletions(-) mode change 100755 => 100644 resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.json diff --git a/resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_door.dat b/resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_door.dat index e6ddaa80ee03b78e3718c2e6ac1cd360b4b3dca1..bbe13a6305c0ac115fbb3cfd2e408ab28235844e 100644 GIT binary patch delta 13 UcmaFI^p0r*2O}fXWKPCZ03Y51p8x;= delta 13 UcmaFI^p0r*2O}fHWKPCZ03Xx?od5s; diff --git a/resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_door.json b/resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_door.json index 05cc4b0..64b51f0 100644 --- a/resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_door.json +++ b/resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_door.json @@ -32,7 +32,7 @@ "isop": false, "deviceid": "ZG9vckRldmljZVVVSUQwMA==", "ch": 0, - "cm": 0, + "cm": 2, "tm": 0, "om": 3, "sm": [3] diff --git a/resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_light.dat b/resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_light.dat index 0f4653aa92b5908d8dae36c1ad58456e8b9525b9..8728afd9f6a5740c131f41b919f7333b3d7f6179 100644 GIT binary patch delta 13 UcmaFI^p0r*2O}fXWKPCZ03Y51p8x;= delta 13 UcmaFI^p0r*2O}fHWKPCZ03Xx?od5s; diff --git a/resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_light.json b/resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_light.json index 5ec466b..96bd2e9 100644 --- a/resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_light.json +++ b/resource/csdk/security/provisioning/ck_manager/sample/oic_svr_db_light.json @@ -32,7 +32,7 @@ "isop": false, "deviceid": "bGlnaHREZXZpY2VVVUlEMA==", "ch": 0, - "cm": 0, + "cm": 2, "tm": 0, "om": 3, "sm": [3] diff --git a/resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.dat b/resource/csdk/security/provisioning/sample/oic_svr_db_server_justworks.dat index 552fdec1087a3d167521586fa9b057594e6d31f2..7e569f10f6c4a2dee010ca5afb23bfc089af9503 100644 GIT binary patch delta 13 UcmZ3_yqcm)) + { + 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) { diff --git a/resource/csdk/security/src/pstatresource.c b/resource/csdk/security/src/pstatresource.c index 2fb01c0..f51c8c7 100644 --- a/resource/csdk/security/src/pstatresource.c +++ b/resource/csdk/security/src/pstatresource.c @@ -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"); } } } diff --git a/resource/csdk/stack/samples/linux/secure/oic_svr_db_client_directpairing.dat b/resource/csdk/stack/samples/linux/secure/oic_svr_db_client_directpairing.dat index 917900f9c3b5e04f24323073f4d3524a8c144d43..59d7dea27a57eed99d7e701f3c2b826bbb5bafcb 100644 GIT binary patch delta 11 ScmaFJ^pI)7Z$_qxe^LP-vIR!~ delta 11 ScmaFJ^pI)7Z$^fRe^LP-ss%*= diff --git a/resource/csdk/stack/samples/linux/secure/oic_svr_db_client_directpairing.json b/resource/csdk/stack/samples/linux/secure/oic_svr_db_client_directpairing.json index 3da1ae9..ad5519d 100644 --- a/resource/csdk/stack/samples/linux/secure/oic_svr_db_client_directpairing.json +++ b/resource/csdk/stack/samples/linux/secure/oic_svr_db_client_directpairing.json @@ -31,7 +31,7 @@ "isop": false, "deviceid": "ZGlyZWN0cGFpcmluZ0Rldg==", "ch": 0, - "cm": 0, + "cm": 2, "tm": 0, "om": 3, "sm": [3] -- 2.7.4