Expand description
C ABI for HIDE. Every language binding calls this; none reimplements the cryptography, so there is exactly one implementation to review.
Rules this boundary keeps:
- Nothing crossing the boundary is trusted: every pointer is checked for null and every length is validated before use.
- Secret keys never leave Rust. Callers hold an opaque handle; there is no function that exports key material.
- Buffers allocated here are freed here (
hide_buffer_free), because a caller freeing Rust memory with libcfreeis undefined behaviour. - No function unwinds across the boundary. A panic in Rust crossing into C is undefined behaviour, so every entry point catches it.
Structs§
- Hide
Buffer - An owned buffer handed to the caller. Free it with
hide_buffer_free. - Hide
Secret Key - An opaque secret key. The caller only ever holds this pointer; there is no accessor that returns the underlying bytes.
- Hide
Signing Identity - An opaque signing identity. As with secret keys, no function exports the seed: a binding can sign, and cannot leak.
- Hide
Spent Nonces - The verifier’s record of answered challenges. Replay can only be detected by the verifier, so this must outlive a single request.
Constants§
- HIDE_
ERR_ AUTHENTICATION - HIDE_
ERR_ CHALLENGE_ EXPIRED - Reasons a challenge answer was refused, beyond the generic codes above.
- HIDE_
ERR_ CHALLENGE_ REPLAYED - HIDE_
ERR_ INTERNAL - HIDE_
ERR_ INVALID_ ARGUMENT - HIDE_
ERR_ MALFORMED - HIDE_
ERR_ NOT_ A_ KEY - HIDE_
ERR_ NO_ MATCHING_ RECIPIENT - HIDE_
ERR_ PANIC - HIDE_
ERR_ TOO_ LARGE - HIDE_
ERR_ WRONG_ PASSPHRASE - HIDE_
KEY_ PROTECTED - HIDE_
KEY_ RAW - Key file kinds reported by
hide_inspect_key. - HIDE_
MIN_ PASSPHRASE_ LEN - HIDE_
NONCE_ LEN - A challenge nonce.
- HIDE_OK
- Status codes. Zero is success; everything else is a failure the caller must handle. Values are stable across versions: bindings switch on them.
- HIDE_
PUBLIC_ KEY_ LEN - HIDE_
SIGNATURE_ LEN - A hybrid signature: Ed25519 followed by ML-DSA-65.
- HIDE_
VERIFYING_ KEY_ LEN - A hybrid verifying key.
Functions§
- hide_
buffer_ empty - An empty buffer, for initialising a local before passing its address in.
Callers must start from this rather than from uninitialised memory, because
hide_buffer_freereads the pointer it is given. - hide_
buffer_ ⚠free - Frees a buffer produced by this library.
- hide_
challenge_ ⚠accept - Accepts a challenge answer exactly once. A valid signature replayed a
second time returns
HIDE_ERR_CHALLENGE_REPLAYED, which is the entire reason this call takes aspentrecord rather than being a pure function. - hide_
challenge_ ⚠answer - Answers a challenge, producing a signature over it.
- hide_
challenge_ ⚠new - Creates a challenge for a prover to answer. The encoded challenge is not secret and is handed to the prover as-is.
- hide_
decrypt ⚠ - Decrypts a container. Nothing is written to
outunless the whole payload authenticates, so a caller cannot act on unverified plaintext. - hide_
encrypt ⚠ - Encrypts a buffer for one or more recipients.
- hide_
error_ message - Human-readable text for a status code. The returned string is static and must not be freed.
- hide_
identity_ ⚠generate - Creates an identity and returns it sealed under
passphrase, ready to write to disk. One seed backs both encryption and signing, so a caller has a single thing to back up; the seed itself never crosses the boundary. - hide_
inspect_ ⚠key - Reports whether a key file is raw or passphrase-protected, without needing the passphrase.
- hide_
keypair_ ⚠generate - Generates a key pair. The secret is returned as an opaque handle; the public key is returned as bytes, which are safe to share.
- hide_
public_ ⚠key_ armor - Encodes a public key as pasteable armored text, returned as UTF-8 bytes.
- hide_
public_ ⚠key_ dearmor - Decodes armored public-key text back into bytes.
- hide_
secret_ ⚠key_ free - Releases a secret key. The key material is zeroized.
- hide_
secret_ ⚠key_ open - Loads a secret key from a file’s bytes. Pass
passphrase = NULLfor a raw key; a protected key without a passphrase fails rather than guessing. - hide_
secret_ ⚠key_ protect - Seals a secret key with a passphrase, producing the bytes to store on disk.
- hide_
secret_ ⚠key_ public - Derives the public key belonging to a secret key.
- hide_
sign_ ⚠message - Signs a message under a caller-chosen context.
- hide_
signing_ ⚠identity_ free - Releases a signing identity, zeroizing the seed.
- hide_
signing_ ⚠identity_ open - Loads a signing identity from a key file’s bytes.
- hide_
signing_ ⚠identity_ public - The shareable verifying key for a signing identity.
- hide_
spent_ ⚠nonces_ free - Releases the record of spent nonces.
- hide_
spent_ nonces_ new - Creates the verifier’s record of spent nonces.
- hide_
verify_ ⚠message - Verifies a signature. Returns
HIDE_OKonly if both halves verify. - hide_
version - The library version, as a static NUL-terminated string.