Hi,
I'm using S32K144, trying to use CSEc key11~17 update oher keys, since M1 message's Auth ID is 4 bit and doesn't have 1 bit KBS as KeyID. It seems impossible to do this.
解決済! 解決策の投稿を見る。
Hi @yaojianhang
that's very good point. I did some debugging on my side and I found out that there's a bug in the calculate_M1_to_M5 function.
I already mentioned this code:
key_id = key_id & 0x0F; //For keys in the other bank, don't consider the KBS bit in M1 & M4 calculation. Follow traditional SHE specs
However, this is not enough. Also AuthID should be modified in the same way when calculating M1 and M4. From AN5401:
And:
So, I added this code:
auth_key_id = auth_key_id & 0x0F;
... and everything works as expected now.
Thank you for pointing this out, I will report it.
Regards,
Lukas
Hi @yaojianhang
let me share some screenshots:
From the reference manual:
In application note AN5401:
In source files of AN5401:
And regarding the second question, this can be found in AN5401:
This is given by SHE specification. RAM_KEY can be updated anytime, you do not need to know MASTER_ECU_KEY or previous value of the RAM_KEY.
Regards,
Lukas
In this code,use CSEC_KEY_11 updates CSEC_KEY_11 return ERC_KEY_INVALID, use MASTER_ECU_KEY updates CSEC_KEY_11 return no error.
How to use CSEC_KEY_11 updates CSEC_KEY_11? Is it possible? Thanks for you reply.
Regards,
yaojianhang.
Hi @yaojianhang
that's very good point. I did some debugging on my side and I found out that there's a bug in the calculate_M1_to_M5 function.
I already mentioned this code:
key_id = key_id & 0x0F; //For keys in the other bank, don't consider the KBS bit in M1 & M4 calculation. Follow traditional SHE specs
However, this is not enough. Also AuthID should be modified in the same way when calculating M1 and M4. From AN5401:
And:
So, I added this code:
auth_key_id = auth_key_id & 0x0F;
... and everything works as expected now.
Thank you for pointing this out, I will report it.
Regards,
Lukas
additions:
can CSEc key11~17 update themselves and ram_key?