aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorLibravatar Rutger Broekhoff2023-12-30 15:49:47 +0100
committerLibravatar Rutger Broekhoff2023-12-30 15:49:47 +0100
commitdc85c97f3730b066f3603081d21df67349f9a84d (patch)
treecf4b3af533ddd9cfec39dee4a1c36a93eeed7013 /cmd
parenta8726abf0b61327190204446974c073d8a64f102 (diff)
downloadgitolfs3-dc85c97f3730b066f3603081d21df67349f9a84d.tar.gz
gitolfs3-dc85c97f3730b066f3603081d21df67349f9a84d.zip
Add command for generating ED25519 keypairs
Diffstat (limited to 'cmd')
-rw-r--r--cmd/gitolfs3-gen-ed25519-key/main.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/cmd/gitolfs3-gen-ed25519-key/main.go b/cmd/gitolfs3-gen-ed25519-key/main.go
new file mode 100644
index 0000000..8288fd1
--- /dev/null
+++ b/cmd/gitolfs3-gen-ed25519-key/main.go
@@ -0,0 +1,31 @@
1package main
2
3import (
4 "crypto/ed25519"
5 "crypto/rand"
6 "encoding/hex"
7 "fmt"
8 "os"
9)
10
11func wipe(b []byte) {
12 for i := range b {
13 b[i] = 0
14 }
15}
16
17func main() {
18 publicKey, privateKey, err := ed25519.GenerateKey(rand.Reader)
19 if err != nil {
20 fmt.Fprintf(os.Stderr, "Failed to generate ED25519 key: %s", err)
21 os.Exit(1)
22 }
23 defer wipe(privateKey)
24
25 enc := hex.NewEncoder(os.Stdout)
26 print("Public ")
27 enc.Write(publicKey)
28 print("\nPrivate ")
29 enc.Write(privateKey.Seed())
30 println()
31}