Documentation ¶
Index ¶
- Variables
- func BytesCombine(pBytes ...[]byte) []byte
- func FindPKCS11Lib(opts CNCC_GMOpts)
- func GetPublicKeyExample() *sm2.PublicKey
- 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(opts CNCC_GMOpts, keyStore bccsp.KeyStore) (bccsp.BCCSP, error)
- func NewDummyKeyStore() bccsp.KeyStore
- func NewFileBasedKeyStore(pwd []byte, path string, readOnly bool) (bccsp.KeyStore, error)
- func OpenNetSign(ip, password string, port int) (socketFd int, ns *netsign.NetSign)
- func RandStringInt() string
- func SM4Decrypt(key, src []byte) ([]byte, error)
- func SM4Encrypt(key, src []byte) ([]byte, error)
- func SaveSKI(path, ski string) error
- func ToLowS(k *ecdsa.PublicKey, s *big.Int) (*big.Int, bool, error)
- func UnmarshalSM2Signature(raw []byte) (*big.Int, *big.Int, error)
- type CNCC_GMOpts
- type DummyKeystoreOpts
- type FileKeystoreOpts
- type Impl
- func (csp *Impl) Decrypt(k bccsp.Key, ciphertext []byte, opts bccsp.DecrypterOpts) (plaintext []byte, err error)
- func (csp *Impl) Encrypt(k bccsp.Key, plaintext []byte, opts bccsp.EncrypterOpts) (ciphertext []byte, err error)
- func (csp *Impl) GetHash(opts bccsp.HashOpts) (h hash.Hash, err error)
- func (csp *Impl) GetKey(ski []byte) (k bccsp.Key, err error)
- func (csp *Impl) Hash(msg []byte, opts bccsp.HashOpts) (digest []byte, err error)
- func (csp *Impl) KeyDeriv(k bccsp.Key, opts bccsp.KeyDerivOpts) (dk bccsp.Key, err error)
- func (csp *Impl) KeyGen(opts bccsp.KeyGenOpts) (k bccsp.Key, err error)
- func (csp *Impl) KeyImport(raw interface{}, opts bccsp.KeyImportOpts) (k bccsp.Key, err error)
- func (csp *Impl) Sign(k bccsp.Key, digest []byte, opts bccsp.SignerOpts) (signature []byte, err error)
- func (csp *Impl) Uploadcert(ski []byte, certBytes []byte) error
- func (csp *Impl) Verify(k bccsp.Key, signature, digest []byte, opts bccsp.SignerOpts) (valid bool, err error)
- type InmemKeystoreOpts
- type NetSignConfig
- type NetSignSesssion
- type SM2Signature
Constants ¶
This section is empty.
Variables ¶
var ( SessionCacheSize = 10 BJ_NetSignConfig []*NetSignConfig SH_NetSignConfig []*NetSignConfig BAK_NetSignConfig []*NetSignConfig )
Functions ¶
func BytesCombine ¶
func FindPKCS11Lib ¶
func FindPKCS11Lib(opts CNCC_GMOpts)
* 环境变量格式: CORE_PEER_BCCSP_CNCC_GM_IP=111.63.61.21,111.63.61.22;17.63.61.21,17.63.61.22 CORE_PEER_BCCSP_CNCC_GM_PORT=50060,50061;50060,50061 CORE_PEER_BCCSP_CNCC_GM_password=123456,123456;123456,123456 理论上用 “;” 来区分 北京和上海的签名服务器配置
func GetPublicKeyExample ¶
func GetRandomBytes ¶
GetRandomBytes returns len random looking bytes
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 OpenNetSign ¶
func SM4Decrypt ¶
AESCBCPKCS7Decrypt combines CBC decryption and PKCS7 unpadding
func SM4Encrypt ¶
AESCBCPKCS7Encrypt combines CBC encryption and PKCS7 padding
Types ¶
type CNCC_GMOpts ¶
type CNCC_GMOpts struct { // Default algorithms when not specified (Deprecated?) SecLevel int `mapstructure:"security" json:"security" yaml:"Security"` HashFamily string `mapstructure:"hash" json:"hash" yaml:"Hash"` // Keystore options Ephemeral bool `mapstructure:"tempkeys,omitempty" json:"tempkeys,omitempty" yaml:"Ephemeral"` FileKeystore *FileKeystoreOpts `mapstructure:"filekeystore,omitempty" json:"filekeystore,omitempty", yaml:"FileKeyStore"` DummyKeystore *DummyKeystoreOpts `mapstructure:"dummykeystore,omitempty" json:"dummykeystore,omitempty"` // PKCS11 options Library string `mapstructure:"library" json:"library" yaml:"Library"` Ip string `mapstructure:"ip" json:"ip" yaml:"Ip"` Port string `mapstructure:"port" json:"port" yaml:"Port"` Password string `mapstructure:"password" json:"password" yaml:"Password"` Sensitive bool `mapstructure:"sensitivekeys,omitempty" json:"sensitivekeys,omitempty" yaml:"Sensitive"` SoftVerify bool `mapstructure:"softwareverify,omitempty" json:"softwareverify,omitempty" yaml:"SoftVerify"` }
CNCC_GMpts contains options for the CNCC_GMFactory
type DummyKeystoreOpts ¶
type DummyKeystoreOpts struct{}
type FileKeystoreOpts ¶
type FileKeystoreOpts struct {
KeyStorePath string `mapstructure:"keystore" json:"keystore" yaml:"KeyStore"`
}
type Impl ¶
type Impl struct { bccsp.BCCSP // 内嵌BCCSP接口 Sessions chan *NetSignSesssion // 会话标识符通道,默认10(sessionCacheSize = 10) // contains filtered or unexported fields }
func (*Impl) Decrypt ¶
func (csp *Impl) Decrypt(k bccsp.Key, ciphertext []byte, opts bccsp.DecrypterOpts) (plaintext []byte, err error)
根据解密者选项opts,使用k对ciphertext进行解密
func (*Impl) Encrypt ¶
func (csp *Impl) Encrypt(k bccsp.Key, plaintext []byte, opts bccsp.EncrypterOpts) (ciphertext []byte, err error)
根据加密者选项opts,使用k加密plaintext
func (*Impl) GetHash ¶
GetHash returns and instance of hash.Hash using options opts. If opts is nil then the default hash function is returned.
type InmemKeystoreOpts ¶
type InmemKeystoreOpts struct{}
InmemKeystoreOpts - empty, as there is no config for the in-memory keystore
type NetSignConfig ¶
type NetSignSesssion ¶
type NetSignSesssion struct { NSC *NetSignConfig NS_sesion int }