aboutsummaryrefslogtreecommitdiff
path: root/cmd/sigsum/format
diff options
context:
space:
mode:
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
+}