diff options
author | NavaL <ayoyo@thoughtworks.com> | 2016-06-17 21:37:24 +0200 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2016-06-17 20:14:18 -0400 |
commit | 46486807a3274c89adf4b5764cc62ed87d58ca70 (patch) | |
tree | 75726b9c6f88f0b23783f1cc5cacdae9d408f02a /mail | |
parent | 465c14feff60ee69e5c3f0e1febda9d3f3573a11 (diff) |
[bug] initialize OpenSSL context just once in leap.mail
Do not initialize the openssl context on each call to get mail payload phash.
The openSSL backend should only be initialized once because it is activating the os random engine
which in turn unregister and free current engine first. This is very tricky when operations are running in threads
as it essentially momentarily unregister the openssl crypto callbacks that makes openssl thread safe.
- Resolves: #8180 with the soledad PR #324
Diffstat (limited to 'mail')
-rw-r--r-- | mail/src/leap/mail/walk.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/mail/src/leap/mail/walk.py b/mail/src/leap/mail/walk.py index 17349e6a..c1166014 100644 --- a/mail/src/leap/mail/walk.py +++ b/mail/src/leap/mail/walk.py @@ -24,10 +24,11 @@ from cryptography.hazmat.primitives import hashes from leap.mail.utils import first +crypto_backend = MultiBackend([OpenSSLBackend()]) + def get_hash(s): - backend = MultiBackend([OpenSSLBackend()]) - digest = hashes.Hash(hashes.SHA256(), backend) + digest = hashes.Hash(hashes.SHA256(), crypto_backend) digest.update(s) return digest.finalize().encode("hex").upper() |