diff options
author | drebs <drebs@leap.se> | 2013-05-09 15:56:04 -0300 |
---|---|---|
committer | drebs <drebs@leap.se> | 2013-05-09 15:56:04 -0300 |
commit | 8fae83a20504851845eeda5c089f2c53f8678eae (patch) | |
tree | 9e833cf8dbfb0c2e2db82a5f1083bd0f2284d1ea /src/leap/common/tests | |
parent | c72aa2e8c356d57c272ce91e72417ee231edd57d (diff) |
Add sign/verify to keymanager's openpgp.
Diffstat (limited to 'src/leap/common/tests')
-rw-r--r-- | src/leap/common/tests/test_keymanager.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/leap/common/tests/test_keymanager.py b/src/leap/common/tests/test_keymanager.py index 1d7a382..d3dee40 100644 --- a/src/leap/common/tests/test_keymanager.py +++ b/src/leap/common/tests/test_keymanager.py @@ -169,7 +169,7 @@ class KeyManagerWithSoledadTestCase(BaseLeapTest): class OpenPGPCryptoTestCase(KeyManagerWithSoledadTestCase): - def test_openpgp_gen_key(self): + def _test_openpgp_gen_key(self): pgp = openpgp.OpenPGPScheme(self._soledad) self.assertRaises(KeyNotFound, pgp.get_key, 'user@leap.se') key = pgp.gen_key('user@leap.se') @@ -363,6 +363,34 @@ class KeyManagerKeyManagementTestCase( 'leap@leap.se' ) + def test_verify_with_private_raises(self): + km = self._key_manager() + km._wrapper_map[OpenPGPKey].put_key_raw(PRIVATE_KEY) + data = 'data' + privkey = km.get_key(ADDRESS, OpenPGPKey, private=True) + signed = openpgp.sign(data, privkey) + self.assertRaises( + AssertionError, + openpgp.verify, signed, privkey) + + def test_sign_with_public_raises(self): + km = self._key_manager() + km._wrapper_map[OpenPGPKey].put_key_raw(PUBLIC_KEY) + data = 'data' + pubkey = km.get_key(ADDRESS, OpenPGPKey, private=False) + self.assertRaises( + AssertionError, + openpgp.sign, data, pubkey) + + def test_sign_verify(self): + km = self._key_manager() + km._wrapper_map[OpenPGPKey].put_key_raw(PRIVATE_KEY) + data = 'data' + privkey = km.get_key(ADDRESS, OpenPGPKey, private=True) + signed = openpgp.sign(data, privkey) + pubkey = km.get_key(ADDRESS, OpenPGPKey, private=False) + self.assertTrue(openpgp.verify(signed, pubkey)) + # Key material for testing KEY_FINGERPRINT = "E36E738D69173C13D709E44F2F455E2824D18DDF" |