Documentation ¶
Index ¶
- Constants
- Variables
- func AddOidAsn1(name string, identifier asn1.ObjectIdentifier)
- func AddOidHash(name string, value func() hash.Hash)
- func AddRfc1423Algo(value rfc1423Algo)
- func AppendOID(b asn1.ObjectIdentifier, v ...int) asn1.ObjectIdentifier
- func DecryptPEMBlock(block *pem.Block, password []byte) ([]byte, error)
- func DecryptPKCS8PrivateKey(data, password []byte) ([]byte, error)
- func EncryptPKCS8PrivateKey(rand io.Reader, blockType string, data []byte, password []byte, ...) (*pem.Block, error)
- func YoumarkPKCS8MarshalPrivateKey(priv any, password []byte, opts *youmarkPKCS8.Opts) ([]byte, error)
- func YoumarkPKCS8ParsePrivateKey(der []byte, password []byte) (any, youmarkPKCS8.KDFParameters, error)
- type CA
- func (this CA) CreateCA() CA
- func (this CA) CreateCSR() CA
- func (this CA) CreateCert(ca any) CA
- func (this CA) CreatePKCS12Cert(caCerts []*x509.Certificate, pwd string) CA
- func (this CA) CreatePKCS12CertTrustStore(certs []*x509.Certificate, password string) CA
- func (this CA) CreatePrivateKey() CA
- func (this CA) DecodePKCS12CertChain(pfxData []byte, password string) (privateKey interface{}, certificate *x509.Certificate, ...)
- func (this CA) DecodePKCS12CertTrustStore(pfxData []byte, password string) (certs []*x509.Certificate, err error)
- func (this CA) FromCert(cert *x509.Certificate) CA
- func (this CA) FromCertRequest(cert *x509.CertificateRequest) CA
- func (this CA) FromCertificateDer(der []byte) CA
- func (this CA) FromCertificateRequestDer(asn1Data []byte) CA
- func (this CA) FromPKCS12Cert(pfxData []byte, password string) CA
- func (this CA) FromPrivateKey(key any) CA
- func (this CA) FromPublicKey(key any) CA
- func (this CA) FromSM2PKCS12Cert(pfxData []byte, password string) CA
- func (this CA) FromSM2PKCS12OneCert(pfxData []byte, password string) CA
- func (this CA) GenerateEcdsaKey(curve string) CA
- func (this CA) GenerateEdDSAKey() CA
- func (this CA) GenerateRsaKey(bits int) CA
- func (this CA) GenerateSM2Key() CA
- func (this CA) GetCert() any
- func (this CA) GetCertRequest() any
- func (this CA) GetError() error
- func (this CA) GetKeyData() []byte
- func (this CA) GetPrivateKey() any
- func (this CA) GetPublicKey() any
- func (this CA) GetSM2SignatureAlgorithm(name string) sm2X509.SignatureAlgorithm
- func (this CA) GetSignatureAlgorithm(name string) x509.SignatureAlgorithm
- func (this CA) MakeCA(subject *pkix.Name, expire int, signAlgName string) CA
- func (this CA) MakeCSR(country []string, organization []string, organizationalUnit []string, ...) CA
- func (this CA) MakeCert(subject *pkix.Name, expire int, dns []string, ip []net.IP, signAlgName string) CA
- func (this CA) MakeSM2CA(subject *pkix.Name, expire int, signAlgName string) CA
- func (this CA) MakeSM2CSR(country []string, organization []string, organizationalUnit []string, ...) CA
- func (this CA) MakeSM2Cert(subject *pkix.Name, expire int, dns []string, ip []net.IP, signAlgName string) CA
- func (this CA) OnError(fn CAErrorFunc) CA
- func (this CA) SM2Verify(rootPEM string, certPEM string, opts sm2X509.VerifyOptions) (bool, error)
- func (this CA) ToKeyBytes() []byte
- func (this CA) ToKeyString() string
- func (this CA) UpdateCert(fn func(*x509.Certificate) *x509.Certificate) CA
- func (this CA) UpdateCertRequest(fn func(*x509.CertificateRequest) *x509.CertificateRequest) CA
- func (this CA) UpdateSM2Cert(fn func(*x509.Certificate) *x509.Certificate) CA
- func (this CA) UpdateSM2CertRequest(fn func(*x509.CertificateRequest) *x509.CertificateRequest) CA
- func (this CA) Verify(rootPEM string, certPEM string, opts x509.VerifyOptions) (bool, error)
- func (this CA) WithCert(data any) CA
- func (this CA) WithCertRequest(data any) CA
- func (this CA) WithError(err error) CA
- func (this CA) WithKeyData(data []byte) CA
- func (this CA) WithPrivateKey(data any) CA
- func (this CA) WithPublicKey(data any) CA
- type CACertificate
- type CACertificateRequest
- type CAErrorFunc
- type CAExtKeyUsage
- type CAKeyUsage
- type CAPkixAlgorithmIdentifier
- type CAPkixAttributeTypeAndValue
- type CAPkixAttributeTypeAndValueSET
- type CAPkixCertificateList
- type CAPkixExtension
- type CAPkixName
- type CAPkixRDNSequence
- type CAPkixRevokedCertificate
- type CAPkixTBSCertificateList
- type CAPublicKeyAlgorithm
- type CASM2Certificate
- type CASM2CertificateRequest
- type CASM2ExtKeyUsage
- type CASM2KeyUsage
- type CASM2PublicKeyAlgorithm
- type CASM2SignatureAlgorithm
- type CASM2VerifyOptions
- type CASignatureAlgorithm
- type CAVerifyOptions
- type Cipher
- type CipherFunc
- type CipherFuncMap
- type CryptoHashMap
- type Cryptobin
- func (this Cryptobin) Aes() Cryptobin
- func (this Cryptobin) AesCFBDecrypt() Cryptobin
- func (this Cryptobin) AesCFBEncrypt() Cryptobin
- func (this Cryptobin) AesECBDecrypt() Cryptobin
- func (this Cryptobin) AesECBEncrypt() Cryptobin
- func (this Cryptobin) AesECBGenerateKey(key []byte) (genKey []byte)
- func (this Cryptobin) Blowfish(salt ...string) Cryptobin
- func (this Cryptobin) CBC() Cryptobin
- func (this Cryptobin) CFB() Cryptobin
- func (this Cryptobin) CTR() Cryptobin
- func (this Cryptobin) Cast5() Cryptobin
- func (this Cryptobin) Chacha20(nonce string, counter ...uint32) Cryptobin
- func (this Cryptobin) Chacha20poly1305(nonce string, additional string) Cryptobin
- func (this Cryptobin) CheckGuessMultiple() bool
- func (this Cryptobin) CipherBlock(key []byte) (cipher.Block, error)
- func (this Cryptobin) CipherDecrypt() Cryptobin
- func (this Cryptobin) CipherEncrypt() Cryptobin
- func (this Cryptobin) Decrypt() Cryptobin
- func (this Cryptobin) Des() Cryptobin
- func (this Cryptobin) ECB() Cryptobin
- func (this Cryptobin) Encrypt() Cryptobin
- func (this Cryptobin) FromBase64String(data string) Cryptobin
- func (this Cryptobin) FromBytes(data []byte) Cryptobin
- func (this Cryptobin) FromHexString(data string) Cryptobin
- func (this Cryptobin) FromString(data string) Cryptobin
- func (this Cryptobin) FuncDecrypt(f func(Cryptobin) Cryptobin) Cryptobin
- func (this Cryptobin) FuncEncrypt(f func(Cryptobin) Cryptobin) Cryptobin
- func (this Cryptobin) GCM(nonce string, additional ...string) Cryptobin
- func (this Cryptobin) GetConfig() map[string]any
- func (this Cryptobin) GetData() []byte
- func (this Cryptobin) GetError() error
- func (this Cryptobin) GetIv() []byte
- func (this Cryptobin) GetKey() []byte
- func (this Cryptobin) GetMode() string
- func (this Cryptobin) GetMultiple() string
- func (this Cryptobin) GetOneConfig(key string) any
- func (this Cryptobin) GetPadding() string
- func (this Cryptobin) GetParsedData() []byte
- func (this Cryptobin) GuessDecrypt() Cryptobin
- func (this Cryptobin) GuessEncrypt() Cryptobin
- func (this Cryptobin) ISO10126Padding() Cryptobin
- func (this Cryptobin) ISO7816_4Padding() Cryptobin
- func (this Cryptobin) NoPadding() Cryptobin
- func (this Cryptobin) NoParse() Cryptobin
- func (this Cryptobin) OFB() Cryptobin
- func (this Cryptobin) OnError(fn ErrorFunc) Cryptobin
- func (this Cryptobin) PKCS1Padding(bt ...string) Cryptobin
- func (this Cryptobin) PKCS5Padding() Cryptobin
- func (this Cryptobin) PKCS7Padding() Cryptobin
- func (this Cryptobin) Padding(plainText []byte, blockSize int) []byte
- func (this Cryptobin) RC4() Cryptobin
- func (this Cryptobin) RsaDecrypt(password ...string) Cryptobin
- func (this Cryptobin) RsaEncrypt() Cryptobin
- func (this Cryptobin) RsaOAEPDecrypt(typ string, password ...string) Cryptobin
- func (this Cryptobin) RsaOAEPEncrypt(typ string) Cryptobin
- func (this Cryptobin) RsaPrikeyEncrypt(password ...string) Cryptobin
- func (this Cryptobin) RsaPubkeyDecrypt() Cryptobin
- func (this Cryptobin) SM2Decrypt(password ...string) Cryptobin
- func (this Cryptobin) SM2Encrypt() Cryptobin
- func (this Cryptobin) SM4() Cryptobin
- func (this Cryptobin) SetIv(data string) Cryptobin
- func (this Cryptobin) SetKey(data string) Cryptobin
- func (this Cryptobin) String() string
- func (this Cryptobin) TBCPadding() Cryptobin
- func (this Cryptobin) Tea(rounds ...int) Cryptobin
- func (this Cryptobin) ToBase64String() string
- func (this Cryptobin) ToBytes() []byte
- func (this Cryptobin) ToHexString() string
- func (this Cryptobin) ToString() string
- func (this Cryptobin) TriDes() Cryptobin
- func (this Cryptobin) Twofish() Cryptobin
- func (this Cryptobin) UnPadding(cipherText []byte) []byte
- func (this Cryptobin) WithConfig(config map[string]any) Cryptobin
- func (this Cryptobin) WithData(data []byte) Cryptobin
- func (this Cryptobin) WithError(err error) Cryptobin
- func (this Cryptobin) WithIv(iv []byte) Cryptobin
- func (this Cryptobin) WithKey(key []byte) Cryptobin
- func (this Cryptobin) WithMode(mode string) Cryptobin
- func (this Cryptobin) WithMultiple(multiple string) Cryptobin
- func (this Cryptobin) WithOneConfig(key string, value any) Cryptobin
- func (this Cryptobin) WithPadding(padding string) Cryptobin
- func (this Cryptobin) WithParsedData(data []byte) Cryptobin
- func (this Cryptobin) X923Padding() Cryptobin
- func (this Cryptobin) Xtea() Cryptobin
- func (this Cryptobin) Xts(cipher string, sectorNum uint64) Cryptobin
- func (this Cryptobin) ZeroPadding() Cryptobin
- type DSA
- func DSAFromBase64String(data string) DSA
- func DSAFromBytes(data []byte) DSA
- func DSAFromHexString(data string) DSA
- func DSAFromPrivateKey(key []byte) DSA
- func DSAFromPrivateKeyWithPassword(key []byte, password string) DSA
- func DSAFromPublicKey(key []byte) DSA
- func DSAFromString(data string) DSA
- func DSAGenerateKey(ln string) DSA
- func NewDSA() DSA
- func (this DSA) CreatePrivateKey() DSA
- func (this DSA) CreatePrivateKeyWithPassword(password string, opts ...string) DSA
- func (this DSA) CreatePublicKey() DSA
- func (this DSA) DataHash(signHash string, data []byte) []byte
- func (this DSA) FromBase64String(data string) DSA
- func (this DSA) FromBytes(data []byte) DSA
- func (this DSA) FromHexString(data string) DSA
- func (this DSA) FromPrivateKey(key []byte) DSA
- func (this DSA) FromPrivateKeyWithPassword(key []byte, password string) DSA
- func (this DSA) FromPublicKey(key []byte) DSA
- func (this DSA) FromString(data string) DSA
- func (this DSA) GenerateKey(ln string) DSA
- func (this DSA) GetData() []byte
- func (this DSA) GetError() error
- func (this DSA) GetKeyData() []byte
- func (this DSA) GetParedData() []byte
- func (this DSA) GetPrivateKey() *dsa.PrivateKey
- func (this DSA) GetPublicKey() *dsa.PublicKey
- func (this DSA) GetSignHash() string
- func (this DSA) GetVeryed() bool
- func (this DSA) MakePublicKey() DSA
- func (this DSA) MarshalPrivateKey(key *dsa.PrivateKey) ([]byte, error)
- func (this DSA) MarshalPublicKey(key *dsa.PublicKey) ([]byte, error)
- func (this DSA) OnError(fn DSAErrorFunc) DSA
- func (this DSA) ParsePrivateKey(derBytes []byte) (*dsa.PrivateKey, error)
- func (this DSA) ParsePrivateKeyFromPEM(key []byte) (*dsa.PrivateKey, error)
- func (this DSA) ParsePrivateKeyFromPEMWithPassword(key []byte, password string) (*dsa.PrivateKey, error)
- func (this DSA) ParsePublicKey(derBytes []byte) (*dsa.PublicKey, error)
- func (this DSA) ParsePublicKeyFromPEM(key []byte) (*dsa.PublicKey, error)
- func (this DSA) Sign(separator ...string) DSA
- func (this DSA) SignAsn1() DSA
- func (this DSA) SignBytes() DSA
- func (this DSA) SignHex() DSA
- func (this DSA) ToBase64String() string
- func (this DSA) ToBytes() []byte
- func (this DSA) ToHexString() string
- func (this DSA) ToKeyBytes() []byte
- func (this DSA) ToKeyString() string
- func (this DSA) ToString() string
- func (this DSA) ToVeryed() bool
- func (this DSA) VerifyAsn1(data []byte) DSA
- func (this DSA) VerifyBytes(data []byte) DSA
- func (this DSA) VerifyHex(data []byte) DSA
- func (this DSA) Very(data []byte, separator ...string) DSA
- func (this DSA) WithData(data []byte) DSA
- func (this DSA) WithError(err error) DSA
- func (this DSA) WithParedData(data []byte) DSA
- func (this DSA) WithPrivateKey(data *dsa.PrivateKey) DSA
- func (this DSA) WithPublicKey(data *dsa.PublicKey) DSA
- func (this DSA) WithSignHash(data string) DSA
- func (this DSA) WithVeryed(data bool) DSA
- type DSAErrorFunc
- type DSASignature
- type Ecdsa
- func EcdsaFromBase64String(data string) Ecdsa
- func EcdsaFromBytes(data []byte) Ecdsa
- func EcdsaFromHexString(data string) Ecdsa
- func EcdsaFromPKCS8PrivateKey(key []byte) Ecdsa
- func EcdsaFromPKCS8PrivateKeyWithPassword(key []byte, password string) Ecdsa
- func EcdsaFromPrivateKey(key []byte) Ecdsa
- func EcdsaFromPrivateKeyWithPassword(key []byte, password string) Ecdsa
- func EcdsaFromPublicKey(key []byte) Ecdsa
- func EcdsaFromString(data string) Ecdsa
- func EcdsaFromYoumarkPKCS8PrivateKeyWithPassword(key []byte, password string) Ecdsa
- func EcdsaGenerateKey(hash string) Ecdsa
- func NewEcdsa() Ecdsa
- func (this Ecdsa) CreatePKCS8PrivateKey() Ecdsa
- func (this Ecdsa) CreatePKCS8PrivateKeyWithPassword(password string, opts ...string) Ecdsa
- func (this Ecdsa) CreatePrivateKey() Ecdsa
- func (this Ecdsa) CreatePrivateKeyWithPassword(password string, opts ...string) Ecdsa
- func (this Ecdsa) CreatePublicKey() Ecdsa
- func (this Ecdsa) CreateYoumarkPKCS8PrivateKeyWithPassword(password string, opt ...YoumarkPKCS8Opts) Ecdsa
- func (this Ecdsa) DataHash(signHash string, data []byte) []byte
- func (this Ecdsa) FromBase64String(data string) Ecdsa
- func (this Ecdsa) FromBytes(data []byte) Ecdsa
- func (this Ecdsa) FromHexString(data string) Ecdsa
- func (this Ecdsa) FromPKCS8PrivateKey(key []byte) Ecdsa
- func (this Ecdsa) FromPKCS8PrivateKeyWithPassword(key []byte, password string) Ecdsa
- func (this Ecdsa) FromPrivateKey(key []byte) Ecdsa
- func (this Ecdsa) FromPrivateKeyBytes(priByte []byte) Ecdsa
- func (this Ecdsa) FromPrivateKeyDBytes(DBytes []byte) Ecdsa
- func (this Ecdsa) FromPrivateKeyString(keyString string) Ecdsa
- func (this Ecdsa) FromPrivateKeyWithPassword(key []byte, password string) Ecdsa
- func (this Ecdsa) FromPublicKey(key []byte) Ecdsa
- func (this Ecdsa) FromPublicKeyString(keyString string) Ecdsa
- func (this Ecdsa) FromPublicKeyXYBytes(XBytes, YBytes []byte) Ecdsa
- func (this Ecdsa) FromString(data string) Ecdsa
- func (this Ecdsa) FromYoumarkPKCS8PrivateKeyWithPassword(key []byte, password string) Ecdsa
- func (this Ecdsa) GenerateKey() Ecdsa
- func (this Ecdsa) GetData() []byte
- func (this Ecdsa) GetError() error
- func (this Ecdsa) GetKeyData() []byte
- func (this Ecdsa) GetParedData() []byte
- func (this Ecdsa) GetPrivateKey() *ecdsa.PrivateKey
- func (this Ecdsa) GetPrivateKeyCurve() elliptic.Curve
- func (this Ecdsa) GetPrivateKeyD() *big.Int
- func (this Ecdsa) GetPrivateKeyX() *big.Int
- func (this Ecdsa) GetPrivateKeyY() *big.Int
- func (this Ecdsa) GetPublicKey() *ecdsa.PublicKey
- func (this Ecdsa) GetPublicKeyCurve() elliptic.Curve
- func (this Ecdsa) GetPublicKeyX() *big.Int
- func (this Ecdsa) GetPublicKeyY() *big.Int
- func (this Ecdsa) GetSignHash() string
- func (this Ecdsa) GetVeryed() bool
- func (this Ecdsa) MakePublicKey() Ecdsa
- func (this Ecdsa) OnError(fn EcdsaErrorFunc) Ecdsa
- func (this Ecdsa) ParseECPKCS8PrivateKeyFromPEMWithPassword(key []byte, password string) (*ecdsa.PrivateKey, error)
- func (this Ecdsa) ParseECPrivateKeyFromPEM(key []byte) (*ecdsa.PrivateKey, error)
- func (this Ecdsa) ParseECPrivateKeyFromPEMWithPassword(key []byte, password string) (*ecdsa.PrivateKey, error)
- func (this Ecdsa) ParseECPublicKeyFromPEM(key []byte) (*ecdsa.PublicKey, error)
- func (this Ecdsa) Sign(separator ...string) Ecdsa
- func (this Ecdsa) SignAsn1() Ecdsa
- func (this Ecdsa) SignHex() Ecdsa
- func (this Ecdsa) ToBase64String() string
- func (this Ecdsa) ToBytes() []byte
- func (this Ecdsa) ToHexString() string
- func (this Ecdsa) ToKeyBytes() []byte
- func (this Ecdsa) ToKeyString() string
- func (this Ecdsa) ToString() string
- func (this Ecdsa) ToVeryed() bool
- func (this Ecdsa) VerifyAsn1(data []byte) Ecdsa
- func (this Ecdsa) VerifyHex(data []byte) Ecdsa
- func (this Ecdsa) Very(data []byte, separator ...string) Ecdsa
- func (this Ecdsa) WithCurve(curve string) Ecdsa
- func (this Ecdsa) WithData(data []byte) Ecdsa
- func (this Ecdsa) WithError(err error) Ecdsa
- func (this Ecdsa) WithParedData(data []byte) Ecdsa
- func (this Ecdsa) WithPrivateKey(data *ecdsa.PrivateKey) Ecdsa
- func (this Ecdsa) WithPublicKey(data *ecdsa.PublicKey) Ecdsa
- func (this Ecdsa) WithSignHash(hash string) Ecdsa
- func (this Ecdsa) WithVeryed(data bool) Ecdsa
- type EcdsaErrorFunc
- type EdDSA
- func EdDSAFromBase64String(data string) EdDSA
- func EdDSAFromBytes(data []byte) EdDSA
- func EdDSAFromHexString(data string) EdDSA
- func EdDSAFromPrivateKey(key []byte) EdDSA
- func EdDSAFromPrivateKeyWithPassword(key []byte, password string) EdDSA
- func EdDSAFromPublicKey(key []byte) EdDSA
- func EdDSAFromString(data string) EdDSA
- func EdDSAGenerateKey() EdDSA
- func NewEdDSA() EdDSA
- func (this EdDSA) CreatePrivateKey() EdDSA
- func (this EdDSA) CreatePrivateKeyWithPassword(password string, opts ...string) EdDSA
- func (this EdDSA) CreatePublicKey() EdDSA
- func (this EdDSA) FromBase64String(data string) EdDSA
- func (this EdDSA) FromBytes(data []byte) EdDSA
- func (this EdDSA) FromHexString(data string) EdDSA
- func (this EdDSA) FromPrivateKey(key []byte) EdDSA
- func (this EdDSA) FromPrivateKeyWithPassword(key []byte, password string) EdDSA
- func (this EdDSA) FromPublicKey(key []byte) EdDSA
- func (this EdDSA) FromString(data string) EdDSA
- func (this EdDSA) GenerateKey() EdDSA
- func (this EdDSA) GetData() []byte
- func (this EdDSA) GetError() error
- func (this EdDSA) GetKeyData() []byte
- func (this EdDSA) GetParedData() []byte
- func (this EdDSA) GetPrivateKey() ed25519.PrivateKey
- func (this EdDSA) GetPublicKey() ed25519.PublicKey
- func (this EdDSA) GetVeryed() bool
- func (this EdDSA) MakePublicKey() EdDSA
- func (this EdDSA) OnError(fn EdDSAErrorFunc) EdDSA
- func (this EdDSA) ParseEdPrivateKeyFromPEM(key []byte) (crypto.PrivateKey, error)
- func (this EdDSA) ParseEdPrivateKeyFromPEMWithPassword(key []byte, password string) (crypto.PrivateKey, error)
- func (this EdDSA) ParseEdPublicKeyFromPEM(key []byte) (crypto.PublicKey, error)
- func (this EdDSA) Sign() EdDSA
- func (this EdDSA) ToBase64String() string
- func (this EdDSA) ToBytes() []byte
- func (this EdDSA) ToHexString() string
- func (this EdDSA) ToKeyBytes() []byte
- func (this EdDSA) ToKeyString() string
- func (this EdDSA) ToString() string
- func (this EdDSA) ToVeryed() bool
- func (this EdDSA) Very(data []byte) EdDSA
- func (this EdDSA) WithData(data []byte) EdDSA
- func (this EdDSA) WithError(err error) EdDSA
- func (this EdDSA) WithParedData(data []byte) EdDSA
- func (this EdDSA) WithPrivateKey(data ed25519.PrivateKey) EdDSA
- func (this EdDSA) WithPublicKey(data ed25519.PublicKey) EdDSA
- func (this EdDSA) WithVeryed(data bool) EdDSA
- type EdDSAErrorFunc
- type Encoding
- type ErrorFunc
- type Hash
- func (this Hash) AddCryptoHash(name string, sha crypto.Hash) Hash
- func (this Hash) AddHash(name string, sha hashFunc) Hash
- func (this Hash) DataCryptoHash(typ string, slices ...[]byte) []byte
- func (this Hash) DataHash(typ string, slices ...[]byte) []byte
- func (this Hash) GetCryptoHash(typ string) crypto.Hash
- func (this Hash) GetHash(typ string) hashFunc
- func (this Hash) WithCryptoHashs(hashes CryptoHashMap) Hash
- func (this Hash) WithHashs(hashes HashMap) Hash
- type HashMap
- type Opts
- type Padding
- func (this Padding) ISO10126Padding(text []byte, blockSize int) []byte
- func (this Padding) ISO10126UnPadding(src []byte) []byte
- func (this Padding) ISO7816_4Padding(text []byte, blockSize int) []byte
- func (this Padding) ISO7816_4UnPadding(src []byte) []byte
- func (this Padding) PKCS1Padding(text []byte, blockSize int, bt string) []byte
- func (this Padding) PKCS1UnPadding(src []byte) []byte
- func (this Padding) PKCS5Padding(text []byte) []byte
- func (this Padding) PKCS5UnPadding(src []byte) []byte
- func (this Padding) PKCS7Padding(text []byte, blockSize int) []byte
- func (this Padding) PKCS7UnPadding(src []byte) []byte
- func (this Padding) RandomBytes(length uint) []byte
- func (this Padding) TBCPadding(text []byte, blockSize int) []byte
- func (this Padding) TBCUnPadding(src []byte) []byte
- func (this Padding) X923Padding(text []byte, blockSize int) []byte
- func (this Padding) X923UnPadding(src []byte) []byte
- func (this Padding) ZeroPadding(text []byte, blockSize int) []byte
- func (this Padding) ZeroUnPadding(src []byte) []byte
- 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 ...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
- type SM2
- func NewSM2() SM2
- func SM2FromBase64String(data string) SM2
- func SM2FromBytes(data []byte) SM2
- func SM2FromHexString(data string) SM2
- func SM2FromPrivateKey(key []byte) SM2
- func SM2FromPrivateKeyWithPassword(key []byte, password string) SM2
- func SM2FromPublicKey(key []byte) SM2
- func SM2FromString(data string) SM2
- func SM2GenerateKey() SM2
- func (this SM2) CreatePrivateKey() SM2
- func (this SM2) CreatePrivateKeyWithPassword(password string) SM2
- func (this SM2) CreatePublicKey() SM2
- func (this SM2) Decrypt() SM2
- func (this SM2) Encrypt() SM2
- func (this SM2) FromBase64String(data string) SM2
- func (this SM2) FromBytes(data []byte) SM2
- func (this SM2) FromHexString(data string) SM2
- func (this SM2) FromPrivateKey(key []byte) SM2
- func (this SM2) FromPrivateKeyBytes(priByte []byte) SM2
- func (this SM2) FromPrivateKeyDBytes(DBytes []byte) SM2
- func (this SM2) FromPrivateKeyString(keyString string) SM2
- func (this SM2) FromPrivateKeyWithPassword(key []byte, password string) SM2
- func (this SM2) FromPublicKey(key []byte) SM2
- func (this SM2) FromPublicKeyString(keyString string) SM2
- func (this SM2) FromPublicKeyXYBytes(XBytes, YBytes []byte) SM2
- func (this SM2) FromString(data string) SM2
- func (this SM2) GenerateKey() SM2
- func (this SM2) GetData() []byte
- func (this SM2) GetError() error
- func (this SM2) GetKeyData() []byte
- func (this SM2) GetParedData() []byte
- func (this SM2) GetPrivateKey() *sm2.PrivateKey
- func (this SM2) GetPrivateKeyCurve() elliptic.Curve
- func (this SM2) GetPrivateKeyD() *big.Int
- func (this SM2) GetPrivateKeyX() *big.Int
- func (this SM2) GetPrivateKeyY() *big.Int
- func (this SM2) GetPublicKey() *sm2.PublicKey
- func (this SM2) GetPublicKeyCurve() elliptic.Curve
- func (this SM2) GetPublicKeyX() *big.Int
- func (this SM2) GetPublicKeyY() *big.Int
- func (this SM2) GetVeryed() bool
- func (this SM2) MakePublicKey() SM2
- func (this SM2) OnError(fn SM2ErrorFunc) SM2
- func (this SM2) ParsePrivateKeyFromPEM(key []byte) (*sm2.PrivateKey, error)
- func (this SM2) ParsePrivateKeyFromPEMWithPassword(key []byte, password string) (*sm2.PrivateKey, error)
- func (this SM2) ParsePublicKeyFromPEM(key []byte) (*sm2.PublicKey, error)
- func (this SM2) Sign() SM2
- func (this SM2) SignAsn1(uid []byte) SM2
- func (this SM2) SignHex(uid []byte) SM2
- func (this SM2) ToBase64String() string
- func (this SM2) ToBytes() []byte
- func (this SM2) ToHexString() string
- func (this SM2) ToKeyBytes() []byte
- func (this SM2) ToKeyString() string
- func (this SM2) ToString() string
- func (this SM2) ToVeryed() bool
- func (this SM2) VerifyAsn1(data []byte, uid []byte) SM2
- func (this SM2) VerifyHex(data []byte, uid []byte) SM2
- func (this SM2) Very(data []byte) SM2
- func (this SM2) WithData(data []byte) SM2
- func (this SM2) WithError(err error) SM2
- func (this SM2) WithParedData(data []byte) SM2
- func (this SM2) WithPrivateKey(data *sm2.PrivateKey) SM2
- func (this SM2) WithPublicKey(data *sm2.PublicKey) SM2
- func (this SM2) WithVeryed(data bool) SM2
- type SM2ErrorFunc
- type YoumarkPKCS8Opts
Constants ¶
const PBKDF2Iterations = 10000
PBKDF2Iterations is the default number of iterations for PBKDF2, 100k iterations. Nist recommends at least 10k, 1Passsword uses 100k.
const PBKDF2SaltSize = 16
PBKDF2SaltSize is the default size of the salt for PBKDF2, 128-bit salt.
Variables ¶
var ( ErrNotDSAPrivateKey = errors.New("key is not a valid DSA private key") ErrNotDSAPublicKey = errors.New("key is not a valid DSA public key") )
var ( ErrNotECPublicKey = errors.New("key is not a valid ECDSA public key") ErrNotECPrivateKey = errors.New("key is not a valid ECDSA private key") )
var ( ErrNotEdPrivateKey = errors.New("key is not a valid Ed25519 private key") ErrNotEdPublicKey = errors.New("key is not a valid Ed25519 public key") )
var ( // 创建私钥默认可用选项 // HMACHash 目前支持 SHA256 和 SHA1 Youmark_PKCS8_AES128CBC_SHA256 = youmarkPKCS8.Opts{ Cipher: youmarkPKCS8.AES128CBC, KDFOpts: youmarkPKCS8.PBKDF2Opts{ SaltSize: 8, IterationCount: 2048, HMACHash: crypto.SHA256, }, } Youmark_PKCS8_AES192CBC_SHA256 = youmarkPKCS8.Opts{ Cipher: youmarkPKCS8.AES192CBC, KDFOpts: youmarkPKCS8.PBKDF2Opts{ SaltSize: 8, IterationCount: 1000, HMACHash: crypto.SHA256, }, } Youmark_PKCS8_AES256CBC_SHA256 = youmarkPKCS8.Opts{ Cipher: youmarkPKCS8.AES256CBC, KDFOpts: youmarkPKCS8.PBKDF2Opts{ SaltSize: 16, IterationCount: 2000, HMACHash: crypto.SHA256, }, } Youmark_PKCS8_AES128GCM_SHA256 = youmarkPKCS8.Opts{ Cipher: youmarkPKCS8.AES128GCM, KDFOpts: youmarkPKCS8.PBKDF2Opts{ SaltSize: 8, IterationCount: 2048, HMACHash: crypto.SHA256, }, } Youmark_PKCS8_AES192GCM_SHA256 = youmarkPKCS8.Opts{ Cipher: youmarkPKCS8.AES192GCM, KDFOpts: youmarkPKCS8.PBKDF2Opts{ SaltSize: 8, IterationCount: 10000, HMACHash: crypto.SHA256, }, } Youmark_PKCS8_AES256GCM_SHA256 = youmarkPKCS8.Opts{ Cipher: youmarkPKCS8.AES256GCM, KDFOpts: youmarkPKCS8.PBKDF2Opts{ SaltSize: 16, IterationCount: 16, HMACHash: crypto.SHA256, }, } Youmark_PKCS8_TripleDESCBC_SHA1 = youmarkPKCS8.Opts{ Cipher: youmarkPKCS8.TripleDESCBC, KDFOpts: youmarkPKCS8.PBKDF2Opts{ SaltSize: 16, IterationCount: 16, HMACHash: crypto.SHA1, }, } Youmark_PKCS8_AES256CBC_Scrypt = youmarkPKCS8.Opts{ Cipher: youmarkPKCS8.AES256CBC, KDFOpts: youmarkPKCS8.ScryptOpts{ CostParameter: 1 << 2, BlockSize: 8, ParallelizationParameter: 1, SaltSize: 16, }, } )
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 DefaultOpts = &Opts{ SaltSize: PBKDF2SaltSize, IterationCount: PBKDF2Iterations, HMACHash: "SHA256", }
默认配置
var PEMCiphers = map[string]x509.PEMCipher{ "DESCBC": x509.PEMCipherDES, "DESEDE3CBC": x509.PEMCipher3DES, "AES128CBC": x509.PEMCipherAES128, "AES192CBC": x509.PEMCipherAES192, "AES256CBC": x509.PEMCipherAES256, }
pem 加密方式
Functions ¶
func AppendOID ¶ added in v1.0.1010
func AppendOID(b asn1.ObjectIdentifier, v ...int) asn1.ObjectIdentifier
最加数据为新的 Identifier
func DecryptPEMBlock ¶
解出 PEM 块
func DecryptPKCS8PrivateKey ¶
解出 PKCS8 密钥 加密方式: AES-128-CBC | AES-192-CBC | AES-256-CBC | DES | 3DES
func EncryptPKCS8PrivateKey ¶
func EncryptPKCS8PrivateKey( rand io.Reader, blockType string, data []byte, password []byte, alg x509.PEMCipher, opts ...any, ) (*pem.Block, error)
加密 PKCS8
func YoumarkPKCS8MarshalPrivateKey ¶ added in v1.0.1012
func YoumarkPKCS8MarshalPrivateKey(priv any, password []byte, opts *youmarkPKCS8.Opts) ([]byte, error)
创建私钥带密码
func YoumarkPKCS8ParsePrivateKey ¶ added in v1.0.1012
func YoumarkPKCS8ParsePrivateKey(der []byte, password []byte) (any, youmarkPKCS8.KDFParameters, error)
设置私钥带密码
Types ¶
type CA ¶ added in v1.0.1010
type CA struct { // 错误 Error error // contains filtered or unexported fields }
*
- CA *
- @create 2022-7-22
- @author deatil
func (CA) CreatePKCS12Cert ¶ added in v1.0.1012
func (this CA) CreatePKCS12Cert(caCerts []*x509.Certificate, pwd string) CA
pkcs12 密钥 caCerts 通常保留为空 支持 [rsa | ecdsa | sm2]
func (CA) CreatePKCS12CertTrustStore ¶ added in v1.0.1012
func (this CA) CreatePKCS12CertTrustStore(certs []*x509.Certificate, password string) CA
pkcs12 密钥
func (CA) DecodePKCS12CertChain ¶ added in v1.0.1012
func (this CA) DecodePKCS12CertChain(pfxData []byte, password string) (privateKey interface{}, certificate *x509.Certificate, caCerts []*x509.Certificate, err error)
解析 pkcs12 cert
func (CA) DecodePKCS12CertTrustStore ¶ added in v1.0.1012
func (this CA) DecodePKCS12CertTrustStore(pfxData []byte, password string) (certs []*x509.Certificate, err error)
解析 pkcs12 cert
func (CA) FromCertRequest ¶ added in v1.0.1010
func (this CA) FromCertRequest(cert *x509.CertificateRequest) CA
证书请求
func (CA) FromCertificateDer ¶ added in v1.0.1010
解析证书导入
func (CA) FromCertificateRequestDer ¶ added in v1.0.1010
解析证书导入
func (CA) FromPKCS12Cert ¶ added in v1.0.1012
pkcs12
func (CA) FromPrivateKey ¶ added in v1.0.1010
私钥 可用 [*rsa.PrivateKey | *ecdsa.PrivateKey | ed25519.PrivateKey]
func (CA) FromPublicKey ¶ added in v1.0.1010
公钥 可用 [*rsa.PublicKey | *ecdsa.PublicKey | ed25519.PublicKey]
func (CA) FromSM2PKCS12Cert ¶ added in v1.0.1012
pkcs12
func (CA) FromSM2PKCS12OneCert ¶ added in v1.0.1011
pkcs12
func (CA) GenerateEcdsaKey ¶ added in v1.0.1010
生成密钥 Ecdsa 可选 [P521 | P384 | P256 | P224]
func (CA) GenerateRsaKey ¶ added in v1.0.1010
生成密钥 RSA bits = 512 | 1024 | 2048 | 4096
func (CA) GetSM2SignatureAlgorithm ¶ added in v1.0.1010
func (this CA) GetSM2SignatureAlgorithm(name string) sm2X509.SignatureAlgorithm
获取 SM2 签名 alg
func (CA) GetSignatureAlgorithm ¶ added in v1.0.1010
func (this CA) GetSignatureAlgorithm(name string) x509.SignatureAlgorithm
获取签名 alg
func (CA) MakeCSR ¶ added in v1.0.1010
func (this CA) MakeCSR( country []string, organization []string, organizationalUnit []string, locality []string, province []string, streetAddress []string, postalCode []string, commonName string, ) CA
生成证书请求
func (CA) MakeCert ¶ added in v1.0.1010
func (this CA) MakeCert( subject *pkix.Name, expire int, dns []string, ip []net.IP, signAlgName string, ) CA
生成自签名证书
func (CA) MakeSM2CSR ¶ added in v1.0.1010
func (this CA) MakeSM2CSR( country []string, organization []string, organizationalUnit []string, locality []string, province []string, streetAddress []string, postalCode []string, commonName string, ) CA
生成证书请求
func (CA) MakeSM2Cert ¶ added in v1.0.1010
func (this CA) MakeSM2Cert( subject *pkix.Name, expire int, dns []string, ip []net.IP, signAlgName string, ) CA
生成自签名证书
func (CA) UpdateCert ¶ added in v1.0.1010
func (this CA) UpdateCert(fn func(*x509.Certificate) *x509.Certificate) CA
更新 Cert 数据
func (CA) UpdateCertRequest ¶ added in v1.0.1010
func (this CA) UpdateCertRequest(fn func(*x509.CertificateRequest) *x509.CertificateRequest) CA
更新证书请求数据
func (CA) UpdateSM2Cert ¶ added in v1.0.1010
func (this CA) UpdateSM2Cert(fn func(*x509.Certificate) *x509.Certificate) CA
更新 Cert 数据
func (CA) UpdateSM2CertRequest ¶ added in v1.0.1010
func (this CA) UpdateSM2CertRequest(fn func(*x509.CertificateRequest) *x509.CertificateRequest) CA
更新证书请求数据
func (CA) WithCertRequest ¶ added in v1.0.1010
设置 certRequest 可用 [*x509.CertificateRequest | *sm2X509.CertificateRequest]
func (CA) WithPrivateKey ¶ added in v1.0.1010
设置 PrivateKey
type CACertificateRequest ¶ added in v1.0.1010
type CACertificateRequest = x509.CertificateRequest
证书请求
type CAPkixAlgorithmIdentifier ¶ added in v1.0.1011
type CAPkixAlgorithmIdentifier = pkix.AlgorithmIdentifier
AlgorithmIdentifier
type CAPkixAttributeTypeAndValue ¶ added in v1.0.1011
type CAPkixAttributeTypeAndValue = pkix.AttributeTypeAndValue
AttributeTypeAndValue 数据
type CAPkixAttributeTypeAndValueSET ¶ added in v1.0.1011
type CAPkixAttributeTypeAndValueSET = pkix.AttributeTypeAndValueSET
AttributeTypeAndValueSET
type CAPkixCertificateList ¶ added in v1.0.1011
type CAPkixCertificateList = pkix.CertificateList
CertificateList
type CAPkixRevokedCertificate ¶ added in v1.0.1011
type CAPkixRevokedCertificate = pkix.RevokedCertificate
RevokedCertificate
type CAPkixTBSCertificateList ¶ added in v1.0.1011
type CAPkixTBSCertificateList = pkix.TBSCertificateList
TBSCertificateList
type CAPublicKeyAlgorithm ¶ added in v1.0.1011
type CAPublicKeyAlgorithm = x509.PublicKeyAlgorithm
PublicKeyAlgorithm
type CASM2CertificateRequest ¶ added in v1.0.1010
type CASM2CertificateRequest = sm2X509.CertificateRequest
SM2 证书请求
type CASM2PublicKeyAlgorithm ¶ added in v1.0.1011
type CASM2PublicKeyAlgorithm = sm2X509.PublicKeyAlgorithm
PublicKeyAlgorithm
type CASM2SignatureAlgorithm ¶ added in v1.0.1011
type CASM2SignatureAlgorithm = sm2X509.SignatureAlgorithm
SignatureAlgorithm
type CASignatureAlgorithm ¶ added in v1.0.1011
type CASignatureAlgorithm = x509.SignatureAlgorithm
SignatureAlgorithm
type Cipher ¶ added in v1.0.1012
type Cipher struct {
// contains filtered or unexported fields
}
*
- 加密方式 *
- @create 2022-7-26
- @author deatil
func (Cipher) AddFunc ¶ added in v1.0.1012
func (this Cipher) AddFunc(name string, block CipherFunc) Cipher
添加
func (Cipher) WithFunc ¶ added in v1.0.1012
func (this Cipher) WithFunc(funcs CipherFuncMap) Cipher
覆盖
type CipherFunc ¶ added in v1.0.1012
CipherFunc
type CipherFuncMap ¶ added in v1.0.1012
type CipherFuncMap = map[string]CipherFunc
CipherFunc map 列表
type Cryptobin ¶
type Cryptobin struct { // 错误 Error error // contains filtered or unexported fields }
*
- 对称加密 *
- @create 2022-3-19
- @author deatil
func (Cryptobin) AesECBDecrypt ¶
func (Cryptobin) AesECBEncrypt ¶
func (Cryptobin) AesECBGenerateKey ¶
func (Cryptobin) Chacha20poly1305 ¶ added in v1.0.2
Chacha20poly1305 nonce is 12 bytes
func (Cryptobin) CheckGuessMultiple ¶ added in v1.0.1012
检测 guess 方式
func (Cryptobin) CipherBlock ¶
Cipher
func (Cryptobin) FromBase64String ¶
Base64
func (Cryptobin) FuncDecrypt ¶ added in v1.0.1006
方法解密
func (Cryptobin) FuncEncrypt ¶ added in v1.0.1006
方法加密
func (Cryptobin) GetOneConfig ¶ added in v1.0.3
获取一个配置
func (Cryptobin) ISO10126Padding ¶ added in v1.0.3
ISO10126 补码
func (Cryptobin) ISO7816_4Padding ¶ added in v1.0.3
ISO7816_4 补码
func (Cryptobin) PKCS1Padding ¶ added in v1.0.3
PKCS1 补码
func (Cryptobin) RsaDecrypt ¶
RSA 私钥解密 pkcs8 带密码不支持其他工具生成的密钥
func (Cryptobin) RsaOAEPDecrypt ¶ added in v1.0.1006
RSA OAEP 私钥解密 pkcs8 带密码不支持其他工具生成的密钥 typ 为 hash.defaultHashes 对应数据
func (Cryptobin) RsaOAEPEncrypt ¶ added in v1.0.1006
RSA OAEP 公钥加密 typ 为 hash.defaultHashes 对应数据
func (Cryptobin) RsaPrikeyEncrypt ¶
RSA 私钥加密 pkcs8 带密码不支持其他工具生成的密钥
func (Cryptobin) SM2Decrypt ¶ added in v1.0.3
SM2 私钥解密
func (Cryptobin) WithMultiple ¶ added in v1.0.1006
加密类型
func (Cryptobin) WithOneConfig ¶ added in v1.0.3
设置一个配置
func (Cryptobin) WithParsedData ¶ added in v1.0.1011
补码算法
func (Cryptobin) X923Padding ¶ added in v1.0.3
X923 补码
type DSA ¶ added in v1.0.1011
type DSA struct { // 错误 Error error // contains filtered or unexported fields }
*
- DSA *
- @create 2022-7-25
- @author deatil
func DSAFromPrivateKeyWithPassword ¶ added in v1.0.1012
私钥带密码
func DSAGenerateKey ¶ added in v1.0.1011
生成密钥 可用参数 [L1024N160 | L2048N224 | L2048N256 | L3072N256]
func (DSA) CreatePrivateKeyWithPassword ¶ added in v1.0.1012
私钥带密码 CreatePrivateKeyWithPassword("123", "AES256CBC")
func (DSA) FromBase64String ¶ added in v1.0.1011
Base64
func (DSA) FromPrivateKeyWithPassword ¶ added in v1.0.1012
私钥带密码
func (DSA) GenerateKey ¶ added in v1.0.1011
生成密钥 可用参数 [L1024N160 | L2048N224 | L2048N256 | L3072N256]
func (DSA) GetPrivateKey ¶ added in v1.0.1011
func (this DSA) GetPrivateKey() *dsa.PrivateKey
获取 PrivateKey
func (DSA) GetPublicKey ¶ added in v1.0.1011
获取 PublicKey
func (DSA) MarshalPrivateKey ¶ added in v1.0.1011
func (this DSA) MarshalPrivateKey(key *dsa.PrivateKey) ([]byte, error)
包装私钥
func (DSA) MarshalPublicKey ¶ added in v1.0.1011
包装公钥
func (DSA) ParsePrivateKey ¶ added in v1.0.1011
func (this DSA) ParsePrivateKey(derBytes []byte) (*dsa.PrivateKey, error)
解析私钥
func (DSA) ParsePrivateKeyFromPEM ¶ added in v1.0.1011
func (this DSA) ParsePrivateKeyFromPEM(key []byte) (*dsa.PrivateKey, error)
解析私钥
func (DSA) ParsePrivateKeyFromPEMWithPassword ¶ added in v1.0.1012
func (this DSA) ParsePrivateKeyFromPEMWithPassword(key []byte, password string) (*dsa.PrivateKey, error)
解析私钥带密码
func (DSA) ParsePublicKey ¶ added in v1.0.1011
解析公钥
func (DSA) ParsePublicKeyFromPEM ¶ added in v1.0.1011
解析公钥
func (DSA) VerifyAsn1 ¶ added in v1.0.1011
公钥验证 使用原始数据[data]对比签名后数据
func (DSA) VerifyBytes ¶ added in v1.0.1012
公钥验证 使用原始数据[data]对比签名后数据
func (DSA) WithParedData ¶ added in v1.0.1011
设置 paredData
func (DSA) WithPrivateKey ¶ added in v1.0.1011
func (this DSA) WithPrivateKey(data *dsa.PrivateKey) DSA
设置 PrivateKey
func (DSA) WithPublicKey ¶ added in v1.0.1011
设置 PublicKey
func (DSA) WithSignHash ¶ added in v1.0.1011
设置 hash 类型 可用参数可查看 Hash 结构体数据
type DSASignature ¶ added in v1.0.1011
type Ecdsa ¶
type Ecdsa struct { // 错误 Error error // contains filtered or unexported fields }
*
- Ecdsa *
- @create 2022-4-3
- @author deatil
func EcdsaFromPKCS8PrivateKey ¶ added in v1.0.1012
PKCS8 私钥
func EcdsaFromPKCS8PrivateKeyWithPassword ¶ added in v1.0.1012
PKCS8 私钥带密码
func EcdsaFromPrivateKeyWithPassword ¶ added in v1.0.1012
私钥
func EcdsaFromYoumarkPKCS8PrivateKeyWithPassword ¶ added in v1.0.1012
设置私钥带密码
func EcdsaGenerateKey ¶
生成密钥 可选 [P521 | P384 | P256 | P224]
func (Ecdsa) CreatePKCS8PrivateKey ¶ added in v1.0.1012
PKCS8 私钥
func (Ecdsa) CreatePKCS8PrivateKeyWithPassword ¶ added in v1.0.1012
PKCS8 私钥带密码 CreatePKCS8PrivateKeyWithPassword("123", "AES256CBC", "SHA256")
func (Ecdsa) CreatePrivateKeyWithPassword ¶ added in v1.0.1012
私钥带密码 CreatePrivateKeyWithPassword("123", "AES256CBC")
func (Ecdsa) CreateYoumarkPKCS8PrivateKeyWithPassword ¶ added in v1.0.1012
func (this Ecdsa) CreateYoumarkPKCS8PrivateKeyWithPassword(password string, opt ...YoumarkPKCS8Opts) Ecdsa
创建私钥带密码
func (Ecdsa) FromPKCS8PrivateKey ¶ added in v1.0.1012
PKCS8 私钥
func (Ecdsa) FromPKCS8PrivateKeyWithPassword ¶ added in v1.0.1012
Pkcs8WithPassword
func (Ecdsa) FromPrivateKeyBytes ¶ added in v1.0.1005
明文私钥生成私钥结构体
func (Ecdsa) FromPrivateKeyDBytes ¶ added in v1.0.1006
私钥字符,必须先添加公钥
func (Ecdsa) FromPrivateKeyString ¶ added in v1.0.1005
私钥字符,必须先添加公钥 (hexStringD)
func (Ecdsa) FromPrivateKeyWithPassword ¶ added in v1.0.1012
私钥带密码
func (Ecdsa) FromPublicKeyString ¶ added in v1.0.1005
公钥字符 (hexStringX + hexStringY)
func (Ecdsa) FromPublicKeyXYBytes ¶ added in v1.0.1005
公钥字符对
func (Ecdsa) FromYoumarkPKCS8PrivateKeyWithPassword ¶ added in v1.0.1012
设置私钥带密码
func (Ecdsa) GetPrivateKeyCurve ¶ added in v1.0.1005
获取 PrivateKeyCurve
func (Ecdsa) GetPrivateKeyD ¶ added in v1.0.1005
获取 PrivateKeyD privateKeyDHex := NewEncoding().HexEncode(GetPrivateKeyD().Bytes())
func (Ecdsa) GetPrivateKeyX ¶ added in v1.0.1005
获取 PrivateKeyX privateKeyXHex := NewEncoding().HexEncode(GetPrivateKeyX().Bytes())
func (Ecdsa) GetPrivateKeyY ¶ added in v1.0.1005
获取 PrivateKeyY privateKeyYHex := NewEncoding().HexEncode(GetPrivateKeyY().Bytes())
func (Ecdsa) GetPublicKeyCurve ¶ added in v1.0.1005
获取 PublicKeyCurve
func (Ecdsa) GetPublicKeyX ¶ added in v1.0.1005
获取 PublicKeyX publicKeyXHex := NewEncoding().HexEncode(GetPublicKeyX().Bytes())
func (Ecdsa) GetPublicKeyY ¶ added in v1.0.1005
获取 PublicKeyY publicKeyYHex := NewEncoding().HexEncode(GetPublicKeyY().Bytes())
func (Ecdsa) ParseECPKCS8PrivateKeyFromPEMWithPassword ¶ added in v1.0.1012
func (this Ecdsa) ParseECPKCS8PrivateKeyFromPEMWithPassword(key []byte, password string) (*ecdsa.PrivateKey, error)
解析 PKCS8 带密码的私钥
func (Ecdsa) ParseECPrivateKeyFromPEM ¶
func (this Ecdsa) ParseECPrivateKeyFromPEM(key []byte) (*ecdsa.PrivateKey, error)
解析私钥
func (Ecdsa) ParseECPrivateKeyFromPEMWithPassword ¶ added in v1.0.1012
func (this Ecdsa) ParseECPrivateKeyFromPEMWithPassword(key []byte, password string) (*ecdsa.PrivateKey, error)
解析私钥带密码
func (Ecdsa) ParseECPublicKeyFromPEM ¶
解析公钥
func (Ecdsa) VerifyAsn1 ¶ added in v1.0.1007
公钥验证 使用原始数据[data]对比签名后数据
func (Ecdsa) WithPrivateKey ¶
func (this Ecdsa) WithPrivateKey(data *ecdsa.PrivateKey) Ecdsa
设置 PrivateKey
func (Ecdsa) WithPublicKey ¶
设置 PublicKey
func (Ecdsa) WithVeryed ¶ added in v1.0.1011
设置 veryed
type EdDSA ¶ added in v1.0.2
type EdDSA struct { // 错误 Error error // contains filtered or unexported fields }
*
- EdDSA *
- @create 2022-4-3
- @author deatil
func EdDSAFromPrivateKeyWithPassword ¶ added in v1.0.1012
私钥
func (EdDSA) CreatePrivateKeyWithPassword ¶ added in v1.0.1012
私钥带密码 CreatePrivateKeyWithPassword("123", "AES256CBC")
func (EdDSA) FromBase64String ¶ added in v1.0.2
Base64
func (EdDSA) FromPrivateKeyWithPassword ¶ added in v1.0.1012
私钥带密码
func (EdDSA) GetPrivateKey ¶ added in v1.0.2
func (this EdDSA) GetPrivateKey() ed25519.PrivateKey
获取 PrivateKey
func (EdDSA) GetPublicKey ¶ added in v1.0.2
获取 PublicKey
func (EdDSA) ParseEdPrivateKeyFromPEM ¶ added in v1.0.2
func (this EdDSA) ParseEdPrivateKeyFromPEM(key []byte) (crypto.PrivateKey, error)
解析私钥
func (EdDSA) ParseEdPrivateKeyFromPEMWithPassword ¶ added in v1.0.1012
func (this EdDSA) ParseEdPrivateKeyFromPEMWithPassword(key []byte, password string) (crypto.PrivateKey, error)
解析私钥带密码
func (EdDSA) ParseEdPublicKeyFromPEM ¶ added in v1.0.2
解析公钥
func (EdDSA) WithParedData ¶ added in v1.0.2
设置 paredData
func (EdDSA) WithPrivateKey ¶ added in v1.0.2
func (this EdDSA) WithPrivateKey(data ed25519.PrivateKey) EdDSA
设置 PrivateKey
func (EdDSA) WithPublicKey ¶ added in v1.0.2
设置 PublicKey
func (EdDSA) WithVeryed ¶ added in v1.0.1011
设置 veryed
type Encoding ¶ added in v1.0.1005
type Encoding struct{}
*
- 编码 *
- @create 2022-4-17
- @author deatil
func (Encoding) Base64Decode ¶ added in v1.0.1005
Base64 解码
func (Encoding) Base64Encode ¶ added in v1.0.1005
Base64 编码
type Hash ¶ added in v1.0.1006
type Hash struct {
// contains filtered or unexported fields
}
*
- 摘要 *
- @create 2022-4-16
- @author deatil
func (Hash) AddCryptoHash ¶ added in v1.0.1006
添加
func (Hash) DataCryptoHash ¶ added in v1.0.1006
签名后数据
func (Hash) GetCryptoHash ¶ added in v1.0.1006
类型
func (Hash) WithCryptoHashs ¶ added in v1.0.1006
func (this Hash) WithCryptoHashs(hashes CryptoHashMap) Hash
覆盖 cryptoHashes
type Padding ¶ added in v1.0.3
type Padding struct{}
*
- 补码 *
- @create 2022-4-17
- @author deatil
func (Padding) ISO10126Padding ¶ added in v1.0.3
ISO10126Padding 填充至符合块大小的整数倍,填充值最后一个字节为填充的数量数,其他字节填充随机字节。
func (Padding) ISO10126UnPadding ¶ added in v1.0.3
func (Padding) ISO7816_4Padding ¶ added in v1.0.3
ISO7816_4Padding 填充至符合块大小的整数倍,填充值第一个字节为0x80,其他字节填0x00。
func (Padding) ISO7816_4UnPadding ¶ added in v1.0.3
func (Padding) PKCS1Padding ¶ added in v1.0.3
填充格式如下: Padding = 00 + BT + PS + 00 + D 00为固定字节 BT为处理模式 PS为填充字节,填充数量为k - 3 - D,k表示密钥长度, D表示原文长度。 PS的最小长度为8个字节。填充的值根据BT值来定: BT = 00时,填充全00 BT = 01时,填充全FF BT = 02时,随机填充,但不能为00。
func (Padding) PKCS1UnPadding ¶ added in v1.0.3
func (Padding) PKCS5Padding ¶ added in v1.0.3
PKCS7Padding的子集,块大小固定为8字节
func (Padding) PKCS5UnPadding ¶ added in v1.0.3
func (Padding) PKCS7Padding ¶ added in v1.0.3
明文补码算法 填充至符合块大小的整数倍,填充值为填充数量数
func (Padding) PKCS7UnPadding ¶ added in v1.0.3
明文减码算法
func (Padding) RandomBytes ¶ added in v1.0.3
随机字节
func (Padding) TBCPadding ¶ added in v1.0.3
TBCPadding(Trailling-Bit-Compliment) 填充至符合块大小的整数倍,原文最后一位为1时填充0x00,最后一位为0时填充0xFF。
func (Padding) TBCUnPadding ¶ added in v1.0.3
func (Padding) X923Padding ¶ added in v1.0.3
X923Padding 填充至符合块大小的整数倍,填充值最后一个字节为填充的数量数,其他字节填0
func (Padding) X923UnPadding ¶ added in v1.0.3
func (Padding) ZeroPadding ¶ added in v1.0.3
数据长度不对齐时使用0填充,否则不填充
func (Padding) ZeroUnPadding ¶ added in v1.0.3
type Rsa ¶
type Rsa struct { // 错误 Error error // contains filtered or unexported fields }
*
- Rsa 加密 *
- @create 2021-8-28
- @author deatil
func RsaFromPKCS12CertWithPassword ¶ added in v1.0.1012
Pkcs12CertWithPassword
func RsaFromPKCS1PrivateKeyWithPassword ¶ added in v1.0.1012
Pkcs1WithPassword
func RsaFromPKCS8PrivateKeyWithPassword ¶ added in v1.0.1012
Pkcs8WithPassword
func RsaFromPrivateKeyWithPassword ¶
私钥带密码
func RsaFromYoumarkPKCS8PrivateKeyWithPassword ¶ added in v1.0.1012
设置私钥带密码
func (Rsa) CreatePKCS1PrivateKey ¶ added in v1.0.1012
PKCS1 私钥
func (Rsa) CreatePKCS1PrivateKeyWithPassword ¶ added in v1.0.1012
PKCS1 私钥带密码 CreatePKCS1PrivateKeyWithPassword("123", "AES256CBC")
func (Rsa) CreatePKCS8PrivateKey ¶ added in v1.0.1012
PKCS8 私钥
func (Rsa) CreatePKCS8PrivateKeyWithPassword ¶ added in v1.0.1012
PKCS8 私钥带密码 CreatePKCS8PrivateKeyWithPassword("123", "AES256CBC", "SHA256")
func (Rsa) CreatePrivateKey ¶ added in v1.0.1012
私钥, PKCS1 别名
func (Rsa) CreatePrivateKeyWithPassword ¶ added in v1.0.1012
私钥带密码, PKCS1 别名
func (Rsa) CreateYoumarkPKCS8PrivateKeyWithPassword ¶ added in v1.0.1012
func (this Rsa) CreateYoumarkPKCS8PrivateKeyWithPassword(password string, opt ...YoumarkPKCS8Opts) Rsa
创建私钥带密码
func (Rsa) FromPKCS12Cert ¶ added in v1.0.1012
Pkcs12 Cert
func (Rsa) FromPKCS12CertWithPassword ¶ added in v1.0.1012
Pkcs12CertWithPassword
func (Rsa) FromPKCS1PrivateKey ¶ added in v1.0.1012
Pkcs1
func (Rsa) FromPKCS1PrivateKeyWithPassword ¶ added in v1.0.1012
Pkcs1WithPassword
func (Rsa) FromPKCS8PrivateKey ¶ added in v1.0.1012
Pkcs8
func (Rsa) FromPKCS8PrivateKeyWithPassword ¶ added in v1.0.1012
Pkcs8WithPassword
func (Rsa) FromPrivateKeyWithPassword ¶
私钥带密码
func (Rsa) FromYoumarkPKCS8PrivateKeyWithPassword ¶ added in v1.0.1012
设置私钥带密码
func (Rsa) GenerateKey ¶
生成密钥 bits = 512 | 1024 | 2048 | 4096
func (Rsa) PSSSign ¶ added in v1.0.2
func (this Rsa) PSSSign(opts ...rsa.PSSOptions) Rsa
私钥签名 常用为: PS256[SHA256] | PS384[SHA384] | PS512[SHA512]
func (Rsa) PSSVery ¶ added in v1.0.2
func (this Rsa) PSSVery(data []byte, opts ...rsa.PSSOptions) Rsa
公钥验证 使用原始数据[data]对比签名后数据
func (Rsa) ParseRSAPKCS12CertFromPEMWithPassword ¶ added in v1.0.1012
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 公钥
type SM2 ¶ added in v1.0.3
type SM2 struct { // 错误 Error error // contains filtered or unexported fields }
*
- 国密 SM2 加密 *
- @create 2022-4-16
- @author deatil
func SM2FromPrivateKeyWithPassword ¶ added in v1.0.3
私钥带密码
func (SM2) CreatePrivateKeyWithPassword ¶ added in v1.0.3
国密 PKCS8 私钥带密码
func (SM2) FromBase64String ¶ added in v1.0.3
Base64
func (SM2) FromPrivateKeyBytes ¶ added in v1.0.1005
明文私钥生成私钥结构体
func (SM2) FromPrivateKeyDBytes ¶ added in v1.0.1006
私钥字符,必须先添加公钥
func (SM2) FromPrivateKeyString ¶ added in v1.0.1005
私钥字符,必须先添加公钥 (hexStringD) private-key: 07e4********;
func (SM2) FromPrivateKeyWithPassword ¶ added in v1.0.3
私钥带密码
func (SM2) FromPublicKeyString ¶ added in v1.0.1005
公钥字符 (hexStringX + hexStringY) public-key: 047c********.
func (SM2) FromPublicKeyXYBytes ¶ added in v1.0.1005
公钥字符对
func (SM2) GetPrivateKey ¶ added in v1.0.3
func (this SM2) GetPrivateKey() *sm2.PrivateKey
获取 PrivateKey
func (SM2) GetPrivateKeyCurve ¶ added in v1.0.1005
获取 PrivateKeyCurve
func (SM2) GetPrivateKeyD ¶ added in v1.0.1005
获取 PrivateKeyD privateKeyDHex := NewEncoding().HexEncode(GetPrivateKeyD().Bytes())
func (SM2) GetPrivateKeyX ¶ added in v1.0.1005
获取 PrivateKeyX privateKeyXHex := NewEncoding().HexEncode(GetPrivateKeyX().Bytes())
func (SM2) GetPrivateKeyY ¶ added in v1.0.1005
获取 PrivateKeyY privateKeyYHex := NewEncoding().HexEncode(GetPrivateKeyY().Bytes())
func (SM2) GetPublicKey ¶ added in v1.0.3
获取 PublicKey
func (SM2) GetPublicKeyCurve ¶ added in v1.0.1005
获取 PublicKeyCurve
func (SM2) GetPublicKeyX ¶ added in v1.0.1005
获取 PublicKeyX publicKeyXHex := NewEncoding().HexEncode(GetPublicKeyX().Bytes())
func (SM2) GetPublicKeyY ¶ added in v1.0.1005
获取 PublicKeyY publicKeyYHex := NewEncoding().HexEncode(GetPublicKeyY().Bytes())
func (SM2) ParsePrivateKeyFromPEM ¶ added in v1.0.3
func (this SM2) ParsePrivateKeyFromPEM(key []byte) (*sm2.PrivateKey, error)
解析 SM2 PKCS8 私钥
func (SM2) ParsePrivateKeyFromPEMWithPassword ¶ added in v1.0.3
func (this SM2) ParsePrivateKeyFromPEMWithPassword(key []byte, password string) (*sm2.PrivateKey, error)
解析 SM2 PKCS8 私钥带密码
func (SM2) ParsePublicKeyFromPEM ¶ added in v1.0.3
解析 SM2 PKCS8 公钥
func (SM2) VerifyAsn1 ¶ added in v1.0.1007
公钥验证 使用原始数据[data]对比签名后数据
func (SM2) WithParedData ¶ added in v1.0.3
设置 paredData
func (SM2) WithPrivateKey ¶ added in v1.0.3
func (this SM2) WithPrivateKey(data *sm2.PrivateKey) SM2
设置 PrivateKey
func (SM2) WithPublicKey ¶ added in v1.0.3
设置 PublicKey
Source Files ¶
- ca.go
- ca_alias.go
- ca_create.go
- ca_from.go
- ca_get.go
- ca_helper.go
- ca_make_sm2.go
- ca_make_x509.go
- ca_on.go
- ca_to.go
- ca_verify.go
- ca_with.go
- cipher.go
- cryptobin.go
- dsa.go
- dsa_create.go
- dsa_from.go
- dsa_get.go
- dsa_helper.go
- dsa_make.go
- dsa_marshal.go
- dsa_on.go
- dsa_parse.go
- dsa_sign.go
- dsa_to.go
- dsa_with.go
- ecdsa.go
- ecdsa_create.go
- ecdsa_from.go
- ecdsa_get.go
- ecdsa_helper.go
- ecdsa_make.go
- ecdsa_on.go
- ecdsa_parse.go
- ecdsa_sign.go
- ecdsa_to.go
- ecdsa_with.go
- ecdsa_youmark.go
- eddsa.go
- eddsa_create.go
- eddsa_from.go
- eddsa_get.go
- eddsa_helper.go
- eddsa_make.go
- eddsa_on.go
- eddsa_parse.go
- eddsa_sign.go
- eddsa_to.go
- eddsa_with.go
- encoding.go
- encryption.go
- encryption_cipher.go
- encryption_guess.go
- encryption_padding.go
- encryption_rsa.go
- encryption_sm2.go
- from.go
- get.go
- hash.go
- helper.go
- on.go
- padding.go
- pkcs8.go
- pkcs8_youmark.go
- rsa.go
- rsa_create.go
- rsa_encodingkey.go
- rsa_encryption.go
- rsa_from.go
- rsa_get.go
- rsa_helper.go
- rsa_make.go
- rsa_on.go
- rsa_parse.go
- rsa_pss_sign.go
- rsa_sign.go
- rsa_to.go
- rsa_with.go
- rsa_youmark.go
- sm2.go
- sm2_create.go
- sm2_encryption.go
- sm2_from.go
- sm2_get.go
- sm2_helper.go
- sm2_make.go
- sm2_on.go
- sm2_parse.go
- sm2_sign.go
- sm2_to.go
- sm2_with.go
- special.go
- to.go
- use.go
- with.go