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

AES ECB with Softdevice active

I am trying to use the ECB encryption mechanism and had it working perfectly well on the 11.0.0 alpha SDK. With the release of 11.0.0 it now hardfaults ( NRF_ECB->TASKS_STARTECB = 1) when the softdevice is active. I do the ecb_init before calling the softdevice however I cannot actually do encryption.

I have seen the reply here: devzone.nordicsemi.com/.../

Is this correct behavior then in the release version? Is there any way I can disable the softdevice using ECB if so? I do not use any of the security features in the softdevice.

-- EDIT IMPROVED ANSWER --

Just wanted to point out that the link given in the answer is really great for finding what the SD exposes:

sd exposed functions

Here is a quick example for the AES ECB module that answers the question for future ref:

// SDK 11.0.0 - SD 132

#include "nrf_soc.h" 

static const uint8_t key[16] = { 'N', 'o', 't', 'a', 'g', 'o', 'o', 'd', 'p', 'a', 's', 's', 'w', 'o', 'r', 'd' };

static uint8_t  ecb_data[48];
static uint8_t* ecb_key =        ecb_data;
static uint8_t* ecb_cleartext =  ecb_data + 16;
static uint8_t* ecb_ciphertext = ecb_data + 32;

void ecb_init() {

    memcpy(ecb_key, key, 16);
}

void ecb_encrypt(uint8_t * input, uint8_t * output) {

    memcpy(ecb_cleartext, input, 16);

    sd_ecb_block_encrypt((nrf_ecb_hal_data_t *)ecb_data);

    memcpy(output, ecb_ciphertext, 16);
}
Related