sm2

package
v2.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalPrivateKey

func MarshalPrivateKey(key *PrivateKey) ([]byte, error)

MarshalPrivateKey private key conversion

func MarshalPublicKey

func MarshalPublicKey(key *PublicKey) ([]byte, error)

MarshalPublicKey public key conversion

func PrivateKeyDerToPEM

func PrivateKeyDerToPEM(der []byte) (string, error)

func PrivateKeyToPEM

func PrivateKeyToPEM(key *PrivateKey) (string, error)

func PublicKeyDerToPEM

func PublicKeyDerToPEM(der []byte) (string, error)

func PublicKeyToPEM

func PublicKeyToPEM(key *PublicKey) (string, error)

Types

type PrivateKey

type PrivateKey struct {
	*gmssl.PrivateKey

	Pub PublicKey
	// contains filtered or unexported fields
}

func GenerateKeyPair

func GenerateKeyPair() (*PrivateKey, error)

func PrivateKeyFromPEM

func PrivateKeyFromPEM(skPEM string, pass string) (*PrivateKey, error)

func UnmarshalPrivateKey

func UnmarshalPrivateKey(der []byte) (*PrivateKey, error)

func UnmarshalPrivateKeyWithCurve

func UnmarshalPrivateKeyWithCurve(namedCurveOID *asn1.ObjectIdentifier, der []byte) (*PrivateKey, error)

func (*PrivateKey) Bytes

func (sk *PrivateKey) Bytes() ([]byte, error)

func (*PrivateKey) Decrypt

func (sk *PrivateKey) Decrypt(ciphertext []byte) ([]byte, error)

func (*PrivateKey) DecryptWithOpts

func (sk *PrivateKey) DecryptWithOpts(ciphertext []byte, opts *bccrypto.EncOpts) ([]byte, error)

func (*PrivateKey) EncryptKey

func (sk *PrivateKey) EncryptKey() bccrypto.EncryptKey

func (*PrivateKey) PublicKey

func (sk *PrivateKey) PublicKey() bccrypto.PublicKey

func (*PrivateKey) Sign

func (sk *PrivateKey) Sign(msg []byte) ([]byte, error)

func (*PrivateKey) SignWithOpts

func (sk *PrivateKey) SignWithOpts(msg []byte, opts *bccrypto.SignOpts) ([]byte, error)

func (*PrivateKey) String

func (sk *PrivateKey) String() (string, error)

func (*PrivateKey) ToStandardKey

func (sk *PrivateKey) ToStandardKey() crypto2.PrivateKey

func (*PrivateKey) Type

func (sk *PrivateKey) Type() bccrypto.KeyType

type PublicKey

type PublicKey struct {
	*gmssl.PublicKey
	// contains filtered or unexported fields
}

func PublicKeyFromPEM

func PublicKeyFromPEM(pkPEM string) (*PublicKey, error)

func UnmarshalPublicKey

func UnmarshalPublicKey(der []byte) (*PublicKey, error)

func (*PublicKey) Bytes

func (pk *PublicKey) Bytes() ([]byte, error)

func (*PublicKey) CalSM2Digest

func (pk *PublicKey) CalSM2Digest(uid string, msg []byte) ([]byte, error)

func (*PublicKey) Encrypt

func (pk *PublicKey) Encrypt(plaintext []byte) ([]byte, error)

func (*PublicKey) EncryptWithOpts

func (pk *PublicKey) EncryptWithOpts(data []byte, opts *bccrypto.EncOpts) ([]byte, error)

func (*PublicKey) String

func (pk *PublicKey) String() (string, error)

func (*PublicKey) ToStandardKey

func (pk *PublicKey) ToStandardKey() crypto.PublicKey

ToStandardKey nolint

func (*PublicKey) Type

func (pk *PublicKey) Type() bccrypto.KeyType

func (*PublicKey) Verify

func (pk *PublicKey) Verify(msg []byte, sig []byte) (bool, error)

func (*PublicKey) VerifyWithOpts

func (pk *PublicKey) VerifyWithOpts(msg []byte, sig []byte, opts *bccrypto.SignOpts) (bool, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL