summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-09-09 14:19:27 -0300
committerdrebs <drebs@leap.se>2013-09-18 11:24:55 -0300
commit2b0f2f02ca296d5e4fc167f0753f988c08a52064 (patch)
tree485eb923e0380cdedb2bf797621f217c9f5b963b
parentc51e243917c9cfd5859de9f42fcb9943a94ab096 (diff)
Remove pycrypto as test requirement.
-rw-r--r--common/src/leap/soledad/common/tests/test_crypto.py23
1 files changed, 10 insertions, 13 deletions
diff --git a/common/src/leap/soledad/common/tests/test_crypto.py b/common/src/leap/soledad/common/tests/test_crypto.py
index 01b43299..db217bb3 100644
--- a/common/src/leap/soledad/common/tests/test_crypto.py
+++ b/common/src/leap/soledad/common/tests/test_crypto.py
@@ -29,9 +29,6 @@ import binascii
from leap.common.testing.basetest import BaseLeapTest
-from Crypto import Random
-
-
from leap.soledad.client import (
Soledad,
crypto,
@@ -193,7 +190,7 @@ class SoledadCryptoAESTestCase(BaseSoledadTest):
def test_encrypt_decrypt_sym(self):
# generate 256-bit key
- key = Random.new().read(32)
+ key = os.urandom(32)
iv, cyphertext = self._soledad._crypto.encrypt_sym(
'data', key,
method=crypto.EncryptionMethods.AES_256_CTR)
@@ -206,7 +203,7 @@ class SoledadCryptoAESTestCase(BaseSoledadTest):
self.assertEqual('data', plaintext)
def test_decrypt_with_wrong_iv_fails(self):
- key = Random.new().read(32)
+ key = os.urandom(32)
iv, cyphertext = self._soledad._crypto.encrypt_sym(
'data', key,
method=crypto.EncryptionMethods.AES_256_CTR)
@@ -224,17 +221,17 @@ class SoledadCryptoAESTestCase(BaseSoledadTest):
self.assertNotEqual('data', plaintext)
def test_decrypt_with_wrong_key_fails(self):
- key = Random.new().read(32)
+ key = os.urandom(32)
iv, cyphertext = self._soledad._crypto.encrypt_sym(
'data', key,
method=crypto.EncryptionMethods.AES_256_CTR)
self.assertTrue(cyphertext is not None)
self.assertTrue(cyphertext != '')
self.assertTrue(cyphertext != 'data')
- wrongkey = Random.new().read(32) # 256-bits key
+ wrongkey = os.urandom(32) # 256-bits key
# ensure keys are different in case we are extremely lucky
while wrongkey == key:
- wrongkey = Random.new().read(32)
+ wrongkey = os.urandom(32)
plaintext = self._soledad._crypto.decrypt_sym(
cyphertext, wrongkey, iv=iv,
method=crypto.EncryptionMethods.AES_256_CTR)
@@ -245,7 +242,7 @@ class SoledadCryptoXSalsa20TestCase(BaseSoledadTest):
def test_encrypt_decrypt_sym(self):
# generate 256-bit key
- key = Random.new().read(32)
+ key = os.urandom(32)
iv, cyphertext = self._soledad._crypto.encrypt_sym(
'data', key,
method=crypto.EncryptionMethods.XSALSA20)
@@ -258,7 +255,7 @@ class SoledadCryptoXSalsa20TestCase(BaseSoledadTest):
self.assertEqual('data', plaintext)
def test_decrypt_with_wrong_iv_fails(self):
- key = Random.new().read(32)
+ key = os.urandom(32)
iv, cyphertext = self._soledad._crypto.encrypt_sym(
'data', key,
method=crypto.EncryptionMethods.XSALSA20)
@@ -276,17 +273,17 @@ class SoledadCryptoXSalsa20TestCase(BaseSoledadTest):
self.assertNotEqual('data', plaintext)
def test_decrypt_with_wrong_key_fails(self):
- key = Random.new().read(32)
+ key = os.urandom(32)
iv, cyphertext = self._soledad._crypto.encrypt_sym(
'data', key,
method=crypto.EncryptionMethods.XSALSA20)
self.assertTrue(cyphertext is not None)
self.assertTrue(cyphertext != '')
self.assertTrue(cyphertext != 'data')
- wrongkey = Random.new().read(32) # 256-bits key
+ wrongkey = os.urandom(32) # 256-bits key
# ensure keys are different in case we are extremely lucky
while wrongkey == key:
- wrongkey = Random.new().read(32)
+ wrongkey = os.urandom(32)
plaintext = self._soledad._crypto.decrypt_sym(
cyphertext, wrongkey, iv=iv,
method=crypto.EncryptionMethods.XSALSA20)