Documentation ¶
Index ¶
- Constants
- func GetSignatureFromCFCA(signature []byte) []byte
- func MarshalPrivateKey(key *PrivateKey) ([]byte, error)
- func MarshalPublicKey(key *PublicKey) ([]byte, error)
- func PrivateKeyToPEM(key *PrivateKey) (string, error)
- func PublicKeyToPEM(key *PublicKey) (string, error)
- type CtxPool
- type PrivateKey
- func (sk *PrivateKey) Bytes() ([]byte, error)
- func (sk PrivateKey) Decrypt(cipher []byte) ([]byte, error)
- func (sk *PrivateKey) DecryptWithMode(cipher []byte, mode lhsm.SM2CipherMode) ([]byte, error)
- func (sk PrivateKey) DecryptWithOpts(ciphertext []byte, opts *bccrypto.EncOpts) ([]byte, error)
- func (sk PrivateKey) EncryptKey() bccrypto.EncryptKey
- func (sk *PrivateKey) PublicKey() bccrypto.PublicKey
- func (sk *PrivateKey) Sign(msg []byte) ([]byte, error)
- func (sk *PrivateKey) SignWithOpts(msg []byte, opts *bccrypto.SignOpts) ([]byte, error)
- func (sk *PrivateKey) String() (string, error)
- func (sk *PrivateKey) ToStandardKey() crypto.PrivateKey
- func (sk *PrivateKey) Type() bccrypto.KeyType
- type PublicKey
- func (pk *PublicKey) Bytes() ([]byte, error)
- func (pk PublicKey) Encrypt(msg []byte) ([]byte, error)
- func (pk PublicKey) EncryptWithMode(msg []byte, mode lhsm.SM2CipherMode) ([]byte, error)
- func (pk PublicKey) EncryptWithOpts(data []byte, opts *bccrypto.EncOpts) ([]byte, error)
- func (pk *PublicKey) String() (string, error)
- func (pk *PublicKey) ToStandardKey() crypto.PublicKey
- func (pk *PublicKey) Type() bccrypto.KeyType
- func (pk *PublicKey) Verify(data []byte, sig []byte) (bool, error)
- func (pk *PublicKey) VerifyWithOpts(msg []byte, sig []byte, opts *bccrypto.SignOpts) (bool, error)
Constants ¶
View Source
const BIG_NUM_SIZE = 64
View Source
const (
CTX_POOLSIZE_PER_PK = 1
)
View Source
const SM2_CIPHER_EXTRA_SIZE = 120
View Source
const SM2_CIPHER_MODE_C1C2C3 = lhsm.SM2CipherMode_C1C2C3
View Source
const SM2_CIPHER_MODE_C1C2C3_ASN1 = lhsm.SM2CipherMode_C1C2C3_ASN1
View Source
const SM2_CIPHER_MODE_C1C3C2 = lhsm.SM2CipherMode_C1C3C2
View Source
const SM2_CIPHER_MODE_C1C3C2_ASN1 = lhsm.SM2CipherMode_C1C3C2_ASN1
View Source
const SM2_PRIVATE_KEY_SIZE = 64
View Source
const SM2_PRIVATE_KEY_STR_LEN = 66
View Source
const SM2_PUBLIC_KEY_SIZE = 130
View Source
const SM2_PUBLIC_KEY_STR_LEN = 132
View Source
const SM2_SIGNATURE_MAX_SIZE = 80
View Source
const SM2_SIGNATURE_MODE_RS = lhsm.SM2SignMode_RS
View Source
const SM2_SIGNATURE_MODE_RS_ASN1 = lhsm.SM2SignMode_RS_ASN1
View Source
const SM3_DIGEST_SIZE = lhsm.SM3_DIGEST_LENGTH
Variables ¶
This section is empty.
Functions ¶
func GetSignatureFromCFCA ¶
nolint CFCA证书若签名为31位,会补0,go本身是不补,长度写31 兼容 去掉补0,长度改为31
func MarshalPrivateKey ¶
func MarshalPrivateKey(key *PrivateKey) ([]byte, error)
func PrivateKeyToPEM ¶
func PrivateKeyToPEM(key *PrivateKey) (string, error)
func PublicKeyToPEM ¶
Types ¶
type CtxPool ¶
type CtxPool struct {
// contains filtered or unexported fields
}
func NewCtxPoolWithPubKey ¶
func (*CtxPool) ReleaseCtx ¶
type PrivateKey ¶
func GenerateKeyPair ¶
func GenerateKeyPair() (*PrivateKey, error)
func PrivateKeyFromPEM ¶
func PrivateKeyFromPEM(skPEM string) (*PrivateKey, error)
func UnmarshalPrivateKey ¶
func UnmarshalPrivateKey(der []byte) (*PrivateKey, error)
func UnmarshalPrivateKeyWithCurve ¶
func UnmarshalPrivateKeyWithCurve(namedCurveOID *asn1.ObjectIdentifier, der []byte) (*PrivateKey, error)
func (*PrivateKey) Bytes ¶
func (sk *PrivateKey) Bytes() ([]byte, error)
func (*PrivateKey) DecryptWithMode ¶
func (sk *PrivateKey) DecryptWithMode(cipher []byte, mode lhsm.SM2CipherMode) ([]byte, error)
func (PrivateKey) DecryptWithOpts ¶
func (PrivateKey) EncryptKey ¶
func (sk PrivateKey) EncryptKey() bccrypto.EncryptKey
func (*PrivateKey) PublicKey ¶
func (sk *PrivateKey) PublicKey() bccrypto.PublicKey
func (*PrivateKey) SignWithOpts ¶
func (*PrivateKey) String ¶
func (sk *PrivateKey) String() (string, error)
func (*PrivateKey) ToStandardKey ¶
func (sk *PrivateKey) ToStandardKey() crypto.PrivateKey
func (*PrivateKey) Type ¶
func (sk *PrivateKey) Type() bccrypto.KeyType
type PublicKey ¶
type PublicKey struct { elliptic.Curve X, Y *big.Int Text []byte // contains filtered or unexported fields }
func ParseSM2PublicKey ¶
func PublicKeyFromPEM ¶
func UnmarshalPublicKey ¶
func (PublicKey) EncryptWithMode ¶
func (PublicKey) EncryptWithOpts ¶
func (*PublicKey) ToStandardKey ¶
ToStandardKey nolint
Click to show internal directories.
Click to hide internal directories.