Documentation ¶
Index ¶
- func Compress(a *PublicKey) []byte
- func Decrypt(priv *PrivateKey, data []byte) ([]byte, error)
- func Encrypt(pub *PublicKey, data []byte) ([]byte, error)
- func MarshalSm2EcryptedPrivateKey(PrivKey *PrivateKey, pwd []byte) ([]byte, error)
- func MarshalSm2PrivateKey(key *PrivateKey, pwd []byte) ([]byte, error)
- func MarshalSm2PublicKey(key *PublicKey) ([]byte, error)
- func MarshalSm2UnecryptedPrivateKey(key *PrivateKey) ([]byte, error)
- func P256Sm2() elliptic.Curve
- func Sign(priv *PrivateKey, hash []byte) (r, s *big.Int, err error)
- func SignDataToSignDigit(sign []byte) (*big.Int, *big.Int, error)
- func SignDigitToSignData(r, s *big.Int) ([]byte, error)
- func Sm2Sign(priv *PrivateKey, msg, uid []byte) (r, s *big.Int, err error)
- func Sm2Verify(pub *PublicKey, msg, uid []byte, r, s *big.Int) bool
- func Verify(pub *PublicKey, hash []byte, r, s *big.Int) bool
- func WritePrivateKeytoMem(key *PrivateKey, pwd []byte) ([]byte, error)
- func WritePrivateKeytoPem(FileName string, key *PrivateKey, pwd []byte) (bool, error)
- func WritePublicKeytoMem(key *PublicKey, _ []byte) ([]byte, error)
- func WritePublicKeytoPem(FileName string, key *PublicKey, _ []byte) (bool, error)
- func ZA(pub *PublicKey, uid []byte) ([]byte, error)
- type EncryptedPrivateKeyInfo
- type Pbes2Algorithms
- type Pbes2Encs
- type Pbes2KDfs
- type Pbes2Params
- type Pkdf2Params
- type PrivateKey
- func GenerateKey() (*PrivateKey, error)
- func ParsePKCS8EcryptedPrivateKey(der, pwd []byte) (*PrivateKey, error)
- func ParsePKCS8PrivateKey(der, pwd []byte) (*PrivateKey, error)
- func ParsePKCS8UnecryptedPrivateKey(der []byte) (*PrivateKey, error)
- func ParseSm2PrivateKey(der []byte) (*PrivateKey, error)
- func ReadPrivateKeyFromMem(data []byte, pwd []byte) (*PrivateKey, error)
- func ReadPrivateKeyFromPem(FileName string, pwd []byte) (*PrivateKey, error)
- type PrivateKeyInfo
- type PublicKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalSm2EcryptedPrivateKey ¶
func MarshalSm2EcryptedPrivateKey(PrivKey *PrivateKey, pwd []byte) ([]byte, error)
func MarshalSm2PrivateKey ¶
func MarshalSm2PrivateKey(key *PrivateKey, pwd []byte) ([]byte, error)
func MarshalSm2PublicKey ¶
func MarshalSm2UnecryptedPrivateKey ¶
func MarshalSm2UnecryptedPrivateKey(key *PrivateKey) ([]byte, error)
func SignDataToSignDigit ¶ added in v1.2.2
func Sm2Sign ¶ added in v1.2.2
func Sm2Sign(priv *PrivateKey, msg, uid []byte) (r, s *big.Int, err error)
func WritePrivateKeytoMem ¶
func WritePrivateKeytoMem(key *PrivateKey, pwd []byte) ([]byte, error)
func WritePrivateKeytoPem ¶
func WritePrivateKeytoPem(FileName string, key *PrivateKey, pwd []byte) (bool, error)
func WritePublicKeytoPem ¶
Types ¶
type EncryptedPrivateKeyInfo ¶
type EncryptedPrivateKeyInfo struct { EncryptionAlgorithm Pbes2Algorithms EncryptedData []byte }
reference to https://www.rfc-editor.org/rfc/rfc5958.txt
type Pbes2Algorithms ¶
type Pbes2Algorithms struct { IdPBES2 asn1.ObjectIdentifier Pbes2Params Pbes2Params }
reference to https://www.ietf.org/rfc/rfc2898.txt
type Pbes2Encs ¶
type Pbes2Encs struct { EncryAlgo asn1.ObjectIdentifier IV []byte }
type Pbes2KDfs ¶
type Pbes2KDfs struct { IdPBKDF2 asn1.ObjectIdentifier Pkdf2Params Pkdf2Params }
reference to https://www.ietf.org/rfc/rfc2898.txt
type Pbes2Params ¶
type Pbes2Params struct { KeyDerivationFunc Pbes2KDfs // PBES2-KDFs EncryptionScheme Pbes2Encs // PBES2-Encs }
reference to https://www.ietf.org/rfc/rfc2898.txt
type Pkdf2Params ¶
type Pkdf2Params struct { Salt []byte IterationCount int Prf pkix.AlgorithmIdentifier }
reference to https://www.ietf.org/rfc/rfc2898.txt
type PrivateKey ¶
func GenerateKey ¶
func GenerateKey() (*PrivateKey, error)
func ParsePKCS8EcryptedPrivateKey ¶
func ParsePKCS8EcryptedPrivateKey(der, pwd []byte) (*PrivateKey, error)
func ParsePKCS8PrivateKey ¶
func ParsePKCS8PrivateKey(der, pwd []byte) (*PrivateKey, error)
func ParsePKCS8UnecryptedPrivateKey ¶
func ParsePKCS8UnecryptedPrivateKey(der []byte) (*PrivateKey, error)
func ParseSm2PrivateKey ¶
func ParseSm2PrivateKey(der []byte) (*PrivateKey, error)
func ReadPrivateKeyFromMem ¶
func ReadPrivateKeyFromMem(data []byte, pwd []byte) (*PrivateKey, error)
func ReadPrivateKeyFromPem ¶
func ReadPrivateKeyFromPem(FileName string, pwd []byte) (*PrivateKey, error)
func (*PrivateKey) Decrypt ¶ added in v1.2.2
func (priv *PrivateKey) Decrypt(data []byte) ([]byte, error)
func (*PrivateKey) Public ¶
func (priv *PrivateKey) Public() crypto.PublicKey
The SM2's private key contains the public key
func (*PrivateKey) Sign ¶
func (priv *PrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts) ([]byte, error)
sign format = 30 + len(z) + 02 + len(r) + r + 02 + len(s) + s, z being what follows its size, ie 02+len(r)+r+02+len(s)+s
type PrivateKeyInfo ¶
type PrivateKeyInfo struct { Version int // v1 or v2 PrivateKeyAlgorithm []asn1.ObjectIdentifier PrivateKey []byte }
reference to https://www.rfc-editor.org/rfc/rfc5958.txt
type PublicKey ¶
func Decompress ¶ added in v1.2.2
func ParseSm2PublicKey ¶
func ReadPublicKeyFromPem ¶
Click to show internal directories.
Click to hide internal directories.