crypto_async_rs/lib.rs
1//! # crypto-async-rs
2//!
3//! A high-performance, pure Rust cryptographic library providing both synchronous and asynchronous
4//! implementations of essential cryptographic primitives. This library focuses on streaming
5//! operations and async I/O for optimal performance in modern Rust applications.
6//!
7//! ## Features
8//!
9//! ### Core Cryptographic Algorithms
10//! - **AES-GCM** (128/192/256-bit) - Authenticated encryption with async streaming support
11//! - **ChaCha20-Poly1305** - High-performance AEAD cipher with async operations
12//! - **X25519 ECDH** - Elliptic curve Diffie-Hellman key exchange
13//! - **SHA Family** - SHA1, SHA224, SHA256, SHA384, SHA512 with async streaming
14//! - **HMAC** - Hash-based message authentication codes
15//! - **HKDF** - HMAC-based key derivation function
16//!
17//! ### Key Capabilities
18//! - ✅ **Async/Streaming Support** - Process large data without loading into memory
19//! - ✅ **High Performance** - Top 5-10% performance compared to industry standards
20//! - ✅ **Memory Safe** - Pure Rust implementation with secure memory handling
21//! - ✅ **Constant-Time Operations** - Resistant to timing attacks
22//! - ✅ **Comprehensive Benchmarks** - Detailed performance analysis and comparisons
23//! - ✅ **Production Ready** - Thoroughly tested with RFC compliance
24//!
25//! ## Quick Start
26//!
27//! Add to your `Cargo.toml`:
28//!
29//! ```toml
30//! [dependencies]
31//! crypto-async-rs = "0.1.1"
32//! tokio = { version = "1.0", features = ["full"] }
33//! ```
34//!
35//! ## Example Usage
36//!
37//! ```rust
38//! use crypto_async_rs::ecdh_x25519::{x25519, U_COORDINATE};
39//!
40//! fn main() -> Result<(), crypto_async_rs::ecdh_x25519::X25519Error> {
41//! // Example private keys (in practice, use secure random generation)
42//! let alice_private = [
43//! 0x77, 0x07, 0x6d, 0x0a, 0x73, 0x18, 0xa5, 0x7d, 0x3c, 0x16, 0xc1, 0x72, 0x51, 0xb2, 0x66, 0x45,
44//! 0xdf, 0x4c, 0x2f, 0x87, 0xeb, 0xc0, 0x99, 0x2a, 0xb1, 0x77, 0xfb, 0xa5, 0x1d, 0xb9, 0x2c, 0x2a,
45//! ];
46//! let bob_private = [
47//! 0x5d, 0xab, 0x08, 0x7e, 0x62, 0x4a, 0x8a, 0x4b, 0x79, 0xe1, 0x7f, 0x8b, 0x83, 0x80, 0x0e, 0xe6,
48//! 0x6f, 0x3b, 0xb1, 0x29, 0x26, 0x18, 0xb6, 0xfd, 0x1c, 0x2f, 0x8b, 0x27, 0xff, 0x88, 0xe0, 0xeb,
49//! ];
50//!
51//! // Compute public keys
52//! let alice_public = x25519(alice_private, U_COORDINATE)?;
53//! let bob_public = x25519(bob_private, U_COORDINATE)?;
54//!
55//! // Perform key exchange
56//! let alice_shared = x25519(alice_private, bob_public)?;
57//! let bob_shared = x25519(bob_private, alice_public)?;
58//!
59//! // Both parties now have the same shared secret
60//! assert_eq!(alice_shared, bob_shared);
61//!
62//! println!("Key exchange successful!");
63//! Ok(())
64//! }
65//! ```
66//!
67//! ## Performance
68//!
69//! This library achieves **top 5-10% performance** compared to industry-standard cryptographic libraries:
70//!
71//! - **ChaCha20-Poly1305**: ~359 MiB/s (64KB data)
72//! - **AES-256-GCM**: ~253 MiB/s (64KB data)
73//! - **X25519 ECDH**: 4,070 ops/sec
74//! - **SHA512**: ~393 MiB/s (64KB data)
75//!
76//! For detailed performance analysis, see the comprehensive benchmark documentation in the `benches/` directory.
77//!
78//! ## Security
79//!
80//! - **Constant-Time Operations**: Resistant to timing attacks
81//! - **Secure Memory Handling**: Automatic zeroing of sensitive data
82//! - **Input Validation**: Comprehensive error handling and validation
83//! - **RFC Compliance**: Implements standard algorithms per RFC specifications
84//!
85//! ## License
86//!
87//! This project is licensed under the MIT License - see the LICENSE file for details.
88
89pub mod aes;
90pub mod aes_gcm;
91pub mod aes_gcm_async;
92pub mod cha_cha_poly;
93pub mod cha_cha_poly_async;
94pub mod ecdh_x25519;
95pub mod hkdf;
96pub mod hmac;
97pub mod sha1;
98pub mod sha224;
99pub mod sha256;
100pub mod sha384;
101pub mod sha512;