Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KeysGenerator ¶
type KeysGenerator interface { // 生成sm2公私钥对 GenPrivateKey() (*Sm2PrivateKey, error) // 从sm2私钥导出公钥 PublicKey(k *Sm2PrivateKey) *Sm2PublicKey // 从未加密的pkcs8数据解析出sm2私钥 ParsePKCS8UnecryptedPrivateKey(der []byte) (*Sm2PrivateKey, error) // 从加密的pkcs8数据解析出sm2私钥 ParsePKCS8PrivateKey(der, pwd []byte) (*Sm2PrivateKey, error) // 根据给定密钥,加密sm2私钥,输出ASN.1编码数据 MarshalSm2PrivateKey(k *Sm2PrivateKey, pwd []byte) ([]byte, error) // 从ASN.1编码数据解析出sm2公钥 ParseSm2PublicKey(der []byte) (*Sm2PublicKey, error) // 序列化sm2私钥,输出ASN.1编码数据 MarshalSm2PublicKey(k *Sm2PublicKey) ([]byte, error) }
type Sm2Crypto ¶
type Sm2Crypto interface { // 签名验证,验证成功返回true,error为nil; 验证失败返回false,并返回错误信息 Verify(k *Sm2PublicKey, sig, msg []byte, opts crypto.SignerOpts) (bool, error) // 数据签名, 成功返回数字签名,error为nil; 失败返回nil,并返回错误信息 Sign(k *Sm2PrivateKey, msg []byte, opts crypto.SignerOpts) ([]byte, error) // 数据加密, 成功返回密文,error为nil; 失败返回nil,并返回错误信息 Encrypt(k *Sm2PublicKey, plaintext []byte) ([]byte, error) // 数据解密,成功返回明文,error为nil; 失败返回nil,并返回错误信息 Decrypt(k *Sm2PrivateKey, ciphertext []byte, opts crypto.DecrypterOpts) ([]byte, error) // 返回sm2算法使用的椭圆曲线 Sm2P256Curve() elliptic.Curve }
type Sm2PrivateKey ¶
type Sm2PrivateKey struct { Sm2PublicKey D *big.Int }
sm2私钥,与ecdsa私钥结构一致,用来统一sm2私钥结构,其他国密实现的sm2私钥可以统一转换成该结构体
func (*Sm2PrivateKey) Sign ¶
func (s *Sm2PrivateKey) Sign(rand io.Reader, digest []byte, opts crypto.SignerOpts) (signature []byte, err error)
该方法尚未实现,由于可能对应多种不同类型私钥的签名方法,无法统一,签名方法使用 Sm2Crypto.Sign 函数
type Sm2PublicKey ¶
sm2公钥,与ecdsa公钥结构一致,用来统一sm2公钥结构,其他国密实现的sm2公钥可以统一转换成该结构体
Click to show internal directories.
Click to hide internal directories.