Repository navigation
Backlog
Labels
enhancementNew feature or request
Description
Summary
cas-lib has cas_lib::password_hashers::pbkdf2::{derivation, derivation_with_salt} (HMAC-SHA3-256, 32-byte key; derivation returns the key and its generated salt in Pbkdf2Result). cas-core-lib doesn't export it. cas-typescript-sdk already wraps it; this brings cas-core-lib (and through it cas-dotnet-sdk) level.
Not blocked: the API is already in the cas-lib 0.7.0 this crate pins. Rebase onto #145 if that lands first.
Work
pbkdf2_derivation(password, iterations)returns a two-buffer#[repr(C)]result (key + salt), so it needs afree_pbkdf2_resultand a row in the CLAUDE.md ownership table.pbkdf2_derivation_with_salt(password, iterations, salt)returns the key throughexport_bytes.- Iterations below
MIN_ITERATIONSor a salt shorter thanMIN_SALT_LENGTH(16 bytes) return cas-lib'sInvalidParameterscode. - The salt is the 22-character PHC B64 string's bytes; document that callers must store it as-is.
Tests
- Inline tests:
derivationthenderivation_with_saltwith the returned salt gives the same key; parameter-limit errors;free_pbkdf2_resulttwice is harmless.
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