Skip to content

ogar-encryption: sealed two-direction session stream - #360

Merged
AdaWorldAPI merged 1 commit into
mainfrom
ccr-0455e606-wmtsor
Oct 15, 2026
Merged

AdaWorldAPI merged 1 commit into
mainfrom
ccr-0455e606-wmtsor

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

What

ogar_encryption::stream::SealedStream: one endpoint of a sealed, two-direction session stream. It is the generic form of a2ui-server's sealed frame transport, moved here so other consumers (MedCare first) can encrypt a live session without depending on a2ui-server. It handles bytes only; the caller passes the associated data.

Wire form (unchanged from a2ui)

[direction:1][counter:8 LE][ciphertext || 16-byte tag], nonce [direction][counter LE][zero:15], XChaCha20-Poly1305 via the existing aead re-export.

One fix against the a2ui original

a2ui's open_frame takes the direction from the blob and never checks it against the receiver. Both directions use the same key, so a sender's own message reflected back to it opens and is accepted as if the peer had sent it. SealedStream::open refuses that (StreamError::WrongDirection). a2ui-server will move onto this module in a follow-up PR, which closes it there too.

Also

  • The send counter refuses to wrap (CounterExhausted) instead of overflowing.
  • The key is wiped on drop.
  • A refused message never moves the replay watermark (tested).

Precondition (in the module docs)

One key per session. Counters restart at 0, so a key shared between two sessions reuses every nonce. Derive it from a fresh random salt.

Tests

8 new tests: round trip both ways, reflection, replay and reorder, wrong key / tamper / different AAD, forged counter, truncated / unknown direction, counter exhaustion, wire prefix layout. Disable runs: dropping the direction check fails the reflection test; allowing an equal counter fails the replay test.

🤖 Generated with Claude Code

https://claude.ai/code/session_01G22yT6htkcdyXsihxxXdrg


Generated by Claude Code

The generic form of a2ui-server's sealed frame transport, moved here so
any consumer (MedCare first) can encrypt a live session without
depending on a2ui-server. It sees bytes only; the caller supplies the
associated data.

Same wire form: [direction:1][counter:8 LE][ciphertext || tag], nonce
[direction][counter LE][zero]. One change against the a2ui original:
open refuses a message whose direction byte is not the one this half
receives. Both directions share the key, so the original would accept
a sender's own message reflected back to it.

Also: the send counter refuses to wrap, and the key is wiped on drop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G22yT6htkcdyXsihxxXdrg
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bdd67c64-ab13-482c-90e6-e4df1f2154b2
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review October 15, 2026 05:52
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T05:54:29.886016Z bde1a1c Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@AdaWorldAPI
AdaWorldAPI merged commit ee3c700 into main Oct 15, 2026
4 checks passed
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.

2 participants