Skip to content

Commit 6310637

Browse files
committed
pass verifier
1 parent 28ab369 commit 6310637

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed

cmd/gcp/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,13 @@ func awaitSignal(doneFn func()) {
200200
doneFn()
201201
}
202202

203-
func newGCPStorage(ctx context.Context, signer note.Signer) (*sctfe.CTStorage, error) {
203+
func newGCPStorage(ctx context.Context, signer note.Signer, verifier note.Verifier) (*sctfe.CTStorage, error) {
204204
gcpCfg := gcpTessera.Config{
205205
ProjectID: *projectID,
206206
Bucket: *bucket,
207207
Spanner: *spannerDB,
208208
}
209-
tesseraStorage, err := gcpTessera.New(ctx, gcpCfg, tessera.WithCheckpointSignerVerifier(signer, nil), tessera.WithCTLayout())
209+
tesseraStorage, err := gcpTessera.New(ctx, gcpCfg, tessera.WithCheckpointSignerVerifier(signer, verifier), tessera.WithCTLayout())
210210
if err != nil {
211211
return nil, fmt.Errorf("Failed to initialize GCP Tessera storage: %v", err)
212212
}

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ require (
4242
github.com/beorn7/perks v1.0.1 // indirect
4343
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
4444
github.com/cespare/xxhash/v2 v2.3.0 // indirect
45+
github.com/cisco/go-tls-syntax v0.0.0-20200617162716-46b0cfb76b9b // indirect
4546
github.com/cncf/xds/go v0.0.0-20240905190251-b4127c9b8d78 // indirect
4647
github.com/envoyproxy/go-control-plane v0.13.0 // indirect
4748
github.com/envoyproxy/protoc-gen-validate v1.1.0 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,8 @@ github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
664664
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
665665
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
666666
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
667+
github.com/cisco/go-tls-syntax v0.0.0-20200617162716-46b0cfb76b9b h1:Ves2turKTX7zruivAcUOQg155xggcbv3suVdbKCBQNM=
668+
github.com/cisco/go-tls-syntax v0.0.0-20200617162716-46b0cfb76b9b/go.mod h1:0AZAV7lYvynZQ5ErHlGMKH+4QYMyNCFd+AiL9MlrCYA=
667669
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
668670
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
669671
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=

instance.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,19 @@ import (
2525
"github.com/google/certificate-transparency-go/asn1"
2626
"github.com/google/certificate-transparency-go/x509util"
2727
"github.com/google/trillian/monitoring"
28+
tnote "github.com/transparency-dev/formats/note"
2829
"golang.org/x/mod/sumdb/note"
2930
)
3031

32+
type createStorageFunc func(context.Context, note.Signer, note.Verifier) (*CTStorage, error)
33+
3134
// InstanceOptions describes the options for a log instance.
3235
type InstanceOptions struct {
3336
// Validated holds the original configuration options for the log, and some
3437
// of its fields parsed as a result of validating it.
3538
Validated *ValidatedLogConfig
3639
// CreateStorage instantiates a Tessera storage implementation with a signer option.
37-
CreateStorage func(context.Context, note.Signer) (*CTStorage, error)
40+
CreateStorage createStorageFunc
3841
// Deadline is a timeout for Tessera requests.
3942
Deadline time.Duration
4043
// MetricFactory allows creating metrics.
@@ -92,10 +95,19 @@ func SetUpInstance(ctx context.Context, opts InstanceOptions) (*Instance, error)
9295
timeSource := new(SystemTimeSource)
9396
ctSigner := NewCpSigner(cfg.Signer, cfg.Origin, logID, timeSource)
9497

98+
vkey, err := tnote.RFC6962VerifierString(cfg.Origin, cfg.Signer.Public())
99+
if err != nil {
100+
return nil, fmt.Errorf("failed to create verifier key: %v", err)
101+
}
102+
ctVerifier, err := tnote.NewRFC6962Verifier(vkey)
103+
if err != nil {
104+
return nil, fmt.Errorf("failed to create verifier: %v", err)
105+
}
106+
95107
if opts.CreateStorage == nil {
96108
return nil, fmt.Errorf("failed to initiate storage backend: nil createStorage")
97109
}
98-
storage, err := opts.CreateStorage(ctx, ctSigner)
110+
storage, err := opts.CreateStorage(ctx, ctSigner, ctVerifier)
99111
if err != nil {
100112
return nil, fmt.Errorf("failed to initiate storage backend: %v", err)
101113
}

instance_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
"golang.org/x/mod/sumdb/note"
3131
)
3232

33-
func fakeCTStorage(_ context.Context, _ note.Signer) (*CTStorage, error) {
33+
func fakeCTStorage(_ context.Context, _ note.Signer, _ note.Verifier) (*CTStorage, error) {
3434
return &CTStorage{}, nil
3535
}
3636

@@ -52,7 +52,7 @@ func TestSetUpInstance(t *testing.T) {
5252
extKeyUsages string
5353
rejectExtensions string
5454
signer crypto.Signer
55-
ctStorage func(context.Context, note.Signer) (*CTStorage, error)
55+
ctStorage createStorageFunc
5656
wantErr string
5757
}{
5858
{
@@ -150,7 +150,7 @@ func TestSetUpInstance(t *testing.T) {
150150
spannerDB: "spanner",
151151
rootsPemFile: "./testdata/fake-ca.cert",
152152
signer: signer,
153-
ctStorage: func(_ context.Context, _ note.Signer) (*CTStorage, error) {
153+
ctStorage: func(_ context.Context, _ note.Signer, _ note.Verifier) (*CTStorage, error) {
154154
return nil, fmt.Errorf("I failed")
155155
},
156156
wantErr: "failed to initiate storage backend",

0 commit comments

Comments
 (0)