parsePublicKeyBlock parses any allowed type public key. Currently only allows parsing ed25519 type public keys.
(derKey []byte)
| 123 | |
| 124 | // parsePublicKeyBlock parses any allowed type public key. Currently only allows parsing ed25519 type public keys. |
| 125 | func parsePublicKeyBlock(derKey []byte) (crypto.PublicKey, error) { |
| 126 | if keyInterface, err := x509.ParsePKIXPublicKey(derKey); err == nil { |
| 127 | switch typedKey := keyInterface.(type) { |
| 128 | case ed25519.PublicKey: |
| 129 | return typedKey, nil |
| 130 | default: |
| 131 | return nil, fmt.Errorf("signingalgorithm: unknown public key type: %T", typedKey) |
| 132 | } |
| 133 | } |
| 134 | return nil, errors.New("signingalgorithm: couldn't parse public key.") |
| 135 | } |