1. Overview[edit | edit source]
The STM32 MPUs embed tamper detection management system.
The tamper management and configuration functions have been added to the secure OS to select and detect events to protect against external attacks.
On a tamper event, secrets are erased or blocked.
The automatic erase mode of all secrets can be configured for any tampers (internal and external). It is enabled by default but can be turned off (NOERASE) if the user application needs to control erase operations. If disabled:
On STM32MP13x lines series:
- The backup registers, SRAM3, and RHUK (root hardware unique key) in BSEC are locked (no read nor write are possible until event acknowledged)
- SAES, HASH peripherals and PKA SRAM are always erased
- All of: SRAM1, backup registers, the BSEC, RHUK (root hardware unique key) and BHK bus to access to SAES are locked (no read nor write are possible until event acknowledged)
- SAES, HASH peripherals and PKA SRAM are always erased
- (Optionnal) BKPSRAM is erased
The device secrets access is blocked when erase is on-going.
1.1. Internal tampers[edit | edit source]
The table below represents the list of the supported internal tampers.
1.2. External tampers[edit | edit source]
External tampers can be defined on all MPUs:
The external tampers can be configured as passive (they detect a level or an edge on one pin) or as active (2 pins have to be linked together, and the TAMP hardware regularly sends a random level on the OUT pin, then reads IN pins and raises the tamper flag if the values mismatch). Note that the number of mismatch before a tamper event is raised can be configured.
2. Software configuration[edit | edit source]
The tamper driver only exists in OP-TEE.
External tampers have to be configured in device tree.
Internal and external tampers have to be activated in main configuration file .
The device tree enables the TAMP IP and configures the external tamper (active, passive, level, and so on).
The main.c activates the desired TAMPER_ID, in ERASE or NOERASE mode and defines which is the callback in case of an event. An external TAMPER can be activated only if the corresponding TAMPER_ID is enabled in the device tree.
Example :
TAMP_CB_ACK_AND_RESET; } stm32_tamp_activate(INT_TAMP1, TAMP_ERASE, tamp1_callback);static uint32_t int_tamp1_callback(int id) { MSG("Backup domain voltage threshold monitoring tamper event occurs"); /* ... */ /* specific application event management */ /* ... */ return
The value returned by the callback defines if the driver acknowledges the event, and resets the board. If the event is configured as NOERASE, the callback may check:
- in case of true positive: erase manually secret (with stm32_tamp_erase_secret()) and returns TAMP_CB_ACK_AND_RESET
- in case of false positive: returns TAMP_CB_ACK (it unlocks the secret IPs).
The main.c configures the permission access of the TAMP register (privileged mode, secure mode), and it shows if the backup SRAM is included in the secret IPs list.
2.1. Default internal tampers configuration[edit | edit source]
- By default, only internal tampers 1, 2, 3 , 4, 7, 12 and 13 are enabled, configured as ERASE, and the callback resets the board.
- By default, only internal tampers 1, 2, 3 , 4 are enabled, configure as ERASE, and the callback will reset the board.
- Not yet supported
2.2. External tampers[edit | edit source]
On the STM32MP135F-DK , a tamper button is connected to the external tamper 2. It is default enable in the device tree. Pressing the TAMP button raises the EXT_TAMP2 event, erases all secrets and resets the board.