diff options
author | Ruben Pollan <meskio@sindominio.net> | 2016-02-11 01:20:33 +0100 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2016-02-11 01:20:33 +0100 |
commit | 9e15deaee705fcc5f01f10c63c695595e937d3b1 (patch) | |
tree | b68970db90692a2d27fcf7508cee2bc8db6aab41 | |
parent | 3f9bfdb7a846fa165e222543f02dc8e72fcc891b (diff) |
[feat] Use cryptography instead of pycryptopp to reduce dependencies.
* Resolves: #7889
-rw-r--r-- | mail/changes/next-changelog.rst | 1 | ||||
-rw-r--r-- | mail/pkg/requirements-latest.pip | 2 | ||||
-rw-r--r-- | mail/src/leap/mail/adaptors/soledad.py | 3 | ||||
-rw-r--r-- | mail/src/leap/mail/walk.py | 7 |
4 files changed, 7 insertions, 6 deletions
diff --git a/mail/changes/next-changelog.rst b/mail/changes/next-changelog.rst index 625dcacb..79792460 100644 --- a/mail/changes/next-changelog.rst +++ b/mail/changes/next-changelog.rst @@ -12,6 +12,7 @@ Features ~~~~~~~~ - `#7656 <https://leap.se/code/issues/7656>`_: Emit multi-user aware events. - `#4008 <https://leap.se/code/issues/4008>`_: Add token-based authentication to local IMAP/SMTP services. +- `#7889 <https://leap.se/code/issues/7889>`_: Use cryptography instead of pycryptopp to reduce dependencies. - Use twisted.cred to authenticate IMAP users. - `#1234 <https://leap.se/code/issues/1234>`_: Description of the new feature corresponding with issue #1234. diff --git a/mail/pkg/requirements-latest.pip b/mail/pkg/requirements-latest.pip index f561d4e0..846a319c 100644 --- a/mail/pkg/requirements-latest.pip +++ b/mail/pkg/requirements-latest.pip @@ -1,7 +1,5 @@ --index-url https://pypi.python.org/simple/ -pycryptopp - --allow-external u1db --allow-unverified u1db --allow-external dirspec --allow-unverified dirspec -e 'git+https://github.com/pixelated-project/leap_pycommon.git@develop#egg=leap.common' diff --git a/mail/src/leap/mail/adaptors/soledad.py b/mail/src/leap/mail/adaptors/soledad.py index 7f2b1cf6..f4af020d 100644 --- a/mail/src/leap/mail/adaptors/soledad.py +++ b/mail/src/leap/mail/adaptors/soledad.py @@ -22,7 +22,6 @@ import re from collections import defaultdict from email import message_from_string -from pycryptopp.hash import sha256 from twisted.internet import defer from twisted.python import log from zope.interface import implements @@ -1208,7 +1207,7 @@ def _split_into_parts(raw): def _parse_msg(raw): msg = message_from_string(raw) parts = walk.get_parts(msg) - chash = sha256.SHA256(raw).hexdigest() + chash = walk.get_hash(raw) multi = msg.is_multipart() return msg, parts, chash, multi diff --git a/mail/src/leap/mail/walk.py b/mail/src/leap/mail/walk.py index 7be1bb87..8693bdd2 100644 --- a/mail/src/leap/mail/walk.py +++ b/mail/src/leap/mail/walk.py @@ -17,13 +17,16 @@ """ Utilities for walking along a message tree. """ -from pycryptopp.hash import sha256 +from cryptography.hazmat.backends import default_backend +from cryptography.hazmat.primitives import hashes from leap.mail.utils import first def get_hash(s): - return sha256.SHA256(s).hexdigest() + digest = hashes.Hash(hashes.SHA256(), default_backend()) + digest.update(s) + return digest.finalize().encode("hex").upper() """ |