Documentation ¶
Index ¶
- Variables
- type Opts
- type PBKDF2Opts
- type SM2
- func FromBase64String(data string) SM2
- func FromBytes(data []byte) SM2
- func FromHexString(data string) SM2
- func FromPrivateKey(key []byte) SM2
- func FromPrivateKeyWithPassword(key []byte, password string) SM2
- func FromPublicKey(key []byte) SM2
- func FromString(data string) SM2
- func GenerateKey() SM2
- func New() SM2
- func NewSM2() SM2
- func (this SM2) AppendError(errs ...error) SM2
- func (this SM2) CreatePKCS8KdfPrivateKeyWithPassword(password string, opts ...any) SM2
- func (this SM2) CreatePKCS8PbePrivateKeyWithPassword(password string, alg string) SM2
- func (this SM2) CreatePKCS8PrivateKeyWithPassword(password string, opts ...any) SM2
- func (this SM2) CreatePrivateKey() SM2
- func (this SM2) CreatePrivateKeyWithPassword(password string, opts ...any) SM2
- func (this SM2) CreatePublicKey() SM2
- func (this SM2) CreateSM2PrivateKeyWithPassword(password string) SM2
- func (this SM2) Decrypt() SM2
- func (this SM2) DecryptAsn1(pub *sm2.PrivateKey, data []byte, mode int) ([]byte, error)
- func (this SM2) Encrypt() SM2
- func (this SM2) EncryptAsn1(pub *sm2.PublicKey, data []byte, mode int, rand io.Reader) ([]byte, error)
- func (this SM2) Error() cryptobin_tool.Errors
- func (this SM2) FromBase64String(data string) SM2
- func (this SM2) FromBytes(data []byte) SM2
- func (this SM2) FromHexString(data string) SM2
- func (this SM2) FromPrivateKey(key []byte) SM2
- func (this SM2) FromPrivateKeyBytes(priByte []byte) SM2
- func (this SM2) FromPrivateKeyDBytes(DBytes []byte) SM2
- func (this SM2) FromPrivateKeyString(keyString string) SM2
- func (this SM2) FromPrivateKeyWithPassword(key []byte, password string) SM2
- func (this SM2) FromPublicKey(key []byte) SM2
- func (this SM2) FromPublicKeyString(keyString string) SM2
- func (this SM2) FromPublicKeyXYBytes(XBytes, YBytes []byte) SM2
- func (this SM2) FromPublicKeyXYString(xString string, yString string) SM2
- func (this SM2) FromString(data string) SM2
- func (this SM2) GenerateKey() SM2
- func (this SM2) GetData() []byte
- func (this SM2) GetErrors() []error
- func (this SM2) GetKeyData() []byte
- func (this SM2) GetMode() int
- func (this SM2) GetParedData() []byte
- func (this SM2) GetPrivateKey() *sm2.PrivateKey
- func (this SM2) GetPrivateKeyCurve() elliptic.Curve
- func (this SM2) GetPrivateKeyDHexString() string
- func (this SM2) GetPrivateKeyXHexString() string
- func (this SM2) GetPrivateKeyYHexString() string
- func (this SM2) GetPublicKey() *sm2.PublicKey
- func (this SM2) GetPublicKeyCurve() elliptic.Curve
- func (this SM2) GetPublicKeyXHexString() string
- func (this SM2) GetPublicKeyYHexString() string
- func (this SM2) GetVerify() bool
- func (this SM2) MakeKeyDer() SM2
- func (this SM2) MakePublicKey() SM2
- func (this SM2) OnError(fn SM2ErrorFunc) SM2
- func (this SM2) ParsePKCS8PrivateKeyFromPEMWithPassword(key []byte, password string) (*sm2.PrivateKey, error)
- func (this SM2) ParsePrivateKeyFromPEM(key []byte) (*sm2.PrivateKey, error)
- func (this SM2) ParsePrivateKeyFromPEMWithPassword(key []byte, password string) (*sm2.PrivateKey, error)
- func (this SM2) ParsePublicKeyFromPEM(key []byte) (*sm2.PublicKey, error)
- func (this SM2) SetMode(data string) SM2
- func (this SM2) Sign() SM2
- func (this SM2) SignAsn1(uid []byte) SM2
- func (this SM2) SignHex(uid []byte) SM2
- func (this SM2) ToBase64String() string
- func (this SM2) ToBytes() []byte
- func (this SM2) ToHexString() string
- func (this SM2) ToKeyBytes() []byte
- func (this SM2) ToKeyString() string
- func (this SM2) ToString() string
- func (this SM2) ToVerify() bool
- func (this SM2) ToVerifyInt() int
- func (this SM2) Verify(data []byte) SM2
- func (this SM2) VerifyAsn1(data []byte, uid []byte) SM2
- func (this SM2) VerifyHex(data []byte, uid []byte) SM2
- func (this SM2) WithData(data []byte) SM2
- func (this SM2) WithErrors(errs []error) SM2
- func (this SM2) WithMode(data int) SM2
- func (this SM2) WithParedData(data []byte) SM2
- func (this SM2) WithPrivateKey(data *sm2.PrivateKey) SM2
- func (this SM2) WithPublicKey(data *sm2.PublicKey) SM2
- func (this SM2) WithVerify(data bool) SM2
- type SM2ErrorFunc
- type ScryptOpts
Constants ¶
This section is empty.
Variables ¶
var ( // 获取 Cipher 类型 GetCipherFromName = cryptobin_pkcs8.GetCipherFromName // 获取 hash 类型 GetHashFromName = cryptobin_pkcs8.GetHashFromName )
var (
ErrKeyMustBePEMEncoded = errors.New("invalid key: Key must be a PEM encoded PKCS1 or PKCS8 key")
)
Functions ¶
This section is empty.
Types ¶
type SM2 ¶
type SM2 struct { // 错误 Errors []error // contains filtered or unexported fields }
*
- 国密 SM2 加密 *
- @create 2022-4-16
- @author deatil
func FromPrivateKeyWithPassword ¶ added in v1.0.1018
私钥带密码
func (SM2) CreatePKCS8KdfPrivateKeyWithPassword ¶ added in v1.0.1028
生成 PKCS8 私钥带密码 pem 数据
func (SM2) CreatePKCS8PbePrivateKeyWithPassword ¶ added in v1.0.1028
生成 PKCS8 私钥带密码 pem 数据
func (SM2) CreatePKCS8PrivateKeyWithPassword ¶ added in v1.0.1028
生成 PKCS8 私钥带密码 pem 数据 CreatePKCS8PrivateKeyWithPassword("123", "AES256CBC", "SHA256")
func (SM2) CreatePrivateKey ¶
生成私钥 pem 数据 使用: obj := New().GenerateKey() priKey := obj.CreatePrivateKey().ToKeyString()
func (SM2) CreatePrivateKeyWithPassword ¶
生成私钥带密码 pem 数据
func (SM2) CreateSM2PrivateKeyWithPassword ¶ added in v1.0.1028
生成私钥带密码 pem 数据
func (SM2) DecryptAsn1 ¶ added in v1.0.1041
sm2 解密,解析 asn.1 编码格式的密文内容
func (SM2) EncryptAsn1 ¶ added in v1.0.1041
func (this SM2) EncryptAsn1(pub *sm2.PublicKey, data []byte, mode int, rand io.Reader) ([]byte, error)
sm2 加密,返回 asn.1 编码格式的密文内容
func (SM2) FromPrivateKeyBytes ¶
明文私钥生成私钥结构体
func (SM2) FromPrivateKeyDBytes ¶
私钥字符,必须先添加公钥
func (SM2) FromPrivateKeyString ¶
私钥字符,必须先添加公钥 (hexStringD) private-key: 07e4********;
func (SM2) FromPrivateKeyWithPassword ¶
私钥带密码
func (SM2) FromPublicKeyString ¶
公钥字符 (hexStringX + hexStringY) public-key: 047c********.
func (SM2) FromPublicKeyXYBytes ¶
公钥字符对
func (SM2) FromPublicKeyXYString ¶ added in v1.0.1018
公钥 x,y 16进制字符对 [xString: xHexString, yString: yHexString]
func (SM2) GetPrivateKeyCurve ¶
获取 PrivateKeyCurve
func (SM2) GetPrivateKeyDHexString ¶ added in v1.0.1018
获取 PrivateKeyD
func (SM2) GetPrivateKeyXHexString ¶ added in v1.0.1018
获取 PrivateKeyX
func (SM2) GetPrivateKeyYHexString ¶ added in v1.0.1018
获取 PrivateKeyY
func (SM2) GetPublicKeyXHexString ¶ added in v1.0.1018
获取 PublicKeyX
func (SM2) GetPublicKeyYHexString ¶ added in v1.0.1018
获取 PublicKeyY
func (SM2) ParsePKCS8PrivateKeyFromPEMWithPassword ¶ added in v1.0.1028
func (this SM2) ParsePKCS8PrivateKeyFromPEMWithPassword(key []byte, password string) (*sm2.PrivateKey, error)
解析 PSM2 KCS8 带密码的私钥
func (SM2) ParsePrivateKeyFromPEM ¶
func (this SM2) ParsePrivateKeyFromPEM(key []byte) (*sm2.PrivateKey, error)
解析 SM2 PKCS8 私钥
func (SM2) ParsePrivateKeyFromPEMWithPassword ¶
func (this SM2) ParsePrivateKeyFromPEMWithPassword(key []byte, password string) (*sm2.PrivateKey, error)
解析 SM2 PKCS8 私钥带密码
func (SM2) ParsePublicKeyFromPEM ¶
解析 SM2 PKCS8 公钥
func (SM2) VerifyAsn1 ¶
公钥验证 使用原始数据[data]对比签名后数据