How to use AES128 ECB for decryption

Hi,

I am using nRF51822, and try to use the ECB block AES128 to do some data decryption. From the SDK I found 2 API functions:

  1. uint32_t sd_ecb_block_encrypt ( nrf_ecb_hal_data_t * p_ecb_data ) Seems this one is only usable for encrypt, can you provide or have a similar one for decrypt?

  2. bool nrf_ecb_crypt ( uint8_t * dst, const uint8_t * src ) This one seems can be used for both encrypt and decrypt, but I am not sure how to specify whether I need to decrypt or encrypt and also how to specify the key correctly, if you have any code snippets or examples that will be really helpful.

Another question is about the data block size, seems it is fixed at 16 bytes now, can I specify a different size or need to cut into 16 byte block in my applicaiton code?

Thanks,

Jun

Parents
  • I was looking for the same, seems like the hardware only has enryption and no decryption. In ble connections this is sufficient while the counter mode is used. In countermode messages are both enrcypted and decripted using AES (ECB)encryption of a counter value, so ECB decription not needed for bluetooth and it seems Nordic made the hardware to fit BLE security and just BLE security .

Reply Children
No Data