MCUX CLNS
MCUX Crypto Library Normal Secure
Loading...
Searching...
No Matches
Branching flow protection

Support for flow protected branches. More...

Macros

#define MCUX_CSSL_FP_BRANCH_DECL(id)
 Declaration of a flow protected branch.
#define MCUX_CSSL_FP_BRANCH_POSITIVE(...)
 Positive scenario for a branch is executed.
#define MCUX_CSSL_FP_BRANCH_NEGATIVE(...)
 Negative scenario of a branch is executed.
#define MCUX_CSSL_FP_BRANCH_TAKEN_POSITIVE(...)
 Expectation that positive branch has been taken.
#define MCUX_CSSL_FP_BRANCH_TAKEN_NEGATIVE(...)
 Expectation that negative branch has been taken.

Detailed Description

Support for flow protected branches.

This subset of Flow protection macros is used to protect positive/negative branches (if, else).

The mechanism allows to check that the expected case was taken, but not necessarily that the entire case was executed.

Important note:

For this protection to work, both if and else cases need to be present, even if empty besides the MCUX_CSSL_FP_BRANCH_POSITIVE or MCUX_CSSL_FP_BRANCH_NEGATIVE macro usage.

Both cases need either MCUX_CSSL_FP_BRANCH_POSITIVE or MCUX_CSSL_FP_BRANCH_NEGATIVE (not both, not none).

Every MCUX_CSSL_FP_BRANCH_POSITIVE macro use needs to be balanced with MCUX_CSSL_FP_BRANCH_TAKEN_POSITIVE, specifying a matching condition. (Same for MCUX_CSSL_FP_BRANCH_NEGATIVE with MCUX_CSSL_FP_BRANCH_TAKEN_NEGATIVE).

See also
mcuxCsslFlowProtection_Branch_example.c
Declaration
MCUX_CSSL_FP_BRANCH_DECL
Events
MCUX_CSSL_FP_BRANCH_POSITIVE
MCUX_CSSL_FP_BRANCH_NEGATIVE
Expectations
MCUX_CSSL_FP_BRANCH_TAKEN_POSITIVE
MCUX_CSSL_FP_BRANCH_TAKEN_NEGATIVE

Macro Definition Documentation

◆ MCUX_CSSL_FP_BRANCH_DECL

#define MCUX_CSSL_FP_BRANCH_DECL ( id)

Declaration of a flow protected branch.

To inform the flow protection mechanism about a branch that needs to be protected, a branch identifier needs to be declared. This identifier can then be used in the events and expectation macros. For example:

MCUX_CSSL_FP_BRANCH_DECL(someBranchIdentifier);
if (condition)
{
MCUX_CSSL_FP_BRANCH_POSITIVE(someBranchIdentifier);
}
else
{
MCUX_CSSL_FP_BRANCH_NEGATIVE(someBranchIdentifier);
}
// ...
MCUX_CSSL_FP_BRANCH_TAKEN_POSITIVE(someBranchIdentifier, condition),
MCUX_CSSL_FP_BRANCH_TAKEN_NEGATIVE(someBranchIdentifier, !condition)
);
#define MCUX_CSSL_FP_FUNCTION_EXIT(...)
Flow protection handler for the function exit point.
Definition mcuxCsslFlowProtection.h:328
#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
Events
MCUX_CSSL_FP_BRANCH_POSITIVE
MCUX_CSSL_FP_BRANCH_NEGATIVE
Expectations
MCUX_CSSL_FP_BRANCH_TAKEN_POSITIVE
MCUX_CSSL_FP_BRANCH_TAKEN_NEGATIVE
Parameters
idIdentifier for the branch that is flow protected.
Examples
mcuxCsslFlowProtection_Branch_example.c.

◆ MCUX_CSSL_FP_BRANCH_POSITIVE

#define MCUX_CSSL_FP_BRANCH_POSITIVE ( ...)

Positive scenario for a branch is executed.

This branch event macro informs the flow mechanism that the positive scenario of the branch is executed for the branch declared by MCUX_CSSL_FP_BRANCH_DECL with the given id. For example:

MCUX_CSSL_FP_BRANCH_DECL(someBranchIdentifier);
if (condition)
{
MCUX_CSSL_FP_BRANCH_POSITIVE(someBranchIdentifier);
}
else
{
MCUX_CSSL_FP_BRANCH_NEGATIVE(someBranchIdentifier);
}
// ...
MCUX_CSSL_FP_BRANCH_TAKEN_POSITIVE(someBranchIdentifier)),
MCUX_CSSL_FP_BRANCH_TAKEN_NEGATIVE(someBranchIdentifier))
);
#define MCUX_CSSL_FP_CONDITIONAL_IMPL(condition,...)
Conditional expectation aggregation.
Definition mcuxCsslFlowProtection_None.h:70
Declaration
MCUX_CSSL_FP_BRANCH_DECL
Expectation
MCUX_CSSL_FP_BRANCH_TAKEN_POSITIVE
Parameters
...The following parameters need to be passed (comma separated):
  • id: Identifier for the branch for which the positive scenario is executed.
  • expect: Zero or more (comma separated) declarations of expected code flow behavior related to this event.
Examples
mcuxCsslFlowProtection_Branch_example.c.

◆ MCUX_CSSL_FP_BRANCH_NEGATIVE

#define MCUX_CSSL_FP_BRANCH_NEGATIVE ( ...)

Negative scenario of a branch is executed.

This branch event macro informs the flow mechanism that the positive scenario of the branch is executed for the branch declared by MCUX_CSSL_FP_BRANCH_DECL with the given id.

For example usage see MCUX_CSSL_FP_BRANCH_POSITIVE.

Declaration
MCUX_CSSL_FP_BRANCH_DECL
Expectation
MCUX_CSSL_FP_BRANCH_TAKEN_NEGATIVE
Parameters
...The following parameters need to be passed (comma separated):
  • id: Identifier for the branch for which the negative scenario is executed.
  • expect: Zero or more (comma separated) declarations of expected code flow behavior related to this event.
Examples
mcuxCsslFlowProtection_Branch_example.c.

◆ MCUX_CSSL_FP_BRANCH_TAKEN_POSITIVE

#define MCUX_CSSL_FP_BRANCH_TAKEN_POSITIVE ( ...)

Expectation that positive branch has been taken.

This expectation macro indicates to the flow protection mechanism that the branch declared by MCUX_CSSL_FP_BRANCH_DECL with the given id has executed the positive scenario (under the given condition). For example:

MCUX_CSSL_FP_BRANCH_DECL(someBranchIdentifier);
if (condition)
{
MCUX_CSSL_FP_BRANCH_POSITIVE(someBranchIdentifier);
}
else
{
MCUX_CSSL_FP_BRANCH_NEGATIVE(someBranchIdentifier);
}
// ...
// Providing the condition as part of the branch expectation.
// Alternatively, the expectation can be placed in a conditional block.
MCUX_CSSL_FP_BRANCH_TAKEN_POSITIVE(someBranchIdentifier, condition),
MCUX_CSSL_FP_BRANCH_TAKEN_NEGATIVE(someBranchIdentifier, !condition)
);
Declaration
MCUX_CSSL_FP_BRANCH_DECL
Event
MCUX_CSSL_FP_BRANCH_POSITIVE
See also
MCUX_CSSL_FP_FUNCTION_ENTRY
MCUX_CSSL_FP_FUNCTION_EXIT
MCUX_CSSL_FP_FUNCTION_EXIT_WITH_CHECK
MCUX_CSSL_FP_EXPECT
MCUX_CSSL_FP_CONDITIONAL
Parameters
...The following parameters need to be passed (comma separated):
  • id: Identifier of the flow protected branch.
  • condition: Optional, condition under which this branch is taken.
Examples
mcuxCsslFlowProtection_Branch_example.c.

◆ MCUX_CSSL_FP_BRANCH_TAKEN_NEGATIVE

#define MCUX_CSSL_FP_BRANCH_TAKEN_NEGATIVE ( ...)

Expectation that negative branch has been taken.

This expectation macro indicates to the flow protection mechanism that the branch declared by MCUX_CSSL_FP_BRANCH_DECL with the given id has executed the negative scenario (under the given condition).

For example usage see MCUX_CSSL_FP_BRANCH_TAKEN_POSITIVE.

Declaration
MCUX_CSSL_FP_BRANCH_DECL
Event
MCUX_CSSL_FP_BRANCH_NEGATIVE
See also
MCUX_CSSL_FP_FUNCTION_ENTRY
MCUX_CSSL_FP_FUNCTION_EXIT
MCUX_CSSL_FP_FUNCTION_EXIT_WITH_CHECK
MCUX_CSSL_FP_EXPECT
MCUX_CSSL_FP_CONDITIONAL
Parameters
...The following parameters need to be passed (comma separated):
  • id: Identifier of the flow protected branch.
  • condition: Optional, condition under which this branch is taken.
Examples
mcuxCsslFlowProtection_Branch_example.c.