aboutsummaryrefslogtreecommitdiff
path: root/client/cmd/cosign
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-06-06 15:59:35 +0200
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-06-06 15:59:35 +0200
commit47bacfd5c5d22470340e0823c4ad37b45914b68e (patch)
tree0984b55ced1e537e8d1d681c77157f1a47e47cdc /client/cmd/cosign
parent0285454c34b0b3003bc8ede3e304b843ad949be8 (diff)
started using the refactored packages in siglog server
Diffstat (limited to 'client/cmd/cosign')
-rw-r--r--client/cmd/cosign/main.go56
1 files changed, 0 insertions, 56 deletions
diff --git a/client/cmd/cosign/main.go b/client/cmd/cosign/main.go
deleted file mode 100644
index e86842b..0000000
--- a/client/cmd/cosign/main.go
+++ /dev/null
@@ -1,56 +0,0 @@
-package main
-
-import (
- "bytes"
- "crypto/ed25519"
- "encoding/hex"
- "flag"
- "fmt"
- "log"
- "net/http"
-
- "github.com/system-transparency/stfe/types"
-)
-
-var (
- url = flag.String("url", "http://localhost:6965/st/v0", "base url")
- sk = flag.String("sk", "e1d7c494dacb0ddf809a17e4528b01f584af22e3766fa740ec52a1711c59500d711090dd2286040b50961b0fe09f58aa665ccee5cb7ee042d819f18f6ab5046b", "hex key")
-)
-
-func main() {
- priv, err := hex.DecodeString(*sk)
- if err != nil {
- log.Fatalf("DecodeString: %v", err)
- }
- sk := ed25519.PrivateKey(priv)
- vk := sk.Public().(ed25519.PublicKey)
- fmt.Printf("sk: %x\nvk: %x\n", sk, vk)
-
- rsp, err := http.Get(*url + "/get-tree-head-to-sign")
- if err != nil {
- log.Fatalf("Get: %v", err)
- }
- var sth types.SignedTreeHead
- if err := sth.UnmarshalASCII(rsp.Body); err != nil {
- log.Fatalf("UnmarshalASCII: %v", err)
- }
- fmt.Printf("%+v\n", sth)
-
- msg := sth.TreeHead.Marshal()
- sig := ed25519.Sign(sk, msg)
- sigident := &types.SigIdent{
- KeyHash: types.Hash(vk[:]),
- Signature: &[types.SignatureSize]byte{},
- }
- copy(sigident.Signature[:], sig)
-
- buf := bytes.NewBuffer(nil)
- if err := sigident.MarshalASCII(buf); err != nil {
- log.Fatalf("MarshalASCII: %v", err)
- }
- rsp, err = http.Post(*url+"/add-cosignature", "type/stfe", buf)
- if err != nil {
- log.Fatalf("Post: %v", err)
- }
- fmt.Printf("Status: %v\n", rsp.StatusCode)
-}