Documentation ¶
Index ¶
- Variables
- type Opts
- type PBKDF2Opts
- type Rsa
- func FromBase64String(data string) Rsa
- func FromBytes(data []byte) Rsa
- func FromHexString(data string) Rsa
- func FromPKCS12Cert(key []byte) Rsa
- func FromPKCS12CertWithPassword(key []byte, password string) Rsa
- func FromPKCS1PrivateKey(key []byte) Rsa
- func FromPKCS1PrivateKeyWithPassword(key []byte, password string) Rsa
- func FromPKCS8PrivateKey(key []byte) Rsa
- func FromPKCS8PrivateKeyWithPassword(key []byte, password string) Rsa
- func FromPrivateKey(key []byte) Rsa
- func FromPrivateKeyWithPassword(key []byte, password string) Rsa
- func FromPublicKey(key []byte) Rsa
- func FromString(data string) Rsa
- func GenerateKey(bits int) Rsa
- func New() Rsa
- func NewRsa() 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 ...any) Rsa
- func (this Rsa) CreatePrivateKey() Rsa
- func (this Rsa) CreatePrivateKeyWithPassword(password string, opts ...string) Rsa
- func (this Rsa) CreatePublicKey() 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) FromPublicKeyNE(nString string, e int) Rsa
- func (this Rsa) FromString(data 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) GetPublicKeyE() int
- func (this Rsa) GetPublicKeyNHexString() string
- 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
- type ScryptOpts
Constants ¶
This section is empty.
Variables ¶
var ( // 获取 Cipher 类型 GetCipherFromName = cryptobin_pkcs8.GetCipherFromName // 获取 hash 类型 GetHashFromName = cryptobin_pkcs8.GetHashFromName )
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") )
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") )
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 FromPKCS12CertWithPassword ¶ added in v1.0.1018
Pkcs12CertWithPassword
func FromPKCS1PrivateKeyWithPassword ¶ added in v1.0.1018
Pkcs1WithPassword
func FromPKCS8PrivateKeyWithPassword ¶ added in v1.0.1018
Pkcs8WithPassword
func FromPrivateKeyWithPassword ¶ added in v1.0.1018
私钥带密码
func GenerateKey ¶ added in v1.0.1018
生成密钥 bits = 512 | 1024 | 2048 | 4096
func (Rsa) CreatePKCS1PrivateKeyWithPassword ¶
生成 PKCS1 私钥带密码 pem 数据 CreatePKCS1PrivateKeyWithPassword("123", "AES256CBC")
func (Rsa) CreatePKCS8PrivateKeyWithPassword ¶
生成 PKCS8 私钥带密码 pem 数据 CreatePKCS8PrivateKeyWithPassword("123", "AES256CBC", "SHA256")
func (Rsa) CreatePrivateKey ¶
生成私钥 pem 数据, PKCS1 别名 使用: obj := New().GenerateKey(2048) priKey := obj.CreatePrivateKey().ToKeyString()
func (Rsa) CreatePrivateKeyWithPassword ¶
生成私钥带密码 pem 数据, PKCS1 别名
func (Rsa) FromPKCS12CertWithPassword ¶
Pkcs12CertWithPassword
func (Rsa) FromPKCS1PrivateKeyWithPassword ¶
Pkcs1WithPassword
func (Rsa) FromPKCS8PrivateKeyWithPassword ¶
Pkcs8WithPassword
func (Rsa) FromPrivateKeyWithPassword ¶
私钥带密码
func (Rsa) FromPublicKeyNE ¶ added in v1.0.1018
模数、指数生成公钥 指数默认为 10001
func (Rsa) GenerateKey ¶
生成密钥 bits = 512 | 1024 | 2048 | 4096
func (Rsa) GetPublicKeyNHexString ¶ added in v1.0.1018
获取 PublicKeyN
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 公钥