Documentation
¶
Index ¶
- Variables
- func ComputeKey(pubKey, priKey *big.Int) (*big.Int, error)
- func EcbDecrypt(key, src []byte) ([]byte, error)deprecated
- func EcbDecryptBase64(key, src string) (string, error)deprecated
- func EcbEncrypt(key, src []byte) ([]byte, error)deprecated
- func EcbEncryptBase64(key, src string) (string, error)deprecated
- func Gunzip(bs []byte) ([]byte, error)
- func Gzip(bs []byte) []byte
- func Hmac(key []byte, body string) []byte
- func HmacBase64(key []byte, body string) string
- func NewECBDecrypter(b cipher.Block) cipher.BlockModedeprecated
- func NewECBEncrypter(b cipher.Block) cipher.BlockModedeprecated
- func NewPublicKey(bs []byte) *big.Int
- type DhKey
- type RsaDecrypter
- type RsaEncrypter
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidPriKey indicates the invalid private key. ErrInvalidPriKey = errors.New("invalid private key") // ErrInvalidPubKey indicates the invalid public key. ErrInvalidPubKey = errors.New("invalid public key") // ErrPubKeyOutOfBound indicates the public key is out of bound. ErrPubKeyOutOfBound = errors.New("public key out of bound") )
var ( // ErrPrivateKey indicates the invalid private key. ErrPrivateKey = errors.New("private key error") // ErrPublicKey indicates the invalid public key. ErrPublicKey = errors.New("failed to parse PEM block containing the public key") // ErrNotRsaKey indicates the invalid RSA key. ErrNotRsaKey = errors.New("key type is not RSA") )
var ErrPaddingSize = errors.New("padding size error")
ErrPaddingSize indicates bad padding size.
Functions ¶
func ComputeKey ¶
ComputeKey returns a key from public key and private key.
func EcbDecrypt
deprecated
func EcbDecryptBase64
deprecated
func EcbEncrypt
deprecated
func EcbEncryptBase64
deprecated
func HmacBase64 ¶
HmacBase64 returns the base64 encoded string of HMAC for body with the given key.
func NewECBDecrypter
deprecated
func NewECBEncrypter
deprecated
func NewPublicKey ¶
NewPublicKey returns a public key from the given bytes.
Types ¶
type RsaDecrypter ¶
type RsaDecrypter interface {
Decrypt(input []byte) ([]byte, error)
DecryptBase64(input string) ([]byte, error)
}
RsaDecrypter represents a RSA decrypter.
func NewRsaDecrypter
deprecated
func NewRsaDecrypter(file string) (RsaDecrypter, error)
Deprecated: NewRsaDecrypter returns a RsaDecrypter with the given file. PKCS#1 v1.5 padding is vulnerable to padding oracle attacks. Use NewRsaOAEPDecrypter instead.
func NewRsaOAEPDecrypter ¶
func NewRsaOAEPDecrypter(file string) (RsaDecrypter, error)
NewRsaOAEPDecrypter returns a RsaDecrypter using OAEP with SHA-256.
type RsaEncrypter ¶
RsaEncrypter represents a RSA encrypter.
func NewRsaEncrypter
deprecated
func NewRsaEncrypter(key []byte) (RsaEncrypter, error)
Deprecated: NewRsaEncrypter returns a RsaEncrypter with the given key. PKCS#1 v1.5 padding is vulnerable to padding oracle attacks. Use NewRsaOAEPEncrypter instead.
func NewRsaOAEPEncrypter ¶
func NewRsaOAEPEncrypter(key []byte) (RsaEncrypter, error)
NewRsaOAEPEncrypter returns a RsaEncrypter using OAEP with SHA-256.