BLE data transfer use AES/CCM encryption and unencryption

Hi,

      I development a elock device to use nordic 52832 chip. I want to transfer some information between phone app and my device. Like UUID / user account / user password.

for against BLE sniffer, we need use AES method to protect our information.

Can I follow  \examples\crypto\nrf_cc310\aes example to do it? Or any suggest for us? Our data transfer flow as below

 - phone app sent unlock command to our device

 - our device sent a random number to phone app

 - phone app response

- our device check response to unlock

Thank you.

John.

Parents
  • Why do you not just rely on the security features of BLE? When you use LE Secure Connections with some kind of MITM prevention, then the connection uses AES/CCM. Just make sure, that your lock makes sure, the connection is actually encrypted with a key that was obtained by the proper pairing.

  • Hi Robitzki,

           You mean I just need to enable MITM protected.

    1. My All data should encrypted by AES.

    2. Phone app can get a key from device when pairing boths.

    3. Is MITM a standard function on BLE?

    Do you have any example that can refer it?  which Nordic SDK version can support it?  

    Also, we don't want the user to have to enter the passkey by phone. In fact the user doesn't need to pick up the phone to unlock my device(Like auto lock and unlock)

    Thank you.

    John.

  • Hi Hung and Torsten,

             Thank you for your quickly answer.

    But for our design, we must auto lock or unlock our device. Don't need to pick up the phone and enter the passkey. Do I have any way that I can use MITM without passkey(Maybe our key already save in our phone app)

    Also, I want to know that can I use below method(ECB) with softwaredevice to do our secure way?

    devzone.nordicsemi.com/.../intro-to-application-level-security-using-the-ecb-

    Have any issue or limit? 

    Thank you.

    John

  • Hi John, 


    Yes it's possible to do what described in Daniel's blog for your application. 

    But I want to make it clear that the bonding process (with passkey or NFC) only needed on the first time the phone connect to the lock. On the next connection the phone and the lock will use a common LTK to encrypt the link. 
    Imagine when a new user setting up his phone as the key, he would need to either read the NFC tag on the log or type the code that show on the log. After that the lock automatically open when the phone is close by (connect - encrypt - unlock command - disconnect)

    If you want to have an extra security layer you can also implement what Daniel described, on top of BLE encryption. 

  • Hi Hung,

           Maybe I'll describe as below what I understand, see if that's right.

    Step 1: I use MITM function to bonding my device and phone.

    Step 2: Use key in passkey on phone to confirm your own.

    Step 3: When I will lock device, the device will connect to my phone

    Step 4: AES encrypt and unencrypt some information transfer between device and phone

    Step 5: If authentication succeeded, device will lock

    As I know, if I enable MITM function. The transfer data between device and phone will protected by AES. But AES need a key on device and phone side. When will I get this key? I need burn in this key in my device during production in factory? and transfer this key to phone when user enable lock feature? -  I don't understond.

    Do you have any user flow can refer it?

    Thank you

    John.

  • Hi John, 


    It would work this way: 

    Step 1. User turns on the Lock

    Step 2. Customer open the app on the phone to connect to the lock for the first time and bonding process starts

    Step 3a. If there is keyboard on the lock, the phone can display passkey and user need to type the same passkey on the lock . It's the random passkey the phone generated.

    Step 3b. If there is display on the lock, the lock can display the passkey and user type the same passkey on the phone. It's the random passkey the lock generated

    Step 4. Two device bonded . They now have generated and stored the same LTK (long term key). This is Bluetooth LTK.

    Here the set up process is done. 

    Step 5 when the user with the phone come close to the lock, the lock automatically connect to it

    Step 6 The phone and the lock encrypt the connection using the previously stored LTK. The lock now know for sure that it connect to the authenticated phone. 

    Step 7 The link is now encrypted , and the phone can now send the command to lock or unlock the door. 

    Step 8 After the door is locked or unlocked, the phone can disconnect the encrypted connection. 

    At step 7 you can implement your extra security protocol if you want. 

  • Hi Hung,

           Thank you for your answer. Very clear.

    One more question. If my lock don't have keyboard or display. Only have some hardware buttons. 

    The only way I can do what you describe. Is there only a static passkey way?

    It would work this way for me:

    Step 3a. Lock device have a static passkey "123456". I provided a QR code include my static passkey. phone scan this QR code to get and send passkey "123456" to lock device.

    Step 3a-1 Lock device get "123456" from phone to compare passkey in lock device side. If match. then bonded.

    Is it right?

    Thank you.

    John.,

Reply
  • Hi Hung,

           Thank you for your answer. Very clear.

    One more question. If my lock don't have keyboard or display. Only have some hardware buttons. 

    The only way I can do what you describe. Is there only a static passkey way?

    It would work this way for me:

    Step 3a. Lock device have a static passkey "123456". I provided a QR code include my static passkey. phone scan this QR code to get and send passkey "123456" to lock device.

    Step 3a-1 Lock device get "123456" from phone to compare passkey in lock device side. If match. then bonded.

    Is it right?

    Thank you.

    John.,

Children
  • Hi John, 


    According to the spec, static passkey is not considered safe. One can just retry bonding 20 times (LESC) to get the correct passkey. 

    Please make it very clear that bonding and lock/unlock the doorlock are not the same. 


    So the passkey to bond shouldn't be used to lock or unlock the door . Bonding is to encrypt the link for the first time the two device (phone and doorlock) talk to each other. After that they are secured to talk to each other. Then you can send your command to unlock/lock when the link is encrypted.

    Note that you can turn off bonding after you bond with the first device. After that, you can switch to the mode that the device doesn't bond with any new device and only can be switch to bond mode when you open it or send a command from the phone. 

  • Hi Hung,

        Yes. I know. My current thinking is as below.

    1. Use static passkey to bonded my device and phone.(QR code include my static passkey and mac address, My app will know when app scan QR code)

    2. Set whitelist. So another phone can't scan and link my device.

    3. encrypted data transfer between my phone and device. Then I can send lock or unlock command.

    Is it right?

    My question is if I use static passkey. What will be the flow of the mechanism for my phone and device to exchange passkeys with each other?

    Also,I'm thinking of a way to delete bonded mode.Back to the first pairing

    Thank you.

    John. 

  • Hi John, 

    Yes , it's correct. If you can limit the access to bonding mode then it's safer as the attacker need to try at least 20 times to guess the key and it's not possible to find the passkey even when they sniff the communication. 

    For static passkey, please have a look here. It's for legacy pairing but I believe you can use the same BLE_GAP_OPT_PASSKEY for LESC. You would need to configure your device capability to display (even though it doesn't have a display) and the peer device should have keyboard. 

    Regarding delete bonded information, you should implement the code on the lock that allow the authorized phone to delete bond. Or to have a failsafe button on the lock that allow it to reset the database and allow new bond. 

  • Hi Hung,

        Can I use below flow to do all things.

    1. Set a passkey on device.

    2. When phone and device connected, send this passkey to phone. But the phone does not display the passkey code. Then user must use a qr code card to scan and automatically fill it in the blanks as like ******.

    3. Then reply to the device and complete the comparison

    Does that make sense for secure? Does it help to improve safety?

    Thank you.

    John.

  • Hi John,

     
    What exactly you are trying to achieve here ? 


    It's not possible to customize the Bluetooth pairing on the phone. It's handled by the system. 
    So what you can do is to make the app that can scan for the QR code and after scanning QR code it can tell the end user on the phone which passkey they should enter. 

Related