Skip to content

Commit

Permalink
Test that encryption is static.
Browse files Browse the repository at this point in the history
* The curve used for encryption is derived from the key provided.
  • Loading branch information
Renelvon committed Sep 16, 2014
1 parent b0c000b commit 90bd914
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/test_ec.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ def setUpClass(cls):
cls.alice = ec.ECC(curve=cls.ecc_curve)
cls.bob = ec.ECC(curve=cls.ecc_curve)
cls.bob_pubkey = cls.bob.get_pubkey()
cls.bob_privkey = cls.bob.get_privkey()
cls.alice_pubkey = cls.alice.get_pubkey()
cls.data = "YELLOW SUBMARINE"

def test_asymmetric_enc_dec(self):
plaintext = "Hello Bob"
Expand All @@ -78,6 +80,22 @@ def test_curve_mismatch(self):
with self.assertRaises(Exception):
agent2.get_ecdh_key(agent1.get_pubkey())

def test_encrypt_is_static(self):
obj_agent1 = ec.ECC(curve=self.ecc_curve)
obj_agent2 = ec.ECC(curve='sect283k1')
cls_agent3 = ec.ECC

encd1 = obj_agent1.encrypt(self.data, self.bob_pubkey)
encd2 = obj_agent2.encrypt(self.data, self.bob_pubkey)
encd3 = cls_agent3.encrypt(self.data, self.bob_pubkey)

dcd1 = self.bob.decrypt(encd1)
dcd2 = self.bob.decrypt(encd2)
dcd3 = self.bob.decrypt(encd3)

self.assertEqual(dcd1, dcd2)
self.assertEqual(dcd2, dcd3)


if __name__ == "__main__":
unittest.main()

0 comments on commit 90bd914

Please sign in to comment.