Hi,
Based on other discussions of encryption etc , I created a function to encrypt all the data, so that whenever I call the function It encrypts.
static nrf_ecb_hal_data_t aes_struct; static uint8_t aes_data[16]; static uint8_t aes_data_decrypted[16]; //Initializing arrays memset (&aes_struct, 0, sizeof(aes_struct)); memset (aes_data, 0, sizeof(aes_data)); memset (aes_data_decrypted, 0, sizeof(aes_data_decrypted)); uint8_t* encrypt(uint8_t* p_data) { //Initializing key for (int i = 0; i < 16; i++) { aes_struct.key [i] = i; } //Initializing nouncence memset (aes_struct.cleartext, 0xaa, sizeof(aes_struct.cleartext)); //todo: use more random data and add counter //Creating chipertext sd_ecb_block_encrypt(&aes_struct); //Encrypt -> XOR chipertext with p_data: for (int i = 0; i < length; i++) { aes_data[i] = p_data [i] ^ aes_struct.ciphertext[i]; } //decrypt -> XOR chipertext with Encrypted data: return (aes_data); } uint8_t* decrypt(uint8_t* p_data) { for (int i = 0; i < length; i++) { aes_data[i] = p_data [i] ^ aes_struct.ciphertext[i]; } //decrypt -> XOR chipertext with Encrypted data: return (aes_data); }
But I am not able to call the function, there's always an error
uint8_t vib_cnt_buf[5]; Convert_to_ascii(right,(&vib_cnt_buf[0]),8); &vib_cnt_buf = encrypt(&vib_cnt_buf); //Encrypting this data
Can you please help