Documentation ¶
Index ¶
- Variables
- func AddCipher(name string, cipher func() Cipher)
- func CheckPEMCipher(name string) bool
- func DecryptPEMBlock(b *pem.Block, password []byte) ([]byte, error)deprecated
- func DeriveKey(password, salt []byte, keySize int) []byte
- func EncryptPEMBlock(rand io.Reader, blockType string, data, password []byte, cipher Cipher) (*pem.Block, error)deprecated
- func IsEncryptedPEMBlock(b *pem.Block) booldeprecated
- type Cipher
- type CipherCBC
- type CipherCFB
- type CipherCTR
- type CipherOFB
Constants ¶
This section is empty.
Variables ¶
var Cipher3DESCBC = CipherCBC{ // contains filtered or unexported fields }
var Cipher3DESCFB = CipherCFB{ // contains filtered or unexported fields }
var Cipher3DESCTR = CipherCTR{ // contains filtered or unexported fields }
var Cipher3DESOFB = CipherOFB{ // contains filtered or unexported fields }
var CipherAES128CBC = CipherCBC{ // contains filtered or unexported fields }
AES_CBC 模式
var CipherAES128CFB = CipherCFB{ // contains filtered or unexported fields }
AES_CFB 模式
var CipherAES128CTR = CipherCTR{ // contains filtered or unexported fields }
AES_CTR 模式
var CipherAES128OFB = CipherOFB{ // contains filtered or unexported fields }
AES_OFB 模式
var CipherAES192CBC = CipherCBC{ // contains filtered or unexported fields }
var CipherAES192CFB = CipherCFB{ // contains filtered or unexported fields }
var CipherAES192CTR = CipherCTR{ // contains filtered or unexported fields }
var CipherAES192OFB = CipherOFB{ // contains filtered or unexported fields }
var CipherAES256CBC = CipherCBC{ // contains filtered or unexported fields }
var CipherAES256CFB = CipherCFB{ // contains filtered or unexported fields }
var CipherAES256CTR = CipherCTR{ // contains filtered or unexported fields }
var CipherAES256OFB = CipherOFB{ // contains filtered or unexported fields }
var CipherDESCBC = CipherCBC{ // contains filtered or unexported fields }
DES_CBC 模式
var CipherDESCFB = CipherCFB{ // contains filtered or unexported fields }
DES_CFB 模式
var CipherDESCTR = CipherCTR{ // contains filtered or unexported fields }
DES_CTR 模式
var CipherDESOFB = CipherOFB{ // contains filtered or unexported fields }
DES_OFB 模式
var CipherGrasshopperCBC = CipherCBC{ // contains filtered or unexported fields }
GRASSHOPPER_CBC 模式
var CipherGrasshopperCFB = CipherCFB{ // contains filtered or unexported fields }
GRASSHOPPER_CFB 模式
var CipherGrasshopperCTR = CipherCTR{ // contains filtered or unexported fields }
GRASSHOPPER_CTR 模式
var CipherGrasshopperOFB = CipherOFB{ // contains filtered or unexported fields }
GRASSHOPPER_OFB 模式
var CipherSM4CBC = CipherCBC{ // contains filtered or unexported fields }
SM4_CBC 模式
var CipherSM4CFB = CipherCFB{ // contains filtered or unexported fields }
SM4_CFB 模式
var CipherSM4CTR = CipherCTR{ // contains filtered or unexported fields }
SM4_CTR 模式
var CipherSM4OFB = CipherOFB{ // contains filtered or unexported fields }
SM4_OFB 模式
var IncorrectPasswordError = errors.New("pkcs1: decryption password incorrect")
IncorrectPasswordError is returned when an incorrect password is detected.
Functions ¶
func DecryptPEMBlock
deprecated
DecryptPEMBlock takes a PEM block encrypted according to RFC 1423 and the password used to encrypt it and returns a slice of decrypted DER encoded bytes. It inspects the DEK-Info header to determine the algorithm used for decryption. If no DEK-Info header is present, an error is returned. If an incorrect password is detected an IncorrectPasswordError is returned. Because of deficiencies in the format, it's not always possible to detect an incorrect password. In these cases no error will be returned but the decrypted DER bytes will be random noise.
Deprecated: Legacy PEM encryption as specified in RFC 1423 is insecure by design. Since it does not authenticate the ciphertext, it is vulnerable to padding oracle attacks that can let an attacker recover the plaintext.
func EncryptPEMBlock
deprecated
func EncryptPEMBlock(rand io.Reader, blockType string, data, password []byte, cipher Cipher) (*pem.Block, error)
EncryptPEMBlock returns a PEM block of the specified type holding the given DER encoded data encrypted with the specified algorithm and password according to RFC 1423.
Deprecated: Legacy PEM encryption as specified in RFC 1423 is insecure by design. Since it does not authenticate the ciphertext, it is vulnerable to padding oracle attacks that can let an attacker recover the plaintext.
func IsEncryptedPEMBlock
deprecated
IsEncryptedPEMBlock returns whether the PEM block is password encrypted according to RFC 1423.
Deprecated: Legacy PEM encryption as specified in RFC 1423 is insecure by design. Since it does not authenticate the ciphertext, it is vulnerable to padding oracle attacks that can let an attacker recover the plaintext.
Types ¶
type Cipher ¶
type Cipher interface { // 名称 Name() string // 块大小 BlockSize() int // 加密, 返回: [加密后数据, iv, error] Encrypt(rand io.Reader, key, plaintext []byte) ([]byte, []byte, error) // 解密 Decrypt(key, iv, ciphertext []byte) ([]byte, error) }
加密接口
type CipherCBC ¶
type CipherCBC struct {
// contains filtered or unexported fields
}
CBC 模式加密
type CipherCFB ¶
type CipherCFB struct {
// contains filtered or unexported fields
}
CFB 模式加密
type CipherCTR ¶
type CipherCTR struct {
// contains filtered or unexported fields
}
CTR 模式加密