cancel
Showing results for 
Search instead for 
Did you mean: 

CMSIS cmox_mac_compute() with trustzone on Secure CRC peripheral

TMO
Visitor

Hello , 

I am trying to calculate a MAC using `cmox_mac_compute()` from this lib on an STM32L562 in the Secure code.

The code looks like this :

auto r = cmox_initialize(NULL); /*default template with stm32l5xx.h included*/
auto ret = cmox_mac_compute(CMOX_CMAC_AES_ALGO,
	                       in, in_s,
	                       key, 16,
	                       NULL, 0,
	                       out, 16, NULL);

This exact code works when run on non secure mode if everything is set as non secure in stm32CubeMX.
I tried to debug the library to understand what was wrong and found out that the issue comes from the fact that cmox_mac_compute tries to access my crc peripheral from 0x40023000 instead of 0x50023000 (CRC non secure and secure addresses).
I am also almost sure that my GTZ and SAU are correctly set because i was able to write at address 0x50023000 and not at 0x40023000 when running from Secure code.

I also have :

CRC_BASE_S => 0x50023000
CRC_BASE_NS => 0x40023000
CRC_BASE => 0x50023000

So this looks fine. I also tried to forcefuly set CRC_BASE_NS to 0x50023000 but the cmac calculation was wrong again (still the same as when it doesn't work).

Because of these reasons , i guess that CMSIS isn't using CRC_BASE but an instance or something not directly linked to CRC_BASE.

I suppose that has to be done in 'cmox_initialize' or something similar but couldn't find anything to set the address or the mode to 'Secure execution context' so the library accesses the CRC through its secure address.

Also , i am effectively compiling the secure version in the secure elf and the same goes for non secure.

Can anyone help reguarding this matter ?  

0 REPLIES 0