HSE AES182 encryption not working correctly

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

HSE AES182 encryption not working correctly

Jump to solution
379 Views
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!

0 Kudos
Reply
1 Solution
358 Views
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

 

 

View solution in original post

0 Kudos
Reply
2 Replies
359 Views
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 Kudos
Reply
350 Views
Rmpr
Contributor II
That solved the problem.
Thank you!
0 Kudos
Reply