cancel
Showing results for 
Search instead for 
Did you mean: 

CRYP unit not working on ST32F407

johannes2
Associate II
Posted on August 29, 2012 at 15:03

Hi forum,

I'm having trouble getting the CRYP unit working on a ST32F407. First I've tried manually (failed) and -- thinking that I did something wrong -- tried with the ST provided libraries (which also don't work). I'm doing something wrong, I'm very sure, but I can't figure out what. First off: Yes, I have the device properly enabled:

[code]

RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_CRYP, ENABLE);

[/code]

then, I use this:

[code]

        CRYP_InitTypeDef x;

        memset(&x, 0, sizeof(x));

        x.CRYP_AlgoDir = CRYP_AlgoDir_Encrypt;

        x.CRYP_AlgoMode = CRYP_AlgoMode_AES_ECB;

        x.CRYP_DataType = CRYP_DataType_32b;

        x.CRYP_KeySize = CRYP_KeySize_128b;

        CRYP_Init(&x);

    }

    {

        CRYP_KeyInitTypeDef x;

        memset(&x, 0, sizeof(x));

        CRYP_KeyInit(&x);

    }

    CRYP_FIFOFlush();

    CRYP_Cmd(ENABLE);

    /* Write input data */

    for (int i = 0; i < 4; i++) {

         CRYP_DataIn(((uint32_t*)aSource)[i]);

    }

    printf(''Waiting...\r\n'');

    /* Wait until finished */

    while (!CRYP_GetFlagStatus(CRYP_FLAG_OFNE));

[/code]

(this never finishes, i.e. it's not yielding any data). Then I tried the ''high level'' function, which should do everything for me

[code]

printf(''Result: %d\r\n'', CRYP_AES_ECB(MODE_ENCRYPT, (unsigned char*)aKey, 128, (unsigned char*)aSource, 16, aDestination));

[/code]

...which fails with error 1.

Any ideas?

Best regards,

Joe

#stm32f407-cryp-aes128
5 REPLIES 5
johannes2
Associate II
Posted on August 29, 2012 at 15:25

Ouch. This hurts.

The 407 doesn't have a CRYP unit. The 417 does.

Sorry for the post,

Best regards,

Joe
Posted on August 29, 2012 at 15:57

The 407 doesn't have a CRYP unit. The 417 does.

 

Yep, that's pretty much the problem. Avoids a lot of the ITAR/Export joy.

You should be able to look at the RCC clock enable bit, and determine it never gets set.

There are less 417 part choices, basically a 512KB and 1MB flash version, from a common die.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
johannes2
Associate II
Posted on August 29, 2012 at 18:13

Ah, I didn't check if the bit in RCC actually got set. What got me curious was that CRYP->CR->CRYPEN never got set.

However, I somehow would've expected a fault. Accesses to that memory area on the 407 don't trap, but don't execute either. Interesting to know. But thanks for the tip, will check RCC next time, too.

rajesh
Associate
Posted on August 23, 2013 at 11:16

Hi I am Testing CRYP on STM32f407VG RCC also configured but in CRYP Registers are not loading.

thanks ..

Posted on August 23, 2013 at 14:08

The 407 doesn't have a CRYP or HASH engine, so don't be surprised that it doesn't work. You will need a 417 part.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..