diff options
author | Dwayne C. Litzenberger <dlitz@dlitz.net> | 2009-04-25 13:57:55 -0400 |
---|---|---|
committer | Dwayne C. Litzenberger <dlitz@dlitz.net> | 2009-04-25 13:57:58 -0400 |
commit | 133fbaddb8ef651536b82dabe4c4c8ee58c9193a (patch) | |
tree | 12291861c8240e7fcdade2c18d233d77d53f550b /src/_fastmath.c | |
parent | 6670391900e7aced3df02adbe0de20842b2d34fc (diff) | |
download | pycrypto-133fbaddb8ef651536b82dabe4c4c8ee58c9193a.tar.gz |
Crypto.PublicKey: Raise ValueError/TypeError/RuntimeError instead of the various custom "error" exceptions
At some point, it might be a good idea to remove the custom error classes themselves.
Diffstat (limited to 'src/_fastmath.c')
-rwxr-xr-x | src/_fastmath.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/_fastmath.c b/src/_fastmath.c index 0c65c45..58ddb10 100755 --- a/src/_fastmath.c +++ b/src/_fastmath.c @@ -415,7 +415,7 @@ dsaKey__sign (dsaKey * key, PyObject * args) result = dsaSign (key, m, k, r, s); if (result == 1) { - PyErr_SetString (fastmathError, "K not between 2 and q"); + PyErr_SetString (PyExc_ValueError, "K not between 2 and q"); return NULL; } lr = mpzToLongObj (r); @@ -600,7 +600,7 @@ rsaKey__encrypt (rsaKey * key, PyObject * args) result = rsaEncrypt (key, v); if (result == 1) { - PyErr_SetString (fastmathError, "Plaintext too large"); + PyErr_SetString (PyExc_ValueError, "Plaintext too large"); return NULL; } r = (PyObject *) mpzToLongObj (v); @@ -623,13 +623,13 @@ rsaKey__decrypt (rsaKey * key, PyObject * args) result = rsaDecrypt (key, v); if (result == 1) { - PyErr_SetString (fastmathError, + PyErr_SetString (PyExc_ValueError, "Ciphertext too large"); return NULL; } else if (result == 2) { - PyErr_SetString (fastmathError, + PyErr_SetString (PyExc_TypeError, "Private key not available in this object"); return NULL; } @@ -681,12 +681,12 @@ rsaKey__blind (rsaKey * key, PyObject * args) result = rsaBlind (key, v, vblind); if (result == 1) { - PyErr_SetString (fastmathError, "Message too large"); + PyErr_SetString (PyExc_ValueError, "Message too large"); return NULL; } else if (result == 2) { - PyErr_SetString (fastmathError, "Blinding factor too large"); + PyErr_SetString (PyExc_ValueError, "Blinding factor too large"); return NULL; } r = (PyObject *) mpzToLongObj (v); @@ -713,17 +713,17 @@ rsaKey__unblind (rsaKey * key, PyObject * args) result = rsaUnBlind (key, v, vblind); if (result == 1) { - PyErr_SetString (fastmathError, "Message too large"); + PyErr_SetString (PyExc_ValueError, "Message too large"); return NULL; } else if (result == 2) { - PyErr_SetString (fastmathError, "Blinding factor too large"); + PyErr_SetString (PyExc_ValueError, "Blinding factor too large"); return NULL; } else if (result == 3) { - PyErr_SetString (fastmathError, "Inverse doesn't exist"); + PyErr_SetString (PyExc_ValueError, "Inverse doesn't exist"); return NULL; } r = (PyObject *) mpzToLongObj (v); |