Documentation ¶
Index ¶
- Constants
- func Base64DecodeSM2ECDHPrivateKey(privStr string) (*ecdh.PrivateKey, error)
- func Base64DecodeSM2ECDHPublicKey(pubStr string) (*ecdh.PublicKey, error)
- func Base64DecodeSM2ECDSAPrivateKey(pubKeyStr string, privKeyStr string) (*sm2.PrivateKey, error)
- func Base64DecodeSM2ECDSAPublicKey(pubKeyStr string) (*ecdsa.PublicKey, error)
- func GenerateSM2ECDHKeypair() (string, string)
- func GenerateSM2ECDSAKeypair() (*sm2.PrivateKey, string, string)
- type HeaderGmsm
- func (h *HeaderGmsm) Bytes() []byte
- func (h *HeaderGmsm) Counter() uint64
- func (h *HeaderGmsm) EphermeralBytes() []byte
- func (h *HeaderGmsm) Flag() uint16
- func (h *HeaderGmsm) HMACBytes() []byte
- func (h *HeaderGmsm) IdentityBytes() []byte
- func (h *HeaderGmsm) NonceBytes() []byte
- func (h *HeaderGmsm) SetCounter(counter uint64)
- func (h *HeaderGmsm) SetFlag(flag uint16)
- func (h *HeaderGmsm) SetTypeAndPayloadSize(t int, s int)
- func (h *HeaderGmsm) SetVersion(major int, minor int)
- func (h *HeaderGmsm) Size() int
- func (h *HeaderGmsm) StaticBytes() []byte
- func (h *HeaderGmsm) TimestampBytes() []byte
- func (h *HeaderGmsm) TypeAndPayloadSize() (t int, s int)
- func (h *HeaderGmsm) Version() (int, int)
- type SM2ECDH
- func (s *SM2ECDH) Identity() []byte
- func (c *SM2ECDH) MidPublicKey() []byte
- func (s *SM2ECDH) Name() string
- func (s *SM2ECDH) PrivateKey() []byte
- func (s *SM2ECDH) PrivateKeyBase64() string
- func (s *SM2ECDH) PublicKey() []byte
- func (s *SM2ECDH) PublicKeyBase64() string
- func (s *SM2ECDH) SetPrivateKey(prk []byte) (err error)
- func (s *SM2ECDH) SharedSecret(pbk []byte) []byte
Constants ¶
View Source
const ( PrivateKeySize = 32 PublicKeySize = 64 )
View Source
const ( HeaderCommonSize = 24 HashSize = 32 GCMNonceSize = 12 GCMTagSize = 16 TimestampSize = 8 HeaderSize = HeaderCommonSize + PublicKeySize + PublicKeySize + GCMTagSize + TimestampSize + GCMTagSize + HashSize )
View Source
const ( NHP_FLAG_EXTENDEDLENGTH = 1 << iota NHP_FLAG_COMPRESS )
header flags (bit 0 - bit 11)
View Source
const (
NHP_FLAG_SCHEME_GMSM = 0 << 12
)
cipher scheme combination (bit 11 - bit 15)
Variables ¶
This section is empty.
Functions ¶
func Base64DecodeSM2ECDHPrivateKey ¶
func Base64DecodeSM2ECDHPrivateKey(privStr string) (*ecdh.PrivateKey, error)
func Base64DecodeSM2ECDSAPrivateKey ¶
func Base64DecodeSM2ECDSAPrivateKey(pubKeyStr string, privKeyStr string) (*sm2.PrivateKey, error)
func GenerateSM2ECDSAKeypair ¶
func GenerateSM2ECDSAKeypair() (*sm2.PrivateKey, string, string)
生成用于ECDSA的SM2公私钥对
Types ¶
type HeaderGmsm ¶
type HeaderGmsm struct { HeaderCommon [HeaderCommonSize]byte Ephermeral [PublicKeySize]byte Static [PublicKeySize + GCMTagSize]byte Timestamp [TimestampSize + GCMTagSize]byte HMAC [HashSize]byte }
func (*HeaderGmsm) Bytes ¶
func (h *HeaderGmsm) Bytes() []byte
func (*HeaderGmsm) Counter ¶
func (h *HeaderGmsm) Counter() uint64
func (*HeaderGmsm) EphermeralBytes ¶
func (h *HeaderGmsm) EphermeralBytes() []byte
func (*HeaderGmsm) Flag ¶
func (h *HeaderGmsm) Flag() uint16
func (*HeaderGmsm) HMACBytes ¶
func (h *HeaderGmsm) HMACBytes() []byte
func (*HeaderGmsm) IdentityBytes ¶
func (h *HeaderGmsm) IdentityBytes() []byte
func (*HeaderGmsm) NonceBytes ¶
func (h *HeaderGmsm) NonceBytes() []byte
func (*HeaderGmsm) SetCounter ¶
func (h *HeaderGmsm) SetCounter(counter uint64)
func (*HeaderGmsm) SetFlag ¶
func (h *HeaderGmsm) SetFlag(flag uint16)
func (*HeaderGmsm) SetTypeAndPayloadSize ¶
func (h *HeaderGmsm) SetTypeAndPayloadSize(t int, s int)
func (*HeaderGmsm) SetVersion ¶
func (h *HeaderGmsm) SetVersion(major int, minor int)
func (*HeaderGmsm) Size ¶
func (h *HeaderGmsm) Size() int
func (*HeaderGmsm) StaticBytes ¶
func (h *HeaderGmsm) StaticBytes() []byte
func (*HeaderGmsm) TimestampBytes ¶
func (h *HeaderGmsm) TimestampBytes() []byte
func (*HeaderGmsm) TypeAndPayloadSize ¶
func (h *HeaderGmsm) TypeAndPayloadSize() (t int, s int)
gmsm header implementations
func (*HeaderGmsm) Version ¶
func (h *HeaderGmsm) Version() (int, int)
type SM2ECDH ¶
type SM2ECDH struct { PrivKey [PrivateKeySize]byte PubKey [PublicKeySize]byte PrivKeyBase64 string PubKeyBase64 string BriefName string // contains filtered or unexported fields }
func (*SM2ECDH) MidPublicKey ¶
func (*SM2ECDH) PrivateKey ¶
func (*SM2ECDH) PrivateKeyBase64 ¶
func (*SM2ECDH) PublicKeyBase64 ¶
func (*SM2ECDH) SetPrivateKey ¶
func (*SM2ECDH) SharedSecret ¶
Click to show internal directories.
Click to hide internal directories.