Skip to main content

Crate tessera

Crate tessera 

Source
Expand description

krypteia-tessera — shared pure-Rust hash primitives for the krypteia workspace.

One home for every hash, XOF, keyed construction, KDF and checksum the workspace needs — SHA-2, SHA-3 / Keccak, the SHAKE / cSHAKE XOFs, MGF1, the legacy/alt family (SHA-1, RIPEMD-160, BLAKE2b/2s, BLAKE3), HMAC, the SP 800-185 keyed constructions (KMAC, TupleHash, ParallelHash), the KDF family (HKDF, PBKDF2, SP 800-108, scrypt, Argon2) and the non-cryptographic CRC-16/32 checksums — so that quantica (post-quantum) and arcana (classical) stop carrying their own copies. The granularity (one crate rather than per-family) follows the survey of the Rust crypto ecosystem recorded for v0.2.

no_std, no runtime dependencies. Constant-timeness is not a goal of the hash compression functions themselves (their inputs are public data); secret-dependent comparison/zeroization stays in silentops. The memory-hard KDFs process a secret password and are not constant-time: scrypt (ROMix) and Argon2d/Argon2id use data-dependent memory addressing driven by the password (Argon2i is the data-independent variant). This is inherent to the constructions and documented by design, not a defect; see each module’s # Side-channel posture.

§Roadmap (this crate is built in stages)

  1. traits (Digest, Xof) — done.
  2. SHA-3: Keccak-f, SHA3-224/256/384/512, SHAKE128/256, cSHAKE — done.
  3. SHA-2: SHA-224/256/384/512/512-224/512-256, MGF1 — done.
  4. legacy/alt family: SHA-1, RIPEMD-160, BLAKE2b/2s, BLAKE3 — done.
  5. quantica migrates onto this crate for Keccak (hot path; benchmarked).
  6. arcana migrates onto this crate for SHA-2/SHA-3 and the legacy family.
  7. keyed constructions: HMAC, the SP 800-185 family (KMAC, TupleHash, ParallelHash) — done.
  8. KDF family: HKDF, PBKDF2, SP 800-108 (KBKDF) and the memory-hard scrypt / Argon2 password hashes — done.
  9. non-cryptographic CRC-16/32 checksums (no Digest impl) — done.

Re-exports§

pub use argon2::argon2;
pub use blake2::Blake2b;
pub use blake2::Blake2s;
pub use blake3::Blake3;
pub use blake3::derive_key;
pub use blake3::hash as blake3_hash;
pub use blake3::keyed_hash;
pub use crc::Crc16;
pub use crc::Crc16Algorithm;
pub use crc::Crc32;
pub use crc::Crc32Algorithm;
pub use hmac::hmac;
pub use hmac::hmac_multi;
pub use mgf1::mgf1;
pub use pbkdf2::pbkdf2;
pub use ripemd160::Ripemd160;
pub use scrypt::scrypt;
pub use sha1::Sha1;
pub use sha2::Sha224;
pub use sha2::Sha256;
pub use sha2::Sha384;
pub use sha2::Sha512;
pub use sha2::Sha512_224;
pub use sha2::Sha512_256;
pub use sha3::CShake128;
pub use sha3::CShake256;
pub use sha3::Sha3_224;
pub use sha3::Sha3_256;
pub use sha3::Sha3_384;
pub use sha3::Sha3_512;
pub use sha3::Shake128;
pub use sha3::Shake256;
pub use sp800_185::kmac128;
pub use sp800_185::kmac128_xof;
pub use sp800_185::kmac256;
pub use sp800_185::kmac256_xof;
pub use sp800_185::parallelhash128;
pub use sp800_185::parallelhash128_xof;
pub use sp800_185::parallelhash256;
pub use sp800_185::parallelhash256_xof;
pub use sp800_185::tuplehash128;
pub use sp800_185::tuplehash128_xof;
pub use sp800_185::tuplehash256;
pub use sp800_185::tuplehash256_xof;
pub use traits::Digest;
pub use traits::Xof;

Modules§

argon2
Argon2 — memory-hard password hashing (RFC 9106 / PHC winner).
blake2
BLAKE2b and BLAKE2s hash functions (RFC 7693).
blake3
BLAKE3 cryptographic hash / XOF (BLAKE3 spec, 2020-01-09; reference blake3.py / reference_impl.rs from the BLAKE3 team).
crc
CRC-16 / CRC-32 cyclic redundancy checks (error-detection codes).
hkdf
HKDF — HMAC-based Extract-and-Expand Key Derivation Function (RFC 5869).
hmac
HMAC — keyed-hash message authentication code (FIPS 198-1 / RFC 2104).
mgf1
MGF1 mask generation function (PKCS#1 v2.2 / RFC 8017 §B.2.1).
pbkdf2
PBKDF2 — Password-Based Key Derivation Function 2 (RFC 2898 / PKCS#5 v2.1, NIST SP 800-132).
ripemd160
RIPEMD-160 (ISO/IEC 10118-3). 160-bit output, 512-bit (64-byte) blocks. Two parallel computation lines (left and right), each five rounds of sixteen operations. Best known today as the second hash in Bitcoin address derivation (RIPEMD-160(SHA-256(pk))).
scrypt
scrypt — memory-hard password-based key derivation (RFC 7914 / Percival 2009).
sha1
SHA-1 (FIPS 180-4) — collision-broken (SHAttered 2017), kept for legacy interop only (HMAC-SHA-1 in old TLS, early X.509, Git storage). Do not use for new signature designs.
sha2
SHA-2 family (FIPS 180-4): SHA-224/256 (32-bit core) and SHA-384/512/512-224/512-256 (64-bit core), behind the Digest trait.
sha3
SHA-3 and SHAKE (FIPS 202) over the Keccak-f[1600] sponge.
sp800_108
SP 800-108 — key-based key derivation functions (KBKDF), NIST SP 800-108r1.
sp800_185
Keyed and derived hash functions from NIST SP 800-185: KMAC, TupleHash and ParallelHash (and their XOF variants).
traits
Minimal hash traits for the krypteia workspace.