-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PM-5728] Enable Zeroize support for keys and EncStrings #515
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
158308e
Enable Zeroize support for keys and EncStrings
dani-garcia 73f77ce
Fix doclinks
dani-garcia 76ee8c3
Fix review comments
dani-garcia c3d9d31
Merge branch 'main' into ps/PM-5728-zeroize
dani-garcia 29c7e8a
Welp that segfaults on CI lol
dani-garcia 1cc8b26
Review comments
dani-garcia c7f6b5a
Zeroize for SHA is on master but not the release :facepalm:
dani-garcia 29e174d
Fmt
dani-garcia 6142c0d
Merge branch 'main' into ps/PM-5728-zeroize
dani-garcia 6e84446
Fix conflicts
dani-garcia 9311349
Add mut comment
dani-garcia 9fbb514
Merge branch 'main' into ps/PM-5728-zeroize
dani-garcia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe this consumes the key. Do we need to zero
dec
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We zeroize the key inside the
TryFrom<&mut [u8]>
impl:https://github.com/bitwarden/sdk/blob/6e844469c9e1555a5abc45248ea88abcc025679b/crates/bitwarden-crypto/src/keys/symmetric_crypto_key.rs#L90-L115
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That feels potentially confusing? Do you expect a
TryFrom
of a slice to manipulate the input? I do see the benefit of ensuring it gets consumed though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also just pass an owned Vec<> and consume it in the function, but that will limit the use of the API for someone trying to pass a GenericArray or a [u8; 64] for example.
I think the fact that the function receives a
&mut [u8]
should make it clear enough that something is being modified, but we could add a comment mentioning explicitly that it's being zeroed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a comment to make it explicit. We can revaluate if this turns out to be confusing, potentially not using try from and instead having an explicit function could make it less confusing.