check sign from client

This commit is contained in:
Tnze
2022-12-03 14:59:24 +08:00
parent 68a3f48e97
commit fde8193afd
3 changed files with 62 additions and 30 deletions

View File

@ -1,6 +1,7 @@
package auth
import (
"crypto"
"crypto/rsa"
"crypto/x509"
"errors"
@ -67,3 +68,7 @@ func (p *PublicKey) Verify() bool {
}
return VerifySignature(encoded, p.Signature)
}
func (p *PublicKey) VerifyMessage(hash, signature []byte) error {
return rsa.VerifyPKCS1v15(p.PubKey, crypto.SHA256, hash, signature)
}