Two-layer security for the BLE relay: 1. BLE Just Works pairing (link-layer encryption) - ESP32 requires bonding before accepting writes - Characteristic permissions set to ESP_GATT_PERM_WRITE_ENCRYPTED - IO capability NO_INPUT_NO_OUTPUT (no passkey needed) - LE Secure Connections with bonding (ESP_LE_AUTH_REQ_SC_BOND) 2. HMAC-SHA256 authentication (application-level) - 32-byte shared secret in src/hmac_key.h (generated, gitignored) - Each command signed: HMAC-SHA256(key, command || sequence) - 37-byte packet format: [cmd:1][seq:4][hmac:32] - Sequence counter prevents replay (strictly increasing, starts at 1) - mbedtls on ESP, javax.crypto.Mac on Android Key management: - tools/generate_hmac_key.py generates random key + writes src/hmac_key.h - ESP prints hex key to serial 5 seconds after boot - Android app: SettingsActivity with eye-toggle password field - Key stored in SharedPreferences, supports multiple ESP modules Other changes: - Android app: bonding flow (createBond -> BOND_BONDED -> discover) - Android app: MTU negotiation (request 256) - Android app: settings button (gear icon) in main screen - Fix: sequence counter starts at 1 to prevent first-packet rejection - Updated README with full security documentation
34 lines
No EOL
312 B
Text
34 lines
No EOL
312 B
Text
# HMAC key (generated, do not commit)
|
|
src/hmac_key.h
|
|
|
|
# PlatformIO
|
|
.pio/
|
|
.pioenvs/
|
|
.piolibdeps/
|
|
.clang_complete
|
|
.gcc-flags.json
|
|
>Sconscript
|
|
>SConscript
|
|
>*.scons
|
|
|
|
# Android/Gradle
|
|
.gradle/
|
|
build/
|
|
local.properties
|
|
*.iml
|
|
.idea/
|
|
*.apk
|
|
*.aab
|
|
*.ap_
|
|
*.dex
|
|
|
|
# OS
|
|
.DS_Store
|
|
Thumbs.db
|
|
|
|
# IDE
|
|
.vscode/
|
|
.idea/
|
|
*.swp
|
|
*.swo
|
|
*~ |