Skip to content

Commit

Permalink
x509util: support Ed25519 public keys
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddrysdale committed Apr 30, 2022
1 parent 4beacb9 commit 9bc27bb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion x509util/x509util.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"bytes"
"crypto/dsa"
"crypto/ecdsa"
"crypto/ed25519"
"crypto/elliptic"
"crypto/rsa"
"encoding/base64"
Expand Down Expand Up @@ -103,6 +104,8 @@ func publicKeyAlgorithmToString(algo x509.PublicKeyAlgorithm) string {
return "dsaEncryption"
case x509.ECDSA:
return "id-ecPublicKey"
case x509.Ed25519:
return "Ed25519"
default:
return strconv.Itoa(int(algo))
}
Expand Down Expand Up @@ -174,8 +177,11 @@ func publicKeyToString(_ x509.PublicKeyAlgorithm, pub interface{}) string {
appendHexData(&buf, data, 15, " ")
buf.WriteString("\n")
buf.WriteString(fmt.Sprintf(" ASN1 OID: %s", oidname))
case ed25519.PublicKey:
buf.WriteString(" pub:\n")
appendHexData(&buf, []byte(pub), 15, " ")
default:
buf.WriteString(fmt.Sprintf("%v", pub))
buf.WriteString(fmt.Sprintf(" %T: %v", pub, pub))
}
return buf.String()
}
Expand Down

0 comments on commit 9bc27bb

Please sign in to comment.