• caglararli@hotmail.com
  • 05386281520

BLE Challenge-Response Authentication Using Pre-Shared Key and SHA-256

Çağlar Arlı      -    29 Views

BLE Challenge-Response Authentication Using Pre-Shared Key and SHA-256

I’m working on a Bluetooth Low Energy lock system and have implemented a challenge-response authentication flow for secure communication between the lock (an ESP32 device) and the user's phone. I'm very new to these technologies, and was wondering if anyone has feedback on the flow of my system:

  1. The lock and phone both have a pre-shared secret key. This key is stored locally on both the phone and the lock.
  2. The phone acts as the BLE peripheral, and the lock acts as the central. When it detects the phone, the lock initiates the challenge-response process.
  3. The lock generates a random challenge every time the phone attempts to unlock the lock. This challenge is sent to the phone over BLE.
  4. The phone reads the challenge, appends the pre-shared secret key, and hashes the combination using SHA-256. The hashed result (challenge + secret key) is sent back to the lock.
  5. When the hashed response from the phone is received, the lock recomputes the hash using the original challenge and its copy of the pre-shared secret key. If the hashes match, the lock authenticates the phone and unlocks, otherwise, the lock rejects the request.

The secret key is never transmitted over BLE. Only the challenge and the hashed response (challenge + secret key) are sent over the air. BLE communication is encrypted, and I have considered bonding, but it's not currently implemented.

My main question is if this flow provides a secure challenge-response mechanism? Also, is using SHA-256 with the pre-shared key and challenge sufficient to protect the system from potential attacks? Should I consider adding a timestamp or nonce, or is that unnecessary? And finally, the secret key is currently the same for multiple interactions -- should I consider key rotation, and is this doable without internet access?

Thank you in advance!