pkcs8pbe

package
v1.0.1048 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PEMCipherMD2AndDES = CipherBlockCBC{
	// contains filtered or unexported fields
}
View Source
var PEMCipherMD2AndRC2_64 = CipherBlockCBC{
	// contains filtered or unexported fields
}
View Source
var PEMCipherMD5AndDES = CipherBlockCBC{
	// contains filtered or unexported fields
}
View Source
var PEMCipherMD5AndRC2_64 = CipherBlockCBC{
	// contains filtered or unexported fields
}
View Source
var PEMCipherMap = map[string]PEMCipher{
	"MD2AndDES":      PEMCipherMD2AndDES,
	"MD5AndDES":      PEMCipherMD5AndDES,
	"SHA1AndDES":     PEMCipherSHA1AndDES,
	"SHA1And3DES":    PEMCipherSHA1And3DES,
	"SHA1AndRC4_128": PEMCipherSHA1AndRC4_128,
	"SHA1AndRC4_40":  PEMCipherSHA1AndRC4_40,

	"SHA1AndRC2_128": PEMCipherSHA1AndRC2_128,
	"SHA1AndRC2_40":  PEMCipherSHA1AndRC2_40,
	"SHA1AndRC2_64":  PEMCipherSHA1AndRC2_64,
	"MD2AndRC2_64":   PEMCipherMD2AndRC2_64,
	"MD5AndRC2_64":   PEMCipherMD5AndRC2_64,
}

PEMCipher 列表

View Source
var PEMCipherSHA1And3DES = CipherBlockCBC{
	// contains filtered or unexported fields
}
View Source
var PEMCipherSHA1AndDES = CipherBlockCBC{
	// contains filtered or unexported fields
}
View Source
var PEMCipherSHA1AndRC2_128 = CipherBlockCBC{
	// contains filtered or unexported fields
}
View Source
var PEMCipherSHA1AndRC2_40 = CipherBlockCBC{
	// contains filtered or unexported fields
}
View Source
var PEMCipherSHA1AndRC2_64 = CipherBlockCBC{
	// contains filtered or unexported fields
}
View Source
var PEMCipherSHA1AndRC4_128 = CipherRC4{
	// contains filtered or unexported fields
}
View Source
var PEMCipherSHA1AndRC4_40 = CipherRC4{
	// contains filtered or unexported fields
}

Functions

func AddCipher

func AddCipher(oid asn1.ObjectIdentifier, cipher func() PEMCipher)

添加加密

func CheckCipherFromName

func CheckCipherFromName(name string) bool

检测 Cipher 类型

func DecryptPEMBlock

func DecryptPEMBlock(block *pem.Block, password []byte) ([]byte, error)

解出 PEM 块

func DecryptPKCS8PrivateKey

func DecryptPKCS8PrivateKey(data, password []byte) ([]byte, error)

解出 PKCS8 密钥

func EncryptPKCS8PrivateKey

func EncryptPKCS8PrivateKey(
	rand io.Reader,
	blockType string,
	data []byte,
	password []byte,
	cipher PEMCipher,
) (*pem.Block, error)

加密 PKCS8

Types

type CipherBlockCBC

type CipherBlockCBC struct {
	// contains filtered or unexported fields
}

cbc 模式加密

func (CipherBlockCBC) Decrypt

func (this CipherBlockCBC) Decrypt(password, params, ciphertext []byte) ([]byte, error)

解密

func (CipherBlockCBC) Encrypt

func (this CipherBlockCBC) Encrypt(password, plaintext []byte) ([]byte, []byte, error)

加密

func (CipherBlockCBC) KeySize

func (this CipherBlockCBC) KeySize() int

值大小

func (CipherBlockCBC) OID

oid

func (CipherBlockCBC) WithSaltSize added in v1.0.1033

func (this CipherBlockCBC) WithSaltSize(saltSize int) CipherBlockCBC

设置 saltSize

type CipherRC4

type CipherRC4 struct {
	// contains filtered or unexported fields
}

rc4 模式加密

func (CipherRC4) Decrypt

func (this CipherRC4) Decrypt(password, params, ciphertext []byte) ([]byte, error)

解密

func (CipherRC4) Encrypt

func (this CipherRC4) Encrypt(password, plaintext []byte) ([]byte, []byte, error)

加密

func (CipherRC4) KeySize

func (this CipherRC4) KeySize() int

值大小

func (CipherRC4) OID

func (this CipherRC4) OID() asn1.ObjectIdentifier

oid

func (CipherRC4) WithSaltSize added in v1.0.1033

func (this CipherRC4) WithSaltSize(saltSize int) CipherRC4

设置 saltSize

type PEMCipher

type PEMCipher interface {
	// oid
	OID() asn1.ObjectIdentifier

	// 值大小
	KeySize() int

	// 加密, 返回: [加密后数据, 参数, error]
	Encrypt(key, plaintext []byte) ([]byte, []byte, error)

	// 解密
	Decrypt(key, params, ciphertext []byte) ([]byte, error)
}

加密接口

func GetCipherFromName

func GetCipherFromName(name string) PEMCipher

获取 Cipher 类型

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL