Documentation ¶
Index ¶
- Variables
- func GetCryptoEngine() crypto.Engine
- func GetPublicKeyAlgorithmFromMode(mode int) (pkix.AlgorithmIdentifier, error)
- func GetSoftwareEngine(keyStoreAbsPath string) crypto.Engine
- func MarshalECPrivateKey(key *asym.ECDSAPrivateKey) ([]byte, error)
- func MarshalPKCS1PrivateKey(key *rsa.PrivateKey) []byte
- func MarshalPKCS1PublicKey(key *rsa.PublicKey) []byte
- func MarshalPKCS8PrivateKey(key *PrivateKey) ([]byte, error)
- func MarshalPKIXPublicKey(rawpub []byte, mode int) ([]byte, error)
- func MarshalSMPrivateKey(x *gm.SM2PrivateKey, withPKCS8 bool) ([]byte, error)
- func ModeFromCurve(curve elliptic.Curve) int
- func ModeFromRSAMod(rsaMod int) (int, error)
- func ModeGetCurve(mode int) (elliptic.Curve, error)
- func ModeGetRSAMod(mode int) (int, error)
- func ModeIsECDSAAlgo(mode int) bool
- func ModeIsEncryptAlgo(mode int) bool
- func ModeIsHashAlgo(mode int) bool
- func ModeIsRSAAlgo(mode int) bool
- func ModeIsSignatureAlgo(mode int) bool
- func ParseECPrivateKey(der []byte) (*asym.ECDSAPrivateKey, error)
- func ParsePKCS1PrivateKey(der []byte) (*rsa.PrivateKey, error)
- func ParsePKCS1PublicKey(der []byte) (*rsa.PublicKey, error)
- func ParsePKCS8PrivateKey(der []byte) (crypto.PrivateKey, error)
- func ParsePKIXPublicKey(derBytes []byte) (rawPub []byte, mode int, err error)
- func ParseSMPrivateKey(der []byte) (*gm.SM2PrivateKey, error)
- func UseSm2Batch(reader io.Reader) crypto.FlagReader
- type EncryptEngineMux
- func (e *EncryptEngineMux) CreateDecKey(persistent bool, mode int) (index []byte, k crypto.DecKey, err error)
- func (e *EncryptEngineMux) CreateSignKey(persistent bool, mode int) (index []byte, k crypto.SignKey, err error)
- func (e *EncryptEngineMux) GetDecKey(key []byte, mode int) (crypto.DecKey, error)
- func (e *EncryptEngineMux) GetEncKey(key []byte, mode int) (crypto.EncKey, error)
- func (e *EncryptEngineMux) GetHash(mode int) (crypto.Hasher, error)
- func (e *EncryptEngineMux) GetLevel() ([]int, uint8)
- func (e *EncryptEngineMux) GetSecretKey(mode int, pwd, key []byte) (crypto.SecretKey, error)
- func (e *EncryptEngineMux) GetSignKey(key []byte, mode int) (crypto.SignKey, error)
- func (e *EncryptEngineMux) GetVerifyKey(key []byte, mode int) (crypto.VerifyKey, error)
- func (e *EncryptEngineMux) ImportDecKey(key []byte, mode int) (index []byte, err error)
- func (e *EncryptEngineMux) ImportSignKey(key []byte, mode int) (index []byte, err error)
- func (e *EncryptEngineMux) Rander() (io.Reader, error)
- func (e *EncryptEngineMux) String() string
- type Function
- type MockSecretKey
- type PrivateKey
- type PublicKey
- type PublicKeyAlgorithm
- type SecretKey
Constants ¶
This section is empty.
Variables ¶
var ( OidPublicKeyRSA = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 1, 1} //oidPublicKeyDSA = asn1.ObjectIdentifier{1, 2, 840, 10040, 4, 1} OidPublicKeyECDSAOrSM2 = asn1.ObjectIdentifier{1, 2, 840, 10045, 2, 1} )
RFC 3279, 2.3 Public Key Algorithms
pkcs-1 OBJECT IDENTIFIER ::== { iso(1) member-body(2) us(840)
rsadsi(113549) pkcs(1) 1 }
rsaEncryption OBJECT IDENTIFIER ::== { pkcs1-1 1 }
id-dsa OBJECT IDENTIFIER ::== { iso(1) member-body(2) us(840)
x9-57(10040) x9cm(4) 1 }
RFC 5480, 2.1.1 Unrestricted Algorithm Identifier and Parameters RFC 5480, 2.1.1 Unrestricted Algorithm Identifier and Parameters">¶
id-ecPublicKey OBJECT IDENTIFIER ::= { iso(1) member-body(2) us(840) ansi-X9-62(10045) keyType(2) 1 }
OID for algo
Functions ¶
func GetPublicKeyAlgorithmFromMode ¶
func GetPublicKeyAlgorithmFromMode(mode int) (pkix.AlgorithmIdentifier, error)
GetPublicKeyAlgorithmFromMode get public pkix.AlgorithmIdentifier from mode
func GetSoftwareEngine ¶
GetSoftwareEngine get software engine
func MarshalECPrivateKey ¶
func MarshalECPrivateKey(key *asym.ECDSAPrivateKey) ([]byte, error)
MarshalECPrivateKey marshals an EC private Key into ASN.1, DER format.
func MarshalPKCS1PrivateKey ¶
func MarshalPKCS1PrivateKey(key *rsa.PrivateKey) []byte
MarshalPKCS1PrivateKey converts a private Key to ASN.1 DER encoded form.
func MarshalPKCS1PublicKey ¶
MarshalPKCS1PublicKey converts an RSA public Key to PKCS#1, ASN.1 DER form.
func MarshalPKCS8PrivateKey ¶
func MarshalPKCS8PrivateKey(key *PrivateKey) ([]byte, error)
MarshalPKCS8PrivateKey converts a private Key to PKCS#8 encoded form. The following Key types are supported: *rsa.PrivateKey, *ecdsa.PrivateKey. Unsupported Key types result in an error.
See RFC 5208. support gm
func MarshalPKIXPublicKey ¶
MarshalPKIXPublicKey serialises a public Key to DER-encoded PKIX format.
func MarshalSMPrivateKey ¶
func MarshalSMPrivateKey(x *gm.SM2PrivateKey, withPKCS8 bool) ([]byte, error)
MarshalSMPrivateKey marshal sm2 private key
func ModeFromRSAMod ¶
ModeFromRSAMod get mode from RSA mode
func ModeGetCurve ¶
ModeGetCurve get curve form mode
func ModeIsECDSAAlgo ¶
ModeIsECDSAAlgo is it a ECDSA signature algorithm
func ModeIsEncryptAlgo ¶
ModeIsEncryptAlgo is it a encrypt algorithm
func ModeIsRSAAlgo ¶
ModeIsRSAAlgo is it a RSA signature algorithm
func ModeIsSignatureAlgo ¶
ModeIsSignatureAlgo is it a signature algorithm
func ParseECPrivateKey ¶
func ParseECPrivateKey(der []byte) (*asym.ECDSAPrivateKey, error)
ParseECPrivateKey parses an ASN.1 Elliptic Curve Private Key Structure.
func ParsePKCS1PrivateKey ¶
func ParsePKCS1PrivateKey(der []byte) (*rsa.PrivateKey, error)
ParsePKCS1PrivateKey returns an RSA private Key from its ASN.1 PKCS#1 DER encoded form.
func ParsePKCS1PublicKey ¶
ParsePKCS1PublicKey parses a PKCS#1 public Key in ASN.1 DER form.
func ParsePKCS8PrivateKey ¶
func ParsePKCS8PrivateKey(der []byte) (crypto.PrivateKey, error)
ParsePKCS8PrivateKey parses an unencrypted, PKCS#8 private Key. See RFC 5208.
func ParsePKIXPublicKey ¶
ParsePKIXPublicKey parses a DER encoded public Key. These values are typically found in PEM blocks with "BEGIN PUBLIC KEY".
func ParseSMPrivateKey ¶
func ParseSMPrivateKey(der []byte) (*gm.SM2PrivateKey, error)
ParseSMPrivateKey Parse guomi private Key, support gmssl private Key and cfca private Key return the PrivateKey type. first try to resolve to the private Key of type gmssl. if it fails, try to resolve to the private Key of cfca.
func UseSm2Batch ¶
func UseSm2Batch(reader io.Reader) crypto.FlagReader
UseSm2Batch use Sm2 batch mode
Types ¶
type EncryptEngineMux ¶
type EncryptEngineMux struct {
// contains filtered or unexported fields
}
EncryptEngineMux encryption mux
func (*EncryptEngineMux) CreateDecKey ¶
func (e *EncryptEngineMux) CreateDecKey(persistent bool, mode int) (index []byte, k crypto.DecKey, err error)
CreateDecKey create dec Key
func (*EncryptEngineMux) CreateSignKey ¶
func (e *EncryptEngineMux) CreateSignKey(persistent bool, mode int) (index []byte, k crypto.SignKey, err error)
CreateSignKey sign Key
func (*EncryptEngineMux) GetHash ¶
func (e *EncryptEngineMux) GetHash(mode int) (crypto.Hasher, error)
GetHash get hash function
func (*EncryptEngineMux) GetLevel ¶
func (e *EncryptEngineMux) GetLevel() ([]int, uint8)
GetLevel get level
func (*EncryptEngineMux) GetSecretKey ¶
GetSecretKey get secret Key
func (*EncryptEngineMux) GetSignKey ¶
GetSignKey get sign Key
func (*EncryptEngineMux) GetVerifyKey ¶
GetVerifyKey get verify Key
func (*EncryptEngineMux) ImportDecKey ¶
func (e *EncryptEngineMux) ImportDecKey(key []byte, mode int) (index []byte, err error)
ImportDecKey import dec Key
func (*EncryptEngineMux) ImportSignKey ¶
func (e *EncryptEngineMux) ImportSignKey(key []byte, mode int) (index []byte, err error)
ImportSignKey import sign Key
type Function ¶
type Function uint32
Function function
type PrivateKey ¶
type PrivateKey struct { PublicKey //the first is gm, the second is ecdsa, the third is rsa PrivKey crypto.Signer }
PrivateKey private Key
type PublicKeyAlgorithm ¶
type PublicKeyAlgorithm int
PublicKeyAlgorithm public Key algorithm
const ( UnknownPublicKeyAlgorithm PublicKeyAlgorithm = iota RSA //DSA ECDSA SM2 )
signature algorithm
func GetPublicKeyAlgorithmFromAlgorithmIdentifier ¶
func GetPublicKeyAlgorithmFromAlgorithmIdentifier(algo pkix.AlgorithmIdentifier) PublicKeyAlgorithm
GetPublicKeyAlgorithmFromAlgorithmIdentifier get PublicKeyAlgorithm
func (PublicKeyAlgorithm) String ¶
func (algo PublicKeyAlgorithm) String() string