AES Encryption using DMA on RT 595

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

AES Encryption using DMA on RT 595

410 Views
paulM90
Contributor II

Hi guys. I'm an intermediate level embedded systems engineer trying to transition a project from STM32F4/7 series over to an NXP I.MX RT 595. So far, I've relied on both the documentation and the provided examples (stellar, kudos NXP - especially for providing CMakes, for use with arm gcc) to breeze my way through porting over 70% in less than a week.

Full disclosure - I'm not that experienced with NXP products or the SDK (touched a development board for the first time about a week ago) and I'm trying to do encryption using HASHCRYPT + DMA.

I'm only going to be encrypting aligned buffers (divisible by 4 words, no more than 8064 words, so as not to exceed the 11-bit MEMCTRL register.

So far, I have the following workflow:

1. I set the appropriate registers (initialization sequence, setting the key, the iv, the length etc.).

2. The actual encryption

 

    // THIS IS BASICALLY COPY - PASTE FROM THE hashcrypt_aes_one_block FUNCTION
    HASHCRYPT->MEMADDR = HASHCRYPT_MEMADDR_BASE(plainAes128);
    HASHCRYPT->MEMCTRL = HASHCRYPT_MEMCTRL_MASTER(1) | 
    HASHCRYPT_MEMCTRL_COUNT(size / 16U);
    while (size >= HASHCRYPT_AES_BLOCK_SIZE)
    {
        /* Get result */
        while (0U == (HASHCRYPT->STATUS & HASHCRYPT_STATUS_DIGEST_MASK))
        {
        }
        memcpy(outputEncrypted, (uint32_t*)HASHCRYPT->DIGEST0, 16);
        idx += HASHCRYPT_AES_BLOCK_SIZE / 4U;
        size -= HASHCRYPT_AES_BLOCK_SIZE;
    }
    HASHCRYPT->CTRL &= ~(HASHCRYPT_CTRL_MODE_MASK);

 

3. Deinit the module.

From what I imagine, in order to use DMA, I should use a DMA channel that copies data from the peripheral over to the output buffer.

What gives me grief is how I should configure the DMA, exactly. I figure the DMA controller needs to poll for the HASHCRYPT-> STATUS and afterwards to actually copy the data over to the destination.

Any kind of assistance would be greatly appreciated.

 

Thank you for your time!

0 Kudos
2 Replies

341 Views
paulM90
Contributor II

If I would have managed by myself, I would not have asked for help, Mr. Miguel. Though I must be frank, I expected someone to have already done that - how lazy of me. I'll try to figure it out and I'll post the solution here.

0 Kudos

365 Views
Miguel04
NXP TechSupport
NXP TechSupport

Hi @paulM90 

I recommend you to read chapter 16.1.5 Chip-specific DMA Initialization from the reference manual and look into the examples provided on the sdk to see how is the DMA used and verify if you missed something during the initialization of your custom project.

Best Regards, Miguel.

0 Kudos