Documentation ¶
Index ¶
- Variables
- func AddCipher(name string, cipher func() Cipher)
- func AddKDF(name string, params func() KDFParameters)
- func AddKey(name string, key func() Key)
- func EncodeSSHKeyToPem(keyBlock *pem.Block) []byte
- func GetStructName(name any) string
- func MarshalOpenSSHPrivateKey(key crypto.PrivateKey, comment string) (*pem.Block, error)
- func MarshalOpenSSHPrivateKeyWithPassword(key crypto.PrivateKey, comment string, password []byte, opts ...Opts) (*pem.Block, error)
- func ParseOpenSSHPrivateKey(key []byte) (crypto.PrivateKey, error)
- func ParseOpenSSHPrivateKeyWithPassword(key []byte, password []byte) (crypto.PrivateKey, error)
- func ParseSSHKeyPem(data []byte) ([]byte, error)
- type BcryptOpts
- type Cipher
- type CipherCBC
- type CipherCTR
- type KDFOpts
- type KDFParameters
- type Key
- type KeyEcdsa
- type KeyEdDsa
- type KeyRsa
- type Opts
- type PcryptOpts
Constants ¶
This section is empty.
Variables ¶
View Source
var ( SSHAES128CTR = "aes128-ctr" SSHAES192CTR = "aes192-ctr" SSHAES256CTR = "aes256-ctr" SSHAES128CBC = "aes128-cbc" SSHAES192CBC = "aes192-cbc" SSHAES256CBC = "aes256-cbc" )
View Source
var AES128CBC = CipherCBC{ // contains filtered or unexported fields }
AES128CBC is the 128-bit key AES cipher in CBC mode.
View Source
var AES128CTR = CipherCTR{ // contains filtered or unexported fields }
AES128CTR is the 128-bit key AES cipher in CTR mode.
View Source
var AES192CBC = CipherCBC{ // contains filtered or unexported fields }
AES192CBC is the 192-bit key AES cipher in CBC mode.
View Source
var AES192CTR = CipherCTR{ // contains filtered or unexported fields }
AES192CTR is the 192-bit key AES cipher in CTR mode.
View Source
var AES256CBC = CipherCBC{ // contains filtered or unexported fields }
AES256CBC is the 256-bit key AES cipher in CBC mode.
View Source
var AES256CTR = CipherCTR{ // contains filtered or unexported fields }
AES256CTR is the 256-bit key AES cipher in CTR mode.
View Source
var CipherMap = map[string]Cipher{ "AES128CTR": AES128CTR, "AES192CTR": AES192CTR, "AES256CTR": AES256CTR, "AES128CBC": AES128CBC, "AES192CBC": AES192CBC, "AES256CBC": AES256CBC, }
Cipher 列表
View Source
var DefaultOpts = Opts{ Cipher: AES256CTR, KDFOpts: BcryptOpts{ SaltSize: 16, Rounds: 16, }, }
默认配置
Functions ¶
func EncodeSSHKeyToPem ¶ added in v1.0.1030
编码到 pem
func MarshalOpenSSHPrivateKey ¶
编码
func MarshalOpenSSHPrivateKeyWithPassword ¶ added in v1.0.1030
func MarshalOpenSSHPrivateKeyWithPassword(key crypto.PrivateKey, comment string, password []byte, opts ...Opts) (*pem.Block, error)
编码
func ParseOpenSSHPrivateKeyWithPassword ¶ added in v1.0.1030
func ParseOpenSSHPrivateKeyWithPassword(key []byte, password []byte) (crypto.PrivateKey, error)
解析带密码
Types ¶
type BcryptOpts ¶
BcryptOpts 设置
func (BcryptOpts) GetSaltSize ¶
func (this BcryptOpts) GetSaltSize() int
func (BcryptOpts) Name ¶
func (this BcryptOpts) Name() string
type Cipher ¶
type Cipher interface { // 名称 Name() string // 值大小 KeySize() int // 块大小 BlockSize() int // 加密, 返回: [加密后数据, error] Encrypt(key, plaintext []byte) ([]byte, error) // 解密 Decrypt(key, ciphertext []byte) ([]byte, error) }
加密接口
func ParseCipher ¶
type KDFOpts ¶
type KDFOpts interface { // 名称 Name() string // 生成密钥 DeriveKey(password []byte, size int) (key []byte, params string, err error) // 随机数大小 GetSaltSize() int }
KDF 设置接口
type KDFParameters ¶
type KDFParameters interface { // 生成密钥 DeriveKey(password []byte, kdfOpts string, size int) (key []byte, err error) }
数据接口
func ParsePbkdf ¶
func ParsePbkdf(kdfName string) (KDFParameters, error)
type Key ¶
type Key interface { // 包装 Marshal(key crypto.PrivateKey, comment string) (string, []byte, []byte, error) // 解析 Parse(data []byte) (crypto.PrivateKey, error) }
Key 接口
func ParseKeytype ¶
type PcryptOpts ¶ added in v1.0.1029
PcryptOpts 设置
func (PcryptOpts) GetSaltSize ¶ added in v1.0.1029
func (this PcryptOpts) GetSaltSize() int
func (PcryptOpts) Name ¶ added in v1.0.1029
func (this PcryptOpts) Name() string
Click to show internal directories.
Click to hide internal directories.