asymmetric

package
v0.0.0-...-5f1ca4c Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrivatePemType = "ecc private key"
	PrivatePemFile = "ecc.pri.pem"
	PublicPemType  = "ecc public key"
	PublicPemFile  = "ecc.pub.pem"
)

ECC,全称椭圆曲线密码学(英语:Elliptic curve cryptography,缩写为 ECC),主要是指相关数学原理

View Source
const (
	//GenericRSA_Bits	密钥长度
	GenericRSA_Bits = 1024
)

Variables

View Source
var (
	ErrDataToLarge     = errors.New("message too long for RSA public key size")
	ErrDataLen         = errors.New("data length error")
	ErrDataBroken      = errors.New("data broken, first byte is not zero")
	ErrKeyPairDismatch = errors.New("data is not encrypted by the private key")
	ErrDecryption      = errors.New("decryption error")
	ErrPublicKey       = errors.New("get public key error")
	ErrPrivateKey      = errors.New("get private key error")
)

Functions

This section is empty.

Types

type Ecc

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

Ecc 椭圆曲线密码

func (*Ecc) Decrypt

func (e *Ecc) Decrypt(cipherText []byte) ([]byte, error)

Decrypt 解密

func (*Ecc) Encrypt

func (e *Ecc) Encrypt(plainText []byte) ([]byte, error)

Encrypt 加密

func (*Ecc) GenerateEcdsaKey

func (e *Ecc) GenerateEcdsaKey(keySize ...int)

GenerateEcdsaKey 生成密钥和公钥

func (*Ecc) LoadPem

func (e *Ecc) LoadPem(privatePemFile, publicPemFile string) error

LoadPem 加载pem私钥公钥

func (*Ecc) PrivateKeySignature

func (e *Ecc) PrivateKeySignature(data []byte) (r, s []byte)

PrivateKeySignature 私钥签名

func (*Ecc) PublicKeyVerify

func (e *Ecc) PublicKeyVerify(data, r, s []byte) bool

PublicKeyVerify 公钥验证

func (*Ecc) SavePem

func (e *Ecc) SavePem(pems ...string)

SavePem 保存密钥和公钥pem 文件,参数1:密钥文件,参数2:公钥文件

type RsaCrypto

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

JavaGenericRSA java的对接的rsa

func (*RsaCrypto) EqualPrivateKeyString

func (grsa *RsaCrypto) EqualPrivateKeyString(pri string) bool

EqualPrivateKeyString 对比密钥

func (*RsaCrypto) EqualPublicKeyString

func (grsa *RsaCrypto) EqualPublicKeyString(pub string) bool

EqualPublicKeyString 对比公钥

func (*RsaCrypto) GetPrivateKey

func (grsa *RsaCrypto) GetPrivateKey() string

GetPrivateKey 获取私钥

func (*RsaCrypto) GetPublicKey

func (grsa *RsaCrypto) GetPublicKey() string

GetPublicKey 获取公钥

func (*RsaCrypto) InitByGenerateKey

func (grsa *RsaCrypto) InitByGenerateKey()

InitByGenerateKey 初始化

func (*RsaCrypto) PrivateKeyDecrypt

func (grsa *RsaCrypto) PrivateKeyDecrypt(data string) (string, error)

PrivateKeyDecrypt 私钥解密

func (*RsaCrypto) PrivateKeyDecryptByte

func (grsa *RsaCrypto) PrivateKeyDecryptByte(input []byte) ([]byte, error)

PrivateKeyDecryptByte 私钥解密

func (*RsaCrypto) PrivateKeyEncrypt

func (grsa *RsaCrypto) PrivateKeyEncrypt(data string) (string, error)

PrivateKeyEncrypt 私钥加密

func (*RsaCrypto) PrivateKeyEncryptByte

func (grsa *RsaCrypto) PrivateKeyEncryptByte(input []byte) ([]byte, error)

PrivateKeyEncryptByte 私钥加密

func (*RsaCrypto) PublicKeyDecrypt

func (grsa *RsaCrypto) PublicKeyDecrypt(data string) (string, error)

PublicKeyDecrypt 公钥解密

func (*RsaCrypto) PublicKeyDecryptByte

func (grsa *RsaCrypto) PublicKeyDecryptByte(input []byte) ([]byte, error)

PublicKeyDecryptByte 公钥解密

func (*RsaCrypto) PublicKeyEncrypt

func (grsa *RsaCrypto) PublicKeyEncrypt(data string) (string, error)

PublicKeyEncrypt 公钥加密

func (*RsaCrypto) PublicKeyEncryptByte

func (grsa *RsaCrypto) PublicKeyEncryptByte(input []byte) ([]byte, error)

PublicKeyEncryptByte 公钥加密

func (*RsaCrypto) SetPrivateKey

func (grsa *RsaCrypto) SetPrivateKey(pri string) (err error)

SetPrivateKey 设置私钥

func (*RsaCrypto) SetPublicKey

func (grsa *RsaCrypto) SetPublicKey(pub string) (err error)

SetPublicKey 设置公钥

Jump to

Keyboard shortcuts

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