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: leechul <chuls.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/6325
Reviewed-by: Yonggoo Kang <ygace.kang@samsung.com>
Reviewed-by: Dmitriy Zhuravlev <d.zhuravlev@samsung.com>
Tested-by: Dmitriy Zhuravlev <d.zhuravlev@samsung.com>
*/
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
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
* @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.
* @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__ */
*/
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
#endif // __WITH_DTLS__\r
\r
\r
+/**\r
+ * Internal function to update resource owner\r
+ *\r
+ * @param newROwner new owner\r
+ *\r
+ * @retval ::OC_STACK_OK for Success, otherwise some error value\r
+ */\r
+OCStackResult SetDpairingRownerId(const OicUuid_t* newROwner);\r
+\r
#ifdef __cplusplus\r
}\r
#endif\r
*/\r
void FreePdAclList(OicSecPdAcl_t* pdacls);\r
\r
+/**\r
+ * Internal function to update resource owner\r
+ *\r
+ * @param newROwner new owner\r
+ *\r
+ * @retval ::OC_STACK_OK for Success, otherwise some error value\r
+ */\r
+OCStackResult SetPconfRownerId(const OicUuid_t* newROwner);\r
\r
#ifdef __cplusplus\r
}\r
*/
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
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
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
#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
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
};
/**
// <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
}
OICFree((acl)->resources);
- /* Clean Owners */
- OICFree((acl)->owners);
-
/* Clean ACL node itself */
OICFree((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;
}
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)
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;
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;
}
*cred = GenerateCredential(deviceId, SIGNED_ASYMMETRIC_KEY, &certificateChain,
- &privKey, 1, ptDeviceId);
+ &privKey, ptDeviceId);
return OC_STACK_OK;
}
#endif // __WITH_X509__
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);
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");
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)
OICFree(ace->recurrences);
}
- // Clean Owners
- OICFree(ace->owners);
-
// Clean ACL node itself
OICFree(ace);
}
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.");
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.");
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);
}
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;
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:
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;
+}
// Clean Amss
OICFree(amaclTmp1->amss);
- // Clean Owners
- OICFree(amaclTmp1->owners);
-
// Clean Amacl node itself
OICFree(amaclTmp1);
}
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.");
}
}
- // 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);
}
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;
+}
+
//Clean Period
OICFree(cred->period);
- //Clean Owners
- OICFree(cred->owners);
-
//Clean Cred node itself
OICFree(cred);
}
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.");
}
}
- // 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);
}
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;
cred->privateData.len = privateData->len;
}
- VERIFY_SUCCESS(TAG, ownersLen > 0, ERROR);
- cred->ownersLen = ownersLen;
-
- cred->owners = (OicUuid_t *)OICCalloc(cred->ownersLen, sizeof(*cred->owners));
- VERIFY_NON_NULL(TAG, cred->owners, ERROR);
- for (size_t i = 0; i < cred->ownersLen; i++)
- {
- memcpy(cred->owners[i].id, owners[i].id, sizeof(cred->owners[i].id));
- }
+ VERIFY_NON_NULL(TAG, rownerID, ERROR);
+ memcpy(&cred->rownerID, rownerID, sizeof(OicUuid_t));
ret = OC_STACK_OK;
exit:
* @param[in] credType Type of credential to be added
* @param[in] pin numeric characters
* @param[in] pinSize length of 'pin'
- * @param[in] ownersLen Number of owners
- * @param[in] owners Array of owners
+ * @param[in] rownerID Resource owner's UUID
* @param[out] tmpCredSubject Generated credential's subject.
*
* @return OC_STACK_OK for success and errorcode otherwise.
*/
OCStackResult AddTmpPskWithPIN(const OicUuid_t* tmpSubject, OicSecCredType_t credType,
const char * pin, size_t pinSize,
- size_t ownersLen, const OicUuid_t * owners, OicUuid_t* tmpCredSubject)
+ const OicUuid_t * rownerID, OicUuid_t* tmpCredSubject)
{
OCStackResult ret = OC_STACK_ERROR;
OIC_LOG(DEBUG, TAG, "AddTmpPskWithPIN IN");
uint8_t privData[OWNER_PSK_LENGTH_128] = {0,};
OicSecKey_t privKey = {privData, OWNER_PSK_LENGTH_128};
OicSecCred_t* cred = NULL;
- int dtlsRes = DeriveCryptoKeyFromPassword((const unsigned char *)pin, pinSize, owners->id,
+ int dtlsRes = DeriveCryptoKeyFromPassword((const unsigned char *)pin, pinSize, rownerID->id,
UUID_LENGTH, PBKDF_ITERATIONS,
OWNER_PSK_LENGTH_128, privData);
VERIFY_SUCCESS(TAG, (0 == dtlsRes) , ERROR);
cred = GenerateCredential(tmpSubject, credType, NULL,
- &privKey, ownersLen, owners);
+ &privKey, rownerID);
if(NULL == cred)
{
OIC_LOG(ERROR, TAG, "GeneratePskWithPIN() : Failed to generate credential");
}
#undef CERT_LEN_PREFIX
#endif /* __WITH_X509__ */
+
+OCStackResult SetCredRownerId(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 == gCred)
+ {
+ ret = OC_STACK_NO_RESOURCE;
+ }
+
+ if(newROwner && gCred)
+ {
+ memcpy(prevId.id, gCred->rownerID.id, sizeof(prevId.id));
+ memcpy(gCred->rownerID.id, newROwner->id, sizeof(newROwner->id));
+
+ ret = CredToCBORPayload(gCred, &cborPayload, &size);
+ VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
+
+ ret = UpdateSecureResourceInPS(OIC_JSON_CRED_NAME, cborPayload, size);
+ VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
+
+ OICFree(cborPayload);
+ }
+
+ return ret;
+
+exit:
+ OICFree(cborPayload);
+ memcpy(gCred->rownerID.id, prevId.id, sizeof(prevId.id));
+ return ret;
+}
+
cborFindResult = cbor_value_get_int(&crlMap, (int *) &crl->CrlId);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding CrlId.");
}
-
+
cborFindResult = cbor_value_map_find_value(&crlCbor, OIC_CBOR_CRL_THIS_UPDATE, &crlMap);
if (CborNoError == cborFindResult && cbor_value_is_byte_string(&crlMap))
{
cborFindResult = cbor_value_map_find_value(&crlCbor, OIC_CBOR_CRL_DATA, &crlMap);
if (CborNoError == cborFindResult && cbor_value_is_byte_string(&crlMap))
{
- cborFindResult = cbor_value_dup_byte_string(&crlMap,
+ cborFindResult = cbor_value_dup_byte_string(&crlMap,
&crl->CrlData.data, &crl->CrlData.len, NULL);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Advancing Byte Array.");
}
memcpy(crl->CrlData.data, gCrl->CrlData.data, outLen);
crl->CrlData.len = outLen;
}
- else
+ else
{
crl->CrlData.len = 0;
OIC_LOG (ERROR, TAG, "Set default failed");
pconf->prm = NULL; // to prevent free\r
ptr->prmLen = pconf->prmLen;\r
memcpy(&ptr->deviceID, &pconf->deviceID, sizeof(OicUuid_t));\r
- memcpy(&ptr->rowner, &pconf->rowner, sizeof(OicUuid_t));\r
+ memcpy(&ptr->rowner, &pconf->rownerID, sizeof(OicUuid_t));\r
ptr->next = NULL;\r
\r
LL_PREPEND(*ppList, ptr);\r
res = AddTmpPskWithPIN(&dpairData->peer->deviceID,\r
SYMMETRIC_PAIR_WISE_KEY,\r
(char*)dpairData->pin, DP_PIN_LENGTH,\r
- 1, &dpairData->peer->rowner, &subjectId);\r
+ &dpairData->peer->rowner, &subjectId);\r
VERIFY_SUCCESS(TAG, OC_STACK_OK == res, ERROR);\r
\r
\r
#include "doxmresource.h"
#include "pstatresource.h"
#include "aclresource.h"
+#include "amaclresource.h"
+#include "pconfresource.h"
+#include "dpairingresource.h"
#include "psinterface.h"
#include "srmresourcestrings.h"
#include "securevirtualresourcetypes.h"
strUuid = NULL;
}
-
*secDoxm = doxm;
ret = OC_STACK_OK;
//Save the owner's UUID to derive owner credential
memcpy(&(gDoxm->owner), &(newDoxm->owner), sizeof(OicUuid_t));
- // OCServerRequest *request = (OCServerRequest *)ehRequest->requestHandle;
- // Generating OwnerPSK
- // OIC_LOG (INFO, TAG, "Doxm EntityHandle generating OwnerPSK");
- // Generate new credential for provisioning tool
- // ehRet = AddOwnerPSK((CAEndpoint_t *)&request->devAddr, newDoxm,
- // (uint8_t*) OXM_JUST_WORKS, strlen(OXM_JUST_WORKS));
- // VERIFY_SUCCESS(TAG, OC_EH_OK == ehRet, ERROR);
-
// Update new state in persistent storage
if (true == UpdatePersistentStorage(gDoxm))
{
if ((false == gDoxm->owned) && (true == newDoxm->owned) &&
(memcmp(&(gDoxm->owner), &(newDoxm->owner), sizeof(OicUuid_t)) == 0))
{
+ //Change the SVR's resource owner as owner device.
+ OCStackResult ownerRes = SetAclRownerId(&gDoxm->owner);
+ if(OC_STACK_OK != ownerRes && OC_STACK_NO_RESOURCE != ownerRes)
+ {
+ ehRet = OC_EH_ERROR;
+ goto exit;
+ }
+ ownerRes = SetAmaclRownerId(&gDoxm->owner);
+ if(OC_STACK_OK != ownerRes && OC_STACK_NO_RESOURCE != ownerRes)
+ {
+ ehRet = OC_EH_ERROR;
+ goto exit;
+ }
+ ownerRes = SetCredRownerId(&gDoxm->owner);
+ if(OC_STACK_OK != ownerRes && OC_STACK_NO_RESOURCE != ownerRes)
+ {
+ ehRet = OC_EH_ERROR;
+ goto exit;
+ }
+ ownerRes = SetPstatRownerId(&gDoxm->owner);
+ if(OC_STACK_OK != ownerRes && OC_STACK_NO_RESOURCE != ownerRes)
+ {
+ ehRet = OC_EH_ERROR;
+ goto exit;
+ }
+ ownerRes = SetDpairingRownerId(&gDoxm->owner);
+ if(OC_STACK_OK != ownerRes && OC_STACK_NO_RESOURCE != ownerRes)
+ {
+ ehRet = OC_EH_ERROR;
+ goto exit;
+ }
+ ownerRes = SetPconfRownerId(&gDoxm->owner);
+ if(OC_STACK_OK != ownerRes && OC_STACK_NO_RESOURCE != ownerRes)
+ {
+ ehRet = OC_EH_ERROR;
+ goto exit;
+ }
+
gDoxm->owned = true;
+ memcpy(&gDoxm->rownerID, &gDoxm->owner, sizeof(OicUuid_t));
+
// Update new state in persistent storage
if (UpdatePersistentStorage(gDoxm))
{
OIC_LOG (DEBUG, TAG, "SetDpairingResourceOwner");
if (gDpair)
{
- memcpy(&gDpair->rowner, rowner, sizeof(OicUuid_t));
+ memcpy(&gDpair->rownerID, rowner, sizeof(OicUuid_t));
}
}
OIC_LOG(INFO, TAG, "pairingPSK dump:\n");
OIC_LOG_BUFFER(INFO, TAG, pairingPSK, OWNER_PSK_LENGTH_128);
//Generating new credential for direct-pairing client
- size_t ownLen = 1;
OicSecCred_t *cred = GenerateCredential(peerDevID,
SYMMETRIC_PAIR_WISE_KEY, NULL,
- &pairingKey, ownLen, owner);
+ &pairingKey, owner);
VERIFY_NON_NULL(TAG, cred, ERROR);
res = AddCredential(cred);
}
//ROWNER -- Mandatory
- cborEncoderResult = cbor_encode_text_string(&dpairMap, OIC_JSON_ROWNERID_NAME,
- strlen(OIC_JSON_ROWNERID_NAME));
- VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding ROWNER tag");
{
char *rowner = NULL;
- ret = ConvertUuidToStr(&dpair->rowner, &rowner);
+ cborEncoderResult = cbor_encode_text_string(&dpairMap, OIC_JSON_ROWNERID_NAME,
+ strlen(OIC_JSON_ROWNERID_NAME));
+ VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding ROWNER tag");
+ ret = ConvertUuidToStr(&dpair->rownerID, &rowner);
VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
cborEncoderResult = cbor_encode_text_string(&dpairMap, rowner, strlen(rowner));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed Adding Rowner ID value");
char *id = NULL;
cborFindResult = cbor_value_dup_text_string(&dpairMap, &id, &len, NULL);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding RownerID value");
- ret = ConvertStrToUuid(id, &dpair->rowner);
+ ret = ConvertStrToUuid(id, &dpair->rownerID);
VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
OICFree(id);
}
}
gDpair->spm = newDpair->spm;
memcpy(&gDpair->pdeviceID, &newDpair->pdeviceID, sizeof(OicUuid_t));
- memcpy(&gDpair->rowner, &pconf->rowner, sizeof(OicUuid_t));
+ memcpy(&gDpair->rownerID, &pconf->rownerID, sizeof(OicUuid_t));
#ifdef __WITH_DTLS__
// Add temporary psk
res = AddTmpPskWithPIN(&gDpair->pdeviceID,
SYMMETRIC_PAIR_WISE_KEY,
(char*)pconf->pin.val, DP_PIN_LENGTH,
- 1, &gDpair->rowner, &subjectId);
+ &gDpair->rownerID, &subjectId);
if(res != OC_STACK_OK ||
memcmp(&gDpair->pdeviceID, &subjectId, sizeof(OicUuid_t)))
{
OIC_LOG_V(INFO, TAG, "SavePairingPSK for %s(%d)", request->devAddr.addr,
request->devAddr.port);
OCStackResult res = SavePairingPSK(&request->devAddr, &newDpair->pdeviceID,
- (OicUuid_t *)&pconf->rowner, true);
+ (OicUuid_t *)&pconf->rownerID, true);
VERIFY_SUCCESS(TAG, OC_STACK_OK == res, ERROR);
#endif //__WITH_DTLS__
memcpy(&acl.subject, &gDpair->pdeviceID, sizeof(OicUuid_t));
acl.resources = pdAcl->resources;
acl.resourcesLen = pdAcl->resourcesLen;
- acl.owners = (OicUuid_t*)&pconf->rowner;
- acl.ownersLen = 1;
+ memcpy(&acl.rownerID, &pconf->rownerID, sizeof(OicUuid_t));
acl.permission = pdAcl->permission;
acl.periods = pdAcl->periods;
acl.recurrences = pdAcl->recurrences;
return OC_STACK_ERROR;
}
}
+
+OCStackResult SetDpairingRownerId(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 == gDpair)
+ {
+ ret = OC_STACK_NO_RESOURCE;
+ }
+
+ if(newROwner && gDpair)
+ {
+ memcpy(prevId.id, gDpair->rownerID.id, sizeof(prevId.id));
+ memcpy(gDpair->rownerID.id, newROwner->id, sizeof(newROwner->id));
+
+ ret = DpairingToCBORPayload(gDpair, &cborPayload, &size);
+ VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
+
+ ret = UpdateSecureResourceInPS(OIC_JSON_DPAIRING_NAME, cborPayload, size);
+ VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
+
+ OICFree(cborPayload);
+ }
+
+ return ret;
+
+exit:
+ OICFree(cborPayload);
+ memcpy(gDpair->rownerID.id, prevId.id, sizeof(prevId.id));
+ return ret;
+}
}
//ROwner -- Mandatory
- cborEncoderResult = cbor_encode_text_string(&pconfMap, OIC_JSON_ROWNERID_NAME,
- strlen(OIC_JSON_ROWNERID_NAME));
- VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to encode rowner string");
{
char *rowner = NULL;
- ret = ConvertUuidToStr(&pconf->rowner, &rowner);
+ cborEncoderResult = cbor_encode_text_string(&pconfMap, OIC_JSON_ROWNERID_NAME,
+ strlen(OIC_JSON_ROWNERID_NAME));
+ VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to encode rowner string");
+ ret = ConvertUuidToStr(&pconf->rownerID, &rowner);
VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
cborEncoderResult = cbor_encode_text_string(&pconfMap, rowner, strlen(rowner));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to encode rwoner value");
char *rowner = NULL;
cborFindResult = cbor_value_dup_text_string(&pconfMap, &rowner, &len, NULL);
VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed to get rowner");
- ret = ConvertStrToUuid(rowner, &pconf->rowner);
+ ret = ConvertStrToUuid(rowner, &pconf->rownerID);
VERIFY_SUCCESS(TAG, ret == OC_STACK_OK, ERROR);
OICFree(rowner);
}
if (true == GetDoxmResourceData()->dpc)
{
//Making response elements for Get request
- if( (true == gPconf->edp) && (gPconf->prm && 0 < gPconf->prmLen) &&
- (0 < strlen((const char*)gPconf->deviceID.id)) && (0 < strlen((const char*)gPconf->rowner.id)))
+ if( (true == gPconf->edp) &&
+ (gPconf->prm && 0 < gPconf->prmLen) &&
+ (0 < strlen((const char*)gPconf->deviceID.id)) &&
+ (0 < strlen((const char*)gPconf->rownerID.id)))
{
pconf.edp = true;
pconf.prm = gPconf->prm;
pconf.prmLen = gPconf->prmLen;
memcpy(&pconf.deviceID, &gPconf->deviceID, sizeof(OicUuid_t));
- memcpy(&pconf.rowner, &gPconf->rowner, sizeof(OicUuid_t));
+ memcpy(&pconf.rownerID, &gPconf->rownerID, sizeof(OicUuid_t));
OIC_LOG (DEBUG, TAG, "PCONF - direct pairing enabled");
}
else if (false == gPconf->edp)
{
pconf.edp = false;
- memcpy(&pconf.rowner, &gPconf->rowner, sizeof(OicUuid_t));
+ memcpy(&pconf.rownerID, &gPconf->rownerID, sizeof(OicUuid_t));
OIC_LOG (DEBUG, TAG, "PCONF - direct pairing disable");
}
else
gPconf->prm = newPconf->prm;
gPconf->prmLen = newPconf->prmLen;
gPconf->pdacls = newPconf->pdacls;
- memcpy(&gPconf->rowner, &newPconf->rowner, sizeof(OicUuid_t));
+ memcpy(&gPconf->rownerID, &newPconf->rownerID, sizeof(OicUuid_t));
// to delete old value(prm, pdacl)
newPconf->prm = oldPrm;
}
return false;
}
+
+OCStackResult SetPconfRownerId(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 == gPconf)
+ {
+ ret = OC_STACK_NO_RESOURCE;
+ }
+
+ if(newROwner && gPconf)
+ {
+ memcpy(prevId.id, gPconf->rownerID.id, sizeof(prevId.id));
+ memcpy(gPconf->rownerID.id, newROwner->id, sizeof(newROwner->id));
+
+ ret = PconfToCBORPayload(gPconf, &cborPayload, &size);
+ VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
+
+ ret = UpdateSecureResourceInPS(OIC_JSON_PCONF_NAME, cborPayload, size);
+ VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
+
+ OICFree(cborPayload);
+ }
+
+ return ret;
+
+exit:
+ OICFree(cborPayload);
+ memcpy(gPconf->rownerID.id, prevId.id, sizeof(prevId.id));
+ return ret;
+}
+
}
}
}
+
+OCStackResult SetPstatRownerId(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 == gPstat)
+ {
+ ret = OC_STACK_NO_RESOURCE;
+ }
+
+ if(newROwner && gPstat)
+ {
+ memcpy(prevId.id, gPstat->rownerID.id, sizeof(prevId.id));
+ memcpy(gPstat->rownerID.id, newROwner->id, sizeof(newROwner->id));
+
+ ret = PstatToCBORPayload(gPstat, &cborPayload, &size);
+ VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
+
+ ret = UpdateSecureResourceInPS(OIC_JSON_PSTAT_NAME, cborPayload, size);
+ VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
+
+ OICFree(cborPayload);
+ }
+
+ return ret;
+
+exit:
+ OICFree(cborPayload);
+ memcpy(gPstat->rownerID.id, prevId.id, sizeof(prevId.id));
+ return ret;
+}
+
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to Add SVC Serv Type Value.");
// Owners
+ // TODO: Need to modification to single ROwner, (Currently SINGLE_SERVICE_CLIENT_DRIVEN only)
cborEncoderResult = cbor_encode_text_string(&svcMap, OIC_JSON_OWNERS_NAME,
strlen(OIC_JSON_OWNERS_NAME));
VERIFY_CBOR_SUCCESS(TAG, cborEncoderResult, "Failed to Add SVC Owners Tag.");
jsonAclObj = cJSON_GetObjectItem(jsonAclMap, OIC_JSON_ROWNERID_NAME);
VERIFY_NON_NULL(TAG, jsonAclObj, ERROR);
VERIFY_SUCCESS(TAG, cJSON_String == jsonAclObj->type, ERROR);
- headAcl->ownersLen = 1;
- VERIFY_SUCCESS(TAG, headAcl->ownersLen > 0, ERROR);
- headAcl->owners = (OicUuid_t*)OICCalloc(headAcl->ownersLen, sizeof(OicUuid_t));
- VERIFY_NON_NULL(TAG, (headAcl->owners), ERROR);
- ret = ConvertStrToUuid(jsonAclObj->valuestring, &headAcl->owners[0]);
+ ret = ConvertStrToUuid(jsonAclObj->valuestring, &headAcl->rownerID);
VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
ret = OC_STACK_OK;
int numCred = cJSON_GetArraySize(jsonCredArray);
VERIFY_SUCCESS(TAG, numCred > 0, ERROR);
int idx = 0;
+ size_t ownersLen = 0;
do
{
cJSON *jsonCred = cJSON_GetArrayItem(jsonCredArray, idx);
VERIFY_NON_NULL(TAG, cred->period, ERROR);
strncpy(cred->period, jsonObj->valuestring, jsonObjLen);
}
-
cred->next = NULL;
-
} while( ++idx < numCred);
}
cJSON *jsonCredObj = cJSON_GetObjectItem(jsonCredMap, OIC_JSON_ROWNERID_NAME);
VERIFY_NON_NULL(TAG, jsonCredObj, ERROR);
VERIFY_SUCCESS(TAG, cJSON_String == jsonCredObj->type, ERROR);
- headCred->ownersLen = 1;
- VERIFY_SUCCESS(TAG, headCred->ownersLen > 0, ERROR);
- headCred->owners = (OicUuid_t*)OICCalloc(headCred->ownersLen, sizeof(OicUuid_t));
- VERIFY_NON_NULL(TAG, (headCred->owners), ERROR);
- ret = ConvertStrToUuid(jsonCredObj->valuestring, &headCred->owners[0]);
+ ret = ConvertStrToUuid(jsonCredObj->valuestring, &headCred->rownerID);
VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
ret = OC_STACK_OK;
VERIFY_NON_NULL(TAG, jsonObj, ERROR);
VERIFY_SUCCESS(TAG, cJSON_String == jsonObj->type, ERROR);
- headAmacl->ownersLen = 1;
- VERIFY_SUCCESS(TAG, headAmacl->ownersLen > 0, ERROR);
- headAmacl->owners = (OicUuid_t*)OICCalloc(headAmacl->ownersLen, sizeof(OicUuid_t));
- VERIFY_NON_NULL(TAG, (headAmacl->owners), ERROR);
-
- ret = ConvertStrToUuid(jsonObj->valuestring, &headAmacl->owners[0]);
+ ret = ConvertStrToUuid(jsonObj->valuestring, &headAmacl->rownerID);
VERIFY_SUCCESS(TAG, OC_STACK_OK == ret, ERROR);
ret = OC_STACK_OK;
defaultAcl->resources[i] = OICStrdup(defaulAclRsrc[i]);
ASSERT_TRUE(defaultAcl->resources[i] != NULL);
}
- defaultAcl->ownersLen = 1;
uint8_t defaultAclOwnrs[] = {0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32};
- defaultAcl->owners = (OicUuid_t *)OICCalloc(1, sizeof(OicUuid_t));
- ASSERT_TRUE(defaultAcl->owners != NULL);
- memcpy(defaultAcl->owners[0].id, defaultAclOwnrs, sizeof(defaultAclOwnrs));
+ memcpy(defaultAcl->rownerID.id, defaultAclOwnrs, sizeof(defaultAclOwnrs));
size_t defaultAclSize = 0;
uint8_t *defaultPsStorage = NULL;
ASSERT_TRUE(secAcl->resources[i] != NULL);
}
- secAcl->ownersLen = 1;
+
uint8_t ownrs[] = {0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
0x32, 0x32, 0x32, 0x32, 0x32, 0x32};
- secAcl->owners = (OicUuid_t *)OICCalloc(1, sizeof(OicUuid_t));
- ASSERT_TRUE(secAcl->owners != NULL);
- memcpy(secAcl->owners[0].id, ownrs, sizeof(ownrs));
+ memcpy(secAcl->rownerID.id, ownrs, sizeof(ownrs));
OicSecAcl_t *secAcl1 = (OicSecAcl_t *) OICCalloc(1, sizeof(OicSecAcl_t));
ASSERT_TRUE(secAcl1 != NULL);
secAcl1->resources[i] = OICStrdup(rsrc1[i]);
ASSERT_TRUE(secAcl1->resources[i] != NULL);
}
- secAcl1->ownersLen = 1;
- secAcl1->owners = (OicUuid_t *)OICCalloc(1, sizeof(OicUuid_t));
- ASSERT_TRUE(secAcl1->owners != NULL);
- memcpy(secAcl1->owners[0].id, ownrs, sizeof(ownrs));
+ memcpy(secAcl1->rownerID.id, ownrs, sizeof(ownrs));
secAcl->next = secAcl1;
OicSecAcl_t *secAcl2 = (OicSecAcl_t *) OICCalloc(1, sizeof(OicSecAcl_t));
secAcl2->resources[i] = OICStrdup(rsrc2[i]);
ASSERT_TRUE(secAcl2->resources[i] != NULL);
}
- secAcl2->ownersLen = 1;
- secAcl2->owners = (OicUuid_t *)OICCalloc(1, sizeof(OicUuid_t));
- ASSERT_TRUE(secAcl2->owners != NULL);
- memcpy(secAcl2->owners[0].id, ownrs, sizeof(ownrs));
+ memcpy(secAcl2->rownerID.id, ownrs, sizeof(ownrs));
secAcl1->next = secAcl2;
OicSecAcl_t *secAcl3 = (OicSecAcl_t *) OICCalloc(1, sizeof(OicSecAcl_t));
secAcl3->resources[i] = OICStrdup(rsrc3[i]);
ASSERT_TRUE(secAcl3->resources[i] != NULL);
}
- secAcl3->ownersLen = 2;
- secAcl3->owners = (OicUuid_t *)OICCalloc(2, sizeof(OicUuid_t));
- ASSERT_TRUE(secAcl3->owners != NULL);
- memcpy(secAcl3->owners[0].id, ownrs, sizeof(ownrs));
- uint8_t ownrs1[] = {0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34,
- 0x34, 0x34, 0x34, 0x34, 0x34, 0x34};
- memcpy(secAcl3->owners[1].id, ownrs1, sizeof(ownrs1));
+ memcpy(secAcl3->rownerID.id, ownrs, sizeof(ownrs));
secAcl2->next = secAcl3;
secAcl3->next = NULL;
EXPECT_EQ(2, acl->permission);
EXPECT_EQ(6 , acl->resourcesLen);
EXPECT_STREQ("/oic/res", acl->resources[0]);
- EXPECT_EQ(1, acl->ownersLen);
DeleteACLList(acl);
OICFree(psStorage);
DeleteACLList(secAcl);
OICStrcpy(acl->resources[1], sizeof(acl->resources[1]) - 1, "/a/fan");
}
acl->permission = 6;
- acl->ownersLen = 1;
- acl->owners = (OicUuid_t*)OICCalloc(acl->ownersLen, sizeof(OicUuid_t));
- VERIFY_NON_NULL(TAG, acl->owners, ERROR);
- memcpy(acl->owners->id, "1111111111111111", sizeof(acl->owners->id));
+ memcpy(acl->rownerID.id, "1111111111111111", sizeof(acl->rownerID.id));
ret = OC_STACK_OK;
exit:
secAmacl->resources[i] = OICStrdup(rsrc[i]);
ASSERT_TRUE(NULL != secAmacl->resources[i]);
}
- secAmacl->ownersLen = 1;
uint8_t ownrs[] = {0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
0x32, 0x32, 0x32, 0x32, 0x32, 0x32};
- secAmacl->owners = (OicUuid_t *)OICCalloc(1, sizeof(*secAmacl->owners));
- if (!secAmacl->owners)
- {
- DeleteAmaclList(secAmacl);
- }
- ASSERT_TRUE(NULL != secAmacl->owners);
- memcpy(secAmacl->owners[0].id, ownrs, sizeof(ownrs));
+ memcpy(secAmacl->rownerID.id, ownrs, sizeof(ownrs));
OicSecAmacl_t *secAmacl1 = (OicSecAmacl_t *) OICCalloc(1, sizeof(*secAmacl1));
if (!secAmacl1)
secAmacl1->resources[i] = OICStrdup(rsrc1[i]);
ASSERT_TRUE(NULL != secAmacl1->resources[i]);
}
- secAmacl1->ownersLen = 1;
- secAmacl1->owners = (OicUuid_t *)OICCalloc(1, sizeof(*secAmacl1->owners));
- if (!secAmacl1->owners)
- {
- DeleteAmaclList(secAmacl);
- DeleteAmaclList(secAmacl1);
- }
- ASSERT_TRUE(NULL != secAmacl1->owners);
- memcpy(secAmacl1->owners[0].id, ownrs, sizeof(ownrs));
+ memcpy(secAmacl1->rownerID.id, ownrs, sizeof(ownrs));
secAmacl1->next = NULL;
secAmacl->next = secAmacl1;
EXPECT_STREQ(secAmacl->resources[0], amacl->resources[0]);
EXPECT_STREQ(secAmacl->resources[1], amacl->resources[1]);
EXPECT_EQ(secAmacl->resourcesLen, amacl->resourcesLen);
- EXPECT_EQ(secAmacl->ownersLen, amacl->ownersLen);
- EXPECT_EQ(*secAmacl->owners[0].id, *amacl->owners[0].id);
+ EXPECT_EQ(memcmp(secAmacl->rownerID.id, amacl->rownerID.id, sizeof(amacl->rownerID.id)), 0);
DeleteAmaclList(secAmacl);
DeleteAmaclList(amacl);
cred->privateData.data = (uint8_t *)OICCalloc(1, strlen("My private Key11") + 1);
VERIFY_NON_NULL(TAG, cred->privateData.data, ERROR);
OICStrcpy((char *)cred->privateData.data, strlen("My private Key11")+1,"My private Key11");
- cred->ownersLen = 1;
- cred->owners = (OicUuid_t *)OICCalloc(cred->ownersLen, sizeof(*cred->owners));
- VERIFY_NON_NULL(TAG, cred->owners, ERROR);
- OICStrcpy((char *)cred->owners[0].id, sizeof(cred->owners[0].id), "aaaaaaaaaaaaaaaa");
+ OICStrcpy((char *)cred->rownerID.id, sizeof(cred->rownerID.id), "aaaaaaaaaaaaaaaa");
cred->next = (OicSecCred_t*)OICCalloc(1, sizeof(*cred->next));
VERIFY_NON_NULL(TAG, cred->next, ERROR);
cred->next->credId = 5678;
VERIFY_NON_NULL(TAG, cred->next->publicData.data, ERROR);
OICStrcpy(cred->next->publicData.data, sz,"My Public Key123");
#endif
- cred->next->ownersLen = 2;
- cred->next->owners = (OicUuid_t *)OICCalloc(cred->next->ownersLen, sizeof(*cred->next->owners));
- VERIFY_NON_NULL(TAG, cred->next->owners, ERROR);
- OICStrcpy((char *)cred->next->owners[0].id, sizeof(cred->next->owners[0].id), "bbbbbbbbbbbbbbbb");
- OICStrcpy((char *)cred->next->owners[1].id, sizeof(cred->next->owners[1].id), "cccccccccccccccc");
+ OICStrcpy((char *)cred->next->rownerID.id, sizeof(cred->next->rownerID.id), "bbbbbbbbbbbbbbbb");
return cred;
OIC_LOG_V(INFO, TAG, "cred->publicData.data = %s", credTmp1->publicData.data);
}
#endif /* __WITH_X509__ */
- OIC_LOG_V(INFO, TAG, "cred->ownersLen = %zu", credTmp1->ownersLen);
- for(size_t i = 0; i < cred->ownersLen; i++)
- {
- OIC_LOG_V(INFO, TAG, "cred->owners[%zu].id = %s", i, credTmp1->owners[i].id);
- }
+ OIC_LOG_V(INFO, TAG, "cred->rownerID = %s", credTmp1->rownerID.id);
}
}
TEST(CredResourceTest, GenerateCredentialValidInput)
{
- OicUuid_t owners[1];
- OICStrcpy((char *)owners[0].id, strlen("ownersId21"), "ownersId21");
+ OicUuid_t rownerID = {{0}};
+ OICStrcpy((char *)rownerID.id, strlen("ownersId21"), "ownersId21");
OicUuid_t subject = {{0}};
OICStrcpy((char *)subject.id, strlen("subject11"), "subject11");
OicSecKey_t key = {privateKey, sizeof(privateKey)};
OicSecCred_t * cred = NULL;
-
cred = GenerateCredential(&subject, SYMMETRIC_PAIR_WISE_KEY, NULL,
- &key, 1, owners);
+ &key, &rownerID);
printCred(cred);
ASSERT_TRUE(NULL != cred);
TEST(CredResourceTest, GenerateAndAddCredentialValidInput)
{
- OicUuid_t owners[1];
- OICStrcpy((char *)owners[0].id, sizeof(owners[0].id), "ownersId11");
+ OicUuid_t rownerID = {{0}};
+ OICStrcpy((char *)rownerID.id, sizeof(rownerID.id), "ownersId11");
OicUuid_t subject = {{0}};
OICStrcpy((char *)subject.id, sizeof(subject.id), "subject11");
OicSecCred_t *headCred = NULL;
cred1 = GenerateCredential(&subject, SYMMETRIC_PAIR_WISE_KEY, NULL,
- &key, 1, owners);
+ &key, &rownerID);
EXPECT_EQ(OC_STACK_OK, AddCredential(cred1));
headCred = cred1;
- OICStrcpy((char *)owners[0].id, sizeof(owners[0].id), "ownersId22");
+ OICStrcpy((char *)rownerID.id, sizeof(rownerID.id), "ownersId22");
OICStrcpy((char *)subject.id, sizeof(subject.id), "subject22");
cred1 = GenerateCredential(&subject, SYMMETRIC_PAIR_WISE_KEY, NULL,
- &key, 1, owners);
+ &key, &rownerID);
EXPECT_EQ(OC_STACK_OK, AddCredential(cred1));
- OICStrcpy((char *)owners[0].id, sizeof(owners[0].id), "ownersId33");
+ OICStrcpy((char *)rownerID.id, sizeof(rownerID.id), "ownersId33");
OICStrcpy((char *)subject.id, sizeof(subject.id), "subject33");
cred1 = GenerateCredential(&subject, SYMMETRIC_PAIR_WISE_KEY, NULL,
- &key, 1, owners);
+ &key, &rownerID);
EXPECT_EQ(OC_STACK_OK, AddCredential(cred1));
const OicSecCred_t* credList = GetCredResourceData(&headCred->subject);
}
OICFree((acl)->resources);
- /* Clean Owners */
- OICFree((acl)->owners);
-
/* Clean ACL node itself */
/* Required only if acl was created in heap */
OICFree((acl));
} while (0 != ret );
// Set Rowner
- printf("Num. of Rowner : ");
- ret = scanf("%zu", &acl->ownersLen);
- if ((1 != ret) || (acl->ownersLen <= 0 || acl->ownersLen > 20))
- {
- printf("Error while input\n");
- return -1;
- }
printf("-URN identifying the rowner\n");
printf("ex) 1111-1111-1111-1111 (16 Numbers except to '-')\n");
- acl->owners = (OicUuid_t *)OICCalloc(acl->ownersLen, sizeof(OicUuid_t));
- if (NULL == acl->owners)
+
+ printf("Rowner : ");
+ ret = scanf("%19ms", &temp_id);
+ if (1 != ret)
{
- OIC_LOG(ERROR, TAG, "Error while memory allocation");
+ printf("Error while input\n");
return -1;
}
- for (size_t i = 0; i < acl->ownersLen; i++)
- {
- printf("[%zu]Rowner : ", i + 1);
- ret = scanf("%19ms", &temp_id);
- if (1 != ret)
- {
- printf("Error while input\n");
- return -1;
- }
- for (int k = 0, j = 0; temp_id[k] != '\0'; k++)
+ for (int k = 0, j = 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];
}
- OICFree(temp_id);
}
+ OICFree(temp_id);
+
return 0;
}