Decrypt AES CBC

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

Decrypt AES CBC

2,587 Views
Bkaya
Contributor III

Hello Everyone;

I have custom board with RT1176. In my application, i am decrypting the encrypted bin file. If i read all encrypted bin file at once and send the datas to decryption functions, it works correctly but as you can guess i have to use lots of ram space.

I change my code to decrease the usage of ram. I am reading data 256 bytes and after that decrypting the data for almost 200 times. When i debug my code, decryption process is done only one time(first cycle) successfully. After that, decryption process is not working.

What am i doing wrong? Can you help me?

Bkaya_0-1711433255320.png

 

Best Regards,

Basri KAYA

@kerryzhou 

0 Kudos
Reply
7 Replies

2,524 Views
Bkaya
Contributor III

Also i realized something new for me. I copied&pasted AesCbcExample functions, variables, input vector, etc. inside of the caam_cm7 sdk example and debuged it. It did not work successfully. Encrypted file missmatched with expected encrypted file.

Is this example works correctly? 

Bkaya_0-1711462287649.png

0 Kudos
Reply

2,327 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @Bkaya ,

 Can you upload your demo which can reproduce the issues directly, then I can test it on my side directly,

 So sorry for the later reply, really a little overflow recently for the other customer's cases testing.

 

Best Regards,

kerry

0 Kudos
Reply

2,253 Views
Bkaya
Contributor III

Hi @kerryzhou ,

All developers may be busy time to time so no problem. I just want to fix and understand the issue.

I shared the demo with you but as i mentioned i did not used this demo code directly for the second problem. I copy pasted same functions and variables to my custom board. Also if you will test it, i will be glad.

Do you have any idea for my first problem what cause that? I checked reference manuel and datasheet but i did not find the problem.

Best Regards,

Basri KAYA

0 Kudos
Reply

2,241 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @Bkaya ,

   Thanks a lot for your understanding.

   Sure, I can test it on my MIMXRT1170-EVK board, and I find your attached code is totally the SDK demo, right?

   I mean, how to reproduce your issues in the SDK demo:decryption process is done only one time(first cycle) successfully. After that, decryption process is not working.

  Can you also add some code in the caam.c from the SDK to reproduce the issues? I think, we can use some fixed data in the RAM, then to test it.

  You also can modify the camm.c, which can reproduce the issues, then I can test it on my RT1170-EVK directly.

  About your first question, still need to reproduce the issues to check the detail situation, even need to discuss with our expert internally. So reproduce issues on my side EVK is very important.

 

Best Regards,

Kerry

0 Kudos
Reply

2,235 Views
Bkaya
Contributor III

Hi @kerryzhou ,

- Yes, code that shared is SDK Demo code. For second problem, you can run the demo directly. I got errors while debugging as i mentioned above.

- I have 50 Kb encrypted bin file and i want to decrypte every cycle 256 bytes of that file untill 50Kb. Yes, as you said first time decryption process works correctly.

- I tried to modify caam.c simply as in my project. You can understand what i am trying to do. I did not test the code cause i do not have EVK-Board. I hope it works.

- If it is not enought for you, i want to modify caam.c as you wish but i am reading bin file from USB so i have to modify whole project. I also do not have permission to share my project. If you can write a scenario about how you will read data etc., i can try to modify. I can take a screen record while debugging and share with you. Is it fine?

Best Regards,

Basri KAYA

 

0 Kudos
Reply

2,568 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @Bkaya ,

  I am really appreciated your effort and testing.

  Do you also have the NXP MIMXRT1170-EVK or EVKB board?

  Can you reproduce the issue with the simple code on our NXP board?

Then, I can help you do the detail testing, thanks.

 

Best Regards,

Kerry

0 Kudos
Reply

2,561 Views
Bkaya
Contributor III

Hi @kerryzhou ,

I do not have EVKB board. Therefore, i am using my custom board.

I will try to explain my problem clearly. Also i downloaded SDK example which is caam_cm7 and used it as an example code.

In my code:

1) I set CAAM_Init(). 

Bkaya_0-1711440799687.pngBkaya_1-1711440837393.png

2) I am reading encrypted bin file 256 bytes, decrypting it by using CAAM_AES_DecryptCbc() function and writing the data to flash. 

First time of the loop, decyption process done successfully.

Bkaya_3-1711441149958.pngBkaya_4-1711441211334.png

Second time of the loop, decryption process did not work but it returned success. After this point to end of the for loop, all decryption process will return 0s. Hence, i can not write correct main application to the flash.

Bkaya_5-1711441341514.pngBkaya_6-1711441381302.png

Therefore, i think i am missing some important things. If you ask me, what did i do to solve this issue?

- I tried to find application note but i did not find which match with my problem.

- I tried to init Caam begining of the loop and deinit it end of the loop. It did not work.

- I used Caam_wait() function between multiple process. It did not work so,

What am i doing wrong? Can we solve this problem or should i write custom decryption firmware?

Best Regards,

Basri KAYA

 

 

 

0 Kudos
Reply