sm2

package
v0.0.0-...-a01cb7b Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

SM2

A Go implementation of the Chinese SM2 crypto system.

Tests

$ go test .

Benchmarks

$ go test -timeout 1h -bench=. -benchtime=1m

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KDF

func KDF(klen int, z []byte) ([]byte, error)

KDF key derivation function

func P256Sm2

func P256Sm2() elliptic.Curve

func SM2Decrypt

func SM2Decrypt(cipher []byte, privkey *PrivateKey) ([]byte, error)

SM2Decrypt

func SM2Encrypt

func SM2Encrypt(msg []byte, pubkey *PublicKey) ([]byte, error)

SM2Encrypt

func SM2Verify

func SM2Verify(msg []byte, sig Signature, pubkey PublicKey, id []byte) (bool, error)

SM2Verify verify SM2 signature

func WNafReversed

func WNafReversed(wnaf []int8) []int8

func ZA

func ZA(pubkey PublicKey, id []byte) []byte

ZA prepare for signature sm3(ENTLA, id, a, b, x, y)

Types

type PrivateKey

type PrivateKey struct {
	PublicKey
	D *big.Int
}

PrivateKey SM2 private key

func GenerateKey

func GenerateKey() (*PrivateKey, error)

GenerateKey generate random key pair

type PublicKey

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

PublicKey SM2 public key

type Signature

type Signature struct {
	R, S *big.Int
}

Signature SM2 signature

func SM2Sign

func SM2Sign(msg []byte, privkey *PrivateKey, id []byte) (Signature, error)

SM2Sign SM2 sign

Jump to

Keyboard shortcuts

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