๐ฆ CrabGraph
A safe, ergonomic, and high-performance cryptographic library for Rust, built on top of audited primitives from the RustCrypto ecosystem and other trusted sources.
โ ๏ธ Security Notice
This library is NOT yet audited by third-party cryptographic experts. While it uses audited primitives (RustCrypto, dalek-cryptography), mistakes in composition can still lead to vulnerabilities. DO NOT use in production without a professional security audit.
Note: The optional rsa-support feature has a known vulnerability (RUSTSEC-2023-0071 - Marvin timing attack). Use Ed25519/X25519 instead.
For security issues, please see SECURITY.md.
โจ Features
- ๐ Authenticated Encryption (AEAD): AES-GCM, ChaCha20-Poly1305
- ๐ Key Derivation: PBKDF2, Argon2, HKDF
- โ๏ธ Digital Signatures: Ed25519
- ๐ค Key Exchange: X25519 (Elliptic Curve Diffie-Hellman)
- ๐ Message Authentication: HMAC (SHA-256, SHA-512)
- #๏ธโฃ Hashing: SHA-256, SHA-512, (optional: SHA-3, BLAKE2)
- ๐ฒ Secure Random: Cryptographically secure RNG wrapper
- ๐งน Memory Safety: Automatic zeroization of sensitive data
- ๐ Interoperability: Helpers for CryptoJS compatibility
- ๐ Performance: Zero-copy operations, hardware acceleration support
- ๐ฆ No-std Support: Core functionality available in embedded contexts
๐ Quick Start
Add to your Cargo.toml:
[]
= "0.1"
Authenticated Encryption (AES-GCM)
use ;
Key Derivation (Argon2)
use ;
Digital Signatures (Ed25519)
use ;
HMAC Authentication
use ;
๐ Documentation
๐๏ธ Architecture
CrabGraph is built on these audited cryptographic libraries:
- RustCrypto:
aes-gcm,chacha20poly1305,sha2,hmac,pbkdf2,hkdf - dalek-cryptography:
ed25519-dalek,x25519-dalek - Argon2: Official Rust bindings to the Argon2 reference implementation
๐ฏ Design Principles
- Safe by Default: AEAD modes, proper nonce handling, automatic secret zeroization
- No Footguns: High-level API hides complexity; low-level access requires opt-in
- Audited Primitives: Never implements crypto from scratch
- Performance: Zero-copy, hardware acceleration, minimal allocations
- Ergonomic: Builder patterns, clear error messages, comprehensive docs
- Interoperable: Helpers for common JS library compatibility
๐งช Testing & Quality
# Run all tests
# Run benchmarks
# Run fuzzing (requires cargo-fuzz)
# Security audit
๐ง Feature Flags
default: Enablesstdsupportstd: Standard library support (enabled by default)alloc: Allocation support without full stdno_std: Embedded/bare-metal supportextended-hashes: SHA-3 and BLAKE2 supportrsa-support: RSA encryption/signatures (large dependency)serde-support: Serialization for keys and ciphertextszero-copy:bytescrate integration for high-performance scenarioswasm: WebAssembly support
๐ค Contributing
Contributions are welcome! Please read CONTRIBUTING.md and our Code of Conduct.
๐ License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
๐ Acknowledgments
Built on the shoulders of giants:
- RustCrypto team
- dalek-cryptography contributors
- Argon2 reference implementation authors
โ ๏ธ Disclaimer
This software is provided "as is", without warranty of any kind. See LICENSE files for details.
IMPORTANT: Cryptography is hard. This library has not undergone a formal security audit. Use at your own risk, especially in production environments. Always consult with security professionals for critical applications.