docs(crypto): state the real base64 key contract #7
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/MCPWEB-8-base64-key-contract"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The decode_master_key doc comment claimed standard base64 was accepted "with or without padding via a trim". That is false: both key decoders use the B64_STANDARD engine, whose PAD config defaults to DecodePaddingMode::RequireCanonical, so an unpadded 43-character key is rejected. The trim only strips surrounding whitespace. decode_session_key documented nothing about the alphabet or padding at all, and both failure messages said only "is not valid base64", giving an operator no hint about what to change.
Decoding behavior is unchanged: canonical decoding of a security key is the right default, since it rejects a truncated or re-encoded key instead of silently accepting it. Both doc comments now state the contract (standard alphabet, padding required, exactly 32 decoded bytes, i.e. what
openssl rand -base64 32emits), both base64 error contexts name the requirement and the minting recipe, and new unit tests pin the strictness by asserting that unpadded and URL-safe encodings are rejected for both keys. The wrong-length error stays separate.#MCPWEB-8