MPC5775 - CSE key update

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

MPC5775 - CSE key update

1,726 次查看
jochengerster
NXP Employee
NXP Employee

Hi

need help with the request from a direct customer using CSE module of MPC5775E/MPC5775B microcontroller - see below their query:

I am trying to implement the key update procedure in CSE as described in AN5418 (rev 0 03/2017). I have managed to successfully update keys in slots KEY_1-KEY_10 but I have trouble updating the keys on slots KEY_11-KEY_20.
I am not sure which value shall be used as keyId when generating m1. Since keys on slots KEY_11-KEY_20 share same id as appropriate keys on slots KEY_1-KEY_10 and only differ by the KBS bit setting I tried to use same Ids (e.g. Key_1 and Key_11 use same ID for m1 generation). I verified that the Crypto_CSE driver sets the KBS bit as expected, but then when the LOAD_KEY command is executed the driver returns '0x08 Key update error' via CSE_ECR register.
I also tried the second option and generated m1 using the key id with KBS bit included (e.g. For Key_19 I used id equal to 0x1C). In such case I was receiving '0x04 Invalid key' error via CSE_ECR register. But after all, in this case error is expected since keyId and authKeyId must each fit on 4 bits of m1.
I tried using both MASTER_ECU_KEY (after setting it) and the keyId of the key being updated for AuthID input for m1 generation, and I used appropriate values for KDF input (I used all zeros for the key being update the first time with AuthID being set to the new key ID). No combination solved the issue.
I performed factory reset and confirmed it was successful before each test.
For more context:
I am not settings any flags, and I am using wildcard UID (all 0x00).
I am using MCAL version:
* Autosar Version : 4.3.1
* Autosar Revision : ASR_REL_4_3_REV_0001
* Autosar Conf.Variant :
* SW Version : 1.0.2
* Build Version : MPC5777C_MCAL_1_0_2_RTM_ASR_REL_4_3_REV_0001_20221004

Could you please provide some advice on the issue? Perhaps you would be able to provide some example code or example values of m1-m5 and k1-k4 for update of the key from Key11-Key20 range?

 

thanks

best regards

Jochen

0 项奖励
回复
3 回复数

1,712 次查看
jochengerster
NXP Employee
NXP Employee

To me KEY11to20 use the same key IDs for the calculations, as for the key1to10.

jochengerster_0-1737384243384.png

 

 

jochengerster_1-1737384243408.png

 

 

Regarding “Key update error” can you share more details and what to check

jochengerster_2-1737384243414.png

thanks

Jochen

0 项奖励
回复

1,692 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @jochengerster 

I agree, it should be just about setting of the KBS bit before using/loading/updating keys 11-20.

I wanted to test it to be absolutely sure but I have some troubles with my EVB. I should get another board at beginning of the next week. Please wait for results of my test...

Key update error will occur when M1-M3 values are not correct or when counter is not higher than previous value.

Regards,

Lukas

0 项奖励
回复

1,658 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

I found out that there's no more thing we need to consider in addition to KBS bit:

lukaszadrapa_0-1737980501814.png

I tried to modify cse_keyconfig_mpc5777c example in SDK. The SDK driver correctly updates KBS bit. But the sample code which calculates M1-M5 does not take KEY11-KEY20 into account. So, I tried to add the constants mentioned above but I still can't make it working. I also found in history that these two things (KBS and the constants) is the only difference when using KEY11-KEY20. It's probably just some minor SW issue on my side. I will do more tests tomorrow.

0 项奖励
回复