This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

aes crypt hangs

Hello,

I'm trying to make use of the AES crypt code from the application level code.

Per devzone.nordicsemi.com/.../51822-aes-encryption-and-decryption-demo-code

I'm trying to implement the CTR approach.

However, whenever I call the aes encrypt code, the system seems to hang/die.

I have tried using: nrf_ecb_init(); nrf_ecb_set_key(key); nrf_ecb_crypt();

and

sd_ecb_block_encrypt()

In the top case, it dies upon entry to nrf_ecb_init(). And then if I try only sd_ecb_block_encrypt(), this also "dies".

By "dies" I mean that it enters the method and never returns. (step over in debugger)

Is there something we are supposed to do to enable AES access from the app?

I'm using S110 6.0, latest SDK, target is nrf51822

Thank you,

Matthew

  • When using the softdevice, you need to make sure to not use blocks that are listed as restricted or blocked directly from your application. If you do, you'll see a HardFault. You can see a list of these peripherals in the SoftDevice Specification, and the ECB block is one of them. This is the reason taht the nrf_ecb_* functions fail. (If you halt the device with the debugger after having tried to call one of these functions, you should be able to easily see that it hangs in the HardFault_Handler of arm_startup_nrf51.s.)

    As for the reason for sd_ecb_block_encrypt() "fails", I suspect that what you see is that debugging isn't really possible when any time critical activities have been started with the softdevice (advertising, connection). This has been discussed at length here previously, for example here and here. If however you run this AES code before starting advertising or a connection, you should be able to debug this code as you want.

  • Yes, sorry, I meant to delete this question, as I determined exactly as you wrote a few hours later. thank you!

Related