sm2

package
v1.0.31 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	C1C3C2 = 0
	C1C2C3 = 1
)

Functions

func BytesCombine

func BytesCombine(pBytes ...[]byte) []byte

func CipherMarshal

func CipherMarshal(data []byte) ([]byte, error)

func CipherUnmarshal

func CipherUnmarshal(data []byte) ([]byte, error)

func Decrypt

func Decrypt(pri *PrivateKey, data []byte, mode int) ([]byte, error)

func DecryptAsn1

func DecryptAsn1(pub *PrivateKey, data []byte) ([]byte, error)

func Encrypt

func Encrypt(pub *PublicKey, data []byte, random io.Reader, mode int) ([]byte, error)

func EncryptAsn1

func EncryptAsn1(pub *PublicKey, data []byte, rand io.Reader) ([]byte, error)

func KeyExchangeResponder added in v1.0.23

func KeyExchangeResponder(kLen int, ida, idb []byte, priB *PrivateKey, pubA *PublicKey, priBTemp *PrivateKey, pubATemp *PublicKey) (k, s1, s2 []byte, err error)

func KeyExchangeViaInitiator added in v1.0.23

func KeyExchangeViaInitiator(keyLen int, initiatorId, responderId []byte, initiatorPrivateKey *PrivateKey, responderPublicKey *PublicKey, initiatorTempPrivateKey *PrivateKey, responderTempPublicKey *PublicKey) (k, s1, s2 []byte, err error)

func P256Sm2

func P256Sm2() elliptic.Curve

func Sign

func Sign(pri *PrivateKey, msg, uid []byte, random io.Reader) (r, s *big.Int, err error)

func Verify

func Verify(pub *PublicKey, msg, uid []byte, r, s *big.Int) bool

func WNafReversed

func WNafReversed(wnaf []int8) []int8

func ZA

func ZA(pub *PublicKey, uid []byte) ([]byte, error)

Types

type PrivateKey

type PrivateKey struct {
	PublicKey
	D *big.Int
	// contains filtered or unexported fields
}

func GenerateKey

func GenerateKey(random io.Reader) (*PrivateKey, error)

func ParsePrivateKey

func ParsePrivateKey(pemBytes []byte) (key *PrivateKey, err error)

func ParsePrivateKeyWithPassword

func ParsePrivateKeyWithPassword(pemBytes []byte, passwd []byte) (key *PrivateKey, err error)

func (*PrivateKey) Decrypt

func (pri *PrivateKey) Decrypt(_ io.Reader, msg []byte, _ crypto.DecrypterOpts) (plaintext []byte, err error)

func (*PrivateKey) DecryptAsn1

func (pri *PrivateKey) DecryptAsn1(data []byte) ([]byte, error)

func (*PrivateKey) Encode

func (pri *PrivateKey) Encode() ([]byte, error)

func (*PrivateKey) Public

func (pri *PrivateKey) Public() crypto.PublicKey

func (*PrivateKey) Sign

func (pri *PrivateKey) Sign(random io.Reader, msg []byte) ([]byte, error)

type PublicKey

type PublicKey struct {
	elliptic.Curve
	X, Y *big.Int
}

func ParsePublicKey

func ParsePublicKey(pemBytes []byte) (key *PublicKey, err error)

func (*PublicKey) Encode

func (pub *PublicKey) Encode() ([]byte, error)

func (*PublicKey) EncryptAsn1

func (pub *PublicKey) EncryptAsn1(data []byte, random io.Reader) ([]byte, error)

func (*PublicKey) Sm3Digest

func (pub *PublicKey) Sm3Digest(msg, uid []byte) ([]byte, error)

func (*PublicKey) Verify

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

Jump to

Keyboard shortcuts

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