enveloped

package
v1.0.2063 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AddCipher = pbes2.AddCipher
	GetCipher = pbes2.GetCipher

	// 帮助函数
	GetCipherFromName   = pbes2.GetCipherFromName
	CheckCipherFromName = pbes2.CheckCipherFromName
)
View Source
var (
	DESCBC     = pbes2.DESCBC
	DESEDE3CBC = pbes2.DESEDE3CBC
	RC2CBC     = pbes2.RC2CBC
	RC5CBC     = pbes2.RC5CBC

	AES128ECB = pbes2.AES128ECB
	AES128CBC = pbes2.AES128CBC
	AES128OFB = pbes2.AES128OFB
	AES128CFB = pbes2.AES128CFB
	AES128GCM = pbes2.AES128GCM
	AES128CCM = pbes2.AES128CCM

	AES192ECB = pbes2.AES192ECB
	AES192CBC = pbes2.AES192CBC
	AES192OFB = pbes2.AES192OFB
	AES192CFB = pbes2.AES192CFB
	AES192GCM = pbes2.AES192GCM
	AES192CCM = pbes2.AES192CCM

	AES256ECB = pbes2.AES256ECB
	AES256CBC = pbes2.AES256CBC
	AES256OFB = pbes2.AES256OFB
	AES256CFB = pbes2.AES256CFB
	AES256GCM = pbes2.AES256GCM
	AES256CCM = pbes2.AES256CCM

	SM4ECB  = pbes2.SM4ECB
	SM4CBC  = pbes2.SM4CBC
	SM4OFB  = pbes2.SM4OFB
	SM4CFB  = pbes2.SM4CFB
	SM4CFB1 = pbes2.SM4CFB1
	SM4CFB8 = pbes2.SM4CFB8
	SM4GCM  = pbes2.SM4GCM
	SM4CCM  = pbes2.SM4CCM
)

加密方式

View Source
var DefaultOpts = Opts{
	Cipher:     AES256CBC,
	KeyEncrypt: KeyEncryptRSA,
}

默认配置

View Source
var KeyEncryptRSA = KeyEncryptWithRsa{
	// contains filtered or unexported fields
}

KeyEncryptRSA

View Source
var KeyEncryptRSAESOAEP = KeyEncryptWithRsa{
	// contains filtered or unexported fields
}

KeyEncryptRSAESOAEP

View Source
var KeyEncryptRSASHA1 = KeyEncryptWithRsa{
	// contains filtered or unexported fields
}

KeyEncryptRSASHA1

View Source
var KeyEncryptRSASHA256 = KeyEncryptWithRsa{
	// contains filtered or unexported fields
}

KeyEncryptRSASHA256

View Source
var KeyEncryptRSASHA384 = KeyEncryptWithRsa{
	// contains filtered or unexported fields
}

KeyEncryptRSASHA384

View Source
var KeyEncryptRSASHA512 = KeyEncryptWithRsa{
	// contains filtered or unexported fields
}

KeyEncryptRSASHA512

View Source
var KeyEncryptSM2 = KeyEncryptWithSM2{
	// contains filtered or unexported fields
}

KeyEncryptSM2

Functions

func AddkeyEncrypt

func AddkeyEncrypt(oid asn1.ObjectIdentifier, fn func() KeyEncrypt)

添加 key 加密方式

Types

type Cipher

type Cipher = pbes2.Cipher

别名

type Enveloped

type Enveloped struct{}

func NewEnveloped

func NewEnveloped() Enveloped

func (Enveloped) Decrypt

func (this Enveloped) Decrypt(data []byte, cert *x509.Certificate, pkey crypto.PrivateKey) ([]byte, error)

解析

func (Enveloped) Encrypt

func (this Enveloped) Encrypt(rand io.Reader, content []byte, recipients []*x509.Certificate, opts ...Opts) ([]byte, error)

加密

type KeyEncrypt

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

	// 加密, 返回: [加密后数据, error]
	Encrypt(plaintext []byte, pkey crypto.PublicKey) ([]byte, error)

	// 解密
	Decrypt(ciphertext []byte, pkey crypto.PrivateKey) ([]byte, error)
}

非对称加密

type KeyEncryptWithRsa

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

key 用 rsa 加密

func (KeyEncryptWithRsa) Decrypt

func (this KeyEncryptWithRsa) Decrypt(ciphertext []byte, pkey crypto.PrivateKey) ([]byte, error)

解密

func (KeyEncryptWithRsa) Encrypt

func (this KeyEncryptWithRsa) Encrypt(plaintext []byte, pkey crypto.PublicKey) ([]byte, error)

加密

func (KeyEncryptWithRsa) OID

oid

type KeyEncryptWithSM2

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

key 用 sm2 加密

func (KeyEncryptWithSM2) Decrypt

func (this KeyEncryptWithSM2) Decrypt(ciphertext []byte, pkey crypto.PrivateKey) ([]byte, error)

解密

func (KeyEncryptWithSM2) Encrypt

func (this KeyEncryptWithSM2) Encrypt(plaintext []byte, pkey crypto.PublicKey) ([]byte, error)

加密

func (KeyEncryptWithSM2) OID

oid

type Opts

type Opts struct {
	Cipher     Cipher
	KeyEncrypt KeyEncrypt
}

配置

Jump to

Keyboard shortcuts

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