Skip to content

Suites in the signed handshake; hybrid encryption for pushes (10.10.0) - #24

Merged
prmeyn merged 1 commit into
mainfrom
feature/suite-and-hybrid-push
Dec 3, 2026
Merged

prmeyn merged 1 commit into
mainfrom
feature/suite-and-hybrid-push

Conversation

@prmeyn

@prmeyn prmeyn commented Dec 3, 2026

Copy link
Copy Markdown
Owner

Crypto hardening step 2, SignedChannel half. It builds on PublicKeyUtils 10.3.0 (prmeyn/PublicKeyUtils#7), which is live on nuget.org.

This is a protocol hard cut, as decided. SignedChannel has no outside users, and the one project using it isn't live. A 10.9 browser can't register with a 10.10 server, or the other way round. Ship the NuGet packages and the npm client together.

Server

  • ChannelSuites defines one suite, "sc2":
    • signing: ECDSA P-384 with SHA-512;
    • encryption: RSA-OAEP-256 (2048+ bits) wrapping a fresh AES-256-GCM key per message.
  • The suite is named inside the signed registration blob (EncryptionPublicKeyWithTimestampRequest.Suite), so it can't be downgraded in transit. The handshake refuses:
    • a missing or unknown suite (matched exactly, so SC2 is refused);
    • a verifying key on another curve;
    • an encryption key with another alg.
  • The suite is stored on the session (ChannelSessionRecord.Suite, auto-mapped in MongoDB). A session without one (written before 10.10) or on a switched-off suite gets 401, and the browser registers again.
  • SignedChannelOptions.AllowedSuites defaults to every known suite and can only narrow the list. An unknown id or an empty list fails at startup.
  • The handshake answer and every push are PublicKeyUtils HybridEnvelopes, which removes the 190-byte push limit.
  • Both validators now also take IOptions<SignedChannelOptions>; they're registered automatically.

Client (npm)

  • Sends Suite: CHANNEL_SUITE ("sc2") inside the signed blob. CHANNEL_SUITE is exported.
  • The RSA private key has the unwrapKey usage only (the public JWK still has key_ops: ["encrypt"]). Each AES key is unwrapped straight into a non-extractable CryptoKey, so no key material ever reaches JavaScript.
  • CryptoCore.decryptMessage opens version 1 envelopes and rejects malformed, truncated, altered or other-version ones.

Tests

  • Server: 67, 14 new in SuiteTests. They cover:

    • a missing suite, an unknown one, or the wrong case;
    • P-256 and P-521 signing keys;
    • RSA-OAEP and RSA-OAEP-512 encryption keys;
    • the suite stored on the session;
    • switching the suite off (existing session gets 401, new registration gets 400);
    • a stored session without a suite gets 401;
    • the handshake answer and pushes are envelopes;
    • options validation.

    The 53 existing tests pass unchanged, with the test helper now opening envelopes.

  • Client: 19, 4 new. They cover:

    • the suite is inside the signed blob;
    • the private key has the unwrapKey usage only;
    • envelopes of any size open, and altered, truncated or wrong-key ones return null;
    • a 1,000-byte push is delivered.
  • Cross-check: the built client opened envelopes sealed by PublicKeyUtils 10.3.0 in .NET (21 and 4,010 characters).

Release

Minor: 10.9.0 → 10.10.0 for SignedChannel, SignedChannel.MongoDb and npm signed-channel-client. No prmeyn package depends on SignedChannel. README has the 10.10.0 release notes, and the client README is updated. Tag only after merge and the go-ahead.

🤖 Generated with Claude Code

… to the browser

Protocol change (hard cut; server and npm client must move together).

Server
- ChannelSuites: "sc2" = ECDSA P-384 + SHA-512, RSA-OAEP-256 (2048+ bits)
  wrapping per-message AES-256-GCM keys. The only suite.
- The browser names its suite inside the signed registration blob
  (EncryptionPublicKeyWithTimestampRequest.Suite). The handshake refuses a missing
  or unknown suite, another signing curve and another encryption alg.
- ChannelSessionRecord.Suite is stored; a session without one (pre-10.10) or on a
  switched-off suite gets 401 and the browser re-registers.
- SignedChannelOptions.AllowedSuites (default: all known) can only narrow; an
  unknown id or empty list fails startup.
- Handshake answer and pushes are PublicKeyUtils 10.3.0 HybridEnvelopes: no more
  190-byte limit.

Client
- Sends Suite: CHANNEL_SUITE ("sc2") inside the signed blob.
- RSA private key has the unwrapKey usage only; each AES key is unwrapped
  straight into a non-extractable CryptoKey. CryptoCore.decryptMessage opens
  envelopes and rejects malformed, altered or other-version ones.

Tests: 67 server (14 new SuiteTests), 19 client (4 new). Checked the built
client opens envelopes sealed by PublicKeyUtils 10.3.0 (.NET).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@prmeyn
prmeyn merged commit 44d0ee3 into main Dec 3, 2026
2 checks passed
@prmeyn
prmeyn deleted the feature/suite-and-hybrid-push branch December 3, 2026 21:16
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