Fix astyle issues

Signed-off-by: Darryl Green <darryl.green@arm.com>
pull/13003/head
Darryl Green 2020-05-27 09:47:56 +01:00
parent fcf60ec683
commit a62b3591d9
17 changed files with 369 additions and 415 deletions

View File

@ -29,8 +29,7 @@ int32_t pal_attestation_function(int type, va_list valist)
uint8_t *challenge, *token; uint8_t *challenge, *token;
uint32_t challenge_size, *token_size, verify_token_size; uint32_t challenge_size, *token_size, verify_token_size;
switch (type) switch (type) {
{
case PAL_INITIAL_ATTEST_GET_TOKEN: case PAL_INITIAL_ATTEST_GET_TOKEN:
challenge = va_arg(valist, uint8_t *); challenge = va_arg(valist, uint8_t *);
challenge_size = va_arg(valist, uint32_t); challenge_size = va_arg(valist, uint32_t);

View File

@ -41,8 +41,7 @@ typedef uint32_t cfg_id_t;
#define PAL_STATUS_UNSUPPORTED_FUNC 0xFF #define PAL_STATUS_UNSUPPORTED_FUNC 0xFF
typedef enum typedef enum {
{
PAL_STATUS_SUCCESS = 0x0, PAL_STATUS_SUCCESS = 0x0,
PAL_STATUS_ERROR = 0x80 PAL_STATUS_ERROR = 0x80
} pal_status_t; } pal_status_t;

View File

@ -40,8 +40,7 @@ uint32_t pal_its_function(int type, va_list valist)
*/ */
size_t actual_size; size_t actual_size;
switch (type) switch (type) {
{
case PAL_ITS_SET: case PAL_ITS_SET:
uid = va_arg(valist, psa_storage_uid_t); uid = va_arg(valist, psa_storage_uid_t);
data_length = va_arg(valist, uint32_t); data_length = va_arg(valist, uint32_t);

View File

@ -108,16 +108,11 @@ void main_wrapper(void)
void pal_mbed_os_compliance_test_initialize(void) void pal_mbed_os_compliance_test_initialize(void)
{ {
if (COMPLIANCE_TEST_CRYPTO == type_g) if (COMPLIANCE_TEST_CRYPTO == type_g) {
{
inject_entropy(); inject_entropy();
} } else if (COMPLIANCE_TEST_STORAGE == type_g) {
else if (COMPLIANCE_TEST_STORAGE == type_g)
{
reset_storage_for_compliance_test(); reset_storage_for_compliance_test();
} } else if (COMPLIANCE_TEST_ATTESTATION == type_g) {
else if (COMPLIANCE_TEST_ATTESTATION == type_g)
{
reset_storage_for_compliance_test(); reset_storage_for_compliance_test();
inject_entropy(); inject_entropy();
psa_crypto_init(); psa_crypto_init();

View File

@ -34,8 +34,7 @@ uint32_t pal_ps_function(int type, va_list valist)
psa_storage_create_flags_t ps_create_flags; psa_storage_create_flags_t ps_create_flags;
struct psa_ps_info_t *ps_p_info; struct psa_ps_info_t *ps_p_info;
switch (type) switch (type) {
{
case PAL_PS_SET: case PAL_PS_SET:
uid = va_arg(valist, psa_storage_uid_t); uid = va_arg(valist, psa_storage_uid_t);
data_length = va_arg(valist, uint32_t); data_length = va_arg(valist, uint32_t);

View File

@ -28,34 +28,27 @@ static int get_items_in_map(QCBORDecodeContext *decode_context,
struct items_to_get_t *item_ptr = item_list; struct items_to_get_t *item_ptr = item_list;
/* initialize the data type of all items in the list */ /* initialize the data type of all items in the list */
while (item_ptr->label != 0) while (item_ptr->label != 0) {
{
item_ptr->item.uDataType = QCBOR_TYPE_NONE; item_ptr->item.uDataType = QCBOR_TYPE_NONE;
item_ptr++; item_ptr++;
} }
QCBORDecode_GetNext(decode_context, &item); QCBORDecode_GetNext(decode_context, &item);
if (item.uDataType != QCBOR_TYPE_MAP) if (item.uDataType != QCBOR_TYPE_MAP) {
{
return PAL_ATTEST_ERROR; return PAL_ATTEST_ERROR;
} }
for (item_index = item.val.uCount; item_index != 0; item_index--) for (item_index = item.val.uCount; item_index != 0; item_index--) {
{ if (QCBORDecode_GetNext(decode_context, &item) != QCBOR_SUCCESS) {
if (QCBORDecode_GetNext(decode_context, &item) != QCBOR_SUCCESS)
{
return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING;
} }
if (item.uLabelType != QCBOR_TYPE_INT64) if (item.uLabelType != QCBOR_TYPE_INT64) {
{
continue; continue;
} }
item_ptr = item_list; item_ptr = item_list;
while (item_ptr->label != 0) while (item_ptr->label != 0) {
{ if (item.label.int64 == item_ptr->label) {
if (item.label.int64 == item_ptr->label)
{
item_ptr->item = item; item_ptr->item = item;
} }
item_ptr++; item_ptr++;
@ -74,13 +67,11 @@ static int get_item_in_map(QCBORDecodeContext *decode_context,
item_list[0].label = label; item_list[0].label = label;
item_list[1].label = 0; item_list[1].label = 0;
if (get_items_in_map(decode_context, item_list)) if (get_items_in_map(decode_context, item_list)) {
{
return PAL_ATTEST_ERROR; return PAL_ATTEST_ERROR;
} }
if (item_list[0].item.uDataType == QCBOR_TYPE_NONE) if (item_list[0].item.uDataType == QCBOR_TYPE_NONE) {
{
return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING;
} }
@ -100,18 +91,15 @@ static int parse_unprotected_headers(QCBORDecodeContext *decode_context,
item_list[2].label = 0; item_list[2].label = 0;
*loop_back = false; *loop_back = false;
if (get_items_in_map(decode_context, item_list)) if (get_items_in_map(decode_context, item_list)) {
{
return PAL_ATTEST_ERROR; return PAL_ATTEST_ERROR;
} }
if (item_list[1].item.uDataType == QCBOR_TYPE_TRUE) if (item_list[1].item.uDataType == QCBOR_TYPE_TRUE) {
{
*loop_back = true; *loop_back = true;
} }
if (item_list[0].item.uDataType != QCBOR_TYPE_BYTE_STRING) if (item_list[0].item.uDataType != QCBOR_TYPE_BYTE_STRING) {
{
return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING;
} }
@ -128,18 +116,15 @@ static int parse_protected_headers(struct useful_buf_c protected_headers,
QCBORDecode_Init(&decode_context, protected_headers, 0); QCBORDecode_Init(&decode_context, protected_headers, 0);
if (get_item_in_map(&decode_context, COSE_HEADER_PARAM_ALG, &item)) if (get_item_in_map(&decode_context, COSE_HEADER_PARAM_ALG, &item)) {
{
return PAL_ATTEST_ERROR; return PAL_ATTEST_ERROR;
} }
if (QCBORDecode_Finish(&decode_context)) if (QCBORDecode_Finish(&decode_context)) {
{
return PAL_ATTEST_ERROR; return PAL_ATTEST_ERROR;
} }
if ((item.uDataType != QCBOR_TYPE_INT64) || (item.val.int64 > INT32_MAX)) if ((item.uDataType != QCBOR_TYPE_INT64) || (item.val.int64 > INT32_MAX)) {
{
return PAL_ATTEST_ERROR; return PAL_ATTEST_ERROR;
} }
@ -162,113 +147,101 @@ static int parse_claims(QCBORDecodeContext *decode_context, QCBORItem item,
int status = PAL_ATTEST_SUCCESS; int status = PAL_ATTEST_SUCCESS;
/* Parse each claim and validate their data type */ /* Parse each claim and validate their data type */
while (status == PAL_ATTEST_SUCCESS) while (status == PAL_ATTEST_SUCCESS) {
{
status = QCBORDecode_GetNext(decode_context, &item); status = QCBORDecode_GetNext(decode_context, &item);
if (status != PAL_ATTEST_SUCCESS) if (status != PAL_ATTEST_SUCCESS) {
break; break;
}
mandatory_claims |= 1 << (EAT_CBOR_ARM_RANGE_BASE - item.label.int64); mandatory_claims |= 1 << (EAT_CBOR_ARM_RANGE_BASE - item.label.int64);
if (item.uLabelType == QCBOR_TYPE_INT64) if (item.uLabelType == QCBOR_TYPE_INT64) {
{ if (item.label.int64 == EAT_CBOR_ARM_LABEL_NONCE) {
if (item.label.int64 == EAT_CBOR_ARM_LABEL_NONCE) if (item.uDataType == QCBOR_TYPE_BYTE_STRING) {
{
if (item.uDataType == QCBOR_TYPE_BYTE_STRING)
{
/* Given challenge vs challenge in token */ /* Given challenge vs challenge in token */
if (UsefulBuf_Compare(item.val.string, completed_challenge)) if (UsefulBuf_Compare(item.val.string, completed_challenge)) {
return PAL_ATTEST_TOKEN_CHALLENGE_MISMATCH; return PAL_ATTEST_TOKEN_CHALLENGE_MISMATCH;
} }
else } else {
return PAL_ATTEST_TOKEN_NOT_SUPPORTED; return PAL_ATTEST_TOKEN_NOT_SUPPORTED;
} }
else if (item.label.int64 == EAT_CBOR_ARM_LABEL_BOOT_SEED || } else if (item.label.int64 == EAT_CBOR_ARM_LABEL_BOOT_SEED ||
item.label.int64 == EAT_CBOR_ARM_LABEL_IMPLEMENTATION_ID || item.label.int64 == EAT_CBOR_ARM_LABEL_IMPLEMENTATION_ID ||
item.label.int64 == EAT_CBOR_ARM_LABEL_UEID) item.label.int64 == EAT_CBOR_ARM_LABEL_UEID) {
{ if (item.uDataType != QCBOR_TYPE_BYTE_STRING) {
if (item.uDataType != QCBOR_TYPE_BYTE_STRING)
return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING;
} }
else if (item.label.int64 == EAT_CBOR_ARM_LABEL_ORIGINATION || } else if (item.label.int64 == EAT_CBOR_ARM_LABEL_ORIGINATION ||
item.label.int64 == EAT_CBOR_ARM_LABEL_PROFILE_DEFINITION || item.label.int64 == EAT_CBOR_ARM_LABEL_PROFILE_DEFINITION ||
item.label.int64 == EAT_CBOR_ARM_LABEL_HW_VERSION) item.label.int64 == EAT_CBOR_ARM_LABEL_HW_VERSION) {
{ if (item.uDataType != QCBOR_TYPE_TEXT_STRING) {
if (item.uDataType != QCBOR_TYPE_TEXT_STRING)
return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING;
} }
else if (item.label.int64 == EAT_CBOR_ARM_LABEL_CLIENT_ID || } else if (item.label.int64 == EAT_CBOR_ARM_LABEL_CLIENT_ID ||
item.label.int64 == EAT_CBOR_ARM_LABEL_SECURITY_LIFECYCLE) item.label.int64 == EAT_CBOR_ARM_LABEL_SECURITY_LIFECYCLE) {
{ if (item.uDataType != QCBOR_TYPE_INT64) {
if (item.uDataType != QCBOR_TYPE_INT64)
return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING;
} }
else if (item.label.int64 == EAT_CBOR_ARM_LABEL_SW_COMPONENTS) } else if (item.label.int64 == EAT_CBOR_ARM_LABEL_SW_COMPONENTS) {
{ if (item.uDataType != QCBOR_TYPE_ARRAY) {
if (item.uDataType != QCBOR_TYPE_ARRAY)
return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING;
}
sw_component_present = 1; sw_component_present = 1;
status = QCBORDecode_GetNext(decode_context, &item); status = QCBORDecode_GetNext(decode_context, &item);
if (status != PAL_ATTEST_SUCCESS) if (status != PAL_ATTEST_SUCCESS) {
continue; continue;
}
count = item.val.uCount; count = item.val.uCount;
for (i = 0; i <= count; i++) for (i = 0; i <= count; i++) {
{
mandaroty_sw_components |= 1 << item.label.int64; mandaroty_sw_components |= 1 << item.label.int64;
if (item.label.int64 == EAT_CBOR_SW_COMPONENT_MEASUREMENT) if (item.label.int64 == EAT_CBOR_SW_COMPONENT_MEASUREMENT) {
{ if (item.uDataType != QCBOR_TYPE_BYTE_STRING) {
if (item.uDataType != QCBOR_TYPE_BYTE_STRING)
return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING;
} }
else if (item.label.int64 == EAT_CBOR_SW_COMPONENT_MEASUREMENT_DESC) } else if (item.label.int64 == EAT_CBOR_SW_COMPONENT_MEASUREMENT_DESC) {
{ if (item.uDataType != QCBOR_TYPE_TEXT_STRING) {
if (item.uDataType != QCBOR_TYPE_TEXT_STRING)
return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING;
} }
else if (item.label.int64 == EAT_CBOR_SW_COMPONENT_VERSION) } else if (item.label.int64 == EAT_CBOR_SW_COMPONENT_VERSION) {
{ if (item.uDataType != QCBOR_TYPE_TEXT_STRING) {
if (item.uDataType != QCBOR_TYPE_TEXT_STRING)
return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING;
} }
else if (item.label.int64 == EAT_CBOR_SW_COMPONENT_SIGNER_ID) } else if (item.label.int64 == EAT_CBOR_SW_COMPONENT_SIGNER_ID) {
{ if (item.uDataType != QCBOR_TYPE_BYTE_STRING) {
if (item.uDataType != QCBOR_TYPE_BYTE_STRING)
return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING;
} }
else if (item.label.int64 == EAT_CBOR_SW_COMPONENT_EPOCH) } else if (item.label.int64 == EAT_CBOR_SW_COMPONENT_EPOCH) {
{ if (item.uDataType != QCBOR_TYPE_INT64) {
if (item.uDataType != QCBOR_TYPE_INT64)
return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING;
} }
else if (item.label.int64 == EAT_CBOR_SW_COMPONENT_TYPE) } else if (item.label.int64 == EAT_CBOR_SW_COMPONENT_TYPE) {
{ if (item.uDataType != QCBOR_TYPE_TEXT_STRING) {
if (item.uDataType != QCBOR_TYPE_TEXT_STRING)
return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING;
} }
}
if (i < count) if (i < count) {
{
status = QCBORDecode_GetNext(decode_context, &item); status = QCBORDecode_GetNext(decode_context, &item);
if (status != PAL_ATTEST_SUCCESS) if (status != PAL_ATTEST_SUCCESS) {
return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING;
} }
} }
}
} }
} } else {
else
{
/* ToDo: Add other claim types */ /* ToDo: Add other claim types */
} }
} }
if (status == QCBOR_ERR_HIT_END) if (status == QCBOR_ERR_HIT_END) {
return PAL_ATTEST_SUCCESS; return PAL_ATTEST_SUCCESS;
else } else {
return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING;
} }
}
/** /**
@brief - This API will verify the attestation token @brief - This API will verify the attestation token
@ -324,60 +297,67 @@ int32_t pal_initial_attest_verify_token(uint8_t *challenge, uint32_t challenge_s
* Only COSE_SIGN1 is supported now. * Only COSE_SIGN1 is supported now.
*/ */
if (item.uDataType != QCBOR_TYPE_ARRAY || item.val.uCount != 4 || if (item.uDataType != QCBOR_TYPE_ARRAY || item.val.uCount != 4 ||
!QCBORDecode_IsTagged(&decode_context, &item, CBOR_TAG_COSE_SIGN1)) !QCBORDecode_IsTagged(&decode_context, &item, CBOR_TAG_COSE_SIGN1)) {
return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING;
}
/* Get the next headers */ /* Get the next headers */
QCBORDecode_GetNext(&decode_context, &item); QCBORDecode_GetNext(&decode_context, &item);
if (item.uDataType != QCBOR_TYPE_BYTE_STRING) if (item.uDataType != QCBOR_TYPE_BYTE_STRING) {
return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING;
}
protected_headers = item.val.string; protected_headers = item.val.string;
/* Parse the protected headers and check the data type and value*/ /* Parse the protected headers and check the data type and value*/
status = parse_protected_headers(protected_headers, &cose_algorithm_id); status = parse_protected_headers(protected_headers, &cose_algorithm_id);
if (status != PAL_ATTEST_SUCCESS) if (status != PAL_ATTEST_SUCCESS) {
return status; return status;
}
/* Parse the unprotected headers and check the data type and value */ /* Parse the unprotected headers and check the data type and value */
short_circuit = false; short_circuit = false;
status = parse_unprotected_headers(&decode_context, &kid, &short_circuit); status = parse_unprotected_headers(&decode_context, &kid, &short_circuit);
if (status != PAL_ATTEST_SUCCESS) if (status != PAL_ATTEST_SUCCESS) {
return status; return status;
}
/* Get the payload */ /* Get the payload */
QCBORDecode_GetNext(&decode_context, &item); QCBORDecode_GetNext(&decode_context, &item);
if (item.uDataType != QCBOR_TYPE_BYTE_STRING) if (item.uDataType != QCBOR_TYPE_BYTE_STRING) {
return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING;
}
payload = item.val.string; payload = item.val.string;
/* Get the digital signature */ /* Get the digital signature */
QCBORDecode_GetNext(&decode_context, &item); QCBORDecode_GetNext(&decode_context, &item);
if (item.uDataType != QCBOR_TYPE_BYTE_STRING) if (item.uDataType != QCBOR_TYPE_BYTE_STRING) {
return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING;
}
/* Initialize the Decoder and validate the payload format */ /* Initialize the Decoder and validate the payload format */
QCBORDecode_Init(&decode_context, payload, QCBOR_DECODE_MODE_NORMAL); QCBORDecode_Init(&decode_context, payload, QCBOR_DECODE_MODE_NORMAL);
status = QCBORDecode_GetNext(&decode_context, &item); status = QCBORDecode_GetNext(&decode_context, &item);
if (status != PAL_ATTEST_SUCCESS) if (status != PAL_ATTEST_SUCCESS) {
return status; return status;
}
if (item.uDataType != QCBOR_TYPE_MAP) if (item.uDataType != QCBOR_TYPE_MAP) {
return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING; return PAL_ATTEST_TOKEN_ERR_CBOR_FORMATTING;
}
/* Parse the payload and check the data type of each claim */ /* Parse the payload and check the data type of each claim */
status = parse_claims(&decode_context, item, completed_challenge); status = parse_claims(&decode_context, item, completed_challenge);
if (status != PAL_ATTEST_SUCCESS) if (status != PAL_ATTEST_SUCCESS) {
return status; return status;
}
if ((mandatory_claims & MANDATORY_CLAIM_WITH_SW_COMP) == MANDATORY_CLAIM_WITH_SW_COMP) if ((mandatory_claims & MANDATORY_CLAIM_WITH_SW_COMP) == MANDATORY_CLAIM_WITH_SW_COMP) {
{ if ((mandaroty_sw_components & MANDATORY_SW_COMP) != MANDATORY_SW_COMP) {
if ((mandaroty_sw_components & MANDATORY_SW_COMP) != MANDATORY_SW_COMP)
return PAL_ATTEST_TOKEN_NOT_ALL_MANDATORY_CLAIMS; return PAL_ATTEST_TOKEN_NOT_ALL_MANDATORY_CLAIMS;
} }
else if ((mandatory_claims & MANDATORY_CLAIM_NO_SW_COMP) != MANDATORY_CLAIM_NO_SW_COMP) } else if ((mandatory_claims & MANDATORY_CLAIM_NO_SW_COMP) != MANDATORY_CLAIM_NO_SW_COMP) {
{
return PAL_ATTEST_TOKEN_NOT_ALL_MANDATORY_CLAIMS; return PAL_ATTEST_TOKEN_NOT_ALL_MANDATORY_CLAIMS;
} }

View File

@ -5,7 +5,9 @@
void pal_mbed_os_compliance_test_initialize(void); void pal_mbed_os_compliance_test_initialize(void);
void pal_mbed_os_compliance_test_destroy(void); void pal_mbed_os_compliance_test_destroy(void);
#ifdef __cplusplus
extern "C" { extern "C" {
#endif
@ -31,12 +33,9 @@ void mbed_val_test_exit(void)
uint32_t status = mbed_val_get_status(); uint32_t status = mbed_val_get_status();
pal_mbed_os_compliance_test_destroy(); pal_mbed_os_compliance_test_destroy();
/* return if test skipped or failed */ /* return if test skipped or failed */
if (IS_TEST_FAIL(status) || IS_TEST_SKIP(status)) if (IS_TEST_FAIL(status) || IS_TEST_SKIP(status)) {
{
GREENTEA_TESTSUITE_RESULT(false); GREENTEA_TESTSUITE_RESULT(false);
} } else {
else
{
GREENTEA_TESTSUITE_RESULT(true); GREENTEA_TESTSUITE_RESULT(true);
mbed_val_set_status(RESULT_END(VAL_STATUS_SUCCESS)); mbed_val_set_status(RESULT_END(VAL_STATUS_SUCCESS));
} }
@ -64,25 +63,20 @@ val_status_t mbed_val_execute_non_secure_tests(uint32_t test_num, client_test_t
test_info.test_num = test_num; test_info.test_num = test_num;
mbed_val_print(PRINT_TEST, "[Info] Executing tests from non-secure\n", 0); mbed_val_print(PRINT_TEST, "[Info] Executing tests from non-secure\n", 0);
while (tests_list[i] != NULL) while (tests_list[i] != NULL) {
{
memset(testcase_name, 0, 100); memset(testcase_name, 0, 100);
sprintf(testcase_name, "Check%" PRIu32, i); sprintf(testcase_name, "Check%" PRIu32, i);
GREENTEA_TESTCASE_START(testcase_name); GREENTEA_TESTCASE_START(testcase_name);
if (server_hs == TRUE) if (server_hs == TRUE) {
{
/* Handshake with server tests */ /* Handshake with server tests */
test_info.block_num = i; test_info.block_num = i;
status = mbed_val_execute_secure_test_func(&handle, test_info, status = mbed_val_execute_secure_test_func(&handle, test_info,
SERVER_TEST_DISPATCHER_SID); SERVER_TEST_DISPATCHER_SID);
if (VAL_ERROR(status)) if (VAL_ERROR(status)) {
{
mbed_val_set_status(RESULT_FAIL(status)); mbed_val_set_status(RESULT_FAIL(status));
mbed_val_print(PRINT_ERROR, "[Check%d] START\n", i); mbed_val_print(PRINT_ERROR, "[Check%d] START\n", i);
return status; return status;
} } else {
else
{
mbed_val_print(PRINT_DEBUG, "[Check%d] START\n", i); mbed_val_print(PRINT_DEBUG, "[Check%d] START\n", i);
} }
} }
@ -90,42 +84,36 @@ val_status_t mbed_val_execute_non_secure_tests(uint32_t test_num, client_test_t
/* Execute client tests */ /* Execute client tests */
test_status = tests_list[i](CALLER_NONSECURE); test_status = tests_list[i](CALLER_NONSECURE);
if (server_hs == TRUE) if (server_hs == TRUE) {
{
/* Retrive Server test status */ /* Retrive Server test status */
status = mbed_val_get_secure_test_result(&handle); status = mbed_val_get_secure_test_result(&handle);
} }
if (test_status != VAL_STATUS_SUCCESS) if (test_status != VAL_STATUS_SUCCESS) {
{
status = VAL_STATUS_ERROR; status = VAL_STATUS_ERROR;
} }
if (IS_TEST_SKIP(status)) if (IS_TEST_SKIP(status)) {
{
mbed_val_set_status(status); mbed_val_set_status(status);
mbed_val_print(PRINT_DEBUG, "[Check%d] SKIPPED\n", i); mbed_val_print(PRINT_DEBUG, "[Check%d] SKIPPED\n", i);
GREENTEA_TESTCASE_FINISH(testcase_name, 1, 0); GREENTEA_TESTCASE_FINISH(testcase_name, 1, 0);
continue_test = false; continue_test = false;
} } else if (VAL_ERROR(status)) {
else if (VAL_ERROR(status))
{
mbed_val_set_status(RESULT_FAIL(status)); mbed_val_set_status(RESULT_FAIL(status));
if (server_hs == TRUE) if (server_hs == TRUE) {
mbed_val_print(PRINT_ERROR, "[Check%d] FAILED\n", i); mbed_val_print(PRINT_ERROR, "[Check%d] FAILED\n", i);
}
GREENTEA_TESTCASE_FINISH(testcase_name, 0, 1); GREENTEA_TESTCASE_FINISH(testcase_name, 0, 1);
continue_test = false; continue_test = false;
} } else {
else if (server_hs == TRUE) {
{
if (server_hs == TRUE)
mbed_val_print(PRINT_DEBUG, "[Check%d] PASSED\n", i); mbed_val_print(PRINT_DEBUG, "[Check%d] PASSED\n", i);
}
GREENTEA_TESTCASE_FINISH(testcase_name, 1, 0); GREENTEA_TESTCASE_FINISH(testcase_name, 1, 0);
continue_test = true; continue_test = true;
} }
if (!continue_test) if (!continue_test) {
{
return status; return status;
} }
@ -172,8 +160,7 @@ val_status_t mbed_val_execute_secure_test_func(psa_handle_t *handle, test_info_t
psa_status_t status_of_call = PSA_SUCCESS; psa_status_t status_of_call = PSA_SUCCESS;
*handle = pal_ipc_connect(sid, 0); *handle = pal_ipc_connect(sid, 0);
if (*handle < 0) if (*handle < 0) {
{
mbed_val_print(PRINT_ERROR, "Could not connect SID. Handle=%x\n", *handle); mbed_val_print(PRINT_ERROR, "Could not connect SID. Handle=%x\n", *handle);
return VAL_STATUS_CONNECTION_FAILED; return VAL_STATUS_CONNECTION_FAILED;
} }
@ -182,8 +169,7 @@ val_status_t mbed_val_execute_secure_test_func(psa_handle_t *handle, test_info_t
psa_invec data[1] = {{&test_data, sizeof(test_data)}}; psa_invec data[1] = {{&test_data, sizeof(test_data)}};
status_of_call = pal_ipc_call(*handle, data, 1, NULL, 0); status_of_call = pal_ipc_call(*handle, data, 1, NULL, 0);
if (status_of_call != PSA_SUCCESS) if (status_of_call != PSA_SUCCESS) {
{
status = VAL_STATUS_CALL_FAILED; status = VAL_STATUS_CALL_FAILED;
mbed_val_print(PRINT_ERROR, "Call to dispatch SF failed. Status=%x\n", status_of_call); mbed_val_print(PRINT_ERROR, "Call to dispatch SF failed. Status=%x\n", status_of_call);
pal_ipc_close(*handle); pal_ipc_close(*handle);
@ -229,8 +215,7 @@ val_status_t mbed_val_get_secure_test_result(psa_handle_t *handle)
psa_invec data[1] = {{&test_data, sizeof(test_data)}}; psa_invec data[1] = {{&test_data, sizeof(test_data)}};
status_of_call = pal_ipc_call(*handle, data, 1, &resp, 1); status_of_call = pal_ipc_call(*handle, data, 1, &resp, 1);
if (status_of_call != PSA_SUCCESS) if (status_of_call != PSA_SUCCESS) {
{
status = VAL_STATUS_CALL_FAILED; status = VAL_STATUS_CALL_FAILED;
mbed_val_print(PRINT_ERROR, "Call to dispatch SF failed. Status=%x\n", status_of_call); mbed_val_print(PRINT_ERROR, "Call to dispatch SF failed. Status=%x\n", status_of_call);
} }
@ -250,8 +235,7 @@ val_status_t mbed_val_ipc_connect(uint32_t sid, uint32_t minor_version, psa_hand
{ {
*handle = pal_ipc_connect(sid, minor_version); *handle = pal_ipc_connect(sid, minor_version);
if (*handle < 0) if (*handle < 0) {
{
return VAL_STATUS_CONNECTION_FAILED; return VAL_STATUS_CONNECTION_FAILED;
} }
@ -276,8 +260,7 @@ val_status_t mbed_val_ipc_call(psa_handle_t handle, psa_invec *in_vec, size_t in
call_status = pal_ipc_call(handle, in_vec, in_len, out_vec, out_len); call_status = pal_ipc_call(handle, in_vec, in_len, out_vec, out_len);
if (call_status != PSA_SUCCESS) if (call_status != PSA_SUCCESS) {
{
return VAL_STATUS_CALL_FAILED; return VAL_STATUS_CALL_FAILED;
} }
@ -309,7 +292,7 @@ val_status_t mbed_val_wd_reprogram_timer(wd_timeout_type_t timeout_type)
return VAL_STATUS_SUCCESS; return VAL_STATUS_SUCCESS;
} }
#ifdef __cplusplus
} // extern "C" } // extern "C"
#endif