Skip to content

Add per-session ephemeral X25519 key exchange#3

Merged
neuromechanist merged 2 commits into
mainfrom
feature/ephemeral-session-keys
Jun 23, 2026
Merged

Add per-session ephemeral X25519 key exchange#3
neuromechanist merged 2 commits into
mainfrom
feature/ephemeral-session-keys

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Summary

Establishes a fresh ephemeral X25519 keypair for every connection, signed with the shared Ed25519 key and exchanged in the TCP handshake (new Security-Ephemeral-Key / Security-Ephemeral-Sig headers). The session key is derived from the ephemeral Diffie-Hellman output bound to a transcript of both ephemeral public keys and the shared identity.

Benefits:

  • A unique session key per connection.
  • Forward secrecy: a later compromise of the long-term keypair cannot reconstruct past session keys (ephemeral secrets are zeroed after derivation).
  • Authorization is strengthened from "knows the public key" to "holds the private key" via the ephemeral-key signature.

Also adds LSLSecurity::reset() to return the process-global security singleton to a clean state for test isolation.

Test plan

  • C++ internal (Catch2): 3127 security assertions; full suite passes in randomized order.
  • C++ external e2e: real secure outlet -> inlet handshake and encrypted transfer (1035 assertions).
  • Build: cmake -DLSL_SECURITY=ON -DLSL_UNITTESTS=ON -DLSL_SECURITY_TOOLS=ON; ctest.

Each connection now establishes a fresh ephemeral X25519 keypair, signed
with the shared Ed25519 key and exchanged in the TCP handshake (new
Security-Ephemeral-Key and Security-Ephemeral-Sig headers). The session key
is derived from the ephemeral Diffie-Hellman output bound to a transcript of
both ephemeral public keys and the shared identity, giving a unique key per
session and forward secrecy, and proving each peer holds the private key
rather than merely knowing the public one.

Adds LSLSecurity::reset() so the process-global security singleton can be
returned to a clean state between tests, and C++ unit tests covering keypair
freshness, derivation symmetry, per-session key uniqueness, and ephemeral-key
signature verification.
@neuromechanist neuromechanist merged commit e2d9eb0 into main Jun 23, 2026
5 checks passed
@neuromechanist neuromechanist deleted the feature/ephemeral-session-keys branch June 23, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant