From: Jihun Ha Date: Sat, 7 Jan 2017 04:09:08 +0000 (+0900) Subject: Update for Multi Ownership Transfer condition X-Git-Tag: 1.3.0~902 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=505aee795593c8d3fd436980feb0e80ccbc1ff85;p=platform%2Fupstream%2Fiotivity.git Update for Multi Ownership Transfer condition The found enrollee's owner ID indicates a same ID of mediator. However, a list of owned devices managed in mediator's PMD db has no element for the found enrollee. In that case, MOT will be failed. For this, ES_OWNERSHIP_IS_NOT_SYNCHRONIZED value is returned, which guides a user to reset a Enrollee's SVR DB file. Change-Id: Ia5feaccccfc4cca4a0673d08cbba4d473324e37f Signed-off-by: Parkhi Signed-off-by: Jihun Ha Reviewed-on: https://gerrit.iotivity.org/gerrit/16191 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- diff --git a/service/easy-setup/inc/escommon.h b/service/easy-setup/inc/escommon.h index ecd31bb..39636ef 100755 --- a/service/easy-setup/inc/escommon.h +++ b/service/easy-setup/inc/escommon.h @@ -174,7 +174,10 @@ typedef enum ES_SECURE_RESOURCE_DISCOVERY_FAILURE, /** - * Ownership transfer fails because DTLS handshake failure happens + * Ownership transfer fails due to one of unexpected reasons. + * E.g. A packet loss even with retransmission happens during ownership transfer. + * E.g. Mediator's owned status is 'unowned' + * E.g. A user confirmation for random pin-based or certificate-based OT fails */ ES_OWNERSHIP_TRANSFER_FAILURE, @@ -203,6 +206,14 @@ typedef enum ES_PRE_CONFIG_PIN_PROVISIONING_FAILURE, /** + * The found enrollee's owner ID indicates a same ID of mediator. + * However, a list of owned devices managed in mediator's PMD db has no element for the found enrollee. + * That can happen where only mediator is reset without any inform to the enrollee. + * To proceed an ownership transfer to the enrollee, it needs to reset the enrollee's SVR DB for its owner, i.e. the mediator + */ + ES_OWNERSHIP_IS_NOT_SYNCHRONIZED, + + /** * Provisioning fails for some reason. */ ES_ERROR = 255 diff --git a/service/easy-setup/mediator/richsdk/src/EnrolleeSecurity.cpp b/service/easy-setup/mediator/richsdk/src/EnrolleeSecurity.cpp index d9d1b47..99bc477 100755 --- a/service/easy-setup/mediator/richsdk/src/EnrolleeSecurity.cpp +++ b/service/easy-setup/mediator/richsdk/src/EnrolleeSecurity.cpp @@ -493,6 +493,53 @@ namespace OIC #ifdef MULTIPLE_OWNER else { + OCUUIdentity* mediatorDevId = (OCUUIdentity* )OICMalloc(sizeof(OCUUIdentity)); + + if(!mediatorDevId) + { + OIC_LOG(DEBUG, ENROLEE_SECURITY_TAG, "provisionOwnership: OICMalloc error return"); + res = ESResult::ES_OWNERSHIP_TRANSFER_FAILURE; + return res; + } + + if(OC::OCPlatform::getDeviceId(mediatorDevId) != OC_STACK_OK) + { + OIC_LOG(ERROR, ENROLEE_SECURITY_TAG, "getDeviceId is failed."); + res = ESResult::ES_OWNERSHIP_TRANSFER_FAILURE; + OICFree(mediatorDevId); + return res; + } + + if(!memcmp(m_securedResource->getDevPtr()->doxm->owner.id, + mediatorDevId->id, UUID_IDENTITY_SIZE * sizeof(uint8_t))) + { + OIC_LOG(ERROR, ENROLEE_SECURITY_TAG, + "The found device's owner ID is same as Mediator's ID but Meditor does not know it"); + OIC_LOG(ERROR, ENROLEE_SECURITY_TAG, "Only Mediator would be reset"); + res = ESResult::ES_OWNERSHIP_IS_NOT_SYNCHRONIZED; + OICFree(mediatorDevId); + return res; + } + + OicSecSubOwner_t* subOwnerList = m_securedResource->getDevPtr()->doxm->subOwners; + + while(subOwnerList) + { + if(!memcmp(subOwnerList->uuid.id, mediatorDevId->id, + UUID_IDENTITY_SIZE * sizeof(uint8_t))) + { + OIC_LOG(ERROR, ENROLEE_SECURITY_TAG, + "The found device's subOwner ID is same as Mediator's ID but Meditor does not know it"); + OIC_LOG(ERROR, ENROLEE_SECURITY_TAG, "Only Mediator would be reset"); + res = ESResult::ES_OWNERSHIP_IS_NOT_SYNCHRONIZED; + OICFree(mediatorDevId); + return res; + } + subOwnerList = subOwnerList->next; + } + + OICFree(mediatorDevId); + res = performMultipleOwnershipTransfer(); if(res != ESResult::ES_OK)