Skip to content

Verify in-place AEAD decrypt is in use — adopt if not #34

Description

@stanvx

Parent

Architecture review (2026-06-21), "Latency tricks worth lifting wholesale". Independent of the deepening series. Smallest slice in this batch — could land in under an hour.

What to build

Both libsodium ChaCha20-Poly1305 and ring's AES-GCM support overlapping input/output buffers (m == c). Saves one stack-allocated buffer per encrypted packet. The architecture review claims AnyPlug's crypto "already uses ring"; this slice verifies whether the in-place pattern is actually in use, and adopts it if not.

Audit shared/usbip-core/src/crypto.rs and the call sites in usbip-server/src/crypto_stream.rs (and the matching client side). For each decrypt call, check whether the plaintext buffer is freshly allocated, or whether it's aliased to the ciphertext buffer. If aliased, document with a comment; if not, refactor to alias.

Acceptance criteria

  • Audit comment in usbip-core/src/crypto.rs lists each decrypt call site with a one-line verdict: "in-place" or "allocates"
  • Every "allocates" verdict is either (a) refactored to in-place with a unit test proving byte-equality, or (b) explicitly marked "must allocate because X" with reasoning
  • cargo test --workspace --release passes (especially cargo test -p usbip-core --release for the crypto round-trip tests)
  • cargo clippy --workspace -- -D warnings clean
  • No public API change to SealedSession::open / seal
  • A new micro-benchmark (criterion, default sample size) shows the latency improvement on a 512-byte packet

Blocked by

None — can start immediately.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestready-for-agentTriage complete; ready for an agent to implement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions