~ubuntu-branches/ubuntu/lucid/m2crypto/lucid

« back to all changes in this revision

Viewing changes to tests/test_dh.py

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-11-06 01:28:39 UTC
  • mfrom: (2.2.5 sid)
  • Revision ID: james.westby@ubuntu.com-20091106012839-zjjugwmj8zggokqh
Tags: 0.20.1-1ubuntu1
* Merge from debian testing, remaining changes:
  - debian/rules; enable testsuite, add more files to "clean" rule.
  - tests/test_ssl.py: use signal 9 to kill old s_server processes
    to work around build HUP signal-ignore-mask (LP: #451998).

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
        self.assertRaises(TypeError, DH.DH, 'junk')
22
22
 
23
23
    def test_gen_params(self):
24
 
        a = DH.gen_params(128, 2, self.genparam_callback)
 
24
        a = DH.gen_params(1024, 2, self.genparam_callback)
25
25
        assert a.check_params() == 0
26
26
 
27
27
    def test_gen_params_bad_cb(self):
28
 
        a = DH.gen_params(128, 2, self.genparam_callback2)
 
28
        a = DH.gen_params(1024, 2, self.genparam_callback2)
29
29
        assert a.check_params() == 0
30
30
 
31
31
    def test_print_params(self):
32
 
        a = DH.gen_params(128, 2, self.genparam_callback)
 
32
        a = DH.gen_params(1024, 2, self.genparam_callback)
33
33
        bio = BIO.MemoryBuffer()
34
34
        a.print_params(bio)
35
35
        params = bio.read()
36
 
        assert params.find('(128 bit)')
 
36
        assert params.find('(1024 bit)')
37
37
        assert params.find('generator: 2 (0x2)')
38
38
 
39
39
    def test_load_params(self):
48
48
        ak = a.compute_key(b.pub)
49
49
        bk = b.compute_key(a.pub)
50
50
        assert ak == bk
 
51
        self.assertEqual(len(a), 128)
 
52
 
 
53
        self.assertRaises(DH.DHError, setattr, a, 'p', 1)
 
54
        self.assertRaises(DH.DHError, setattr, a, 'priv', 1)
51
55
 
52
56
 
53
57
def suite():