From 123c444ffd7a2ad2af58b62caad3ec7ae451256e Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Wed, 13 Apr 2022 16:54:25 +0200 Subject: clean-up sigsum tool structure --- cmd/sigsum/format/format.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 cmd/sigsum/format/format.go (limited to 'cmd/sigsum/format') diff --git a/cmd/sigsum/format/format.go b/cmd/sigsum/format/format.go new file mode 100644 index 0000000..eff7b3e --- /dev/null +++ b/cmd/sigsum/format/format.go @@ -0,0 +1,27 @@ +package format + +import ( + "fmt" + + "git.sigsum.org/sigsum-go/pkg/types" + "git.sigsum.org/sigsum-tools-go/internal/util" + "git.sigsum.org/sigsum-tools-go/pkg/policy" +) + +func Main(args []string, policy policy.Policy) error { + if len(args) != 1 { + return fmt.Errorf("format: must have one input file") + } + + preimage, err := util.FileHash(args[0]) + if err != nil { + return fmt.Errorf("format: preparing checksum: %v", err) + } + stm := types.Statement{ + ShardHint: policy.ShardHint(), + Checksum: *types.HashFn(preimage[:]), + } + + fmt.Printf("%s", stm.ToBinary()) + return nil +} -- cgit v1.2.3