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 FromPKCS1PublicKey(key []byte) Rsa
- func FromPKCS8PrivateKey(key []byte) Rsa
- func FromPKCS8PrivateKeyWithPassword(key []byte, password string) Rsa
- func FromPKCS8PublicKey(key []byte) 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 GenerateMultiPrimeKey(nprimes int, bits int) Rsa
- func New() Rsa
- func NewRsa() Rsa
- func (this Rsa) AppendError(err ...error) Rsa
- func (this Rsa) CheckKeyPair() bool
- func (this Rsa) CreatePKCS1PrivateKey() Rsa
- func (this Rsa) CreatePKCS1PrivateKeyWithPassword(password string, opts ...string) Rsa
- func (this Rsa) CreatePKCS1PublicKey() Rsa
- func (this Rsa) CreatePKCS8PrivateKey() Rsa
- func (this Rsa) CreatePKCS8PrivateKeyWithPassword(password string, opts ...any) Rsa
- func (this Rsa) CreatePKCS8PublicKey() Rsa
- func (this Rsa) CreatePrivateKey() Rsa
- func (this Rsa) CreatePrivateKeyWithPassword(password string, opts ...string) Rsa
- func (this Rsa) CreateXMLPrivateKey() Rsa
- func (this Rsa) CreateXMLPublicKey() 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) Error() error
- 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) FromPKCS1PublicKey(key []byte) Rsa
- func (this Rsa) FromPKCS8PrivateKey(key []byte) Rsa
- func (this Rsa) FromPKCS8PrivateKeyWithPassword(key []byte, password string) Rsa
- func (this Rsa) FromPKCS8PublicKey(key []byte) 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) FromXMLPrivateKey(key []byte) Rsa
- func (this Rsa) FromXMLPublicKey(key []byte) Rsa
- func (this Rsa) GenerateKey(bits int) Rsa
- func (this Rsa) GenerateMultiPrimeKey(nprimes int, bits int) Rsa
- func (this Rsa) GetData() []byte
- func (this Rsa) GetErrors() []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) GetVerify() bool
- func (this Rsa) MakeKeyDer() Rsa
- func (this Rsa) MakePublicKey() Rsa
- func (this Rsa) OnError(fn RsaErrorFunc) Rsa
- func (this Rsa) PSSSign(opts ...rsa.PSSOptions) Rsa
- func (this Rsa) PSSVerify(data []byte, opts ...rsa.PSSOptions) Rsa
- func (this Rsa) ParsePKCS12CertFromPEMWithPassword(pfxData []byte, password string) (*rsa.PrivateKey, error)
- func (this Rsa) ParsePKCS1PublicKeyFromPEM(key []byte) (*rsa.PublicKey, error)
- func (this Rsa) ParsePKCS8PrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error)
- func (this Rsa) ParsePKCS8PublicKeyFromPEM(key []byte) (*rsa.PublicKey, error)
- func (this Rsa) ParsePrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)
- func (this Rsa) ParsePrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error)
- func (this Rsa) ParsePrivateKeyFromXML(key []byte) (*rsa.PrivateKey, error)
- func (this Rsa) ParsePublicKeyFromXML(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) ToVerify() bool
- func (this Rsa) ToVerifyInt() int
- func (this Rsa) Verify(data []byte) Rsa
- func (this Rsa) WithData(data []byte) Rsa
- func (this Rsa) WithError(errs []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) WithVerify(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 { // 错误 Errors []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 GenerateMultiPrimeKey ¶ added in v1.0.1051
生成密钥
func (Rsa) CreatePKCS1PrivateKeyWithPassword ¶
生成 PKCS1 私钥带密码 pem 数据 CreatePKCS1PrivateKeyWithPassword("123", "AES256CBC")
func (Rsa) CreatePKCS1PublicKey ¶ added in v1.0.1043
生成 pcks1 公钥 pem 数据
func (Rsa) CreatePKCS8PrivateKeyWithPassword ¶
生成 PKCS8 私钥带密码 pem 数据 CreatePKCS8PrivateKeyWithPassword("123", "AES256CBC", "SHA256")
func (Rsa) CreatePKCS8PublicKey ¶ added in v1.0.1043
生成公钥 pem 数据
func (Rsa) CreatePrivateKey ¶
生成私钥 pem 数据, PKCS1 别名 使用: obj := New().GenerateKey(2048) priKey := obj.CreatePrivateKey().ToKeyString()
func (Rsa) CreatePrivateKeyWithPassword ¶
生成私钥带密码 pem 数据, PKCS1 别名
func (Rsa) CreateXMLPrivateKey ¶ added in v1.0.2002
生成私钥 xml 数据
func (Rsa) CreateXMLPublicKey ¶ added in v1.0.2002
生成公钥 xml 数据
func (Rsa) FromPKCS12CertWithPassword ¶
Pkcs12CertWithPassword
func (Rsa) FromPKCS1PrivateKeyWithPassword ¶
Pkcs1WithPassword
func (Rsa) FromPKCS1PublicKey ¶ added in v1.0.1043
PKCS1 公钥
func (Rsa) FromPKCS8PrivateKeyWithPassword ¶
Pkcs8WithPassword
func (Rsa) FromPKCS8PublicKey ¶ added in v1.0.1043
PKCS8 公钥
func (Rsa) FromPrivateKeyWithPassword ¶
私钥带密码
func (Rsa) FromPublicKeyNE ¶ added in v1.0.1018
模数、指数生成公钥 指数默认为 10001
func (Rsa) FromXMLPrivateKey ¶ added in v1.0.2002
XML 私钥
func (Rsa) FromXMLPublicKey ¶ added in v1.0.2002
XML 公钥
func (Rsa) GenerateKey ¶
生成密钥 bits = 512 | 1024 | 2048 | 4096
func (Rsa) GenerateMultiPrimeKey ¶ added in v1.0.1050
生成密钥
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) PSSVerify ¶ added in v1.0.1033
func (this Rsa) PSSVerify(data []byte, opts ...rsa.PSSOptions) Rsa
公钥验证 使用原始数据[data]对比签名后数据
func (Rsa) ParsePKCS12CertFromPEMWithPassword ¶ added in v1.0.1043
func (this Rsa) ParsePKCS12CertFromPEMWithPassword(pfxData []byte, password string) (*rsa.PrivateKey, error)
解析 pkf 证书
func (Rsa) ParsePKCS1PublicKeyFromPEM ¶ added in v1.0.1043
解析 PKCS1 公钥
func (Rsa) ParsePKCS8PrivateKeyFromPEMWithPassword ¶ added in v1.0.1043
func (this Rsa) ParsePKCS8PrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error)
解析 PKCS8 带密码的私钥
func (Rsa) ParsePKCS8PublicKeyFromPEM ¶ added in v1.0.1043
解析 PKCS8 公钥
func (Rsa) ParsePrivateKeyFromPEM ¶ added in v1.0.1043
func (this Rsa) ParsePrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)
解析 PKCS1 / PKCS8 私钥
func (Rsa) ParsePrivateKeyFromPEMWithPassword ¶ added in v1.0.1043
func (this Rsa) ParsePrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error)
解析 PKCS1 带密码的私钥
func (Rsa) ParsePrivateKeyFromXML ¶ added in v1.0.2002
func (this Rsa) ParsePrivateKeyFromXML(key []byte) (*rsa.PrivateKey, error)
解析 xml 私钥
func (Rsa) ParsePublicKeyFromXML ¶ added in v1.0.2002
解析 xml 公钥