-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.go
More file actions
177 lines (167 loc) · 3.67 KB
/
Copy pathmain.go
File metadata and controls
177 lines (167 loc) · 3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
package main
import (
"log"
"os"
"runtime/pprof"
"github.com/urfave/cli"
)
func main() {
var cpuProfileFile *os.File
app := cli.NewApp()
app.Version = "1.1.0"
app.Usage = "Create and verify XMSS[MT] signatures"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "cpuprofile, p",
Usage: "write cpu profile to `FILE`",
},
}
app.Commands = []cli.Command{
{
Name: "algs",
Usage: "List XMSS[MT] instances",
Action: cmdAlgs,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "non-std, n",
Usage: "Include instances which are not listed in the RFC " +
"or NIST standard",
},
},
},
{
Name: "generate",
Usage: "Generate an XMSS[MT] keypair",
Action: cmdGenerate,
Flags: []cli.Flag{
cli.StringFlag{
Name: "alg, a",
Usage: "XMSS[MT] named instance to use, see `xmssmt algs'",
Value: "XMSSMT-SHAKE_40/4_256",
},
cli.IntFlag{
Name: "n",
Usage: "Override security parameter n",
Value: 32,
},
cli.IntFlag{
Name: "w",
Usage: "Override Winternitz parameter w",
Value: 16,
},
cli.IntFlag{
Name: "full-height, t",
Usage: "Override full tree height parameter",
Value: 40,
},
cli.IntFlag{
Name: "d",
Usage: "Override height-of-hypertree paramater d",
Value: 4,
},
cli.BoolFlag{
Name: "force, f",
Usage: "Override existing files",
},
cli.StringFlag{
Name: "hash, H",
Usage: "Override hash function to use. (shake, shake256 or sha2)",
Value: "shake",
},
cli.StringFlag{
Name: "prf, P",
Usage: "Override prf function to use. (rfc or nist)",
},
cli.StringFlag{
Name: "privkey, s",
Usage: "Path to store private key at",
Value: "xmssmt.key",
},
cli.StringFlag{
Name: "pubkey, p",
Usage: "Path to store public key at",
Value: "xmssmt.pub",
},
},
},
{
Name: "sign",
Usage: "Create an XMSS[MT] signature",
Action: cmdSign,
Flags: []cli.Flag{
cli.StringFlag{
Name: "privkey, s",
Usage: "Use private key stored at `FILE`",
Value: "xmssmt.key",
},
cli.StringFlag{
Name: "file, f",
Usage: "Create a signature of `FILE`",
},
cli.StringFlag{
Name: "output, o",
Usage: "Write signature to `FILE`",
},
},
},
{
Name: "verify",
Usage: "Verifies an XMSS[MT] signature",
Action: cmdVerify,
Flags: []cli.Flag{
cli.StringFlag{
Name: "pubkey, p",
Usage: "Path to read public key from `FILE`",
Value: "xmssmt.pub",
},
cli.StringFlag{
Name: "file, f",
Usage: "Reads message from `FILE`",
},
cli.StringFlag{
Name: "signature, S",
Usage: "Reads signature from `FILE`",
},
},
},
{
Name: "speed",
Usage: "Benchmark XMSS[MT] instances",
Action: cmdSpeed,
Flags: []cli.Flag{
cli.StringFlag{
Name: "alg, a",
Usage: "Benchmark instance named `NAME`",
},
cli.BoolFlag{
Name: "cwd",
Usage: "Look for existing key in current working directory",
},
cli.BoolFlag{
Name: "non-std, n",
Usage: "Include instances which are not listed in the " +
"RFC or NIST standard",
},
},
},
}
app.Before = func(c *cli.Context) error {
if cpuProfilePath := c.String("cpuprofile"); cpuProfilePath != "" {
var err error
cpuProfileFile, err = os.Create(cpuProfilePath)
if err != nil {
log.Fatalf("os.Create(): %v", err)
}
pprof.StartCPUProfile(cpuProfileFile)
}
return nil
}
app.After = func(c *cli.Context) error {
if cpuProfileFile != nil {
pprof.StopCPUProfile()
cpuProfileFile.Close()
}
return nil
}
app.Run(os.Args)
}