Skip to content

Commit ae56f3d

Browse files
committed
Add Sigsum config to --build
We introduce a .String() function on the Log type to help us do this.
1 parent 4f447cb commit ae56f3d

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

cmd/tkey-verification/util.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/spf13/pflag"
1212
"github.com/tillitis/tkey-verification/internal/appbins"
1313
"github.com/tillitis/tkey-verification/internal/firmware"
14+
"github.com/tillitis/tkey-verification/internal/sigsum"
1415
"github.com/tillitis/tkey-verification/internal/vendorkey"
1516
)
1617

@@ -27,6 +28,12 @@ func builtWith() {
2728
os.Exit(1)
2829
}
2930

31+
var log sigsum.Log
32+
if err = log.FromEmbedded(); err != nil {
33+
le.Printf("Sigsum configuration missing")
34+
os.Exit(1)
35+
}
36+
3037
firmwares, err := firmware.NewFirmwares()
3138
if err != nil {
3239
le.Printf("Found no usable firmwares\n")
@@ -38,11 +45,15 @@ Supported verisigner-app tags:
3845
%s
3946
Known vendor signing keys:
4047
%s
48+
49+
Known Sigsum configuration:
50+
%s
4151
Known firmwares:
4252
%s
4353
`,
4454
strings.Join(appBins.Tags(), " \n "),
4555
vendorKeys.String(),
56+
log.String(),
4657
strings.Join(firmwares.List(), " \n "))
4758

4859
}

internal/sigsum/sigsum.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type PubKey struct {
3434
}
3535

3636
func (p PubKey) String() string {
37-
return fmt.Sprintf("%v using app %v: %x\n Valid: %v-%v\n", p.Name, p.Tag, p.Key, p.Start.Format(time.RFC3339), p.End.Format(time.RFC3339))
37+
return fmt.Sprintf("%v using app %v: %x\n Valid: %v - %v\n", p.Name, p.Tag, p.Key, p.Start.Format(time.RFC3339), p.End.Format(time.RFC3339))
3838
}
3939

4040
type Log struct {
@@ -43,6 +43,23 @@ type Log struct {
4343
Policy *policy.Policy
4444
}
4545

46+
func (s *Log) String() string {
47+
var output string
48+
49+
output = "Logs:\n"
50+
for _, log := range s.Policy.GetLogsWithUrl() {
51+
output += fmt.Sprintf(" - Key: %x\n", log.PublicKey)
52+
output += fmt.Sprintf(" URL: %v\n\n", log.URL)
53+
}
54+
55+
output += "Submit keys:\n"
56+
for _, key := range s.Keys {
57+
output += fmt.Sprintf(" - %s", key)
58+
}
59+
60+
return output
61+
}
62+
4663
type State int
4764

4865
const (

0 commit comments

Comments
 (0)