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

Unexport HashLogRoot. Verify with VerifySignedLogRoot. #1042

Merged
merged 3 commits into from
Mar 8, 2018

Conversation

gdbelvin
Copy link
Contributor

@gdbelvin gdbelvin commented Mar 6, 2018

Reduce the API surface of the crypto package: unexport HashLogRoot

Signing and verifying SignedLogRoots should only go through SignLogRoot and VerifySignedLogRoot functions. This simplifies future work to adjust the signature formats.

#958

@gdbelvin gdbelvin requested a review from daviddrysdale March 6, 2018 15:26
@gdbelvin gdbelvin force-pushed the f/sig/logroot_proto branch from a8c86f7 to 2b97bd8 Compare March 6, 2018 15:26
@codecov-io
Copy link

codecov-io commented Mar 6, 2018

Codecov Report

Merging #1042 into master will decrease coverage by 0.04%.
The diff coverage is 77.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1042      +/-   ##
==========================================
- Coverage    62.6%   62.56%   -0.05%     
==========================================
  Files         100      101       +1     
  Lines        8324     8379      +55     
==========================================
+ Hits         5211     5242      +31     
- Misses       2593     2610      +17     
- Partials      520      527       +7
Impacted Files Coverage Δ
client/log_verifier.go 73.07% <0%> (+2.16%) ⬆️
server/log_rpc_server.go 77.67% <100%> (ø) ⬆️
crypto/data_formats.go 77.77% <100%> (ø) ⬆️
log/sequencer.go 79.46% <100%> (-1.07%) ⬇️
crypto/signer.go 72.09% <100%> (+1.36%) ⬆️
crypto/verifier.go 45.83% <42.85%> (-0.51%) ⬇️
storage/tools/dump_tree/dumplib/dumplib.go 42.16% <66.66%> (ø) ⬆️
trees/trees.go 85.18% <0%> (-5.73%) ⬇️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2d7d1fd...ef8fdb5. Read the comment docs.

gdbelvin added 2 commits March 6, 2018 17:35
SignLogRoot should produce a *trillian.SignedLogRoot
VerifyLogRoot should verify a *trillian.SignedLogRoot

This prevents clients from needing to parse the SignedLogRoot object
themslves. It also provides a single API point to maintain.

VerifySignedLogRoot will produce a *trillian.SignedLogRoot.
The idea is the force clients to only use data that has been returned
from a successful verification.
@gdbelvin gdbelvin force-pushed the f/sig/logroot_proto branch from 2b97bd8 to cc99c97 Compare March 6, 2018 17:37
crypto/signer.go Outdated
// signature. Hashing is performed by github.com/benlaurie/objecthash.
func (s *Signer) SignLogRoot(root *trillian.SignedLogRoot) (*sigpb.DigitallySigned, error) {
hash, err := HashLogRoot(*root)
// SignLogRoot hashes and signs the supplied (to-be) SignedLogRoot and returns a SignedLogRoot
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe "returns a complete SignedLogRoot (including signature)".

(also nit) Trailing full stop in comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -115,23 +115,17 @@ func TestSignLogRoot(t *testing.T) {
t.Errorf("Failed to sign log root: %v", err)
continue
}
if got := len(sig.Signature); got == 0 {
if got := len(sig.Signature.Signature); got == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

sig is now a bit misleading - maybe rename to slr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@gdbelvin gdbelvin merged commit 0e6d950 into google:master Mar 8, 2018
@gdbelvin gdbelvin deleted the f/sig/logroot_proto branch March 8, 2018 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants