v.io: v.io/x/ref/lib/security/internal Index | Files | Directories

package internal

import "v.io/x/ref/lib/security/internal"


Package Files



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")

func CopyKeyFile Uses

func CopyKeyFile(fromFile, toFile string) error

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

func CryptoKeyFromSSHKey Uses

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

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

func LoadPEMPrivateKey Uses

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 Uses

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

LoadPEMPublicKey loads a public key in PEM PKIX format.

func LoadPEMPublicKeyFile Uses

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

LoadPEMPublicKeyFile loads a public key file in PEM PKIX format.

func LoadSSHPublicKey Uses

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

LoadSSHPublicKey loads a public key in SSH authorized hosts format.

func LoadSSHPublicKeyFile Uses

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

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

func ParseECDSAKey Uses

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

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

func ParseED25519Key Uses

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

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

func SavePEMKeyPair Uses

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 Uses

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

WritePEMKeyPair writes a key pair in pem format.


lockedfilePackage lockedfile creates and manipulates files whose contents should only change atomically.
lockedfile/filelockPackage filelock provides a platform-independent API for advisory file locking.

Package internal imports 13 packages (graph) and is imported by 8 packages. Updated 2020-10-24. Refresh now. Tools for package owners.