S32K144 CSEc CMAC Verify

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

S32K144 CSEc CMAC Verify

跳至解决方案
1,020 次查看
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 项奖励
回复
1 解答
979 次查看
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 项奖励
回复
1 回复
980 次查看
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 项奖励
回复