Documentation ¶
Index ¶
- Constants
- func BHGenerateKey() (pubKey string, priKey string, err error)
- func BHGeneratePointCompressKey() (pubKey string, priKey string, err error)
- func BHSign(priKey string, userID []byte, src []byte) ([]byte, error)
- func BHSignX(priKey string, userID []byte, src []byte) ([]byte, error)
- func BHVerify(pubKey string, userID []byte, src []byte, sign []byte) (pass bool, err error)
- func BHVerifyWithPointCompress(pubKey string, userID []byte, src []byte, sign []byte) (pass bool, err error)
- func BHVerifyWithPointCompressX(pubKey string, userID []byte, src []byte, sign []byte) (pass bool, err error)
- func BHVerifyX(pubKey string, userID []byte, src []byte, sign []byte) (pass bool, err error)
- func Decrypt(priv *PrivateKey, in []byte) ([]byte, error)
- func Encrypt(pub *PublicKey, in []byte) ([]byte, error)
- func GenerateKey(rand io.Reader) (*PrivateKey, *PublicKey, error)
- func MarshalCipher(in []byte) ([]byte, error)
- func MarshalSign(r, s *big.Int) ([]byte, error)
- func P256Sm2() elliptic.Curve
- 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) (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
Constants ¶
const ( BitSize = 256 KeyBytes = (BitSize + 7) / 8 UnCompress = 0x04 )
Variables ¶
This section is empty.
Functions ¶
func BHGenerateKey ¶
BHGenerateKey used to product publicKey and privateKey
func BHGeneratePointCompressKey ¶
BHGeneratePointCompressKey used to product publicKey and privateKey. The publicKey is ponit compressed
func BHSign ¶
BHSign used to sign src,priKey is hex string.return r/s bytes If userID be assigned nil,which default value is 1234567812345678
func BHSignX ¶
BHSignX used to sign src,priKey is hex string.return asn.1 format bytes If userID be assigned nil,which default value is 1234567812345678
func BHVerify ¶
BHVerify function is similar with VerifyWithPointCompress,the pubKey is unCompress,the sign is r/s bytes
func BHVerifyWithPointCompress ¶
func BHVerifyWithPointCompress(pubKey string, userID []byte, src []byte, sign []byte) (pass bool, err error)
BHVerifyWithPointCompress used to verify src and sign,the pubKey is point compress,the sign is r/s bytes If userID be assigned nil,which default value is 1234567812345678
func BHVerifyWithPointCompressX ¶
func BHVerifyWithPointCompressX(pubKey string, userID []byte, src []byte, sign []byte) (pass bool, err error)
BHVerifyWithPointCompressX used to verify src and sign,the pubKey is point compress,the sign is asn.1 format bytes If userID be assigned nil,which default value is 1234567812345678
func BHVerifyX ¶
BHVerifyX function is similar with VerifyWithPointCompress,the pubKey is unCompress,the sign is asn.1 format bytes
func GenerateKey ¶
func GenerateKey(rand io.Reader) (*PrivateKey, *PublicKey, error)
func MarshalCipher ¶
func ResponderConfirm ¶
func UnmarshalCipher ¶
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
}