pbes1

package
v1.0.3006 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MD2AndDES = CipherBlockCBC{
	// contains filtered or unexported fields
}

PBES1

View Source
var MD2AndRC2_64 = CipherBlockCBC{
	// contains filtered or unexported fields
}
View Source
var MD5AndCAST5 = CipherBlockCBC{
	// contains filtered or unexported fields
}
View Source
var MD5AndDES = CipherBlockCBC{
	// contains filtered or unexported fields
}
View Source
var MD5AndRC2_64 = CipherBlockCBC{
	// contains filtered or unexported fields
}
View Source
var PEMCipherMap = map[string]Cipher{

	"SHA1AndRC4_128": SHA1AndRC4_128,
	"SHA1AndRC4_40":  SHA1AndRC4_40,
	"SHA1And3DES":    SHA1And3DES,
	"SHA1And2DES":    SHA1And2DES,
	"SHA1AndRC2_128": SHA1AndRC2_128,
	"SHA1AndRC2_40":  SHA1AndRC2_40,

	"MD5AndCAST5":   MD5AndCAST5,
	"SHAAndTwofish": SHAAndTwofish,

	"MD2AndDES":     MD2AndDES,
	"MD2AndRC2_64":  MD2AndRC2_64,
	"MD5AndDES":     MD5AndDES,
	"MD5AndRC2_64":  MD5AndRC2_64,
	"SHA1AndDES":    SHA1AndDES,
	"SHA1AndRC2_64": SHA1AndRC2_64,
}

PEMCipher 列表

View Source
var SHA1And2DES = CipherBlockCBC{
	// contains filtered or unexported fields
}
View Source
var SHA1And3DES = CipherBlockCBC{
	// contains filtered or unexported fields
}
View Source
var SHA1AndDES = CipherBlockCBC{
	// contains filtered or unexported fields
}
View Source
var SHA1AndRC2_128 = CipherBlockCBC{
	// contains filtered or unexported fields
}
View Source
var SHA1AndRC2_40 = CipherBlockCBC{
	// contains filtered or unexported fields
}
View Source
var SHA1AndRC2_64 = CipherBlockCBC{
	// contains filtered or unexported fields
}
View Source
var SHA1AndRC4_128 = CipherRC4{
	// contains filtered or unexported fields
}

pkcs12

View Source
var SHA1AndRC4_40 = CipherRC4{
	// contains filtered or unexported fields
}
View Source
var SHAAndTwofish = CipherBlockCBC{
	// contains filtered or unexported fields
}

use 32 bytes key length

Functions

func AddCipher

func AddCipher(oid asn1.ObjectIdentifier, cipher CipherFunc)

添加加密

func AllCipher added in v1.0.2032

func AllCipher() map[string]CipherFunc

全部

func CheckCipher added in v1.0.2031

func CheckCipher(c Cipher) bool

检测 Cipher

func CheckCipherFromName

func CheckCipherFromName(name string) bool

检测 Cipher 类型

func DerivedKeyPbkdf1 added in v1.0.2032

func DerivedKeyPbkdf1(password string, salt string, iter int, keyLen int, ivLen int, h func() hash.Hash) ([]byte, []byte)

生成密钥

func DerivedKeyPkcs12 added in v1.0.2032

func DerivedKeyPkcs12(password string, salt string, iter int, keyLen int, ivLen int, h func() hash.Hash) ([]byte, []byte)

生成密钥

func GetCipherName added in v1.0.2031

func GetCipherName(c Cipher) string

获取 Cipher 类型名称

Types

type Cipher

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

	// 值大小
	KeySize() int

	// 是否有 KeyLength
	HasKeyLength() bool

	// 密码是否需要 Bmp 处理
	NeedBmpPassword() bool

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

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

加密接口

func GetCipher

func GetCipher(oid string) (Cipher, error)

获取加密

func GetCipherFromName

func GetCipherFromName(name string) Cipher

获取 Cipher 类型

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(rand io.Reader, password, plaintext []byte) ([]byte, []byte, error)

加密

func (CipherBlockCBC) HasKeyLength added in v1.0.2039

func (this CipherBlockCBC) HasKeyLength() bool

是否有 KeyLength

func (CipherBlockCBC) KeySize

func (this CipherBlockCBC) KeySize() int

值大小

func (CipherBlockCBC) NeedBmpPassword added in v1.0.2066

func (this CipherBlockCBC) NeedBmpPassword() bool

密码是否需要 Bmp 处理

func (CipherBlockCBC) OID

oid

func (CipherBlockCBC) WithDerivedKeyFunc added in v1.0.2032

func (this CipherBlockCBC) WithDerivedKeyFunc(derivedKeyFunc DerivedKeyFunc) CipherBlockCBC

设置 derivedKeyFunc

func (CipherBlockCBC) WithHasKeyLength added in v1.0.2039

func (this CipherBlockCBC) WithHasKeyLength(hasKeyLength bool) CipherBlockCBC

func (CipherBlockCBC) WithKeySize added in v1.0.2072

func (this CipherBlockCBC) WithKeySize(keySize int) CipherBlockCBC

设置 saltSize

func (CipherBlockCBC) WithNeedBmpPassword added in v1.0.2066

func (this CipherBlockCBC) WithNeedBmpPassword(needBmpPass bool) CipherBlockCBC

func (CipherBlockCBC) WithSaltSize

func (this CipherBlockCBC) WithSaltSize(saltSize int) CipherBlockCBC

设置 saltSize

type CipherFunc added in v1.0.2032

type CipherFunc = func() Cipher

方法

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(rand io.Reader, password, plaintext []byte) ([]byte, []byte, error)

加密

func (CipherRC4) HasKeyLength added in v1.0.2039

func (this CipherRC4) HasKeyLength() bool

是否有 KeyLength

func (CipherRC4) KeySize

func (this CipherRC4) KeySize() int

值大小

func (CipherRC4) NeedBmpPassword added in v1.0.2066

func (this CipherRC4) NeedBmpPassword() bool

密码是否需要 Bmp 处理

func (CipherRC4) OID

func (this CipherRC4) OID() asn1.ObjectIdentifier

oid

func (CipherRC4) WithDerivedKeyFunc added in v1.0.2032

func (this CipherRC4) WithDerivedKeyFunc(derivedKeyFunc DerivedKeyFunc) CipherRC4

设置 derivedKeyFunc

func (CipherRC4) WithHasKeyLength added in v1.0.2039

func (this CipherRC4) WithHasKeyLength(hasKeyLength bool) CipherRC4

func (CipherRC4) WithNeedBmpPassword added in v1.0.2066

func (this CipherRC4) WithNeedBmpPassword(needBmpPass bool) CipherRC4

func (CipherRC4) WithSaltSize

func (this CipherRC4) WithSaltSize(saltSize int) CipherRC4

设置 saltSize

type Ciphers added in v1.0.2032

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

Ciphers

func CloneCiphers added in v1.0.2032

func CloneCiphers() *Ciphers

克隆

func NewCiphers added in v1.0.2032

func NewCiphers() *Ciphers

func (*Ciphers) AddCipher added in v1.0.2032

func (this *Ciphers) AddCipher(oid asn1.ObjectIdentifier, cipher CipherFunc)

添加加密

func (*Ciphers) All added in v1.0.2032

func (this *Ciphers) All() map[string]CipherFunc

全部

func (*Ciphers) Clone added in v1.0.2032

func (this *Ciphers) Clone() *Ciphers

克隆

func (*Ciphers) GetCipher added in v1.0.2032

func (this *Ciphers) GetCipher(oid string) (Cipher, error)

获取加密

type DerivedKeyFunc added in v1.0.2032

type DerivedKeyFunc = func(password string, salt string, iter int, keyLen int, ivLen int, h func() hash.Hash) ([]byte, []byte)

密码迭代生成

Jump to

Keyboard shortcuts

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