Example for the Branch functionality of the Flow Protection component.
#include <mcuxCsslExamples.h>
#define MCUXCLCSSLFLOWPROTECTION_OK 0x2EDEu
#define MCUXCLCSSLFLOWPROTECTION_NOT_OK 0x89ADu
#define MCUXCLCSSLFLOWPROTECTION_FAULT_ATTACK 0xF0FAu
{
uint32_t result;
if (MCUXCLCSSLFLOWPROTECTION_OK == arg)
{
result = MCUXCLCSSLFLOWPROTECTION_OK;
}
else
{
result = MCUXCLCSSLFLOWPROTECTION_NOT_OK;
}
)
);
}
{
uint32_t result;
if (MCUXCLCSSLFLOWPROTECTION_OK == arg)
{
result = MCUXCLCSSLFLOWPROTECTION_OK;
}
else
{
result = MCUXCLCSSLFLOWPROTECTION_NOT_OK;
}
}
{
uint32_t result;
switch (arg)
{
case MCUXCLCSSLFLOWPROTECTION_OK:
{
result = MCUXCLCSSLFLOWPROTECTION_OK;
break;
}
case MCUXCLCSSLFLOWPROTECTION_NOT_OK:
{
result = MCUXCLCSSLFLOWPROTECTION_NOT_OK;
break;
}
default:
{
result = 0;
break;
}
}
)
);
}
MCUX_CSSL_EX_FUNCTION(mcuxCsslFlowProtection_Branch_example)
{
if (MCUXCLCSSLFLOWPROTECTION_OK != returnCode)
{
return MCUX_CSSL_EX_ERROR;
}
#if !defined(MCUX_CSSL_FP_USE_CODE_SIGNATURE) && !defined(MCUX_CSSL_FP_USE_NONE)
{
return MCUX_CSSL_EX_ERROR;
}
#else
(void) token0;
#endif
if (MCUXCLCSSLFLOWPROTECTION_OK != returnCode1)
{
return MCUX_CSSL_EX_ERROR;
}
#if !defined(MCUX_CSSL_FP_USE_CODE_SIGNATURE) && !defined(MCUX_CSSL_FP_USE_NONE)
{
return MCUX_CSSL_EX_ERROR;
}
#else
(void) token1;
#endif
if (MCUXCLCSSLFLOWPROTECTION_OK != returnCode2)
{
return MCUX_CSSL_EX_ERROR;
}
#if !defined(MCUX_CSSL_FP_USE_CODE_SIGNATURE) && !defined(MCUX_CSSL_FP_USE_NONE)
{
return MCUX_CSSL_EX_ERROR;
}
#else
(void) token2;
#endif
return MCUX_CSSL_EX_OK;
}
Provides the API for the CSSL flow protection mechanism.
Definition of function identifiers for the flow protection mechanism.
#define MCUX_CSSL_FP_FUNCTION_DECL(...)
Declaration of a flow protected function.
Definition mcuxCsslFlowProtection.h:166
#define MCUX_CSSL_FP_FUNCTION_ENTRY(...)
Flow protection handler for the function entry point.
Definition mcuxCsslFlowProtection.h:285
#define MCUX_CSSL_FP_PROTECTED_TYPE(resultType)
Based on a given base type, builds a return type with flow protection.
Definition mcuxCsslFlowProtection.h:138
#define MCUX_CSSL_FP_FUNCTION_DEF(...)
Definition of a flow protected function.
Definition mcuxCsslFlowProtection.h:200
#define MCUX_CSSL_FP_FUNCTION_EXIT_WITH_CHECK(...)
Flow protection handler for the function exit point which includes an actual check of the code flow.
Definition mcuxCsslFlowProtection.h:367
#define MCUX_CSSL_FP_FUNCTION_EXIT(...)
Flow protection handler for the function exit point.
Definition mcuxCsslFlowProtection.h:328
#define MCUX_CSSL_FP_FUNCTION_CALLED(...)
Expectation of a called function.
Definition mcuxCsslFlowProtection.h:777
#define MCUX_CSSL_FP_FUNCTION_CALL_PROTECTED(...)
Call a flow protected function from unprotected code.
Definition mcuxCsslFlowProtection.h:547
#define MCUX_CSSL_FP_BRANCH_DECL(id)
Declaration of a flow protected branch.
Definition mcuxCsslFlowProtection.h:981
#define MCUX_CSSL_FP_BRANCH_NEGATIVE(...)
Negative scenario of a branch is executed.
Definition mcuxCsslFlowProtection.h:1045
#define MCUX_CSSL_FP_BRANCH_TAKEN_NEGATIVE(...)
Expectation that negative branch has been taken.
Definition mcuxCsslFlowProtection.h:1117
#define MCUX_CSSL_FP_BRANCH_TAKEN_POSITIVE(...)
Expectation that positive branch has been taken.
Definition mcuxCsslFlowProtection.h:1089
#define MCUX_CSSL_FP_BRANCH_POSITIVE(...)
Positive scenario for a branch is executed.
Definition mcuxCsslFlowProtection.h:1021
#define MCUX_CSSL_FP_SWITCH_TAKEN(...)
Expected that a specific case is handled from a switch.
Definition mcuxCsslFlowProtection.h:1329
#define MCUX_CSSL_FP_SWITCH_CASE(...)
Case that is being handled from a switch.
Definition mcuxCsslFlowProtection.h:1227
#define MCUX_CSSL_FP_SWITCH_TAKEN_DEFAULT(...)
Expected that default case is handled from a switch.
Definition mcuxCsslFlowProtection.h:1381
#define MCUX_CSSL_FP_SWITCH_DEFAULT(...)
Case that is being handled from a switch.
Definition mcuxCsslFlowProtection.h:1275
#define MCUX_CSSL_FP_SWITCH_DECL(id)
Declaration of a flow protected switch.
Definition mcuxCsslFlowProtection.h:1178
#define MCUX_CSSL_FP_CONDITIONAL(condition,...)
Handling of conditionally expected code flow behavior.
Definition mcuxCsslFlowProtection.h:1443