Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetHash ¶
func GetHash(scheme SignatureScheme) hash.Hash
func Serialize ¶
Serialize the signature object to byte array as the following format:
|---------------------------|-----------------| | signature_scheme (1 byte) | signature_data | |---------------------------|-----------------|
signature_data differs in the signature algorithm.
- For ECDSA, it is the concatenation of two byte arrays of equal length converted from R and S.
- For SM2, it starts with the user ID (empty if not specified) with a `0` as termination, and followed by the R and S data as described in ECDSA.
- For EdDSA, it is just the signature data which could be handled by package ed25519.
Types ¶
type SM2Signature ¶
type SM2Signature struct { DSASignature ID string }
type Signature ¶
type Signature struct { Scheme SignatureScheme Value interface{} }
func Deserialize ¶
Deserialize the input data into a Signature object.
func Sign ¶
func Sign(scheme SignatureScheme, pri crypto.PrivateKey, msg []byte, opt interface{}) (sig *Signature, err error)
Sign generates the signature for the input message @msg, using private key @pri and the signature scheme @scheme.
Some signature scheme may use extra parameters, which could be inputted via the last argument @opt:
- SM2 signature needs the user ID (string). If it is an empty string, the default ID ("1234567812345678") would be used.
type SignatureScheme ¶
type SignatureScheme byte
const ( SHA224withECDSA SignatureScheme = iota SHA256withECDSA SHA384withECDSA SHA512withECDSA SHA3_224withECDSA SHA3_256withECDSA SHA3_384withECDSA SHA3_512withECDSA RIPEMD160withECDSA SM3withSM2 SHA512withEDDSA )
func GetScheme ¶
func GetScheme(name string) (SignatureScheme, error)
func (SignatureScheme) Name ¶
func (s SignatureScheme) Name() string
Click to show internal directories.
Click to hide internal directories.