HSE AES182 encryption not working correctly

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

HSE AES182 encryption not working correctly

跳至解决方案
495 次查看
Rmpr
Contributor II

Hello, I'm trying to encrypt an array of 16 of a plain text:

uint8 Data_au8[AES128_ECB_PLAIN_TEXT_SIZE] = {
    0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
};

 

With the array initialized like this, this works fine since it gives the the following encrypted array:

Rmpr_0-1746450034995.png

 

But, this is not what I want my code to do, I want to change the values of the array in my main function, but If I do this:

uint8 Status_u8 = 0x01u;

uint8 Data_au8[AES128_ECB_PLAIN_TEXT_SIZE] = {
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
    0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
};

int main()
{
    Data_au8[0] = Status_u8;
    Data_au8[1] = Status_u8;

    /* Encryption */
}

 

It doesn't encrypt properly:

Rmpr_1-1746450566196.png

 

What could be causing this?

Thank you in advance!

标记 (4)
0 项奖励
回复
1 解答
474 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @Rmpr 

This sounds like data cache issue. All the data objects used for communication with HSE must be forced to non-cacheable memory. The data cache is usually configured to copy-back mode and HSE can't see the data cache on core(s), so this may cause coherency issues. HSE always accesses physical addresses only.

For quick test, you can try to disable the data cache completely. Either in your project settings or in your debugger:

lukaszadrapa_0-1746517563666.png

lukaszadrapa_1-1746517680478.png 

Regards,

Lukas

 

 

在原帖中查看解决方案

0 项奖励
回复
2 回复数
475 次查看
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi @Rmpr 

This sounds like data cache issue. All the data objects used for communication with HSE must be forced to non-cacheable memory. The data cache is usually configured to copy-back mode and HSE can't see the data cache on core(s), so this may cause coherency issues. HSE always accesses physical addresses only.

For quick test, you can try to disable the data cache completely. Either in your project settings or in your debugger:

lukaszadrapa_0-1746517563666.png

lukaszadrapa_1-1746517680478.png 

Regards,

Lukas

 

 

0 项奖励
回复
466 次查看
Rmpr
Contributor II
That solved the problem.
Thank you!
0 项奖励
回复