feat(vault): add key-version header and rotation keyring support (#1770)#2051
Open
trivikramkalagi91-commits wants to merge 4 commits into
Open
Conversation
Contributor
Author
|
hey @utksh1 all the 26 checks have been passed with no error please review the pr as it is ready to merge |
Contributor
Author
|
hi @utksh1 i have resolved the merge conflict and also the issue is solved and PR is ready to merge plese review it |
Contributor
Author
|
hi @utksh1 i have resolved the merge conflict and also the issue is solved and PR is ready to merge plese review it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Refactor
VaultCryptoinbackend/secuscan/vault.pyto add explicit key-version headers, rotation keyring support, collision-safe legacy fallback decryption, key ID extraction, and strict payload length guards.Key Technical Enhancements
Prepend magic header
b"SV1:"(4 bytes) and raw key fingerprint (8 bytes) to newly encrypted blobs:Updated
VaultCrypto.__init__(key, fallback_keys=[...])to maintain an internal_keyring: Dict[bytes, AESGCM]). Decryption extracts the key ID from the header to look up the correct key instantly without trial-and-error GCM tag failures.If versioned decryption fails or if a legacy random 12-byte nonce coincidentally starts with
b"SV1:"(1 indecrypt()automatically falls back to attempting legacy decryption (nonce(12) || ciphertext), guaranteeing zero false-positive decryption failures for pre-existing secrets.Added
VaultCrypto.extract_key_id(cls, payload: str) -> Optional[str]to inspect base64url payloads and return the colon-separated hex key fingerprint without requiring secret decryption.Enforced strict minimum length guards (
Related Issues
Closes #1770
Type of Change
How Has This Been Tested?
Automated backend unit and integration test suites executed: