sm2

package
v6.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2019 License: BSD-3-Clause Imports: 9 Imported by: 30

Documentation

Overview

Package sm2 系统签名包

Index

Constants

View Source
const (
	SM2PrivateKeyLength = 32
	SM2PublicKeyLength  = 65
)

const

View Source
const (
	Name = "sm2"
	ID   = 3
)

const

Variables

This section is empty.

Functions

func Deserialize

func Deserialize(sigStr []byte) (*big.Int, *big.Int, error)

Deserialize 反序列化

func IsLowS

func IsLowS(s *big.Int) bool

IsLowS ...

func Serialize

func Serialize(r, s *big.Int) []byte

Serialize 序列化

func SerializePrivateKey

func SerializePrivateKey(p *sm2.PrivateKey) []byte

SerializePrivateKey 私钥序列化

func SerializePublicKey

func SerializePublicKey(p *sm2.PublicKey) []byte

SerializePublicKey 公钥序列化

func ToLowS

func ToLowS(k *sm2.PublicKey, s *big.Int) *big.Int

ToLowS ...

Types

type Driver

type Driver struct{}

Driver 驱动

func (Driver) GenKey

func (d Driver) GenKey() (crypto.PrivKey, error)

GenKey 生成私钥

func (Driver) PrivKeyFromBytes

func (d Driver) PrivKeyFromBytes(b []byte) (privKey crypto.PrivKey, err error)

PrivKeyFromBytes 字节转为私钥

func (Driver) PubKeyFromBytes

func (d Driver) PubKeyFromBytes(b []byte) (pubKey crypto.PubKey, err error)

PubKeyFromBytes 字节转为公钥

func (Driver) SignatureFromBytes

func (d Driver) SignatureFromBytes(b []byte) (sig crypto.Signature, err error)

SignatureFromBytes 字节转为签名

type PrivKeySM2

type PrivKeySM2 [SM2PrivateKeyLength]byte

PrivKeySM2 私钥

func (PrivKeySM2) Bytes

func (privKey PrivKeySM2) Bytes() []byte

Bytes 字节格式

func (PrivKeySM2) Equals

func (privKey PrivKeySM2) Equals(other crypto.PrivKey) bool

Equals 公钥

func (PrivKeySM2) PubKey

func (privKey PrivKeySM2) PubKey() crypto.PubKey

PubKey 私钥生成公钥

func (PrivKeySM2) Sign

func (privKey PrivKeySM2) Sign(msg []byte) crypto.Signature

Sign 签名

func (PrivKeySM2) String

func (privKey PrivKeySM2) String() string

type PubKeySM2

type PubKeySM2 [SM2PublicKeyLength]byte

PubKeySM2 公钥

func (PubKeySM2) Bytes

func (pubKey PubKeySM2) Bytes() []byte

Bytes 字节格式

func (PubKeySM2) Equals

func (pubKey PubKeySM2) Equals(other crypto.PubKey) bool

Equals 相等

func (PubKeySM2) KeyString

func (pubKey PubKeySM2) KeyString() string

KeyString Must return the full bytes in hex. Used for map keying, etc.

func (PubKeySM2) String

func (pubKey PubKeySM2) String() string

func (PubKeySM2) VerifyBytes

func (pubKey PubKeySM2) VerifyBytes(msg []byte, sig crypto.Signature) bool

VerifyBytes 验证字节

type Signature

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

Signature 签名

type SignatureS

type SignatureS struct {
	crypto.Signature
}

SignatureS 签名

type SignatureSM2

type SignatureSM2 []byte

SignatureSM2 签名

func (SignatureSM2) Bytes

func (sig SignatureSM2) Bytes() []byte

Bytes 字节格式

func (SignatureSM2) Equals

func (sig SignatureSM2) Equals(other crypto.Signature) bool

Equals 相等

func (SignatureSM2) IsZero

func (sig SignatureSM2) IsZero() bool

IsZero 是否为0

func (SignatureSM2) String

func (sig SignatureSM2) String() string

Jump to

Keyboard shortcuts

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