summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
authordrebs <drebs@leap.se>2013-11-04 15:15:46 -0200
committerdrebs <drebs@leap.se>2013-11-04 16:59:16 -0200
commit45f158060a4ed2f95a94d839a869a76a02d5ceab (patch)
treecc27cb61d29a4165255c8ddd04b37ae4fd05d2b9 /src/leap
parent933731e4671c8ed3b7fa16bf1222e06f76eea215 (diff)
Remove key comment on OpenPGP key generation.
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/keymanager/openpgp.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/leap/keymanager/openpgp.py b/src/leap/keymanager/openpgp.py
index 111dfaf..a4dc1b8 100644
--- a/src/leap/keymanager/openpgp.py
+++ b/src/leap/keymanager/openpgp.py
@@ -27,6 +27,7 @@ import re
import shutil
import tempfile
import locale
+from contextlib import closing
from gnupg import GPG
from gnupg.gnupg import GPGUtilities
@@ -47,6 +48,10 @@ from leap.keymanager.keys import (
logger = logging.getLogger(__name__)
+#
+# A temporary GPG keyring wrapped to provide OpenPGP functionality.
+#
+
class TempGPGWrapper(object):
"""
A context manager that wraps a temporary GPG keyring which only contains
@@ -244,7 +249,7 @@ class OpenPGPScheme(EncryptionScheme):
key_length=4096,
name_real=address,
name_email=address,
- name_comment='Generated by LEAP Key Manager.')
+ name_comment='')
logger.info("About to generate keys... This might take SOME time.")
gpg.gen_key(params)
logger.info("Keys for %s have been successfully "
@@ -598,12 +603,10 @@ class OpenPGPScheme(EncryptionScheme):
# gpg.verify_file(), which receives the data as a binary
# stream and the name of a file containing the signature.
sf, sfname = tempfile.mkstemp()
- sfd = os.fdopen(sf, 'w')
- sfd.write(detached_sig)
- sfd.close()
- df = _make_binary_stream(data, gpg._encoding)
- result = gpg.verify_file(df, sig_file=sfname)
- df.close()
+ with os.fdopen(sf, 'w') as sfd:
+ sfd.write(detached_sig)
+ with closing(_make_binary_stream(data, gpg._encoding)) as df:
+ result = gpg.verify_file(df, sig_file=sfname)
gpgpubkey = gpg.list_keys().pop()
valid = result.valid
rfprint = result.fingerprint