summaryrefslogtreecommitdiff
path: root/src/leap/keymanager/openpgp.py
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2014-04-04 16:24:11 -0300
committerTomás Touceda <chiiph@leap.se>2014-04-04 16:24:11 -0300
commitb25f3ae5ecaa70abaf80edc62931b5980c14e637 (patch)
tree290162fc323925f043ea037a09a9b347b97b954f /src/leap/keymanager/openpgp.py
parent77e4e1d037a8eb796553b3f28f31e4f4d1ccee84 (diff)
parentee170c64aacdc59043b0e620fc476c1e60a0a1e0 (diff)
Merge branch 'release-0.3.8'0.3.8
Diffstat (limited to 'src/leap/keymanager/openpgp.py')
-rw-r--r--src/leap/keymanager/openpgp.py21
1 files changed, 3 insertions, 18 deletions
diff --git a/src/leap/keymanager/openpgp.py b/src/leap/keymanager/openpgp.py
index 856b21e4..950d022c 100644
--- a/src/leap/keymanager/openpgp.py
+++ b/src/leap/keymanager/openpgp.py
@@ -14,19 +14,13 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-
"""
Infrastructure for using OpenPGP keys in Key Manager.
"""
-
-
-import locale
import logging
import os
import re
import shutil
-import sys
import tempfile
from contextlib import closing
@@ -298,7 +292,7 @@ class OpenPGPScheme(EncryptionScheme):
@raise KeyNotFound: If the key was not found on local storage.
"""
# Remove the identity suffix after the '+' until the '@'
- # e.g.: test_user+something@provider.com becomes test_user@probider.com
+ # e.g.: test_user+something@provider.com becomes test_user@provider.com
# since the key belongs to the identity without the '+' suffix.
address = re.sub(r'\+.*\@', '@', address)
@@ -526,7 +520,7 @@ class OpenPGPScheme(EncryptionScheme):
return result.data
except errors.GPGError as e:
logger.error('Failed to decrypt: %s.' % str(e))
- raise error.EncryptError()
+ raise errors.EncryptError()
def decrypt(self, data, privkey, passphrase=None, verify=None):
"""
@@ -568,20 +562,11 @@ class OpenPGPScheme(EncryptionScheme):
'Failed to verify signature with key %s: %s' %
(verify.key_id, result.stderr))
- # XXX: this is the encoding used by gpg module
- # https://github.com/isislovecruft/python-gnupg/\
- # blob/master/gnupg/_meta.py#L121
- encoding = locale.getpreferredencoding()
- if encoding is None:
- encoding = sys.stdin.encoding
- if encoding is None:
- encoding = 'utf-8'
- return result.data.decode(encoding, 'replace')
+ return result.data
except errors.GPGError as e:
logger.error('Failed to decrypt: %s.' % str(e))
raise errors.DecryptError(str(e))
-
def is_encrypted(self, data):
"""
Return whether C{data} was asymmetrically encrypted using OpenPGP.