Documentation ¶
Index ¶
- Variables
- type Rsa
- func NewRsa() Rsa
- func RsaFromBase64String(data string) Rsa
- func RsaFromBytes(data []byte) Rsa
- func RsaFromHexString(data string) Rsa
- func RsaFromPKCS12Cert(key []byte) Rsa
- func RsaFromPKCS12CertWithPassword(key []byte, password string) Rsa
- func RsaFromPKCS1PrivateKey(key []byte) Rsa
- func RsaFromPKCS1PrivateKeyWithPassword(key []byte, password string) Rsa
- func RsaFromPKCS8PrivateKey(key []byte) Rsa
- func RsaFromPKCS8PrivateKeyWithPassword(key []byte, password string) Rsa
- func RsaFromPrivateKey(key []byte) Rsa
- func RsaFromPrivateKeyWithPassword(key []byte, password string) Rsa
- func RsaFromPublicKey(key []byte) Rsa
- func RsaFromString(data string) Rsa
- func RsaFromYoumarkPKCS8PrivateKeyWithPassword(key []byte, password string) Rsa
- func RsaGenerateKey(bits int) Rsa
- func (this Rsa) CreatePKCS1PrivateKey() Rsa
- func (this Rsa) CreatePKCS1PrivateKeyWithPassword(password string, opts ...string) Rsa
- func (this Rsa) CreatePKCS8PrivateKey() Rsa
- func (this Rsa) CreatePKCS8PrivateKeyWithPassword(password string, opts ...string) Rsa
- func (this Rsa) CreatePrivateKey() Rsa
- func (this Rsa) CreatePrivateKeyWithPassword(password string, opts ...string) Rsa
- func (this Rsa) CreatePublicKey() Rsa
- func (this Rsa) CreateYoumarkPKCS8PrivateKeyWithPassword(password string, opt ...tool.YoumarkPKCS8Opts) Rsa
- func (this Rsa) Decrypt() Rsa
- func (this Rsa) DecryptOAEP(typ ...string) Rsa
- func (this Rsa) Encrypt() Rsa
- func (this Rsa) EncryptOAEP(typ ...string) Rsa
- func (this Rsa) FromBase64String(data string) Rsa
- func (this Rsa) FromBytes(data []byte) Rsa
- func (this Rsa) FromHexString(data string) Rsa
- func (this Rsa) FromPKCS12Cert(key []byte) Rsa
- func (this Rsa) FromPKCS12CertWithPassword(key []byte, password string) Rsa
- func (this Rsa) FromPKCS1PrivateKey(key []byte) Rsa
- func (this Rsa) FromPKCS1PrivateKeyWithPassword(key []byte, password string) Rsa
- func (this Rsa) FromPKCS8PrivateKey(key []byte) Rsa
- func (this Rsa) FromPKCS8PrivateKeyWithPassword(key []byte, password string) Rsa
- func (this Rsa) FromPrivateKey(key []byte) Rsa
- func (this Rsa) FromPrivateKeyWithPassword(key []byte, password string) Rsa
- func (this Rsa) FromPublicKey(key []byte) Rsa
- func (this Rsa) FromString(data string) Rsa
- func (this Rsa) FromYoumarkPKCS8PrivateKeyWithPassword(key []byte, password string) Rsa
- func (this Rsa) GenerateKey(bits int) Rsa
- func (this Rsa) GetData() []byte
- func (this Rsa) GetError() error
- func (this Rsa) GetKeyData() []byte
- func (this Rsa) GetParedData() []byte
- func (this Rsa) GetPrivateKey() *rsa.PrivateKey
- func (this Rsa) GetPublicKey() *rsa.PublicKey
- func (this Rsa) GetSignHash() string
- func (this Rsa) GetVeryed() bool
- func (this Rsa) MakePublicKey() Rsa
- func (this Rsa) OnError(fn RsaErrorFunc) Rsa
- func (this Rsa) PSSSign(opts ...rsa.PSSOptions) Rsa
- func (this Rsa) PSSVery(data []byte, opts ...rsa.PSSOptions) Rsa
- func (this Rsa) ParseRSAPKCS12CertFromPEMWithPassword(pfxData []byte, password string) (*rsa.PrivateKey, error)
- func (this Rsa) ParseRSAPKCS8PrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error)
- func (this Rsa) ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)
- func (this Rsa) ParseRSAPrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error)
- func (this Rsa) ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error)
- func (this Rsa) PriKeyEncrypt() Rsa
- func (this Rsa) PubKeyDecrypt() Rsa
- func (this Rsa) Sign() Rsa
- func (this Rsa) ToBase64String() string
- func (this Rsa) ToBytes() []byte
- func (this Rsa) ToHexString() string
- func (this Rsa) ToKeyBytes() []byte
- func (this Rsa) ToKeyString() string
- func (this Rsa) ToString() string
- func (this Rsa) ToVeryed() bool
- func (this Rsa) Very(data []byte) Rsa
- func (this Rsa) WithData(data []byte) Rsa
- func (this Rsa) WithError(err error) Rsa
- func (this Rsa) WithParedData(data []byte) Rsa
- func (this Rsa) WithPrivateKey(data *rsa.PrivateKey) Rsa
- func (this Rsa) WithPublicKey(data *rsa.PublicKey) Rsa
- func (this Rsa) WithSignHash(data string) Rsa
- func (this Rsa) WithVeryed(data bool) Rsa
- type RsaErrorFunc
Constants ¶
This section is empty.
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") )
View Source
var ( ErrKeyMustBePEMEncoded = errors.New("invalid key: Key must be a PEM encoded PKCS1 or PKCS8 key") ErrNotRSAPrivateKey = errors.New("key is not a valid RSA private key") ErrNotRSAPublicKey = errors.New("key is not a valid RSA public key") )
View Source
var PEMCiphers = map[string]x509.PEMCipher{ "DESCBC": x509.PEMCipherDES, "DESEDE3CBC": x509.PEMCipher3DES, "AES128CBC": x509.PEMCipherAES128, "AES192CBC": x509.PEMCipherAES192, "AES256CBC": x509.PEMCipherAES256, }
pem 加密方式
Functions ¶
This section is empty.
Types ¶
type Rsa ¶
type Rsa struct { // 错误 Error error // contains filtered or unexported fields }
*
- Rsa 加密 *
- @create 2021-8-28
- @author deatil
func RsaFromPKCS12CertWithPassword ¶
Pkcs12CertWithPassword
func RsaFromPKCS1PrivateKeyWithPassword ¶
Pkcs1WithPassword
func RsaFromPKCS8PrivateKeyWithPassword ¶
Pkcs8WithPassword
func RsaFromPrivateKeyWithPassword ¶
私钥带密码
func RsaFromYoumarkPKCS8PrivateKeyWithPassword ¶
设置私钥带密码
func (Rsa) CreatePKCS1PrivateKeyWithPassword ¶
PKCS1 私钥带密码 CreatePKCS1PrivateKeyWithPassword("123", "AES256CBC")
func (Rsa) CreatePKCS8PrivateKeyWithPassword ¶
PKCS8 私钥带密码 CreatePKCS8PrivateKeyWithPassword("123", "AES256CBC", "SHA256")
func (Rsa) CreatePrivateKeyWithPassword ¶
私钥带密码, PKCS1 别名
func (Rsa) CreateYoumarkPKCS8PrivateKeyWithPassword ¶
func (this Rsa) CreateYoumarkPKCS8PrivateKeyWithPassword(password string, opt ...tool.YoumarkPKCS8Opts) Rsa
创建私钥带密码
func (Rsa) FromPKCS12CertWithPassword ¶
Pkcs12CertWithPassword
func (Rsa) FromPKCS1PrivateKeyWithPassword ¶
Pkcs1WithPassword
func (Rsa) FromPKCS8PrivateKeyWithPassword ¶
Pkcs8WithPassword
func (Rsa) FromPrivateKeyWithPassword ¶
私钥带密码
func (Rsa) FromYoumarkPKCS8PrivateKeyWithPassword ¶
设置私钥带密码
func (Rsa) GenerateKey ¶
生成密钥 bits = 512 | 1024 | 2048 | 4096
func (Rsa) PSSSign ¶
func (this Rsa) PSSSign(opts ...rsa.PSSOptions) Rsa
私钥签名 常用为: PS256[SHA256] | PS384[SHA384] | PS512[SHA512]
func (Rsa) PSSVery ¶
func (this Rsa) PSSVery(data []byte, opts ...rsa.PSSOptions) Rsa
公钥验证 使用原始数据[data]对比签名后数据
func (Rsa) ParseRSAPKCS12CertFromPEMWithPassword ¶
func (this Rsa) ParseRSAPKCS12CertFromPEMWithPassword(pfxData []byte, password string) (*rsa.PrivateKey, error)
解析 pkf 证书
func (Rsa) ParseRSAPKCS8PrivateKeyFromPEMWithPassword ¶
func (this Rsa) ParseRSAPKCS8PrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error)
解析 PKCS8 带密码的私钥
func (Rsa) ParseRSAPrivateKeyFromPEM ¶
func (this Rsa) ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)
解析 PKCS1 / PKCS8 私钥
func (Rsa) ParseRSAPrivateKeyFromPEMWithPassword ¶
func (this Rsa) ParseRSAPrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error)
解析 PKCS1 带密码的私钥
func (Rsa) ParseRSAPublicKeyFromPEM ¶
解析 PKCS1 / PKCS8 公钥
Click to show internal directories.
Click to hide internal directories.