Commit a4c5663c authored by leechul's avatar leechul Committed by Dmitriy Zhuravlev

Modify to update rowner as PT's UUID when ownership transfer is done.

  1) Modify data structure of each security resource as single instance of rowner.
  1) Add internal API to set the rowner.
  2) Modify the doxmresource.c in order to update rowner when OTM is done.
  3) Fix the minor bugs.

[Patch 1] : Intial upload
[Patch 2] : Revert the direct pairing related SVR DB files to prevent conflict.
[Patch 3] : Rebase
[Patch 4] : Remove the compile errors
[Patch 5-6] : Remove the compile errors for arduino
[Patch 7] : Update commit message
[Patch 8] : Rebase

Change-Id: I2f10786082265a2942dcadccb12f113658db8c34
Signed-off-by: default avatarleechul <chuls.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/6325Reviewed-by: default avatarYonggoo Kang <ygace.kang@samsung.com>
Reviewed-by: default avatarDmitriy Zhuravlev <d.zhuravlev@samsung.com>
Tested-by: default avatarDmitriy Zhuravlev <d.zhuravlev@samsung.com>
parent 8e8fb015
......@@ -87,6 +87,15 @@ OCStackResult InstallNewACL(const uint8_t* payload, const size_t size);
*/
OCStackResult UpdateDefaultSecProvACL();
/**
* Internal function to update resource owner
*
* @param newROwner new owner
*
* @retval ::OC_STACK_OK for Success, otherwise some error value
*/
OCStackResult SetAclRownerId(const OicUuid_t* newROwner);
#ifdef __cplusplus
}
#endif
......
......@@ -73,6 +73,16 @@ OCStackResult AmaclGetAmsDeviceId(const char *resource, OicUuid_t *amsId);
OCStackResult AmaclToCBORPayload(const OicSecAmacl_t *amacl, uint8_t **cborPayload,
size_t *cborSize);
/**
* Internal function to update resource owner
*
* @param newROwner new owner
*
* @retval ::OC_STACK_OK for Success, otherwise some error value
*/
OCStackResult SetAmaclRownerId(const OicUuid_t* newROwner);
#ifdef __cplusplus
}
#endif
......
......@@ -76,15 +76,14 @@ OCStackResult CredToCBORPayload(const OicSecCred_t* cred, uint8_t **cborPayload,
* @param credType credential type.
* @param publicData public data such as public key.
* @param privateData private data such as private key.
* @param ownersLen length of owners array
* @param owners array of owners.
* @param rownerID Resource owner's UUID.
*
* @return pointer to instance of @ref OicSecCred_t if successful. else NULL in case of error.
*/
OicSecCred_t * GenerateCredential(const OicUuid_t* subject, OicSecCredType_t credType,
const OicSecCert_t * publicData, const OicSecKey_t * privateData,
size_t ownersLen, const OicUuid_t * owners);
const OicUuid_t * rownerID);
/**
* This function adds the new cred to the credential list.
......@@ -130,15 +129,14 @@ int32_t GetDtlsPskCredentials( CADtlsPskCredType_t type,
* @param credType is the type of credential to be added
* @param pin is the numeric characters
* @param pinSize is the length of 'pin'
* @param ownersLen is the number of owners
* @param owners is the array of owners
* @param rownerID Resource owner's UUID
* @param tmpCredSubject is the generated credential's subject.
*
* @return ::OC_STACK_OK for success or else errorcode.
*/
OCStackResult AddTmpPskWithPIN(const OicUuid_t* tmpSubject, OicSecCredType_t credType,
const char * pin, size_t pinSize,
size_t ownersLen, const OicUuid_t * owners,
const OicUuid_t * rownerID,
OicUuid_t* tmpCredSubject);
#endif /* __WITH_DTLS__ */
......@@ -162,6 +160,15 @@ int GetDtlsX509Credentials(CADtlsX509Creds_t *credInfo);
*/
void DeleteCredList(OicSecCred_t* cred);
/**
* Internal function to update resource owner
*
* @param newROwner new owner
*
* @retval ::OC_STACK_OK for Success, otherwise some error value
*/
OCStackResult SetCredRownerId(const OicUuid_t* newROwner);
#ifdef __cplusplus
}
#endif
......
......@@ -91,6 +91,15 @@ OCStackResult SavePairingPSK(OCDevAddr *endpoint,
#endif // __WITH_DTLS__
/**
* Internal function to update resource owner
*
* @param newROwner new owner
*
* @retval ::OC_STACK_OK for Success, otherwise some error value
*/
OCStackResult SetDpairingRownerId(const OicUuid_t* newROwner);
#ifdef __cplusplus
}
#endif
......
......@@ -117,6 +117,14 @@ void DeletePconfBinData(OicSecPconf_t* pconf);
*/
void FreePdAclList(OicSecPdAcl_t* pdacls);
/**
* Internal function to update resource owner
*
* @param newROwner new owner
*
* @retval ::OC_STACK_OK for Success, otherwise some error value
*/
OCStackResult SetPconfRownerId(const OicUuid_t* newROwner);
#ifdef __cplusplus
}
......
......@@ -76,6 +76,15 @@ void DeletePstatBinData(OicSecPstat_t* pstat);
*/
void RestorePstatToInitState();
/**
* Internal function to update resource owner
*
* @param newROwner new owner
*
* @retval ::OC_STACK_OK for Success, otherwise some error value
*/
OCStackResult SetPstatRownerId(const OicUuid_t* newROwner);
#ifdef __cplusplus
}
#endif
......
......@@ -325,8 +325,7 @@ struct OicSecAcl
size_t prdRecrLen; // the number of elts in Periods
char **periods; // 3:R:M*:N:String (<--M*; see Spec)
char **recurrences; // 5:R:M:N:String
size_t ownersLen; // the number of elts in Owners
OicUuid_t *owners; // 8:R:M:Y:oic.uuid
OicUuid_t rownerID; // 8:R:S:Y:oic.uuid
// NOTE: we are using UUID for Owners instead of Svc type for mid-April
// SRM version only; this will change to Svc type for full implementation.
//TODO change Owners type to oic.sec.svc
......@@ -345,8 +344,7 @@ struct OicSecAmacl
char **resources; // 0:R:M:Y:String
size_t amssLen; // the number of elts in Amss
OicUuid_t *amss; // 1:R:M:Y:acl
size_t ownersLen; // the number of elts in Owners
OicUuid_t *owners; // 2:R:M:Y:oic.uuid
OicUuid_t rownerID; // 2:R:S:Y:oic.uuid
// NOTE: we are using UUID for Owners instead of Svc type for mid-April
// SRM version only; this will change to Svc type for full implementation.
//TODO change Owners type to oic.sec.svc
......@@ -373,8 +371,7 @@ struct OicSecCred
#endif /* __WITH_X509__ */
OicSecKey_t privateData; // 6:R:S:N:oic.sec.key
char *period; // 7:R:S:N:String
size_t ownersLen; // the number of elts in Owners
OicUuid_t *owners; // 8:R:M:Y:oic.uuid
OicUuid_t rownerID; // 8:R:S:Y:oic.uuid
// NOTE: we are using UUID for Owners instead of Svc type for mid-April
// SRM version only; this will change to Svc type for full implementation.
//OicSecSvc_t *Owners; // 8:R:M:Y:oic.sec.svc
......@@ -537,7 +534,7 @@ struct OicSecPconf
OicUuid_t *pddevs; // 4:R:M:Y:oic.uuid
size_t pddevLen; // the number of elts in pddev
OicUuid_t deviceID; // 5:R:S:Y:oic.uuid
OicUuid_t rowner; // 6:R:S:Y:oic.uuid
OicUuid_t rownerID; // 6:R:S:Y:oic.uuid
};
/**
......@@ -548,7 +545,7 @@ struct OicSecDpairing
// <Attribute ID>:<Read/Write>:<Multiple/Single>:<Mandatory?>:<Type>
OicSecPrm_t spm; // 0:R/W:S:Y:UINT16
OicUuid_t pdeviceID; // 1:R:S:Y:oic.uuid
OicUuid_t rowner; // 2:R:S:Y:oic.uuid
OicUuid_t rownerID; // 2:R:S:Y:oic.uuid
};
#define MAX_VERSION_LEN 16 // Security Version length. i.e., 00.00.000 + reserved space
......
......@@ -80,9 +80,6 @@ static void deleteACL(OicSecAcl_t *acl)
}
OICFree((acl)->resources);
/* Clean Owners */
OICFree((acl)->owners);
/* Clean ACL node itself */
OICFree((acl));
......@@ -275,43 +272,28 @@ static int InputACL(OicSecAcl_t *acl)
}
while (0 != CalculateAclPermission(temp_pms, &(acl->permission)) );
// Set Rowner
printf("Num. of Rowner : ");
ret = scanf("%zu", &acl->ownersLen);
if(-1 == ret)
{
printf("Error while input\n");
return -1;
}
printf("-URN identifying the rowner\n");
printf("ex) lightDeviceUUID0 (16 Numbers except to '-')\n");
acl->owners = (OicUuid_t *)OICCalloc(acl->ownersLen, sizeof(OicUuid_t));
if (NULL == acl->owners)
printf("Rowner : ");
char *ptr_temp_id = NULL;
ret = scanf("%19ms", &ptr_temp_id);
if (1 == ret)
{
OIC_LOG(ERROR, TAG, "Error while memory allocation");
OICStrcpy(temp_id, sizeof(temp_id), ptr_temp_id);
OICFree(ptr_temp_id);
}
else
{
printf("Error while input\n");
return -1;
}
for (size_t i = 0; i < acl->ownersLen; i++)
j = 0;
for (int k = 0; temp_id[k] != '\0'; k++)
{
printf("[%zu]Rowner : ", i + 1);
char *ptr_temp_id = NULL;
ret = scanf("%19ms", &ptr_temp_id);
if (1 == ret)
{
OICStrcpy(temp_id, sizeof(temp_id), ptr_temp_id);
OICFree(ptr_temp_id);
}
else
{
printf("Error while input\n");
return -1;
}
j = 0;
for (int k = 0; temp_id[k] != '\0'; k++)
if (DASH != temp_id[k])
{
if (DASH != temp_id[k])
{
acl->owners[i].id[j++] = temp_id[k];
}
acl->rownerID.id[j++] = temp_id[k];
}
}
return 0;
......
......@@ -1018,13 +1018,6 @@ static OicSecAcl_t* createAcl(const int dev_num)
}
printf(" Entered Wrong Number. Please Enter Again\n");
}
acl->ownersLen = 1;
acl->owners = (OicUuid_t*) OICCalloc(1, sizeof(OicUuid_t));
if(!acl->owners)
{
OIC_LOG(ERROR, TAG, "createAcl: OICCalloc error return");
goto CRACL_ERROR;
}
dev = getDevInst((const OCProvisionDev_t*)g_own_list, own_num);
if(!dev || !dev->doxm)
......@@ -1032,7 +1025,7 @@ static OicSecAcl_t* createAcl(const int dev_num)
OIC_LOG(ERROR, TAG, "createAcl: device instance empty");
goto CRACL_ERROR;
}
memcpy(acl->owners, &dev->doxm->deviceID, UUID_LENGTH);
memcpy(&acl->rownerID, &dev->doxm->deviceID, sizeof(OicUuid_t));
printf("\n");
return acl;
......
......@@ -68,11 +68,11 @@ OCStackResult PMGeneratePairWiseCredentials(OicSecCredType_t type, size_t keySiz
OCFillRandomMem(privData, privDataKeySize);
// TODO: currently owner array is 1. only provisioning tool's id.
tempFirstCred = GenerateCredential(secondDeviceId, type, NULL, &privKey, 1, ptDeviceId);
tempFirstCred = GenerateCredential(secondDeviceId, type, NULL, &privKey, ptDeviceId);
VERIFY_NON_NULL(TAG, tempFirstCred, ERROR);
// TODO: currently owner array is 1. only provisioning tool's id.
tempSecondCred = GenerateCredential(firstDeviceId, type, NULL, &privKey, 1, ptDeviceId);
tempSecondCred = GenerateCredential(firstDeviceId, type, NULL, &privKey, ptDeviceId);
VERIFY_NON_NULL(TAG, tempSecondCred, ERROR);
*firstCred = tempFirstCred;
......@@ -230,7 +230,7 @@ OCStackResult PMGenerateCertificateCredentials(const OicUuid_t *ptDeviceId,
}
*cred = GenerateCredential(deviceId, SIGNED_ASYMMETRIC_KEY, &certificateChain,
&privKey, 1, ptDeviceId);
&privKey, ptDeviceId);
return OC_STACK_OK;
}
#endif // __WITH_X509__
......@@ -420,11 +420,9 @@ static OCStackResult SaveOwnerPSK(OCProvisionDev_t *selectedDeviceInfo)
OIC_LOG(INFO, TAG,"ownerPSK dump:\n");
OIC_LOG_BUFFER(INFO, TAG,ownerPSK, OWNER_PSK_LENGTH_128);
//Generating new credential for provisioning tool
size_t ownLen = 1;
OicSecCred_t *cred = GenerateCredential(&selectedDeviceInfo->doxm->deviceID,
SYMMETRIC_PAIR_WISE_KEY, NULL,
&ownerKey, ownLen, &ptDeviceID);
&ownerKey, &ptDeviceID);
VERIFY_NON_NULL(TAG, cred, ERROR);
res = AddCredential(cred);
......
......@@ -639,7 +639,7 @@ OCStackResult SRPProvisionCredentials(void *ctx, OicSecCredType_t type, size_t k
OIC_LOG(INFO, TAG, "SRPUnlinkDevices : NULL Callback");
return OC_STACK_INVALID_CALLBACK;
}
if (SYMMETRIC_PAIR_WISE_KEY == type &&
if (SYMMETRIC_PAIR_WISE_KEY == type &&
0 == memcmp(&pDev1->doxm->deviceID, &pDev2->doxm->deviceID, sizeof(OicUuid_t)))
{
OIC_LOG(INFO, TAG, "SRPUnlinkDevices : Same device ID");
......@@ -989,7 +989,7 @@ OCStackResult SRPProvisionDirectPairing(void *ctx, const OCProvisionDev_t *selec
OIC_LOG(ERROR, TAG, "Error while retrieving provisioning tool's device ID");
return OC_STACK_ERROR;
}
memcpy(&pconf->rowner, &provTooldeviceID, sizeof(OicUuid_t));
memcpy(&pconf->rownerID, &provTooldeviceID, sizeof(OicUuid_t));
OCSecurityPayload* secPayload = (OCSecurityPayload*)OICCalloc(1, sizeof(OCSecurityPayload));
if(!secPayload)
......
......@@ -97,9 +97,6 @@ static void FreeACE(OicSecAcl_t *ace)
OICFree(ace->recurrences);
}
// Clean Owners
OICFree(ace->owners);
// Clean ACL node itself
OICFree(ace);
}
......@@ -210,7 +207,6 @@ OCStackResult AclToCBORPayload(const OicSecAcl_t *secAcl, uint8_t **payload, siz
WILDCARD_SUBJECT_ID_LEN : sizeof(OicUuid_t);
if(inLen == WILDCARD_SUBJECT_ID_LEN)
{
char *subject = NULL;
cborEncoderResult = cbor_encode_text_string(&oicSecAclMap, WILDCARD_RESOURCE_URI,
strlen(WILDCARD_RESOURCE_URI));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding Subject Id wildcard Value.");
......@@ -340,31 +336,21 @@ OCStackResult AclToCBORPayload(const OicSecAcl_t *secAcl, uint8_t **payload, siz
acl = acl->next;
}
// Close ACES Array
cborEncoderResult = cbor_encoder_close_container(&aclListMap, &acesArray);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing ACES Array.");
// Close ACLIST Map
cborEncoderResult = cbor_encoder_close_container(&aclMap, &aclListMap);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing ACLIST Map.");
// TODO : Need to modify acl->owners[0] to acl->rownerid based on RAML spec.
acl = (OicSecAcl_t *)secAcl;
// Rownerid
if(acl->owners && acl->ownersLen > 0)
{
char *rowner = NULL;
cborEncoderResult = cbor_encode_text_string(&aclMap, OIC_JSON_ROWNERID_NAME,
strlen(OIC_JSON_ROWNERID_NAME));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding rownerid Name.");
char *rowner = NULL;
ret = ConvertUuidToStr(&acl->owners[0], &rowner);
ret = ConvertUuidToStr(&secAcl->rownerID, &rowner);
VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
cborEncoderResult = cbor_encode_text_string(&aclMap, rowner, strlen(rowner));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding rownerid Value.");
......@@ -696,10 +682,7 @@ OicSecAcl_t* CBORPayloadToAcl(const uint8_t *cborPayload, const size_t size)
char *stRowner = NULL;
cborFindResult = cbor_value_dup_text_string(&aclMap, &stRowner, &len, NULL);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding Rownerid Value.");
headAcl->ownersLen = 1;
headAcl->owners = (OicUuid_t *)OICCalloc(headAcl->ownersLen, sizeof(*headAcl->owners));
VERIFY_NON_NULL(TAG, headAcl->owners, ERROR);
ret = ConvertStrToUuid(stRowner, &headAcl->owners[0]);
ret = ConvertStrToUuid(stRowner, &headAcl->rownerID);
VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
OICFree(stRowner);
}
......@@ -1179,10 +1162,8 @@ OCStackResult GetDefaultACL(OicSecAcl_t** defaultAcl)
OCRandomUuidResult rdm = OCGenerateUuid(ownerId.id);
VERIFY_SUCCESS(TAG, RAND_UUID_OK == rdm, FATAL);
}
acl->ownersLen = 1;
acl->owners = (OicUuid_t*) OICMalloc(sizeof(OicUuid_t));
VERIFY_NON_NULL(TAG, (acl->owners), ERROR);
memcpy(acl->owners, &ownerId, sizeof(OicUuid_t));
memcpy(&acl->rownerID, &ownerId, sizeof(OicUuid_t));
acl->next = NULL;
......@@ -1385,10 +1366,7 @@ static OicSecAcl_t* GetSecDefaultACL()
VERIFY_SUCCESS(TAG, OC_STACK_OK == res, FATAL);
// Owners -- Mandatory
newDefaultAcl->ownersLen = 1;
newDefaultAcl->owners = (OicUuid_t*)OICMalloc(sizeof(OicUuid_t));
VERIFY_NON_NULL(TAG, (newDefaultAcl->owners), ERROR);
memcpy(newDefaultAcl->owners, &ownerId, sizeof(OicUuid_t));
memcpy(&newDefaultAcl->rownerID, &ownerId, sizeof(OicUuid_t));
return newDefaultAcl;
exit:
......@@ -1470,3 +1448,41 @@ OCStackResult UpdateDefaultSecProvACL()
return ret;
}
OCStackResult SetAclRownerId(const OicUuid_t* newROwner)
{
OCStackResult ret = OC_STACK_ERROR;
uint8_t *cborPayload = NULL;
size_t size = 0;
OicUuid_t prevId = {.id={0}};
if(NULL == newROwner)
{
ret = OC_STACK_INVALID_PARAM;
}
if(NULL == gAcl)
{
ret = OC_STACK_NO_RESOURCE;
}
if(newROwner && gAcl)
{
memcpy(prevId.id, gAcl->rownerID.id, sizeof(prevId.id));
memcpy(gAcl->rownerID.id, newROwner->id, sizeof(newROwner->id));
ret = AclToCBORPayload(gAcl, &cborPayload, &size);
VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
ret = UpdateSecureResourceInPS(OIC_JSON_ACL_NAME, cborPayload, size);
VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
OICFree(cborPayload);
}
return ret;
exit:
OICFree(cborPayload);
memcpy(gAcl->rownerID.id, prevId.id, sizeof(prevId.id));
return ret;
}
......@@ -66,9 +66,6 @@ void DeleteAmaclList(OicSecAmacl_t* amacl)
// Clean Amss
OICFree(amaclTmp1->amss);
// Clean Owners
OICFree(amaclTmp1->owners);
// Clean Amacl node itself
OICFree(amaclTmp1);
}
......@@ -199,13 +196,12 @@ OCStackResult AmaclToCBORPayload(const OicSecAmacl_t *amaclS, uint8_t **cborPayl
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing AMSS Array.");
// TODO : Need to check owner property in the RAML spec.
// rowner
// rowner -- Mandatory
cborEncoderResult = cbor_encode_text_string(&amaclMap, OIC_JSON_ROWNERID_NAME,
strlen(OIC_JSON_ROWNERID_NAME));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding ROwnerID Name Tag.");
// TODO : Need to modify amacl->owners[0] to amacl->rownerid based on RAML spec.
ret = ConvertUuidToStr(&amacl->owners[0], &stRowner);
ret = ConvertUuidToStr(&amacl->rownerID, &stRowner);
VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
cborEncoderResult = cbor_encode_text_string(&amaclMap, stRowner, strlen(stRowner));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding ROwner Value.");
......@@ -419,17 +415,14 @@ OCStackResult CBORPayloadToAmacl(const uint8_t *cborPayload, size_t size,
}
}
// TODO : Need to modify headAmacl->owners[0].id to headAmacl->rowner based on RAML spec.
// Rowner -- Mandatory
if (0 == strcmp(OIC_JSON_ROWNERID_NAME, name))
{
char *stRowner = NULL;
cborFindResult = cbor_value_dup_text_string(&amaclMap, &stRowner, &len, NULL);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding ROwner Value.");
headAmacl->ownersLen = 1;
headAmacl->owners = (OicUuid_t *)OICCalloc(headAmacl->ownersLen, sizeof(*headAmacl->owners));
VERIFY_NON_NULL(TAG, headAmacl->owners, ERROR);
ret = ConvertStrToUuid(stRowner, &headAmacl->owners[0]);
ret = ConvertStrToUuid(stRowner, &headAmacl->rownerID);
VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
OICFree(stRowner);
}
......@@ -636,3 +629,43 @@ OCStackResult AmaclGetAmsDeviceId(const char *resource, OicUuid_t *amsDeviceId)
exit:
return OC_STACK_ERROR;
}
OCStackResult SetAmaclRownerId(const OicUuid_t* newROwner)
{
OCStackResult ret = OC_STACK_ERROR;
uint8_t *cborPayload = NULL;
size_t size = 0;
OicUuid_t prevId = {.id={0}};
if(NULL == newROwner)
{
ret = OC_STACK_INVALID_PARAM;
}
if(NULL == gAmacl)
{
ret = OC_STACK_NO_RESOURCE;
}
if(newROwner && gAmacl)
{
memcpy(prevId.id, gAmacl->rownerID.id, sizeof(prevId.id));
memcpy(gAmacl->rownerID.id, newROwner->id, sizeof(newROwner->id));
ret = AmaclToCBORPayload(gAmacl, &cborPayload, &size);
VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
ret = UpdateSecureResourceInPS(OIC_JSON_AMACL_NAME, cborPayload, size);
VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
OICFree(cborPayload);
}
return ret;
exit:
OICFree(cborPayload);
memcpy(gAmacl->rownerID.id, prevId.id, sizeof(prevId.id));
return ret;
}
......@@ -96,9 +96,6 @@ static void FreeCred(OicSecCred_t *cred)
//Clean Period
OICFree(cred->period);
//Clean Owners
OICFree(cred->owners);
//Clean Cred node itself
OICFree(cred);
}
......@@ -293,22 +290,21 @@ OCStackResult CredToCBORPayload(const OicSecCred_t *credS, uint8_t **cborPayload
cborEncoderResult = cbor_encoder_close_container(&credArray, &credMap);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing Cred Map.");
cred = cred->next;
}
cborEncoderResult = cbor_encoder_close_container(&credRootMap, &credArray);
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Closing Cred Array.");
cred = credS;
// TODO : Need to modify cred->owners[0] to cred->rownerid based on RAML spec.
// Rownerid
if(cred->owners && cred->ownersLen > 0)
{
char *rowner = NULL;
cborEncoderResult = cbor_encode_text_string(&credRootMap, OIC_JSON_ROWNERID_NAME,
strlen(OIC_JSON_ROWNERID_NAME));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding rownerid Name.");
ret = ConvertUuidToStr(&cred->owners[0], &rowner);
ret = ConvertUuidToStr(&cred->rownerID, &rowner);
VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
cborEncoderResult = cbor_encode_text_string(&credRootMap, rowner, strlen(rowner));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Addding rownerid Value.");
......@@ -566,16 +562,14 @@ OCStackResult CBORPayloadToCred(const uint8_t *cborPayload, size_t size,
}
}
// TODO : Need to modify headCred->owners[0].id to headCred->rowner based on RAML spec.
//ROwner -- Mandatory
if (strcmp(tagName, OIC_JSON_ROWNERID_NAME) == 0)
{
char *stRowner = NULL;
cborFindResult = cbor_value_dup_text_string(&CredRootMap, &stRowner, &len, NULL);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding Rownerid Value.");
headCred->ownersLen = 1;
headCred->owners = (OicUuid_t *)OICCalloc(headCred->ownersLen, sizeof(*headCred->owners));
VERIFY_NON_NULL(TAG, headCred->owners, ERROR);
ret = ConvertStrToUuid(stRowner, &headCred->owners[0]);
ret = ConvertStrToUuid(stRowner, &headCred->rownerID);
VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
OICFree(stRowner);
}
......@@ -605,7 +599,7 @@ exit:
OicSecCred_t * GenerateCredential(const OicUuid_t * subject, OicSecCredType_t credType,
const OicSecCert_t * publicData, const OicSecKey_t* privateData,
size_t ownersLen, const OicUuid_t * owners)
const OicUuid_t * rownerID)
{
(void)publicData;
OCStackResult ret = OC_STACK_ERROR;
......@@ -642,15 +636,8 @@ OicSecCred_t * GenerateCredential(const OicUuid_t * subject, OicSecCredType_t cr
cred->privateData.len = privateData->len;