Skip to content
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

Fix hashed message verification #118

Merged
merged 4 commits into from
Nov 4, 2022
Merged

Conversation

hectorj2f
Copy link
Contributor

@hectorj2f hectorj2f commented Nov 4, 2022

Summary

When trying to time-stamp messages longer than 32 bytes, I realized the verification function was failing to verify the response and the input message hashes. I was seen the following error: Hashed messages don't match.

Then I had a look at the digitorus/timestamp implementation and I observed that messages longer than 32 bytes were timestamped without issues. So I had a look at our verification code and found a different way of validating the hashed messages than the one used in the timestamp code.

I changed the verify code function to follow the same approach, so we can validate the hashed message as done in digitorus/timestamp.

To reproduce the issue, you can simply change the example in our readme from myblob to blobblobblobblobblobblobblobblobblob, and you will get the failed hashed comparison using the verify cmd.

Release Note

fix: verify hashed messages

Documentation

Signed-off-by: Hector Fernandez <hector@chainguard.dev>
@hectorj2f hectorj2f requested a review from a team as a code owner November 4, 2022 11:54
@codecov-commenter
Copy link

codecov-commenter commented Nov 4, 2022

Codecov Report

Merging #118 (2943ec5) into main (d9d08e5) will increase coverage by 1.17%.
The diff coverage is 66.66%.

@@            Coverage Diff             @@
##             main     #118      +/-   ##
==========================================
+ Coverage   50.21%   51.39%   +1.17%     
==========================================
  Files          14       14              
  Lines         687      683       -4     
==========================================
+ Hits          345      351       +6     
+ Misses        307      295      -12     
- Partials       35       37       +2     
Impacted Files Coverage Δ
cmd/timestamp-cli/app/verify.go 20.23% <66.66%> (+7.73%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Signed-off-by: Hector Fernandez <hector@chainguard.dev>
cmd/timestamp-cli/app/verify.go Outdated Show resolved Hide resolved
cmd/timestamp-cli/app/verify_test.go Outdated Show resolved Hide resolved
cmd/timestamp-cli/app/verify.go Outdated Show resolved Hide resolved
Signed-off-by: Hector Fernandez <hector@chainguard.dev>
Co-authored-by: Bob Callaway <bobcallaway@users.noreply.github.com>
Signed-off-by: Hector Fernandez <hector@chainguard.dev>
@hectorj2f
Copy link
Contributor Author

@bobcallaway Thanks for the review

@cpanato cpanato merged commit 5b514aa into sigstore:main Nov 4, 2022
@hectorj2f hectorj2f deleted the fix_verify_hashes branch November 4, 2022 15:54
Copy link
Contributor

@haydentherapper haydentherapper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks for fixing! Looks like the root cause was reading into a buffer of size(sha256 hash) bytes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants