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:
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?
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?
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 .
The key in .key, and the input data in .cleartext, then call the function, then the output data will be in .ciphertext
You call the same function sd_ecb_block_encrypt whether you want to encrypt or decrypt. The operation is symmetrical.