BLE encryption : Which AES 128 decryptor to be used?


frv
 

Hi,


If I want to use "bt_encrypt_le", what should be the specification to find the right AES decryptor?


I thought I could use the AES_ECB_decrypt from the tiny-AES-C library see : https://github.com/bricke/tiny-AES-C

github.com
Tiny AES in C. This is a small and portable implementation of the AES ECB and CBC encryption algorithms written in C. The API is very simple and looks like this (I am using C99 <stdint.h>-style annotated types):

But without success so far.


I also see that the encrypted data done with both functions: bt_encrypt_le and  AES_ECB_encrypt are not the same.


Nevertheless I can use tiny-AES-C on Zephyr. Just wondering why both are not compatible.



u8_t enc_data[16];
        u8_t key[]       = { 0x01, 0x02, 0x03, 0x04, 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7 };
        u8_t plaintext[] = { 0x01, 0x02, 0x03, 0x04, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };

        AES_ECB_encrypt(plaintext, key, enc_data, 16);
        printk("encrypted text = %x %x %x %x %x\n", enc_data[0], enc_data[1], enc_data[2], enc_data[3], enc_data[4]);

        if (bt_encrypt_le(key, plaintext, enc_data) != 0)
        {
           printk("Encryption failed for passkey");
        }
        else
        {
           printk("encrypted text = %x %x %x %x %x\n", enc_data[0], enc_data[1], enc_data[2], enc_data[3],                                                                                            enc_data[4]);
        }


Any idea?


Thanks in advance,

Best regards,

Frank

Join devel@lists.zephyrproject.org to automatically receive all group messages.