aboutsummaryrefslogtreecommitdiffstats
path: root/test.patch
blob: 63084cba7a9e263f8239599fcd7d2e59c74ed4fc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
--- a/tests/test_ec_curves.py
+++ b/tests/test_ec_curves.py
@@ -20,8 +20,17 @@ Hunk #1, a/tests/test_ec_curves.py
 
 import unittest
 #import sha
-from M2Crypto import EC, Rand
-from test_ecdsa import ECDSATestCase as ECDSATest
+try:
+    from M2Crypto import EC, Rand
+    from test_ecdsa import ECDSATestCase as ECDSATest
+# AttributeError: 'module' object has no attribute 'ec_init'
+#except AttributeError:
+except:
+    EC_Module_Available = False
+    print("No EC modules available")
+else:
+    EC_Module_Available = True
+    print("EC modules are available")
 
 
 curves = [
@@ -108,6 +117,9 @@ Hunk #2, a/tests/test_ec_curves.py curves = [
 #    ('ipsec4', 185),
 #]
 
+
+@unittest.skipUnless(EC_Module_Available,
+                     'Requires EC modules compiled into OpenSSL')
 class ECCurveTests(unittest.TestCase):
     #data = sha.sha('Kilroy was here!').digest()     # 160 bits
     data = "digest"     # keep short (48 bits) so lesser curves 
@@ -153,7 +165,8 @@ Hunk #3, a/tests/test_ec_curves.py def suite():
 
 
 if __name__ == '__main__':
-    Rand.load_file('randpool.dat', -1) 
+    print("EC_Module_Available = %s" % EC_Module_Available)
+    Rand.load_file('randpool.dat', -1)
     unittest.TextTestRunner().run(suite())
     Rand.save_file('randpool.dat')
 
--- a/tests/test_ecdh.py
+++ b/tests/test_ecdh.py
@@ -8,9 +8,20 @@ Hunk #1, a/tests/test_ecdh.py Portions copyright (c) 2005-2006 Vrije U
 
 
 import unittest
-from M2Crypto import EC, BIO, Rand, m2
 import sys
+try:
+    from M2Crypto import EC, BIO, Rand, m2
+# AttributeError: 'module' object has no attribute 'ec_init'
+except:
+    EC_Module_Available = False
+    print("No EC modules available")
+else:
+    EC_Module_Available = True
+    print("EC modules are available")
 
+
+@unittest.skipUnless(EC_Module_Available,
+                     'Requires EC modules compiled into OpenSSL')
 class ECDHTestCase(unittest.TestCase):
 
     privkey = 'tests/ec.priv.pem'
@@ -43,7 +54,8 @@ Hunk #2, a/tests/test_ecdh.py def suite():
 
 
 if __name__=='__main__':
-    Rand.load_file('randpool.dat', -1) 
+    print("EC_Module_Available = %s" % EC_Module_Available)
+    Rand.load_file('randpool.dat', -1)
     unittest.TextTestRunner().run(suite())
     Rand.save_file('randpool.dat')
 
--- a/tests/test_ecdsa.py
+++ b/tests/test_ecdsa.py
@@ -8,8 +8,20 @@ Hunk #1, a/tests/test_ecdsa.py Portions copyright (c) 2005-2006 Vrije U
 
 import unittest
 import sha
-from M2Crypto import EC, BIO, Rand, m2
+try:
+    from M2Crypto import EC, BIO, Rand, m2
+# AttributeError: 'module' object has no attribute 'ec_init'
+#except AttributeError:
+except:
+    EC_Module_Available = False
+    print("No EC modules available")
+else:
+    EC_Module_Available = True
+    print("EC modules are available")
 
+
+@unittest.skipUnless(EC_Module_Available,
+                     'Requires EC modules compiled into OpenSSL')
 class ECDSATestCase(unittest.TestCase):
 
     errkey = 'tests/rsa.priv.pem'
@@ -69,7 +81,8 @@ Hunk #2, a/tests/test_ecdsa.py def suite():
     
 
 if __name__ == '__main__':
-    Rand.load_file('randpool.dat', -1) 
+    print("EC_Module_Available = %s" % EC_Module_Available)
+    Rand.load_file('randpool.dat', -1)
     unittest.TextTestRunner().run(suite())
     Rand.save_file('randpool.dat')