Skip to main content

tessera/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Cédric Mesnil <cslashm@pm.me>
3
4//! `krypteia-tessera` — shared pure-Rust hash primitives for the krypteia
5//! workspace.
6//!
7//! One home for every hash, XOF, keyed construction, KDF and checksum the
8//! workspace needs — SHA-2, SHA-3 / Keccak, the SHAKE / cSHAKE XOFs, MGF1,
9//! the legacy/alt family (SHA-1, RIPEMD-160, BLAKE2b/2s, BLAKE3), HMAC, the
10//! SP 800-185 keyed constructions (KMAC, TupleHash, ParallelHash), the KDF
11//! family (HKDF, PBKDF2, SP 800-108, scrypt, Argon2) and the
12//! non-cryptographic CRC-16/32 checksums — so that `quantica` (post-quantum)
13//! and `arcana` (classical) stop carrying their own copies. The granularity
14//! (one crate rather than per-family) follows the survey of the Rust
15//! crypto ecosystem recorded for v0.2.
16//!
17//! `no_std`, no runtime dependencies. Constant-timeness is **not** a goal
18//! of the hash compression functions themselves (their inputs are public
19//! data); secret-dependent comparison/zeroization stays in `silentops`. The
20//! memory-hard KDFs process a **secret** password and are **not**
21//! constant-time: scrypt (ROMix) and Argon2d/Argon2id use **data-dependent**
22//! memory addressing driven by the password (Argon2i is the data-independent
23//! variant). This is inherent to the constructions and documented by design,
24//! not a defect; see each module's `# Side-channel posture`.
25//!
26//! # Roadmap (this crate is built in stages)
27//!
28//! 1. traits ([`Digest`], [`Xof`]) — done.
29//! 2. SHA-3: Keccak-f, SHA3-224/256/384/512, SHAKE128/256, cSHAKE — done.
30//! 3. SHA-2: SHA-224/256/384/512/512-224/512-256, MGF1 — done.
31//! 4. legacy/alt family: SHA-1, RIPEMD-160, BLAKE2b/2s, BLAKE3 — done.
32//! 5. quantica migrates onto this crate for Keccak (hot path; benchmarked).
33//! 6. arcana migrates onto this crate for SHA-2/SHA-3 and the legacy family.
34//! 7. keyed constructions: HMAC, the SP 800-185 family (KMAC, TupleHash,
35//!    ParallelHash) — done.
36//! 8. KDF family: HKDF, PBKDF2, SP 800-108 (KBKDF) and the memory-hard
37//!    scrypt / Argon2 password hashes — done.
38//! 9. non-cryptographic CRC-16/32 checksums (no `Digest` impl) — done.
39
40#![no_std]
41
42extern crate alloc;
43
44pub mod argon2;
45pub mod blake2;
46pub mod blake3;
47pub mod crc;
48pub mod hkdf;
49pub mod hmac;
50pub mod mgf1;
51pub mod pbkdf2;
52pub mod ripemd160;
53pub mod scrypt;
54pub mod sha1;
55pub mod sha2;
56pub mod sha3;
57pub mod sp800_108;
58pub mod sp800_185;
59pub mod traits;
60
61pub use argon2::argon2;
62pub use blake2::{Blake2b, Blake2s};
63pub use blake3::{Blake3, derive_key, hash as blake3_hash, keyed_hash};
64// CRC engines + algorithm types. The named parameter-set consts stay under
65// `crc::` (e.g. `crc::CRC32_ISO_HDLC`) to keep the crate root uncluttered.
66// CRC is a non-cryptographic checksum and deliberately does not impl `Digest`.
67pub use crc::{Crc16, Crc16Algorithm, Crc32, Crc32Algorithm};
68pub use hmac::{hmac, hmac_multi};
69pub use mgf1::mgf1;
70// PBKDF2 as a root free fn (mirrors `mgf1`); HKDF's extract/expand/derive stay
71// under `hkdf::` because those names are too generic for the crate root.
72pub use pbkdf2::pbkdf2;
73pub use ripemd160::Ripemd160;
74pub use scrypt::scrypt;
75pub use sha1::Sha1;
76pub use sha2::{Sha224, Sha256, Sha384, Sha512, Sha512_224, Sha512_256};
77pub use sha3::{CShake128, CShake256, Sha3_224, Sha3_256, Sha3_384, Sha3_512, Shake128, Shake256};
78pub use sp800_185::{
79    kmac128, kmac128_xof, kmac256, kmac256_xof, parallelhash128, parallelhash128_xof, parallelhash256,
80    parallelhash256_xof, tuplehash128, tuplehash128_xof, tuplehash256, tuplehash256_xof,
81};
82pub use traits::{Digest, Xof};