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,
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
#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)