Standard library / crypto/rsa
crypto/rsa.PrivateKey.Validate()
Checks mathematical consistency of an RSA key; does not establish provenance or security policy. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func (priv *PrivateKey) Validate() errorReturn Value
error
Result as described above; check any returned error before use.
Working Example
Example Snippetgo
package main
import ( "crypto/rand" "crypto/rsa" "fmt")
func main() { k := must(rsa.GenerateKey(rand.Reader, 2048)); fmt.Println(k.Validate() == nil) }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) }}