# std::crypto API Reference

Public declarations reachable through the documented package entry points. Signatures follow the source snapshot; consult the module guide for support and qualification boundaries.


## Application entry points

Start with [checked cryptographic facades](index.md), [AEAD ownership and nonce policy](encryption.md), [hashes](hashing.md), and [key derivation/signatures](kdf.md). `export` marks a declaration in its defining source module; it does not classify a raw kernel or test helper as an application-level facade.

<a id="Digest32"></a>

### Digest32

Import: `"crypto"`.

```vex
export contract Digest32 {
    reset()!;
    update(data: str)!;
    updateRaw(data: RawBuf, len: u64)!;
    sum(out: Ptr<u8>, out_len: u64)!;
}
```

<a id="Mac32"></a>

### Mac32

Import: `"crypto"`.

```vex
export contract Mac32 {
    reset()!;
    update(data: str)!;
    updateRaw(data: RawBuf, len: u64)!;
    final(out: Ptr<u8>, out_len: u64)!;
}
```

<a id="ChaCha20Poly1305"></a>

### ChaCha20Poly1305

Import: `"crypto"`.

```vex
export struct ChaCha20Poly1305
```

<a id="Aes128Gcm"></a>

### Aes128Gcm

Import: `"crypto"`.

```vex
export struct Aes128Gcm
```

<a id="Aes256Gcm"></a>

### Aes256Gcm

Import: `"crypto"`.

```vex
export struct Aes256Gcm
```

<a id="HkdfSha256"></a>

### HkdfSha256

Import: `"crypto"`.

```vex
export struct HkdfSha256
```

<a id="HkdfSha384"></a>

### HkdfSha384

Import: `"crypto"`.

```vex
export struct HkdfSha384
```

<a id="Pbkdf2Sha256"></a>

### Pbkdf2Sha256

Import: `"crypto"`.

```vex
export struct Pbkdf2Sha256
```

<a id="X25519"></a>

### X25519

Import: `"crypto"`.

```vex
export struct X25519
```

<a id="Ed25519"></a>

### Ed25519

Import: `"crypto"`.

```vex
export struct Ed25519
```

<a id="Argon2Parameters"></a>

### Argon2Parameters

Import: `"crypto"`.

```vex
export struct Argon2Parameters
```

Public Argon2 cost policy. Memory is expressed in KiB, matching RFC 9106.

**Implements:** `Copy`

**Public fields:**

- `timeCost`: `u64`
- `memoryKiB`: `u64`
- `parallelism`: `u64`

<a id="Argon2id"></a>

### Argon2id

Import: `"crypto"`.

```vex
export struct Argon2id
```

Type-safe Argon2id facade. RawBuf kernels remain available for protocol

implementations, while application code should use this Span/Vec surface.

<a id="CryptoError"></a>

### CryptoError

Import: `"crypto"`.

```vex
export struct CryptoError
```

Allocation-free cryptographic operation failure. `requested` and `limit`

are byte counts unless the operation documents another unit.

**Implements:** `Copy`

**Public fields:**

- `kind`: `CryptoErrorKind`
- `requested`: `u64`
- `limit`: `u64`

<a id="Fe25519"></a>

### Fe25519

Import: `"crypto"`.

```vex
export struct Fe25519
```

Field element in 5x51-bit limbs

**Implements:** `Copy`

**Public fields:**

- `l`: `[u64; 5]`

<a id="Poly1305"></a>

### Poly1305

Import: `"crypto"`.

```vex
export struct Poly1305
```

<a id="Sha1"></a>

### Sha1

Import: `"crypto"`.

```vex
export struct Sha1
```

<a id="Sha256"></a>

### Sha256

Import: `"crypto"`.

```vex
export struct Sha256
```

<a id="Sha512"></a>

### Sha512

Import: `"crypto"`.

```vex
export struct Sha512
```

**Public fields:**

- `h`: `[u64; 8]`
- `buf`: `[u8; 128]`
- `bufLen`: `u64`
- `totalLen`: `u64`

<a id="Sha384"></a>

### Sha384

Import: `"crypto"`.

```vex
export struct Sha384
```

SHA-384 shares SHA-512's compression function and block size, but uses

the independent FIPS 180-4 initial state and truncates the digest to 48
bytes. Keeping a single `Sha512` engine avoids a second cryptographic
kernel drifting away from the standard.

<a id="CryptoErrorKind"></a>

### CryptoErrorKind

Import: `"crypto"`.

```vex
export enum CryptoErrorKind
```

**Variants:**

- `InvalidKeyLength`
- `InvalidNonceLength`
- `InvalidTagLength`
- `InvalidSignatureLength`
- `MessageTooLarge`
- `CounterExhausted`
- `AuthenticationFailed`
- `InvalidPublicKey`
- `InvalidParameter`
- `OutOfMemory`

<a id="aeadEncrypt"></a>

### aeadEncrypt

Import: `"crypto"`.

```vex
export fn aeadEncrypt(key: RawBuf, nonce: RawBuf, aad: RawBuf, aadLen: u64, plaintext: RawBuf, ptLen: u64, out: RawBuf): Result<[u8; 16], CryptoError>
```

Encrypt with ChaCha20-Poly1305 AEAD (RFC 8439).

key: 32 bytes, nonce: 12 bytes.
Writes ciphertext to `out` (same length as plaintext).
Returns 16-byte authentication tag.

**Returns:** `Result<[u8; 16], CryptoError>`

<a id="aeadDecrypt"></a>

### aeadDecrypt

Import: `"crypto"`.

```vex
export fn aeadDecrypt(key: RawBuf, nonce: RawBuf, aad: RawBuf, aadLen: u64, ciphertext: RawBuf, ctLen: u64, tag: RawBuf, out: RawBuf): Result<(), CryptoError>
```

Decrypt with ChaCha20-Poly1305 AEAD (RFC 8439).

key: 32 bytes, nonce: 12 bytes.
Returns `Ok(())` after authentication and decryption, or a typed `CryptoError`.
Authentication failure clears `ctLen` output bytes. The early oversized-AAD
error returns before touching output; do not infer that every error clears it.
This raw API cannot validate allocation extents: callers must supply the exact
readable/writable byte ranges below and uphold aliasing requirements. Prefer
the checked `ChaCha20Poly1305` facade for application records.

**Returns:** `Result<(), CryptoError>`

<a id="aes256ExpandKey"></a>

### aes256ExpandKey

Import: `"crypto"`.

```vex
export fn aes256ExpandKey(key: RawBuf): [u8; 240]
```

Expand an AES-256 key once for internal multi-block constructions.

Callers must securely erase the returned 240-byte schedule.

**Returns:** `[u8; 240]`

<a id="aes128ExpandKey"></a>

### aes128ExpandKey

Import: `"crypto"`.

```vex
export fn aes128ExpandKey(key: RawBuf): [u8; 176]
```

Expand an AES-128 key once for internal multi-block constructions.

Callers must securely erase the returned 176-byte schedule.

**Returns:** `[u8; 176]`

<a id="aes128EncryptBlockWithRk"></a>

### aes128EncryptBlockWithRk

Import: `"crypto"`.

```vex
export fn aes128EncryptBlockWithRk(rkb: RawBuf, input: RawBuf, out: RawBuf)
```

<a id="aes128EncryptBlock"></a>

### aes128EncryptBlock

Import: `"crypto"`.

```vex
export fn aes128EncryptBlock(key: RawBuf, input: RawBuf, out: RawBuf)
```

AES-128 encrypt one 16-byte block.

key: 16 bytes, input: 16 bytes.

<a id="aes256EncryptBlockWithRk"></a>

### aes256EncryptBlockWithRk

Import: `"crypto"`.

```vex
export fn aes256EncryptBlockWithRk(rkb: RawBuf, input: RawBuf, out: RawBuf)
```

<a id="aes256EncryptBlock"></a>

### aes256EncryptBlock

Import: `"crypto"`.

```vex
export fn aes256EncryptBlock(key: RawBuf, input: RawBuf, out: RawBuf)
```

AES-256 encrypt one 16-byte block.

key: 32 bytes, input: 16 bytes.

<a id="aes256CtrXorWithRk"></a>

### aes256CtrXorWithRk

Import: `"crypto"`.

```vex
export fn aes256CtrXorWithRk(rkb: RawBuf, counter0: RawBuf, input: RawBuf, len: u64, out: RawBuf): Result<(), CryptoError>
```

AES-256 CTR using a caller-owned expanded schedule.

**Returns:** `Result<(), CryptoError>`

<a id="aes256CtrXor"></a>

### aes256CtrXor

Import: `"crypto"`.

```vex
export fn aes256CtrXor(key: RawBuf, counter0: RawBuf, input: RawBuf, len: u64, out: RawBuf): Result<(), CryptoError>
```

AES-256 CTR XOR helper (counter block is 16-byte J0-like block).

Uses inc32 in big-endian per GCM convention.

**Returns:** `Result<(), CryptoError>`

<a id="aes128CtrXorWithRk"></a>

### aes128CtrXorWithRk

Import: `"crypto"`.

```vex
export fn aes128CtrXorWithRk(rkb: RawBuf, counter0: RawBuf, input: RawBuf, len: u64, out: RawBuf): Result<(), CryptoError>
```

AES-128 CTR XOR helper (counter block is a 16-byte J0-like block).

Like AES-GCM's CTR construction, the supplied block is incremented before
it is encrypted for the first segment.

**Returns:** `Result<(), CryptoError>`

<a id="aes128CtrXor"></a>

### aes128CtrXor

Import: `"crypto"`.

```vex
export fn aes128CtrXor(key: RawBuf, counter0: RawBuf, input: RawBuf, len: u64, out: RawBuf): Result<(), CryptoError>
```

**Returns:** `Result<(), CryptoError>`

<a id="aes128CtrXorFromInitialCounter"></a>

### aes128CtrXorFromInitialCounter

Import: `"crypto"`.

```vex
export fn aes128CtrXorFromInitialCounter(key: RawBuf, counter0: RawBuf, input: RawBuf, len: u64, out: RawBuf)
```

<a id="aes128GcmEncrypt"></a>

### aes128GcmEncrypt

Import: `"crypto"`.

```vex
export fn aes128GcmEncrypt(key: RawBuf, nonce12: RawBuf, aad: RawBuf, aadLen: u64, plaintext: RawBuf, ptLen: u64, out: RawBuf): Result<[u8; 16], CryptoError>
```

AES-128-GCM encrypt with the NIST 96-bit nonce fast path.

**Returns:** `Result<[u8; 16], CryptoError>`

<a id="aes128GcmDecrypt"></a>

### aes128GcmDecrypt

Import: `"crypto"`.

```vex
export fn aes128GcmDecrypt(key: RawBuf, nonce12: RawBuf, aad: RawBuf, aadLen: u64, ciphertext: RawBuf, ctLen: u64, tag: RawBuf, out: RawBuf): Result<(), CryptoError>
```

AES-128-GCM authenticated decryption. Plaintext is released only after the

complete tag has been verified in constant time.

**Returns:** `Result<(), CryptoError>`

<a id="aes256GcmEncrypt"></a>

### aes256GcmEncrypt

Import: `"crypto"`.

```vex
export fn aes256GcmEncrypt(key: RawBuf, nonce12: RawBuf, aad: RawBuf, aadLen: u64, plaintext: RawBuf, ptLen: u64, out: RawBuf): Result<[u8; 16], CryptoError>
```

AES-256-GCM encrypt with one key expansion per complete operation.

**Returns:** `Result<[u8; 16], CryptoError>`

<a id="aes256GcmDecrypt"></a>

### aes256GcmDecrypt

Import: `"crypto"`.

```vex
export fn aes256GcmDecrypt(key: RawBuf, nonce12: RawBuf, aad: RawBuf, aadLen: u64, ciphertext: RawBuf, ctLen: u64, tag: RawBuf, out: RawBuf): Result<(), CryptoError>
```

**Returns:** `Result<(), CryptoError>`

<a id="argon2idDerive"></a>

### argon2idDerive

Import: `"crypto"`.

```vex
export fn argon2idDerive(password: RawBuf, pwdLen: u64, salt: RawBuf, saltLen: u64, timeCost: u64, memoryKiB: u64, parallelism: u64, out: RawBuf, outLen: u64): Result<(), CryptoError>
```

Argon2id derivation (recommended default).

**Returns:** `Result<(), CryptoError>`

<a id="argon2idDeriveEx"></a>

### argon2idDeriveEx

Import: `"crypto"`.

```vex
export fn argon2idDeriveEx(password: RawBuf, pwdLen: u64, salt: RawBuf, saltLen: u64, secret: RawBuf, secretLen: u64, ad: RawBuf, adLen: u64, timeCost: u64, memoryKiB: u64, parallelism: u64, out: RawBuf, outLen: u64): Result<(), CryptoError>
```

Argon2id derivation with optional secret/ad fields (RFC-style inputs).

**Returns:** `Result<(), CryptoError>`

<a id="argon2iDerive"></a>

### argon2iDerive

Import: `"crypto"`.

```vex
export fn argon2iDerive(password: RawBuf, pwdLen: u64, salt: RawBuf, saltLen: u64, timeCost: u64, memoryKiB: u64, parallelism: u64, out: RawBuf, outLen: u64): Result<(), CryptoError>
```

Argon2i derivation (data-independent indexing).

**Returns:** `Result<(), CryptoError>`

<a id="argon2iDeriveEx"></a>

### argon2iDeriveEx

Import: `"crypto"`.

```vex
export fn argon2iDeriveEx(password: RawBuf, pwdLen: u64, salt: RawBuf, saltLen: u64, secret: RawBuf, secretLen: u64, ad: RawBuf, adLen: u64, timeCost: u64, memoryKiB: u64, parallelism: u64, out: RawBuf, outLen: u64): Result<(), CryptoError>
```

Argon2i derivation with optional secret/ad fields.

**Returns:** `Result<(), CryptoError>`

<a id="argon2dDerive"></a>

### argon2dDerive

Import: `"crypto"`.

```vex
export fn argon2dDerive(password: RawBuf, pwdLen: u64, salt: RawBuf, saltLen: u64, timeCost: u64, memoryKiB: u64, parallelism: u64, out: RawBuf, outLen: u64): Result<(), CryptoError>
```

Argon2d derivation (data-dependent indexing).

**Returns:** `Result<(), CryptoError>`

<a id="argon2dDeriveEx"></a>

### argon2dDeriveEx

Import: `"crypto"`.

```vex
export fn argon2dDeriveEx(password: RawBuf, pwdLen: u64, salt: RawBuf, saltLen: u64, secret: RawBuf, secretLen: u64, ad: RawBuf, adLen: u64, timeCost: u64, memoryKiB: u64, parallelism: u64, out: RawBuf, outLen: u64): Result<(), CryptoError>
```

Argon2d derivation with optional secret/ad fields.

**Returns:** `Result<(), CryptoError>`

<a id="base64Encode"></a>

### base64Encode

Import: `"crypto"`.

```vex
export fn base64Encode(src: RawBuf, len: u64): string
```

Base64 encode raw bytes (RFC 4648, padded).

**Returns:** `string`

<a id="base64EncodeString"></a>

### base64EncodeString

Import: `"crypto"`.

```vex
export fn base64EncodeString(s: str): string
```

Base64 encode string bytes as UTF-8 byte sequence.

**Returns:** `string`

<a id="blake2bTo"></a>

### blake2bTo

Import: `"crypto"`.

```vex
export fn blake2bTo(data: RawBuf, len: u64, out: Ptr<u8>, outLen: u64)
```

Compute BLAKE2b hash to caller-provided output buffer.

outLen must be in [1, 64].

<a id="blake2bHex"></a>

### blake2bHex

Import: `"crypto"`.

```vex
export fn blake2bHex(data: str): string
```

**Returns:** `string`

<a id="ctEq"></a>

### ctEq

Import: `"crypto"`.

```vex
export fn ctEq(a: RawBuf, aLen: u64, b: RawBuf, bLen: u64): bool
```

Constant-time equality over two byte slices (64-bit SWAR accelerated).

Returns false on length mismatch.

**Returns:** `bool`

<a id="xorInto"></a>

### xorInto

Import: `"crypto"`.

```vex
export fn xorInto(dst: RawBuf, a: RawBuf, b: RawBuf, len: u64)
```

XOR two sources into destination: dst[i] = a[i] ^ b[i] (64-bit SWAR accelerated)

<a id="xorInPlace"></a>

### xorInPlace

Import: `"crypto"`.

```vex
export fn xorInPlace(dst: RawBuf, src: RawBuf, len: u64)
```

In-place XOR: dst[i] ^= src[i] (64-bit SWAR accelerated)

<a id="zeroize"></a>

### zeroize

Import: `"crypto"`.

```vex
export fn zeroize(buf: RawBuf, len: u64)
```

Zeroize sensitive buffer memory. The compiler lowers this to a volatile

memset so the stores survive dead-store elimination before deallocation.

<a id="chacha20Block"></a>

### chacha20Block

Import: `"crypto"`.

```vex
export fn chacha20Block(key: RawBuf, nonce: RawBuf, counter: u32, out: RawBuf)
```

Generate one 64-byte ChaCha20 block.

<a id="chacha20Xor"></a>

### chacha20Xor

Import: `"crypto"`.

```vex
export fn chacha20Xor(out: RawBuf, input: RawBuf, len: u64, key: RawBuf, nonce: RawBuf, counter: u32): Result<(), CryptoError>
```

XOR stream with input using 4-way SIMD parallel block pass (256 bytes per iteration).

**Returns:** `Result<(), CryptoError>`

<a id="pointIdentity"></a>

### pointIdentity

Import: `"crypto"`.

```vex
export fn pointIdentity(out: &ExtPoint!)
```

<a id="pointDouble"></a>

### pointDouble

Import: `"crypto"`.

```vex
export fn pointDouble(p: &ExtPoint, out: &ExtPoint!)
```

<a id="pointAdd"></a>

### pointAdd

Import: `"crypto"`.

```vex
export fn pointAdd(p: &ExtPoint, q: &ExtPoint, out: &ExtPoint!)
```

<a id="scalarMul"></a>

### scalarMul

Import: `"crypto"`.

```vex
export fn scalarMul(scalar: RawBuf, point: &ExtPoint, out: &ExtPoint!)
```

<a id="pointEncode"></a>

### pointEncode

Import: `"crypto"`.

```vex
export fn pointEncode(p: &ExtPoint, out: RawBuf)
```

<a id="basepointExt"></a>

### basepointExt

Import: `"crypto"`.

```vex
export fn basepointExt(out: &ExtPoint!)
```

<a id="ed25519PublicKey"></a>

### ed25519PublicKey

Import: `"crypto"`.

```vex
export fn ed25519PublicKey(pubOut: RawBuf, privateKey: RawBuf)
```

Ed25519 key pair generation.

privateKey: 32 random bytes.
Writes 32-byte public key to pubOut.

<a id="ed25519Sign"></a>

### ed25519Sign

Import: `"crypto"`.

```vex
export fn ed25519Sign(sigOut: RawBuf, privateKey: RawBuf, message: RawBuf, msgLen: u64)
```

Ed25519 sign a message.

Writes 64-byte signature to sigOut.
privateKey: 32 bytes, message: raw bytes.

<a id="ed25519SignHex"></a>

### ed25519SignHex

Import: `"crypto"`.

```vex
export fn ed25519SignHex(privateKey: RawBuf, message: RawBuf, msgLen: u64): string
```

Ed25519 sign returning hex(signature[64]).

**Returns:** `string`

<a id="ed25519Verify"></a>

### ed25519Verify

Import: `"crypto"`.

```vex
export fn ed25519Verify(signature: RawBuf, publicKey: RawBuf, message: RawBuf, msgLen: u64): bool
```

Ed25519 verify: returns true iff signature is valid.

**Returns:** `bool`

<a id="ed25519PublicKeyHex"></a>

### ed25519PublicKeyHex

Import: `"crypto"`.

```vex
export fn ed25519PublicKeyHex(privateKey: RawBuf): string
```

Ed25519 public key generation returning hex.

**Returns:** `string`

<a id="ed25519BasepointHex"></a>

### ed25519BasepointHex

Import: `"crypto"`.

```vex
export fn ed25519BasepointHex(): string
```

Diagnostic helper: return encoded Ed25519 basepoint.

**Returns:** `string`

<a id="ed25519MulBaseHex"></a>

### ed25519MulBaseHex

Import: `"crypto"`.

```vex
export fn ed25519MulBaseHex(scalar: RawBuf): string
```

Diagnostic helper: encode scalar*B for a raw 32-byte scalar.

**Returns:** `string`

<a id="feZero"></a>

### feZero

Import: `"crypto"`.

```vex
export fn feZero(out: &Fe25519!)
```

<a id="feOne"></a>

### feOne

Import: `"crypto"`.

```vex
export fn feOne(out: &Fe25519!)
```

<a id="feCopy"></a>

### feCopy

Import: `"crypto"`.

```vex
export fn feCopy(f: &Fe25519, out: &Fe25519!)
```

Copy a field element (creates a new value from a reference)

<a id="feFromBytes"></a>

### feFromBytes

Import: `"crypto"`.

```vex
export fn feFromBytes(b: RawBuf, out: &Fe25519!)
```

<a id="feToBytes"></a>

### feToBytes

Import: `"crypto"`.

```vex
export fn feToBytes(f: &Fe25519, out: RawBuf)
```

<a id="feAdd"></a>

### feAdd

Import: `"crypto"`.

```vex
export fn feAdd(a: &Fe25519, b: &Fe25519, out: &Fe25519!)
```

<a id="feSub"></a>

### feSub

Import: `"crypto"`.

```vex
export fn feSub(a: &Fe25519, b: &Fe25519, out: &Fe25519!)
```

<a id="feMul"></a>

### feMul

Import: `"crypto"`.

```vex
export fn feMul(a: &Fe25519, b: &Fe25519, out: &Fe25519!)
```

<a id="feMulSmall"></a>

### feMulSmall

Import: `"crypto"`.

```vex
export fn feMulSmall(a: &Fe25519, coefficient: u64, out: &Fe25519!)
```

Multiply by a single machine-word coefficient. This is the canonical

constant/small-coefficient path for field formulas: it preserves the same
reduction semantics as `feMul` without manufacturing a sparse field
element and paying for its zero products.

<a id="feSq"></a>

### feSq

Import: `"crypto"`.

```vex
export fn feSq(a: &Fe25519, out: &Fe25519!)
```

<a id="feInvert"></a>

### feInvert

Import: `"crypto"`.

```vex
export fn feInvert(z: &Fe25519, out: &Fe25519!)
```

<a id="feCSwap"></a>

### feCSwap

Import: `"crypto"`.

```vex
export fn feCSwap(a: &Fe25519!, b: &Fe25519!, swap: u64)
```

<a id="hexEncode"></a>

### hexEncode

Import: `"crypto"`.

```vex
export fn hexEncode(src: RawBuf, len: u64): string
```

Encode raw bytes to lowercase hex string.

**Returns:** `string`

<a id="hexDecodeTo"></a>

### hexDecodeTo

Import: `"crypto"`.

```vex
export fn hexDecodeTo(hex: str, out: RawBuf, outCap: u64): u64
```

Decode hex string to bytes into caller-provided output buffer.

Returns number of written bytes, or 0 on invalid hex/out-of-capacity.

**Returns:** `u64`

<a id="hkdfExtract"></a>

### hkdfExtract

Import: `"crypto"`.

```vex
export fn hkdfExtract(salt: RawBuf, saltLen: u64, ikm: RawBuf, ikmLen: u64, prk: Ptr<u8>): Result<(), CryptoError>
```

HKDF-Extract: PRK = HMAC-SHA256(salt, IKM)

If salt is empty (saltLen==0), uses 32 zero bytes as default salt.

**Returns:** `Result<(), CryptoError>`

<a id="hkdfExpand"></a>

### hkdfExpand

Import: `"crypto"`.

```vex
export fn hkdfExpand(prk: RawBuf, prkLen: u64, info: RawBuf, infoLen: u64, out: RawBuf, outLen: u64): Result<(), CryptoError>
```

HKDF-Expand: derive output keying material from PRK.

prk: 32 bytes (from hkdfExtract), outLen ≤ 255*32 = 8160 bytes.

**Returns:** `Result<(), CryptoError>`

<a id="hkdf"></a>

### hkdf

Import: `"crypto"`.

```vex
export fn hkdf(salt: RawBuf, saltLen: u64, ikm: RawBuf, ikmLen: u64, info: RawBuf, infoLen: u64, out: RawBuf, outLen: u64): Result<(), CryptoError>
```

One-shot HKDF: Extract + Expand.

**Returns:** `Result<(), CryptoError>`

<a id="hkdfExtractSha384"></a>

### hkdfExtractSha384

Import: `"crypto"`.

```vex
export fn hkdfExtractSha384(salt: RawBuf, saltLen: u64, ikm: RawBuf, ikmLen: u64, prk: Ptr<u8>): Result<(), CryptoError>
```

HKDF-Extract with HMAC-SHA384. An empty salt is represented by one

SHA-384 digest-length block of zero bytes, as required by RFC 5869.

**Returns:** `Result<(), CryptoError>`

<a id="hkdfExpandSha384"></a>

### hkdfExpandSha384

Import: `"crypto"`.

```vex
export fn hkdfExpandSha384(prk: RawBuf, prkLen: u64, info: RawBuf, infoLen: u64, out: RawBuf, outLen: u64): Result<(), CryptoError>
```

HKDF-Expand with HMAC-SHA384. The RFC 5869 limit is 255 digest blocks.

**Returns:** `Result<(), CryptoError>`

<a id="hkdfSha384"></a>

### hkdfSha384

Import: `"crypto"`.

```vex
export fn hkdfSha384(salt: RawBuf, saltLen: u64, ikm: RawBuf, ikmLen: u64, info: RawBuf, infoLen: u64, out: RawBuf, outLen: u64): Result<(), CryptoError>
```

**Returns:** `Result<(), CryptoError>`

<a id="hmacSha1To"></a>

### hmacSha1To

Import: `"crypto"`.

```vex
export fn hmacSha1To(key: RawBuf, keyLen: u64, data: RawBuf, dataLen: u64, out: Ptr<u8>)
```

HMAC-SHA1 (RFC 2104).  SHA-1 is retained solely for interoperating with

protocol profiles such as SRTP AES_CM_128_HMAC_SHA1_80; new application
protocols should use HMAC-SHA256 instead.

<a id="hmacSha256To"></a>

### hmacSha256To

Import: `"crypto"`.

```vex
export fn hmacSha256To(key: RawBuf, keyLen: u64, data: RawBuf, dataLen: u64, out: Ptr<u8>)
```

<a id="hmacSha256PartsTo"></a>

### hmacSha256PartsTo

Import: `"crypto"`.

```vex
export fn hmacSha256PartsTo(key: RawBuf, keyLen: u64, first: RawBuf, firstLen: u64, second: RawBuf, secondLen: u64, third: RawBuf, thirdLen: u64, out: Ptr<u8>)
```

Allocation-free HMAC-SHA256 over three discontiguous byte segments.

This is the shared kernel for HKDF/PBKDF2; no secret-bearing concatenation
buffer or per-round allocator traffic is required.

<a id="hmacSha384PartsTo"></a>

### hmacSha384PartsTo

Import: `"crypto"`.

```vex
export fn hmacSha384PartsTo(key: RawBuf, keyLen: u64, first: RawBuf, firstLen: u64, second: RawBuf, secondLen: u64, third: RawBuf, thirdLen: u64, out: Ptr<u8>)
```

Allocation-free HMAC-SHA384 over three discontiguous byte segments.

SHA-384 uses SHA-512's 128-byte block size and a 48-byte digest.

<a id="hmacSha384To"></a>

### hmacSha384To

Import: `"crypto"`.

```vex
export fn hmacSha384To(key: RawBuf, keyLen: u64, data: RawBuf, dataLen: u64, out: Ptr<u8>)
```

<a id="hmacSha384Hex"></a>

### hmacSha384Hex

Import: `"crypto"`.

```vex
export fn hmacSha384Hex(key: str, data: str): string
```

**Returns:** `string`

<a id="hmacSha256Hex"></a>

### hmacSha256Hex

Import: `"crypto"`.

```vex
export fn hmacSha256Hex(key: str, data: str): string
```

**Returns:** `string`

<a id="hmacVerifySha256Hex"></a>

### hmacVerifySha256Hex

Import: `"crypto"`.

```vex
export fn hmacVerifySha256Hex(key: str, data: str, expectedHex: str): bool
```

**Returns:** `bool`

<a id="pbkdf2Sha256"></a>

### pbkdf2Sha256

Import: `"crypto"`.

```vex
export fn pbkdf2Sha256(password: RawBuf, pwdLen: u64, salt: RawBuf, saltLen: u64, iterations: u64, out: RawBuf, outLen: u64): Result<(), CryptoError>
```

PBKDF2 with HMAC-SHA256 as PRF.

Password and salt are raw buffers, iterations &gt;= 1, output written to `out`.

**Returns:** `Result<(), CryptoError>`

<a id="pbkdf2Sha256Hex"></a>

### pbkdf2Sha256Hex

Import: `"crypto"`.

```vex
export fn pbkdf2Sha256Hex(password: str, salt: str, iterations: u64, dkLen: u64): Result<string, CryptoError>
```

Convenience: PBKDF2-SHA256 with string inputs, returns hex-encoded output.

**Returns:** `Result<string, CryptoError>`

<a id="newPoly1305"></a>

### newPoly1305

Import: `"crypto"`.

```vex
export fn newPoly1305(key: RawBuf, key_len: usize): Poly1305
```

**Returns:** `Poly1305`

<a id="poly1305Auth"></a>

### poly1305Auth

Import: `"crypto"`.

```vex
export fn poly1305Auth(key: RawBuf, key_len: usize, message: RawBuf, msg_len: usize): [u8; 16]
```

**Returns:** `[u8; 16]`

<a id="newSha1"></a>

### newSha1

Import: `"crypto"`.

```vex
export fn newSha1(): Sha1
```

**Returns:** `Sha1`

<a id="sha1To"></a>

### sha1To

Import: `"crypto"`.

```vex
export fn sha1To(data: RawBuf, len: u64, out: Ptr<u8>)
```

<a id="sha1Hex"></a>

### sha1Hex

Import: `"crypto"`.

```vex
export fn sha1Hex(data: str): string
```

**Returns:** `string`

<a id="newSha256"></a>

### newSha256

Import: `"crypto"`.

```vex
export fn newSha256(): Sha256
```

**Returns:** `Sha256`

<a id="sha256To"></a>

### sha256To

Import: `"crypto"`.

```vex
export fn sha256To(data: RawBuf, len: u64, out: Ptr<u8>)
```

<a id="sha256Hex"></a>

### sha256Hex

Import: `"crypto"`.

```vex
export fn sha256Hex(data: str): string
```

**Returns:** `string`

<a id="sha512Hex"></a>

### sha512Hex

Import: `"crypto"`.

```vex
export fn sha512Hex(data: str): string
```

**Returns:** `string`

<a id="sha512To"></a>

### sha512To

Import: `"crypto"`.

```vex
export fn sha512To(data: RawBuf, len: u64, out: Ptr<u8>)
```

<a id="sha384Hex"></a>

### sha384Hex

Import: `"crypto"`.

```vex
export fn sha384Hex(data: str): string
```

**Returns:** `string`

<a id="sha384To"></a>

### sha384To

Import: `"crypto"`.

```vex
export fn sha384To(data: RawBuf, len: u64, out: Ptr<u8>)
```

<a id="xorBlocks"></a>

### xorBlocks

Import: `"crypto"`.

```vex
export fn xorBlocks(dst: RawBuf, a: RawBuf, b: RawBuf, bytes: u64)
```

<a id="addU32Blocks"></a>

### addU32Blocks

Import: `"crypto"`.

```vex
export fn addU32Blocks(dst: RawBuf, a: RawBuf, b: RawBuf, words: u64)
```

<a id="rotrU32Blocks"></a>

### rotrU32Blocks

Import: `"crypto"`.

```vex
export fn rotrU32Blocks(dst: RawBuf, src: RawBuf, words: u64, shift: u32)
```

<a id="x25519"></a>

### x25519

Import: `"crypto"`.

```vex
export fn x25519(out: RawBuf, scalar: RawBuf, point: RawBuf)
```

Scalar multiplication: result = scalar * point on Curve25519.

Both scalar and point are 32 bytes (little-endian).
Result written to out (32 bytes).

<a id="x25519Basepoint"></a>

### x25519Basepoint

Import: `"crypto"`.

```vex
export fn x25519Basepoint(out: RawBuf, privateKey: RawBuf)
```

Generate X25519 public key from private key.

Private key: 32 random bytes (will be clamped internally).
Uses basepoint u=9.

<a id="x25519Hex"></a>

### x25519Hex

Import: `"crypto"`.

```vex
export fn x25519Hex(myPrivate: RawBuf, theirPublic: RawBuf): string
```

Compute X25519 shared secret, returns hex string.

**Returns:** `string`

<a id="ChaCha20Poly1305-sealDetachedInto"></a>

### ChaCha20Poly1305.sealDetachedInto

```vex
export fn ChaCha20Poly1305.sealDetachedInto(key: Span<u8>, nonce: Span<u8>, aad: Span<u8>, plaintext: Span<u8>, output: &Vec<u8>!): Result<[u8; 16], CryptoError>
```

Encrypt into caller-reusable storage and return a detached 128-bit tag.

Source/output overlap is staged before any resize; output is empty on error.

**Returns:** `Result<[u8; 16], CryptoError>`

<a id="ChaCha20Poly1305-openDetachedInto"></a>

### ChaCha20Poly1305.openDetachedInto

```vex
export fn ChaCha20Poly1305.openDetachedInto(key: Span<u8>, nonce: Span<u8>, aad: Span<u8>, ciphertext: Span<u8>, tag: Span<u8>, output: &Vec<u8>!): Result<usize, CryptoError>
```

Authenticate before releasing plaintext into caller-reusable storage.

The output is securely erased and emptied on every failure.

**Returns:** `Result<usize, CryptoError>`

<a id="ChaCha20Poly1305-sealInto"></a>

### ChaCha20Poly1305.sealInto

```vex
export fn ChaCha20Poly1305.sealInto(key: Span<u8>, nonce: Span<u8>, aad: Span<u8>, plaintext: Span<u8>, output: &Vec<u8>!): Result<usize, CryptoError>
```

Encrypt to the conventional `ciphertext || tag` representation.

**Returns:** `Result<usize, CryptoError>`

<a id="ChaCha20Poly1305-openInto"></a>

### ChaCha20Poly1305.openInto

```vex
export fn ChaCha20Poly1305.openInto(key: Span<u8>, nonce: Span<u8>, aad: Span<u8>, sealed: Span<u8>, output: &Vec<u8>!): Result<usize, CryptoError>
```

Open a conventional `ciphertext || tag` value.

**Returns:** `Result<usize, CryptoError>`

<a id="ChaCha20Poly1305-seal"></a>

### ChaCha20Poly1305.seal

```vex
export fn ChaCha20Poly1305.seal(key: Span<u8>, nonce: Span<u8>, aad: Span<u8>, plaintext: Span<u8>): Result<Vec<u8>, CryptoError>
```

**Returns:** `Result<Vec<u8>, CryptoError>`

<a id="ChaCha20Poly1305-open"></a>

### ChaCha20Poly1305.open

```vex
export fn ChaCha20Poly1305.open(key: Span<u8>, nonce: Span<u8>, aad: Span<u8>, sealed: Span<u8>): Result<Vec<u8>, CryptoError>
```

**Returns:** `Result<Vec<u8>, CryptoError>`

<a id="Aes256Gcm-sealDetachedInto"></a>

### Aes256Gcm.sealDetachedInto

```vex
export fn Aes256Gcm.sealDetachedInto(key: Span<u8>, nonce: Span<u8>, aad: Span<u8>, plaintext: Span<u8>, output: &Vec<u8>!): Result<[u8; 16], CryptoError>
```

AES-256-GCM detached encryption with the checked/reusable contract.

**Returns:** `Result<[u8; 16], CryptoError>`

<a id="Aes256Gcm-openDetachedInto"></a>

### Aes256Gcm.openDetachedInto

```vex
export fn Aes256Gcm.openDetachedInto(key: Span<u8>, nonce: Span<u8>, aad: Span<u8>, ciphertext: Span<u8>, tag: Span<u8>, output: &Vec<u8>!): Result<usize, CryptoError>
```

**Returns:** `Result<usize, CryptoError>`

<a id="Aes256Gcm-sealInto"></a>

### Aes256Gcm.sealInto

```vex
export fn Aes256Gcm.sealInto(key: Span<u8>, nonce: Span<u8>, aad: Span<u8>, plaintext: Span<u8>, output: &Vec<u8>!): Result<usize, CryptoError>
```

**Returns:** `Result<usize, CryptoError>`

<a id="Aes256Gcm-openInto"></a>

### Aes256Gcm.openInto

```vex
export fn Aes256Gcm.openInto(key: Span<u8>, nonce: Span<u8>, aad: Span<u8>, sealed: Span<u8>, output: &Vec<u8>!): Result<usize, CryptoError>
```

**Returns:** `Result<usize, CryptoError>`

<a id="Aes256Gcm-seal"></a>

### Aes256Gcm.seal

```vex
export fn Aes256Gcm.seal(key: Span<u8>, nonce: Span<u8>, aad: Span<u8>, plaintext: Span<u8>): Result<Vec<u8>, CryptoError>
```

**Returns:** `Result<Vec<u8>, CryptoError>`

<a id="Aes256Gcm-open"></a>

### Aes256Gcm.open

```vex
export fn Aes256Gcm.open(key: Span<u8>, nonce: Span<u8>, aad: Span<u8>, sealed: Span<u8>): Result<Vec<u8>, CryptoError>
```

**Returns:** `Result<Vec<u8>, CryptoError>`

<a id="Aes128Gcm-sealDetachedInto"></a>

### Aes128Gcm.sealDetachedInto

```vex
export fn Aes128Gcm.sealDetachedInto(key: Span<u8>, nonce: Span<u8>, aad: Span<u8>, plaintext: Span<u8>, output: &Vec<u8>!): Result<[u8; 16], CryptoError>
```

AES-128-GCM detached encryption for protocols such as TLS 1.3.

**Returns:** `Result<[u8; 16], CryptoError>`

<a id="Aes128Gcm-openDetachedInto"></a>

### Aes128Gcm.openDetachedInto

```vex
export fn Aes128Gcm.openDetachedInto(key: Span<u8>, nonce: Span<u8>, aad: Span<u8>, ciphertext: Span<u8>, tag: Span<u8>, output: &Vec<u8>!): Result<usize, CryptoError>
```

**Returns:** `Result<usize, CryptoError>`

<a id="Aes128Gcm-sealInto"></a>

### Aes128Gcm.sealInto

```vex
export fn Aes128Gcm.sealInto(key: Span<u8>, nonce: Span<u8>, aad: Span<u8>, plaintext: Span<u8>, output: &Vec<u8>!): Result<usize, CryptoError>
```

**Usage contract:** The combined result is ciphertext followed by the tag; it does not contain the nonce. Keep nonce allocation and key lifetime at the application boundary. See [AEAD nonce lifecycle](encryption.md#nonce-and-key-lifecycle).

**Returns:** `Result<usize, CryptoError>`

<a id="Aes128Gcm-openInto"></a>

### Aes128Gcm.openInto

```vex
export fn Aes128Gcm.openInto(key: Span<u8>, nonce: Span<u8>, aad: Span<u8>, sealed: Span<u8>, output: &Vec<u8>!): Result<usize, CryptoError>
```

**Usage contract:** Only a successful result authenticates and releases plaintext. A valid tag does not itself enforce replay policy. Inputs are borrowed; the successful owning output can outlive them.

**Returns:** `Result<usize, CryptoError>`

<a id="Aes128Gcm-seal"></a>

### Aes128Gcm.seal

```vex
export fn Aes128Gcm.seal(key: Span<u8>, nonce: Span<u8>, aad: Span<u8>, plaintext: Span<u8>): Result<Vec<u8>, CryptoError>
```

**Usage contract:** The combined result is ciphertext followed by the tag; it does not contain the nonce. Keep nonce allocation and key lifetime at the application boundary. See [AEAD nonce lifecycle](encryption.md#nonce-and-key-lifecycle).

**Returns:** `Result<Vec<u8>, CryptoError>`

<a id="Aes128Gcm-open"></a>

### Aes128Gcm.open

```vex
export fn Aes128Gcm.open(key: Span<u8>, nonce: Span<u8>, aad: Span<u8>, sealed: Span<u8>): Result<Vec<u8>, CryptoError>
```

**Usage contract:** Only a successful result authenticates and releases plaintext. A valid tag does not itself enforce replay policy. Inputs are borrowed; the successful owning output can outlive them.

**Returns:** `Result<Vec<u8>, CryptoError>`

<a id="HkdfSha256-extract"></a>

### HkdfSha256.extract

```vex
export fn HkdfSha256.extract(salt: Span<u8>, inputKeyMaterial: Span<u8>): Result<[u8; 32], CryptoError>
```

Extract a fixed 32-byte pseudorandom key without exposing raw pointers.

**Returns:** `Result<[u8; 32], CryptoError>`

<a id="HkdfSha256-expandInto"></a>

### HkdfSha256.expandInto

```vex
export fn HkdfSha256.expandInto(prk: Span<u8>, info: Span<u8>, outputLength: usize, output: &Vec<u8>!): Result<usize, CryptoError>
```

Expand a 32-byte PRK into caller-reusable storage. RFC 5869's 8160-byte

maximum is enforced before allocation or output mutation.

**Returns:** `Result<usize, CryptoError>`

<a id="HkdfSha256-deriveInto"></a>

### HkdfSha256.deriveInto

```vex
export fn HkdfSha256.deriveInto(salt: Span<u8>, inputKeyMaterial: Span<u8>, info: Span<u8>, outputLength: usize, output: &Vec<u8>!): Result<usize, CryptoError>
```

One-shot HKDF-SHA256 derivation into caller-reusable storage.

**Returns:** `Result<usize, CryptoError>`

<a id="HkdfSha256-derive"></a>

### HkdfSha256.derive

```vex
export fn HkdfSha256.derive(salt: Span<u8>, inputKeyMaterial: Span<u8>, info: Span<u8>, outputLength: usize): Result<Vec<u8>, CryptoError>
```

**Usage contract:** Returns an independent owning byte vector. Length failure is typed; use distinct context values for distinct protocol purposes. See [HKDF guidance](kdf.md#hkdf).

**Returns:** `Result<Vec<u8>, CryptoError>`

<a id="HkdfSha384-extract"></a>

### HkdfSha384.extract

```vex
export fn HkdfSha384.extract(salt: Span<u8>, inputKeyMaterial: Span<u8>): Result<[u8; 48], CryptoError>
```

Extract a fixed 48-byte SHA-384 pseudorandom key through safe spans.

**Returns:** `Result<[u8; 48], CryptoError>`

<a id="HkdfSha384-expandInto"></a>

### HkdfSha384.expandInto

```vex
export fn HkdfSha384.expandInto(prk: Span<u8>, info: Span<u8>, outputLength: usize, output: &Vec<u8>!): Result<usize, CryptoError>
```

Expand a 48-byte PRK into caller-reusable storage. RFC 5869's 12240-byte

SHA-384 maximum is enforced before allocation or output mutation.

**Returns:** `Result<usize, CryptoError>`

<a id="HkdfSha384-deriveInto"></a>

### HkdfSha384.deriveInto

```vex
export fn HkdfSha384.deriveInto(salt: Span<u8>, inputKeyMaterial: Span<u8>, info: Span<u8>, outputLength: usize, output: &Vec<u8>!): Result<usize, CryptoError>
```

**Returns:** `Result<usize, CryptoError>`

<a id="HkdfSha384-derive"></a>

### HkdfSha384.derive

```vex
export fn HkdfSha384.derive(salt: Span<u8>, inputKeyMaterial: Span<u8>, info: Span<u8>, outputLength: usize): Result<Vec<u8>, CryptoError>
```

**Returns:** `Result<Vec<u8>, CryptoError>`

<a id="Pbkdf2Sha256-deriveInto"></a>

### Pbkdf2Sha256.deriveInto

```vex
export fn Pbkdf2Sha256.deriveInto(password: Span<u8>, salt: Span<u8>, iterations: u64, outputLength: usize, output: &Vec<u8>!): Result<usize, CryptoError>
```

PBKDF2-HMAC-SHA256 into reusable storage. Iteration count and RFC output

block limit are validated before output mutation; all intermediate U/T
blocks are securely erased by the kernel.

**Returns:** `Result<usize, CryptoError>`

<a id="Pbkdf2Sha256-derive"></a>

### Pbkdf2Sha256.derive

```vex
export fn Pbkdf2Sha256.derive(password: Span<u8>, salt: Span<u8>, iterations: u64, outputLength: usize): Result<Vec<u8>, CryptoError>
```

**Returns:** `Result<Vec<u8>, CryptoError>`

<a id="X25519-publicKeyTo"></a>

### X25519.publicKeyTo

```vex
export fn X25519.publicKeyTo(privateKey: Span<u8>, output: &Span<u8>!): Result<usize, CryptoError>
```

Derive an X25519 public key from an exact 32-byte private scalar.

**Returns:** `Result<usize, CryptoError>`

<a id="X25519-publicKeyInto"></a>

### X25519.publicKeyInto

```vex
export fn X25519.publicKeyInto(privateKey: Span<u8>, output: &Vec<u8>!): Result<usize, CryptoError>
```

Derive an X25519 public key into reusable owned storage.

**Returns:** `Result<usize, CryptoError>`

<a id="X25519-publicKey"></a>

### X25519.publicKey

```vex
export fn X25519.publicKey(privateKey: Span<u8>): Result<[u8; 32], CryptoError>
```

**Returns:** `Result<[u8; 32], CryptoError>`

<a id="X25519-sharedSecretTo"></a>

### X25519.sharedSecretTo

```vex
export fn X25519.sharedSecretTo(privateKey: Span<u8>, peerPublicKey: Span<u8>, output: &Span<u8>!): Result<usize, CryptoError>
```

**Usage contract:** Returns 32 on success. The all-zero shared result clears the destination and returns InvalidPublicKey. Dimension/overlap checks run before the operation; the raw span still requires valid live backing storage. X25519 alone does not authenticate the peer.

Compute a contributory X25519 shared secret. RFC 7748 permits callers to

reject an all-zero result; this safe API always rejects it in constant time
so low-order public keys cannot silently collapse the handshake secret.
The caller-owned output is exact-width, allocation-free, and zeroed before
returning `InvalidPublicKey` for a non-contributory peer.

**Returns:** `Result<usize, CryptoError>`

<a id="X25519-sharedSecretInto"></a>

### X25519.sharedSecretInto

```vex
export fn X25519.sharedSecretInto(privateKey: Span<u8>, peerPublicKey: Span<u8>, output: &Vec<u8>!): Result<usize, CryptoError>
```

Compute a contributory X25519 shared secret into reusable owned storage.

**Returns:** `Result<usize, CryptoError>`

<a id="X25519-sharedSecret"></a>

### X25519.sharedSecret

```vex
export fn X25519.sharedSecret(privateKey: Span<u8>, peerPublicKey: Span<u8>): Result<[u8; 32], CryptoError>
```

**Returns:** `Result<[u8; 32], CryptoError>`

<a id="Ed25519-publicKey"></a>

### Ed25519.publicKey

```vex
export fn Ed25519.publicKey(privateSeed: Span<u8>): Result<[u8; 32], CryptoError>
```

Derive the RFC 8032 public key for an exact 32-byte private seed.

**Returns:** `Result<[u8; 32], CryptoError>`

<a id="Ed25519-signInto"></a>

### Ed25519.signInto

```vex
export fn Ed25519.signInto(privateSeed: Span<u8>, message: Span<u8>, output: &Vec<u8>!): Result<usize, CryptoError>
```

Deterministically sign a message into caller-reusable storage. The private

seed and message may alias the output; both are staged before resize.

**Returns:** `Result<usize, CryptoError>`

<a id="Ed25519-sign"></a>

### Ed25519.sign

```vex
export fn Ed25519.sign(privateSeed: Span<u8>, message: Span<u8>): Result<[u8; 64], CryptoError>
```

**Returns:** `Result<[u8; 64], CryptoError>`

<a id="Ed25519-verify"></a>

### Ed25519.verify

```vex
export fn Ed25519.verify(publicKey: Span<u8>, message: Span<u8>, signature: Span<u8>): Result<bool, CryptoError>
```

**Usage contract:** Accept only Ok(true). Ok(false) means signature rejection; invalid dimensions produce a typed error. Public-key identity/trust is a separate application responsibility.

Strict verification: canonical encodings, canonical S, and non-small-order

R/public-key points are required. Dimension errors are typed; a well-formed
but invalid signature returns `Ok(false)`.

**Returns:** `Result<bool, CryptoError>`

<a id="Argon2Parameters-new"></a>

### Argon2Parameters.new

```vex
export fn Argon2Parameters.new(timeCost: u64, memoryKiB: u64, parallelism: u64): Argon2Parameters
```

**Returns:** `Argon2Parameters`

<a id="Argon2Parameters-recommended"></a>

### Argon2Parameters.recommended

```vex
export fn Argon2Parameters.recommended(): Argon2Parameters
```

RFC 9106's memory-constrained recommendation: 64 MiB, three passes and

four lanes. Applications should benchmark and increase memory when their
deployment budget permits it.

**Returns:** `Argon2Parameters`

<a id="Argon2id-deriveInto"></a>

### Argon2id.deriveInto

```vex
export fn Argon2id.deriveInto(password: Span<u8>, salt: Span<u8>, parameters: Argon2Parameters, outputLength: usize, output: &Vec<u8>!): Result<usize, CryptoError>
```

Derive into caller-reusable storage. Input/output aliases are staged before

Vec growth and every failure leaves `output` empty and securely erased.

**Returns:** `Result<usize, CryptoError>`

<a id="Argon2id-deriveExInto"></a>

### Argon2id.deriveExInto

```vex
export fn Argon2id.deriveExInto(password: Span<u8>, salt: Span<u8>, secret: Span<u8>, associatedData: Span<u8>, parameters: Argon2Parameters, outputLength: usize, output: &Vec<u8>!): Result<usize, CryptoError>
```

RFC 9106 extended derivation with an optional secret (pepper) and

associated data. The secret is mixed into H0 and is never copied to output.

**Returns:** `Result<usize, CryptoError>`

<a id="Argon2id-derive"></a>

### Argon2id.derive

```vex
export fn Argon2id.derive(password: Span<u8>, salt: Span<u8>, parameters: Argon2Parameters, outputLength: usize): Result<Vec<u8>, CryptoError>
```

**Returns:** `Result<Vec<u8>, CryptoError>`

<a id="Argon2id-deriveEx"></a>

### Argon2id.deriveEx

```vex
export fn Argon2id.deriveEx(password: Span<u8>, salt: Span<u8>, secret: Span<u8>, associatedData: Span<u8>, parameters: Argon2Parameters, outputLength: usize): Result<Vec<u8>, CryptoError>
```

**Returns:** `Result<Vec<u8>, CryptoError>`

<a id="CryptoError-new"></a>

### CryptoError.new

```vex
export fn CryptoError.new(kind: CryptoErrorKind, requested: u64, limit: u64): CryptoError
```

**Returns:** `CryptoError`

<a id="CryptoError-message"></a>

### CryptoError.message

```vex
export fn (self: &CryptoError) message(): str
```

**Returns:** `str`

<a id="Poly1305-new"></a>

### Poly1305.new

```vex
export fn Poly1305.new(key: RawBuf, key_len: usize): Poly1305
```

**Returns:** `Poly1305`

<a id="Poly1305-update"></a>

### Poly1305.update

```vex
export fn (self: &Poly1305!) update(data: RawBuf, len: usize)
```

<a id="Poly1305-finalize"></a>

### Poly1305.finalize

```vex
export fn (self: &Poly1305!) finalize(): [u8; 16]
```

**Returns:** `[u8; 16]`

<a id="Sha1-new"></a>

### Sha1.new

```vex
export fn Sha1.new(): Sha1
```

**Returns:** `Sha1`

<a id="Sha1-reset"></a>

### Sha1.reset

```vex
export fn (self: &Sha1!) reset()!
```

**Receiver:** `self: &Sha1!` *(mutable reference)*

<a id="Sha1-update"></a>

### Sha1.update

```vex
export fn (self: &Sha1!) update(data: str)
```

<a id="Sha1-updateRaw"></a>

### Sha1.updateRaw

```vex
export fn (self: &Sha1!) updateRaw(data: RawBuf, len: u64)
```

<a id="Sha1-sum"></a>

### Sha1.sum

```vex
export fn (self: &Sha1!) sum(out: Ptr<u8>, out_len: u64)!
```

<a id="Sha256-new"></a>

### Sha256.new

```vex
export fn Sha256.new(): Sha256
```

**Returns:** `Sha256`

<a id="Sha256-reset"></a>

### Sha256.reset

```vex
export fn (self: &Sha256!) reset()!
```

**Receiver:** `self: &Sha256!` *(mutable reference)*

<a id="Sha256-update"></a>

### Sha256.update

```vex
export fn (self: &Sha256!) update(data: str)
```

<a id="Sha256-updateRaw"></a>

### Sha256.updateRaw

```vex
export fn (self: &Sha256!) updateRaw(data: RawBuf, len: u64)
```

<a id="Sha256-sum"></a>

### Sha256.sum

```vex
export fn (self: &Sha256!) sum(out: Ptr<u8>, out_len: u64)!
```

<a id="Sha256-snapshotTo"></a>

### Sha256.snapshotTo

```vex
export fn (self: &Sha256) snapshotTo(out: Ptr<u8>, outLen: u64): bool
```

Writes the digest of the current state without consuming or finalizing it.

Hash-state cloning is deliberately explicit instead of making `Sha256`
`Copy`: callers can take protocol snapshots without enabling accidental
silent duplication of cryptographic state. The temporary state is erased
before this function returns.

**Returns:** `bool`

<a id="Sha512-new"></a>

### Sha512.new

```vex
export fn Sha512.new(): Sha512
```

**Returns:** `Sha512`

<a id="Sha512-init"></a>

### Sha512.init

```vex
export fn (self: &Sha512!) init()
```

**Receiver:** `self: &Sha512!` *(mutable reference)*

<a id="Sha384-new"></a>

### Sha384.new

```vex
export fn Sha384.new(): Sha384
```

**Returns:** `Sha384`

<a id="Sha512-update512"></a>

### Sha512.update512

```vex
export fn (self: &Sha512!) update512(data: str)
```

<a id="Sha512-updateRaw512"></a>

### Sha512.updateRaw512

```vex
export fn (self: &Sha512!) updateRaw512(data: RawBuf, len: u64)
```

<a id="Sha512-sum512"></a>

### Sha512.sum512

```vex
export fn (self: &Sha512!) sum512(out: Ptr<u8>, outLen: u64)
```

<a id="Sha384-update384"></a>

### Sha384.update384

```vex
export fn (self: &Sha384!) update384(data: str)
```

<a id="Sha384-updateRaw384"></a>

### Sha384.updateRaw384

```vex
export fn (self: &Sha384!) updateRaw384(data: RawBuf, len: u64)
```

<a id="Sha384-sum384"></a>

### Sha384.sum384

```vex
export fn (self: &Sha384!) sum384(out: Ptr<u8>, outLen: u64)
```

<a id="Sha384-reset384"></a>

### Sha384.reset384

```vex
export fn (self: &Sha384!) reset384()
```

Resets a SHA-384 state to its FIPS 180-4 initial value.

**Receiver:** `self: &Sha384!` *(mutable reference)*

<a id="Sha384-snapshotTo"></a>

### Sha384.snapshotTo

```vex
export fn (self: &Sha384) snapshotTo(out: Ptr<u8>, outLen: u64): bool
```

Writes the digest of the current state without consuming or finalizing it.

The explicitly cloned temporary state is erased before returning.

---

---

*Generated by vex-doc v2.0 • 2026-10-28*
