Repository navigation
Backlog
Labels
enhancementNew feature or request
Description
Summary
cas-lib 0.7.1 added cas_lib::kdf (Cryptographic-API-Services/cas-lib#152) with CASHkdfSha256 / CASHkdfSha512 implementing CASHKDF (extract, expand, derive). cas-core-lib doesn't export it yet. cas-typescript-sdk already wraps it; this brings cas-core-lib (and through it cas-dotnet-sdk) level.
Blocked by: #145 (HKDF needs cas-lib 0.7.1 or later).
Work
- New
src/hkdf/module (mod.rs+types.rs), registered insrc/lib.rs. hkdf_sha256_extract/hkdf_sha256_expand/hkdf_sha256_deriveand the SHA-512 equivalents. Inputs: salt, ikm, prk, info as pointer + length; output length asusize.- Return the PRK / OKM through
export_bytes(ZeroAlloc wipes it onfree_bytes). - Out-of-range output lengths (0, or above 255 × hash length) and a PRK shorter than the hash length come back as cas-lib's
InvalidParameters/InvalidKeycodes, not a panic.
Tests
- Wycheproof
hkdf_sha256_test.json/hkdf_sha512_test.jsonrun in cas-lib and cas-typescript-sdk; here, add inline tests that extract-then-expand equals derive, plus the length-limit errors.
Implementation notes (cas-core-lib FFI conventions, see CLAUDE.md)
#[no_mangle] pub extern "C"functions; bytes cross as pointer +usizelength, never slices orVecs.- Results are
#[repr(C)]structs in the module'stypes.rswith anerror_code; buffers are handed out withexport_bytes(neveras_mut_ptr+forget), strings withCString::into_raw. - Result structs that hold more than one buffer get a
free_<struct>and a row in the CLAUDE.md "Ownership of returned memory" table; every new struct gets the ownership rustdoc (csbindgen copies it into the C# bindings). - Null or bad pointers return an error code instead of panicking (fix!: reject bad FFI pointers instead of panicking, and report keygen failures #144 pattern); the body delegates straight to cas-lib, with no crypto decisions here.
- If cas-lib adds a
CasErrorvariant, map it to the next appended numeric code (the mapping is an append-only ABI contract consumed by cas-dotnet-sdk). - Inline
#[test]round-trip, error-path and free tests in the module.
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.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity