summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNavaL <ayoyo@thoughtworks.com>2016-06-17 21:37:24 +0200
committerKali Kaneko <kali@leap.se>2016-06-17 20:14:18 -0400
commit5992172f58684ff21bffec9ed9414aaa9b26cd31 (patch)
tree15218d76fb748992cc9a4b2daadede5b709b620d
parent0cef35297c8a38d27f390b27ec3d0be0a84230ad (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
-rw-r--r--src/leap/mail/walk.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/leap/mail/walk.py b/src/leap/mail/walk.py
index 17349e6..c116601 100644
--- a/src/leap/mail/walk.py
+++ b/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()