Ask questions and find answers on STM32 security frameworks and tools, including cryptographic libraries, TrustZone, and the Secure Manager.
Most recent activity
Post edited by ST moderator to be inline with the community rules especially with the code sharing. In next time please use </> button to paste your code. Please read this post: How to insert source code Hello, I need to calculate SHA-256 on STM32L562 MCU. I need a final single Hash output digest for an input of 8192 keys where each key is of 32 bytes. I am accumulating each key using: HAL_HASHEx_SHA256_Accmlt(&hhash, data, 32); upto 8191 keys. The final key i.e. 8192th key is fed to Hash engine using: HAL_HASHEx_SHA256_Accmlt_End(&hhash, last_data, 32, out_digest, 0xFF); Using this above approach I understood that a final "out_digest" will result a final 32-byte Hash value but I am not obtaining the correct Hash. I tried to reduce keys from 8192 to 2048 thinking that a small data may be processed correctly by Hash processor but still got the wrong Hash value. Instead of accumulating keys one by one, if I take a buffer of size (2048 * 32) bytes and accumul
Hi,I'm working on STM32L496 for some security application, as per L4 series documents I see that L4 series controllers has AES hardware, but in my IOC settings under security option I don't see the AES. Why is this? does it mean STM32L496 doesn't have AES hardware inbuilt? if yes is there any software approach?Thanks
Hi Team, I am trying to add a Secondary/custom bootloader in SBSFU. But not able to figure it out how to do it. I changed memory for active slot area and used the same area for custom bootloader in both linker file of both SBSFU and custom bootloader application. But does not work as expected. Can you please guide me through this? I need to add a Custom bootloader and trigger user application from it. What are the modification that I need to do for this. I am using STM32H753 board. @Jocelyn RICARD
I'm currently working on a final project titled "Design and Communication Security Mechanisms in an Embedded Gateway Module for Electric Vehicle Networks." I'll be creating a security mechanism using AES-128 and a hash function, and securing data from Ethernet communication protocols. I'd like to ask:1. How can I integrate Ethernet communication and security using the STM32F767ZIT6? 2. How can I create an encryption and decryption mechanism using AES-128 cryptography on the STM32F767ZIT6?
Hi, I've been working on porting the SBSFU onto a STM32H7A series with my custom gcc-arm build environment.The example project I am referring to is: x-cube-sbsfu-v2-7-0\STM32CubeExpansion_SBSFU_V2.7.0\Projects\STM32H7B3I-DK\Applications\2_Images.Everything seems to be working fine, but I have one issue that I am struggling with. So, the main SBSFU is supposed to call SE_CallGate() being the entry to the core secure engine, and it gets rebooted constantly. And, what I found is that the reboot doesn't happen if I get "IS_CALLER_SE_IF()" commented out. // se_callgate.c SE_ErrorStatus SE_CallGate(SE_FunctionIDTypeDef eID, SE_StatusTypeDef *const peSE_Status, uint32_t PrimaskParam, ...) { SE_ErrorStatus e_ret_status; va_list arguments; volatile uint32_t LR; #if defined(__CC_ARM) || defined(__ICCARM__) LR = get_LR(); #elif defined(__ARMCC_VERSION) __asm volatile("MOV %0, LR\n" : "=r"(LR)); #elif defined(__GNUC__) register unsigned lr asm("lr"); LR = lr; #endif /*
This works fine in an app without SM but when I run this from a non-secure app together with SM, the last step fails. This is the code: // Enable access to RTC and backup domain HAL_PWR_EnableBkUpAccess(); if (__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) == RESET) { // Reset the backup domain (equivalent to LL_RCC_ForceBackupDomainReset) __HAL_RCC_BACKUPRESET_FORCE(); __HAL_RCC_BACKUPRESET_RELEASE(); // Ensure LSE is OFF and NOT in bypass mode CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEON | RCC_BDCR_LSEBYP); // Set drive strength for startup (must be done while LSE is OFF) __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_MEDIUMHIGH); // Enable LSE __HAL_RCC_LSE_CONFIG(RCC_LSE_ON); // Wait until LSE is ready, with timeout if (SYSTIMER_WaitFlag(&RCC->BDCR, RCC_BDCR_LSERDY, true, 20000000)) { } else { // Disable LSE __HAL_RCC_LSE_CONFIG(RCC_LSE_OFF); // LSE activation error, handle as appropriate status = HAL_TIMEOUT; } // Select LSE as RTC clock source __HAL_RCC_RTC_CONFIG(RC
Hi, I'm using 3 channels of ADC4 with GPDMA1 (channel 4) in secure world of a TrustZone-project and the DMA-buffer stays always 0. The same ADC/DMA-configuration with the same application code (all mnus the security aspects) are working fine without TrustZone on the same hardware. I set the DMA-channel and the ADC-channel to secure and privileged, also the SAU-configuration for these peripherals is secure, the DMA-interrupt (circular) is triggered and calling HAL_ADC_ConvCpltCallback but there's nothing inside the DMA-buffer (which is defined as volatile inside a secure and privileged SRAM-area). I've tried different ADC conversion rates, clock rates and clock sources, checked for errors (especially overruns) and secure faults (with GTZC), there's absolutely nothing. I guess it must have something to do with secure/privileged areas or peripherals but since all the parts are secure and privileged I don't know what it could be. I'd be thankful for any suggestions; here is my ADC DMA-init
HelloWe are considering STM32 based processor for our next generation of products and would like to talk to a security expert with ST to discuss achieving CRA compliance.The "contact" page on the website down not provide a way to contact ST in the UK.
TL;DR:On STM32G0B1 with SBSFU + SECoreBin, I want to design a secure crypto/key enclave for the user APP.Enclave should be WRP/PCROP/MPU protected.Only accessible via SVC/gateway from the unprivileged APP.Should remain updateable through SBSFU (included in .sfb). Is this approach feasible, and what is the recommended way to implement it?Hello,I am designing a product based on the STM32G0B1KEU6 MCU. I have integrated my project into SBSFU to harden security as much as possible.Currently, secure boot and secure update are protected by design (RDP, WRP and PCROP for flash, MPU for RAM). I tried to access SECoreBin crypto services from the user application but that results in a HardFault (SBSFU is configured to forbid this, by design).My question: what is the most secure approach to provide crypto operations and key storage to the user application itself?Can I mimic a kind of “custom SECoreBin” dedicated to AES/ECC operations and key management for the APP?Conceptually, my idea
The reference manual mentions that data swapping can be used when e.g. processing ASCII, but I'm not clear on exactly what it does. If I set it to byte mode, does that mean I can write single byte values padded to 32 bits with zeros into the FIFO? And with the bit mode, can I write single bits padded to 32 with zeros? What if I don't pad with zeros and just write 31 random bits plus the 1 bit I care about?Obviously I can gather the bits together into a 32 bit word and write it in one go, but that will involve the CPU. If I can write bits, or even just bytes, with DMA, it will improve performance considerably.
Hello @Jocelyn RICARD , @D.Botelho I am trying to enable debug authentication on a stm32h573 mcu following this example: https://community.st.com/t5/stm32-mcus/how-to-enable-rdp-like-product-state-flash-protection-in-stm32h5/ta-p/708082.I was able to generate the obk file and to transition the device to provisioning state:This my xml file and the current product state: But when trying to provision the obk file, i got this error:Do you know what could be the problem and how to recover from this state and provision the device ?Thank you!
Hello!I am trying to provision a DA certificate on STM32H563 through CANFD Bootloader in system memory.I am calling special function 0x83 as described in AN2606 and AN5405. As I can understand, this is an RSSLIB_PFUNC->DataProvisioning.I am filling the structure and place it to the SRAM3. See the picture/hex.typedef struct { uint32_t *pSource; uint32_t *pDestination; uint32_t Size; uint32_t DoEncryption; uint32_t Crc; } RSSLIB_DataProvisioningConf_t;The structure is placed in 0x2005C000The 0x60 bytes of the obk payload is placed in 0x2005C000.The fuction returns Error code 0xF5F58080 (CRC Error).I've tried several algorythms, byte-reversal, but could not get it worked.I tried to find an example of using this function, but without success.So, I am asking for some code example showing this function.Maybe I need to prepare data somehow. Or add another data in crc calculations.Thanks!
Hello,I have two applications: one at 0x08000000 and one at 0x08080000. Both run fine individually (when setting the boot config bytes to the fitting offset). Now I want to use the one at 0x08000000 as secure area and escape it by using exitSecureArea. In the debugger, I can observe that the code runs fine until the very call to exitSecureArea. Now my questions are:1. Is there something else I need to to? This seems to suggest that I need to set the VTOR register. I currently (try to) do it before the call to exitSecureArea.2. If I need to setup the VTOR register, is my code below correct? Or do I need to do it differently/at a different place?3. Does exitSecureArea also work when the secure area is not set? I only tried without setting it as not to brick the device.4. Is there a way to debug this nicely? Spoiler (Highlight to read)typedef struct{uint32_t sizeInBytes; /*!< pass 0 for an empty secure area */uint32_t startAddress; /*!< pass NULL for an empty secure area
When I tried it, got the following error:2025-04-18 14:58:31,172 - DEBUG - Executing command: "C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exe" -c port=JLINK debugauth=22025-04-18 14:58:31,674 - DEBUG - -------------------------------------------------------------------2025-04-18 14:58:31,674 - DEBUG - STM32CubeProgrammer v2.19.02025-04-18 14:58:31,674 - DEBUG - -------------------------------------------------------------------2025-04-18 14:58:31,675 - DEBUG -2025-04-18 14:58:31,678 - DEBUG - Connecting to J-Link/Flasher Probe2025-04-18 14:58:32,043 - DEBUG - Device=Cortex-M332025-04-18 14:58:32,133 - DEBUG - Device ID : 0x4842025-04-18 14:58:32,134 - DEBUG - Voltage : 3.32V2025-04-18 14:58:32,135 - DEBUG - Frequency : 4000 KHz2025-04-18 14:58:32,218 - DEBUG - Flash size : 2 MBytes2025-04-18 14:58:32,221 - DEBUG - Error: Debug Authentication is not yet supported by J-Link2025-04-18 14:58:32,250 - ERROR - Command '"C:\Program Files\STMicro
Post edited by ST moderator to be inline with the community rules especially with the code sharing. In next time please use </> button to paste your code. Please read this post: How to insert source code Hello,I am trying to use AES GCM on the STM32U545.When I verify the result, I use the site "AES Encryption Online - Ciphereditor". In the vector, I have to input the value without the counter (0x02); otherwise, the results don't match.Why is this happening? Here are my test vectors: Data: 02 03 04 05 06 07 08 09Key: 59 9e b6 5e 6b 2a 2a 7f cc 40 e5 1c 4f 6e 32 57IV: d4 07 30 1c fa 29 af 85 25 98 1c 17 00 00 00 02AAD: 29 0A 0B 0C Configuration: aesGcmDesc.KeySize = CRYP_KEYSIZE_128B; aesGcmDesc.DataType = CRYP_NO_SWAP; aesGcmDesc.Algorithm = CRYP_AES_GCM_GMAC; aesGcmDesc.pKey = (uint32_t*)v->key; aesGcmDesc.pInitVect = (uint32_t*)v->iv; aesGcmDesc.pAAD = (uint32_t*)v->aad; aesGcmDesc.AADSize = 4; aesGcmDesc.TagSize = 16; aesGcmDesc.Timeout = 0xFF;
There are several peripherals that have a separate layer of protection based on privileged/unprivileged, here are some examples from the reference manual:MCE:39.2 MCE main features"AHB configuration port, privileged aware"RTC:49.2 RTC main features"Alarm A, alarm B, wake-up Timer and timestamp individual privilege protection"A first question would be: What privilege is being talked about?Is it the CPU's current (un)privileged mode when the CPU has sent the access request?Or is it the CPU's current (un)privileged mode independent of whether the CPU has sent the access request?Or is it any bus master's current (un)privileged mode (assuming every bus master has such concept) when that bus master has sent the access request?It does appear that other bus masters have privilege-based protection:GPDMA:12.2 GPDMA main features"Privileged/unprivileged support:- Support for privileged and unprivileged GPDMA transfers, independently at achannel level- Privileged-aware AHB slave port"HPD
Hi, I’m working on porting TF-M to a custom hardware platform based on the STM32U545 running Zephyr. As a starting point, I copied the existing b_u585_iot02a platform and adjusted it for the STM32U545’s 512 KB Flash. However, I haven’t been able to get it working. Has anyone already tried this port, or is there an existing example for the STM32U545?I add parts of the platform configuration files in attachment.Any guidance or references would be greatly appreciated!Lezhi
Hi everyone!In our project for stm32f446, we are trying to use X-CUBE-CRYPTOLIB to verify the firmware signature on the device using ED25519. Unfortunately, when trying to call the cmox_eddsa_verify method, we get the CMOX_ECC_ERR_MEMORY_FAIL error. The error occurs when memory is allocated. Tell me how to overcome this, or perhaps we are doing something wrong.Below is the codebool FirmwareCrypt::verify(const uint8_t* data, size_t size, const uint8_t* sign, size_t sign_size) { if (!data || !size) return false; cmox_ecc_handle_t handle; uint8_t ecc_buf[ECC_BUF_SIZE// 2048]; uint32_t fault_check = 0; memset((void*)&handle, 0, sizeof(cmox_ecc_handle_t)); cmox_ecc_construct(&handle, CMOX_ECC256_MATH_FUNCS, ecc_buf, ECC_BUF_SIZE); cmox_ecc_retval_t ret = cmox_eddsa_verify(&handle, CMOX_ECC_CURVE_ED25519, public_key, PUBLIC_KEY_SIZE, data, size/*~100Kb*/, sign, sign_size, NULL/*&fault_check*/); if (/*(static_cast<uint32_t>(ret) != fault_check) &&am
Hello Firends,Two Questions...1. Firmware Flash with DFU Bootloader succesfully done along with RDP bit. Can we re-flash the fiirmware once RDP L1 is set before through DFU using USB ? my custom board uses STM32F303Rb device. 2. Each STM32 device has UID of 96 bit, Can we use this UID to Club with Firmware so that each firmware image is specifc to that particular Device ? Pls. suggest any Hardware tool / Software tool avilable for same. I found one is segger Flasher secure device, but very expensive. Regards,Bsuthar
I am trying to write a .bat script to reliably flash my combined sbsfu and application binary to a stm32h755. set cube_programmer_cli="C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeProgrammer\bin\STM32_Programmer_CLI.exe" set fw_bin="combined_sbsfu_cm7_cm4.bin" set fw_base=0x08000000 if not exist %fw_bin% ( echo Firmware binary not found. Exiting exit /b) if not exist %cube_programmer_cli% ( echo Cube Programmer CLI not found. Exiting exit /b) @REM Load the combined binary echo Installing combined_sbsfu_cm7_cm4.bin %cube_programmer_cli% -c port=SWD -w %fw_bin% %fw_base% %cube_programmer_cli% -c port=SWD -ob displ echo Setting option bytes... echo Setting WRP protection... @REM Ensures the bootloader application is under write protection @REM 0 is protected, 1 is unprotected %cube_programmer_cli% -c port=SWD -ob nWRP0=0 echo Disabling CM4 boot and SWAP_BANK... @REM Swap bank is unset by default but it is explicitly checked in the bootloader so disabled here %cub
Hi,I am currently facing an issue where TrustZone cannot be disabled on the STM32U545 device with custom hardware.1. [Part Number] STM32U545VET6 on custom hardware2. [Environment] STM32CubeProgrammer 2.20.0 with ST-LINK V2; custom Zephyr application and custom TFM platform3. [Schematics] PH3 (BOOT0) is connected to 3.3V when changing the RDP from Level 0 (AA) to Level 1 (DC)4. [Details]I flashed a custom secure application with TFM onto the device, but it was not working. I wanted to disable TrustZone and return the chip to a “normal” state. Following AN5347 (Section 9.1.2) and an ST Community post, I attempted to perform a regression.Everything worked until I set the RDP to Level 1. However, after power-cycling the target, I could no longer connect to the device. Regardless of how I reset the target or change the ST-LINK connection mode (Hotplug, Under Reset, etc.), I only receive errors such as the following:BOOT0 to VDD:BOOT0 to the ground:5. [Expected
Hello Guys,I tried defining STIROT_ILOADER_DEBUG in the main.h of the iLoader and then i built it and uploaded the Code via script after getting loaded only STiROT Application Logs are are printing but STiROT_iLoader logs are not printing, how can i resolve this issue?
Greetings, I am using a STM32U585 MCU and I made a custom made code that implements the DFU protocol. I could successfully flash a firmare through .bin file and set the Option Bytes, set RDP level 1 and go back to RDP level 0. What I want to do is to be able to flash an encrypted firmware into the board using my method. So obviously, I can't do it through the STM32CubeProgrammer or STM32TrustedPackageCreator since I don't want to depend from any ST HSM smartcard, so I guess I can't do it with SFI way. Is there any other way to encrypt a firmware file, then upload it to the board and the board itself be capable of decrypt the firmware and run it? BTW, I am being using the B-U585I-IOT02A board to make the tests.Thank you!
Hello,I would like to use the TFM application on STM32CubeIDE for the B-U585I-IOT02A board but I can't find the application anywhere. Any help?
Hi,I'm working on the evalboard of the STM32H563. With a plain project I'm able to activate the memory mapped mode of a plugged nor-flash.If I change the project to have Trustzone activated and divided the application in secure/non-secure part, I'm not able to activate the memory mapped mode. The communication to the flash is basically working because I can read the ID. The hal functions don't give any error, so I expect that everything should work.Has anybody an idea what the problem can be? Best regards,Stefan
ST Community highlights – April to June 2026
Already have an account? Login
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.