internal

package
v0.1.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2022 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBadPassphrase is a possible return error from LoadPEMPrivateKey()
	ErrBadPassphrase = errors.New("passphrase incorrect for decrypting private key")

	// ErrPassphraseRequired is a possible return error from LoadPEMPrivateKey()
	ErrPassphraseRequired = errors.New("passphrase required for decrypting private key")
)

Functions

func CopyKeyFile

func CopyKeyFile(fromFile, toFile string) error

CopyKeyFile copies a keyfile, it wqill fail if it can't overwrite an existing file.

func CryptoKeyFromSSHKey

func CryptoKeyFromSSHKey(pk ssh.PublicKey) (interface{}, error)

CryptoKeyFromSSHKey returns one of *ecdsa.PublicKey or ed25519.PublicKey from the the supplied ssh PublicKey.

func LoadPEMPrivateKey

func LoadPEMPrivateKey(r io.Reader, passphrase []byte) (interface{}, error)

loadPEMPrivateKey loads a key from 'r'. returns ErrBadPassphrase for incorrect Passphrase. If the key held in 'r' is unencrypted, 'passphrase' will be ignored.

func LoadPEMPublicKey

func LoadPEMPublicKey(r io.Reader) (interface{}, error)

LoadPEMPublicKey loads a public key in PEM PKIX format.

func LoadPEMPublicKeyFile

func LoadPEMPublicKeyFile(filename string) (interface{}, error)

LoadPEMPublicKeyFile loads a public key file in PEM PKIX format.

func LoadSSHPublicKey

func LoadSSHPublicKey(r io.Reader) (ssh.PublicKey, string, error)

LoadSSHPublicKey loads a public key in SSH authorized hosts format.

func LoadSSHPublicKeyFile

func LoadSSHPublicKeyFile(filename string) (ssh.PublicKey, string, error)

LoadSSHPublicKeyFile loads a public key file in SSH authorized hosts format.

func ParseECDSAKey

func ParseECDSAKey(key ssh.PublicKey) (*ecdsa.PublicKey, error)

ParseECDSAKey creates an ecdsa.PublicKey from an ssh ECDSA key.

func ParseED25519Key

func ParseED25519Key(key ssh.PublicKey) (ed25519.PublicKey, error)

ParseED25519Key creates an ed25519.PublicKey from an ssh ED25519 key.

func SavePEMKeyPair

func SavePEMKeyPair(private, public io.Writer, key interface{}, passphrase []byte) error

SavePEMKey marshals 'key', encrypts it using 'passphrase', and saves the bytes to 'w' in PEM format. If passphrase is nil, the key will not be encrypted.

For example, if key is an ECDSA private key, it will be marshaled in ASN.1, DER format, encrypted, and then written in a PEM block.

func WritePEMKeyPair

func WritePEMKeyPair(key interface{}, privateKeyFile, publicKeyFile string, passphrase []byte) error

WritePEMKeyPair writes a key pair in pem format.

Types

This section is empty.

Directories

Path Synopsis
Package lockedfile creates and manipulates files whose contents should only change atomically.
Package lockedfile creates and manipulates files whose contents should only change atomically.
filelock
Package filelock provides a platform-independent API for advisory file locking.
Package filelock provides a platform-independent API for advisory file locking.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL