Commit Graph
25 Commits
Author SHA1 Message Date
riccardom 7c276ce727 pqkem: apply derived PSK at WG peer-config time (pull) + keep push for rekey 2026-09-11 14:48:54 +02:00
riccardom 56b315d954 pqkem: dedicated slog logger via NB_PQ_MLKEM_LOG_LEVEL 2026-09-11 14:48:54 +02:00
riccardom bac6af349b Homogeneous logs prefix 2026-09-11 14:48:54 +02:00
riccardom 3270fc5e18 Bit of renaming
peer -> peerAddrs
have types for remoteID and localID
t.Close log error
Manager SetTransport -> Start
2026-09-11 14:48:54 +02:00
riccardom 539a1f44c8 Typo 2026-09-11 14:48:54 +02:00
riccardom ef29e996ce Race fix 2026-09-11 14:48:54 +02:00
riccardom cda3922478 Makes Transport just a UDP socket.
Manager owns maps for remoteID <-> remote UDP addr
Engine talks to manager only
2026-09-11 14:48:54 +02:00
riccardom 41298ac24d Added enabled env var 2026-09-11 14:48:54 +02:00
riccardom 902daf61e6 Invert order of keys as per draft 2026-09-11 14:48:54 +02:00
riccardom 0aeed6ae5b Removes confirm. Uses next offer to deliver confirmation/ack of previous round
We clock the next Offer initiation to the OnDataPathRekeyed, so we have 2 minutes
ahead of us to do our attempts and stuff before to give up.
On failure, we will know because we will not receive a new answer.. but more importantly
the wg handshake will fail :D
2026-09-11 14:48:54 +02:00
riccardom cec4bd49b4 Leave signal offer/answer as a pull/push operation not as an actual transport 2026-09-11 14:48:54 +02:00
riccardom 2ed0d3bf03 Assume two transports: initial "signal" (control plane) one (no data path established yet) + data path one
Define OnDataPathRekeyed event to transition from control plane path to data plane path over the WG tunnel.

Keep confirm ALWAYS on NEW established WG tunnel (posthandshake with rekeying). We keep an active method
irrelevant of the WG handshake (we might decide that the indirect wg handshake is sufficient in the future).

Optimistic commit on responder(when sending answer), while on initiator we set it on getting the answer
2026-09-11 14:48:54 +02:00
riccardom f8bb816dea Epurate wg refs 2026-09-11 14:48:54 +02:00
riccardom 661926ce3a Collapse Driver and Manager in one.
- Have just one manager => one lock
 - Session state is needed in driver to => we have it available now.
 - Isomorphically align to rosenpass components and functionality

File	Role	                                  rosenpass equivalent
kem.go	primitive pure X25519MLKEM768	          crypto.go/handshake
message.go	Offer/Answer/Confirm + Encode/Decode  messages.go
manager.go	Manager stateful, single lock	      server logic
callbacks.go	WGCallbackHandler (seam output)	  Handler
Transport (interfaccia)	seam trasporto pluggable  Conn
2026-09-11 14:48:54 +02:00
riccardom 0a3dc2b43f [squash] isInitial and answered can be inferred without state variables 2026-09-11 14:48:54 +02:00
riccardom fa3c3ad214 Manages convergence 2026-09-11 14:48:54 +02:00
riccardom 75dcd571ca Models reattempts 2026-09-11 14:48:54 +02:00
riccardom d8fa34e60b Reuse answer, don't calculate again 2026-09-11 14:48:54 +02:00
riccardom e4bed8de65 Adds driver to glue together manager and outside world 2026-09-11 14:48:54 +02:00
riccardom 311c5f8a8c Defines event callbacks 2026-09-11 14:48:54 +02:00
riccardom 19739b2b4f Admits possible errors on Encode 2026-09-11 14:48:54 +02:00
riccardom 92cf08b2b0 Bench key material boilerplate time/allocs
CGO_ENABLED=1 go test ./client/internal/pqkem/ -run '^$' -bench . -benchmem 2>&1 | grep -E "Benchmark|ns/op|PASS|ok" | head -20

BenchmarkX25519Keygen-14    	   33795	     34966 ns/op	     224 B/op	       5 allocs/op
BenchmarkX25519ECDH-14      	   33855	     33973 ns/op	      32 B/op	       1 allocs/op
BenchmarkMLKEMKeygen-14     	   21817	     67778 ns/op	    8200 B/op	       2 allocs/op
BenchmarkMLKEMEncaps-14     	   29918	     43235 ns/op	    1216 B/op	       2 allocs/op
BenchmarkMLKEMDecaps-14     	   26048	     56291 ns/op	      64 B/op	       2 allocs/op
PASS
ok  	github.com/netbirdio/netbird/client/internal/pqkem	9.751s
Shell cwd was reset to /home/riccardo/Desktop/Personal/netbirdio/netbird
2026-09-11 14:48:54 +02:00
riccardom 87afc3e967 Pure mechanics of manager 2026-09-11 14:48:54 +02:00
riccardom a48bb9ba18 Messages definition 2026-09-11 14:48:54 +02:00
riccardom c796597df5 ML-KEM encapsulate/decapsulate module 2026-09-11 14:48:54 +02:00