Versions in this module Expand all Collapse all v1 v1.0.1 May 8, 2026 Changes in this version + var AES128CBC = CipherCBC + var AES128CTR = CipherCTR + var AES128GCM = CipherGCM + var AES192CBC = CipherCBC + var AES192CTR = CipherCTR + var AES256CBC = CipherCBC + var AES256CTR = CipherCTR + var AES256GCM = CipherGCM + var Arcfour = CipherRC4 + var Arcfour128 = CipherRC4 + var Arcfour256 = CipherRC4 + var BlowfishCBC = CipherCBC + var Cast128CBC = CipherCBC + var Chacha20poly1305 = CipherChacha20poly1305 + var DESEDE3CBC = CipherCBC + var DefaultOpts = Opts + var KeyAlgoSM2 = "ssh-sm2" + var SM4CBC = CipherCBC + var SM4CTR = CipherCTR + var SSHAES128CBC = "aes128-cbc" + var SSHAES128CTR = "aes128-ctr" + var SSHAES128GCM = "aes128-gcm@openssh.com" + var SSHAES192CBC = "aes192-cbc" + var SSHAES192CTR = "aes192-ctr" + var SSHAES256CBC = "aes256-cbc" + var SSHAES256CTR = "aes256-ctr" + var SSHAES256GCM = "aes256-gcm@openssh.com" + var SSHArcfour = "arcfour" + var SSHArcfour128 = "arcfour128" + var SSHArcfour256 = "arcfour256" + var SSHBlowfishCBC = "blowfish-cbc" + var SSHCast128CBC = "cast128-cbc" + var SSHChacha20poly1305 = "chacha20-poly1305@openssh.com" + var SSHDESEDE3CBC = "3des-cbc" + var SSHSM4CBC = "sm4-cbc" + var SSHSM4CTR = "sm4-ctr" + func AddCipher(name string, cipher func() Cipher) + func AddKDF(name string, params func() KDFParameters) + func AddKey(name string, key func() Key) + func AddPubKeyParser(name string, parser PubKeyParser) + func EncodeSSHKeyToPem(keyBlock *pem.Block) []byte + func GetStructName(s any) (name string) + func MarshalAuthorizedKey(key ssh.PublicKey) []byte + func MarshalAuthorizedKeyWithComment(key ssh.PublicKey, comment string) []byte + func MarshalOpenSSHPrivateKey(rand io.Reader, key crypto.PrivateKey, comment string) (*pem.Block, error) + func MarshalOpenSSHPrivateKeyWithPassword(rand io.Reader, key crypto.PrivateKey, comment string, password []byte, ...) (*pem.Block, error) + func NewPublicKey(key any) (out ssh.PublicKey, err error) + func NewSM2PrivateKey(key *sm2.PrivateKey) ssh.Signer + func NewSM2PublicKey(key *sm2.PublicKey) ssh.PublicKey + func NewSignerFromKey(key any) (out ssh.Signer, err error) + func ParseAuthorizedKey(in []byte) (out ssh.PublicKey, comment string, options []string, rest []byte, err error) + func ParseKnownHosts(in []byte) (marker string, hosts []string, pubKey ssh.PublicKey, comment string, ...) + func ParseOpenSSHPrivateKey(key []byte) (crypto.PrivateKey, string, error) + func ParseOpenSSHPrivateKeyToInfo(key []byte) (openSSHPrivateKey, error) + func ParseOpenSSHPrivateKeyWithPassword(key []byte, password []byte) (crypto.PrivateKey, string, error) + func ParsePrivateKey(pemBytes []byte) (ssh.Signer, error) + func ParsePrivateKeyWithPassphrase(pemBytes, passphrase []byte) (ssh.Signer, error) + func ParsePublicKey(in []byte) (out ssh.PublicKey, err error) + func ParseRawPrivateKey(pemBytes []byte) (out any, err error) + func ParseRawPrivateKeyWithPassphrase(pemBytes, passphrase []byte) (out any, err error) + func ParseSM2AuthorizedKey(in []byte) (out ssh.PublicKey, comment string, options []string, rest []byte, err error) + func ParseSM2PrivateKeyFromPem(privateKeyPem []byte, pwd []byte) (*sm2.PrivateKey, error) + func ParseSM2PublicKey(in []byte) (out ssh.PublicKey, err error) + func ParseSM2RawPrivateKey(pemBytes []byte) (any, error) + func ParseSM2RawPrivateKeyWithPassphrase(pemBytes, passphrase []byte) (any, error) + func ParseSSHKeyPem(data []byte) ([]byte, error) + type BcryptOpts struct + Rounds int + SaltSize int + func (this BcryptOpts) DeriveKey(random io.Reader, password []byte, size int) ([]byte, string, error) + func (this BcryptOpts) GetSaltSize() int + func (this BcryptOpts) Name() string + type BcryptbinOpts struct + Rounds int + SaltSize int + func (this BcryptbinOpts) DeriveKey(random io.Reader, password []byte, size int) (key []byte, params string, err error) + func (this BcryptbinOpts) GetSaltSize() int + func (this BcryptbinOpts) Name() string + type Cipher interface + BlockSize func() int + Decrypt func(key, ciphertext []byte) ([]byte, error) + Encrypt func(key, plaintext []byte) ([]byte, error) + KeySize func() int + Name func() string + func GetCipherFromName(name string) Cipher + func ParseCipher(cipherName string) (Cipher, error) + type CipherCBC struct + func (this CipherCBC) BlockSize() int + func (this CipherCBC) Decrypt(key, ciphertext []byte) ([]byte, error) + func (this CipherCBC) Encrypt(key, plaintext []byte) ([]byte, error) + func (this CipherCBC) KeySize() int + func (this CipherCBC) Name() string + type CipherCTR struct + func (this CipherCTR) BlockSize() int + func (this CipherCTR) Decrypt(key, ciphertext []byte) ([]byte, error) + func (this CipherCTR) Encrypt(key, plaintext []byte) ([]byte, error) + func (this CipherCTR) KeySize() int + func (this CipherCTR) Name() string + type CipherChacha20poly1305 struct + func (this CipherChacha20poly1305) BlockSize() int + func (this CipherChacha20poly1305) Decrypt(key, ciphertext []byte) ([]byte, error) + func (this CipherChacha20poly1305) Encrypt(key, plaintext []byte) ([]byte, error) + func (this CipherChacha20poly1305) KeySize() int + func (this CipherChacha20poly1305) Name() string + type CipherGCM struct + func (this CipherGCM) BlockSize() int + func (this CipherGCM) Decrypt(key, ciphertext []byte) ([]byte, error) + func (this CipherGCM) Encrypt(key, plaintext []byte) ([]byte, error) + func (this CipherGCM) KeySize() int + func (this CipherGCM) Name() string + type CipherRC4 struct + func (this CipherRC4) BlockSize() int + func (this CipherRC4) Decrypt(key, ciphertext []byte) ([]byte, error) + func (this CipherRC4) Encrypt(key, plaintext []byte) ([]byte, error) + func (this CipherRC4) KeySize() int + func (this CipherRC4) Name() string + func (this CipherRC4) WithKeySize(keySize int) CipherRC4 + type KDFOpts interface + DeriveKey func(random io.Reader, password []byte, size int) (key []byte, params string, err error) + GetSaltSize func() int + Name func() string + type KDFParameters interface + DeriveKey func(password []byte, kdfOpts string, size int) (key []byte, err error) + func ParsePBKDF(kdfName string) (KDFParameters, error) + type Key interface + Marshal func(key crypto.PrivateKey, comment string) (string, []byte, []byte, error) + Parse func(data []byte) (crypto.PrivateKey, string, error) + func ParseKeyType(keyName string) (Key, error) + type KeyDSA struct + func (this KeyDSA) Marshal(key crypto.PrivateKey, comment string) (string, []byte, []byte, error) + func (this KeyDSA) Parse(rest []byte) (crypto.PrivateKey, string, error) + type KeyECDSA struct + func (this KeyECDSA) Marshal(key crypto.PrivateKey, comment string) (string, []byte, []byte, error) + func (this KeyECDSA) Parse(rest []byte) (crypto.PrivateKey, string, error) + type KeyEdDSA struct + func (this KeyEdDSA) Marshal(key crypto.PrivateKey, comment string) (string, []byte, []byte, error) + func (this KeyEdDSA) Parse(rest []byte) (crypto.PrivateKey, string, error) + type KeyRSA struct + func (this KeyRSA) Marshal(key crypto.PrivateKey, comment string) (string, []byte, []byte, error) + func (this KeyRSA) Parse(rest []byte) (crypto.PrivateKey, string, error) + type KeySM2 struct + func (this KeySM2) Marshal(key crypto.PrivateKey, comment string) (string, []byte, []byte, error) + func (this KeySM2) Parse(rest []byte) (crypto.PrivateKey, string, error) + type Opts struct + Cipher Cipher + KDFOpts KDFOpts + type PubKeyParser = func([]byte) (ssh.PublicKey, []byte, error) + func GetPubKeyParser(name string) PubKeyParser