Repository navigation
Description
Summary
Add .NET wrappers for streaming AEAD (STREAM-BE32 over AES-256-GCM and ChaCha20-Poly1305).
Blocked by: Cryptographic-API-Services/cas-core-lib#151 (cas-core-lib exports), which is blocked by Cryptographic-API-Services/cas-lib#156, and a cas-core-lib release that includes it.
Upstream
cas-lib: Cryptographic-API-Services/cas-lib#156 (Streaming AEAD (STREAM) for chunked encryption). Not implemented in cas-lib yet; this issue tracks exposing it once it ships.
API shape in cas-lib: Design first. The API is stateful, so whatever shape cas-lib picks (opaque handle or explicit per-chunk functions) has to cross the FFI without Rust lifetimes. Post the proposed API in this issue before implementing.
Scope
- STREAM encryptor / decryptor over AES-256-GCM
- STREAM over ChaCha20-Poly1305 (and XChaCha20-Poly1305 once Get DLLs / SO out of Contents folder #155 lands)
- The documented wire format (header with nonce prefix, then chunks)
Feature-specific notes
- Stateful API: a
SafeHandle-derived handle and anIDisposablewrapper class (optionally aStreamadapter), so the native state is always freed. The last chunk must be an explicit call (e.g.Finish), never inferred. - It must be impossible to forget the last-chunk flag, and decryption must fail on truncation.
Tests
Run the same vectors cas-lib uses through this repo's harness: The round-trip / reorder / drop / truncate tests cas-lib adds, reproduced here.
Implementation notes (cas-dotnet-sdk conventions, see CLAUDE.md)
- Bump the
cas-core-libsubmodule to the cas-core-lib release that contains the exports, and commit the regeneratedcas-dotnet-sdk/generated/NativeMethods.g.cs(the PR workflows fail if it is stale). - Wrapper class (plus result types under
Types/) that marshals throughNativePin/NativeByteBufferand frees every returned buffer in afinally(or with the matchingfree_<struct>). - Keep secrets in
byte[]/Span<byte>, neverstring; clear them withCryptographicOperations.ZeroMemoryafter use and pin them while they cross the FFI. - Errors surface through
CasErrorHandler/CasException; add aCasErrorCodemember for any new cas-core-lib error code. - Add a usage sample to
docs/EXAMPLES.mdand a benchmark class undercas-dotnet-sdk-benchmarks/Benchmarks/.
Acceptance criteria
- CI green on Linux, Windows and macOS (
--lockedbuilds). - PR title follows Conventional Commits. Don't bump the version or edit
CHANGELOG.mdby hand; release-please does that.
Activity