Line 0
Link Here
|
|
|
1 |
--- ./lib/Crypto/SelfTest/Util/test_number.py.orig 2012-10-03 16:03:52.000000000 +1000 |
2 |
+++ ./lib/Crypto/SelfTest/Util/test_number.py 2012-10-03 16:04:01.000000000 +1000 |
3 |
@@ -276,6 +276,11 @@ |
4 |
self.assertEqual(number.size(0xa2ba40),8*3) |
5 |
self.assertEqual(number.size(0xa2ba40ee07e3b2bd2f02ce227f36a195024486e49c19cb41bbbdfbba98b22b0e577c2eeaffa20d883a76e65e394c69d4b3c05a1e8fadda27edb2a42bc000fe888b9b32c22d15add0cd76b3e7936e19955b220dd17d4ea904b1ec102b2e4de7751222aa99151024c7cb41cc5ea21d00eeb41f7c800834d2c6e06bce3bce7ea9a5L), 1024) |
6 |
|
7 |
+class FastmathTests(unittest.TestCase): |
8 |
+ def setUp(self): |
9 |
+ global number |
10 |
+ from Crypto.Util import number |
11 |
+ |
12 |
def test_negative_number_roundtrip_mpzToLongObj_longObjToMPZ(self): |
13 |
"""Test that mpzToLongObj and longObjToMPZ (internal functions) roundtrip negative numbers correctly.""" |
14 |
n = -100000000000000000000000000000000000L |
15 |
@@ -286,7 +291,21 @@ |
16 |
|
17 |
def get_tests(config={}): |
18 |
from Crypto.SelfTest.st_common import list_test_cases |
19 |
- return list_test_cases(MiscTests) |
20 |
+ tests = list_test_cases(MiscTests) |
21 |
+ try: |
22 |
+ from Crypto.PublicKey import _fastmath |
23 |
+ tests += list_test_cases(FastmathTests) |
24 |
+ except ImportError: |
25 |
+ from distutils.sysconfig import get_config_var |
26 |
+ import inspect, os.path |
27 |
+ _fm_path = os.path.normpath(os.path.dirname(os.path.abspath( |
28 |
+ inspect.getfile(inspect.currentframe()))) |
29 |
+ +"/../../PublicKey/_fastmath"+get_config_var("SO")) |
30 |
+ if os.path.exists(_fm_path): |
31 |
+ raise ImportError("While the _fastmath module exists, importing "+ |
32 |
+ "it failed. This may point to the gmp or mpir shared library "+ |
33 |
+ "not being in the path. _fastmath was found at "+_fm_path) |
34 |
+ return tests |
35 |
|
36 |
if __name__ == '__main__': |
37 |
suite = lambda: unittest.TestSuite(get_tests()) |