Page 1 of 1

data encryption

Posted: Wed Nov 01, 2017 12:55 pm
by Trialblazer47
I wanted to encrypt data to be sent over ble. I am trying to reuse the security file provided with blufi example.

I think the two API blufi_aes_encrypt & blufi_aes_decrypt are to be used to encrypt and decrypt. I tried to make a test code.

first I initalized

Code: Select all

void app_main()
{
  char *input="hello";
  char *out;
  if( security_init() == ESP_FAIL  )
    {
      ESP_LOGI(TAG,"Security init failed.\n");
    }
ESP_LOGI(TAG,"Security done.\n");
aes_encrypt(10, input,5);                       <---- but this keeps crashing  I don't understand its input. 
ESP_LOGI(TAG,"Encrypted : %s \n",input); 
}

I am also thinking where the encryption key set?

I want simple way to encrypt and decrypt data. so please any example would be helpful.

Re: data encryption

Posted: Mon Nov 27, 2017 9:14 am
by blekyo
Hi,
I'm getting the same issue you. Did you you find out how to make it work?

Re: data encryption

Posted: Tue Dec 05, 2017 1:32 pm
by Trialblazer47
no than I gave up that idea.

Re: data encryption

Posted: Tue Dec 12, 2017 9:41 pm
by chegewara
I dont know why this is not answered yet, since its a simple answer. This is wrong usage:

Code: Select all

aes_encrypt(10, input,5); 
Check this https://github.com/espressif/esp-idf/bl ... /aes.h#L21
and this https://github.com/espressif/esp-idf/bl ... .h#L49-L52

and you will have answers why it crash and where to set encryption key.

Re: data encryption

Posted: Fri Dec 15, 2017 3:27 am
by blekyo
OK thanks, after a time spent looking on the code, I managed to understand how to use the mbedtls aes encryption/decryption