cryptoutil

package
v1.14.3 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEccVerification = errors.New("ecdsa: verification error")

Functions

func AESDecrypt

func AESDecrypt(crypted, key []byte) ([]byte, error)

func AESDecryptPEM

func AESDecryptPEM(data, key []byte) ([]byte, error)

func AESEncrypt

func AESEncrypt(data, key []byte) ([]byte, error)

func AESEncryptPEM

func AESEncryptPEM(data, key []byte) ([]byte, error)

func ECCSign added in v1.12.0

func ECCSign(data, priKey []byte) (string, error)

ECCSign 使用 ecc 私钥签名,接收 []byte 类型的公钥

func ECCSignPEM added in v1.12.0

func ECCSignPEM(data, priKey []byte) (string, error)

ECCSignPEM 使用 ecc 私钥签名,接收PEM格式的公钥

func ECCSign_ added in v1.12.0

func ECCSign_(data []byte, priKey *ecdsa.PrivateKey) (sigB64 string, err error)

ECCSign_ 使用 ecc 私钥签名,接收 *ecdsa.PrivateKey 公钥

func ECCVerify added in v1.12.0

func ECCVerify(data []byte, sigB64 string, pubKey []byte) error

ECCVerify 使用 ecc 公钥验签,接收 []byte 类型的公钥

func ECCVerifyPEM added in v1.12.0

func ECCVerifyPEM(data []byte, signStr string, pubKey []byte) error

ECCVerifyPEM 使用 ecc 公钥验签,接收PEM格式的公钥

func ECCVerify_ added in v1.12.0

func ECCVerify_(data []byte, sigB64 string, pubKey *ecdsa.PublicKey) error

ECCVerify_ 使用 ecc 公钥验签,接收 *ecdsa.PublicKey 公钥

func GenerateAESKey

func GenerateAESKey() (key []byte)

GenerateAESKey 生成 256 位 aes 密钥;用 md5 算的 32 个字节

func GenerateECCKey added in v1.12.0

func GenerateECCKey(c elliptic.Curve) (priKey []byte, pubKey []byte, err error)

GenerateECCKey 生成 ecc 密钥,c 可以是

elliptic.P224()
elliptic.P256()
elliptic.P384()
elliptic.P521()

或其他椭圆曲线算法

func GeneratePEMAESKey

func GeneratePEMAESKey() (key []byte)

GeneratePEMAESKey 生成 256 位 PME格式 的 aes 密钥;用 md5 算的 32 个字节

func GeneratePEMECCKey added in v1.12.0

func GeneratePEMECCKey(c elliptic.Curve) (priKey []byte, pubKey []byte, err error)

GeneratePEMECCKey 生成 PEM格式 的 ecc 密钥,c 可以是

elliptic.P224()
elliptic.P256()
elliptic.P384()
elliptic.P521()

或其他椭圆曲线算法

func GeneratePEMRSAKey

func GeneratePEMRSAKey(bits int) (priKey []byte, pubKey []byte, err error)

GeneratePEMRSAKey 生成 PEM格式 的 rsa 密钥,bits 可以给 2048

func GenerateRSAKey

func GenerateRSAKey(bits int) (priKey []byte, pubKey []byte, err error)

GenerateRSAKey 生成 rsa 密钥,bits 可以给 2048

func PKCS5Padding

func PKCS5Padding(data []byte, blockSize int) []byte

func PKCS5UnPadding

func PKCS5UnPadding(data []byte) []byte

func RSADecrypt

func RSADecrypt(data, priKey []byte) ([]byte, error)

RSADecrypt 使用 RSA 私钥解密,接收 []byte 类型的私钥

OAEP: sha256

func RSADecryptPEM

func RSADecryptPEM(data, priKey []byte) ([]byte, error)

RSADecryptPEM 使用 RSA 私钥解密,接收PEM格式的私钥

OAEP: sha256

func RSADecryptPKCS1v15 added in v1.7.3

func RSADecryptPKCS1v15(data, priKey []byte) ([]byte, error)

RSADecrypt 使用 RSA 私钥解密,接收 []byte 类型的私钥

PKCS1v15

func RSADecryptPKCS1v15PEM added in v1.7.3

func RSADecryptPKCS1v15PEM(data, priKey []byte) ([]byte, error)

RSADecryptPEM 使用 RSA 私钥解密,接收PEM格式的私钥

PKCS1v15

func RSADecryptPKCS1v15_ added in v1.7.3

func RSADecryptPKCS1v15_(crypted []byte, priKey *rsa.PrivateKey) ([]byte, error)

RSADecrypt_ 使用 RSA 私钥解密,接收 *rsa.PrivateKey 私钥

PKCS1v15

func RSADecrypt_

func RSADecrypt_(crypted []byte, priKey *rsa.PrivateKey) ([]byte, error)

RSADecrypt_ 使用 RSA 私钥解密,接收 *rsa.PrivateKey 私钥

OAEP: sha256

func RSAEncrypt

func RSAEncrypt(data, pubKey []byte) ([]byte, error)

RSAEncrypt 使用 RSA 公钥加密,接收 []byte 类型的公钥

OAEP: sha256

func RSAEncryptPEM

func RSAEncryptPEM(data, pubKey []byte) ([]byte, error)

RSAEncryptPEM 使用 RSA 公钥加密,接收PEM格式的公钥

OAEP: sha256

func RSAEncryptPKCS1v15 added in v1.7.3

func RSAEncryptPKCS1v15(data, pubKey []byte) ([]byte, error)

RSAEncrypt 使用 RSA 公钥加密,接收 []byte 类型的公钥

PKCS1v15

func RSAEncryptPKCS1v15PEM added in v1.7.3

func RSAEncryptPKCS1v15PEM(data, pubKey []byte) ([]byte, error)

RSAEncryptPEM 使用 RSA 公钥加密,接收PEM格式的公钥

PKCS1v15

func RSAEncryptPKCS1v15_ added in v1.7.3

func RSAEncryptPKCS1v15_(data []byte, pubKey *rsa.PublicKey) ([]byte, error)

RSAEncrypt_ 使用 RSA 公钥加密,接收 *rsa.PublicKey 公钥

PKCS1v15

func RSAEncrypt_

func RSAEncrypt_(data []byte, pubKey *rsa.PublicKey) ([]byte, error)

RSAEncrypt_ 使用 RSA 公钥加密,接收 *rsa.PublicKey 公钥

OAEP: sha256

func RSASignPKCS1v15 added in v1.12.0

func RSASignPKCS1v15(data, priKey []byte) (string, error)

RSASignPKCS1v15 使用 rsa 私钥签名(PKCS1v15),接收 []byte 类型的私钥

func RSASignPKCS1v15PEM added in v1.12.0

func RSASignPKCS1v15PEM(data, priKey []byte) (string, error)

RSASignPKCS1v15PEM 使用 rsa 私钥签名(PKCS1v15),接收PEM格式的私钥

func RSASignPKCS1v15_ added in v1.12.0

func RSASignPKCS1v15_(data []byte, priKey *rsa.PrivateKey) (string, error)

RSASignPKCS1v15_ 使用 rsa 私钥签名(PKCS1v15),接收 *rsa.PrivateKey 私钥

func RSASignPSS added in v1.12.0

func RSASignPSS(data, priKey []byte) (string, error)

RSASignPSS 使用 rsa 私钥签名(PSS),接收 []byte 类型的私钥

func RSASignPSSPEM added in v1.12.0

func RSASignPSSPEM(data, priKey []byte) (string, error)

RSASignPSSPEM 使用 rsa 私钥签名(PSS),接收PEM格式的私钥

func RSASignPSS_ added in v1.12.0

func RSASignPSS_(data []byte, priKey *rsa.PrivateKey) (string, error)

RSASignPSS_ 使用 rsa 私钥签名(PSS),接收 *rsa.PrivateKey 私钥

func RSAVerifyPKCS1v15 added in v1.12.0

func RSAVerifyPKCS1v15(data []byte, signStr string, pubKey []byte) error

RSAVerifyPKCS1v15 使用 rsa 公钥验签(PKCS1v15),接收 []byte 类型的公钥

func RSAVerifyPKCS1v15PEM added in v1.12.0

func RSAVerifyPKCS1v15PEM(data []byte, signStr string, pubKey []byte) error

RSAVerifyPKCS1v15PEM 使用 rsa 公钥验签(PKCS1v15),接收PEM格式的公钥

func RSAVerifyPKCS1v15_ added in v1.12.0

func RSAVerifyPKCS1v15_(data []byte, signStr string, pubKey *rsa.PublicKey) error

RSAVerifyPKCS1v15_ 使用 rsa 公钥验签(PKCS1v15),接收 *rsa.PublicKey 公钥

func RSAVerifyPSS added in v1.12.0

func RSAVerifyPSS(data []byte, signStr string, pubKey []byte) error

RSAVerifyPSS 使用 rsa 公钥验签(PSS),接收 []byte 类型的公钥

func RSAVerifyPSSPEM added in v1.12.0

func RSAVerifyPSSPEM(data []byte, signStr string, pubKey []byte) error

RSAVerifyPSSPEM 使用 rsa 公钥验签(PSS),接收PEM格式的公钥

func RSAVerifyPSS_ added in v1.12.0

func RSAVerifyPSS_(data []byte, signStr string, pubKey *rsa.PublicKey) error

RSAVerifyPSS_ 使用 rsa 公钥验签(PSS),接收 *rsa.PublicKey 公钥

Types

This section is empty.

Jump to

Keyboard shortcuts

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