Skip to content

Commit 489ecb3

Browse files
doublegateclaude
andcommitted
refactor(crypto): split aead.rs into focused modules (REFACTOR-001, 8 SP)
Split monolithic 1,529 LOC aead.rs into 4 focused modules for improved maintainability, testability, and code organization. New module structure (aead/): - cipher.rs (488 LOC): Core AEAD types - Nonce: 24-byte XChaCha20 nonce with counter and random modes - Tag: 16-byte Poly1305 authentication tag - AeadKey: 32-byte key with encrypt/decrypt/in-place operations - AeadCipher: Legacy API wrapper - Key commitment for key-committing AEAD - 9 cipher tests - replay.rs (264 LOC): Replay protection - ReplayProtection: 256-bit sliding window - Constant-time comparison via subtle crate - Multi-word bit shifting for window advancement - 7 replay tests - session.rs (457 LOC): Session management - SessionCrypto: Bidirectional encrypted communication - BufferPool: Zero-allocation buffer reuse - Key commitment in AAD for key-committing AEAD - Automatic nonce counter management - 7 session tests - mod.rs (42 LOC): Public re-exports - All types re-exported for backward compatibility - Module documentation Benefits: - Single responsibility per module - Easier testing and maintenance - Clearer dependency boundaries - Reduced cognitive load (4 small files vs 1 large) - 278 LOC reduction (-18%) through deduplication All 23 AEAD tests preserved and passing. No API changes - full backward compatibility maintained. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 40056f6 commit 489ecb3

File tree

6 files changed

+1261
-1530
lines changed

6 files changed

+1261
-1530
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2828
- **BLAKE3 SIMD (PERF-001, 8 SP)**: rayon + neon features
2929
- 2-4x faster parallel hashing, ARM64 optimization
3030

31+
### Refactored
32+
- **AEAD Module Split (REFACTOR-001, 8 SP)**: Improved code organization
33+
- Split 1,529 LOC `aead.rs` into 4 focused modules (1,251 LOC total)
34+
- `aead/cipher.rs` (488 LOC) - Nonce, Tag, AeadKey, AeadCipher
35+
- `aead/replay.rs` (264 LOC) - ReplayProtection sliding window
36+
- `aead/session.rs` (457 LOC) - SessionCrypto, BufferPool
37+
- `aead/mod.rs` (42 LOC) - Re-exports for backward compatibility
38+
- All 23 AEAD tests preserved and passing
39+
3140
### Documentation
3241
- Refactoring analysis (18 priorities, complexity metrics)
3342

34-
**Story Points: 44 SP**
43+
**Story Points: 52 SP**
3544

3645
## [0.7.0] - 2025-12-01
3746

0 commit comments

Comments
 (0)