--- /dev/null
+update request {
+ &Tmp-String-0 := "Hello world!"
+}
+
+update request {
+ &Tmp-Octets-0 := "%{cipher_rsa_sign:%{Tmp-String-0}}"
+}
+
+if (!&Tmp-Octets-0) {
+ test_fail
+}
+else {
+ test_pass
+}
+
+if (<octets>&Tmp-String-0[0] == &Tmp-Octets-0[0]) {
+ test_fail
+}
+else {
+ test_pass
+}
+
+#
+# Pass the signature and the original message to the verification function
+#
+update request {
+ &Tmp-String-0 := "%{cipher_rsa_verify:%{Tmp-Octets-0} %{Tmp-String-0}}"
+}
+
+if (&Tmp-String-0 != 'yes') {
+ test_fail
+}
+else {
+ test_pass
+}
+
+#
+# Verification should now fail
+#
+update request {
+ &Tmp-String-0 := "Goodbye world!"
+}
+update request {
+ &Tmp-String-0 := "%{cipher_rsa_verify:%{Tmp-Octets-0} %{Tmp-String-0}}"
+}
+
+if (&Tmp-String-0 != 'no') {
+ test_fail
+}
+else {
+ test_pass
+}
+
+#
+# Repeat tests to ensure there are no issues with EVP_PKEY_CTX reuse
+#
+update request {
+ &Tmp-String-0 := "Hello nurse!"
+}
+
+update request {
+ &Tmp-Octets-0 := "%{cipher_rsa_sign:%{Tmp-String-0}}"
+}
+
+if (!&Tmp-Octets-0) {
+ test_fail
+}
+else {
+ test_pass
+}
+
+if (<octets>&Tmp-String-0[0] == &Tmp-Octets-0[0]) {
+ test_fail
+}
+else {
+ test_pass
+}
+
+#
+# Pass the signature and the original message to the verification function
+#
+update request {
+ &Tmp-String-0 := "%{cipher_rsa_verify:%{Tmp-Octets-0} %{Tmp-String-0}}"
+}
+
+if (&Tmp-String-0 != 'yes') {
+ test_fail
+}
+else {
+ test_pass
+}
+
+#
+# Verification should now fail
+#
+update request {
+ &Tmp-String-0 := "Goodbye nurse!"
+}
+update request {
+ &Tmp-String-0 := "%{cipher_rsa_verify:%{Tmp-Octets-0} %{Tmp-String-0}}"
+}
+
+if (&Tmp-String-0 != 'no') {
+ test_fail
+}
+else {
+ test_pass
+}