Skip to content
Snippets Groups Projects
Unverified Commit ccf05989 authored by dlorenc's avatar dlorenc Committed by GitHub
Browse files

Merge pull request #201 from bobcallaway/log_root

Validate and return hash and size from signed root
parents 3c6ce167 bbefd6fd
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,7 @@ import (
"encoding/pem"
"errors"
"fmt"
"strings"
"github.com/sigstore/rekor/cmd/cli/app/state"
......@@ -68,10 +69,6 @@ var logInfoCmd = &cobra.Command{
}
logInfo := result.GetPayload()
cmdOutput := &logInfoCmdOutput{
TreeSize: *logInfo.TreeSize,
RootHash: *logInfo.RootHash,
}
keyHint, err := base64.StdEncoding.DecodeString(logInfo.SignedTreeHead.KeyHint.String())
if err != nil {
......@@ -117,6 +114,19 @@ var logInfoCmd = &cobra.Command{
return nil, err
}
if lr.TreeSize != uint64(*logInfo.TreeSize) {
return nil, errors.New("tree size in signed tree head does not match value returned in API call")
}
if !strings.EqualFold(hex.EncodeToString(lr.RootHash), *logInfo.RootHash) {
return nil, errors.New("root hash in signed tree head does not match value returned in API call")
}
cmdOutput := &logInfoCmdOutput{
TreeSize: int64(lr.TreeSize),
RootHash: hex.EncodeToString(lr.RootHash),
}
oldState := state.Load(serverURL)
if oldState != nil {
persistedSize := oldState.TreeSize
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment