diff --git a/lib/modules/Crypto.pmod/DSA.pmod b/lib/modules/Crypto.pmod/DSA.pmod
index 710c23881cba00104e89d01e7c32abedd25fccab..eb90e3718b5f97fe95165e9d72dab2f7f7d39284 100644
--- a/lib/modules/Crypto.pmod/DSA.pmod
+++ b/lib/modules/Crypto.pmod/DSA.pmod
@@ -368,6 +368,9 @@ class State {
   //! Verify the signature @[r],@[s] against the message @[h].
   int(0..1) raw_verify(Gmp.mpz h, Gmp.mpz r, Gmp.mpz s)
   {
+    if ((r > q) || (s > q)) {
+      return 0;
+    }
     Gmp.mpz w;
     if (catch
       {