const ECPrivateKeyBlockType … const RSAPrivateKeyBlockType … const PrivateKeyBlockType … const PublicKeyBlockType … // MakeEllipticPrivateKeyPEM creates an ECDSA private key func MakeEllipticPrivateKeyPEM() ([]byte, error) { … } // WriteKey writes the pem-encoded key data to keyPath. // The key file will be created with file mode 0600. // If the key file already exists, it will be overwritten. // The parent directory of the keyPath will be created as needed with file mode 0755. func WriteKey(keyPath string, data []byte) error { … } // LoadOrGenerateKeyFile looks for a key in the file at the given path. If it // can't find one, it will generate a new key and store it there. func LoadOrGenerateKeyFile(keyPath string) (data []byte, wasGenerated bool, err error) { … } // MarshalPrivateKeyToPEM converts a known private key type of RSA or ECDSA to // a PEM encoded block or returns an error. func MarshalPrivateKeyToPEM(privateKey crypto.PrivateKey) ([]byte, error) { … } // PrivateKeyFromFile returns the private key in rsa.PrivateKey or ecdsa.PrivateKey format from a given PEM-encoded file. // Returns an error if the file could not be read or if the private key could not be parsed. func PrivateKeyFromFile(file string) (interface{ … } // PublicKeysFromFile returns the public keys in rsa.PublicKey or ecdsa.PublicKey format from a given PEM-encoded file. // Reads public keys from both public and private key files. func PublicKeysFromFile(file string) ([]interface{ … } // verifyKeyData returns true if the provided data appears to be a valid private key. func verifyKeyData(data []byte) bool { … } // ParsePrivateKeyPEM returns a private key parsed from a PEM block in the supplied data. // Recognizes PEM blocks for "EC PRIVATE KEY", "RSA PRIVATE KEY", or "PRIVATE KEY" func ParsePrivateKeyPEM(keyData []byte) (interface{ … } // ParsePublicKeysPEM is a helper function for reading an array of rsa.PublicKey or ecdsa.PublicKey from a PEM-encoded byte array. // Reads public keys from both public and private key files. func ParsePublicKeysPEM(keyData []byte) ([]interface{ … } // parseRSAPublicKey parses a single RSA public key from the provided data func parseRSAPublicKey(data []byte) (*rsa.PublicKey, error) { … } // parseRSAPrivateKey parses a single RSA private key from the provided data func parseRSAPrivateKey(data []byte) (*rsa.PrivateKey, error) { … } // parseECPublicKey parses a single ECDSA public key from the provided data func parseECPublicKey(data []byte) (*ecdsa.PublicKey, error) { … } // parseECPrivateKey parses a single ECDSA private key from the provided data func parseECPrivateKey(data []byte) (*ecdsa.PrivateKey, error) { … }