Documentation ¶
Index ¶
- Constants
- Variables
- func ConvSSHPubKeyToRSAPubKey(key ssh.PublicKey) (*rsa.PublicKey, error)
- func DecryptAES256CBC(r io.Reader, w io.Writer, secret []byte) error
- func DecryptRSAEncodedSecret(key *rsa.PrivateKey, encodedEncryptedSecret string) ([]byte, error)
- func DecryptSecret(key *rsa.PrivateKey, encryptedSecret []byte) ([]byte, error)
- func EncryptAES256CBC(r io.Reader, w io.Writer, secret []byte) error
- func EncryptSecret(key *rsa.PublicKey, secret []byte) ([]byte, error)
- func EncryptSecretForAuthorities(auths []*RSAPublicKey, secret []byte) (snapCore.EncryptedSecretPair, error)
- func FindPubKeyInFile(path string, fp string) (*rsa.PublicKey, error)
- func GenSecret(sz int) ([]byte, error)
- func GetPublicRSAKeyByFingerprint(data []byte, fp string) (*rsa.PublicKey, error)
- func ReadPrivateSSHKeyFile(path string) (*rsa.PrivateKey, error)
- type RSAPrivateKeys
- type RSAPublicKey
Constants ¶
const ( DefaultAuthoritiesKeysFileName = "authorities_keys" )
const ( // AES256KeySize is the size of the AES256 key. AES256KeySize = 32 // OpenSSLSaltSize is the size of the salt used by OpenSSL. OpenSSLSaltSize = 8 // OpenSSLPDKF2Iter is the number of iterations used by OpenSSL. OpenSSLPDKF2Iter = 10000 // OpenSSLSaltedPrefix is the prefix used by OpenSSL. OpenSSLSaltedPrefix = "Salted__" )
const (
DefaultRealmsKeysFileName = "realms_keys"
)
Variables ¶
var ( ErrPKCS7DataIsNotAligned = errors.New("is not block-aligned") ErrPKCS7InvalidPadding = errors.New("invalid padding on input") )
var ( ErrKeyNotFound = errors.New("key not found") ErrKeyNotCryptoKey = errors.New("key is not a crypto key") ErrKeyNotRSAKey = errors.New("key is not a RSA key") )
var ( ErrSecretTooLong = errors.New("secret too long") ErrEmptySecret = errors.New("empty secret") )
var ( ErrDecodePEM = errors.New("unable to decode pem file") ErrNoRSAKey = errors.New("not an RSA private key") )
var (
ErrEmptyData = errors.New("empty data")
)
Errors
var ErrPKCS7BlockSize = errors.New("invalid pkcs7 block size")
var ErrSaltPrefixMismatch = errors.New("salt prefix mismatch")
Functions ¶
func ConvSSHPubKeyToRSAPubKey ¶
ConvSSHPubKeyToRSAPubKey returns the RSA public key from the ssh public key.
func DecryptAES256CBC ¶
DecryptAES256CBC aes-cbc-decrypts the data with the secret. openssl enc -d -aes-256-cbc -pass zzz ...
func DecryptRSAEncodedSecret ¶
func DecryptRSAEncodedSecret(key *rsa.PrivateKey, encodedEncryptedSecret string) ([]byte, error)
DecryptRSAEncodedSecret decrypts an encoded encrypted secret using a RSA private key. The result is aт original secret.
func DecryptSecret ¶
func DecryptSecret(key *rsa.PrivateKey, encryptedSecret []byte) ([]byte, error)
DecryptSecret decrypts the secret with the private key.
func EncryptAES256CBC ¶
EncryptAES256CBC aes-cbc-encrypts the data with the secret. openssl enc -aes-256-cbc -pass zzz ...
func EncryptSecret ¶
EncryptSecret encrypts the secret with the public key.
func EncryptSecretForAuthorities ¶
func EncryptSecretForAuthorities(auths []*RSAPublicKey, secret []byte) (snapCore.EncryptedSecretPair, error)
EncryptSecretForAuthorities encrypts the secret with each authority's public key. The result is a map of encrypted secrets and authority fingerprints.
func FindPubKeyInFile ¶
FindPubKeyInFile returns the public RSA key by fingerprint from the authorized_keys format file.
func GetPublicRSAKeyByFingerprint ¶
GetPublicRSAKeyByFingerprint returns the public RSA key by fingerprint from the authorized_keys format data.
func ReadPrivateSSHKeyFile ¶
func ReadPrivateSSHKeyFile(path string) (*rsa.PrivateKey, error)
Types ¶
type RSAPrivateKeys ¶
type RSAPrivateKeys struct { Key *rsa.PrivateKey FingerPrint string }
RSAPrivate is a map of RSA private keys.
type RSAPublicKey ¶
RSAPublicKey is a map of RSA public keys.
func GetRSAPublicKeysList ¶
func GetRSAPublicKeysList(data []byte) ([]*RSAPublicKey, error)
GetRSAPublicKeyList returns the list of RSA public keys from the authorized_keys format data.
func ReadAuthoritiesPubKeyFile ¶
func ReadAuthoritiesPubKeyFile(path string) ([]*RSAPublicKey, error)