sm2

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2019 License: LGPL-3.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

View Source
const (

	// DEFAULT_ID is the default user id used in Sign and Verify
	DEFAULT_ID = "1234567812345678"
)
View Source
const DIGESTLEN = 32

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(priv *ecdsa.PrivateKey, encryptData []byte) ([]byte, error)

func Encrypt

func Encrypt(pub *ecdsa.PublicKey, data []byte) ([]byte, error)

func SM2P256V1

func SM2P256V1() elliptic.Curve

SM2P256V1 returns the sm2p256v1 curve.

func Sign

func Sign(rand io.Reader, priv *ecdsa.PrivateKey, id string, msg []byte, hasher hash.Hash) (r, s *big.Int, err error)

Sign generates signature for the input message using the private key and id. It returns (r, s) as the signature or error.

func Verify

func Verify(pub *ecdsa.PublicKey, id string, msg []byte, hasher hash.Hash, r, s *big.Int) bool

Verify checks whether the input (r, s) is a valid signature for the message.

Types

type SM2Curve

type SM2Curve interface {
	elliptic.Curve

	// ABytes returns the little endian byte sequence of parameter A.
	ABytes() []byte
}

SM2Curve is the curve interface used in sm2 algorithm. It extends elliptic.Curve by adding a function ABytes().

Jump to

Keyboard shortcuts

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