aboutsummaryrefslogtreecommitdiff
path: root/cmd/sigsum-debug
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus@mullvad.net>2022-04-23 18:44:09 +0200
committerRasmus Dahlberg <rasmus@mullvad.net>2022-04-23 18:44:09 +0200
commitcc9bb6a069d62ed37b7f4866d6dfe37049dc1cf1 (patch)
tree3dc49efe0e0690656897dc8562da6b7cbc41c9ea /cmd/sigsum-debug
parent2c28b4209be2ced9a18c20347e1819a24a45cb66 (diff)
remove sigsum-debug (pending merge in sigsum-go)HEADmain
Diffstat (limited to 'cmd/sigsum-debug')
-rw-r--r--cmd/sigsum-debug/cosign/cosign.go41
-rw-r--r--cmd/sigsum-debug/genkey/genkey.go19
-rw-r--r--cmd/sigsum-debug/hashkey/hashkey.go25
-rw-r--r--cmd/sigsum-debug/hashleaf/hashleaf.go39
-rw-r--r--cmd/sigsum-debug/main.go114
-rw-r--r--cmd/sigsum-debug/pubkey/pubkey.go28
-rw-r--r--cmd/sigsum-debug/sign/sign.go32
7 files changed, 0 insertions, 298 deletions
diff --git a/cmd/sigsum-debug/cosign/cosign.go b/cmd/sigsum-debug/cosign/cosign.go
deleted file mode 100644
index 8597cc6..0000000
--- a/cmd/sigsum-debug/cosign/cosign.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package cosign
-
-import (
- "bytes"
- "fmt"
-
- "git.sigsum.org/sigsum-go/pkg/hex"
- "git.sigsum.org/sigsum-go/pkg/types"
- "git.sigsum.org/sigsum-tools-go/internal/util"
-)
-
-func Main(_ []string, optPriv, optPub string) error {
- priv, err := util.SignerFromHex(optPriv)
- if err != nil {
- return fmt.Errorf("cosign: %v", err)
- }
- b, err := hex.Deserialize(optPub)
- if err != nil {
- return fmt.Errorf("cosign: %v", err)
- }
- if len(b) != types.PublicKeySize {
- return fmt.Errorf("cosign: invalid public key length %d", len(b))
- }
- var pub types.PublicKey
- copy(pub[:], b)
- data, err := util.BytesFromStdin()
- if err != nil {
- return fmt.Errorf("cosign: %v", err)
- }
- var sth types.SignedTreeHead
- if err := sth.FromASCII(bytes.NewBuffer(data)); err != nil {
- return fmt.Errorf("cosign: %v", err)
- }
- witSTH, err := sth.TreeHead.Sign(priv, types.HashFn(pub[:]))
- if err != nil {
- return fmt.Errorf("cosign: %v", err)
- }
-
- fmt.Printf("%s\n", hex.Serialize(witSTH.Signature[:]))
- return nil
-}
diff --git a/cmd/sigsum-debug/genkey/genkey.go b/cmd/sigsum-debug/genkey/genkey.go
deleted file mode 100644
index 5f71e41..0000000
--- a/cmd/sigsum-debug/genkey/genkey.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package genkey
-
-import (
- "crypto/ed25519"
- "crypto/rand"
- "fmt"
-
- "git.sigsum.org/sigsum-go/pkg/hex"
-)
-
-func Main(_ []string) error {
- _, priv, err := ed25519.GenerateKey(rand.Reader)
- if err != nil {
- return fmt.Errorf("genkey: %v", err)
- }
-
- fmt.Printf("%s\n", hex.Serialize(priv[:]))
- return nil
-}
diff --git a/cmd/sigsum-debug/hashkey/hashkey.go b/cmd/sigsum-debug/hashkey/hashkey.go
deleted file mode 100644
index f195239..0000000
--- a/cmd/sigsum-debug/hashkey/hashkey.go
+++ /dev/null
@@ -1,25 +0,0 @@
-package hashkey
-
-import (
- "crypto/ed25519"
- "fmt"
-
- "git.sigsum.org/sigsum-go/pkg/hex"
- "git.sigsum.org/sigsum-go/pkg/types"
- "git.sigsum.org/sigsum-tools-go/internal/util"
-)
-
-func Main(_ []string) error {
- b, err := util.HexFromStdin()
- if err != nil {
- return fmt.Errorf("hashkey: %v", err)
- }
- if len(b) != ed25519.PublicKeySize {
- return fmt.Errorf("hashkey: invalid private key size %d", len(b))
- }
- pub := ed25519.PublicKey(b)
- keyHash := types.HashFn(pub)
-
- fmt.Printf("%s\n", hex.Serialize(keyHash[:]))
- return nil
-}
diff --git a/cmd/sigsum-debug/hashleaf/hashleaf.go b/cmd/sigsum-debug/hashleaf/hashleaf.go
deleted file mode 100644
index 0f5d3e3..0000000
--- a/cmd/sigsum-debug/hashleaf/hashleaf.go
+++ /dev/null
@@ -1,39 +0,0 @@
-package hashleaf
-
-import (
- "crypto/ed25519"
- "fmt"
-
- "git.sigsum.org/sigsum-go/pkg/hex"
- "git.sigsum.org/sigsum-go/pkg/types"
- "git.sigsum.org/sigsum-tools-go/internal/util"
-)
-
-func Main(_ []string, optPriv string, optShardHint uint64) error {
- data, err := util.BytesFromStdin()
- if err != nil {
- return fmt.Errorf("sign: %v", err)
- }
- priv, err := util.SignerFromHex(optPriv)
- if err != nil {
- return fmt.Errorf("sign: %v", err)
- }
- preimage := types.HashFn(data)
- stm := types.Statement{
- ShardHint: optShardHint,
- Checksum: *types.HashFn(preimage[:]),
- }
- sig, err := stm.Sign(priv)
- if err != nil {
- fmt.Errorf("sign: %v", err)
- }
- leaf := types.Leaf{
- Statement: stm,
- Signature: *sig,
- KeyHash: *types.HashFn(priv.Public().(ed25519.PublicKey)[:]),
- }
- lh := types.LeafHash(leaf.ToBinary())
-
- fmt.Printf("%s\n", hex.Serialize(lh[:]))
- return nil
-}
diff --git a/cmd/sigsum-debug/main.go b/cmd/sigsum-debug/main.go
deleted file mode 100644
index fe13cfd..0000000
--- a/cmd/sigsum-debug/main.go
+++ /dev/null
@@ -1,114 +0,0 @@
-// package main provides a tool named sigsum-debug.
-//
-// Build as follows:
-//
-// $ go build -ldflags="-X 'main.someVersion=git commit $(git rev-list -1 HEAD)'"
-// $ mv sigsum-debug $GOPATH/bin/
-//
-// Usage:
-//
-// $ sigsum-debug help
-//
-package main
-
-import (
- "flag"
- "fmt"
- "log"
- "os"
-
- "git.sigsum.org/sigsum-tools-go/cmd/sigsum-debug/cosign"
- "git.sigsum.org/sigsum-tools-go/cmd/sigsum-debug/genkey"
- "git.sigsum.org/sigsum-tools-go/cmd/sigsum-debug/hashkey"
- "git.sigsum.org/sigsum-tools-go/cmd/sigsum-debug/hashleaf"
- "git.sigsum.org/sigsum-tools-go/cmd/sigsum-debug/pubkey"
- "git.sigsum.org/sigsum-tools-go/cmd/sigsum-debug/sign"
- "git.sigsum.org/sigsum-tools-go/internal/options"
-)
-
-const usage = `sigsum-debug version %s
-
-Usage:
- sigsum-debug help
- Outputs a usage message.
-
- sigsum-debug genkey
- Outputs a new private key.
-
- sigsum-debug pubkey
- Reads a private key from stdin and output its public key.
-
- sigsum-debug hashkey
- Reads a public key from stdin and output its key hash.
-
- sigsum-debug hashleaf -k PRIVATE_KEY [-s SHARD_HINT]
- Reads data from STDIN and outputs a leaf hash.
- -k, --private-key Private key to sign with
- -s, --shard-hint Shard hint to use (Default: 0)
-
- sigsum-debug sign -k PRIVATE_KEY [-s SHARD_HINT]
- Reads data from STDIN and outputs a signature.
- -k, --private-key Private key to sign with
- -s, --shard-hint Shard hint to use (Default: 0)
-
- sigsum-debug cosign -w WIT_PRIV -l LOG_PUB
- Reads an ASCII signed tree head from STDIN and outputs a cosignature.
- -w, --witness-priv Witness private key to sign with
- -l, --log-pub Log public key to verify signed tree head
-`
-
-var (
- optPriv string
- optPub string
- optShardHint uint64
-
- someVersion = "devel"
-)
-
-func main() {
- log.SetFlags(0)
-
- var err error
- cmd := options.Parse(printUsage, setOptions)
- switch cmd.Name() {
- case "help":
- cmd.Usage()
- case "genkey":
- err = genkey.Main(cmd.Args())
- case "pubkey":
- err = pubkey.Main(cmd.Args())
- case "hashkey":
- err = hashkey.Main(cmd.Args())
- case "hashleaf":
- err = hashleaf.Main(cmd.Args(), optPriv, optShardHint)
- case "sign":
- err = sign.Main(cmd.Args(), optPriv, optShardHint)
- case "cosign":
- err = cosign.Main(cmd.Args(), optPriv, optPub)
- default:
- err = fmt.Errorf("invalid command %q, try %q", cmd.Name(), "sigsum help")
- }
-
- if err != nil {
- log.Printf("%s", err)
- os.Exit(1)
- }
-}
-
-func printUsage() {
- log.Printf(usage, someVersion)
-}
-
-func setOptions(fs *flag.FlagSet) {
- switch cmd := fs.Name(); cmd {
- case "hashleaf":
- options.AddString(fs, &optPriv, "k", "key", "")
- options.AddUint64(fs, &optShardHint, "s", "shard-hint", 0)
- case "sign":
- options.AddString(fs, &optPriv, "k", "key", "")
- options.AddUint64(fs, &optShardHint, "s", "shard-hint", 0)
- case "cosign":
- options.AddString(fs, &optPriv, "w", "witness-priv", "")
- options.AddString(fs, &optPub, "l", "log-pub", "")
- }
-}
diff --git a/cmd/sigsum-debug/pubkey/pubkey.go b/cmd/sigsum-debug/pubkey/pubkey.go
deleted file mode 100644
index 8f3b467..0000000
--- a/cmd/sigsum-debug/pubkey/pubkey.go
+++ /dev/null
@@ -1,28 +0,0 @@
-package pubkey
-
-import (
- "crypto/ed25519"
- "fmt"
-
- "git.sigsum.org/sigsum-go/pkg/hex"
- "git.sigsum.org/sigsum-tools-go/internal/util"
-)
-
-func Main(_ []string) error {
- b, err := util.HexFromStdin()
- if err != nil {
- return err
- }
- if len(b) != ed25519.PrivateKeySize {
- return fmt.Errorf("pubkey: invalid key size %d", len(b))
- }
-
- priv := ed25519.PrivateKey(b)
- pub, ok := priv.Public().(ed25519.PublicKey)
- if !ok {
- return fmt.Errorf("pubkey: must parse as ed25519")
- }
-
- fmt.Printf("%s\n", hex.Serialize(pub[:]))
- return nil
-}
diff --git a/cmd/sigsum-debug/sign/sign.go b/cmd/sigsum-debug/sign/sign.go
deleted file mode 100644
index c984cb5..0000000
--- a/cmd/sigsum-debug/sign/sign.go
+++ /dev/null
@@ -1,32 +0,0 @@
-package sign
-
-import (
- "fmt"
-
- "git.sigsum.org/sigsum-go/pkg/hex"
- "git.sigsum.org/sigsum-go/pkg/types"
- "git.sigsum.org/sigsum-tools-go/internal/util"
-)
-
-func Main(_ []string, optPriv string, optShardHint uint64) error {
- data, err := util.BytesFromStdin()
- if err != nil {
- return fmt.Errorf("sign: %v", err)
- }
- priv, err := util.SignerFromHex(optPriv)
- if err != nil {
- return fmt.Errorf("sign: %v", err)
- }
- preimage := types.HashFn(data)
- stm := types.Statement{
- ShardHint: optShardHint,
- Checksum: *types.HashFn(preimage[:]),
- }
- sig, err := stm.Sign(priv)
- if err != nil {
- fmt.Errorf("sign: %v", err)
- }
-
- fmt.Printf("%s\n", hex.Serialize(sig[:]))
- return nil
-}