Silicon Labs Secure Engine Manager API definitions.

License#

Copyright 2020 Silicon Laboratories Inc. www.silabs.com

SPDX-License-Identifier: Zlib

The licensor of this software is Silicon Laboratories Inc.

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.

  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.

  3. This notice may not be removed or altered from any source distribution.

The tamper configuration is one-time-programmable, and is done using the initialise OTP command to the SE (see sl_se_init_otp). This means that tamper settings must be written together with secure boot settings, and are immutable after they are written. After tamper has been initialized, it is possible to temporarily disable one or several tamper signals using an authenticated command, similar to secure debug unlock. This is only possible if the debug public key has been installed on the device. It is only possible to disable the customer enabled response. The default response to a signal cannot be disabled.

Tamper is configured by providing the following:

Tamper configuration table

Setting

Description

Tamper response levels

A response level for each tamper signal.

It is not possible to degrade the default response level of a tamper signal, so if a response is set to a lower level than the default response level listed in the table in the Signals section, this won't have any effect.

Filter settings

The tamper filter counter has two settings:

  • Reset period

  • Trigger threshold

These options can be set to the values given in the tables in the Response Filter section. Please see the examples section for a suggested use of the tamper filter signal.

Flags

The tamper flags is used to configure two options:

  • Digital Glitch Detector Always On – This option will keep the digital glitch detector running even while the SE is not performing any operations. This leads to increased energy consumption.

  • Keep Tamper Alive During Sleep (not available on EFR32xG21B devices) – If set, the tamper module keeps running at sleep mode (down to EM3).

Reset threshold

The number of consecutive tamper resets before the the part enters debug mode.

If the threshold is set to 0, the part will never enter the debug mode due to tamper reset.

Example Usage#

The glitch detectors can see spurious activations, and should typically not be used to directly drive a serious tamper response. Instead they should feed their signals into a tamper interrupt (to handle the response logic on the M33), or into the tamper filter counter, which can be used to activate a high level response if a number of incidents occur in a short time window. The time period and counter threshold must be tuned to the use case. In the following example the device will erase OTP and become inoperable if 4 glitch signals is seen in a 1 minute time period.

Since you can only configure tamper once for each device, please make sure that this is the configuration you actually want before you execute this example on actual device.

sl_se_otp_init_t otp_settings_init = SL_SE_OTP_INIT_DEFAULT;

// Configure tamper levels
otp_settings_init.tamper_levels[SL_SE_TAMPER_SIGNAL_FILTER] = SL_SE_TAMPER_LEVEL_PERMANENTLY_ERASE_OTP;
otp_settings_init.tamper_levels[SL_SE_TAMPER_SIGNAL_VGLITCHFALLING] = SL_SE_TAMPER_LEVEL_FILTER;
otp_settings_init.tamper_levels[SL_SE_TAMPER_SIGNAL_VGLITCHRISING] = SL_SE_TAMPER_LEVEL_FILTER;
otp_settings_init.tamper_levels[SL_SE_TAMPER_SIGNAL_DGLITCH] = SL_SE_TAMPER_LEVEL_FILTER;


// Configure tamper filter options
otp_settings_init.tamper_filter_period = SL_SE_TAMPER_FILTER_PERIOD_1MIN;
otp_settings_init.tamper_filter_threshold = SL_SE_TAMPER_FILTER_THRESHOLD_4;


// Commit OTP settings. This command is only available once!
sl_se_init_otp(&otp_settings_init);

RTOS Mode and Multi-Thread Safety#

Note

  • The SE Manager API is multi-thread safe, but does not support preemption. This means the API cannot be called from ISR or critical/atomic sections when running in an RTOS thread. When using the SE Manager API in a bare-metal application, it is the application developer's responsibility to not call the SE Manager APIs when another operation is in progress.

The SE Manager supports multi-thread safe APIs for MicriumOS and FreeRTOS interfacing with CMSIS RTOS2 APIs.

In the cases where Micrium OS or FreeRTOS are included in the project (RTOS-mode), the SE Manager will be configured with threading and yield support. Configure sl_se_command_context_t with sl_se_set_yield to yield the CPU core when the SE Manager is waiting for the Secure Engine to complete a mailbox command.

For threading support the SE Manager applies an SE lock mechanism to protect the Secure Engine Mailbox interface from being accessed by more than one thread, ensuring multi-thread safety. For yielding the CPU core while waiting for the SE, the SE Manager APIs that invoke SE mailbox commands will wait on a semaphore which is signaled in the ISR that handles the SE mailbox completion interrupt. Hence other threads may run on the CPU core while the SE is processing the mailbox command.

Macros#

#define
SL_SE_COMMAND_CONTEXT_INIT { SLI_SE_MAILBOX_COMMAND_DEFAULT(0), false }

Context initialization values.

#define
SL_SE_OTP_INIT_DEFAULT undefined

Default configuration for OTP initialisation structure.

#define
SL_SE_KEY_FLAG_ASYMMETRIC_SIGNING_ONLY (1UL << 10)

Flags that can be used with asymmetric keys Asymmetric key can only be used for signing (not key exchange)

#define
SL_SE_KEY_FLAG_ASYMMETRIC_USES_CUSTOM_DOMAIN (1UL << 12)

Described key belongs to a custom ECC domain.

#define
SL_SE_KEY_FLAG_ASYMMETRIC_BUFFER_HAS_PUBLIC_KEY (1UL << 13)

Storage buffer contains public part of an asymmetric key.

#define
SL_SE_KEY_FLAG_ASYMMETRIC_BUFFER_HAS_PRIVATE_KEY (1UL << 14)

Storage buffer contains private part of an asymmetric key.

#define
SL_SE_KEY_FLAG_ALLOW_ANY_ACCESS (1UL << 15)

Allow usage of this key by other bus masters or TrustZone levels than the one which created/imported the key.

#define
SL_SE_KEY_FLAG_ASYMMMETRIC_SIGNING_ONLY (SL_SE_KEY_FLAG_ASYMMETRIC_SIGNING_ONLY)

Old definition. Retained for backwards compatibility.

#define
SL_SE_KEY_FLAG_SYMMETRIC_KEY_USAGE_REQUIRE_DPA (1 << 9)

Flags that can be used with symmetric keys Usage of key requires DPA countermeasures.

#define
SL_SE_KEY_FLAG_SYMMETRIC_KEY_USAGE_REQUIRE_DFA (1 << 8)

Usage of key requires DFA countermeasures.

#define
SL_SE_KEY_FLAG_NON_EXPORTABLE (1UL << 24)

Do not allow exporting the key to plaintext.

#define
SL_SE_KEY_FLAG_IS_DEVICE_GENERATED (1UL << 25)

Indicate that the key has been generated by this device.

#define
SL_SE_KEY_FLAG_IS_RESTRICTED (1UL << 25 | 1UL << 24)

Indicate that the key can only be used to sign SE generated content.

#define
SL_SE_KEY_TYPE_ALGORITHM_MASK 0xf0000000

Mask for algorithm field in key type.

#define
SL_SE_KEY_TYPE_ALGORITHM_OFFSET 28

Offset of algorithm field in key type.

#define
SL_SE_KEY_TYPE_ATTRIBUTES_MASK 0x00007fff

Mask for attributes field in key type.

#define
SL_SE_KEY_TYPE_ATTRIBUTES_OFFSET 0

Offset of attributes field in key type.

#define
SL_SE_KEY_TYPE_SYMMETRIC 0x00000000

Symmetric key type.

#define
SL_SE_KEY_TYPE_AES_128 0x00000010

Symmetric key type for AES-128 (16 byte key)

#define
SL_SE_KEY_TYPE_AES_192 0x00000018

Symmetric key type for AES-192 (24 byte key)

#define
SL_SE_KEY_TYPE_AES_256 0x00000020

Symmetric key type for AES-256 (32 byte key)

#define
SL_SE_KEY_TYPE_ECC_WEIERSTRASS_PRIME_CUSTOM (0x8U << SL_SE_KEY_TYPE_ALGORITHM_OFFSET)

ECC Weierstrass Prime key type.

#define
SL_SE_KEY_TYPE_ECC_MONTGOMERY (0xbU << SL_SE_KEY_TYPE_ALGORITHM_OFFSET)

ECC Montgomery key type.

#define
SL_SE_KEY_TYPE_ECC_EDDSA (0xcU << SL_SE_KEY_TYPE_ALGORITHM_OFFSET)

EDDSA key type.

#define
SL_SE_KEY_TYPE_ECC_P192 (SL_SE_KEY_TYPE_ECC_WEIERSTRASS_PRIME_CUSTOM | (0x18))

ECC NIST P-192.

#define
SL_SE_KEY_TYPE_ECC_P224 (SL_SE_KEY_TYPE_ECC_WEIERSTRASS_PRIME_CUSTOM | (0x1C))

ECC NIST P-224.

#define
SL_SE_KEY_TYPE_ECC_P256 (SL_SE_KEY_TYPE_ECC_WEIERSTRASS_PRIME_CUSTOM | (0x20))

ECC NIST P-256.

#define
SL_SE_KEY_TYPE_ECC_ED25519 (SL_SE_KEY_TYPE_ECC_EDDSA | (0x20))

ECC Ed25519 key for EdDSA.

#define
SL_SE_KEY_TYPE_ECC_X25519 (SL_SE_KEY_TYPE_ECC_MONTGOMERY | (0x20))

ECC X25519 key for ECDH.

#define
SL_SE_KEY_TYPE_CHACHA20 0x00000020

Symmetric key type for ChaCha20.

#define
SL_SE_KEY_TYPE_ECC_P384 (SL_SE_KEY_TYPE_ECC_WEIERSTRASS_PRIME_CUSTOM | (0x30))

ECC NIST P-384.

#define
SL_SE_KEY_TYPE_ECC_P521 (SL_SE_KEY_TYPE_ECC_WEIERSTRASS_PRIME_CUSTOM | (0x42))

ECC NIST P-521.

#define
SL_SE_KEY_TYPE_ECC_X448 (SL_SE_KEY_TYPE_ECC_MONTGOMERY | (0x38))

ECC X448 key for ECDH.

#define
SL_SE_KEY_TYPE_ECC_ED448 (SL_SE_KEY_TYPE_ECC_EDDSA | (0x38))

ECC Ed448 key for EdDSA.

#define
SL_SE_KEY_STORAGE_EXTERNAL_PLAINTEXT 0x00

Key storage methods.

#define
SL_SE_KEY_STORAGE_EXTERNAL_WRAPPED 0x01

Key is stored encrypted in application memory.

#define
SL_SE_KEY_STORAGE_INTERNAL_VOLATILE 0x02

Key is stored inside the SE, and will persist until system reset or explicitly deleted.

#define
SL_SE_KEY_STORAGE_INTERNAL_IMMUTABLE 0x03

Key is one of the pre-defined keys (pre-loaded or write-once) available in the SE.

#define
SL_SE_KEY_STORAGE_INTERNAL_KSU 0x04

Key is stored in the KSURAM, an internal Key Slot RAM.

#define
SL_SE_KSU_MAX_KEY_SLOTS 0x40

Available KSU Key slots.

#define
SL_SE_KEY_SLOT_VOLATILE_0 0x00

List of available internal SE key slots.

#define
SL_SE_KEY_SLOT_VOLATILE_1 0x01

Internal volatile slot 1.

#define
SL_SE_KEY_SLOT_VOLATILE_2 0x02

Internal volatile slot 2.

#define
SL_SE_KEY_SLOT_VOLATILE_3 0x03

Internal volatile slot 3.

#define
SL_SE_KEY_SLOT_INTERNAL_MIN 0xF7

Minimum key slot value for internal keys.

#define
SL_SE_KEY_SLOT_TRUSTZONE_ROOT_KEY 0xF7

Internal TrustZone root key.

#define
SL_SE_KEY_SLOT_APPLICATION_SECURE_DEBUG_KEY 0xF8

Internal immutable application secure debug key.

#define
SL_SE_KEY_SLOT_APPLICATION_AES_128_KEY 0xFA

Internal immutable application AES-128 key (bootloader key)

#define
SL_SE_KEY_SLOT_APPLICATION_SECURE_BOOT_KEY 0xFC

Internal immutable application secure boot key.

#define
SL_SE_KEY_SLOT_APPLICATION_ATTESTATION_KEY 0xFE

Internal immutable application attestation key.

#define
SL_SE_KEY_SLOT_SE_ATTESTATION_KEY 0xFF

Internal immutable SE attestation key.

#define
SLI_SE_WRAPPED_KEY_OVERHEAD (12 + 16)

Size overhead for wrapped keys.

#define
SL_SE_PRF_AES_CMAC_128 SL_SE_HASH_NONE

Defines mapping the PBKDF2 PRFs to corresponding sl_se_hash_type_t values.

#define
SL_SE_PRF_HMAC_SHA1 SL_SE_HASH_SHA1

HMAC-SHA-1.

#define
SL_SE_PRF_HMAC_SHA224 SL_SE_HASH_SHA224

HMAC-SHA-224.

#define
SL_SE_PRF_HMAC_SHA256 SL_SE_HASH_SHA256

HMAC-SHA-256.

#define
SL_SE_PRF_HMAC_SHA384 SL_SE_HASH_SHA384

HMAC-SHA-384.

#define
SL_SE_PRF_HMAC_SHA512 SL_SE_HASH_SHA512

HMAC-SHA-512.

#define
SL_SE_CHALLENGE_SIZE 16

SE Challenge size.

#define
SL_SE_CERT_KEY_SIZE 64

Certificate key size.

#define
SL_SE_CERT_SIGN_SIZE 64

Certificate signature size.

#define
SL_SE_CERT_BATCH 0x01

Batch ID certificate.

#define
SL_SE_CERT_DEVICE_SE 0x02

SE ID certificate.

#define
SL_SE_CERT_DEVICE_HOST 0x03

Host ID certificate.

#define
SL_SE_TAMPER_LEVEL_IGNORE 0

No action taken.

#define
SL_SE_TAMPER_LEVEL_INTERRUPT 1

Generate interrupt.

#define
SL_SE_TAMPER_LEVEL_FILTER 2

Increment filter counter.

#define
SL_SE_TAMPER_LEVEL_RESET 4

System reset.

#define
SL_SE_TAMPER_LEVEL_PERMANENTLY_ERASE_OTP 7

Erase OTP - THIS WILL MAKE THE DEVICE INOPERATIONAL!

#define
SL_SE_TAMPER_SIGNAL_RESERVED_1 0x0

Reserved tamper signal.

#define
SL_SE_TAMPER_SIGNAL_FILTER_COUNTER 0x1

Filter counter exceeds threshold.

#define
SL_SE_TAMPER_SIGNAL_WATCHDOG 0x2

SE watchdog timeout.

#define
SL_SE_TAMPER_SIGNAL_CRYPTO_ERROR 0x3

Crypto error detected.

#define
SL_SE_TAMPER_SIGNAL_SE_RAM_ECC_2 0x4

SE RAM 2-bit ECC error.

#define
SL_SE_TAMPER_SIGNAL_RESERVED_2 0x5

Reserved tamper signal.

#define
SL_SE_TAMPER_SIGNAL_SE_MAJOR_FAULT 0x6

SE major fault detected.

#define
SL_SE_TAMPER_SIGNAL_L2ICACHE 0x7

L2 instruction cache error.

#define
SL_SE_TAMPER_SIGNAL_RESERVED_3 0x8

Reserved tamper signal.

#define
SL_SE_TAMPER_SIGNAL_USER_SECURE_BOOT_FAILED 0x9

Secure boot of user code failed.

#define
SL_SE_TAMPER_SIGNAL_MAILBOX_AUTHORIZATION_ERROR 0xA

Unauthorised command received over the Mailbox interface.

#define
SL_SE_TAMPER_SIGNAL_DCI_AUTHORIZATION_ERROR 0xB

Unauthorised command received over the DCI interface.

#define
SL_SE_TAMPER_SIGNAL_SE_SOFTWARE_ASSERTION 0xC

SE software triggers an assert.

#define
SL_SE_TAMPER_SIGNAL_RESERVED_4 0xD

Reserved tamper signal.

#define
SL_SE_TAMPER_SIGNAL_SELFTEST_FAILED 0xE

Integrity error of internal storage is detected.

#define
SL_SE_TAMPER_SIGNAL_TRNG_MONITOR 0xF

TRNG monitor detected lack of entropy.

#define
SL_SE_TAMPER_SIGNAL_SECURE_LOCK_ERROR 0x10

Debug lock internal logic check failed.

#define
SL_SE_TAMPER_ATAMPDET 0x11

Any tamper detection.

#define
SL_SE_TAMPER_SIGNAL_OTP_ALARM 0x12

OTP alarm triggered.

#define
SL_SE_TAMPER_SE_ICACHE_ERROR 0x13

SE ICache RAM error.

#define
SL_SE_TAMPER_SIGNAL_SE_RAM_ECC_1 0x14

SE RAM 1-bit ECC error.

#define
SL_SE_TAMPER_SIGNAL_BOD 0x15

Brown-out-detector threshold alert.

#define
SL_SE_TAMPER_SIGNAL_TEMPERATURE_SENSOR 0x16

On-device temperature sensor.

#define
SL_SE_TAMPER_SIGNAL_DPLL_LOCK_FAIL 0x17

DPLL lock failure.

#define
SL_SE_TAMPER_SIGNAL_SOC_PLL_FAIL 0x18

SoC PLL failure.

#define
SL_SE_TAMPER_SIGNAL_ETAMPDET 0x19

External tamper detect.

#define
SL_SE_TAMPER_SIGNAL_KSU_ECC_1 0x1A

KSU ECC 1-bit error.

#define
SL_SE_TAMPER_SIGNAL_KSU_ECC_2 0x1B

KSU ECC 2-bit error.

#define
SL_SE_TAMPER_SIGNAL_QSPI_RESEED_ERR 0x1C

QSPI reseed error.

#define
SL_SE_TAMPER_SIGNAL_PRS0 0x1D

PRS channel 0 asserted.

#define
SL_SE_TAMPER_SIGNAL_PRS1 0x1E

PRS channel 1 asserted.

#define
SL_SE_TAMPER_SIGNAL_PRS2 0x1F

PRS channel 2 asserted.

#define
SL_SE_TAMPER_SIGNAL_NUM_SIGNALS 0x20

Number of tamper signals.

#define
SL_SE_TAMPER_FILTER_PERIOD_32MS 0x0

Timeout ~32ms.

#define
SL_SE_TAMPER_FILTER_PERIOD_64MS 0x1

Timeout ~64ms.

#define
SL_SE_TAMPER_FILTER_PERIOD_128MS 0x2

Timeout ~128ms.

#define
SL_SE_TAMPER_FILTER_PERIOD_256MS 0x3

Timeout ~256ms.

#define
SL_SE_TAMPER_FILTER_PERIOD_512MS 0x4

Timeout ~512ms.

#define
SL_SE_TAMPER_FILTER_PERIOD_1S 0x5

Timeout ~1s.

#define
SL_SE_TAMPER_FILTER_PERIOD_2S 0x6

Timeout ~2s.

#define
SL_SE_TAMPER_FILTER_PERIOD_4S 0x7

Timeout ~4.1s.

#define
SL_SE_TAMPER_FILTER_PERIOD_8S 0x8

Timeout ~8.2s.

#define
SL_SE_TAMPER_FILTER_PERIOD_16S 0x9

Timeout ~16.4s.

#define
SL_SE_TAMPER_FILTER_PERIOD_33S 0xA

Timeout ~32.8s.

#define
SL_SE_TAMPER_FILTER_PERIOD_1MIN 0xB

Timeout ~1.1min.

#define
SL_SE_TAMPER_FILTER_PERIOD_2MIN 0xC

Timeout ~2.2min.

#define
SL_SE_TAMPER_FILTER_PERIOD_4MIN 0xD

Timeout ~4.4min.

#define
SL_SE_TAMPER_FILTER_PERIOD_9MIN 0xE

Timeout ~8.7min.

#define
SL_SE_TAMPER_FILTER_PERIOD_18MIN 0xF

Timeout ~17.5min.

#define
SL_SE_TAMPER_FILTER_PERIOD_35MIN 0x10

Timeout ~35min.

#define
SL_SE_TAMPER_FILTER_PERIOD_1H 0x11

Timeout ~1.2h.

#define
SL_SE_TAMPER_FILTER_PERIOD_2H 0x12

Timeout ~2.3h.

#define
SL_SE_TAMPER_FILTER_PERIOD_5H 0x13

Timeout ~4.7h.

#define
SL_SE_TAMPER_FILTER_PERIOD_9H 0x14

Timeout ~9.3h.

#define
SL_SE_TAMPER_FILTER_PERIOD_19H 0x15

Timeout ~18.6h.

#define
SL_SE_TAMPER_FILTER_PERIOD_2DAYS 0x16

Timeout ~1.6days.

#define
SL_SE_TAMPER_FILTER_PERIOD_3DAYS 0x17

Timeout ~3.1days.

#define
SL_SE_TAMPER_FILTER_PERIOD_6DAYS 0x18

Timeout ~6.2days.

#define
SL_SE_TAMPER_FILTER_PERIOD_12DAYS 0x19

Timeout ~12.4days.

#define
SL_SE_TAMPER_FILTER_PERIOD_25DAYS 0x1A

Timeout ~24.9days.

#define
SL_SE_TAMPER_FILTER_PERIOD_50DAYS 0x1B

Timeout ~49.7days.

#define
SL_SE_TAMPER_FILTER_PERIOD_100DAYS 0x1C

Timeout ~99.4days.

#define
SL_SE_TAMPER_FILTER_PERIOD_199DAYS 0x1D

Timeout ~198.8days.

#define
SL_SE_TAMPER_FILTER_PERIOD_398DAYS 0x1E

Timeout ~397.7days.

#define
SL_SE_TAMPER_FILTER_PERIOD_795DAYS 0x1F

Timeout ~795.4days.

#define
SL_SE_TAMPER_FILTER_THRESHOLD_2 0x7

Counter threshold 2.

#define
SL_SE_TAMPER_FILTER_THRESHOLD_4 0x6

Counter threshold 4.

#define
SL_SE_TAMPER_FILTER_THRESHOLD_8 0x5

Counter threshold 8.

#define
SL_SE_TAMPER_FILTER_THRESHOLD_16 0x4

Counter threshold 16.

#define
SL_SE_TAMPER_FILTER_THRESHOLD_32 0x3

Counter threshold 32.

#define
SL_SE_TAMPER_FILTER_THRESHOLD_64 0x2

Counter threshold 64.

#define
SL_SE_TAMPER_FILTER_THRESHOLD_128 0x1

Counter threshold 128.

#define
SL_SE_TAMPER_FILTER_THRESHOLD_256 0x0

Counter threshold 256.

#define
SL_SE_TAMPER_FLAG_DGLITCH_ALWAYS_ON (1UL << 1)

Tamper flags.

#define
SL_SE_TAMPER_FLAG_KEEP_TAMPER_ALIVE_DURING_SLEEP (1UL << 2)

Tamper is kept alive during sleep (down to EM3)

#define
SL_SE_AES_BLOCK_SIZE (16u)

Block size for the AES.

#define
SL_SE_HASH_STREAMING_INIT_DEFAULT { NULL, 0, 0, NULL }

Default streaming hash context.

#define
SL_SE_SHA1_STREAMING_INIT_DEFAULT { { 0 }, { 0 }, { 0 } }

SHA1 streaming hash context.

#define
SL_SE_SHA224_STREAMING_INIT_DEFAULT { { 0 }, { 0 }, { 0 } }

SHA224 streaming hash context.

#define
SL_SE_SHA256_STREAMING_INIT_DEFAULT { { 0 }, { 0 }, { 0 } }

SHA256 streaming hash context.

#define
SL_SE_SHA384_STREAMING_INIT_DEFAULT { { 0 }, { 0 }, { 0 } }

SHA384 streaming hash context.

#define
SL_SE_SHA512_STREAMING_INIT_DEFAULT { { 0 }, { 0 }, { 0 } }

SHA512 streaming hash context.

#define
SL_SE_MAX_CODE_REGIONS 8

The maximum number of code regions available on the device.