| Recommend this page to a friend! |
| Packages of Mohamed Abdulalim | Crypto | src/KeyRotation/README.md | Download |
|
|||||||||||||||||||||
? Key Rotation ModuleCryptographic Key Lifecycle & Rotation Policy Engine This module provides a strict, fail-closed key rotation layer responsible for managing cryptographic key lifecycle and rotation policy ? without performing any cryptographic operations. > ? This module does NOT encrypt or decrypt data. > ? It exists to control which key is active, which keys are usable, and when rotation occurs. ? PurposeThis module exists to solve key lifecycle management, including:
Typical use cases: - Email queues - Webhook payloads - Deferred jobs - Long-lived encrypted storage ? Core Principle> Key rotation is a policy problem, not a cryptographic primitive. This module: - Owns key lifecycle and status - Owns rotation decisions - Supplies keys to cryptographic services It intentionally does NOT: - Perform encryption - Perform decryption - Know about ciphers or algorithms - Call OpenSSL or crypto libraries ? Architectural Overview
Separation of Responsibilities| Layer | Responsibility | |---------------|------------------------------| | Policy | Enforces rotation rules | | Provider | Stores keys & mutates state | | Service | Orchestration & export | | Crypto Module | Encryption / Decryption only | No circular dependency is allowed. ? Key Identity ModelEach cryptographic key is represented by:
Key Status Semantics| Status | Encrypt | Decrypt | Notes | |----------|---------|---------|-------------------------| | ACTIVE | ?? | ?? | Used for new encryption | | INACTIVE | ? | ?? | Old data only | | RETIRED | ? | ?? | Legacy / grace period | Encryption MUST NEVER use non-ACTIVE keys. ? Invariants (Fail-Closed)This module strictly enforces:
No silent fallback is allowed. ? Module Structure
? Rotation Flow (v1)
? No automatic re-encryption ? No background mutation ? Example Usage (Bootstrap)
? Integration with ReversibleCrypto
? Testing Philosophy
All invariants are validated at runtime. ? What This Module Does NOT Do
? Library-Ready DesignThis module is:
It can be moved to its own repository without refactoring. ? Summary?? Explicit key lifecycle ?? Strict rotation policy ?? Fail-closed security ?? Backward-compatible decryption ?? Clean separation from crypto primitives ?? Production-grade design Key rotation must be explicit, auditable, and boring. Anything implicit is a security risk. |