Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rekor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SafSec
rekor
Commits
fd863402
Commit
fd863402
authored
4 years ago
by
Dan Lorenc
Browse files
Options
Downloads
Patches
Plain Diff
Hookup the proof!
parent
f18fb343
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmd/add.go
+0
-1
0 additions, 1 deletion
cmd/add.go
cmd/get.go
+45
-2
45 additions, 2 deletions
cmd/get.go
with
45 additions
and
3 deletions
cmd/add.go
+
0
−
1
View file @
fd863402
...
...
@@ -97,7 +97,6 @@ For more information, visit [domain]`,
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
fmt
.
Println
(
string
(
content
))
},
}
...
...
This diff is collapsed.
Click to expand it.
cmd/get.go
+
45
−
2
View file @
fd863402
...
...
@@ -17,17 +17,32 @@ package cmd
import
(
"context"
"crypto"
"crypto/x509"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"time"
tcrypto
"github.com/google/trillian/crypto"
tclient
"github.com/google/trillian/client"
"github.com/google/trillian"
"github.com/google/trillian/merkle"
"github.com/google/trillian/merkle/rfc6962"
"github.com/projectrekor/rekor-cli/log"
"github.com/spf13/viper"
"github.com/spf13/cobra"
)
type
getProofResponse
struct
{
Proof
*
trillian
.
GetInclusionProofByHashResponse
Key
[]
byte
}
// getCmd represents the get command
var
getCmd
=
&
cobra
.
Command
{
Use
:
"get"
,
...
...
@@ -38,7 +53,7 @@ For more information, visit [domain]`,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
log
:=
log
.
Logger
rekorServer
:=
viper
.
GetString
(
"rekor_server"
)
url
:=
rekorServer
+
"/api/v1/get"
url
:=
rekorServer
+
"/api/v1/get
proof
"
linkfile
:=
viper
.
GetString
(
"linkfile"
)
// Set Context with Timeout for connects to thde log rpc server
...
...
@@ -63,12 +78,40 @@ For more information, visit [domain]`,
defer
response
.
Body
.
Close
()
content
,
err
:=
ioutil
.
ReadAll
(
response
.
Body
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
fmt
.
Println
(
string
(
content
))
resp
:=
getProofResponse
{}
if
err
:=
json
.
Unmarshal
(
content
,
&
resp
);
err
!=
nil
{
log
.
Fatal
(
err
)
}
pub
,
err
:=
x509
.
ParsePKIXPublicKey
(
resp
.
Key
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
f
,
err
:=
ioutil
.
ReadFile
(
linkfile
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
leafHash
:=
rfc6962
.
DefaultHasher
.
HashLeaf
(
f
)
verifier
:=
tclient
.
NewLogVerifier
(
rfc6962
.
DefaultHasher
,
pub
,
crypto
.
SHA256
)
root
,
err
:=
tcrypto
.
VerifySignedLogRoot
(
verifier
.
PubKey
,
verifier
.
SigHash
,
resp
.
Proof
.
SignedLogRoot
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
v
:=
merkle
.
NewLogVerifier
(
rfc6962
.
DefaultHasher
)
proof
:=
resp
.
Proof
.
Proof
[
0
]
if
err
:=
v
.
VerifyInclusionProof
(
proof
.
LeafIndex
,
int64
(
root
.
TreeSize
),
proof
.
Hashes
,
root
.
RootHash
,
leafHash
);
err
!=
nil
{
log
.
Fatal
(
err
)
}
log
.
Info
(
"proof correct!"
)
},
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment