feat: implement Repository Master Key (RMK) hierarchy with OS keyring storage - #20
Merged
Conversation
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.
Summary
This PR implements a Repository Master Key (RMK) hierarchy to replace the password-based encryption flow. The RMK is generated once during
stash init, stored securely in the OS credential store (Windows Credential Manager, macOS Keychain, Linux secret-service) via thekeyringlibrary, and used to derive per-file and per-chunk encryption keys.Key Changes
Core Implementation
src/stash/core/keymanager.py(new) — RMK generation, storage, retrieval using OS keyringsrc/stash/core/crypto.py— Rewritten for RMK-based hierarchy:generate_file_key(rmk)— per-file key from RMKderive_file_key_from_rmk(rmk, file_id)— deterministic derivationencrypt_filename/decrypt_filename— dedicated filename encryptionencrypt_file_key/decrypt_file_key)src/stash/core/manifest.py— Updated for RMK system (removedfile_key_wrapped)src/stash/core/exceptions.py— AddedKeyManagementErrorCLI Commands
stash init— Generates RMK, stores in keyring, displays recovery key (RMK hex)stash put/stash get— Use RMK from keyring (no password prompt)stash key-commands(new group):lock— remove RMK from keyringunlock --recovery-key <hex>— restore RMK from recovery keystatus— show key management statusrecovery— display RMK for backupDocumentation & Tests
requirements.txtwithkeyring>=25.0UX Flow
Testing
Breaking Changes
put/get— uses RMK from keyringstash init— must be savedDependencies
keyring>=25.0topyproject.tomlandrequirements.txtCloses: #key-management