MCUX CLNS MCUX Crypto Library Normal Secure |

Macros
Switching flow protection
MCUX CSSL &ndash; API » Flow Protection API

Support for flow protected switches. More...

## Macros

#define | MCUX_CSSL_FP_SWITCH_DECL(id)
| Declaration of a flow protected switch. More...
#define | MCUX_CSSL_FP_SWITCH_CASE(...)
| Case that is being handled from a switch. More...
#define | MCUX_CSSL_FP_SWITCH_DEFAULT(...)
| Case that is being handled from a switch. More...
#define | MCUX_CSSL_FP_SWITCH_TAKEN(...)
| Expected that a specific case is handled from a switch. More...
#define | MCUX_CSSL_FP_SWITCH_TAKEN_DEFAULT(...)
| Expected that default case is handled from a switch. More...

## Detailed Description

Support for flow protected switches.

Declaration
  MCUX_CSSL_FP_SWITCH_DECL

Events
  MCUX_CSSL_FP_SWITCH_CASE
  MCUX_CSSL_FP_SWITCH_DEFAULT

Expectations
  MCUX_CSSL_FP_SWITCH_TAKEN
  MCUX_CSSL_FP_SWITCH_TAKEN_DEFAULT

## Macro Definition Documentation

## ◆ MCUX_CSSL_FP_SWITCH_DECL

#define MCUX_CSSL_FP_SWITCH_DECL | ( |  | id | ) |

Declaration of a flow protected switch.

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

MCUX_CSSL_FP_SWITCH_DECL(someSwitchIdentifier);
switch (arg)
{
case 0xC0DEu:
{
result = 0xC0DEu;
MCUX_CSSL_FP_SWITCH_CASE(someSwitchIdentifier, 0xC0DEu);
break;
}
default:
{
result = 0;
MCUX_CSSL_FP_SWITCH_DEFAULT(someSwitchIdentifier);
break;
}
}
// ...
MCUX_CSSL_FP_FUNCTION_EXIT(someFunction, result,
// Option 1: provide the condition as part of the switch expectation.
MCUX_CSSL_FP_SWITCH_TAKEN(someSwitchIdentifier, 0xC0DEu, 0xC0DEu == arg),
// Option 2: place the switch expectation in a conditional block.
MCUX_CSSL_FP_CONDITIONAL(0xC0DEu != arg),
MCUX_CSSL_FP_SWITCH_TAKEN_DEFAULT(someSwitchIdentifier)
)
);

Events
  MCUX_CSSL_FP_SWITCH_CASE
  MCUX_CSSL_FP_SWITCH_DEFAULT

Expectations
  MCUX_CSSL_FP_SWITCH_TAKEN
  MCUX_CSSL_FP_SWITCH_TAKEN_DEFAULT

Parameters

  id | Identifier for the switch that is flow protected.

## ◆ MCUX_CSSL_FP_SWITCH_CASE

#define MCUX_CSSL_FP_SWITCH_CASE | ( |  | ... | ) |

Case that is being handled from a switch.

This switch event macro informs the flow mechanism that the given `case` of the switch is executed for the switch declared by MCUX_CSSL_FP_SWITCH_DECL with the given `id`. For example:

MCUX_CSSL_FP_SWITCH_DECL(someSwitchIdentifier);
switch (arg)
{
case 0xC0DEu:
{
result = 0xC0DEu;
MCUX_CSSL_FP_SWITCH_CASE(someSwitchIdentifier, 0xC0DEu);
break;
}
default:
{
result = 0;
MCUX_CSSL_FP_SWITCH_DEFAULT(someSwitchIdentifier);
break;
}
}
// ...
MCUX_CSSL_FP_FUNCTION_EXIT(someFunction, result,
// Option 1: provide the condition as part of the switch expectation.
MCUX_CSSL_FP_SWITCH_TAKEN(someSwitchIdentifier, 0xC0DEu, 0xC0DEu == arg),
// Option 2: place the switch expectation in a conditional block.
MCUX_CSSL_FP_CONDITIONAL(0xC0DEu != arg),
MCUX_CSSL_FP_SWITCH_TAKEN_DEFAULT(someSwitchIdentifier)
)
);

Declaration
  MCUX_CSSL_FP_SWITCH_DECL

Expectation
  MCUX_CSSL_FP_SWITCH_TAKEN

Parameters

  ... | The following parameters need to be passed (comma separated):
  - id: Identifier of the flow protected switch.
  - case: Case value that is chosen in the switch.
  - expect: Zero or more (comma separated) declarations of expected code flow behavior related to this event.

## ◆ MCUX_CSSL_FP_SWITCH_DEFAULT

#define MCUX_CSSL_FP_SWITCH_DEFAULT | ( |  | ... | ) |

Case that is being handled from a switch.

This switch event macro informs the flow mechanism that the default case of the switch is executed for the switch declared by MCUX_CSSL_FP_SWITCH_DECL with the given `id`. For example:

MCUX_CSSL_FP_SWITCH_DECL(someSwitchIdentifier);
switch (arg)
{
case 0xC0DEu:
{
result = 0xC0DEu;
MCUX_CSSL_FP_SWITCH_CASE(someSwitchIdentifier, 0xC0DEu);
break;
}
default:
{
result = 0;
MCUX_CSSL_FP_SWITCH_DEFAULT(someSwitchIdentifier);
break;
}
}
MCUX_CSSL_FP_FUNCTION_EXIT(someFunction, result,
// Option 1: provide the condition as part of the switch expectation.
MCUX_CSSL_FP_SWITCH_TAKEN(argCheck, 0xC0DEu, 0xC0DEu == arg),
// Option 2: place the switch expectation in a conditional block.
MCUX_CSSL_FP_CONDITIONAL(0xC0DEu != arg),
MCUX_CSSL_FP_SWITCH_TAKEN_DEFAULT(someSwitchIdentifier)
)
);

Declaration
  MCUX_CSSL_FP_SWITCH_DECL

Expectation
  MCUX_CSSL_FP_SWITCH_TAKEN_DEFAULT

Parameters

  ... | The following parameters need to be passed (comma separated):
  - id: Identifier of the flow protected switch.
  - expect: Zero or more (comma separated) declarations of expected code flow behavior related to this event.

## ◆ MCUX_CSSL_FP_SWITCH_TAKEN

#define MCUX_CSSL_FP_SWITCH_TAKEN | ( |  | ... | ) |

Expected that a specific case is handled from a switch.

This expectation macro indicates to the flow protection mechanism that the switch declared by MCUX_CSSL_FP_SWITCH_DECL with the given `id` has executed the `case` (under the given `condition`). For example:

MCUX_CSSL_FP_SWITCH_DECL(someSwitchIdentifier);
switch (arg)
{
case 0xC0DEu:
{
result = 0xC0DEu;
MCUX_CSSL_FP_SWITCH_CASE(someSwitchIdentifier, 0xC0DEu);
break;
}
default:
{
result = 0;
MCUX_CSSL_FP_SWITCH_DEFAULT(someSwitchIdentifier);
break;
}
}
MCUX_CSSL_FP_FUNCTION_EXIT(someFunction, result,
// Option 1: provide the condition as part of the switch expectation.
MCUX_CSSL_FP_SWITCH_TAKEN(argCheck, 0xC0DEu, 0xC0DEu == arg),
// Option 2: place the switch expectation in a conditional block.
MCUX_CSSL_FP_CONDITIONAL(0xC0DEu != arg),
MCUX_CSSL_FP_SWITCH_TAKEN_DEFAULT(someSwitchIdentifier)
)
);

Declaration
  MCUX_CSSL_FP_SWITCH_DECL

Event
  MCUX_CSSL_FP_SWITCH_CASE

See also
  MCUX_CSSL_FP_FUNCTION_ENTRY
  MCUX_CSSL_FP_FUNCTION_EXIT
  MCUX_CSSL_FP_FUNCTION_EXIT_WITH_CHECK
  MCUX_CSSL_FP_EXPECT

Parameters

  ... | The following parameters need to be passed (comma separated):
  - id: Identifier of the flow protected switch.
  - case: Value of the case that is expected to be chosen in the switch.
  - condition: Optional, condition under which the `case` is taken.

## ◆ MCUX_CSSL_FP_SWITCH_TAKEN_DEFAULT

#define MCUX_CSSL_FP_SWITCH_TAKEN_DEFAULT | ( |  | ... | ) |

Expected that default case is handled from a switch.

This expectation macro indicates to the flow protection mechanism that the switch declared by MCUX_CSSL_FP_SWITCH_DECL with the given `id` has executed the default case (under the given `condition`). For example:

MCUX_CSSL_FP_SWITCH_DECL(someSwitchIdentifier);
switch (arg)
{
case 0xC0DEu:
{
result = 0xC0DEu;
MCUX_CSSL_FP_SWITCH_CASE(someSwitchIdentifier, 0xC0DEu);
break;
}
default:
{
result = 0;
MCUX_CSSL_FP_SWITCH_DEFAULT(someSwitchIdentifier);
break;
}
}
MCUX_CSSL_FP_FUNCTION_EXIT(someFunction, result,
// Option 1: provide the condition as part of the switch expectation.
MCUX_CSSL_FP_SWITCH_TAKEN(argCheck, 0xC0DEu, 0xC0DEu == arg),
// Option 2: place the switch expectation in a conditional block.
MCUX_CSSL_FP_CONDITIONAL(0xC0DEu != arg),
MCUX_CSSL_FP_SWITCH_TAKEN_DEFAULT(someSwitchIdentifier)
)
);

Declaration
  MCUX_CSSL_FP_SWITCH_DECL

Event
  MCUX_CSSL_FP_SWITCH_DEFAULT

See also
  MCUX_CSSL_FP_FUNCTION_ENTRY
  MCUX_CSSL_FP_FUNCTION_EXIT
  MCUX_CSSL_FP_FUNCTION_EXIT_WITH_CHECK
  MCUX_CSSL_FP_EXPECT

Parameters

  ... | The following parameters need to be passed (comma separated):
  - id: Identifier of the flow protected switch.
  - condition: Optional, condition under which the default case is taken.