Repository navigation
netcode 1.5.0: upgrade protocol to NETCODE 1.03 with per-connection HChaCha20 key derivation - #228
Merged
Merged
Conversation
…20 key derivation Derive distinct 32-byte client->server and server->client packet keys per connection attempt using crypto_core_hchacha20 over client_salt[8] || server_nonce[8] so connect token keys never encrypt packets directly: - Bump wire version string to "NETCODE 1.03" and library version to 1.5.0. - Append 8-byte random client_salt to connection request packets (1086 bytes), rotated on every connect call and every server failover. - Prepend 8-byte cleartext server_nonce header after sequence number on connection denied and connection challenge packets, bound in 30-byte AAD. - Gate client packet processing strictly by state and lock per-connection derived keys only upon authenticating a connection challenge. - Bind pending connect token history entries to client_salt (constant-time) and timeout_seconds, and consume half-open entries on disconnect. - Update STANDARD.md, SECURITY.md, IMPLEMENTERS.md, fuzz harnesses, conformance vectors/verifiers, unit tests, KAT vectors, and 5 nonce-audit regressions. Author: Emma Antigravity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Upgrades the wire protocol to
NETCODE 1.03and bumpsnetcodetov1.5.0, deriving distinct 256-bit packet keys per connection attempt viaHChaCha20so connect token keys never seal packets directly.Protocol & Implementation Changes (
NETCODE 1.03)"NETCODE 1.03\0"(13bytes) in connect tokens,connection requestpackets, and AEAD associated data; library version1.5.0.HChaCha20): Givenclient_salt[8]andserver_nonce[8], derivespacket_c2s_keyandpacket_s2c_keyviacrypto_core_hchacha20(out, client_salt || server_nonce, token_key, NULL).connection request(type 0): appends 8-byte randomclient_salt(1086bytes, rotated on everyconnectcall and every server-list failover).connection denied(type 1) andconnection challenge(type 2): carry 8-byte cleartextserver_nonceimmediately after the variable-length sequence number and bindserver_nonceinto 30-byte AEAD associated data.connection response,keep-alive,payload, anddisconnect(types 3–6): unchanged wire layout and 22-byte AEAD associated data.connection challenge, verifiesserver_nonceonconnection deniedinsending connection response, and sendsdisconnectpackets only once connection keys exist.PENDINGconnect_token_entriesto(address, client_salt)(constant-time) withintimeout_secondswithout mutating existing entries on mismatch, reuses live half-open(server_nonce, send_key, receive_key)on legitimate retransmits of the same(mac, client_salt), derives fresh keys on new mappings / full-server denials, and consumes half-open entries on authenticateddisconnect.STANDARD.md,SECURITY.md,IMPLEMENTERS.md,fuzz/fuzz_read_packet.c,tools/conformance/*, KAT vectors (test_derive_packet_keys_kat,test_wire_kat_vectors), and added 5NETCODE_NONCE_AUDITregression tests covering unfinished handshakes, sub-timeout disconnects, sub-timeout 100%-packet-loss retries, replayed challenges, and multi-serverglobal_sequencedisjointness.Verification Receipts (
vision, Headf23eaa82d600a8753dc97d730d099e5377b87516)Before (
2d9df60853a69931a891dedfc01a5353373422c4,-DNETCODE_ENABLE_NONCE_AUDIT=1)After (
f23eaa82d600a8753dc97d730d099e5377b87516)