summaryrefslogtreecommitdiff
path: root/lib/Crypto/Util
diff options
context:
space:
mode:
authorDwayne C. Litzenberger <dlitz@dlitz.net>2011-10-10 12:40:39 -0400
committerDwayne C. Litzenberger <dlitz@dlitz.net>2011-10-10 14:49:26 -0400
commit9cfb332b22e38b9d965bfb691eca67b6b8fa64e3 (patch)
tree6c01ceb39716bacbe3d2a0c756ad3a5adac119f1 /lib/Crypto/Util
parent86c4cf4ea66e926267f53348d22698774a7939a5 (diff)
downloadpycrypto-9cfb332b22e38b9d965bfb691eca67b6b8fa64e3.tar.gz
autoconf: only use side-channel secured mpz_powm_sec if it's available (libgmp 5 or later)
Diffstat (limited to 'lib/Crypto/Util')
-rw-r--r--lib/Crypto/Util/number.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Crypto/Util/number.py b/lib/Crypto/Util/number.py
index 7be595b..d5d0c08 100644
--- a/lib/Crypto/Util/number.py
+++ b/lib/Crypto/Util/number.py
@@ -26,7 +26,8 @@
__revision__ = "$Id$"
-from Crypto.pct_warnings import GetRandomNumber_DeprecationWarning
+from Crypto.pct_warnings import GetRandomNumber_DeprecationWarning, PowmInsecureWarning
+from warnings import warn as _warn
import math
bignum = long
@@ -35,6 +36,10 @@ try:
except ImportError:
_fastmath = None
+# You need libgmp v5 or later to get mpz_powm_sec. Warn if it's not available.
+if _fastmath is not None and not _fastmath.HAVE_DECL_MPZ_POWM_SEC:
+ _warn("Not using mpz_powm_sec. You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.", PowmInsecureWarning)
+
# New functions
from _number_new import *