Standard library / crypto/rsa
crypto/rsa.ErrVerification
Signature verification failure. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
var ErrVerification errorWorking Example
Example Snippetgo
package main
import ( "crypto" "crypto/rand" "crypto/rsa" "crypto/sha256" "errors" "fmt")
func main() { k := must(rsa.GenerateKey(rand.Reader, 2048)) h := sha256.Sum256([]byte("Go")) o := &rsa.PSSOptions{SaltLength: rsa.PSSSaltLengthEqualsHash, Hash: crypto.SHA256} s := must(rsa.SignPSS(rand.Reader, k, crypto.SHA256, h[:], o)) h[0] ^= 1 fmt.Println(errors.Is(rsa.VerifyPSS(&k.PublicKey, crypto.SHA256, h[:], s, o), rsa.ErrVerification))}func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}