aboutsummaryrefslogtreecommitdiff
path: root/cmd/sigsum/format
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus@mullvad.net>2022-04-13 16:54:25 +0200
committerRasmus Dahlberg <rasmus@mullvad.net>2022-04-13 16:54:25 +0200
commit123c444ffd7a2ad2af58b62caad3ec7ae451256e (patch)
treeb01d0a849de9045defc9a9505bfb7b0110a34a8d /cmd/sigsum/format
parentb1bcc5d12fc57f0d39f3dadc0d159f4c71ae37d7 (diff)
clean-up sigsum tool structure
Diffstat (limited to 'cmd/sigsum/format')
-rw-r--r--cmd/sigsum/format/format.go27
1 files changed, 27 insertions, 0 deletions
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
+}