TLS-like encryption over Bluetooth on iOS?

前端 未结 1 432
说谎
说谎 2021-01-06 13:25

So, this might be a very special case, but I hope someone can help me out here.

I need to talk to a peripheral via Bluetooth. A device for which we also control the

相关标签:
1条回答
  • 2021-01-06 13:45

    The whole foundation in TLS builds upon trust, i.e. Certificates, Certificate authorities and certification chains, and making sure all data sent and received are authenticated. You could say the whole security relies on the authentication part. The encryption itself is quite straight-forward. One question you should answer is:

    Should it be possible to connect to peripherals that mimic your protocol, i.e. peripherals NOT manufactured by you? If not, with your premises you must have some (unique) secret in each peripheral, for example a private key. The corresponding public key can be signed by your own CA. The public key of the CA can be bundled in your smartphone app (so you need only one key in your app, not one for all peripherals). That way you can verify that the peripheral you connect to is made by your company. This public key should also be the identifier of the peripheral. If you don't have a private / public key pair inside your peripheral and can't do passkey comparison and don't have any shared symmetric key, as far as I know it's impossible to avoid man-in-the-middle attacks.

    Since each smartphone must also initially be treated unauthenticated, if you need to resume a session later, you need to store some unique ID assigned to each smartphone in the peripheral.

    With this in mind, you have basically three different options:

    1. Try to modify some present TLS server software like mbedtls to send all packets over BLE rather than sockets. I have a feeling this might be non-trivial because it seems it's based on the concept of blocking sockets.
    2. Just read the TLS spec on https://tools.ietf.org/html/rfc5246 and implement a minimal TLS server with only the features you need. This is actually not so hard as it may look like first if you only do a minimal implementation and use existing building blocks such as RSA, AES, SHA-2, ECDHE, X.509 certificate parsing code (you can find those here: https://tls.mbed.org/source-code).
    3. Extract the important parts in TLS and make a simplified protocol without all negotiation parameters (since they can be hardcoded). For example, you don't need to send and be able to parse all kind of messages (for example ClientHello), handle fragmentation etc. Just send the random values, certificates, signed data, encrypted data directly.
    0 讨论(0)
提交回复
热议问题