-
Notifications
You must be signed in to change notification settings - Fork 34
Fix sha512 buffer copy #333
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
Closed
+561
−30
Closed
Changes from all commits
Commits
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 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
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
Oops, something went wrong.
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 think here we need to add a check that error out if
hashType == WC_HASH_TYPE_SHA512 && sha512->hashType == hashType).This protects us from wolfcrypt passing bad wc_sha512 objects and more importantly to avoid the server to write more bytes than the ones used in the
wh_Client_DmaProcessClientAddressand related APIsThere 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.
Many existing wolfcrypt ports do not set
hashTypeso this check would go against the intent of this PR.This wolfcrypt PR addresses that, but this wolfHSM change should be independent, imho. wolfSSL/wolfssl#10193
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.
Added a defensive check for the truncated 256 and 224 paths to protect against the overflow. Existing callers should fall into the
defaultcase -- likely an incorrect hash, but at least no overflowThere 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.
if we really want to allow port that do not set hashType we can do
sha512->hashType = hashTypebut I probably leaner to be stricter than forgiving.If you think that "fixing"
sha512->hashTypefor the ports is better, go ahead.I don't think this will generate a bad hash btw, the init is not done here and update operation is the same, final is just a truncation. Am I missing something?
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.
Ah, you're right, hash should be fine.