-
Notifications
You must be signed in to change notification settings - Fork 217
BLE Pairing and Encryption #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Initial - encrypted read
With write encryptionn requirement
Write encryption & visible LTK / IRK
Fixed packet fragmentation
Android bugfix
Fix timing issue during pairing, add pairing control/status methods
Secure random & reject unknown LTK
Pairing code & IOCaps set via implementation of callbacks
Pull request in relation to: #36 and unknownconstant#11 |
Not all devices want to support pairing. This code doesn't seem to do that. |
Happy to take a look - which bit of the spec are you looking at for this? There are a number of volumes which have a C.5.1. The code in this PR currently only supports the peripheral device, so if the device using this code does not support pairing then it shouldn't be set to require encryption. I understand for BLE that the central will instigate encryption only after the peripheral has sent an error response indicating insufficient encryption or authentication. Volume 3, H 3.5.1 describes bonding flags in the pairing procedure. When testing I found that these flags did not affect whether an iPhone stored pairing data or not but I would welcome more info if you're able to test this or have any other insights. |
A little more background. I am building an Ardunio BLE device which emulates a proprietary BLE device that provides steering angle control for the bike training game Zwift. The protocol is already reverse engineered (so thats easy). And the Nano BLE has magnetic sensor, and that can be used as directional input. This is just a dumb BLE device (similar to Battery monitor etc). The code works talking to Android, and probably MacOs. But does not work with Windows 10 the application connects, but then gets no data. I suspect the lack of pairing support. Doing full encryption is overkill for this application. Wondered if this would be enough to just respond with "not supported" |
I did some more experiments (and tried to learn about the twisted maze of BLE security). What would the API be for an application to override the default authentication request settings. |
unknownconstant seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Compile is catching this warning:
Looks like missing i = 0 |
Lots of other warnings now introduced.
|
Hoping to get some time in the next couple of days to take a look at this properly |
Hi @shemminger , I've not been able to reproduce these errors using the standard Arduino compiler. Is this what you have used, or are you using another toolchain? When cloning this library on another computer, a number of errors were generated as I had mistakenly included both this version, and the official release. It may be worth checking this? |
On Mon, 26 Apr 2021 02:51:12 -0700 unknownconstant ***@***.***> wrote:
Hi @shemminger , I've not been able to reproduce these errors using the standard Arduino compiler. Is this what you have used, or are you using another toolchain?
When cloning this library on another computer, a number of errors were generated as I had mistakenly included both this version, and the official release. It may be worth checking this?
I was just building with Arduino IDE on Debian 11.
It has GCC 10 as back end.
|
Any update on when we can have this feature released as an official release? |
I don't know, there seems to be a licence issue. I've signed but it states it's still pending which may be preventing a merge. We may be waiting on the Arduino team to review the code. |
I'm so sorry for jumping late into this. It looks like there's an issue with CLAbot since I do see that the user @unknownconstant signed the CLA, but we can easily force that. |
@alranel CLA signed ✅ |
@alranel can you merge pull request? |
@alranel Any chance to have it merged any time soon? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested the examples with my Android phone and a Nano 33 BLE and they worked like a charm! :)
@alranel It looks like the Pull Request is approved. What happens next? Is it possible that new release will be published soon? Thank you in advance! |
Sorry for being so slow - just one last confirmation: did you write all this code or did you take any part of it from other sources? |
Yes, the code is either original, refactored from this repo, or in the case of a couple of the crypto functions e.g. AES_CMAC is taken from rfc4493, and Bluetooth toolbox functions are implementations of the published Bluetooth LE spec. |
Do we progress or other implementation is needed? |
Unsure - AFAIK it's just waiting on being merged |
The features provided by this pull request would be great to have, I look forward to it being merged. |
Yup we were still waiting for the CLA to be signed by all the commit authors but it looks like it was and the bot is not actually behaving correctly... I'm going to merge it anyway 😉 |
For future reference, the reason the CLA check was not passing is because the check is done against the owner of each commit in the PR. The CLA is signed by your GitHub user account, so the commit can only be verified when its email address (as set via the You can see that some of the commits from @unknownconstant had one email address configuration. For example: and other commits had another. For example: The bot attempts to communicate this situation in the comments:
|
5 years ago, support for encryption was added by arduino-libraries#156. Currently, the BLEEncryption tag needs to be added to require proper encrypted bluetooth pairing. It is possible to add this tag to all other kinds of characteristics except String characteristics. BLEStringCharacteristic's constructor calls BLECharacteristic's constructor, and BLECharacteristic uses a uint16_t instead of a uint8_t. This PR simply changes the properties attribute of BLEStringCharacteristic to match the width of the permissions attribute of BLECharacteristic (from 8 to 16 bits) to support the BLEPermission tags in BLEProperty.h.
This pull request is for an implementation of the BLE Security Manager which allows arduino devices to pair & encrypt connections using the HCI specification. Specifically, it implements Secure Connect / Numeric comparison.
The branch appears stable but I'm aware it may need some refactoring. An example sketch is included to show how to pair devices.
The branch supports encryption instigated by the central when the arduino is the peripheral.