pkcs1

package
v1.0.3011 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cipher3DESCBC = CipherCBC{
	// contains filtered or unexported fields
}
View Source
var Cipher3DESCFB = CipherCFB{
	// contains filtered or unexported fields
}
View Source
var Cipher3DESCTR = CipherCTR{
	// contains filtered or unexported fields
}
View Source
var Cipher3DESOFB = CipherOFB{
	// contains filtered or unexported fields
}
View Source
var CipherAES128CBC = CipherCBC{
	// contains filtered or unexported fields
}

AES_CBC 模式

View Source
var CipherAES128CFB = CipherCFB{
	// contains filtered or unexported fields
}

AES_CFB 模式

View Source
var CipherAES128CTR = CipherCTR{
	// contains filtered or unexported fields
}

AES_CTR 模式

View Source
var CipherAES128OFB = CipherOFB{
	// contains filtered or unexported fields
}

AES_OFB 模式

View Source
var CipherAES192CBC = CipherCBC{
	// contains filtered or unexported fields
}
View Source
var CipherAES192CFB = CipherCFB{
	// contains filtered or unexported fields
}
View Source
var CipherAES192CTR = CipherCTR{
	// contains filtered or unexported fields
}
View Source
var CipherAES192OFB = CipherOFB{
	// contains filtered or unexported fields
}
View Source
var CipherAES256CBC = CipherCBC{
	// contains filtered or unexported fields
}
View Source
var CipherAES256CFB = CipherCFB{
	// contains filtered or unexported fields
}
View Source
var CipherAES256CTR = CipherCTR{
	// contains filtered or unexported fields
}
View Source
var CipherAES256OFB = CipherOFB{
	// contains filtered or unexported fields
}
View Source
var CipherDESCBC = CipherCBC{
	// contains filtered or unexported fields
}

DES_CBC 模式

View Source
var CipherDESCFB = CipherCFB{
	// contains filtered or unexported fields
}

DES_CFB 模式

View Source
var CipherDESCTR = CipherCTR{
	// contains filtered or unexported fields
}

DES_CTR 模式

View Source
var CipherDESOFB = CipherOFB{
	// contains filtered or unexported fields
}

DES_OFB 模式

View Source
var CipherGrasshopperCBC = CipherCBC{
	// contains filtered or unexported fields
}

GRASSHOPPER_CBC 模式

View Source
var CipherGrasshopperCFB = CipherCFB{
	// contains filtered or unexported fields
}

GRASSHOPPER_CFB 模式

View Source
var CipherGrasshopperCTR = CipherCTR{
	// contains filtered or unexported fields
}

GRASSHOPPER_CTR 模式

View Source
var CipherGrasshopperOFB = CipherOFB{
	// contains filtered or unexported fields
}

GRASSHOPPER_OFB 模式

View Source
var CipherSM4CBC = CipherCBC{
	// contains filtered or unexported fields
}

SM4_CBC 模式

View Source
var CipherSM4CFB = CipherCFB{
	// contains filtered or unexported fields
}

SM4_CFB 模式

View Source
var CipherSM4CTR = CipherCTR{
	// contains filtered or unexported fields
}

SM4_CTR 模式

View Source
var CipherSM4OFB = CipherOFB{
	// contains filtered or unexported fields
}

SM4_OFB 模式

View Source
var IncorrectPasswordError = errors.New("pkcs1: decryption password incorrect")

IncorrectPasswordError is returned when an incorrect password is detected.

Functions

func AddCipher

func AddCipher(name string, cipher func() Cipher)

添加加密

func CheckPEMCipher added in v1.0.2033

func CheckPEMCipher(name string) bool

检测 Cipher 类型

func DecryptPEMBlock deprecated

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

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 DeriveKey

func DeriveKey(password, salt []byte, keySize int) []byte

密钥生成器

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

func IsEncryptedPEMBlock(b *pem.Block) bool

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)
}

加密接口

func GetCipher

func GetCipher(name string) (Cipher, error)

获取加密

func GetPEMCipher added in v1.0.2033

func GetPEMCipher(name string) Cipher

获取 Cipher 类型

type CipherCBC

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

CBC 模式加密

func (CipherCBC) BlockSize

func (this CipherCBC) BlockSize() int

块大小

func (CipherCBC) Decrypt

func (this CipherCBC) Decrypt(password, iv, ciphertext []byte) ([]byte, error)

解密

func (CipherCBC) Encrypt

func (this CipherCBC) Encrypt(rand io.Reader, password, plaintext []byte) ([]byte, []byte, error)

加密

func (CipherCBC) Name

func (this CipherCBC) Name() string

名称

type CipherCFB

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

CFB 模式加密

func (CipherCFB) BlockSize

func (this CipherCFB) BlockSize() int

块大小

func (CipherCFB) Decrypt

func (this CipherCFB) Decrypt(password, iv, ciphertext []byte) ([]byte, error)

解密

func (CipherCFB) Encrypt

func (this CipherCFB) Encrypt(rand io.Reader, password, plaintext []byte) ([]byte, []byte, error)

加密

func (CipherCFB) Name

func (this CipherCFB) Name() string

名称

type CipherCTR

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

CTR 模式加密

func (CipherCTR) BlockSize

func (this CipherCTR) BlockSize() int

块大小

func (CipherCTR) Decrypt

func (this CipherCTR) Decrypt(password, iv, ciphertext []byte) ([]byte, error)

解密

func (CipherCTR) Encrypt

func (this CipherCTR) Encrypt(rand io.Reader, password, plaintext []byte) ([]byte, []byte, error)

加密

func (CipherCTR) Name

func (this CipherCTR) Name() string

名称

type CipherOFB

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

OFB 模式加密

func (CipherOFB) BlockSize

func (this CipherOFB) BlockSize() int

块大小

func (CipherOFB) Decrypt

func (this CipherOFB) Decrypt(password, iv, ciphertext []byte) ([]byte, error)

解密

func (CipherOFB) Encrypt

func (this CipherOFB) Encrypt(rand io.Reader, password, plaintext []byte) ([]byte, []byte, error)

加密

func (CipherOFB) Name

func (this CipherOFB) Name() string

名称

Jump to

Keyboard shortcuts

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