I am a newbie in embedded programming. I want to encrypt some advertising data using aes-ecb API, provided by the softdevice but I am not getting any encrypted data after calling sd_ecb_block_encrypt function. I am using this function to encrypt data :
static const uint8_t key[16] = { 'N', 'o', 't', 'a', 'g', 'o', 'o', 'd', 'p', 'a', 's', 's', 'w', 'o', 'r', 'd' };
uint8_t plain_data[16] = "Bengaluru";
void aes_ecb_encryption(uint8_t * p_cleartext, uint8_t * p_cipehertext){
nrf_ecb_hal_data_t m_ecb_data;
uint32_t err_code;
memset(&m_ecb_data, 0, sizeof(m_ecb_data));
memcpy(m_ecb_data.key, key, SOC_ECB_KEY_LENGTH);
memcpy(m_ecb_data.cleartext, p_cleartext, SOC_ECB_CLEARTEXT_LENGTH);
print_concat("ecb_key", (char * ) m_ecb_data.key);
print_concat("cleartext", (char * ) m_ecb_data.cleartext);
err_code = sd_ecb_block_encrypt(&m_ecb_data);
APP_ERROR_CHECK(err_code);
memcpy(&m_ecb_data.ciphertext[0], p_cipehertext, SOC_ECB_CIPHERTEXT_LENGTH);
print_concat("encrypted data", (char * ) m_ecb_data.ciphertext);
}
print_concat function is used to print data on Jlink RTT viewer. I am able to see the key and cleartext on the RTT viewer but in case of ciphertext, I am getting a blank string. This is the output from Jlink RTT :
I am using ble_app_template code given in examples. Is there something like initializing the aes-ecb core or some parameters ?
Where is the problem ?