summaryrefslogtreecommitdiff
path: root/src/leap/common/keymanager/openpgp.py
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-05-16 12:09:27 -0300
committerdrebs <drebs@leap.se>2013-05-16 17:12:45 -0300
commit92ab86bf33b57e40745d4af80e4bc2aa7fc4ac89 (patch)
tree3e206d425bb5baf75d4c4c648d41e213bd0830c4 /src/leap/common/keymanager/openpgp.py
parentd4eaa23280da258eb43baf345b1118a91c6d47fd (diff)
Fix pep8 style.
Diffstat (limited to 'src/leap/common/keymanager/openpgp.py')
-rw-r--r--src/leap/common/keymanager/openpgp.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/leap/common/keymanager/openpgp.py b/src/leap/common/keymanager/openpgp.py
index 0cb1308..d578638 100644
--- a/src/leap/common/keymanager/openpgp.py
+++ b/src/leap/common/keymanager/openpgp.py
@@ -66,7 +66,7 @@ def encrypt_sym(data, passphrase, sign=None):
leap_assert_type(passphrase, str)
if sign is not None:
leap_assert_type(sign, OpenPGPKey)
- leap_assert(sign.private == True)
+ leap_assert(sign.private is True)
def _encrypt_cb(gpg):
result = gpg.encrypt(
@@ -105,7 +105,7 @@ def decrypt_sym(data, passphrase, verify=None):
leap_assert_type(passphrase, str)
if verify is not None:
leap_assert_type(verify, OpenPGPKey)
- leap_assert(verify.private == False)
+ leap_assert(verify.private is False)
def _decrypt_cb(gpg):
result = gpg.decrypt(data, passphrase=passphrase)
@@ -145,7 +145,7 @@ def encrypt_asym(data, pubkey, sign=None):
leap_assert(pubkey.private is False, 'Key is not public.')
if sign is not None:
leap_assert_type(sign, OpenPGPKey)
- leap_assert(sign.private == True)
+ leap_assert(sign.private is True)
def _encrypt_cb(gpg):
result = gpg.encrypt(
@@ -185,7 +185,7 @@ def decrypt_asym(data, privkey, verify=None):
leap_assert(privkey.private is True, 'Key is not private.')
if verify is not None:
leap_assert_type(verify, OpenPGPKey)
- leap_assert(verify.private == False)
+ leap_assert(verify.private is False)
def _decrypt_cb(gpg):
result = gpg.decrypt(data)
@@ -258,6 +258,7 @@ def is_encrypted_asym(data):
return _safe_call(_is_encrypted_cb)
+
def sign(data, privkey):
"""
Sign C{data} with C{privkey}.
@@ -271,7 +272,7 @@ def sign(data, privkey):
@rtype: str
"""
leap_assert_type(privkey, OpenPGPKey)
- leap_assert(privkey.private == True)
+ leap_assert(privkey.private is True)
def _sign_cb(gpg):
result = gpg.sign(data, keyid=privkey.key_id)
@@ -289,6 +290,7 @@ def sign(data, privkey):
return _safe_call(_sign_cb, [privkey])
+
def verify(data, pubkey):
"""
Verify signed C{data} with C{pubkey}.
@@ -302,7 +304,7 @@ def verify(data, pubkey):
@rtype: str
"""
leap_assert_type(pubkey, OpenPGPKey)
- leap_assert(pubkey.private == False)
+ leap_assert(pubkey.private is False)
def _verify_cb(gpg):
result = gpg.verify(data)
@@ -314,6 +316,7 @@ def verify(data, pubkey):
return _safe_call(_verify_cb, [pubkey])
+
#
# Helper functions
#
@@ -358,8 +361,8 @@ def _build_keyring(keys=[]):
@return: A GPG wrapper with a unitary keyring.
@rtype: gnupg.GPG
"""
- privkeys = filter(lambda key: key.private == True, keys)
- pubkeys = filter(lambda key: key.private == False, keys)
+ privkeys = filter(lambda key: key.private is True, keys)
+ pubkeys = filter(lambda key: key.private is False, keys)
# here we filter out public keys that have a correspondent private key in
# the list because the private key_data by itself is enough to also have
# the public key in the keyring, and we want to count the keys afterwards.