diff options
author | Gary van der Merwe <garyvdm@gmail.com> | 2010-08-03 00:13:08 +0200 |
---|---|---|
committer | Gary van der Merwe <garyvdm@gmail.com> | 2010-08-03 00:13:08 +0200 |
commit | 044e7029986a060552770feb1687b00862f1a6ba (patch) | |
tree | e00ba3aa34c8bb343dce0da3f1d7470cd6c83421 /tests | |
parent | e2add909811956b4a5cd91d290a3df45612ba75d (diff) |
Use Crypto.Random rather than Crypto.Util.RandomPool.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_kex.py | 10 | ||||
-rw-r--r-- | tests/test_pkey.py | 11 | ||||
-rw-r--r-- | tests/test_util.py | 4 |
3 files changed, 12 insertions, 13 deletions
diff --git a/tests/test_kex.py b/tests/test_kex.py index 2ecb757c..f6e69960 100644 --- a/tests/test_kex.py +++ b/tests/test_kex.py @@ -28,17 +28,15 @@ from paramiko.kex_gex import KexGex from paramiko import Message -class FakeRandpool (object): - def stir(self): - pass - def get_bytes(self, n): +class FakeRng (object): + def read(self, n): return chr(0xcc) * n class FakeKey (object): def __str__(self): return 'fake-key' - def sign_ssh_data(self, randpool, H): + def sign_ssh_data(self, rng, H): return 'fake-sig' @@ -50,7 +48,7 @@ class FakeModulusPack (object): class FakeTransport (object): - randpool = FakeRandpool() + rng = FakeRng() local_version = 'SSH-2.0-paramiko_1.0' remote_version = 'SSH-2.0-lame' local_kex_init = 'local-kex-init' diff --git a/tests/test_pkey.py b/tests/test_pkey.py index e40bee13..89d55803 100644 --- a/tests/test_pkey.py +++ b/tests/test_pkey.py @@ -23,7 +23,8 @@ Some unit tests for public/private key objects. from binascii import hexlify, unhexlify import StringIO import unittest -from paramiko import RSAKey, DSSKey, Message, util, randpool +from paramiko import RSAKey, DSSKey, Message, util +from paramiko.common import rng # from openssh's ssh-keygen PUB_RSA = 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEA049W6geFpmsljTwfvI1UmKWWJPNFI74+vNKTk4dmzkQY2yAMs6FhlvhlI8ysU4oj71ZsRYMecHbBbxdN79+JRFVYTKaLqjwGENeTd+yv4q+V2PvZv3fLnzApI3l7EJCqhWwJUHJ1jAkZzqDx0tyOL4uoZpww3nmE0kb3y21tH4c=' @@ -151,7 +152,7 @@ class KeyTest (unittest.TestCase): def test_8_sign_rsa(self): # verify that the rsa private key can sign and verify key = RSAKey.from_private_key_file('tests/test_rsa.key') - msg = key.sign_ssh_data(randpool, 'ice weasels') + msg = key.sign_ssh_data(rng, 'ice weasels') self.assert_(type(msg) is Message) msg.rewind() self.assertEquals('ssh-rsa', msg.get_string()) @@ -164,7 +165,7 @@ class KeyTest (unittest.TestCase): def test_9_sign_dss(self): # verify that the dss private key can sign and verify key = DSSKey.from_private_key_file('tests/test_dss.key') - msg = key.sign_ssh_data(randpool, 'ice weasels') + msg = key.sign_ssh_data(rng, 'ice weasels') self.assert_(type(msg) is Message) msg.rewind() self.assertEquals('ssh-dss', msg.get_string()) @@ -178,12 +179,12 @@ class KeyTest (unittest.TestCase): def test_A_generate_rsa(self): key = RSAKey.generate(1024) - msg = key.sign_ssh_data(randpool, 'jerri blank') + msg = key.sign_ssh_data(rng, 'jerri blank') msg.rewind() self.assert_(key.verify_ssh_sig('jerri blank', msg)) def test_B_generate_dss(self): key = DSSKey.generate(1024) - msg = key.sign_ssh_data(randpool, 'jerri blank') + msg = key.sign_ssh_data(rng, 'jerri blank') msg.rewind() self.assert_(key.verify_ssh_sig('jerri blank', msg)) diff --git a/tests/test_util.py b/tests/test_util.py index 3569abf8..256c3d7c 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -147,8 +147,8 @@ class UtilTest (unittest.TestCase): os.unlink('hostfile.temp') def test_6_random(self): - from paramiko.common import randpool + from paramiko.common import rng # just verify that we can pull out 32 bytes and not get an exception. - x = randpool.get_bytes(32) + x = rng.read(32) self.assertEquals(len(x), 32) |