ellswift: don't declassify or leave sk in sha256 buffer#1863
Open
furszy wants to merge 1 commit into
Open
Conversation
secp256k1_ellswift_create assumes sha256 clears the data in its buffer after hashing it, which is not the case. So we shouldn't declassify the whole struct, only the hash result. We should also clear it at the end, so the sk doesn't linger on the stack when no aux rnd is given.
Contributor
|
Concept ACK Interesting find. I was very confused at first why there wouldn't be further writes on this passed hashing object within secp256k1/src/modules/ellswift/main_impl.h Lines 310 to 311 in 13db747 Fwiw Bitcoin Core's BIP324 implementation is not affected by this, as we pass in the randomness ( |
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.
secp256k1_ellswift_createassumes sha256 clears the data in its bufferafter hashing it, which is not the case. So we shouldn't declassify the whole
struct, only the hash result. We should also clear it at the end, so the sk
doesn't linger on the stack when no aux rnd is given.
On master, can add the following diff and run the tests to see sk sitting
in the buffer.