S32K144 CSEc CMAC Verify

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K144 CSEc CMAC Verify

Jump to solution
988 Views
soulyoung
Contributor I

Hello, I have encountered some issues here. When I was using CSEc's CMAC verification, I found that the message length I verified was 10500 or 105600. The CSEC_DRV_VerifyMAC function would tell me that there was an ERC_SQUENCE-ERROR, but my size changed to 105601105602 and I succeeded. What is the reason for this?

0 Kudos
Reply
1 Solution
947 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @soulyoung 

I confirmed there's a bug in the SDK driver. 

It won't work if the message length is:

from 641 to 768

from 1537 to 1664

from 2433 to 2560

etc. 

There's wrong logic when writing MAC to CSEC PRAM memory. 

The SDK is not maintained anymore, so it won't be updated. But you can fix it like this:

Find CSEC_DRV_StartVerifMACCmd function in csec_driver.c and replace this line:

if ((macOffset + CSEC_PAGE_SIZE_IN_BYTES) < CSEC_DATA_BYTES_AVAILABLE)

with this line:

if ((g_csecStatePtr->fullSize - g_csecStatePtr->index) <= (CSEC_DATA_BYTES_AVAILABLE - CSEC_PAGE_SIZE_IN_BYTES))

Then it should work. 

Regards,

Lukas

 

View solution in original post

0 Kudos
Reply
1 Reply
948 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @soulyoung 

I confirmed there's a bug in the SDK driver. 

It won't work if the message length is:

from 641 to 768

from 1537 to 1664

from 2433 to 2560

etc. 

There's wrong logic when writing MAC to CSEC PRAM memory. 

The SDK is not maintained anymore, so it won't be updated. But you can fix it like this:

Find CSEC_DRV_StartVerifMACCmd function in csec_driver.c and replace this line:

if ((macOffset + CSEC_PAGE_SIZE_IN_BYTES) < CSEC_DATA_BYTES_AVAILABLE)

with this line:

if ((g_csecStatePtr->fullSize - g_csecStatePtr->index) <= (CSEC_DATA_BYTES_AVAILABLE - CSEC_PAGE_SIZE_IN_BYTES))

Then it should work. 

Regards,

Lukas

 

0 Kudos
Reply