# Packages
Package sm2ec defines/implements SM2 curve structure.
# Functions
AdjustCiphertextSplicingOrder utility method to change c2 c3 order.
ASN1Ciphertext2Plain utility method to convert ASN.1 encoding ciphertext to plain encoding format.
CalculateSM2Hash calculates hash value for data including uid and public key parameters according standards.
CalculateZA ZA = H256(ENTLA || IDA || a || b || xG || yG || xA || yA).
Decrypt sm2 decrypt implementation by default DecrypterOpts{C1C3C2}.
Encrypt sm2 encrypt implementation, compliance with GB/T 32918.4-2016.
EncryptASN1 sm2 encrypt and output ASN.1 result, compliance with GB/T 32918.4-2016.
GenerateKey generates a new SM2 private key.
IsSM2PublicKey check if given public key is a SM2 public key or not.
MarshalEnvelopedPrivateKey, returns sm2 key pair protected data with ASN.1 format:
SM2EnvelopedKey ::= SEQUENCE { symAlgID AlgorithmIdentifier, symEncryptedKey SM2Cipher, sm2PublicKey SM2PublicKey, sm2EncryptedPrivateKey BIT STRING, }
This implementation follows GB/T 35276-2017, uses SM4 cipher to encrypt sm2 private key.
NewKeyExchange create one new KeyExchange object
在部分场景中,在初始 KeyExchange 时暂时没有对端的公开信息(如公钥、UID),这些信息可能需要在后续的交换中得到。 这种情况下,可设置 peerPub、peerUID 参数为 nil,并在合适的时候通过 KeyExchange.SetPeerParameters 方法配置相关参数。 注意 KeyExchange.SetPeerParameters 方法必须要在 KeyExchange.RepondKeyExchange 或 KeyExchange.RepondKeyExchange 方法之前调用。.
NewPlainDecrypterOpts creates a SM2 non-ASN1 decrypter options.
NewPlainEncrypterOpts creates a SM2 non-ASN1 encrypter options.
NewPrivateKey checks that key is valid and returns a SM2 PrivateKey.
NewPrivateKeyFromInt checks that key is valid and returns a SM2 PrivateKey.
NewPublicKey checks that key is valid and returns a PublicKey.
NewSM2SignerOption creates a SM2 specific signer option.
P256 returns sm2 curve signleton, this function is for backward compatibility.
ParseEnvelopedPrivateKey, parses and decrypts the enveloped SM2 private key.
PlainCiphertext2ASN1 utility method to convert plain encoding ciphertext to ASN.1 encoding format.
PublicKeyToECDH returns k as a [ecdh.PublicKey].
RecoverPublicKeysFromSM2Signature recovers two or four SM2 public keys from a given signature and hash.
Sign signs a hash (which should be the result of hashing a larger message) using the private key, priv.
SignASN1 signs a hash (which should be the result of hashing a larger message) using the private key, priv.
SignWithSM2 follow sm2 dsa standards for hash part, compliance with GB/T 32918.2-2016.
Verify verifies the signature in r, s of hash using the public key, pub.
VerifyASN1 verifies the ASN.1 encoded signature, sig, of hash using the public key, pub.
VerifyASN1WithSM2 verifies the signature in ASN.1 encoding format sig of raw msg and uid using the public key, pub.
VerifyWithSM2 verifies the signature in r, s of raw msg and uid using the public key, pub.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
MarshalCompressed compressed mashal mode.
MarshalHybrid hybrid mashal mode.
MarshalUncompressed uncompressed mashal mode.
# Variables
No description provided by the author
No description provided by the author
DefaultSM2SignerOpts uses default UID and forceGMSign is true.
ErrDecryption represents a failure to decrypt a message.
No description provided by the author
# Structs
DecrypterOpts decryption options.
EncrypterOpts encryption options.
KeyExchange key exchange struct, include internal stat in whole key exchange flow.
PrivateKey represents an ECDSA SM2 private key.
SM2SignerOption implements crypto.SignerOpts interface.
# Interfaces
Signer SM2 special signer.