MCAL: S32K148: Getting ERC_KEY_INVALID for CSEC jobs(e.g Csec_EncryptEcb)

cancel
Showing results for 
Search instead for 
Did you mean: 

MCAL: S32K148: Getting ERC_KEY_INVALID for CSEC jobs(e.g Csec_EncryptEcb)

Jump to solution
149 Views
Pravin_Javalge
Contributor III


Hello,

I am using MCAL Csec driver which is received by NXP.

I have done the program partition and I am able to write Master key and keys(for e.g. KEY_2) using Csec APIs commands successfully but when I try to execute Csec_EncryptEcb(CSEC_KEY_2, aPlainText_Enc, 16U, aCipherText_Enc); then I am getting ERC_KEY_INVLAID.

aPlainText_Enc and aCipherText_Enc is array of 16 bytes

Can you please help what is the root cause here as I have taken care counter value(i.e set to 1 while writing first time) and flags (set to 1 i.e. only wild card is enable) while writing keys

BR,
Pravin

0 Kudos
1 Solution
140 Views
namnguyenviet
NXP Employee
NXP Employee

Hello,

Please verify that your flag attributes were set correctly. Probably the bit was written to the KEY_USAGE flag instead of the WILDCARD field. 

namnguyenviet_0-1642415066880.png

You can try this way: write another key value with flag = 0 in all fields and different counter to a key, then use that key to encrypt. If it can be performed, then probably the key attributes were set incorrectly with previous key value.

Best Regards,

Nam

 

View solution in original post

0 Kudos
1 Reply
141 Views
namnguyenviet
NXP Employee
NXP Employee

Hello,

Please verify that your flag attributes were set correctly. Probably the bit was written to the KEY_USAGE flag instead of the WILDCARD field. 

namnguyenviet_0-1642415066880.png

You can try this way: write another key value with flag = 0 in all fields and different counter to a key, then use that key to encrypt. If it can be performed, then probably the key attributes were set incorrectly with previous key value.

Best Regards,

Nam

 

0 Kudos