Skip to content

refactor(crypto): move KMSService to domain and improve key security#83

Merged
allisson merged 1 commit intomainfrom
improve-crypto
Mar 2, 2026
Merged

refactor(crypto): move KMSService to domain and improve key security#83
allisson merged 1 commit intomainfrom
improve-crypto

Conversation

@allisson
Copy link
Owner

@allisson allisson commented Mar 2, 2026

Relocate the KMSService interface to the domain layer and enhance security by ensuring sensitive key material is zeroed in memory after use.

  • Move KMSService interface from internal/crypto/service to internal/crypto/domain to align with Clean Architecture.
  • Implement proactive zeroing of plaintext key material in KeyManagerService and MasterKeyChain to minimize exposure of sensitive data in memory.
  • Wrap DekUseCase.Rewrap logic in a database transaction to ensure atomicity during batch DEK re-encryption.
  • Update DI container and CLI commands to reflect the package reorganization of KMSService.
  • Update DekUseCase unit tests to verify transaction management and mock expectations.

Relocate the KMSService interface to the domain layer and enhance security by
ensuring sensitive key material is zeroed in memory after use.

- Move `KMSService` interface from `internal/crypto/service` to `internal/crypto/domain` to align with Clean Architecture.
- Implement proactive zeroing of plaintext key material in `KeyManagerService` and `MasterKeyChain` to minimize exposure of sensitive data in memory.
- Wrap `DekUseCase.Rewrap` logic in a database transaction to ensure atomicity during batch DEK re-encryption.
- Update DI container and CLI commands to reflect the package reorganization of `KMSService`.
- Update `DekUseCase` unit tests to verify transaction management and mock expectations.
@allisson allisson merged commit f79bd7c into main Mar 2, 2026
1 of 2 checks passed
@allisson allisson deleted the improve-crypto branch March 2, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant