aboutsummaryrefslogtreecommitdiff
path: root/cmd/tmp/dns
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-10-02 20:23:51 +0200
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2021-10-02 20:23:51 +0200
commitcc75064317725f5b4d58b8b364dbf0c9c431ec3e (patch)
tree7ee92c65d4340ecf910d0c966087f1b5a0ec404a /cmd/tmp/dns
parent01d7bd4785be2c82cc4765ba6e27cbcf61188862 (diff)
added domain_hint enforcementv0.3.0
Diffstat (limited to 'cmd/tmp/dns')
-rw-r--r--cmd/tmp/dns/main.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/cmd/tmp/dns/main.go b/cmd/tmp/dns/main.go
new file mode 100644
index 0000000..b493f15
--- /dev/null
+++ b/cmd/tmp/dns/main.go
@@ -0,0 +1,42 @@
+package main
+
+import (
+ "context"
+ "encoding/hex"
+ "flag"
+ "fmt"
+ "log"
+
+ "git.sigsum.org/sigsum-log-go/pkg/dns"
+ "git.sigsum.org/sigsum-log-go/pkg/types"
+)
+
+var (
+ vk = flag.String("vk", "5aed7ffc3bc088221f6579567b2e6e3c4ac3579bd5e77670755179052c68d5d3", "verification key (hex)")
+ domain_hint = flag.String("domain_hint", "example.com", "domain name that is aware of public key hash in hex")
+)
+
+func main() {
+ flag.Parse()
+
+ var key [types.VerificationKeySize]byte
+ mustDecodeHex(*vk, key[:])
+
+ vf := dns.NewDefaultResolver()
+ if err := vf.Verify(context.Background(), *domain_hint, &key); err != nil {
+ log.Fatal(err)
+ }
+
+ fmt.Println("Success!")
+}
+
+func mustDecodeHex(s string, buf []byte) {
+ b, err := hex.DecodeString(s)
+ if err != nil {
+ log.Fatal(err)
+ }
+ if len(b) != len(buf) {
+ log.Fatal("bad flag: invalid buffer length")
+ }
+ copy(buf, b)
+}