summaryrefslogtreecommitdiff
path: root/src/leap/common/tests
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-05-29 09:50:38 -0300
committerTomás Touceda <chiiph@leap.se>2013-05-29 09:50:38 -0300
commitcec2baa24f454c9f9168b5faed1a465e9943f591 (patch)
treef5428d3c2a0a02e484a69f24063a11f1d9327dda /src/leap/common/tests
parent205fcd6c6bb8712a115f3dfe738c490f5427e09b (diff)
parent7fc904d797cb3c07f593157df1126b4179fe48d8 (diff)
Merge remote-tracking branch 'drebs/feature/2341-use-indexes-to-store-and-fetch-keys' into develop
Conflicts: src/leap/common/keymanager/keys.py
Diffstat (limited to 'src/leap/common/tests')
-rw-r--r--src/leap/common/tests/test_crypto.py12
-rw-r--r--src/leap/common/tests/test_keymanager.py17
2 files changed, 10 insertions, 19 deletions
diff --git a/src/leap/common/tests/test_crypto.py b/src/leap/common/tests/test_crypto.py
index b704c05..ae7dc71 100644
--- a/src/leap/common/tests/test_crypto.py
+++ b/src/leap/common/tests/test_crypto.py
@@ -21,6 +21,10 @@ Tests for the crypto submodule.
"""
+import os
+import binascii
+
+
from leap.common.testing.basetest import BaseLeapTest
from leap.common import crypto
from Crypto import Random
@@ -56,9 +60,13 @@ class CryptoTestCase(BaseLeapTest):
self.assertTrue(cyphertext is not None)
self.assertTrue(cyphertext != '')
self.assertTrue(cyphertext != 'data')
- iv += 1
+ # get a different iv by changing the first byte
+ rawiv = binascii.a2b_base64(iv)
+ wrongiv = rawiv
+ while wrongiv == rawiv:
+ wrongiv = os.urandom(1) + rawiv[1:]
plaintext = crypto.decrypt_sym(
- cyphertext, key, iv=iv,
+ cyphertext, key, iv=binascii.b2a_base64(wrongiv),
method=crypto.EncryptionMethods.AES_256_CTR)
self.assertNotEqual('data', plaintext)
diff --git a/src/leap/common/tests/test_keymanager.py b/src/leap/common/tests/test_keymanager.py
index cffa073..73611b6 100644
--- a/src/leap/common/tests/test_keymanager.py
+++ b/src/leap/common/tests/test_keymanager.py
@@ -44,7 +44,6 @@ from leap.common.keymanager.openpgp import OpenPGPKey
from leap.common.keymanager.keys import (
is_address,
build_key_from_dict,
- keymanager_doc_id,
)
from leap.common.keymanager import errors
@@ -120,22 +119,6 @@ class KeyManagerUtilTestCase(BaseLeapTest):
kdict['validation'], key.validation,
'Wrong data in key.')
- def test_keymanager_doc_id(self):
- doc_id1 = keymanager_doc_id(
- OpenPGPKey, ADDRESS, private=False)
- doc_id2 = keymanager_doc_id(
- OpenPGPKey, ADDRESS, private=True)
- doc_id3 = keymanager_doc_id(
- OpenPGPKey, 'user@leap.se', private=False)
- doc_id4 = keymanager_doc_id(
- OpenPGPKey, 'user@leap.se', private=True)
- self.assertFalse(doc_id1 == doc_id2, 'Doc ids are equal!')
- self.assertFalse(doc_id1 == doc_id3, 'Doc ids are equal!')
- self.assertFalse(doc_id1 == doc_id4, 'Doc ids are equal!')
- self.assertFalse(doc_id2 == doc_id3, 'Doc ids are equal!')
- self.assertFalse(doc_id2 == doc_id4, 'Doc ids are equal!')
- self.assertFalse(doc_id3 == doc_id4, 'Doc ids are equal!')
-
class KeyManagerWithSoledadTestCase(BaseLeapTest):