Commit Graph

95 Commits

Author SHA1 Message Date
dan 218b7cdb27 ble: encrypt wifi password
BLE "just works" pairing dos not protect against active MITM,
so we need to handle this ourselves. Use nacl/libsodium
crypto_box to encrypt and authenticate the wifi password

this also adds a step to the interaction between client and device:
after writing the password, we now write a "true" to the "connecting"
characteristic to kick off the actual conection attempt.
2026-02-17 12:37:59 +00:00
dan 4be5521504 ble: remove unused connection_state attribute 2026-02-15 17:56:18 +00:00
dan 48968551cc add getrandom 0.2.17 with custom source 2026-02-14 20:34:14 +00:00
dan a892593ea5 sense-check docs and comments 2026-02-04 18:59:46 +00:00
dan 671c2a382c reset after configuring wifi, and if if doesn't work 2026-02-04 18:42:49 +00:00
dan d79b32c8bf delete unused imports 2026-02-04 18:35:20 +00:00
dan cee50cd4a8 delete dead commented cde 2026-02-04 17:54:25 +00:00
dan 601c7391a3 write selected wifi credentials to flash nvs
todo
- reboot after writing
- delete bad networks after failing to connect
2026-02-04 00:37:24 +00:00
dan 2cfe436ac9 scan wireless networks & publish over ble
does not actually connect yet
2026-02-02 21:19:39 +00:00
dan dcaa927ab1 don't need ssid and password to do a wifi scan 2026-02-01 22:54:29 +00:00
dan 6c4d64ce0e demonstrate reading/writing a characteristic 2026-02-01 16:45:53 +00:00
dan f25a539084 log when current_network_index is changed 2026-02-01 16:43:45 +00:00
dan a729199926 PoC BLE support
It advertises, and it enumerates some characteristics. None of them
are hooked up to anthing yet
2026-02-01 15:27:30 +00:00
dan 13b0868488 esp_radio Controller is shared between wifi, ble
in preparation for adding ble, move its creation into main and
pass the object into wifi
2026-02-01 00:17:24 +00:00
dan 923dbe6fa9 add session registration with signature checking 2026-01-29 19:10:07 +00:00
dan e6e7030ba6 fix ota_write_chnk bug
somehow hadn't spotted we were not writing the start of the data, oops
2026-01-26 00:25:05 +00:00
dan fb59198f70 remove read_all, shorten using Result
this has made the "can't happen" error messages a bit less helpful
but we will come back to that
2026-01-25 00:44:03 +00:00
dan 0d86c64134 replace read_all with socket.read_exact 2026-01-24 22:20:49 +00:00
dan 04b71489b1 replace join(join) with join3 2026-01-24 00:09:45 +00:00
dan 14045825f3 extract module for ota flashing 2026-01-23 23:57:25 +00:00
dan 3a0dbe5c90 sign firmware with chained hashes
signing each block individually is slow (well, verifying is slow) and
doesn't protect against a MITM e.g. reordering or dropping
blocks. Instead we use the technique described in "How to Sign Digital
Streams (Gennaro, Rohatgi) where only the _first_ block is
cryptographically signed but each block contains a sha256 hash of its
successor block.

https://users.ece.cmu.edu/~adrian/731-sp04/readings/gr-stream-sig.pdf
2026-01-23 19:38:39 +00:00
dan 2f517e991d remove tabs 2026-01-23 19:17:19 +00:00
dan a3edd49f10 check signature on each block 2026-01-21 21:42:26 +00:00
dan cc9bf7897c rearrange OTA message format to sign each block 2026-01-21 18:32:57 +00:00
dan d50244ceb0 ota: buffer data flash full erase blocks
this speeds it up a lot because it's not doing mutiple erases for the
same block
2026-01-20 18:54:48 +00:00
dan b9d02b07b5 OTA support (replace stub) 2026-01-19 21:09:58 +00:00
dan b58453f9e7 add BUILD_ID env var so we can see if OTA worked 2026-01-19 21:06:27 +00:00
dan 235dd59bdc delete unused and commented-out code 2026-01-18 23:16:39 +00:00
dan c8dd5e0414 add tcp listener for OTA updating and session keys
* actual OTA updating not yet implemented, we read from the socket and
  throw the data away

* session keys are ignored
2026-01-16 23:24:27 +00:00
dan 40536c8dca write timestamp at front of each response 2026-01-12 21:57:50 +00:00
dan 9be9d167c3 mdns implementation notes 2026-01-12 18:00:05 +00:00
dan cdf7209c21 rename project 2026-01-11 20:20:00 +00:00
dan fd9b558d4c table subscriptions can have start/end 2026-01-08 00:03:45 +00:00
dan 71460edfdb rearrange subscriber and subscription 2026-01-07 23:50:35 +00:00
dan 4fead34199 stop sending to peer if we haven't heard from it for 60s
this is udp so there is no way to test if it has closed the
connection - instead we expect it to periodically refresh
2026-01-05 21:09:39 +00:00
dan 721dbbf06b we need to bump this number whenever we add a socket 2026-01-05 21:02:16 +00:00
dan 400ac33517 open udp socket, write table 0x11 to any peer that sends us data
TODO: actually parse the message from the peer in case they want
somethng other than table 0x11
2026-01-05 21:01:00 +00:00
dan 18e3c406ec remove unnecessary use 2026-01-05 13:18:52 +00:00
dan bba38102a4 new fn mdns::responder()
wraps up everything including socket creation. this was supposed to be
a thread but I haven't figured that out yet: it doesn't matter yet as
there isn't anmything else we're doing at the same time
2026-01-04 23:22:38 +00:00
dan b65218b0f4 remove Mdns prefix from Responder{,State} 2026-01-02 21:50:16 +00:00
dan 7e5e7c201d rename DnsResource as Resource and alias in client 2026-01-02 21:49:27 +00:00
dan 400e2e1e14 rename DnsDatabase -> Database 2026-01-02 21:27:07 +00:00
dan acd356a7e5 DnsDatabase can be a tuple struct 2026-01-02 20:52:02 +00:00
dan d3a46d5969 make DnsDatabase private 2026-01-02 20:39:47 +00:00
dan 31306f258d extract mdns into separate file 2026-01-02 20:27:48 +00:00
dan 59c2bb1ba1 rename var 2026-01-02 20:20:10 +00:00
dan cd63386282 pass records into DnsDatabase instead of making htem up 2026-01-02 19:43:38 +00:00
dan 4219991e1c move probe failure handling up the call stack
instead of handling name collision inside MdnsResponder,  pass the
error back to the caller which is better placed to decide how to
change the records
2026-01-02 19:20:33 +00:00
dan fe81d1f617 pass socket into MdnsResponder
we otherwise have to pass in the buffers it uses so it's hardly like
we're hiding it.
2026-01-02 19:09:35 +00:00
dan 4fcd921943 whitespace 2026-01-01 16:43:28 +00:00