Bug 2062062 - Cache the encryption key in NSSKeyManager - #7535
Open
jo wants to merge 1 commit into
Open
Conversation
ManagedEncryptorDecryptor asks NSSKeyManager for the key on every encrypt() and decrypt(), and each call is a full NSS token round-trip. add_many_with_meta() holds the store mutex for its entire run, so a bulk import kept LoginStore::shutdown() blocked on that mutex long enough to trip Desktop's 60s async shutdown timeout. NSSKeyManager now keeps the key after the first retrieval. The primary password check still runs on every call and drops the cache when the token is found locked, so re-authentication is unchanged. The key now lives in memory for as long as the token stays unlocked. Zeroizing would have to cover the copies passed on to ManagedEncryptorDecryptor and jwcrypto as well, so that is left as a follow-up.
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.
ManagedEncryptorDecryptor asks NSSKeyManager for the key on every encrypt() and decrypt(), and each call is a full NSS token round-trip. add_many_with_meta() holds the store mutex for its entire run, so a bulk import kept LoginStore::shutdown() blocked on that mutex long enough to trip Desktop's 60s async shutdown timeout.
NSSKeyManager now keeps the key after the first retrieval. The primary password check still runs on every call and drops the cache when the token is found locked, so re-authentication is unchanged.
The key now lives in memory for as long as the token stays unlocked. Zeroizing would have to cover the copies passed on to ManagedEncryptorDecryptor and jwcrypto as well, so that is left as a follow-up.
Pull Request checklist
[ci full]to the PR title.