Browse Source

Add trudy keys and show failure

master
Khoi Trinh 3 years ago
parent
commit
88ce90f88a
  1. 24
      rsa-encrypt-sign.go

24
rsa-encrypt-sign.go

@ -27,6 +27,13 @@ func main() {
} }
bobPublicKey := &bobPrivateKey.PublicKey bobPublicKey := &bobPrivateKey.PublicKey
trudyPrivateKey, err := rsa.GenerateKey(rand.Reader, 2048)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
trudyPublicKey := &trudyPrivateKey.PublicKey
fmt.Println("Alice's Private Key : ", alicePrivateKey) fmt.Println("Alice's Private Key : ", alicePrivateKey)
fmt.Println() fmt.Println()
fmt.Println("Alice's Public key ", alicePublicKey) fmt.Println("Alice's Public key ", alicePublicKey)
@ -124,4 +131,21 @@ func main() {
} else { } else {
fmt.Println("Verify Signature successful!") fmt.Println("Verify Signature successful!")
} }
fmt.Printf("OAEP decrypted [%x] to \n[%s]\n", ciphertext2, plainText)
fmt.Println()
err = rsa.VerifyPSS(
trudyPublicKey,
newhash,
hashed,
signature,
&opts)
if err != nil {
fmt.Println("Signature verification failed!")
os.Exit(1)
} else {
fmt.Println("Verify Signature successful!")
}
} }

Loading…
Cancel
Save