fix!: update argon2
and improve key handling
#4892
Merged
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
Updates
argon2
for the gRPC and wallet use cases. Improves handling of keys and secret data. Fixes issue 4882.Motivation and Context
Issue 4882 notes that different versions of
argon2
are used throughout the codebase. The newer minor version0.4
changes the API significantly, and the older version0.2
is no longer supported.Additionally, gRPC and wallet implementations use the default parameter set from the crate, which is not in line with the OWASP recommendations that we use elsewhere in the key manager.
Further, it's recommended that a specific function be used when performing KDF functionality, as this binds the parameter set into the output. While not a major security issue, it's worth updating to this function where appropriate.
Finally, secret data is kept in memory in many places through the codebase, and this area is no exception. As part of good practice, we should try to zeroize such data wherever possible.
This PR addresses these issues. It updates the gRPC and wallet
argon2
versions to0.4
(the key manager is addressed in PR 4860 and makes the necessary API changes. It updates the parameter set to be consistent with the linked recommendations. It also adds some improved handling of secret data (but does not do so comprehensively, limiting the scope to the updated code).How Has This Been Tested?
Existing tests pass.
BREAKING: This changes how wallet passphrase-based hashes and keys are derived.