Skip to content

Commit c8a7276

Browse files
authored
Merge pull request #5 from AriajSarkar/dev
feat: v3.1
2 parents f8e62e6 + e0447b9 commit c8a7276

16 files changed

Lines changed: 648 additions & 92 deletions

.github/workflows/fuzz.yml

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,43 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v4
14-
- uses: dtolnay/rust-toolchain@nightly
15-
- name: Install cargo-fuzz
16-
run: cargo install cargo-fuzz
17-
- name: Run fuzzing (short duration for CI)
14+
15+
- name: Set up Docker Buildx
16+
uses: docker/setup-buildx-action@v3
17+
18+
- name: Cache Docker layers
19+
uses: actions/cache@v4
20+
with:
21+
path: /tmp/.buildx-cache
22+
key: ${{ runner.os }}-buildx-fuzz-${{ hashFiles('Dockerfile.fuzz', 'Cargo.lock') }}
23+
restore-keys: |
24+
${{ runner.os }}-buildx-fuzz-
25+
26+
- name: Build fuzz Docker image
27+
run: |
28+
docker-compose -f docker-compose.fuzz.yml build \
29+
--build-arg BUILDKIT_INLINE_CACHE=1
30+
31+
- name: Run fuzzing (60 seconds per target)
32+
run: |
33+
docker-compose -f docker-compose.fuzz.yml up || echo "Fuzzing completed with findings"
34+
35+
- name: Check for artifacts
36+
id: check_artifacts
1837
run: |
19-
# Run each fuzz target for 60 seconds
20-
cd fuzz
21-
for target in fuzz_targets/*.rs; do
22-
target_name=$(basename "$target" .rs)
23-
echo "Fuzzing $target_name..."
24-
cargo fuzz run "$target_name" -- -max_total_time=60 || true
25-
done
38+
if [ -d "fuzz/artifacts" ] && [ "$(ls -A fuzz/artifacts 2>/dev/null)" ]; then
39+
echo "artifacts_found=true" >> $GITHUB_OUTPUT
40+
echo "Found crash artifacts:"
41+
find fuzz/artifacts -type f -name "crash-*" -o -name "leak-*" -o -name "timeout-*"
42+
else
43+
echo "artifacts_found=false" >> $GITHUB_OUTPUT
44+
echo "No artifacts found"
45+
fi
46+
2647
- name: Upload artifacts if crashes found
2748
uses: actions/upload-artifact@v4
28-
if: failure()
49+
if: always() && steps.check_artifacts.outputs.artifacts_found == 'true'
2950
with:
3051
name: fuzz-artifacts
3152
path: fuzz/artifacts/
53+
if-no-files-found: ignore

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "crabgraph"
3-
version = "0.3.0"
3+
version = "0.3.1"
44
authors = ["Raj Sarkar <ariajsarkar@gmail.com>"]
55
edition = "2021"
66
rust-version = "1.70"

Dockerfile.fuzz

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Lightweight Rust fuzzing image based on Debian Slim (compatible with sanitizers)
2+
FROM rust:slim AS builder
3+
4+
# Install required build tools
5+
RUN apt-get update && apt-get install -y \
6+
build-essential \
7+
pkg-config \
8+
libssl-dev \
9+
&& rm -rf /var/lib/apt/lists/*
10+
11+
# Install nightly toolchain and cargo-fuzz
12+
RUN rustup default nightly && \
13+
cargo install cargo-fuzz
14+
15+
# Production image
16+
FROM rust:slim
17+
18+
# Install runtime dependencies
19+
RUN apt-get update && apt-get install -y \
20+
build-essential \
21+
pkg-config \
22+
libssl-dev \
23+
&& rm -rf /var/lib/apt/lists/*
24+
25+
# Copy cargo-fuzz from builder
26+
COPY --from=builder /usr/local/cargo/bin/cargo-fuzz /usr/local/cargo/bin/cargo-fuzz
27+
28+
# Set nightly as default
29+
RUN rustup default nightly
30+
31+
WORKDIR /workspace
32+
33+
# Copy Cargo files first for better layer caching
34+
COPY Cargo.toml Cargo.lock ./
35+
COPY fuzz/Cargo.toml ./fuzz/
36+
37+
# Create dummy src to build dependencies (caching layer)
38+
RUN mkdir src && \
39+
echo "fn main() {}" > src/lib.rs && \
40+
mkdir -p fuzz/fuzz_targets && \
41+
echo "#![no_main]\nuse libfuzzer_sys::fuzz_target;\nfuzz_target!(|_data: &[u8]| {});" > fuzz/fuzz_targets/dummy.rs
42+
43+
# Build dependencies to cache them
44+
RUN cd fuzz && cargo +nightly build --release 2>/dev/null || true
45+
46+
# Remove dummy files
47+
RUN rm -rf src fuzz/fuzz_targets/dummy.rs
48+
49+
# Copy actual source code
50+
COPY src ./src
51+
COPY fuzz ./fuzz
52+
53+
# Default command runs all fuzz targets for 60 seconds each
54+
# Cleans up old artifacts before starting
55+
CMD ["sh", "-c", "cd fuzz && \
56+
echo '=========================================='; \
57+
echo 'Cleaning old artifacts...'; \
58+
echo '=========================================='; \
59+
rm -rf artifacts/*/* 2>/dev/null || true; \
60+
echo 'Old artifacts removed. Starting fuzzing...' && \
61+
echo '' && \
62+
for target in fuzz_targets/*.rs; do \
63+
target_name=$(basename $target .rs); \
64+
echo '=========================================='; \
65+
echo 'Fuzzing: '$target_name; \
66+
echo '=========================================='; \
67+
cargo fuzz run $target_name -- -max_total_time=60 || echo 'Issues found in '$target_name; \
68+
done && \
69+
echo '' && \
70+
echo '=========================================='; \
71+
echo 'Fuzzing complete!'; \
72+
echo '=========================================='; \
73+
if [ -d artifacts ] && [ \"$(find artifacts -type f 2>/dev/null)\" ]; then \
74+
echo 'Artifacts found:'; \
75+
find artifacts -type f -exec echo ' {}' \\;; \
76+
else \
77+
echo 'No artifacts generated (no crashes/issues found)'; \
78+
fi"]

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,19 @@ For security issues, please see [SECURITY.md](SECURITY.md).
3232
- 🚀 **Performance**: Zero-copy operations, hardware acceleration support
3333
- 📦 **No-std Support**: Core functionality available in embedded contexts
3434

35+
## 🌐 Live Demo
36+
37+
**[Try CrabGraph in WebAssembly!](https://ariajsarkar.github.io/keyring-wasm/)**
38+
39+
Experience CrabGraph's cryptographic capabilities directly in your browser. This interactive demo showcases real-world usage of the library compiled to WebAssembly, demonstrating encryption, key derivation, and signing operations with zero installation required.
40+
3541
## 🚀 Quick Start
3642

3743
Add to your `Cargo.toml`:
3844

3945
```toml
4046
[dependencies]
41-
crabgraph = "0.1"
47+
crabgraph = "0.3.1"
4248
```
4349

4450
### Authenticated Encryption (AES-GCM)
@@ -196,9 +202,27 @@ fn main() -> CrabResult<()> {
196202
## 📚 Documentation
197203

198204
- [API Documentation](https://docs.rs/crabgraph)
205+
- [GitHub Pages Docs](https://ariajsarkar.github.io/crabgraph/crabgraph/)
206+
- [📊 Performance Benchmarks](https://ariajsarkar.github.io/crabgraph-bench/)
199207
- [Migration from CryptoJS](docs/MIGRATE_CRYPTOJS.md)
200208
- [Examples](examples/)
201209

210+
## ⚡ Performance
211+
212+
CrabGraph delivers excellent performance with minimal overhead over raw primitives:
213+
214+
| Operation | Speed | Throughput |
215+
|-----------|-------|------------|
216+
| AES-256-GCM Encrypt (1KB) | ~0.95 μs | **~1,079 MB/s** |
217+
| ChaCha20-Poly1305 Encrypt (1KB) | ~2.7 μs | **~378 MB/s** |
218+
| Ed25519 Sign | ~16 μs | **~62,500 ops/sec** |
219+
| Ed25519 Verify | ~47 μs | **~21,277 ops/sec** |
220+
| Argon2id KDF (32B) | ~11 ms | Intentionally slow (security) |
221+
222+
📊 **Full benchmark results**: [ariajsarkar.github.io/crabgraph-bench](https://ariajsarkar.github.io/crabgraph-bench/)
223+
224+
*Benchmarks run on modern hardware with AES-NI. Your results may vary.*
225+
202226
## 🏗️ Architecture
203227

204228
CrabGraph is built on these audited cryptographic libraries:

TODOs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ This document tracks planned features, improvements, and ongoing work for CrabGr
259259

260260
## Known Issues
261261

262-
- None reported yet (v0.1.0)
262+
- None reported yet (v0.3.0)
263263

264264
## Contribution Estimates
265265

0 commit comments

Comments
 (0)