Skip to content

Commit b07737f

Browse files
committed
x509util: support Ed25519 public keys
1 parent 1a82a65 commit b07737f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

x509util/x509util.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"bytes"
2121
"crypto/dsa"
2222
"crypto/ecdsa"
23+
"crypto/ed25519"
2324
"crypto/elliptic"
2425
"crypto/rsa"
2526
"encoding/base64"
@@ -103,6 +104,8 @@ func publicKeyAlgorithmToString(algo x509.PublicKeyAlgorithm) string {
103104
return "dsaEncryption"
104105
case x509.ECDSA:
105106
return "id-ecPublicKey"
107+
case x509.Ed25519:
108+
return "Ed25519"
106109
default:
107110
return strconv.Itoa(int(algo))
108111
}
@@ -174,8 +177,11 @@ func publicKeyToString(_ x509.PublicKeyAlgorithm, pub interface{}) string {
174177
appendHexData(&buf, data, 15, " ")
175178
buf.WriteString("\n")
176179
buf.WriteString(fmt.Sprintf(" ASN1 OID: %s", oidname))
180+
case ed25519.PublicKey:
181+
buf.WriteString(" pub:\n")
182+
appendHexData(&buf, []byte(pub), 15, " ")
177183
default:
178-
buf.WriteString(fmt.Sprintf("%v", pub))
184+
buf.WriteString(fmt.Sprintf(" %T: %v", pub, pub))
179185
}
180186
return buf.String()
181187
}

0 commit comments

Comments
 (0)