Commit 3f041f35 by dliangx

签名函数修改

parent 9ee05aca
......@@ -72,10 +72,11 @@ func EncryptAndSign[T any](resp HttpBodyResp[T]) (CryptHttpBodyResp, error) {
log.Println(err)
return cresp, err
}
rBytes := r.Bytes()
sBytes := s.Bytes()
signature := append(rBytes, sBytes...)
signature, err := sm2.SignDigitToSignData(r, s)
if err != nil {
log.Println(err)
return cresp, err
}
cresp.Signature = signature
return cresp, err
}
......@@ -84,7 +85,7 @@ func VerifyAndDecrypt[T any](creq CryptHttpBodyReq) (HttpBodyReq[T], error) {
var req HttpBodyReq[T]
privateKeyBytes, _ := sm2.GenerateKey(strings.NewReader(nltconst.SM2_PRIVATE_KEY))
signature := creq.Signature
r, s, err := sm2.SignDataToSignDigit([]byte(signature))
r, s, err := sm2.SignDataToSignDigit(signature)
if err != nil {
log.Println(err)
return req, err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment