Documentation ¶
Overview ¶
nolint
nolint
nolint
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 tencentsm.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 tencentsm.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 ( // CTX_POOLSIZE_PER_PK is the default ctx pool size for each pk CTX_POOLSIZE_PER_PK = 10 CTXPOOL_CACHESIZE = 10000 )
View Source
const BIG_NUM_SIZE = 64
View Source
const SM2_CIPHER_EXTRA_SIZE = 120
View Source
const SM2_CIPHER_MODE_C1C2C3 = tencentsm.SM2CipherMode_C1C2C3
View Source
const SM2_CIPHER_MODE_C1C2C3_ASN1 = tencentsm.SM2CipherMode_C1C2C3_ASN1
View Source
const SM2_CIPHER_MODE_C1C3C2 = tencentsm.SM2CipherMode_C1C3C2
View Source
const SM2_CIPHER_MODE_C1C3C2_ASN1 = tencentsm.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 = tencentsm.SM2SignMode_RS
View Source
const SM2_SIGNATURE_MODE_RS_ASN1 = tencentsm.SM2SignMode_RS_ASN1
View Source
const SM3_DIGEST_SIZE = tencentsm.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)
MarshalPrivateKey marshal private to der encoded
func MarshalPublicKey ¶
MarshalPublicKey public key conversion
func PrivateKeyToPEM ¶
func PrivateKeyToPEM(key *PrivateKey) (string, error)
PrivateKeyToPEM marshal private key to pem encoded
Types ¶
type CtxPool ¶
type CtxPool struct {
// contains filtered or unexported fields
}
CtxPool is tencentsm public ctx pool
func NewCtxPoolWithPubKey ¶
NewCtxPoolWithPubKey new a ctx pool for pubkey
type PrivateKey ¶
func GenerateKeyPair ¶
func GenerateKeyPair() (*PrivateKey, error)
GenerateKeyPair generate a private key
func PrivateKeyFromPEM ¶
func PrivateKeyFromPEM(skPEM string) (*PrivateKey, error)
PrivateKeyFromPEM unmarshal pem key to PrivateKey
func UnmarshalPrivateKey ¶
func UnmarshalPrivateKey(der []byte) (*PrivateKey, error)
UnmarshalPrivateKey unmarshal der to PrivateKey
func UnmarshalPrivateKeyWithCurve ¶
func UnmarshalPrivateKeyWithCurve(namedCurveOID *asn1.ObjectIdentifier, der []byte) (*PrivateKey, error)
UnmarshalPrivateKeyWithCurve unmarshal der to PrivateKey
func (*PrivateKey) Bytes ¶
func (sk *PrivateKey) Bytes() ([]byte, error)
func (PrivateKey) Decrypt ¶
func (sk PrivateKey) Decrypt(cipher []byte) ([]byte, error)
func (*PrivateKey) DecryptWithMode ¶
func (sk *PrivateKey) DecryptWithMode(cipher []byte, mode tencentsm.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) Sign ¶
func (sk *PrivateKey) Sign(msg []byte) ([]byte, error)
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 ¶
ParseSM2PublicKey parse asn1 public key to PublicKey
func PublicKeyFromPEM ¶
PublicKeyFromPEM parse pem public key to PublicKey
func UnmarshalPublicKey ¶
UnmarshalPublicKey unmarshal der to PublicKey
func (PublicKey) EncryptWithMode ¶
func (PublicKey) EncryptWithOpts ¶
func (*PublicKey) ToStandardKey ¶
ToStandardKey nolint
Click to show internal directories.
Click to hide internal directories.