CSE services in MPC5777c

cancel
Showing results for 
Search instead for 
Did you mean: 

CSE services in MPC5777c

291 Views
tong_zhou
Contributor I

CSE services debug in mpc5777c:

Problem1: authentication for master ECU key

1, after set authkey(master ecu key), then check if the written key is the known key. Referring to manual of mpc5777c, compare UIDmac what is generated by get UID command with the mac calculated over the concatenation of a 128-bit input challenge value, UID(120bit), and CSE_SR[24:31] as the manual said. But the result of verify mac command indicated that is mismatched. source code for example:

for (i = 0; i < 16; i++)
{
verif[i] = get_id_challenge[i];}   //fill msg content 0~15 byte with challange value;
for (i = 0; i < 15; i++)
{
verif[16 + i] = UID[i];} //fill msg content 16~30 byte with UID generated by get UID command;
verif[31] = sreg; //fill msg content 31 byte with sreg generated by get UID command correspond to cse_sr[24]~cse_sr[31]
stat = CSE_DRV_LoadPlainKey(g_authIdKey);
if (stat != CSE_NO_ERR)
return stat;
stat = CSE_DRV_VerifyMAC(CSE_RAM_KEY, verif,256,UID_MAC, 128U);

to authenticate the g_authIdKey is the designed key, i called a load key command, the result indicated the g_authIdKey is what i have designed, wihch has been written into CSE, so eliminate the fault of g_authIdKey otherwise load new key will not success.

Problem2: erase all user key process

as you konwn, DbgAuth command need an authentication input, what is described as using the DEBUG_CHAL command output and the UID, so i want be sure that the input is simply the concatenation of random challenge generated by DEBUG_CHAL command and UID.

source code for example:

stat = CSE_DRV_DbgChal(challenge);
if (stat != CSE_NO_ERR)
return stat;

for (i = 0; i < 16; i++)
{
authPlain[i] = challenge[i];} //fill authPlain text with random challenge value generated by get DEBUG_CHAL ;
for (i = 0; i < 15; i++)
{
authPlain[i + 16] = uid[i];}   //fill authPlain text with UID value what is generated by get UID command;

stat = CSE_DRV_GenerateMAC(CSE_RAM_KEY, authPlain, 248U, auth);
if (stat != CSE_NO_ERR)
return stat;

stat = CSE_DRV_DbgAuth(auth);

I will appreciate anyone for answering the above questions.

0 Kudos
1 Reply

150 Views
tong_zhou
Contributor I

after the guidance of local FAE, now the above problems have been solved.

problem 1:

resulting from sreg value, in original code sreg is directly read from CSE_P3_R, its value should be read and write after get ID command, after modify, UID mac matched;

problem 2:

be sure that the input is simply the concatenation of random challenge generated by DEBUG_CHAL command and UID;

after  debug_auth command,  CSE set CSE_SR_IDB that indicates it has erased all user keys;

But when i reset, one error happened, the CSE return 0x13 error code(fatal error), it confused me so much!

0 Kudos