Expand description
§crypto-async-rs
A high-performance, pure Rust cryptographic library providing both synchronous and asynchronous implementations of essential cryptographic primitives. This library focuses on streaming operations and async I/O for optimal performance in modern Rust applications.
§Features
§Core Cryptographic Algorithms
- AES-GCM (128/192/256-bit) - Authenticated encryption with async streaming support
- ChaCha20-Poly1305 - High-performance AEAD cipher with async operations
- X25519 ECDH - Elliptic curve Diffie-Hellman key exchange
- SHA Family - SHA1, SHA224, SHA256, SHA384, SHA512 with async streaming
- HMAC - Hash-based message authentication codes
- HKDF - HMAC-based key derivation function
§Key Capabilities
- ✅ Async/Streaming Support - Process large data without loading into memory
- ✅ High Performance - Top 5-10% performance compared to industry standards
- ✅ Memory Safe - Pure Rust implementation with secure memory handling
- ✅ Constant-Time Operations - Resistant to timing attacks
- ✅ Comprehensive Benchmarks - Detailed performance analysis and comparisons
- ✅ Production Ready - Thoroughly tested with RFC compliance
§Quick Start
Add to your Cargo.toml:
[dependencies]
crypto-async-rs = "0.1.1"
tokio = { version = "1.0", features = ["full"] }§Example Usage
use crypto_async_rs::ecdh_x25519::{x25519, U_COORDINATE};
fn main() -> Result<(), crypto_async_rs::ecdh_x25519::X25519Error> {
// Example private keys (in practice, use secure random generation)
let alice_private = [
0x77, 0x07, 0x6d, 0x0a, 0x73, 0x18, 0xa5, 0x7d, 0x3c, 0x16, 0xc1, 0x72, 0x51, 0xb2, 0x66, 0x45,
0xdf, 0x4c, 0x2f, 0x87, 0xeb, 0xc0, 0x99, 0x2a, 0xb1, 0x77, 0xfb, 0xa5, 0x1d, 0xb9, 0x2c, 0x2a,
];
let bob_private = [
0x5d, 0xab, 0x08, 0x7e, 0x62, 0x4a, 0x8a, 0x4b, 0x79, 0xe1, 0x7f, 0x8b, 0x83, 0x80, 0x0e, 0xe6,
0x6f, 0x3b, 0xb1, 0x29, 0x26, 0x18, 0xb6, 0xfd, 0x1c, 0x2f, 0x8b, 0x27, 0xff, 0x88, 0xe0, 0xeb,
];
// Compute public keys
let alice_public = x25519(alice_private, U_COORDINATE)?;
let bob_public = x25519(bob_private, U_COORDINATE)?;
// Perform key exchange
let alice_shared = x25519(alice_private, bob_public)?;
let bob_shared = x25519(bob_private, alice_public)?;
// Both parties now have the same shared secret
assert_eq!(alice_shared, bob_shared);
println!("Key exchange successful!");
Ok(())
}§Performance
This library achieves top 5-10% performance compared to industry-standard cryptographic libraries:
- ChaCha20-Poly1305: ~359 MiB/s (64KB data)
- AES-256-GCM: ~253 MiB/s (64KB data)
- X25519 ECDH: 4,070 ops/sec
- SHA512: ~393 MiB/s (64KB data)
For detailed performance analysis, see the comprehensive benchmark documentation in the benches/ directory.
§Security
- Constant-Time Operations: Resistant to timing attacks
- Secure Memory Handling: Automatic zeroing of sensitive data
- Input Validation: Comprehensive error handling and validation
- RFC Compliance: Implements standard algorithms per RFC specifications
§License
This project is licensed under the MIT License - see the LICENSE file for details.
Modules§
- aes
- aes_gcm
- aes_
gcm_ async - cha_
cha_ poly - cha_
cha_ poly_ async - ecdh_
x25519 - X25519 Elliptic Curve Diffie-Hellman Key Exchange
- hkdf
- HKDF (HMAC-based Key Derivation Function)
- hmac
- HMAC (Hash-based Message Authentication Code)
- sha1
- sha224
- sha256
- sha384
- sha512