OicSecDoxm_t *newDevDoxm, OTMContext_t *otmCtx)
{
OIC_LOG_V(DEBUG, TAG, "IN %s", __func__);
+ OCStackResult res = OC_STACK_ERROR;
//In case of Mutual Verified Just-Works, display mutualVerifNum
if (OIC_MV_JUST_WORKS == newDevDoxm->oxmSel)
uint8_t mutualVerifNum[MUTUAL_VERIF_NUM_LEN] = {0};
OicUuid_t deviceID = {.id = {0}};
- if (OC_STACK_OK != GetDoxmDeviceID(&deviceID))
+ //Generate mutualVerifNum
+ char label[LABEL_LEN] = {0};
+ snprintf(label, LABEL_LEN, "%s%s", MUTUAL_VERIF_NUM, OXM_MV_JUST_WORKS);
+ res = GetDoxmDeviceID(&deviceID);
+ if (OC_STACK_OK != res)
{
OIC_LOG(ERROR, TAG, "Error while retrieving Owner's device ID");
+ SetResult(otmCtx, res);
goto exit;
}
-
- //Generate mutualVerifNum
- char label[LABEL_LEN] = {0};
- snprintf(label, LABEL_LEN, "%s%s", MUTUAL_VERIF_NUM, OXM_MV_JUST_WORKS);
-
CAResult_t pskRet = CAGenerateOwnerPSK(endpoint,
(uint8_t *)label,
strlen(label),
if (CA_STATUS_OK != pskRet)
{
OIC_LOG(WARNING, TAG, "CAGenerateOwnerPSK failed");
+ SetResult(otmCtx, OC_STACK_ERROR);
goto exit;
}
memcpy(mutualVerifNum, preMutualVerifNum + sizeof(preMutualVerifNum) - sizeof(mutualVerifNum),
sizeof(mutualVerifNum));
- if (OC_STACK_OK != VerifyOwnershipTransfer(mutualVerifNum, DISPLAY_NUM))
+ res = VerifyOwnershipTransfer(mutualVerifNum, DISPLAY_NUM);
+ if (OC_STACK_OK != res)
{
OIC_LOG(ERROR, TAG, "Error while displaying mutualVerifNum");
+ SetResult(otmCtx, res);
goto exit;
}
}
//In case of confirmed manufacturer cert, display message
else if (OIC_CON_MFG_CERT == newDevDoxm->oxmSel)
{
- if (OC_STACK_OK != VerifyOwnershipTransfer(NULL, DISPLAY_NUM))
+ res = VerifyOwnershipTransfer(NULL, DISPLAY_NUM);
+ if (OC_STACK_OK != res)
{
OIC_LOG(ERROR, TAG, "Error while displaying message");
+ SetResult(otmCtx, res);
goto exit;
}
}
//Send request : POST /oic/sec/doxm [{... , "devowner":"PT's UUID"}]
- OCStackResult res = PostOwnerUuid(otmCtx);
+ res = PostOwnerUuid(otmCtx);
if(OC_STACK_OK != res)
{
OIC_LOG(ERROR, TAG, "Failed to send owner information");
}
else
{
- res = clientResponse->result;
+ if (OIC_CON_MFG_CERT == otmCtx->selectedDeviceInfo->doxm->oxmSel &&
+ OC_STACK_NOT_ACCEPTABLE == clientResponse->result)
+ {
+ res = OC_STACK_USER_DENIED_REQ;
+ }
+ else
+ {
+ res = clientResponse->result;
+ }
OIC_LOG_V(ERROR, TAG, "OwnerUuidHandler : Unexpected result %d", res);
SetResult(otmCtx, res);
}
#if defined(__WITH_DTLS__) || defined (__WITH_TLS__)
else if (OIC_MANUFACTURER_CERTIFICATE == newDoxm->oxmSel || OIC_CON_MFG_CERT == newDoxm->oxmSel)
{
+ //In case of Confirm Manufacturer Cert, get user confirmation
+ if (OIC_CON_MFG_CERT == newDoxm->oxmSel && false == newDoxm->owned &&
+ false == isDuplicatedMsg &&
+ memcmp(&(newDoxm->owner), &emptyOwner, sizeof(OicUuid_t)) != 0)
+ {
+ if (OC_STACK_OK != VerifyOwnershipTransfer(NULL, USER_CONFIRM))
+ {
+ ehRet = OC_EH_NOT_ACCEPTABLE;
+ goto exit;
+ }
+ else
+ {
+ ehRet = OC_EH_OK;
+ }
+ }
+
//Save the owner's UUID to derive owner credential
memcpy(&(gDoxm->owner), &(newDoxm->owner), sizeof(OicUuid_t));
gDoxm->oxmSel = newDoxm->oxmSel;
VERIFY_SUCCESS(TAG, CA_STATUS_OK == CAregisterPkixInfoHandler(GetManufacturerPkixInfo), ERROR);
VERIFY_SUCCESS(TAG, CA_STATUS_OK == CAregisterGetCredentialTypesHandler(InitManufacturerCipherSuiteList), ERROR);
-
- //In case of Confirm Manufacturer Cert, get user confirmation
- if (OIC_CON_MFG_CERT == newDoxm->oxmSel && false == newDoxm->owned &&
- false == isDuplicatedMsg &&
- memcmp(&(newDoxm->owner), &emptyOwner, sizeof(OicUuid_t)) != 0)
- {
- if (OC_STACK_OK != VerifyOwnershipTransfer(NULL, USER_CONFIRM))
- {
- ehRet = OC_EH_NOT_ACCEPTABLE;
- }
- else
- {
- ehRet = OC_EH_OK;
- }
- }
-
-
}
#endif // __WITH_DTLS__ or __WITH_TLS__
}