cancel
Showing results for 
Search instead for 
Did you mean: 

Reset Host Cipher and Mac Key in STSafe IC?

MBuen.1
Senior

Hello guys, how are you all?

I'm currently developing using the X-NUCLE-SAFEA1 board integrated with an STM32WB55. I was executing the pairing example generating a randomic mac and cipher key. I stored successfully this keys into the STSafe, but my program failed to save in the MCU flash, and now these both keys are lost.

Is it possible to reset these keys? I was reading the restricted datasheet and there it says that i need an admin c-mac to execute this operation. I didn't quite got it what this actually means.

Thanks in advance,

Matheus

1 ACCEPTED SOLUTION

Accepted Solutions

Hi Matheus,

Yes, when the key are blocked, each command with HOST C-MAC will return error 0x0B in response header.

Regarding the Host Keys, the configuration in the STSAFE-A is a one-time operation, you can't overwrite the Host Keys when they are configured in the STSAFE-A.

Best Regards,

Benjamin BARATTE

View solution in original post

5 REPLIES 5
Jocelyn RICARD
ST Employee

Hello Matheus,

unfortunately you have no way to recover if you lost the pairing keys because the admin secure channel is not available.

You have to get another X-NUCLEO-SAFEA1

Best regards

Jocelyn

MBuen.1
Senior

Oh, that's sad to hear :sad_but_relieved_face:

The pairing example provided by ST has the following key as default:

uint8_t Host_MAC_Cipher_Key[2U * STSAFEA_HOST_KEY_LENGTH] = {
  0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA,0xBB,0xCC,0xDD,0xEE,0xFF,    /* Host MAC key */
  0x11,0x11,0x22,0x22,0x33,0x33,0x44,0x44,0x55,0x55,0x66,0x66,0x77,0x77,0x88,0x88     /* Host cipher key */
};

Could you confirm me if it is possible to populate STSafe with these keys? If these keys are stored in STSafe, is it possible that these specifically default keys be overwritten?

I'm asking you that because i'm almost 100% sure that these keys were the first one that i stored in the IC and yet i'm not able to communicate commands that require secure channel. Only after testing these default keys i started to generate and store random keys.

Thanks in advance,

Matheus

Benjamin BARATTE
ST Employee

Hi Matheus,

Around the pairing keys (Host Keys) in the X-CUBE-SAFEA1, you have 2 types of application, pairing app and STSAFE-A example.

In the pairing app, by default, default Host keys are loaded in the STSAFE-A and at the end of the MCU flash memory (on STM32L476) if the host keys are not present in the STSAFE-A.

If the Host Keys are already loaded in the STSAFE-A, the pairing application is doing nothing.

If you want to force the Host Keys writing in flash, you have to define _FORCE_DEFAULT_FLASH_, in that case the default keys will be written at the end of the MCU flash.

But this is only needed if in your application, you are loading the Host Keys from flash.

In the applicative example, you have a default configuration in stsafea_interface_conf.h, you have the #define USE_PRE_LOADED_HOST_KEYS if it's set to 1, you will load the key from flash, if it's set to 0, you will use the default keys.

Be aware also, that after 50 commands with wrong C-MAC in a row, the Host Keys will be blocked and you can no longer use them.

So, if you have loaded the default Host Keys in the STSAFE-A, i would recommends to use #define USE_PRE_LOADED_HOST_KEYS 0 in order to use hard coded default Host Keys.

Let me know if you still have issue with your setup.

Best Regards,

Benjamin BARATTE

MBuen.1
Senior

Hey @Benjamin BARATTE​ ,

"Be aware also, that after 50 commands with wrong C-MAC in a row, the Host Keys will be blocked and you can no longer use them."

If this is the case, the STSafe header would me return 0x0B (key blocked error) at any C_MAC command i try, right? If that's so, i guess that's what happened.

Also, just to make sure i understood correctly, even if i put (put attribute cmd) the example default host keys (0x11,0x22,0x33 ...) in STSafe, these keys can't be overwritten by a randomic one, right?

Regards,

Matheus

Hi Matheus,

Yes, when the key are blocked, each command with HOST C-MAC will return error 0x0B in response header.

Regarding the Host Keys, the configuration in the STSAFE-A is a one-time operation, you can't overwrite the Host Keys when they are configured in the STSAFE-A.

Best Regards,

Benjamin BARATTE