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 FromXMLPrivateKey(key []byte) Rsa
- func FromXMLPublicKey(key []byte) Rsa
- func GenerateKey(bits int) Rsa
- func GenerateKeyWithSeed(reader io.Reader, bits int) Rsa
- func GenerateMultiPrimeKey(nprimes int, bits int) Rsa
- func GenerateMultiPrimeKeyWithSeed(reader io.Reader, 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) CreatePublicKey() 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) FromPKCS1PrivateKeyDer(der []byte) Rsa
- func (this Rsa) FromPKCS1PrivateKeyWithPassword(key []byte, password string) Rsa
- func (this Rsa) FromPKCS1PublicKey(key []byte) Rsa
- func (this Rsa) FromPKCS1PublicKeyDer(der []byte) Rsa
- func (this Rsa) FromPKCS8PrivateKey(key []byte) Rsa
- func (this Rsa) FromPKCS8PrivateKeyDer(der []byte) Rsa
- func (this Rsa) FromPKCS8PrivateKeyWithPassword(key []byte, password string) Rsa
- func (this Rsa) FromPKCS8PublicKey(key []byte) Rsa
- func (this Rsa) FromPKCS8PublicKeyDer(der []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) GenerateKeyWithSeed(reader io.Reader, bits int) Rsa
- func (this Rsa) GenerateMultiPrimeKey(nprimes int, bits int) Rsa
- func (this Rsa) GenerateMultiPrimeKeyWithSeed(reader io.Reader, 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() crypto.Hash
- 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) ParsePKCS12CertFromPEMWithPassword(pfxData []byte, password string) (*rsa.PrivateKey, error)
- func (this Rsa) ParsePKCS1PrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)
- func (this Rsa) ParsePKCS1PrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error)
- func (this Rsa) ParsePKCS1PublicKeyFromPEM(key []byte) (*rsa.PublicKey, error)
- func (this Rsa) ParsePKCS8PrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)
- func (this Rsa) ParsePKCS8PrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error)
- func (this Rsa) ParsePKCS8PublicKeyFromPEM(key []byte) (*rsa.PublicKey, error)
- func (this Rsa) ParsePrivateKeyFromXML(key []byte) (*rsa.PrivateKey, error)
- func (this Rsa) ParsePublicKeyFromXML(key []byte) (*rsa.PublicKey, error)
- func (this Rsa) PrivateKeyEncrypt() Rsa
- func (this Rsa) PublicKeyDecrypt() Rsa
- func (this Rsa) SetSignHash(name string) Rsa
- func (this Rsa) Sign() Rsa
- func (this Rsa) SignPSS(opts ...rsa.PSSOptions) 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) VerifyPSS(data []byte, opts ...rsa.PSSOptions) 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(h crypto.Hash) 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") )
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
Pkcs12Cert 带密码
func FromPKCS1PrivateKeyWithPassword ¶ added in v1.0.1018
PKCS1 私钥带密码
func FromPKCS8PrivateKeyWithPassword ¶ added in v1.0.1018
PKCS8 私钥带密码
func FromPrivateKeyWithPassword ¶ added in v1.0.1018
私钥带密码
func GenerateKey ¶ added in v1.0.1018
生成密钥 bits = 512 | 1024 | 2048 | 4096
func GenerateKeyWithSeed ¶ added in v1.0.2026
生成密钥 bits = 512 | 1024 | 2048 | 4096
func GenerateMultiPrimeKey ¶ added in v1.0.1051
生成密钥
func GenerateMultiPrimeKeyWithSeed ¶ added in v1.0.2026
生成密钥
func (Rsa) CreatePKCS1PrivateKeyWithPassword ¶
生成 PKCS1 私钥带密码 pem 数据 CreatePKCS1PrivateKeyWithPassword("123", "AES256CBC") PEMCipher: DESCBC | DESEDE3CBC | AES128CBC | AES192CBC | 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) FromPKCS1PrivateKeyDer ¶ added in v1.0.2015
Pkcs1 DER
func (Rsa) FromPKCS1PrivateKeyWithPassword ¶
Pkcs1WithPassword
func (Rsa) FromPKCS1PublicKey ¶ added in v1.0.1043
PKCS1 公钥
func (Rsa) FromPKCS1PublicKeyDer ¶ added in v1.0.2015
PKCS1 DER 公钥
func (Rsa) FromPKCS8PrivateKeyDer ¶ added in v1.0.2015
Pkcs8 DER
func (Rsa) FromPKCS8PrivateKeyWithPassword ¶
Pkcs8WithPassword
func (Rsa) FromPKCS8PublicKey ¶ added in v1.0.1043
PKCS8 公钥
func (Rsa) FromPKCS8PublicKeyDer ¶ added in v1.0.2015
PKCS8 DER 公钥
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) GenerateKeyWithSeed ¶ added in v1.0.2026
生成密钥 bits = 512 | 1024 | 2048 | 4096
func (Rsa) GenerateMultiPrimeKey ¶ added in v1.0.1050
生成密钥
func (Rsa) GenerateMultiPrimeKeyWithSeed ¶ added in v1.0.2026
生成密钥
func (Rsa) GetPublicKeyNHexString ¶ added in v1.0.1018
获取 PublicKeyN
func (Rsa) ParsePKCS12CertFromPEMWithPassword ¶ added in v1.0.1043
func (this Rsa) ParsePKCS12CertFromPEMWithPassword(pfxData []byte, password string) (*rsa.PrivateKey, error)
解析 pkf 证书
func (Rsa) ParsePKCS1PrivateKeyFromPEM ¶ added in v1.0.2014
func (this Rsa) ParsePKCS1PrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)
解析 PKCS1 私钥
func (Rsa) ParsePKCS1PrivateKeyFromPEMWithPassword ¶ added in v1.0.2014
func (this Rsa) ParsePKCS1PrivateKeyFromPEMWithPassword(key []byte, password string) (*rsa.PrivateKey, error)
解析 PKCS1 带密码的私钥
func (Rsa) ParsePKCS1PublicKeyFromPEM ¶ added in v1.0.1043
解析 PKCS1 公钥
func (Rsa) ParsePKCS8PrivateKeyFromPEM ¶ added in v1.0.2014
func (this Rsa) ParsePKCS8PrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)
解析 PKCS8 私钥
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) 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 公钥
func (Rsa) SignPSS ¶ added in v1.0.2026
func (this Rsa) SignPSS(opts ...rsa.PSSOptions) Rsa
私钥签名 常用为: PS256[SHA256] | PS384[SHA384] | PS512[SHA512]