Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrIncorrectPassword = x509.IncorrectPasswordError
ErrIncorrectPassword is returned when the supplied passphrase was not correct for an encrypted private key.
Functions ¶
func Marshal ¶
func Marshal(pk interface{}, opts *MarshalOptions) ([]byte, error)
Marshal converts a private key into an optionally encrypted format.
func ParseEncryptedPrivateKey ¶
ParseEncryptedPrivateKey returns a Signer from an encrypted private key. It supports the same keys as ParseEncryptedRawPrivateKey.
func ParseEncryptedRawPrivateKey ¶
ParseEncryptedRawPrivateKey returns a private key from an encrypted private key. It supports RSA (PKCS#1 or OpenSSH), DSA (OpenSSL), and ECDSA private keys.
ErrIncorrectPassword will be returned if the supplied passphrase is wrong, but some formats like RSA in PKCS#1 detecting a wrong passphrase is difficult, and other parse errors may be returned.
Types ¶
type Format ¶
type Format int
Format of private key to use when Marshaling.
const ( // FormatOpenSSHv1 encodes a private key using OpenSSH's PROTOCOL.key format: https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key FormatOpenSSHv1 Format = iota // FormatClassicPEM encodes private keys in PEM, with a key-specific encoding, as used by OpenSSH. FormatClassicPEM )
type MarshalOptions ¶
type MarshalOptions struct { // Passphrase to encrypt private key with, if nil, the key will not be encrypted. Passphrase []byte // Format to encode the private key in. Format Format }
MarshalOptions provides the Marshal function format and encryption options.