Documentation ¶
Index ¶
- func CreateCertificateToMem(template, parent *sm2.Certificate, key bccsp.Key) (cert []byte, err error)
- func CreateSm2CertificateRequestToMem(certificateRequest *sm2.CertificateRequest, key bccsp.Key) (csr []byte, err error)
- func GetRandomBytes(len int) ([]byte, error)
- func IsLowS(k *ecdsa.PublicKey, s *big.Int) (bool, error)
- func MarshalSM2Signature(r, s *big.Int) ([]byte, error)
- func New(securityLevel int, hashFamily string, keyStore bccsp.KeyStore) (bccsp.BCCSP, error)
- func NewDummyKeyStore() bccsp.KeyStore
- func NewFileBasedKeyStore(pwd []byte, path string, readOnly bool) (bccsp.KeyStore, error)
- func ParseSm2Certificate2X509(sm2Cert *sm2.Certificate) *x509.Certificate
- func ParseX509Certificate2Sm2(x509Cert *x509.Certificate) *sm2.Certificate
- func ParseX509CertificateRequest2Sm2(x509req *x509.CertificateRequest) *sm2.CertificateRequest
- func SM4Decrypt(key, src []byte) ([]byte, error)
- func SM4Encrypt(key, src []byte) ([]byte, error)
- func SignatureToLowS(k *ecdsa.PublicKey, signature []byte) ([]byte, error)
- func ToLowS(k *ecdsa.PublicKey, s *big.Int) (*big.Int, bool, error)
- func UnmarshalSM2Signature(raw []byte) (*big.Int, *big.Int, error)
- type Decryptor
- type Encryptor
- type Hasher
- type KeyDeriver
- type KeyGenerator
- type KeyImporter
- type SM2Signature
- type Signer
- type Verifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateCertificateToMem ¶
func CreateCertificateToMem(template, parent *sm2.Certificate, key bccsp.Key) (cert []byte, err error)
调用SM2接口生成SM2证书
func CreateSm2CertificateRequestToMem ¶
func CreateSm2CertificateRequestToMem(certificateRequest *sm2.CertificateRequest, key bccsp.Key) (csr []byte, err error)
调用SM2接口生成SM2证书请求
func GetRandomBytes ¶
func NewDummyKeyStore ¶
func NewFileBasedKeyStore ¶
NewFileBasedKeyStore instantiated a file-based key store at a given position. The key store can be encrypted if a non-empty password is specifiec. It can be also be set as read only. In this case, any store operation will be forbidden
func ParseSm2Certificate2X509 ¶
func ParseSm2Certificate2X509(sm2Cert *sm2.Certificate) *x509.Certificate
sm2 证书转换 x509 证书
func ParseX509Certificate2Sm2 ¶
func ParseX509Certificate2Sm2(x509Cert *x509.Certificate) *sm2.Certificate
X509证书格式转换为 SM2证书格式
func ParseX509CertificateRequest2Sm2 ¶
func ParseX509CertificateRequest2Sm2(x509req *x509.CertificateRequest) *sm2.CertificateRequest
X509 证书请求转换 SM2证书请求
func SM4Decrypt ¶
func SM4Encrypt ¶
Types ¶
type Decryptor ¶
type Decryptor interface {
Decrypt(k bccsp.Key, ciphertext []byte, opts bccsp.DecrypterOpts) (plaintext []byte, err error)
}
Decryptor is a BCCSP-like interface that provides decryption algorithms Decrypt decrypts ciphertext using key k. The opts argument should be appropriate for the algorithm used.
type Encryptor ¶
type Encryptor interface {
Encrypt(k bccsp.Key, plaintext []byte, opts bccsp.EncrypterOpts) (ciphertext []byte, err error)
}
Encryptor is a BCCSP-like interface that provides encryption algorithms Encrypt encrypts plaintext using key k. The opts argument should be appropriate for the algorithm used.
type Hasher ¶
type Hasher interface { // Hash hashes messages msg using options opts. // If opts is nil, the default hash function will be used. Hash(msg []byte, opts bccsp.HashOpts) (hash []byte, err error) // GetHash returns and instance of hash.Hash using options opts. // If opts is nil, the default hash function will be returned. GetHash(opts bccsp.HashOpts) (h hash.Hash, err error) }
Hasher is a BCCSP-like interface that provides hash algorithms
type KeyDeriver ¶
type KeyDeriver interface {
KeyDeriv(k bccsp.Key, opts bccsp.KeyDerivOpts) (dk bccsp.Key, err error)
}
KeyDeriver is a BCCSP-like interface that provides key derivation algorithms KeyDeriv derives a key from k using opts. The opts argument should be appropriate for the primitive used.
type KeyGenerator ¶
type KeyGenerator interface {
KeyGen(opts bccsp.KeyGenOpts) (k bccsp.Key, err error)
}
KeyGenerator is a BCCSP-like interface that provides key generation algorithms KeyGen generates a key using opts.
type KeyImporter ¶
type KeyImporter interface {
KeyImport(raw interface{}, opts bccsp.KeyImportOpts) (k bccsp.Key, err error)
}
KeyImporter is a BCCSP-like interface that provides key import algorithms KeyImport imports a key from its raw representation using opts. The opts argument should be appropriate for the primitive used.
type SM2Signature ¶
type Signer ¶
type Signer interface {
Sign(k bccsp.Key, digest []byte, opts bccsp.SignerOpts) (signature []byte, err error)
}
Signer is a BCCSP-like interface that provides signing algorithms
type Verifier ¶
type Verifier interface {
Verify(k bccsp.Key, signature, digest []byte, opts bccsp.SignerOpts) (valid bool, err error)
}
Verifier is a BCCSP-like interface that provides verifying algorithms Verify verifies signature against key k and digest The opts argument should be appropriate for the algorithm used.