sm2

package
v1.65.2 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2021 License: BSD-3-Clause Imports: 10 Imported by: 27

Documentation

Overview

Package sm2 带证书交易的签名

Index

Constants

View Source
const (
	SM2PrivateKeyLength    = 32
	SM2PublicKeyLength     = 65
	SM2PublicKeyCompressed = 33
	SM2SignatureMinLength  = 72
)

const

View Source
const (
	Name = "auth_sm2"
	ID   = 258
)

const

Variables

This section is empty.

Functions

func Deserialize

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

Deserialize 反序列化

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, isCompress bool) []byte

SerializePublicKey 公钥序列化

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 字节转为签名

func (Driver) Validate added in v1.65.1

func (d Driver) Validate(msg, pub, sig []byte) error

Validate validate msg and signature TODO:目前只做了公私钥签名验证,需要根据框架整合证书验证

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 SignatureS

type SignatureS struct {
	crypto.Signature
	// contains filtered or unexported fields
}

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