# Set common flags
if env['CC'] == 'cl':
# Enable warnings as errors.
- env.AppendUnique(CCFLAGS=[
- '/we4133']) # C4133 incompatible type conversion
+ # - warning C4133: incompatible type conversion
+ env.AppendUnique(CCFLAGS=['/we4133'])
+
+ # Disable the following warnings:
+ # - warning C4127: conditional expression is constant
+ # - Disabled due to the widespread usage in IoTivity
+ env.AppendUnique(CCFLAGS=['/wd4127'])
env.AppendUnique(CCFLAGS=['/EHsc'])
{
char example[8];
snprintf(example, sizeof(example), "%d", DEFAULT_PORT);
- int tmp = 0;
- readInteger(&tmp, "port number", example);
+ uint16_t tmp = 0;
+ readUInt16(&tmp, "port number", example);
endPoint.port = tmp;
sendDataToServer = false;
}
skipSpecialCharacters();
}
+void readUInt16(uint16_t* item, const char* description, const char* example)
+{
+ printf("Enter %s (f.e. %s):\n", description, example);
+ scanf("%hu", item);
+ skipSpecialCharacters();
+}
+
/**
* Read user input (expect array of strings)
*
char aceid[MAX_ID_LENGTH] = { 0 };
char subjectuuid[MAX_ID_LENGTH] = { 0 };
- int stype = 0;
- int permission = 0;
+ uint16_t stype = 0;
+ uint16_t permission = 0;
do
{
readString(subjectuuid, sizeof(subjectuuid), "subjectuuid", SUBJECT_ID_EXAMPLE);
} while (OC_STACK_OK != ConvertStrToUuid(subjectuuid, &ace->subjectuuid));
- readInteger(&stype, "subject type", "0 – Device, 1 – User, 2 - Group");
- readInteger(&permission, "permission", "6");
+ readUInt16(&stype, "subject type", "0 – Device, 1 – User, 2 - Group");
+ readUInt16(&permission, "permission", "6");
ace->aceId = OICStrdup(aceid);
ace->stype = stype;
int reslist_count = 0;
readInteger(&reslist_count, "resources list count", "1");
- for (int i = 0; i < reslist_count; i++)
+ for (int j = 0; j < reslist_count; j++)
{
OicSecRsrc_t *res = OICCalloc(1, sizeof(OicSecRsrc_t));
if (!res)
char aceid[MAX_ID_LENGTH] = { 0 };
char subjectuuid[MAX_ID_LENGTH] = { 0 };
- int stype = 0;
- int permission = 0;
+ uint16_t stype = 0;
+ uint16_t permission = 0;
readString(aceid, sizeof(aceid), "ace id", ACE_ID_EXAMPLE);
do
readString(subjectuuid, sizeof(subjectuuid), "subjectuuid", SUBJECT_ID_EXAMPLE);
} while (OC_STACK_OK != ConvertStrToUuid(subjectuuid, &ace->subjectuuid));
- readInteger(&stype, "subject type", "0 – Device, 1 – User, 2 - Group");
- readInteger(&permission, "permission", "6");
+ readUInt16(&stype, "subject type", "0 – Device, 1 – User, 2 - Group");
+ readUInt16(&permission, "permission", "6");
ace->stype = stype;
ace->permission = permission;
void readInteger(int* item, const char* description, const char* example);
/**
+ * Read user input (expect uint16_t value)
+ *
+ * @param[out] item uint16_t item to fill
+ * @param[in] description item description
+ * @param[in] example item example
+ */
+void readUInt16(uint16_t* item, const char* description, const char* example);
+
+/**
* Copies whole binary file to out variable
*
* @param[in] list array of strings structure
static void inputPinCB(OicUuid_t deviceId, char *pin, size_t len, void *context)
{
+ OC_UNUSED(deviceId);
+ OC_UNUSED(context);
+
if(!pin || OXM_RANDOM_PIN_MIN_SIZE > len)
{
OIC_LOG(ERROR, TAG, "inputPinCB invalid parameters");
OCStackResult displayNumCB(void * ctx, uint8_t mutualVerifNum[MUTUAL_VERIF_NUM_LEN])
{
+ OC_UNUSED(ctx);
+
OIC_LOG(INFO, TAG, "IN displayMutualVerifNumCB");
if (NULL != mutualVerifNum)
{
OCStackResult confirmNumCB(void * ctx)
{
+ OC_UNUSED(ctx);
+
for (;;)
{
int userConfirm;
printf(" Entered Wrong Number. Please Enter Again\n");
}
- const int preconfOxm = 4;
int oxm = 0;
for( ; ; )
{
goto CRACL_ERROR;
}
- for(size_t i = 0; i < arrLen; i++)
+ for(size_t j = 0; j < arrLen; j++)
{
- printf(" Enter ResourceType[%zu] Name (e.g. core.led): ", i+1);
+ printf(" Enter ResourceType[%zu] Name (e.g. core.led): ", j+1);
for(int ret=0; 1!=ret; )
{
ret = scanf("%128s", rsrc_in); // '128' is ACL_RESRC_MAX_LEN
for( ; 0x20<=getchar(); ); // for removing overflow garbages
// '0x20<=code' is character region
}
- rsrc->types[i] = OICStrdup(rsrc_in);
- if(!rsrc->types[i])
+ rsrc->types[j] = OICStrdup(rsrc_in);
+ if(!rsrc->types[j])
{
OIC_LOG(ERROR, TAG, "createAcl: OICStrdup error return");
goto CRACL_ERROR;
goto CRACL_ERROR;
}
- for(size_t i = 0; i < arrLen; i++)
+ for(size_t j = 0; j < arrLen; j++)
{
- printf(" Enter Interface[%zu] Name (e.g. oic.if.baseline): ", i+1);
+ printf(" Enter Interface[%zu] Name (e.g. oic.if.baseline): ", j+1);
for(int ret=0; 1!=ret; )
{
ret = scanf("%128s", rsrc_in); // '128' is ACL_RESRC_MAX_LEN
for( ; 0x20<=getchar(); ); // for removing overflow garbages
// '0x20<=code' is character region
}
- rsrc->interfaces[i] = OICStrdup(rsrc_in);
- if(!rsrc->interfaces[i])
+ rsrc->interfaces[j] = OICStrdup(rsrc_in);
+ if(!rsrc->interfaces[j])
{
OIC_LOG(ERROR, TAG, "createAcl: OICStrdup error return");
goto CRACL_ERROR;
OCStackApplicationResult getReqCB(void* ctx, OCDoHandle handle,
OCClientResponse* clientResponse)
{
+ OC_UNUSED(ctx);
+ OC_UNUSED(handle);
+
if (clientResponse == NULL)
{
OIC_LOG(INFO, TAG, "getReqCB received NULL clientResponse");
static int selectTwoDiffNum(int* a, int* b, const int max, const char* str)
{
- if(!a || !b || 2>max || !str)
+ if(!a || !b || (2 > max) || !str)
{
return -1;
}
for( ; ; )
{
- for(int i=0; 2>i; ++i)
+ for(int i = 0; 2 > i; ++i)
{
- int* num = 0==i?a:b;
+ int* num = (0 == i) ? a : b;
for( ; ; )
{
- printf(" > Enter Device[%d] Number, %s: ", i+1, str);
- for(int ret=0; 1!=ret; )
+ printf(" > Enter Device[%d] Number, %s: ", (i + 1), str);
+ for(int ret = 0; 1 != ret;)
{
ret = scanf("%d", num);
for( ; 0x20<=getchar(); ); // for removing overflow garbages
// '0x20<=code' is character region
}
- if(0<*num && max>=*num)
+ if((0 < *num) && (max >= *num))
{
break;
}
return 0;
}
}
-
- return -1;
}
#ifdef __WITH_TLS__
return ehResult;
}
-OCStackResult displayNumCB(void * ctx, uint8_t mutualVerifNum[MUTUAL_VERIF_NUM_LEN])
+OCStackResult displayNumCB(void *ctx, uint8_t mutualVerifNum[MUTUAL_VERIF_NUM_LEN])
{
+ OC_UNUSED(ctx);
+
OIC_LOG(INFO, TAG, "IN displayNumCB");
OIC_LOG(INFO, TAG, "############ mutualVerifNum ############");
OIC_LOG_BUFFER(INFO, TAG, mutualVerifNum, MUTUAL_VERIF_NUM_LEN);
return OC_STACK_OK;
}
-OCStackResult confirmNumCB(void * ctx)
+OCStackResult confirmNumCB(void *ctx)
{
+ OC_UNUSED(ctx);
+
for (;;)
{
int userConfirm;
void DisplayPinCB(char *pin, size_t pinSize, void *context)
{
+ OC_UNUSED(context);
+
if(NULL == pin || pinSize <= 0)
{
OIC_LOG(INFO, TAG, "Invalid PIN");
{
printf("Press 'G' to generate random PIN...\n");
printf("Press 'E' to exit...\n");
- char in = getchar();
+ char in = (char)getchar();
if('G' == in || 'g' == in)
{
char ranPin[OXM_RANDOM_PIN_MAX_SIZE + 1] = {0};
// response handler for LED requests.
static OCStackApplicationResult LedCB(void *ctx, OCDoHandle UNUSED, OCClientResponse *clientResponse)
{
+ OC_UNUSED(ctx);
+ OC_UNUSED(UNUSED);
+
if(clientResponse)
{
if(OC_STACK_OK == clientResponse->result)
// main loop for provisioning manager
int mnNum = 0;
- int selDevNum = 0;
for( ; ; )
{
printf("\n");
LL_FOREACH((cloudAce_t*)aces, ace)
{
- OCRepPayload *payload = OCRepPayloadCreate();
- if (!payload)
+ OCRepPayload *acePayload = OCRepPayloadCreate();
+ if (!acePayload)
{
OIC_LOG_V(DEBUG, TAG, "Can't allocate memory for helperPayload[i]");
goto no_memory;
}
- helperPayload[i++] = payload;
+ helperPayload[i++] = acePayload;
char *uuid = NULL;
if (OC_STACK_OK != ConvertUuidToStr(&ace->subjectuuid, &uuid))
OIC_LOG(ERROR, TAG, "Can't convert subjectuuid to string");
}
- OCRepPayloadSetPropString(payload, OC_RSRVD_SUBJECT_UUID, (const char *)uuid);
- OCRepPayloadSetPropInt(payload, OC_RSRVD_SUBJECT_TYPE, ace->stype);
- OCRepPayloadSetPropInt(payload, OC_RSRVD_PERMISSION_MASK, ace->permission);
+ OCRepPayloadSetPropString(acePayload, OC_RSRVD_SUBJECT_UUID, (const char *)uuid);
+ OCRepPayloadSetPropInt(acePayload, OC_RSRVD_SUBJECT_TYPE, ace->stype);
+ OCRepPayloadSetPropInt(acePayload, OC_RSRVD_PERMISSION_MASK, ace->permission);
OICFree(uuid);
LL_FOREACH(ace->resources, res)
{
- OCRepPayload *payload = OCRepPayloadCreate();
- if (!payload)
+ OCRepPayload *aceResourcePayload = OCRepPayloadCreate();
+ if (!aceResourcePayload)
{
OIC_LOG_V(DEBUG, TAG, "Can't allocate memory for helperPayload2[j]");
goto no_memory;
}
- helperPayload2[j++] = payload;
+ helperPayload2[j++] = aceResourcePayload;
- OCRepPayloadSetPropString(payload, OC_RSRVD_HREF, res->href);
+ OCRepPayloadSetPropString(aceResourcePayload, OC_RSRVD_HREF, res->href);
dimensions[0] = res->typeLen;
- OCRepPayloadSetStringArray(payload, OC_RSRVD_RESOURCE_TYPE,
+ OCRepPayloadSetStringArray(aceResourcePayload, OC_RSRVD_RESOURCE_TYPE,
(const char **)res->types, dimensions);
dimensions[0] = res->interfaceLen;
- OCRepPayloadSetStringArray(payload, OC_RSRVD_INTERFACE,
+ OCRepPayloadSetStringArray(aceResourcePayload, OC_RSRVD_INTERFACE,
(const char **)res->interfaces, dimensions);
}
dimensions[0] = reslist_count;
- OCRepPayloadSetPropObjectArray(payload, OC_RSRVD_RESOURCES,
+ OCRepPayloadSetPropObjectArray(acePayload, OC_RSRVD_RESOURCES,
(const OCRepPayload **)helperPayload2, dimensions);
}
dimensions[0] = acllist_count;
LL_FOREACH((cloudAce_t*)aces, ace)
{
- OCRepPayload *payload = OCRepPayloadCreate();
- if (!payload)
+ OCRepPayload *acePayload = OCRepPayloadCreate();
+ if (!acePayload)
{
OIC_LOG_V(DEBUG, TAG, "Can't allocate memory for helperPayload[i]");
goto no_memory;
}
- helperPayload[i++] = payload;
+ helperPayload[i++] = acePayload;
char *uuid = NULL;
if (OC_STACK_OK != ConvertUuidToStr(&ace->subjectuuid, &uuid))
OIC_LOG(ERROR, TAG, "Can't convert subjectuuid to string");
}
- OCRepPayloadSetPropString(payload, OC_RSRVD_SUBJECT_UUID, (const char *)uuid);
- OCRepPayloadSetPropInt(payload, OC_RSRVD_SUBJECT_TYPE, ace->stype);
- OCRepPayloadSetPropInt(payload, OC_RSRVD_PERMISSION_MASK, ace->permission);
+ OCRepPayloadSetPropString(acePayload, OC_RSRVD_SUBJECT_UUID, (const char *)uuid);
+ OCRepPayloadSetPropInt(acePayload, OC_RSRVD_SUBJECT_TYPE, ace->stype);
+ OCRepPayloadSetPropInt(acePayload, OC_RSRVD_PERMISSION_MASK, ace->permission);
OICFree(uuid);
LL_FOREACH(ace->resources, res)
{
- OCRepPayload *payload = OCRepPayloadCreate();
- if (!payload)
+ OCRepPayload *aceResourcePayload = OCRepPayloadCreate();
+ if (!aceResourcePayload)
{
OIC_LOG_V(DEBUG, TAG, "Can't allocate memory for helperPayload2[j]");
goto no_memory;
}
- helperPayload2[j++] = payload;
+ helperPayload2[j++] = aceResourcePayload;
- OCRepPayloadSetPropString(payload, OC_RSRVD_HREF, res->href);
+ OCRepPayloadSetPropString(aceResourcePayload, OC_RSRVD_HREF, res->href);
dimensions[0] = res->typeLen;
- OCRepPayloadSetStringArray(payload, OC_RSRVD_RESOURCE_TYPE,
+ OCRepPayloadSetStringArray(aceResourcePayload, OC_RSRVD_RESOURCE_TYPE,
(const char **)res->types, dimensions);
dimensions[0] = res->interfaceLen;
- OCRepPayloadSetStringArray(payload, OC_RSRVD_INTERFACE,
+ OCRepPayloadSetStringArray(aceResourcePayload, OC_RSRVD_INTERFACE,
(const char **)res->interfaces, dimensions);
}
dimensions[0] = reslist_count;
- OCRepPayloadSetPropObjectArray(payload, OC_RSRVD_RESOURCES,
+ OCRepPayloadSetPropObjectArray(acePayload, OC_RSRVD_RESOURCES,
(const OCRepPayload **)helperPayload2, dimensions);
}
dimensions[0] = acllist_count;
{
OCStackResult result = OC_STACK_NO_MEMORY;
size_t dimensions[MAX_REP_ARRAY_DEPTH] = { 0 };
- OCRepPayload **heplerPayload = NULL;
+ OCRepPayload **helperPayload = NULL;
size_t i = 0;
- if (!OCRepPayloadGetPropObjectArray(payload, name, &heplerPayload, dimensions))
+ if (!OCRepPayloadGetPropObjectArray(payload, name, &helperPayload, dimensions))
{
OIC_LOG_V(ERROR, TAG, "Can't get: %s", name);
return OC_STACK_MALFORMED_RESPONSE;
for (i = 0; i < gidlist->length; i++)
{
- const OCRepPayload *payload = heplerPayload[i];
+ const OCRepPayload *gidPayload = helperPayload[i];
- if (!OCRepPayloadGetPropString(payload, OC_RSRVD_GROUP_ID, &gidlist->array[i]))
+ if (!OCRepPayloadGetPropString(gidPayload, OC_RSRVD_GROUP_ID, &gidlist->array[i]))
{
OIC_LOG_V(ERROR, TAG, "Can't get: %s", OC_RSRVD_GROUP_ID);
result = OC_STACK_MALFORMED_RESPONSE;
goto exit;
}
- if (!OCRepPayloadGetPropString(payload, OC_RSRVD_MEMBER_ID, &midlist->array[i]))
+ if (!OCRepPayloadGetPropString(gidPayload, OC_RSRVD_MEMBER_ID, &midlist->array[i]))
{
OIC_LOG_V(ERROR, TAG, "Can't get: %s", OC_RSRVD_MEMBER_ID);
result = OC_STACK_MALFORMED_RESPONSE;
goto exit;
}
- OCRepPayloadDestroy(heplerPayload[i]);
+ OCRepPayloadDestroy(helperPayload[i]);
}
result = OC_STACK_OK;
for (size_t k = i; k < gidlist->length; k++)
{
- OCRepPayloadDestroy(heplerPayload[i]);
+ OCRepPayloadDestroy(helperPayload[i]);
}
}
- OICFree(heplerPayload);
+ OICFree(helperPayload);
return result;
}
//add next fields if they were filled
if (userId) OCRepPayloadSetPropString(payload, OC_RSRVD_USER_UUID, userId);
- size_t dimensions[MAX_REP_ARRAY_DEPTH] = {groupIds->length, 0, 0};
+ size_t dimensions[MAX_REP_ARRAY_DEPTH] = {0, 0, 0};
+ dimensions[0] = groupIds->length;
OCRepPayloadSetPropObjectArray(payload, OC_RSRVD_INVITE,
(const struct OCRepPayload **)heplerPayload, dimensions);
if (userId)
{
- size_t len = strlen(uri);
- snprintf(uri + len, MAX_URI_LENGTH - len, "?%s=%s", OC_RSRVD_USER_UUID, userId);
+ len = strlen(uri);
+ snprintf((uri + len), (MAX_URI_LENGTH - len), "?%s=%s", OC_RSRVD_USER_UUID, userId);
}
len = strlen(uri);
//add next fields if they were filled
if (serialNumbers)
{
- size_t dimensions[MAX_REP_ARRAY_DEPTH] = {serialNumbers->length, 0 ,0};
+ size_t dimensions[MAX_REP_ARRAY_DEPTH] = {0, 0, 0};
+ dimensions[0] = serialNumbers->length;
OCRepPayloadSetStringArray(payload, OC_RSRVD_SERIAL_NUMBERS,
(const char**)serialNumbers->array, dimensions);
mbedtls_ctr_drbg_init(&ctr_drbg);
mbedtls_entropy_init(&entropy);
if (0 != mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func,
- &entropy, PERSONALIZATION_STRING, sizeof(PERSONALIZATION_STRING)))
+ &entropy, (const unsigned char*)PERSONALIZATION_STRING, sizeof(PERSONALIZATION_STRING)))
{
OIC_LOG(ERROR, TAG, "Seed initialization failed!");
OIC_LOG_V(DEBUG, TAG, "Out %s", __func__);
// Initialize the DRBG context
mbedtls_ctr_drbg_init(&ctr_drbg);
mbedtls_entropy_init(&entropy);
+
result = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func,
- &entropy, PERSONALIZATION_STRING, sizeof(PERSONALIZATION_STRING));
+ &entropy, (const unsigned char*)PERSONALIZATION_STRING, sizeof(PERSONALIZATION_STRING));
if (result < 0)
{
OIC_LOG(ERROR, TAG, "Seed initialization failed!");
}
else
{
- OicSecKey_t key =
- {
- g_privateKey.bytes,
- g_privateKey.len,
- OIC_ENCODING_DER
- };
+ OicSecKey_t key;
+ memset(&key, 0, sizeof(key));
+ key.data = g_privateKey.bytes;
+ key.len = g_privateKey.len;
+ key.encoding = OIC_ENCODING_DER;
uint16_t credId;
result = SRPSaveOwnCertChain(&cert, &key, &credId);
OCRepPayloadSetPropString(payload, OC_RSRVD_DEVICE_ID, deviceId);
- OicSecKey_t csr = {.data = request.bytes, .len = request.len, .encoding = OIC_ENCODING_DER};
+ OicSecKey_t csr;
+ memset(&csr, 0, sizeof(csr));
+ csr.data = request.bytes;
+ csr.len = request.len;
+ csr.encoding = OIC_ENCODING_DER;
OCRepPayloadSetPropPubDataType(payload, OC_RSRVD_CSR, &csr);
uint8_t *privData = (uint8_t *)OICCalloc(privDataKeySize, sizeof(uint8_t));
VERIFY_NOT_NULL(TAG, privData, ERROR);
- OicSecKey_t privKey = {.data=privData, .len=keySize};
+
+ OicSecKey_t privKey;
+ memset(&privKey, 0, sizeof(privKey));
+ privKey.data = privData;
+ privKey.len = keySize;
+ privKey.encoding = OIC_ENCODING_UNKNOW;
if (!OCGetRandomBytes(privData, privDataKeySize))
{
OCStackResult postOxmRes = OC_STACK_INVALID_PARAM;
OicSecOxm_t* newOxms = NULL;
uint8_t* doxmPayload = NULL;
- size_t doxmPayloadLen = 0;
OIC_LOG(DEBUG, TAG, "IN MOTAddMOTMethod");
pinCred->privateData.len = preconfPINLen;
pinCred->privateData.encoding = OIC_ENCODING_RAW;
pinCred->credType = PIN_PASSWORD;
- OICStrcpy(pinCred->subject.id, sizeof(pinCred->subject.id), WILDCARD_SUBJECT_ID.id);
+ memcpy(&pinCred->subject, &WILDCARD_SUBJECT_ID, sizeof(OicUuid_t));
//Generate the security payload using updated doxm
secPayload = (OCSecurityPayload*)OICCalloc(1, sizeof(OCSecurityPayload));
{
OCStackResult addCredRes = OC_STACK_INVALID_PARAM;
OicSecCred_t* pinCred = NULL;
- bool freeFlag = true;
OIC_LOG(DEBUG, TAG, "IN MOTAddPreconfigPIN");
}
uint8_t ownerPSK[OWNER_PSK_LENGTH_128] = {0};
- OicSecKey_t ownerKey = {ownerPSK, OWNER_PSK_LENGTH_128};
+ OicSecKey_t ownerKey;
+ memset(&ownerKey, 0, sizeof(ownerKey));
+ ownerKey.data = ownerPSK;
+ ownerKey.len = OWNER_PSK_LENGTH_128;
+ ownerKey.encoding = OIC_ENCODING_UNKNOW;
//Generating SubOwnerPSK
CAResult_t pskRet = CAGenerateOwnerPSK(&endpoint,
size_t outSize = 0;
size_t b64BufSize = B64ENCODE_OUT_SAFESIZE((OWNER_PSK_LENGTH_128 + 1));
- char* b64Buf = (uint8_t *)OICCalloc(1, b64BufSize);
+ char* b64Buf = (char*)OICCalloc(1, b64BufSize);
VERIFY_NOT_NULL(TAG, b64Buf, ERROR);
b64Encode(cred->privateData.data, cred->privateData.len, b64Buf, b64BufSize, &outSize);
- OICFree( cred->privateData.data );
+ OICFree(cred->privateData.data);
cred->privateData.data = (uint8_t *)OICCalloc(1, outSize + 1);
VERIFY_NOT_NULL(TAG, cred->privateData.data, ERROR);
- strncpy(cred->privateData.data, b64Buf, outSize);
+ strncpy((char*)(cred->privateData.data), b64Buf, outSize);
cred->privateData.data[outSize] = '\0';
cred->privateData.encoding = OIC_ENCODING_BASE64;
cred->privateData.len = outSize;
memcpy(newCredential.eownerID->id, ownerId.id, sizeof(ownerId.id));
//Fill private data as empty string
- newCredential.privateData.data = "";
+ newCredential.privateData.data = (uint8_t*)"";
newCredential.privateData.len = 0;
newCredential.privateData.encoding = ownerCredential->privateData.encoding;
if(NULL != newDevDoxm)
{
- OicUuid_t emptyUuid = {.id={0}};
-
//Make sure the address matches.
if(strncmp(motCtx->selectedDeviceInfo->endpoint.addr,
endpoint->addr,
#ifdef MULTIPLE_OWNER
static void AddPreconfPinOxMCB(void* ctx, size_t nOfRes, OCProvisionResult_t *arr, bool hasError)
{
+ OC_UNUSED(hasError);
+
ProvPreconfPINCtx_t* provCtx = (ProvPreconfPINCtx_t*)ctx;
if(provCtx)
{
static void OwnershipTransferSessionFailed(const CAEndpoint_t *endpoint,
const CAErrorInfo_t *info, OicSecDoxm_t *newDevDoxm, OTMContext_t *otmCtx, bool emptyOwnerUuid)
{
+ OC_UNUSED(endpoint);
+
OIC_LOG_V(DEBUG, TAG, "IN %s", __func__);
if (CA_DTLS_AUTHENTICATION_FAILURE != info->result)
endpoint.addr[MAX_ADDR_STR_SIZE_CA - 1] = '\0';
endpoint.port = selectedDeviceInfo->securePort;
endpoint.adapter = selectedDeviceInfo->endpoint.adapter;
+ uint8_t ownerPSK[OWNER_PSK_LENGTH_128] = { 0 };
OicUuid_t ownerDeviceID = {.id={0}};
if (OC_STACK_OK != GetDoxmDeviceID(&ownerDeviceID))
return res;
}
- uint8_t ownerPSK[OWNER_PSK_LENGTH_128] = {0};
- OicSecKey_t ownerKey = {.data=ownerPSK, .len=OWNER_PSK_LENGTH_128, .encoding=OIC_ENCODING_RAW};
+ OicSecKey_t ownerKey;
+ memset(&ownerKey, 0, sizeof(ownerKey));
+ ownerKey.data = ownerPSK;
+ ownerKey.len = OWNER_PSK_LENGTH_128;
+ ownerKey.encoding = OIC_ENCODING_RAW;
//Generating OwnerPSK
CAResult_t pskRet = CAGenerateOwnerPSK(&endpoint,
if(NULL == cred)
{
OicUuid_t uuid = {.id={0}};
- OICStrcpy(uuid.id, sizeof(uuid.id), WILDCARD_SUBJECT_ID.id);
+ memcpy(&uuid, &WILDCARD_SUBJECT_ID, sizeof(OicUuid_t));
cred = GetCredResourceData(&uuid);
if(NULL == cred)
{
return OC_STACK_NO_MEMORY;
}
size_t pinLen = 0;
- if(B64_OK != b64Decode(cred->privateData.data, cred->privateData.len, pinBuffer, pinBufLen, &pinLen))
+ if(B64_OK != b64Decode((char*)cred->privateData.data, cred->privateData.len, pinBuffer, pinBufLen, &pinLen))
{
OIC_LOG(ERROR, TAG, "Failed to base64 deconding for preconfig PIN");
OICFree(pinBuffer);
OIC_LOG(INFO, TAG, "Skiping Null response");
return OC_STACK_KEEP_TRANSACTION;
}
-
- return OC_STACK_DELETE_TRANSACTION;
}
/**
return OC_STACK_INVALID_PARAM;
}
}
- return OC_STACK_ERROR;
}
/**
{
int tem = rand() % 25;
- id[i] = tem + 65;
+ id[i] = (uint8_t)(tem + 65);
}
memcpy(&uid.id, &id, UUID_LENGTH);
{
int tem = rand() % 25;
- id[i] = tem + 65;
+ id[i] = (uint8_t)(tem + 65);
}
memcpy(&uid.id, &id, sizeof(uid.id));
}
}
-void SetPersistentHandler(OCPersistentStorage *ps)
+void SetPersistentHandler(OCPersistentStorage *persistentStorage)
{
- if(ps)
+ if(persistentStorage)
{
- ps->open = TestFopen;
- ps->read = fread;
- ps->write = fwrite;
- ps->close = fclose;
- ps->unlink = remove;
+ persistentStorage->open = TestFopen;
+ persistentStorage->read = fread;
+ persistentStorage->write = fwrite;
+ persistentStorage->close = fclose;
+ persistentStorage->unlink = remove;
}
}
int ctx;
OicSecCredType_t type = SIGNED_ASYMMETRIC_KEY;
uint16_t credId = 0;
- OCProvisionDev_t selectedDeviceInfo;
+ OCProvisionDev_t deviceInfo;
- result = SRPProvisionTrustCertChain(&ctx, type, credId, &selectedDeviceInfo, NULL);
+ result = SRPProvisionTrustCertChain(&ctx, type, credId, &deviceInfo, NULL);
EXPECT_EQ(OC_STACK_INVALID_CALLBACK, result);
}
int ctx;
OicSecCredType_t type = PIN_PASSWORD;
uint16_t credId = 0;
- OCProvisionDev_t selectedDeviceInfo;
+ OCProvisionDev_t deviceInfo;
- result = SRPProvisionTrustCertChain(&ctx, type, credId, &selectedDeviceInfo, provisioningCB);
+ result = SRPProvisionTrustCertChain(&ctx, type, credId, &deviceInfo, provisioningCB);
EXPECT_EQ(OC_STACK_INVALID_PARAM, result);
}
int ctx;
OicSecCredType_t type = SIGNED_ASYMMETRIC_KEY;
uint16_t credId = 0;
- OCProvisionDev_t selectedDeviceInfo;
+ OCProvisionDev_t deviceInfo;
- result = SRPProvisionTrustCertChain(&ctx, type, credId, &selectedDeviceInfo, provisioningCB);
+ result = SRPProvisionTrustCertChain(&ctx, type, credId, &deviceInfo, provisioningCB);
EXPECT_EQ(OC_STACK_NO_RESOURCE, result);
}
OCStackResult convRet = AclToCBORPayload(defaultAcl, &defaultPsStorage, &defaultAclSize);
EXPECT_EQ(OC_STACK_OK, convRet);
ASSERT_TRUE(NULL != defaultPsStorage);
- EXPECT_NE(0, defaultAclSize);
+ EXPECT_NE(static_cast<size_t>(0), defaultAclSize);
OicSecAcl_t* convertedAcl = CBORPayloadToAcl(defaultPsStorage, defaultAclSize);
ASSERT_TRUE(NULL != convertedAcl);
{
ByteArray crlArray = {NULL, 0};
GetDerCrl(&crlArray);
- EXPECT_NE(0, crlArray.len);
+ EXPECT_NE(static_cast<size_t>(0), crlArray.len);
}
#endif
int ret = snprintf(filepath, len, "%s%s", STRINGIZE(SECURITY_BUILD_UNITTEST_DIR), filename);
printf("Root build path: %s \n", filepath);
- if (ret == (len - 1))
+ if (ret == (int)(len - 1))
{
FILE *fp = fopen(filepath, "rb");
if (fp)
}
else
{
- size = st.st_size;
+ size = (size_t)st.st_size;
CborValue cbor = {0, };
CborParser parser = {0, };
security_test_env = test_env.Clone()
if security_test_env.get('TARGET_OS') in ['windows', 'msys_nt']:
- security_test_env.AppendUnique(CCFLAGS=['/W3', '/WX'])
+ security_test_env.AppendUnique(CCFLAGS=['/W4', '/WX'])
SConscript('../unittest/SConscript', exports = { 'test_env' : security_test_env })
SConscript('../provisioning/unittest/SConscript', exports = { 'test_env' : security_test_env })