| Recommend this page to a friend! |
| Packages of Mohamed Abdulalim | Crypto | src/KeyRotation/docs/ADR-002-Key-Rotation-Architecture.md | Download |
|
|||||||||||||||||||||
ADR-002: Key Rotation ArchitectureStatusAccepted / Locked Date2026-01-08 Related Decisions
> This ADR is a direct continuation of ADR-001 and exists within the same > cryptographic decision space, despite being implemented as a separate module. ContextThe system uses reversible cryptography for encrypting data that must be decrypted later (e.g. email queues, webhooks, deferred jobs). ADR-001 intentionally excluded key lifecycle management, stating that: - Cryptographic primitives must remain deterministic - Key rotation is an operational and policy concern However, the system still requires: - Controlled key activation - Safe key retirement - Backward-compatible decryption - Future support for re-encryption workflows This ADR defines how key rotation is designed and enforced without violating the guarantees of ADR-001. DecisionWe introduce a dedicated Key Rotation module that is:
Scope DefinitionThe Key Rotation module IS responsible for:
The Key Rotation module is NOT responsible for:
Architectural Separation (Hard Boundary)Reversible Crypto Module
Key Rotation Module
No circular dependency is allowed. Key Identity ModelEach cryptographic key is identified by an immutable A key has:
-
Active Key Rule (Invariant)At any point in time: - Exactly one key MAY be active - Zero active keys is a hard error - Multiple active keys are forbidden This invariant is enforced by the Key Rotation module. Key Status Semantics| Status | Encrypt | Decrypt | Notes | |------|--------|---------|------| | active | ?? | ?? | Used for new encryption | | inactive | ? | ?? | Old data only | | retired | ? | ?? | Grace period / legacy data | Encryption MUST NEVER use inactive or retired keys. Rotation Flow (Version 1)
No automatic re-encryption occurs in this phase. Re-Encryption (Explicitly Out of Scope)Automatic or background re-encryption: - Is NOT part of this ADR - Will be addressed in a future ADR - Must be explicit, observable, and auditable This avoids: - Silent data mutation - Unbounded background work - Hidden security risks Failure Semantics (Fail-Closed)The Key Rotation module MUST fail closed:
No fallbacks are allowed. Extensibility ModelThe module supports multiple key providers via an interface:
The provider is replaceable without modifying cryptographic code. Security Considerations
ConsequencesPositive
Trade-offs
These trade-offs are intentional and accepted. Alternatives Considered? Rotation Inside Crypto ModuleRejected due to: - Mixed responsibilities - Non-deterministic crypto behavior - Poor auditability ? Automatic Re-EncryptionRejected due to: - Hidden side effects - Operational risk - Difficult rollback Final NotesKey rotation is a policy problem, not a cryptographic primitive. This design ensures: - Cryptography remains predictable - Rotation remains explicit - Future expansion is safe and controlled Any deviation from this architecture requires a new ADR. End of Record |