Expand description
Pure Rust cryptography, hardware-accelerated on ten architectures. no_std first.
rscrypto is a single-crate cryptography stack: hashes, AEADs, MACs, KDFs,
password hashing, signatures, key exchange, and checksums. Enable one leaf
feature for a minimal build (sha2, aes-gcm, ed25519, anything) or
full for the entire primitive set. Zero default dependencies; getrandom,
serde, and rayon are opt-in.
The portable Rust path is the byte-for-byte authority. SIMD and ASM kernels
are accelerators, differential-tested against the portable path on every
release. Three-tier dispatch (compile-time target_feature → runtime
detection → portable fallback) picks the fastest safe backend at runtime;
without std, only the compile-time tier runs.
[dependencies]
rscrypto = { version = "0.1", default-features = false, features = ["sha2"] }§Guides
- Repository README: https://github.com/loadingalias/rscrypto#readme
- Runnable examples: https://github.com/loadingalias/rscrypto/tree/main/examples
- Additional docs: https://github.com/loadingalias/rscrypto/tree/main/docs
- Security guidance: https://github.com/loadingalias/rscrypto/blob/main/docs/security.md
§API Shape
- Checksums:
Type::checksum(data)ornew/update/finalize. - Digests:
Type::digest(data)ornew/update/finalize. - XOFs:
Type::xof(data)ornew/update/finalize_xof. - MACs:
Type::mac(key, data)andType::verify_tag(key, data, tag). - AEADs: typed keys and nonces, with combined and detached APIs.
§Quick Start
use rscrypto::{Digest, Sha256};
let digest = Sha256::digest(b"hello world");
let mut h = Sha256::new();
h.update(b"hello ");
h.update(b"world");
assert_eq!(h.finalize(), digest);§AEAD
use rscrypto::{Aead, ChaCha20Poly1305, ChaCha20Poly1305Key, aead::Nonce96};
let key = ChaCha20Poly1305Key::from_bytes([0x11; 32]);
let nonce = Nonce96::from_bytes([0x22; Nonce96::LENGTH]);
let cipher = ChaCha20Poly1305::new(&key);
let mut buffer = *b"data";
let tag = cipher.encrypt_in_place(&nonce, b"aad", &mut buffer)?;
cipher.decrypt_in_place(&nonce, b"aad", &mut buffer, &tag)?;
assert_eq!(&buffer, b"data");§Password Hashing
use rscrypto::{Argon2Params, Argon2VerifyPolicy, Argon2id};
let params = Argon2Params::new().build()?;
let encoded = Argon2id::hash_string(¶ms, b"correct horse battery staple")?;
assert!(
Argon2id::verify_string_with_policy(
b"correct horse battery staple",
&encoded,
&Argon2VerifyPolicy::default(),
)
.is_ok()
);§Feature Groups
checksums: CRC families.hashes: SHA-2, SHA-3, BLAKE2, BLAKE3, Ascon, XXH3, RapidHash.auth: MACs, KDFs, password hashing, Ed25519, X25519.aead: AES-GCM, AES-GCM-SIV, ChaCha20-Poly1305, XChaCha20-Poly1305, AEGIS-256, Ascon-AEAD128.full: all public primitive families.
Leaf features are available for size-conscious builds.
§Security Posture
Constant-time MAC, AEAD, and signature verification with black_box
barriers. Opaque verification errors that leak no failure detail. Zeroize
on drop for every secret-bearing type. strict_* arithmetic on counters
and lengths; release builds keep overflow-checks = true. Continuous
libFuzzer with corpus replay in CI; Miri on the portable backends.
rscrypto is a primitives crate, not a FIPS 140-3 validated module. It
exposes FIPS-aligned primitives (AES-256-GCM, SHA-2, SHA-3 / SHAKE, HMAC,
KMAC, HKDF, PBKDF2) alongside non-FIPS ones. The portable-only feature
flag forces dispatch to the constant-time portable backend for FIPS /
DO-178C / ISO 26262 / IEC 62443 deployments. See the security guidance
for nonce lifecycle, PHC verification limits, and platform fallback notes.
Re-exports§
pub use aead::AeadBufferError;aeadpub use aead::OpenError;aeadpub use aead::Aegis256;aegis256pub use aead::Aegis256Key;aegis256pub use aead::Aegis256Tag;aegis256pub use aead::Aes256Gcm;aes-gcmpub use aead::Aes256GcmKey;aes-gcmpub use aead::Aes256GcmTag;aes-gcmpub use aead::Aes256GcmSiv;aes-gcm-sivpub use aead::Aes256GcmSivKey;aes-gcm-sivpub use aead::Aes256GcmSivTag;aes-gcm-sivpub use aead::AsconAead128;ascon-aeadpub use aead::AsconAead128Key;ascon-aeadpub use aead::AsconAead128Tag;ascon-aeadpub use aead::ChaCha20Poly1305;chacha20poly1305pub use aead::ChaCha20Poly1305Key;chacha20poly1305pub use aead::ChaCha20Poly1305Tag;chacha20poly1305pub use aead::XChaCha20Poly1305;xchacha20poly1305pub use aead::XChaCha20Poly1305Key;xchacha20poly1305pub use aead::XChaCha20Poly1305Tag;xchacha20poly1305pub use auth::HkdfOutputLengthError;hkdfpub use auth::Kmac256;kmacpub use auth::PhcError;phc-stringspub use auth::Argon2Error;argon2pub use auth::Argon2Params;argon2pub use auth::Argon2VerifyPolicy;argon2pub use auth::Argon2Version;argon2pub use auth::Argon2d;argon2pub use auth::Argon2i;argon2pub use auth::Argon2id;argon2pub use auth::Ed25519Keypair;ed25519pub use auth::Ed25519PublicKey;ed25519pub use auth::Ed25519SecretKey;ed25519pub use auth::Ed25519Signature;ed25519pub use auth::HkdfSha256;hkdfpub use auth::HkdfSha384;hkdfpub use auth::HmacSha256;hmacpub use auth::HmacSha384;hmacpub use auth::HmacSha512;hmacpub use auth::Pbkdf2Error;pbkdf2pub use auth::Pbkdf2Sha256;pbkdf2pub use auth::Pbkdf2Sha512;pbkdf2pub use auth::Scrypt;scryptpub use auth::ScryptError;scryptpub use auth::ScryptParams;scryptpub use auth::ScryptVerifyPolicy;scryptpub use auth::X25519Error;x25519pub use auth::X25519PublicKey;x25519pub use auth::X25519SecretKey;x25519pub use checksum::Crc24OpenPgp;crc24pub use checksum::Crc16Ccitt;crc16pub use checksum::Crc16Ibm;crc16pub use checksum::Crc32;crc32pub use checksum::Crc32C;crc32pub use checksum::Crc64;crc64pub use checksum::Crc64Nvme;crc64pub use hashes::crypto::ascon::AsconCxofCustomizationError;ascon-hashpub use hashes::crypto::AsconCxof128;ascon-hashpub use hashes::crypto::AsconCxof128Reader;ascon-hashpub use hashes::crypto::AsconHash256;ascon-hashpub use hashes::crypto::AsconXof;ascon-hashpub use hashes::crypto::AsconXofReader;ascon-hashpub use hashes::crypto::Blake2b;blake2bpub use hashes::crypto::Blake2b256;blake2bpub use hashes::crypto::Blake2b512;blake2bpub use hashes::crypto::Blake2bParams;blake2bpub use hashes::crypto::Blake2s128;blake2spub use hashes::crypto::Blake2s256;blake2spub use hashes::crypto::Blake2sParams;blake2spub use hashes::crypto::Blake3;blake3pub use hashes::crypto::Blake3XofReader;blake3pub use hashes::crypto::Cshake256;sha3pub use hashes::crypto::Cshake256XofReader;sha3pub use hashes::crypto::Sha3_224;sha3pub use hashes::crypto::Sha3_256;sha3pub use hashes::crypto::Sha3_384;sha3pub use hashes::crypto::Sha3_512;sha3pub use hashes::crypto::Shake128;sha3pub use hashes::crypto::Shake128XofReader;sha3pub use hashes::crypto::Shake256;sha3pub use hashes::crypto::Shake256XofReader;sha3pub use hashes::crypto::Sha224;sha2pub use hashes::crypto::Sha256;sha2pub use hashes::crypto::Sha384;sha2pub use hashes::crypto::Sha512;sha2pub use hashes::crypto::Sha512_256;sha2pub use hashes::fast::RapidBuildHasher;rapidhashandallocpub use hashes::fast::RapidHasher;rapidhashandallocpub use hashes::fast::RapidHash;rapidhashpub use hashes::fast::RapidHash128;rapidhashpub use hashes::fast::RapidHashFast64;rapidhashpub use hashes::fast::RapidHashFast128;rapidhashpub use hashes::fast::Xxh3;xxh3pub use hashes::fast::Xxh3_128;xxh3pub use hashes::fast::Xxh3BuildHasher;xxh3andallocpub use hashes::fast::Xxh3Hasher;xxh3andallocpub use traits::Aead;aes-gcmoraes-gcm-sivorchacha20poly1305orxchacha20poly1305oraegis256orascon-aeadpub use traits::Checksum;pub use traits::ChecksumCombine;pub use traits::ConstantTimeEq;pub use traits::Mac;pub use traits::VerificationError;pub use traits::ct;pub use traits::Digest;sha2orsha3orblake2borblake2sorblake3orascon-hashorxxh3orrapidhashpub use traits::FastHash;sha2orsha3orblake2borblake2sorblake3orascon-hashorxxh3orrapidhashpub use traits::Xof;sha2orsha3orblake2borblake2sorblake3orascon-hashorxxh3orrapidhash
Modules§
- aead
aes-gcmoraes-gcm-sivorchacha20poly1305orxchacha20poly1305oraegis256orascon-aead - Authenticated encryption with associated data foundations.
- auth
hmacorhkdforkmacored25519orx25519orphc-stringsorargon2orscrypt - Authentication and key-derivation primitives.
- checksum
crc16orcrc24orcrc32orcrc64 - High-performance CRC checksums.
- hashes
sha2orsha3orblake2borblake2sorblake3orascon-hashorxxh3orrapidhash - Cryptographic digests and fast non-cryptographic hashes.
- platform
- CPU detection and capability reporting.
- traits
- Core cryptographic traits for rscrypto.
Structs§
- Display
Secret aes-gcmoraes-gcm-sivorchacha20poly1305orxchacha20poly1305oraegis256orascon-aeadored25519orx25519 - Explicit opt-in wrapper for displaying secret key bytes as hex.
- Secret
Bytes - Owned secret bytes that zeroize on drop.
Enums§
- Invalid
HexError aes-gcmoraes-gcm-sivorchacha20poly1305orxchacha20poly1305oraegis256orascon-aeadored25519orx25519 - Hex decoding error.