Skip to content

Commit ae2e096

Browse files
committed
ssh-tpm-keygen: add --supported switch to list supported bit lengths
Signed-off-by: Morten Linderud <[email protected]>
1 parent d3c049b commit ae2e096

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

cmd/ssh-tpm-keygen/main.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Options:
3939
ecdsa: 256 (default) | 384 | 521
4040
-I, --import PATH Import existing key into ssh-tpm-agent.
4141
-A Generate host keys for all key types (rsa and ecdsa).
42+
--supported List the supported keys of the TPM.
4243
4344
Generate new TPM sealed keys for ssh-tpm-agent.
4445
@@ -102,6 +103,7 @@ func main() {
102103
keyType, importKey string
103104
bits int
104105
swtpmFlag, hostKeys bool
106+
listsupported bool
105107
)
106108

107109
defaultComment := func() string {
@@ -129,6 +131,7 @@ func main() {
129131
flag.StringVar(&importKey, "import", "", "import key")
130132
flag.BoolVar(&swtpmFlag, "swtpm", false, "use swtpm instead of actual tpm")
131133
flag.BoolVar(&hostKeys, "A", false, "generate host keys")
134+
flag.BoolVar(&listsupported, "supported", false, "list tpm caps")
132135

133136
flag.Parse()
134137

@@ -138,6 +141,16 @@ func main() {
138141
}
139142
defer tpm.Close()
140143

144+
if listsupported {
145+
fmt.Printf("ecdsa bit lengths:")
146+
for _, alg := range key.SupportedECCAlgorithms(tpm) {
147+
fmt.Printf(" %d", alg)
148+
}
149+
fmt.Println()
150+
fmt.Println("rsa bit lengths: 2048")
151+
os.Exit(0)
152+
}
153+
141154
// Generate host keys
142155
if hostKeys {
143156
// Mimics the `ssh-keygen -A -f ./something` behaviour

0 commit comments

Comments
 (0)