Documentation ¶
Index ¶
- type CreateEcdsaSetting
- type CreateRsaSetting
- type CryptEncrypt
- type CryptSign
- type EcdsaKeyManager
- type EcdsaSign
- func (e *EcdsaSign) Sign(keyPair KeyPair, raw []byte) ([]byte, error)
- func (e *EcdsaSign) SignBase64(keyPair KeyPair, base64Raw string) (string, error)
- func (e *EcdsaSign) SignRS(keyPair KeyPair, raw []byte) (*big.Int, *big.Int, error)
- func (e *EcdsaSign) Verify(keyPair KeyPair, raw, sign []byte) error
- func (e *EcdsaSign) VerifyBase64(keyPair KeyPair, base64Raw, base64Sign string) error
- func (e *EcdsaSign) VerifyRS(keyPair KeyPair, raw []byte, r, s *big.Int) (bool, error)
- type KeyPair
- type KeyPairManager
- type PaddingType
- type RsaEncrypt
- func (r *RsaEncrypt) Decrypt(keyPair KeyPair, cipher []byte) ([]byte, error)
- func (r *RsaEncrypt) DecryptBase64(keyPair KeyPair, base64Cipher string) (string, error)
- func (r *RsaEncrypt) Encrypt(keyPair KeyPair, raw []byte) ([]byte, error)
- func (r *RsaEncrypt) EncryptBase64(keyPair KeyPair, base64Raw string) (string, error)
- type RsaKeyManager
- type RsaSign
- func NewRsaSignWithPKCS1(hash hash.Hash, hashType crypto.Hash) (*RsaSign, error)
- func NewRsaSignWithPKCS1AndSHA256() *RsaSign
- func NewRsaSignWithPKCS1AndSHA512() *RsaSign
- func NewRsaSignWithPSS(hash hash.Hash, hashType crypto.Hash) (*RsaSign, error)
- func NewRsaSignWithPSSAndOps(hash hash.Hash, hashType crypto.Hash, saltLength int) (*RsaSign, error)
- func NewRsaSignWithPSSAndSHA256(saltLength ...int) *RsaSign
- func NewRsaSignWithPSSAndSHA512(saltLength ...int) *RsaSign
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateEcdsaSetting ¶
type CreateRsaSetting ¶
type CreateRsaSetting struct {
Length int
}
type CryptEncrypt ¶
type CryptEncrypt interface { // Encrypt 加密 Encrypt(keyPair KeyPair, raw []byte) ([]byte, error) // EncryptBase64 使用标准Base64传递的数据进行加密 EncryptBase64(keyPair KeyPair, base64Raw string) (string, error) // Decrypt 解密 Decrypt(keyPair KeyPair, cipher []byte) ([]byte, error) // DecryptBase64 使用标准Base64传递的数据进行解密 DecryptBase64(keyPair KeyPair, base64Cipher string) (string, error) }
type CryptSign ¶
type CryptSign interface { // Sign 数据签名 Sign(keyPair KeyPair, raw []byte) ([]byte, error) // Verify 签名验证 Verify(keyPair KeyPair, raw, sign []byte) error // SignBase64 使用标准Base64传递的数据进行加签 SignBase64(keyPair KeyPair, base64Raw string) (string, error) // VerifyBase64 使用标准Base64传递的数据进行验签 VerifyBase64(keyPair KeyPair, base64Raw, base64Sign string) error }
type EcdsaKeyManager ¶
type EcdsaKeyManager struct {
CreateSetting CreateEcdsaSetting
}
func (*EcdsaKeyManager) Create ¶
func (e *EcdsaKeyManager) Create() (KeyPair, error)
type EcdsaSign ¶
func NewEcdsaSign ¶
func (*EcdsaSign) SignBase64 ¶
func (*EcdsaSign) VerifyBase64 ¶
type KeyPair ¶
type KeyPair interface { // PrivateKey 获取原始私钥 PrivateKey() interface{} // PublicKey 获取原始公钥信息 PublicKey() interface{} // ToPublicPKCS1Pem 将公钥转换为pkcs1 PEM格式 ToPublicPKCS1Pem() string // ToPrivatePKCS1Pem 将私钥转换为pkcs1 PEM格式 ToPrivatePKCS1Pem() string }
KeyPair 公私钥信息
type KeyPairManager ¶
type KeyPairManager interface { // Create 生成新的公私钥对 Create() (KeyPair, error) // Load 加载公私钥 Load(pubPem, priPem string) (KeyPair, error) }
KeyPairManager KeyPair管理器
type PaddingType ¶
type PaddingType uint8
const ( // PaddingTypeNone 无填充 PaddingTypeNone PaddingType = 0 // PaddingTypePKCS1 PKCS1.5 PaddingTypePKCS1 PaddingType = 1 // PaddingTypeOAEP OAEP模式 PaddingTypeOAEP PaddingType = 2 // PaddingTypePSS PSS模式 PaddingTypePSS PaddingType = 3 )
type RsaEncrypt ¶
type RsaEncrypt struct {
// contains filtered or unexported fields
}
func NewRsaEncryptWithOAEP ¶
func NewRsaEncryptWithOAEP(hash hash.Hash, label []byte) (*RsaEncrypt, error)
NewRsaEncryptWithOAEP 创建一个标准的RSA加密 Padding-OAEP模式实例
func NewRsaEncryptWithPKCS1 ¶
func NewRsaEncryptWithPKCS1() *RsaEncrypt
NewRsaEncryptWithPKCS1 创建一个标准的RSA加密 Padding-PKCS1模式实例
func (*RsaEncrypt) Decrypt ¶
func (r *RsaEncrypt) Decrypt(keyPair KeyPair, cipher []byte) ([]byte, error)
func (*RsaEncrypt) DecryptBase64 ¶
func (r *RsaEncrypt) DecryptBase64(keyPair KeyPair, base64Cipher string) (string, error)
func (*RsaEncrypt) Encrypt ¶
func (r *RsaEncrypt) Encrypt(keyPair KeyPair, raw []byte) ([]byte, error)
func (*RsaEncrypt) EncryptBase64 ¶
func (r *RsaEncrypt) EncryptBase64(keyPair KeyPair, base64Raw string) (string, error)
type RsaKeyManager ¶
type RsaKeyManager struct {
CreateSetting CreateRsaSetting
}
func (*RsaKeyManager) Create ¶
func (r *RsaKeyManager) Create() (KeyPair, error)
type RsaSign ¶
func NewRsaSignWithPKCS1 ¶
NewRsaSignWithPKCS1 创建一个标准RSA签名 Padding-PKCS1 自定义hash函数
func NewRsaSignWithPKCS1AndSHA256 ¶
func NewRsaSignWithPKCS1AndSHA256() *RsaSign
NewRsaSignWithPKCS1AndSHA256 创建一个标准RSA签名 Padding-PKCS1 hash函数为sha256
func NewRsaSignWithPKCS1AndSHA512 ¶
func NewRsaSignWithPKCS1AndSHA512() *RsaSign
NewRsaSignWithPKCS1AndSHA512 创建一个标准RSA签名 Padding-PKCS1 hash函数为sha512
func NewRsaSignWithPSS ¶
NewRsaSignWithPSS 创建一个标准RSA签名 Padding-PSS
func NewRsaSignWithPSSAndOps ¶
func NewRsaSignWithPSSAndOps(hash hash.Hash, hashType crypto.Hash, saltLength int) (*RsaSign, error)
NewRsaSignWithPSSAndOps NewRsaSignWithPSS 创建一个标准RSA签名 Padding-PSS 并指定saltLength
func NewRsaSignWithPSSAndSHA256 ¶
NewRsaSignWithPSSAndSHA256 创建一个标准RSA签名 Padding-PSS hash函数为sha256
func NewRsaSignWithPSSAndSHA512 ¶
NewRsaSignWithPSSAndSHA512 创建一个标准RSA签名 Padding-PSS hash函数为sha512
func (*RsaSign) SignBase64 ¶
Click to show internal directories.
Click to hide internal directories.