cancel
Showing results for 
Search instead for 
Did you mean: 

BlueNRG-2 SoC + hci_le_encrypt() output

JFles.3
Associate

Hello,

I'm currently working with the BlueNRG-2 SoC. I would like to add AES-128 encryption at application-level while leveraging hardware acceleration.

The only function I've found that seems to do the job is hci_le_encrypt(). Based on the documentation, it looks like a straightforward function to encrypt a single 128bits block using AES. However, I'm puzzled by the output I get from this function.

I did a fairly simple test:

  • I used following the key: `{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }`
  • I used the following clear block as input: `{ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }`

With hci_le_encrypt(), I always get the following encrypted block: `{ 0xd0, 0xbf, 0xe1, 0xc7, 0x9a, 0x57, 0xa7, 0xe7, 0x4b, 0x27, 0x6e, 0x90, 0xcc, 0xa5, 0xa7, 0x29 }`.

Whereas with all other AES implementations I've tried, I get the following encrypted block: `{ 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30, 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a }`.

I did try with Pycryptodome (x86), TI AES software implementation (on the BlueNRG2 SoC itself), and another implementation found on Github (on the BlueNRG2 SoC). When relevant, I used ECB mode + no IV. All of them returned the same consistent result.

I have no idea why hci_le_encrypt() returns something else. Did I miss something ?

Best regards,

2 REPLIES 2
AndyR1
Senior

hello,

try to invert your key and data, encrypt and invert output.

OK, that does work ! Thanks :)