[package]
name = "crypt-io"
version = "1.0.0"
edition = "2024"
rust-version = "1.85"
readme = "README.md"
license = "Apache-2.0 OR MIT"

authors = [
    "James Gober <me@jamesgober.com>"
]

description = "AEAD encryption (ChaCha20-Poly1305, AES-256-GCM), hashing (BLAKE3, SHA-2), MAC (HMAC, BLAKE3 keyed), and KDF (HKDF, Argon2id) for Rust. Algorithm-agile. RustCrypto-backed primitives with REPS discipline. Simple API. Sub-microsecond throughput."

# 5 keywords for search optimization
keywords = [
    "encryption",
    "cryptography",
    "ciphers",
    "crypto",
    "hash"
]

# 5 categories for discoverability
categories = [
    "cryptography",
    "authentication",
    "algorithms",
    "encoding",
    "data-structures"
]

documentation = "https://docs.rs/crypt-io"
repository    = "https://github.com/jamesgober/crypt-io"
homepage      = "https://github.com/jamesgober/crypt-io"

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[lib]
name = "crypt_io"
path = "src/lib.rs"

[features]
# Defaults: ChaCha20-Poly1305 + AES-256-GCM (AEAD) + BLAKE3 + SHA-2
# (hashing) + HMAC + BLAKE3 keyed (MAC) + HKDF + Argon2id (KDF).
# Gives a fresh `cargo add crypt-io` the full symmetric-crypto + KDF
# toolkit out of the box.
default = ["std", "zeroize", "aead-chacha20", "aead-aes-gcm", "hash-blake3", "hash-sha2", "mac-hmac", "mac-blake3", "kdf-hkdf", "kdf-argon2", "stream"]

# Core
std = []                              # Standard library (default on)
zeroize = ["dep:zeroize"]             # Zero key buffers on drop (default on)

# AEAD encryption algorithms
aead-chacha20 = ["dep:chacha20poly1305"]  # ChaCha20-Poly1305 (default)
aead-aes-gcm = ["dep:aes-gcm"]            # AES-256-GCM (hw-accel)
aead-all = ["aead-chacha20", "aead-aes-gcm"]

# Hashing algorithms
hash-blake3 = ["dep:blake3"]          # BLAKE3 (default - fastest; 32-byte + XOF)
hash-sha2 = ["dep:sha2"]              # SHA-256, SHA-512 (interop)
hash-all = ["hash-blake3", "hash-sha2"]

# MAC (Message Authentication Code)
mac-hmac = ["dep:hmac", "hash-sha2"]  # HMAC-SHA256, HMAC-SHA512
mac-blake3 = ["hash-blake3"]          # BLAKE3 keyed mode
mac-all = ["mac-hmac", "mac-blake3"]

# KDF (Key Derivation Functions)
kdf-hkdf = ["dep:hkdf", "hash-sha2"]  # HKDF (key derivation)
kdf-argon2 = ["dep:argon2"]           # Argon2id (password hashing)
kdf-all = ["kdf-hkdf", "kdf-argon2"]

# Stream/file encryption (chunked AEAD with STREAM-construction).
# Pulls both AEAD backends so callers can pick either at runtime.
stream = ["aead-chacha20", "aead-aes-gcm"]

# Quality-of-life
metrics = ["dep:metrics-lib"]         # Performance instrumentation
logging = ["dep:log-io"]              # Operation logging
async-trait = ["dep:async-trait"]     # Async API surface

# Convenience presets
preset-all = ["std", "zeroize", "aead-all", "hash-all", "mac-all", "kdf-all", "stream"]
preset-minimal = ["std", "aead-chacha20"]

[dependencies]
# Cryptographic primitives (RustCrypto + BLAKE3)
chacha20poly1305 = { version = "0.10", optional = true }
aes-gcm = { version = "0.10", optional = true }
blake3 = { version = "1", optional = true }
sha2 = { version = "0.10", optional = true }
hmac = { version = "0.12", optional = true }
hkdf = { version = "0.12", optional = true }
argon2 = { version = "0.5", optional = true }

# Portfolio dependencies
mod-rand = { version = "1" }          # CSPRNG for nonces, salts, IVs
error-forge = { version = "1" }       # Error handling
log-io = { version = "1", optional = true }
metrics-lib = { version = "1", optional = true }

# Optional secret zeroing
zeroize = { version = "1.7", optional = true, features = ["derive"] }

# Optional async support
async-trait = { version = "0.1", optional = true }

[dev-dependencies]
criterion = { version = "0.5", features = ["html_reports"] }
proptest = "1"
hex = "0.4"
# Portfolio heap profiler — drives `examples/profile_alloc.rs`.
# Lower MSRV than `dhat`, ~60 ns/op overhead, dhat-compatible JSON
# output. Only pulled in for the example binary.
mod-alloc = "1"

[[example]]
name = "profile_alloc"

[[bench]]
name = "aead"
harness = false

[[bench]]
name = "hash"
harness = false

[[bench]]
name = "mac"
harness = false

[[bench]]
name = "kdf"
harness = false

[[bench]]
name = "stream"
harness = false

[profile.release]
opt-level = 3
lto = "fat"
codegen-units = 1
strip = "symbols"

[profile.bench]
opt-level = 3
lto = "fat"
codegen-units = 1
debug = true