TAMP Exported Functions

HAL TAMP passive tamper mode functions

group TAMP_Exported_Functions_Passive

In passive mode the tampers inputs are monitored and a tamper is detected either on edge or level detection. Those different detection types can be configured by changing the parameters of a digital filter that are common for all the passive tampers. This filter is used to avoid false tamper detection. The passive tampers can work in confirmed or potential modes.

Passive tampers

Edge detection

Edge mode consists of a tamper event generation when either a rising or falling edge is observed. To configure the tampers in edge mode, the application must call HAL_TAMP_PASSIVE_SetConfig with hal_tamp_passive_config_t::type_activation set to HAL_TAMP_PASSIVE_FILTER_DISABLE. The parameter hal_tamp_passive_individual_config_t::trigger must be set to the desired edge type by calling the HAL_TAMP_PASSIVE_SetConfigTampers .

The user can use this mode of tamper detection with the RTCCLK disabled.

Level detection

Level mode consists of a tamper event generation when two, four or eight consecutive samples are observed at the level configured. Calling the HAL_TAMP_PASSIVE_SetConfigTampers and setting hal_tamp_passive_individual_config_t::trigger enable the configuration of the level. To configure the tampers in level mode, the application must call HAL_TAMP_PASSIVE_SetConfig with hal_tamp_passive_config_t::type_activation set to:

  • HAL_TAMP_PASSIVE_FILTER_2_SAMPLES, for two samples detection.

  • HAL_TAMP_PASSIVE_FILTER_4_SAMPLES, for four samples detection.

  • HAL_TAMP_PASSIVE_FILTER_8_SAMPLES, for eight samples detection.

The sampling frequency is chosen by programming the hal_tamp_passive_config_t::sample_frequency

The inputs can be precharged before sampled during a certain duration, this is configured by calling HAL_TAMP_PASSIVE_SetConfig and programming the parameters hal_tamp_passive_config_t::precharge and hal_tamp_passive_config_t::precharge_duration

Potential and confirmed mode.

Each tamper can work in two modes regarding the device secrets erase. The confirmed mode means that when a tamper event occurs the device secrets are automatically erased. The potential mode does not erase all the device secrets when a tamper event occurs. Instead it blocks the read and write access of the device secrets. The access is unblocked when the tamper event is cleared. To configure the erase mode call HAL_TAMP_PASSIVE_SetConfigTampers and configure the hal_tamp_passive_individual_config_t::erase_secrets parameter.

Masked

Some of the tampers can be masked. This means that the application does not need to clear them after a trigger. If a tamper is masked, triggering the tamper event will not affect the device secrets in any way.

This feature is only available when using passive tampers in level mode and interruption is disabled.

Functions

hal_status_t HAL_TAMP_PASSIVE_SetConfig ( const hal_tamp_passive_config_t * p_config )

Configure the passive tampers global parameters.

Parameters :

p_config – Pointer to the passive tampers global configuration instance.

Return values :

HAL_OK – if the configuration is successful, HAL_INVALID_PARAM if the parameter is invalid.

void HAL_TAMP_PASSIVE_GetConfig ( hal_tamp_passive_config_t * p_config )

Retrieve the passive tamper global parameters.

Parameters :

p_config – Pointer to the passive tampers global configuration instance.

hal_status_t HAL_TAMP_PASSIVE_SetConfigTampers ( uint32_t tampers , const hal_tamp_passive_individual_config_t * p_config )

Configure the passive tampers individual parameters.

Note

Only the three first tampers can be masked.

Parameters :
  • tampers – tampers to be configured, can be a combination of

    • HAL_TAMP_TAMPER_1

    • HAL_TAMP_TAMPER_2

    • HAL_TAMP_TAMPER_3

    • HAL_TAMP_TAMPER_4

    • HAL_TAMP_TAMPER_5

    • HAL_TAMP_TAMPER_6

    • HAL_TAMP_TAMPER_7

    • HAL_TAMP_TAMPER_8

  • p_config – Pointer to the passive tamper individual configuration instance.

Return values :

HAL_OK, HAL_INVALID_PARAM – if the parameter is invalid

void HAL_TAMP_PASSIVE_GetConfigTamper ( uint32_t tamper , hal_tamp_passive_individual_config_t * p_config )

Retrieve the passive tamper individual parameters.

Parameters :
  • tamper – tamper to retrieve the configuration, can be one of the following values

    • HAL_TAMP_TAMPER_1

    • HAL_TAMP_TAMPER_2

    • HAL_TAMP_TAMPER_3

    • HAL_TAMP_TAMPER_4

    • HAL_TAMP_TAMPER_5

    • HAL_TAMP_TAMPER_6

    • HAL_TAMP_TAMPER_7

    • HAL_TAMP_TAMPER_8

  • p_config – Pointer to the passive tamper individual configuration instance.

hal_status_t HAL_TAMP_PASSIVE_Start ( uint32_t tampers , uint32_t interruption )

Start the passive tampers.

Parameters :
  • tampers – tampers to be started, can be a combination of

    • HAL_TAMP_TAMPER_1

    • HAL_TAMP_TAMPER_2

    • HAL_TAMP_TAMPER_3

    • HAL_TAMP_TAMPER_4

    • HAL_TAMP_TAMPER_5

    • HAL_TAMP_TAMPER_6

    • HAL_TAMP_TAMPER_7

    • HAL_TAMP_TAMPER_8

  • interruption – enable the interruption, can be a combination of

    • HAL_TAMP_IT_NONE

    • HAL_TAMP_IT_TAMPER_1

    • HAL_TAMP_IT_TAMPER_2

    • HAL_TAMP_IT_TAMPER_3

    • HAL_TAMP_IT_TAMPER_4

    • HAL_TAMP_IT_TAMPER_5

    • HAL_TAMP_IT_TAMPER_6

    • HAL_TAMP_IT_TAMPER_7

    • HAL_TAMP_IT_TAMPER_8

Return values :
  • HAL_OK

  • HAL_ERROR – If trying to enable an interruption to a masked tamper. or if trying to start a tamper that is already started as active tamper.

hal_status_t HAL_TAMP_PASSIVE_Stop ( uint32_t tampers )

Stop the passive tampers.

Parameters :

tampers – tampers to be stopped, can be a combination of

  • HAL_TAMP_TAMPER_1

  • HAL_TAMP_TAMPER_2

  • HAL_TAMP_TAMPER_3

  • HAL_TAMP_TAMPER_4

  • HAL_TAMP_TAMPER_5

  • HAL_TAMP_TAMPER_6

  • HAL_TAMP_TAMPER_7

  • HAL_TAMP_TAMPER_8

Return values :

HAL_OK

hal_status_t HAL_TAMP_PASSIVE_PollForEvent ( uint32_t tampers , uint32_t timeout_ms )

Poll for a tamper event among tampers given in tampers .

Note

Call HAL_TAMP_PASSIVE_Stop to clear the pending tamper event.

Parameters :
  • tampers – tampers to be checked, can be a combination of

    • HAL_TAMP_TAMPER_1

    • HAL_TAMP_TAMPER_2

    • HAL_TAMP_TAMPER_3

    • HAL_TAMP_TAMPER_4

    • HAL_TAMP_TAMPER_5

    • HAL_TAMP_TAMPER_6

    • HAL_TAMP_TAMPER_7

    • HAL_TAMP_TAMPER_8

  • timeout_ms – Timeout duration

Return values :
  • HAL_OK

  • HAL_TIMEOUT – when reaching the timeout during polling.

HAL TAMP internal tamper mode functions

group TAMP_Exported_Functions_Internal

Internal tamper exported functions.

The internal tampers are tampers linked to a specific part of the microcontroller. They protect the microcontroller device secrets in case of transient or environmental perturbation attacks. They can work in potential or confirmed mode.

Each tamper can work in two modes regarding the device secrets erase. The confirmed mode means that when a tamper event occurs the device secrets are automatically erased. The potential mode does not erase all the device secrets when a tamper event occurs. Instead it blocks the read and write access of the device secrets. The access is unblocked when the tamper event is cleared.

To configure the erase mode call HAL_TAMP_INTERNAL_SetConfigTampers and configure the hal_tamp_internal_individual_config_t::erase_secrets parameter.

Functions

hal_status_t HAL_TAMP_INTERNAL_SetConfigTampers ( uint32_t internal_tampers , const hal_tamp_internal_individual_config_t * p_config )

Configure the internal tampers individual parameters.

Parameters :
  • internal_tampers – tampers to be configured, can be a combination of

    • HAL_TAMP_INTERNAL_TAMPER_1

    • HAL_TAMP_INTERNAL_TAMPER_2

    • HAL_TAMP_INTERNAL_TAMPER_3

    • HAL_TAMP_INTERNAL_TAMPER_5

    • HAL_TAMP_INTERNAL_TAMPER_6

    • HAL_TAMP_INTERNAL_TAMPER_7

    • HAL_TAMP_INTERNAL_TAMPER_8

    • HAL_TAMP_INTERNAL_TAMPER_9

    • HAL_TAMP_INTERNAL_TAMPER_11

    • HAL_TAMP_INTERNAL_TAMPER_12

    • HAL_TAMP_INTERNAL_TAMPER_13

  • p_config – Pointer to the internal tamper individual configuration instance.

Return values :

HAL_OK

void HAL_TAMP_INTERNAL_GetConfigTamper ( uint32_t internal_tamper , hal_tamp_internal_individual_config_t * p_config )

Retrieve the internal tamper individual parameter.

Parameters :
  • internal_tamper – tamper to retrieve the configuration, can be one of the following values

    • HAL_TAMP_INTERNAL_TAMPER_1

    • HAL_TAMP_INTERNAL_TAMPER_2

    • HAL_TAMP_INTERNAL_TAMPER_3

    • HAL_TAMP_INTERNAL_TAMPER_5

    • HAL_TAMP_INTERNAL_TAMPER_6

    • HAL_TAMP_INTERNAL_TAMPER_7

    • HAL_TAMP_INTERNAL_TAMPER_8

    • HAL_TAMP_INTERNAL_TAMPER_9

    • HAL_TAMP_INTERNAL_TAMPER_11

    • HAL_TAMP_INTERNAL_TAMPER_12

    • HAL_TAMP_INTERNAL_TAMPER_13

  • p_config – Pointer to the internal tamper individual configuration instance.

hal_status_t HAL_TAMP_INTERNAL_Start ( uint32_t internal_tampers , uint32_t interruption )

Start the internal tampers.

Parameters :
  • internal_tampers – internal tampers to be started, can be a combination of

    • HAL_TAMP_INTERNAL_TAMPER_1

    • HAL_TAMP_INTERNAL_TAMPER_2

    • HAL_TAMP_INTERNAL_TAMPER_3

    • HAL_TAMP_INTERNAL_TAMPER_5

    • HAL_TAMP_INTERNAL_TAMPER_6

    • HAL_TAMP_INTERNAL_TAMPER_7

    • HAL_TAMP_INTERNAL_TAMPER_8

    • HAL_TAMP_INTERNAL_TAMPER_9

    • HAL_TAMP_INTERNAL_TAMPER_11

    • HAL_TAMP_INTERNAL_TAMPER_12

    • HAL_TAMP_INTERNAL_TAMPER_13

  • interruption – enable the interruption, can be a combination of

    • HAL_TAMP_INTERNAL_IT_NONE

    • HAL_TAMP_INTERNAL_IT_TAMPER_1

    • HAL_TAMP_INTERNAL_IT_TAMPER_2

    • HAL_TAMP_INTERNAL_IT_TAMPER_3

    • HAL_TAMP_INTERNAL_IT_TAMPER_5

    • HAL_TAMP_INTERNAL_IT_TAMPER_6

    • HAL_TAMP_INTERNAL_IT_TAMPER_7

    • HAL_TAMP_INTERNAL_IT_TAMPER_8

    • HAL_TAMP_INTERNAL_IT_TAMPER_9

    • HAL_TAMP_INTERNAL_IT_TAMPER_11

    • HAL_TAMP_INTERNAL_IT_TAMPER_12

    • HAL_TAMP_INTERNAL_IT_TAMPER_13

Return values :

HAL_OK

hal_status_t HAL_TAMP_INTERNAL_Stop ( uint32_t internal_tampers )

Stop the internal tampers.

Parameters :

internal_tampers – tampers to be stopped, can be a combination of

  • HAL_TAMP_INTERNAL_TAMPER_1

  • HAL_TAMP_INTERNAL_TAMPER_2

  • HAL_TAMP_INTERNAL_TAMPER_3

  • HAL_TAMP_INTERNAL_TAMPER_5

  • HAL_TAMP_INTERNAL_TAMPER_6

  • HAL_TAMP_INTERNAL_TAMPER_7

  • HAL_TAMP_INTERNAL_TAMPER_8

  • HAL_TAMP_INTERNAL_TAMPER_9

  • HAL_TAMP_INTERNAL_TAMPER_11

  • HAL_TAMP_INTERNAL_TAMPER_12

  • HAL_TAMP_INTERNAL_TAMPER_13

Return values :

HAL_OK

hal_status_t HAL_TAMP_INTERNAL_PollForEvent ( uint32_t internal_tampers , uint32_t timeout_ms )

Poll for a internal tamper event among internal tampers given in internal_tampers .

Note

Call HAL_TAMP_INTERNAL_Stop to clear the pending internal tamper event.

Parameters :
  • internal_tampers – Internal tampers to be checked, can be a combination of

    • HAL_TAMP_INTERNAL_TAMPER_1

    • HAL_TAMP_INTERNAL_TAMPER_2

    • HAL_TAMP_INTERNAL_TAMPER_3

    • HAL_TAMP_INTERNAL_TAMPER_5

    • HAL_TAMP_INTERNAL_TAMPER_6

    • HAL_TAMP_INTERNAL_TAMPER_7

    • HAL_TAMP_INTERNAL_TAMPER_8

    • HAL_TAMP_INTERNAL_TAMPER_9

    • HAL_TAMP_INTERNAL_TAMPER_11

    • HAL_TAMP_INTERNAL_TAMPER_12

    • HAL_TAMP_INTERNAL_TAMPER_13

  • timeout_ms – Timeout duration

Return values :
  • HAL_OK

  • HAL_TIMEOUT – when reaching the timeout during polling.

exported active tamper mode functions

group TAMP_Exported_Functions_Active

The active mode consists of a continuous comparison between a random signal from a tamper output and the signal input from a tamper input. In case of mismatch between the two signals a tamper event is then triggered to protect the device secrets from physical open-short attacks for example.

Random output signal

Pseudo random number generator

A pseudo random number generator computes the signal output of a tamper level. The seed can be configured by this pseudo random number generator is programmed by using the HAL_TAMP_ACTIVE_SetSeed function.

The clock that drives the PRNG change is the RTCCLK passing through a prescaler, called CK_ATPRE. This prescaler can be configured by calling HAL_TAMP_ACTIVE_SetConfig and programming the parameter hal_tamp_active_config_t::asynchronous_prescaler.

Programming hal_tamp_active_config_t::asynchronous_prescaler to HAL_TAMP_ACTIVE_PRESCALER_RTCCLK_DIV_2048 requires the asynchronous prescaler and synchronous prescaler of the RTC to be set to 128 and a multiple of 16 respectively.

Every ninth cycles of CK_ATPRE the value of the PRNG changes. The seed takes 184 APB clock to renew. The application needs to wait for the seed to renew before entering a low power mode or switching off the APB clock.

Output change

Another clock, CK_APER, drives the change in tamper output. CK_APER is generated from the same source as the PRNG, but it is divided by two to the power of hal_tamp_active_config_t::output_period. hal_tamp_active_config_t::output_period is configured by calling HAL_TAMP_ACTIVE_SetConfig .

Every two cycles the output value matches the last consumed value of the PRNG. In between the two cycles, so after one cycle the value is the opposite.

Depending on the number of outputs used the value of PRNG is consumed every :

  • sixteen cycles with one output

  • eight cycles with two outputs.

  • four cycles with three or four outputs

  • two cycles with five or more outputs.

Choose the value of hal_tamp_active_config_t::output_period according to the number of outputs used and the fact that the PRNG changes only every ninth cycle of CK_ATPRE.

Comparison

The comparison between the input and output signals is made every CK_ATPRE cycle. In case a comparison mismatch occurs, a tamper event is triggered.

By default the comparison is made between the same tamper input and output indexes. But it is possible to use the same output for several tamper inputs. This is configured by calling the HAL_TAMP_ACTIVE_SetConfig and HAL_TAMP_ACTIVE_SetConfigTampers function.

By calling HAL_TAMP_ACTIVE_SetConfig and setting the parameter hal_tamp_active_config_t::shared_output to HAL_TAMP_ACTIVE_TAMPER_OUTPUT_SHARED, enables the output sharing. To choose the output tamper for several input tampers the user needs to call the function HAL_TAMP_ACTIVE_SetConfigTampers by setting the parameter tampers_input to the corresponding tampers input and hal_tamp_active_individual_config_t::tamper_output to the corresponding tamper output.

The application can also apply a filter by calling HAL_TAMP_ACTIVE_SetConfig and programming hal_tamp_active_config_t::filter with the value HAL_TAMP_ACTIVE_FILTER_ENABLE. It makes a tamper event trigger only when two comparisons out of four consecutive comparisons are false.

Potential and confirmed mode.

Each tamper can work in two modes regarding the device secrets erase. The confirmed mode means that when a tamper event occurs the device secrets are automatically erased. The potential mode does not erase all the device secrets when a tamper event occurs. Instead it blocks the read and write access of the device secrets. The access is unblocked when the tamper event is cleared.

To configure the erase mode call HAL_TAMP_INTERNAL_SetConfigTampers and configure the hal_tamp_internal_individual_config_t::erase_secrets parameter.

Functions

hal_status_t HAL_TAMP_ACTIVE_SetConfig ( const hal_tamp_active_config_t * p_config )

Configure the active tampers global parameters.

Parameters :

p_config – Pointer to the active tampers global configuration instance.

Return values :
  • HAL_OK

  • HAL_ERROR – In STM32U575xx STM32U585xx the active tamper extension is not present. The 2048 prescaler value can’t be used.

void HAL_TAMP_ACTIVE_GetConfig ( hal_tamp_active_config_t * p_config )

Retrieve the active tampers global parameters.

Parameters :

p_config – Pointer to the active tampers global configuration instance.

hal_status_t HAL_TAMP_ACTIVE_SetConfigTampers ( uint32_t tampers_input , const hal_tamp_active_individual_config_t * p_config )

Configure the active tampers individual parameters.

Parameters :
  • tampers_input – tampers input to be configured, can be a combination of

    • HAL_TAMP_TAMPER_1

    • HAL_TAMP_TAMPER_2

    • HAL_TAMP_TAMPER_3

    • HAL_TAMP_TAMPER_4

    • HAL_TAMP_TAMPER_5

    • HAL_TAMP_TAMPER_6

    • HAL_TAMP_TAMPER_7

    • HAL_TAMP_TAMPER_8

  • p_config – Pointer to the active tamper individual configuration instance.

Return values :

HAL_OK

void HAL_TAMP_ACTIVE_GetConfigTamper ( uint32_t tamper_input , hal_tamp_active_individual_config_t * p_config )

Retrieve the active tamper individual configuration.

Parameters :
  • tamper_input – tampers input to be configured, can be one of the following values

    • HAL_TAMP_TAMPER_1

    • HAL_TAMP_TAMPER_2

    • HAL_TAMP_TAMPER_3

    • HAL_TAMP_TAMPER_4

    • HAL_TAMP_TAMPER_5

    • HAL_TAMP_TAMPER_6

    • HAL_TAMP_TAMPER_7

    • HAL_TAMP_TAMPER_8

  • p_config – Pointer to the active tamper individual configuration instance.

hal_status_t HAL_TAMP_ACTIVE_Start ( uint32_t tampers , uint32_t interruption , const uint32_t * p_seeds )

Start the active tampers.

Warning

All needed active tampers must be started at the same time.

Parameters :
  • tampers – active tampers to activate, can be a combination of

    • HAL_TAMP_TAMPER_1

    • HAL_TAMP_TAMPER_2

    • HAL_TAMP_TAMPER_3

    • HAL_TAMP_TAMPER_4

    • HAL_TAMP_TAMPER_5

    • HAL_TAMP_TAMPER_6

    • HAL_TAMP_TAMPER_7

    • HAL_TAMP_TAMPER_8

  • interruption – enable the interruption, can be a combination of these values.

    • HAL_TAMP_IT_NONE

    • HAL_TAMP_IT_TAMPER_1

    • HAL_TAMP_IT_TAMPER_2

    • HAL_TAMP_IT_TAMPER_3

    • HAL_TAMP_IT_TAMPER_4

    • HAL_TAMP_IT_TAMPER_5

    • HAL_TAMP_IT_TAMPER_6

    • HAL_TAMP_IT_TAMPER_7

    • HAL_TAMP_IT_TAMPER_8

  • p_seeds – Pointer to the seed values. It must be a table with 4 elements.

Return values :
  • HAL_ERROR – If trying to start active tampers when they are already passive tampers and enabled. or if trying to start active tampers when active tampers are already enabled.

  • HAL_OK

hal_status_t HAL_TAMP_ACTIVE_Stop ( uint32_t tampers )

Stop the active tampers.

Warning

All needed active tampers must be stopped at the same time.

Parameters :

tampers – active tampers to stop, can be a combination of

  • HAL_TAMP_TAMPER_1

  • HAL_TAMP_TAMPER_2

  • HAL_TAMP_TAMPER_3

  • HAL_TAMP_TAMPER_4

  • HAL_TAMP_TAMPER_5

  • HAL_TAMP_TAMPER_6

  • HAL_TAMP_TAMPER_7

  • HAL_TAMP_TAMPER_8

Return values :

HAL_OK

hal_status_t HAL_TAMP_ACTIVE_SetSeed ( const uint32_t * p_seeds )

Program a new seed for the pseudo-random number generator (PRNG)

Parameters :

p_seeds – Pointer to the seeds values

Return values :
  • HAL_OK

  • HAL_INVALID_PARAM – when p_seeds is null.

hal_status_t HAL_TAMP_ACTIVE_GetPRNG ( uint32_t * p_prng )

Read pseudo-random generator value.

Parameters :

p_prng – Pointer to the pseudo-random generator value

Return values :
  • HAL_OK

  • HAL_ERROR – when read value is not correct

hal_status_t HAL_TAMP_ACTIVE_PollForEvent ( uint32_t tampers , uint32_t timeout_ms )

Poll for a tamper event among the tampers given in tampers .

Note

Call HAL_TAMP_ACTIVE_Stop to clear the pending tamper event.

Parameters :
  • tampers – tampers to be checked, can be a combination of

    • HAL_TAMP_TAMPER_1

    • HAL_TAMP_TAMPER_2

    • HAL_TAMP_TAMPER_3

    • HAL_TAMP_TAMPER_4

    • HAL_TAMP_TAMPER_5

    • HAL_TAMP_TAMPER_6

    • HAL_TAMP_TAMPER_7

    • HAL_TAMP_TAMPER_8

  • timeout_ms – Timeout duration

Return values :
  • HAL_OK

  • HAL_TIMEOUT – when reaching the timeout during polling.

HAL TAMP IRQ functions

group TAMP_Exported_Functions_IRQ

TAMP IRQ handler exported functions

IRQ handler functions to manage the different tamper event interrupts.

Functions

void HAL_TAMP_IRQHandler ( void )

IRQ handler of the different tamper interrupts.

void HAL_TAMP_TamperIRQHandler ( void )

IRQ handler of the external tampers interrupts.

void HAL_TAMP_InternalTamperIRQHandler ( void )

IRQ handler of the internal tampers interrupts.

HAL TAMP callback functions

group TAMP_Exported_Functions_Callback

Callback exported functions.

Callback functions that the user can overwrite for the different interrupts:

  • Internal tampers.

  • External tampers.

Functions

void HAL_TAMP_InternalTamperEventCallback ( uint32_t internal_tampers )

Internal tamper event callback.

Parameters :

internal_tampers – This parameter can be a combination of

  • HAL_TAMP_INTERNAL_TAMPER_1

  • HAL_TAMP_INTERNAL_TAMPER_2

  • HAL_TAMP_INTERNAL_TAMPER_3

  • HAL_TAMP_INTERNAL_TAMPER_5

  • HAL_TAMP_INTERNAL_TAMPER_6

  • HAL_TAMP_INTERNAL_TAMPER_7

  • HAL_TAMP_INTERNAL_TAMPER_8

  • HAL_TAMP_INTERNAL_TAMPER_9

  • HAL_TAMP_INTERNAL_TAMPER_11

  • HAL_TAMP_INTERNAL_TAMPER_12

  • HAL_TAMP_INTERNAL_TAMPER_13

void HAL_TAMP_TamperEventCallback ( uint32_t tampers )

External tamper event callback.

Parameters :

tampers – This parameter can be a combination of

  • HAL_TAMP_TAMPER_1

  • HAL_TAMP_TAMPER_2

  • HAL_TAMP_TAMPER_3

  • HAL_TAMP_TAMPER_4

  • HAL_TAMP_TAMPER_5

  • HAL_TAMP_TAMPER_6

  • HAL_TAMP_TAMPER_7

  • HAL_TAMP_TAMPER_8

HAL TAMP monotonic counter functions

group TAMP_Exported_Functions_Monotonic_Counters

Monotonic counter exported functions.

The monotonic counter is a simple counter that the user can only increment step by step. To increment the value and read the value the application must call HAL_TAMP_MONOTONIC_IncrementCounter and HAL_TAMP_MONOTONIC_GetCounter .

Functions

hal_status_t HAL_TAMP_MONOTONIC_IncrementCounter ( hal_tamp_monotonic_counter_t index )

Increment the value of the monotonic counter index.

Parameters :

index – monotonic counter index

Return values :

HAL_OK

uint32_t HAL_TAMP_MONOTONIC_GetCounter ( hal_tamp_monotonic_counter_t index )

Retrieves the value of the monotonic counter.

Parameters :

index – monotonic counter index.

Return values :

uint32_t – Value of the monotonic counter.

HAL TAMP device secrets functions

group TAMP_Exported_Functions_Device_Secrets

The device secrets consist of different resources of the microcontroller

Backup registers

There are 32 backup registers. The backup registers are registers that the application can write anything it wants by calling HAL_TAMP_WriteBackupRegisterValue .

Hardware boot key block

The eight first backup registers can be used to store a boot hardware key (BHK) for the secure AES. For this purpose, these registers must belong to the Protection Zone 1: BKPRWSEC must be greater or equal to 8. To block the access to the hardware boot key, the application needs to call HAL_TAMP_EnableHardwareBootkeyBlock . The following events unblock the access to the hardware boot key:

In all cases the backup registers are also erased.

Device secrets access and erase.

The application can enable and disable the access of the different device secrets by calling HAL_TAMP_UnblockDeviceSecretsAccess and HAL_TAMP_BlockDeviceSecretsAccess respectively. By default they can be accessed.

The application can also manually erase the different device secrets by calling the HAL_TAMP_EraseDeviceSecrets function.

Functions

hal_status_t HAL_TAMP_WriteBackupRegisterValue ( hal_tamp_backup_register_idx_t backup_register_index , uint32_t data_32bit )

Program the value of the backup register given by the parameter backup_register_index .

Parameters :
  • backup_register_index – Index of the backup register.

  • data_32bit – Value to be programmed.

Return values :

HAL_OK

uint32_t HAL_TAMP_ReadBackupRegisterValue ( hal_tamp_backup_register_idx_t backup_register_index )

Retrieve the value of the backup register given by the parameter backup_register_index .

Parameters :

backup_register_index – Index of the backup register.

Return values :

uint32_t – Value of the backup register

hal_status_t HAL_TAMP_UnblockDeviceSecretsAccess ( void )

Unblock access to the backup registers and device secrets.

Return values :

HAL_OK

hal_status_t HAL_TAMP_BlockDeviceSecretsAccess ( void )

Block access to the backup registers and devices secrets.

Return values :

HAL_OK

hal_tamp_secrets_status_t HAL_TAMP_IsBlockedDeviceSecretsAccess ( void )

Check if the access to the devices secrets is blocked.

Return values :

hal_tamp_secrets_status_t – Device secrets access status.

hal_status_t HAL_TAMP_EraseDeviceSecrets ( void )

Erase the backup registers and device secrets.

Return values :

HAL_OK

hal_status_t HAL_TAMP_EnableResourceProtection ( uint32_t resources )

Enable the protection as device secrets of the resource given by the parameter resources .

Parameters :

resources – Resources to be protected, can be a combination of

  • HAL_TAMP_BACKUP_SRAM

  • HAL_TAMP_RESOURCES_ALL

Return values :

HAL_OK

hal_status_t HAL_TAMP_DisableResourceProtection ( uint32_t resources )

Disable the protection as device secrets of the resource given by the parameter resources .

Parameters :

resources – Resources to be protected, can be a combination of

  • HAL_TAMP_BACKUP_SRAM

  • HAL_TAMP_RESOURCES_ALL

Return values :

HAL_OK

hal_tamp_protect_resources_status_t HAL_TAMP_IsEnabledResourceProtection ( uint32_t resources )

Check if the resources given by the parameter resources are protected as device secrets.

Parameters :

resources – Resources to be protected, can be a value of

  • HAL_TAMP_BACKUP_SRAM

  • HAL_TAMP_RESOURCES_ALL

Return values :

hal_tamp_protect_resources_status_t – Resource protection status.

hal_status_t HAL_TAMP_EnableHardwareBootkeyBlock ( void )

Blocks access to the eight first backup registers corresponding to the hardware boot key.

Note

The eight first backup registers must be part of Protection Zone 1

Return values :

HAL_OK

hal_tamp_hardware_bootkey_status_t HAL_TAMP_IsEnabledHardwareBootkeyBlock ( void )

Check if the eight first backup registers corresponding to the hardware boot key are blocked.

Return values :

hal_tamp_hardware_bootkey_status_t – Status of the hardware boot key access