Skip to content

Commit de18cd3

Browse files
authored
Merge pull request #8 from AriajSarkar/feature/tls-provider
feat(tls): implement rustls CryptoProvider
2 parents ac9fe54 + 3d63462 commit de18cd3

21 files changed

Lines changed: 5527 additions & 9 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ fuzz/artifacts/
1818
*~
1919
.DS_Store
2020
copilot-instructions.md
21+
prompts/
22+
.agent/
2123

2224
# Testing
2325
*.profraw

CHANGELOG.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,62 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.4.0-pre] - 2026-02-05
11+
12+
### Added
13+
- **TLS CryptoProvider** - Enterprise-grade `rustls::crypto::CryptoProvider` implementation
14+
- Enables crabgraph as the TLS crypto backend for reqwest, hyper-rustls, tokio-rustls, etc.
15+
- Eliminates need for external crypto backends (ring/aws-lc-rs)
16+
- Feature flag: `tls` or `rustls-provider`
17+
18+
- **TLS 1.3 Cipher Suites**:
19+
- `TLS13_AES_256_GCM_SHA384`
20+
- `TLS13_CHACHA20_POLY1305_SHA256`
21+
- `TLS13_AES_128_GCM_SHA256`
22+
23+
- **TLS 1.2 Cipher Suites**:
24+
- `TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384`
25+
- `TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256`
26+
- `TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256`
27+
- `TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384`
28+
- `TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256`
29+
- `TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256`
30+
31+
- **Key Exchange Groups**: X25519, P-256 (secp256r1), P-384 (secp384r1)
32+
33+
- **P-256 (secp256r1) Support** - NIST curve implementation (`tls` feature)
34+
- `P256KeyPair` - ECDH key exchange
35+
- `P256SigningKey` / `P256VerifyingKey` - ECDSA signatures
36+
- PKCS#8/SEC1 key import/export
37+
38+
- **P-384 (secp384r1) Support** - NIST curve implementation (`tls` feature)
39+
- `P384KeyPair` - ECDH key exchange
40+
- `P384SigningKey` / `P384VerifyingKey` - ECDSA signatures
41+
- PKCS#8/SEC1 key import/export
42+
43+
- **SHA-384 Hash Function** - Required for TLS cipher suites
44+
- `sha384()` and `sha384_hex()` functions
45+
- Enabled with `tls` feature
46+
47+
- **TLS Module** (`src/tls/`) - Complete rustls integration
48+
- `tls::provider()` - Get the CryptoProvider
49+
- `tls::install_default()` - Install as global default
50+
- AEAD encryption for TLS records
51+
- Session ticketer with AES-256-GCM
52+
- Signature verification for WebPKI
53+
54+
### Changed
55+
- Test count increased from 313 to **418 tests** (105 new tests for TLS, P-256, P-384)
56+
57+
### Dependencies Added (TLS feature)
58+
- `rustls` 0.23 - TLS library
59+
- `p256` 0.13 - P-256/secp256r1 curve
60+
- `p384` 0.13 - P-384/secp384r1 curve
61+
- `ecdsa` 0.16 - ECDSA signatures
62+
- `digest` 0.10 - Hash trait requirements
63+
- `const-oid` 0.9 - OID constants for signatures
64+
- `rand` 0.8 - RNG for RSA-PSS signing
65+
1066
## [0.3.3] - 2025-11-19
1167

1268
### Changed

Cargo.toml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "crabgraph"
3-
version = "0.3.3"
3+
version = "0.4.0-pre"
44
authors = ["Raj Sarkar <ariajsarkar@gmail.com>"]
55
edition = "2021"
66
rust-version = "1.70"
@@ -74,6 +74,15 @@ serde = { version = "1.0.228", features = ["derive"], optional = true }
7474
# Zero-copy optimizations (optional)
7575
bytes = { version = "1.11.0", optional = true }
7676

77+
# TLS CryptoProvider support (optional)
78+
rustls = { version = "0.23", default-features = false, features = ["std", "tls12"], optional = true }
79+
p256 = { version = "0.13", default-features = false, features = ["ecdh", "ecdsa", "std", "pkcs8", "pem"], optional = true }
80+
p384 = { version = "0.13", default-features = false, features = ["ecdh", "ecdsa", "std", "pkcs8", "pem"], optional = true }
81+
ecdsa = { version = "0.16", default-features = false, features = ["signing", "verifying", "std", "der"], optional = true }
82+
digest = { version = "0.10", optional = true }
83+
const-oid = { version = "0.9", optional = true }
84+
rand = { version = "0.8", optional = true }
85+
7786
[dev-dependencies]
7887
criterion = { version = "0.7.0", features = ["html_reports"] }
7988
proptest = "1.9.0"
@@ -107,6 +116,10 @@ serde-support = ["serde"]
107116
zero-copy = ["bytes"]
108117
# WASM support is automatic via target-specific getrandom dependency
109118
wasm = []
119+
# TLS CryptoProvider support - implements rustls::crypto::CryptoProvider
120+
# Note: TLS feature always enables RSA for certificate validation
121+
tls = ["dep:rustls", "dep:p256", "dep:p384", "dep:ecdsa", "dep:digest", "dep:const-oid", "dep:rand", "rsa-support"]
122+
rustls-provider = ["tls"]
110123

111124
[[example]]
112125
name = "rsa_example"

README.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ For security issues, please see [SECURITY.md](SECURITY.md).
1919
## ✨ Features
2020

2121
- 🔒 **Authenticated Encryption (AEAD)**: AES-GCM, ChaCha20-Poly1305
22-
- **Streaming Encryption**: Process large files chunk-by-chunk with STREAM construction
23-
- 🔑 **Key Derivation**: PBKDF2, Argon2, HKDF
24-
- ✍️ **Digital Signatures**: Ed25519, (optional: RSA-PSS)
25-
- 🤝 **Key Exchange**: X25519 (Elliptic Curve Diffie-Hellman)
22+
- 📦 **Streaming Encryption**: Process large files chunk-by-chunk with STREAM construction
23+
- 🔑 **Key Derivation**: PBKDF2, Argon2, HKDF
24+
- ✍️ **Digital Signatures**: Ed25519, ECDSA (P-256, P-384), (optional: RSA-PSS)
25+
- 🤝 **Key Exchange**: X25519, P-256, P-384 (Elliptic Curve Diffie-Hellman)
2626
- 🔐 **Message Authentication**: HMAC (SHA-256, SHA-512)
27-
- #️⃣ **Hashing**: SHA-256, SHA-512, (optional: SHA-3, BLAKE2)
27+
- #️⃣ **Hashing**: SHA-256, SHA-384, SHA-512, (optional: SHA-3, BLAKE2)
28+
- 🌐 **TLS Support**: rustls CryptoProvider for reqwest, hyper-rustls, tokio-rustls
2829
- 🔒 **Optional RSA Support**: RSA-OAEP encryption & RSA-PSS signatures (⚠️ opt-in only, not recommended)
2930
- 🎲 **Secure Random**: Cryptographically secure RNG wrapper
3031
- 🧹 **Memory Safety**: Automatic zeroization of sensitive data
@@ -266,8 +267,36 @@ cargo audit
266267
- `rsa-support`: RSA encryption/signatures (⚠️ **NOT enabled by default** - opt-in only, has known vulnerability RUSTSEC-2023-0071)
267268
- `serde-support`: Serialization for keys and ciphertexts
268269
- `zero-copy`: `bytes` crate integration for high-performance scenarios
270+
- `tls`: TLS CryptoProvider for rustls (includes P-256, P-384, SHA-384)
271+
- `rustls-provider`: Alias for `tls` feature
269272
- `wasm`: WebAssembly support (⚠️ **Temporarily unavailable in v0.3.3** - see CHANGELOG for details)
270273

274+
### TLS Support (New in v0.4.0)
275+
276+
Use crabgraph as the TLS crypto backend for reqwest, hyper-rustls, and other rustls-based libraries:
277+
278+
```toml
279+
[dependencies]
280+
crabgraph = { version = "0.4.0-pre", features = ["tls"] }
281+
```
282+
283+
```rust
284+
use crabgraph::tls;
285+
286+
fn main() {
287+
// Install crabgraph as the default TLS provider (call once at startup)
288+
tls::install_default();
289+
290+
// Now all rustls-based libraries will use crabgraph
291+
// let client = reqwest::Client::new();
292+
}
293+
```
294+
295+
**Supported Cipher Suites:**
296+
- TLS 1.3: AES-256-GCM, AES-128-GCM, ChaCha20-Poly1305
297+
- TLS 1.2: ECDHE-ECDSA/RSA with AES-GCM and ChaCha20-Poly1305
298+
- Key Exchange: X25519, P-256, P-384
299+
271300
### Enabling RSA Support
272301

273302
RSA is **not included by default** due to security concerns. To use RSA:

src/asym/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,24 @@ pub mod x25519;
88
#[cfg(feature = "rsa-support")]
99
pub mod rsa;
1010

11+
#[cfg(feature = "tls")]
12+
pub mod p256;
13+
14+
#[cfg(feature = "tls")]
15+
pub mod p384;
16+
1117
pub use ed25519::{Ed25519KeyPair, Ed25519PublicKey, Ed25519Signature};
1218
pub use x25519::{X25519KeyPair, X25519PublicKey, X25519SharedSecret};
1319

1420
#[cfg(feature = "rsa-support")]
1521
pub use rsa::{RsaKeyPair, RsaPublicKey, RsaSignature};
22+
23+
#[cfg(feature = "tls")]
24+
pub use p256::{
25+
P256KeyPair, P256PublicKey, P256SharedSecret, P256Signature, P256SigningKey, P256VerifyingKey,
26+
};
27+
28+
#[cfg(feature = "tls")]
29+
pub use p384::{
30+
P384KeyPair, P384PublicKey, P384SharedSecret, P384Signature, P384SigningKey, P384VerifyingKey,
31+
};

0 commit comments

Comments
 (0)