[package]
name = "purecrypto"
version = "0.1.1"
edition = "2024"
rust-version = "1.95"
description = "A pure-Rust cryptography toolkit with no foreign-code dependencies, from constant-time primitives up to keys, X.509 and TLS."
repository = "https://github.com/KarpelesLab/purecrypto"
license = "MIT"
keywords = ["crypto", "cryptography", "no-std", "constant-time"]
categories = ["cryptography", "no-std::no-alloc"]

[lib]
name = "purecrypto"

[features]
# `std` is the convenient default; it implies `alloc`. Disable default
# features for a `no_std` build (`--no-default-features`), optionally
# re-enabling `alloc` for heap-backed types.
default = ["std", "hash", "cipher", "kdf", "bignum", "rng", "rsa", "der", "dh", "x509", "ec", "tls", "dtls", "mlkem", "mldsa", "slhdsa", "cli"]
std = ["alloc"]
alloc = []

# --- module gates (added as each layer lands) ---
hash = []
cipher = []
kdf = ["hash", "cipher"]
bignum = []
rng = ["hash"]
rsa = ["bignum", "rng", "hash"]
# Finite-field Diffie-Hellman over RFC 3526 MODP groups (group14..group18)
# plus RFC 4419 group-exchange. For SSH and legacy TLS / IKE interop;
# ECDH (in the `ec` module) is preferred for new code.
dh = ["bignum", "rng", "alloc"]
der = []
x509 = ["der", "rsa", "hash", "alloc", "ec"]
ec = ["bignum", "rng", "hash", "alloc"]
tls = ["cipher", "hash", "kdf", "ec", "rsa", "x509", "der", "rng", "mlkem", "alloc"]
# DTLS (RFC 6347 + RFC 9147). Builds on the `tls` stack — the record / replay /
# reassembly / cookie chassis lives in `src/dtls/`, with version-specific
# client and server state machines layered on top in later commits.
dtls = ["tls"]
# QUIC v1 (RFC 9000) — transport-layer protocol over UDP, secured by TLS 1.3
# keys (RFC 9001), with loss recovery + congestion control (RFC 9002) and the
# unreliable DATAGRAM extension (RFC 9221). Builds on the `tls` stack; sans-I/O.
# Requires `std` for `std::sync::Mutex` used in the TLS-engine ⇄ QuicConnection
# hook bridge (the trait `QuicHooks: Send` forbids `Rc<RefCell<…>>`).
quic = ["tls", "std"]
# ML-KEM-768 (FIPS 203). no_std + no-alloc core: only hashing (SHA-3/SHAKE) and
# the RNG trait are required.
mlkem = ["hash", "rng"]
# ML-DSA (FIPS 204) signatures. Needs alloc for the variable-width signature
# encoding; the polynomial arithmetic itself is on the stack.
mldsa = ["hash", "rng", "alloc"]
# SLH-DSA (FIPS 205) hash-based signatures. Needs alloc for the large
# signatures (up to ~50 KB); built purely from the hash primitives.
slhdsa = ["hash", "rng", "alloc"]
# C ABI: builds the `ffi` module (the only place `unsafe` is allowed). Build a
# C library with `cargo rustc --features ffi --crate-type cdylib` (or staticlib).
ffi = ["std", "hash", "rng", "rsa", "ec", "der", "x509", "tls", "dtls", "quic", "mldsa", "slhdsa", "mlkem", "kdf", "cipher"]
# The `purecrypto` command-line tool (gates the binary target below).
cli = ["std", "hash", "rng", "rsa", "ec", "der", "x509", "tls", "dtls", "quic", "kdf", "cipher"]

[[bin]]
name = "purecrypto"
path = "src/bin/purecrypto/main.rs"
required-features = ["cli"]

[lints.rust]
# Constant-time correctness depends on disciplined arithmetic; keep the
# foundation honest.
missing_docs = "warn"
unreachable_pub = "warn"
# Deny (not forbid) so a future `ffi`/SIMD module can opt back in locally
# with a scoped `#[allow(unsafe_code)]`; the core stays safe.
unsafe_code = "deny"

[profile.release]
# Crypto code benefits from aggressive inlining of the small primitive ops.
lto = "thin"
