pkcs8pbe

package
v1.0.1031 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

PEMCipher 列表

View Source
var PEMCipherSHA1And3DES = CipherBlockCBC{
	// contains filtered or unexported fields
}
View Source
var PEMCipherSHA1AndDES = 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

type CipherRC4

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

cbc 模式加密

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

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