← Back to section · Tutorials & Labs
The RustCrypto Ecosystem: Modular Crates and How to Choose
RustCrypto is not a single library but a family of modular crates built on traits. This article maps its repositories, lays out the selection dimensions that matter — pure Rust versus FFI bindings, audit status, no_std support — and shows where post-quantum algorithms sit in the landscape.
First, a Correction: RustCrypto Is Not a Library
Many newcomers search crates.io for “RustCrypto” expecting one big library that does everything, and instead find dozens of similarly named small crates: sha2, aes-gcm, chacha20poly1305, hkdf, ed25519-dalek… This is not fragmentation; it is deliberate design. RustCrypto is an open-source organization maintaining a modular system built on traits: independent trait crates define uniform interfaces first, and each algorithm implementation then implements those interfaces. Understanding this map is the first step in making sound cryptography choices in Rust.
The Map: Four Layers of Repositories
The first layer is the trait layer. digest defines a uniform interface for hash functions, aead for authenticated encryption with associated data, cipher for block and stream ciphers, and mac, signature, kem likewise. Your application code should depend on this layer: write against Digest, Aead, Kem, and swapping the underlying algorithm later barely touches the upper logic.
The second layer is algorithm implementations, one crate per algorithm: sha2 provides SHA-256/512, sha3 provides SHA-3 and SHAKE, aes-gcm and chacha20poly1305 provide AEAD, hkdf and pbkdf2 provide key derivation, and rsa, ecdsa, ed25519-dalek provide signatures. All implement the first layer’s traits, so they can be substituted and combined freely.
The third layer is formats, maintained in the RustCrypto/formats repository: pkcs8 handles PKCS#8 private-key encoding, sec1 handles elliptic-curve key formats, x509-cert handles certificate structures, and der and pem handle the underlying encodings. In real systems, most key and certificate interoperability problems live in this layer, not the algorithm layer.
The fourth layer is the neighboring protocol and application ecosystem: rustls (a TLS implementation) consumes the lower layers, and tools such as age are built on the same trait foundation. When selecting, remember that you are choosing not just an algorithm crate but its compatibility with the layers above and below it.
Five Selection Dimensions
Dimension one: pure Rust or FFI binding. RustCrypto’s mainstream implementations are pure Rust, which means simple cross-platform builds, no C toolchain dependency, and a clear memory-safety boundary. Binding crates (such as oqs and the pqcrypto family, covered later in this subcategory) win on algorithm coverage and battle-tested upstreams, at the cost of more complex builds and a larger audit surface. For prototypes, coverage can come first; for production systems, weigh carefully.
Dimension two: audit and maintenance status. Check three things: whether there is a public security audit report (several core RustCrypto crates have received audits funded through channels such as OSTIF), whether releases are active, and whether maintainers respond to security issues. When a cryptography crate stops being maintained, the risk is not missing features — it is known problems nobody fixes.
Dimension three: no_std support. Many RustCrypto crates advertise no_std support, meaning they can run in embedded and kernel environments without the standard library. But note the fine print: support often still requires alloc (heap allocation), or requires you to supply a randomness source or time source. Read the feature list item by item when selecting.
Dimension four: constant-time implementation. Serious cryptographic implementations must avoid secret-dependent branches and memory accesses. The RustCrypto ecosystem generally builds on the constant-time primitives of the subtle crate (covered in its own article in this subcategory), but this is not an automatic guarantee: check whether the crate’s documentation explicitly states constant-time behavior and whether there are known exceptions, such as certain signature-verification paths.
Dimension five: version and documentation quality. Major version bumps of trait-layer crates change interfaces (the digest interface, for example, has changed across versions), so pinning versions and reading migration guides is routine. Whether the documentation states safe-usage guidance and the algorithm’s applicability limits is an important signal of a crate’s maturity.
Where Post-Quantum Algorithms Sit on This Map
The RustCrypto organization maintains a dedicated KEMs repository, whose ml-kem crate is a pure-Rust implementation of FIPS 203 (ML-KEM) built on the kem trait; this subcategory has a hands-on tutorial for it. On the signature side, an ml-dsa crate for FIPS 204 is progressing within the same system. Beyond that, the ecosystem offers independent implementations for cross-checking: fips203, maintained by Integrity Chain (another pure-Rust ML-KEM implementation), and libcrux-ml-kem, maintained by Cryspen along a formal-verification route. Multiple independent implementations are a good thing: they can serve as test vectors and behavioral references for each other, which is exactly the basis for the interoperability testing discussed later.
A Worked Selection Example
Let us put the five dimensions to work on a concrete scenario. Suppose you are prototyping a hybrid key exchange for an internal service: ML-KEM-768 and X25519 negotiate in parallel, session keys are derived via HKDF, and long-term keys are stored on disk in PKCS#8 format. Walk the map layer by layer: at the KEM layer, define the interface with the kem trait and choose RustCrypto’s ml-kem as the implementation (pure Rust, no_std friendly); for the classical side, rather than hand-rolling ECDH, hand it to rustls with the aws-lc-rs backend (see the ring and rustls article); at the derivation layer choose hkdf and sha2, both implementing uniform traits and cheap to replace; at the storage layer use the formats repository’s pkcs8 for encoding, together with zeroize to manage private keys in memory (see the zeroize article). Every crate in this combination is pure Rust, actively maintained, and interfaced at the trait layer. If you later want to test against an independent implementation such as fips203, the change is confined to the assembly layer, because your application code faces the kem trait — that is the payoff of the modular map.
One more thing to watch in the walkthrough: version alignment. Trait-layer and implementation-layer versions must match (for example, the major version of kem versus the version ml-kem depends on). Cargo’s dependency resolution handles most of this, but when crossing major versions, read each crate’s changelog, especially entries touching key formats and serialization compatibility.
Another frequently underestimated dimension is community and documentation language: RustCrypto documentation generally states each implementation’s security claims, known non-constant-time exceptions, and the provenance of its test vectors. This habit of putting the caveats up front is itself a sign of maturity. Conversely, if a cryptography crate’s documentation shows only usage examples and says nothing about security boundaries, treat it as unaudited no matter how many downloads it has. Also note whether a crate provides official example projects and CI badges: examples that still run mean the maintainers are actually maintaining it; stale examples are often the first sign of a project going dormant. These soft signals, combined with the five hard dimensions above, make a complete selection judgment.
Turning Selection into a Sustainable Process
A final reminder: selection is not a one-time act. Algorithm crates ship security fixes, trait interfaces evolve, and your dependency tree changes. Commit Cargo.lock to version control and wire cargo audit into CI (this subcategory has a dedicated article on supply-chain hygiene), so that today’s selection conclusions still hold a year from now. Build map awareness first, then argue about individual crates — that is the order this article hopes you take away.
Tags: RustRustCryptoSelectionEcosystem