Documentation ¶
Overview ¶
Package key contains the common functions to parse and create keys. TODO: It also defines the public key algorithms supported by RA.
Index ¶
- Variables
- func CastSSHPublicKeyToAgentKey(key ssh.PublicKey) *agent.Key
- func CastSSHPublicKeyToCertificate(key ssh.PublicKey) (*ssh.Certificate, error)
- func GenerateKeyPair(pka PublicKeyAlgo) (crypto.PrivateKey, ssh.PublicKey, error)
- func GetPrivateKeyFromFile(file string) (interface{}, error)
- func GetPublicKeyFromFile(file string) (key ssh.PublicKey, comment string, err error)
- func GetPublicKeysFromBytes(data []byte) (keys []ssh.PublicKey, comments []string, err error)
- func GetPublicKeysFromFile(file string) (keys []ssh.PublicKey, comments []string, err error)
- type PublicKeyAlgo
Constants ¶
This section is empty.
Variables ¶
var SSHKeyAlgoStrMap = map[string]PublicKeyAlgo{ "RSA2048": RSA2048, "RSA4096": RSA4096, "ECCP256": ECDSAsecp256r1, "ECCP384": ECDSAsecp384r1, "ECCP521": ECDSAsecp521r1, "ED25519": ED25519, }
SSHKeyAlgoStrMap contains the mapping from strings to supported public key algorithms.
Functions ¶
func CastSSHPublicKeyToAgentKey ¶
CastSSHPublicKeyToAgentKey casts any types of SSH PublicKey to *agent.Key.
func CastSSHPublicKeyToCertificate ¶
func CastSSHPublicKeyToCertificate(key ssh.PublicKey) (*ssh.Certificate, error)
CastSSHPublicKeyToCertificate casts any types of SSH PublicKey to *ssh.Certificate; otherwise, an error is returned.
func GenerateKeyPair ¶
func GenerateKeyPair(pka PublicKeyAlgo) (crypto.PrivateKey, ssh.PublicKey, error)
GenerateKeyPair returns a new pair of keys for the specified algorithm. Caller should cast the returned private key to one of *rsa.PrivateKey, *ecdsa.PrivateKey or *ed25519.PrivateKey depending on the specified input.
func GetPrivateKeyFromFile ¶
GetPrivateKeyFromFile reads the private key from file and returns *rsa.PrivateKey, *dsa.PrivateKey or *ecdsa.PrivateKeyrsa; otherwise, an error is returned.
func GetPublicKeyFromFile ¶
GetPublicKeyFromFile returns the first SSH public key from the given file; otherwise, an error is returned.
func GetPublicKeysFromBytes ¶
GetPublicKeysFromBytes returns a slice of SSH public keys from the given data chunk.
Types ¶
type PublicKeyAlgo ¶
type PublicKeyAlgo int
PublicKeyAlgo is used to specify public key algorithm for the key pair in ssh-agent.
const ( RSA2048 PublicKeyAlgo = iota RSA4096 ECDSAsecp256r1 ECDSAsecp384r1 ECDSAsecp521r1 // ED25519 is not supported in yubico hardware keys currently. ED25519 )
List of supported public key algorithms.
func GetSSHKeyAlgo ¶ added in v0.0.13
func GetSSHKeyAlgo(keyType string) (PublicKeyAlgo, error)
GetSSHKeyAlgo returns a specific public key algorithm by the given algo string. It returns RSA2048 and an error if no valid algorithms found.
func (PublicKeyAlgo) String ¶ added in v0.0.13
func (p PublicKeyAlgo) String() string
String stringifies the PublicKeyAlgo.