Commits

Benoît Allard committed ff3e12c Draft

PyCryptRSA: Make verification work

Comments (0)

Files changed (1)

pythoncardx/crypto/cipher.py

         if self.mode == self.MODE_ENCRYPT:
             (res, ) = self._theKey._theKey.encrypt(_arrayTolong(data), None)
         else:
-            res = self._theKey._theKey.decrypt(_arrayTolong(data))
+            if isinstance(self._theKey, RSAPublicKey):
+                # We are actually verifying, which can be done the same way as
+                # encrypting ...
+                (res, ) = self._theKey._theKey.encrypt(_arrayTolong(data), None)
+            else:
+                res = self._theKey._theKey.decrypt(_arrayTolong(data))
 
         buf = _longToArray(res)