Documentation ¶
Index ¶
- Constants
- func Decrypt(priv *PrivateKey, in []byte, cipherTextType Sm2CipherTextType) ([]byte, error)
- func Encrypt(pub *PublicKey, in []byte, cipherTextType Sm2CipherTextType) ([]byte, error)
- func GenerateKey(rand io.Reader) (*PrivateKey, *PublicKey, error)
- func MarshalCipher(in []byte, cipherTextType Sm2CipherTextType) ([]byte, error)
- func MarshalSign(r, s *big.Int) ([]byte, error)
- func ResponderConfirm(responderS2 []byte, initiatorS2 []byte) bool
- func Sign(priv *PrivateKey, userId []byte, in []byte) ([]byte, error)
- func SignToRS(priv *PrivateKey, userId []byte, in []byte) (r, s *big.Int, err error)
- func UnmarshalCipher(in []byte, cipherTextType Sm2CipherTextType) (out []byte, err error)
- func UnmarshalSign(sign []byte) (r, s *big.Int, err error)
- func Verify(pub *PublicKey, userId []byte, src []byte, sign []byte) bool
- func VerifyByRS(pub *PublicKey, userId []byte, src []byte, r, s *big.Int) bool
- type ExchangeResult
- type P256V1Curve
- type PrivateKey
- type PublicKey
- type Sm2CipherTextType
Constants ¶
View Source
const ( BitSize = 256 KeyBytes = (BitSize + 7) / 8 UnCompress = 0x04 )
Variables ¶
This section is empty.
Functions ¶
func Decrypt ¶
func Decrypt(priv *PrivateKey, in []byte, cipherTextType Sm2CipherTextType) ([]byte, error)
func Encrypt ¶
func Encrypt(pub *PublicKey, in []byte, cipherTextType Sm2CipherTextType) ([]byte, error)
func GenerateKey ¶
func GenerateKey(rand io.Reader) (*PrivateKey, *PublicKey, error)
func MarshalCipher ¶
func MarshalCipher(in []byte, cipherTextType Sm2CipherTextType) ([]byte, error)
func ResponderConfirm ¶
func UnmarshalCipher ¶
func UnmarshalCipher(in []byte, cipherTextType Sm2CipherTextType) (out []byte, err error)
Types ¶
type ExchangeResult ¶
func CalculateKeyWithConfirmation ¶
func CalculateKeyWithConfirmation(initiator bool, keyBits int, confirmationTag []byte, selfStaticPriv *PrivateKey, selfEphemeralPriv *PrivateKey, selfId []byte, otherStaticPub *PublicKey, otherEphemeralPub *PublicKey, otherId []byte) (*ExchangeResult, error)
type P256V1Curve ¶
type P256V1Curve struct { *elliptic.CurveParams A *big.Int }
func GetSm2P256V1 ¶
func GetSm2P256V1() P256V1Curve
type PrivateKey ¶
type PrivateKey struct { D *big.Int Curve P256V1Curve }
func RawBytesToPrivateKey ¶
func RawBytesToPrivateKey(bytes []byte) (*PrivateKey, error)
func (*PrivateKey) GetRawBytes ¶
func (pri *PrivateKey) GetRawBytes() []byte
type PublicKey ¶
type PublicKey struct {
X, Y *big.Int
Curve P256V1Curve
}
func CalculatePubKey ¶
func CalculatePubKey(priv *PrivateKey) *PublicKey
func RawBytesToPublicKey ¶
func (*PublicKey) GetRawBytes ¶
func (*PublicKey) GetUnCompressBytes ¶
type Sm2CipherTextType ¶
type Sm2CipherTextType int32
const ( // 旧标准的密文顺序 C1C2C3 Sm2CipherTextType = 1 // [GM/T 0009-2012]标准规定的顺序 C1C3C2 Sm2CipherTextType = 2 )
Click to show internal directories.
Click to hide internal directories.