csp

package
Version: v1.65.3 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: BSD-3-Clause Imports: 22 Imported by: 9

Documentation

Index

Constants

View Source
const (
	// ECDSAP256KeyGen ECDSA类型
	ECDSAP256KeyGen = 1
	// SM2P256KygGen SM2类型
	SM2P256KygGen = 2
)

Variables

This section is empty.

Functions

func MarshalECDSASignature

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

MarshalECDSASignature 编码ECDSA类型签名

func MarshalSM2Signature

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

MarshalSM2Signature 编码SM2起签名

Types

type CSP

type CSP interface {
	KeyGen(opts int) (k Key, err error)
	Sign(k Key, digest []byte, opts SignerOpts) (signature []byte, err error)
}

CSP 证书生成器接口

func New

func New(keyStore KeyStore) (CSP, error)

New 创建新的证书生成结构

type ECDSASignature

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

ECDSASignature ECDSA签名结构

type Key

type Key interface {
	Bytes() ([]byte, error)
	SKI() []byte
	Symmetric() bool
	Private() bool
	PublicKey() (Key, error)
}

Key 通用key接口

type KeyGenerator

type KeyGenerator interface {
	KeyGen(opts int) (k Key, err error)
}

KeyGenerator key生成器接口

type KeyStore

type KeyStore interface {
	ReadOnly() bool

	StoreKey(k Key) (err error)
}

KeyStore key存储接口

func NewFileBasedKeyStore

func NewFileBasedKeyStore(pwd []byte, path string, readOnly bool) (KeyStore, error)

NewFileBasedKeyStore 创建key存储器

type SM2PrivateKey

type SM2PrivateKey struct {
	PrivKey *sm2.PrivateKey
}

SM2PrivateKey sm2私钥结构

func (*SM2PrivateKey) Bytes

func (k *SM2PrivateKey) Bytes() (raw []byte, err error)

Bytes sm2私钥转成byte

func (*SM2PrivateKey) Private

func (k *SM2PrivateKey) Private() bool

Private sm2私钥

func (*SM2PrivateKey) PublicKey

func (k *SM2PrivateKey) PublicKey() (Key, error)

PublicKey sm2私钥对应公钥

func (*SM2PrivateKey) SKI

func (k *SM2PrivateKey) SKI() (ski []byte)

SKI sm2私钥ski

func (*SM2PrivateKey) Symmetric

func (k *SM2PrivateKey) Symmetric() bool

Symmetric sm2私钥Symmetric

type SM2PublicKey

type SM2PublicKey struct {
	PubKey *sm2.PublicKey
}

SM2PublicKey sm2公钥结构

func (*SM2PublicKey) Bytes

func (k *SM2PublicKey) Bytes() (raw []byte, err error)

Bytes sm2公钥转成byte

func (*SM2PublicKey) Private

func (k *SM2PublicKey) Private() bool

Private 是否sm2私钥

func (*SM2PublicKey) PublicKey

func (k *SM2PublicKey) PublicKey() (Key, error)

PublicKey sm2公钥

func (*SM2PublicKey) SKI

func (k *SM2PublicKey) SKI() (ski []byte)

SKI sm2公钥ski

func (*SM2PublicKey) Symmetric

func (k *SM2PublicKey) Symmetric() bool

Symmetric sm2公钥Symmetric

type SM2Signature

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

SM2Signature SM2签名结构

type Signer

type Signer interface {
	Sign(k Key, digest []byte, opts SignerOpts) (signature []byte, err error)
}

Signer 签名器接口

type SignerOpts

type SignerOpts interface {
	crypto.SignerOpts
}

SignerOpts 签名器参数接口

Jump to

Keyboard shortcuts

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