Documentation ¶
Index ¶
- Variables
- func AddCipher(oid asn1.ObjectIdentifier, cipher func() Cipher)
- func CheckCipherFromName(name string) bool
- type Cipher
- type CipherCBC
- type CipherCCM
- type CipherCCMb
- type CipherCFB
- type CipherCFB1
- type CipherCFB8
- type CipherECB
- type CipherGCM
- type CipherGCMb
- type CipherOFB
- type CipherRC2CBC
- func (this CipherRC2CBC) Decrypt(key, params, ciphertext []byte) ([]byte, error)
- func (this CipherRC2CBC) Encrypt(key, plaintext []byte) ([]byte, []byte, error)
- func (this CipherRC2CBC) KeySize() int
- func (this CipherRC2CBC) OID() asn1.ObjectIdentifier
- func (this CipherRC2CBC) WithKeySize(keySize int) CipherRC2CBC
- func (this CipherRC2CBC) WithRC2Version(rc2Version int) CipherRC2CBC
- type CipherRC5CBC
- func (this CipherRC5CBC) Decrypt(key, params, ciphertext []byte) ([]byte, error)
- func (this CipherRC5CBC) Encrypt(key, plaintext []byte) ([]byte, []byte, error)
- func (this CipherRC5CBC) KeySize() int
- func (this CipherRC5CBC) OID() asn1.ObjectIdentifier
- func (this CipherRC5CBC) WithKeySize(keySize int) CipherRC5CBC
- func (this CipherRC5CBC) WithRounds(rounds uint) CipherRC5CBC
- func (this CipherRC5CBC) WithWordSize(wordSize uint) CipherRC5CBC
Constants ¶
This section is empty.
Variables ¶
var AES128CBC = CipherCBC{ // contains filtered or unexported fields }
AES128CBC is the 128-bit key AES cipher in CBC mode.
var AES128CCM = CipherCCM{ // contains filtered or unexported fields }
AES128CCM is the 128-bit key AES cipher in CCM mode.
var AES128CCMb = CipherCCMb{ // contains filtered or unexported fields }
AES128CCMb is the 128-bit key AES cipher in CCM mode.
var AES128CFB = CipherCFB{ // contains filtered or unexported fields }
AES128CFB is the 128-bit key AES cipher in CFB mode.
var AES128ECB = CipherECB{ // contains filtered or unexported fields }
AES128ECB is the 128-bit key AES cipher in ECB mode.
var AES128GCM = CipherGCM{ // contains filtered or unexported fields }
AES128GCM is the 128-bit key AES cipher in GCM mode.
var AES128GCMb = CipherGCMb{ // contains filtered or unexported fields }
AES128GCMb is the 128-bit key AES cipher in GCM mode.
var AES128OFB = CipherOFB{ // contains filtered or unexported fields }
AES128OFB is the 128-bit key AES cipher in OFB mode.
var AES192CBC = CipherCBC{ // contains filtered or unexported fields }
AES192CBC is the 192-bit key AES cipher in CBC mode.
var AES192CCM = CipherCCM{ // contains filtered or unexported fields }
AES192CCM is the 192-bit key AES cipher in CCM mode.
var AES192CCMb = CipherCCMb{ // contains filtered or unexported fields }
AES192CCMb is the 192-bit key AES cipher in CCM mode.
var AES192CFB = CipherCFB{ // contains filtered or unexported fields }
AES192CFB is the 192-bit key AES cipher in CFB mode.
var AES192ECB = CipherECB{ // contains filtered or unexported fields }
AES192ECB is the 192-bit key AES cipher in ECB mode.
var AES192GCM = CipherGCM{ // contains filtered or unexported fields }
AES192GCM is the 192-bit key AES cipher in GCM mode.
var AES192GCMb = CipherGCMb{ // contains filtered or unexported fields }
AES192GCMb is the 192-bit key AES cipher in GCM mode.
var AES192OFB = CipherOFB{ // contains filtered or unexported fields }
AES192OFB is the 192-bit key AES cipher in OFB mode.
var AES256CBC = CipherCBC{ // contains filtered or unexported fields }
AES256CBC is the 256-bit key AES cipher in CBC mode.
var AES256CCM = CipherCCM{ // contains filtered or unexported fields }
AES256CCM is the 256-bit key AES cipher in CCM mode.
var AES256CCMb = CipherCCMb{ // contains filtered or unexported fields }
AES256CCMb is the 256-bit key AES cipher in CCM mode.
var AES256CFB = CipherCFB{ // contains filtered or unexported fields }
AES256CFB is the 256-bit key AES cipher in CFB mode.
var AES256ECB = CipherECB{ // contains filtered or unexported fields }
AES256ECB is the 256-bit key AES cipher in ECB mode.
var AES256GCM = CipherGCM{ // contains filtered or unexported fields }
AES256GCM is the 256-bit key AES cipher in GCM mode.
var AES256GCMb = CipherGCMb{ // contains filtered or unexported fields }
AES256GCMb is the 256-bit key AES cipher in GCM mode.
var AES256OFB = CipherOFB{ // contains filtered or unexported fields }
AES256OFB is the 256-bit key AES cipher in OFB mode.
var CipherMap = map[string]Cipher{ "DESCBC": DESCBC, "DESEDE3CBC": DESEDE3CBC, "RC2CBC": RC2CBC, "RC5CBC": RC5CBC, "AES128ECB": AES128ECB, "AES128CBC": AES128CBC, "AES128OFB": AES128OFB, "AES128CFB": AES128CFB, "AES128GCM": AES128GCM, "AES128GCMb": AES128GCMb, "AES128CCM": AES128CCM, "AES128CCMb": AES128CCMb, "AES192ECB": AES192ECB, "AES192CBC": AES192CBC, "AES192OFB": AES192OFB, "AES192CFB": AES192CFB, "AES192GCM": AES192GCM, "AES192GCMb": AES192GCMb, "AES192CCM": AES192CCM, "AES192CCMb": AES192CCMb, "AES256ECB": AES256ECB, "AES256CBC": AES256CBC, "AES256OFB": AES256OFB, "AES256CFB": AES256CFB, "AES256GCM": AES256GCM, "AES256GCMb": AES256GCMb, "AES256CCM": AES256CCM, "AES256CCMb": AES256CCMb, "SM4ECB": SM4ECB, "SM4CBC": SM4CBC, "SM4OFB": SM4OFB, "SM4CFB": SM4CFB, "SM4CFB1": SM4CFB1, "SM4CFB8": SM4CFB8, "SM4GCM": SM4GCM, "SM4GCMb": SM4GCMb, "SM4CCM": SM4CCM, "SM4CCMb": SM4CCMb, }
Cipher 列表
var DESCBC = CipherCBC{ // contains filtered or unexported fields }
DESCBC is the 56-bit key 3DES cipher in CBC mode.
var DESEDE3CBC = CipherCBC{ // contains filtered or unexported fields }
TripleDESCBC is the 168-bit key 3DES cipher in CBC mode.
var RC2CBC = CipherRC2CBC{ // contains filtered or unexported fields }
RC2CBC is the [40-bit, 64-bit, 168-bit] key RC2 cipher in CBC mode. [rc2Version, keySize] = [58, 16] | [120, 8] | [160, 5]
var RC5CBC = CipherRC5CBC{ // contains filtered or unexported fields }
RC5CBC is the [16, 24, 32] bytes key RC5 cipher in CBC mode. wordSize = [32, 64] | rounds = [8, 127]
var SM4CBC = CipherCBC{ // contains filtered or unexported fields }
SM4CBC is the 128-bit key SM4 cipher in CBC mode.
var SM4CCM = CipherCCM{ // contains filtered or unexported fields }
SM4CCM is the 128-bit key SM4 cipher in CCM mode.
var SM4CCMb = CipherCCMb{ // contains filtered or unexported fields }
SM4CCMb is the 128-bit key SM4 cipher in CCM mode.
var SM4CFB = CipherCFB{ // contains filtered or unexported fields }
SM4CFB is the 128-bit key SM4 cipher in CFB mode.
var SM4CFB1 = CipherCFB1{ // contains filtered or unexported fields }
SM4CFB1 is the 128-bit key SM4 cipher in CFB mode.
var SM4CFB8 = CipherCFB8{ // contains filtered or unexported fields }
SM4CFB8 is the 128-bit key SM4 cipher in CFB mode.
var SM4ECB = CipherECB{ // contains filtered or unexported fields }
SM4ECB is the 128-bit key SM4 cipher in ECB mode.
var SM4GCM = CipherGCM{ // contains filtered or unexported fields }
SM4GCM is the 128-bit key SM4 cipher in GCM mode.
var SM4GCMb = CipherGCMb{ // contains filtered or unexported fields }
SM4GCMb is the 128-bit key SM4 cipher in GCM mode.
var SM4OFB = CipherOFB{ // contains filtered or unexported fields }
SM4OFB is the 128-bit key SM4 cipher in OFB mode.
Functions ¶
Types ¶
type Cipher ¶
type Cipher interface { // oid OID() asn1.ObjectIdentifier // 值大小 KeySize() int // 加密, 返回: [加密后数据, 参数, error] Encrypt(key, plaintext []byte) ([]byte, []byte, error) // 解密 Decrypt(key, params, ciphertext []byte) ([]byte, error) }
加密接口
type CipherCBC ¶
type CipherCBC struct {
// contains filtered or unexported fields
}
cbc 模式加密
type CipherCCM ¶
type CipherCCM struct {
// contains filtered or unexported fields
}
ccm 模式加密
type CipherCCMb ¶
type CipherCCMb struct {
// contains filtered or unexported fields
}
ccm 模式加密
func (CipherCCMb) Decrypt ¶
func (this CipherCCMb) Decrypt(key, param, ciphertext []byte) ([]byte, error)
解密
type CipherCFB ¶
type CipherCFB struct {
// contains filtered or unexported fields
}
CFB 模式加密
type CipherCFB1 ¶
type CipherCFB1 struct {
// contains filtered or unexported fields
}
CFB1 模式加密
func (CipherCFB1) Decrypt ¶
func (this CipherCFB1) Decrypt(key, params, ciphertext []byte) ([]byte, error)
解密
type CipherCFB8 ¶
type CipherCFB8 struct {
// contains filtered or unexported fields
}
CFB8 模式加密
func (CipherCFB8) Decrypt ¶
func (this CipherCFB8) Decrypt(key, params, ciphertext []byte) ([]byte, error)
解密
type CipherECB ¶
type CipherECB struct {
// contains filtered or unexported fields
}
ecb 模式加密
type CipherGCM ¶
type CipherGCM struct {
// contains filtered or unexported fields
}
gcm 模式加密
type CipherGCMb ¶
type CipherGCMb struct {
// contains filtered or unexported fields
}
gcm 模式加密
func (CipherGCMb) Decrypt ¶
func (this CipherGCMb) Decrypt(key, param, ciphertext []byte) ([]byte, error)
解密
type CipherOFB ¶
type CipherOFB struct {
// contains filtered or unexported fields
}
OFB 模式加密
type CipherRC2CBC ¶
type CipherRC2CBC struct {
// contains filtered or unexported fields
}
cbc 模式加密
func (CipherRC2CBC) Decrypt ¶
func (this CipherRC2CBC) Decrypt(key, params, ciphertext []byte) ([]byte, error)
解密
func (CipherRC2CBC) Encrypt ¶
func (this CipherRC2CBC) Encrypt(key, plaintext []byte) ([]byte, []byte, error)
加密
func (CipherRC2CBC) WithKeySize ¶
func (this CipherRC2CBC) WithKeySize(keySize int) CipherRC2CBC
设置 keySize
func (CipherRC2CBC) WithRC2Version ¶
func (this CipherRC2CBC) WithRC2Version(rc2Version int) CipherRC2CBC
设置 RC2Version
type CipherRC5CBC ¶
type CipherRC5CBC struct {
// contains filtered or unexported fields
}
cbc 模式加密
func (CipherRC5CBC) Decrypt ¶
func (this CipherRC5CBC) Decrypt(key, params, ciphertext []byte) ([]byte, error)
解密
func (CipherRC5CBC) Encrypt ¶
func (this CipherRC5CBC) Encrypt(key, plaintext []byte) ([]byte, []byte, error)
加密
func (CipherRC5CBC) WithKeySize ¶
func (this CipherRC5CBC) WithKeySize(keySize int) CipherRC5CBC
设置 keySize
func (CipherRC5CBC) WithRounds ¶
func (this CipherRC5CBC) WithRounds(rounds uint) CipherRC5CBC
设置 Rounds
func (CipherRC5CBC) WithWordSize ¶
func (this CipherRC5CBC) WithWordSize(wordSize uint) CipherRC5CBC
设置 WordSize