From 5992172f58684ff21bffec9ed9414aaa9b26cd31 Mon Sep 17 00:00:00 2001 From: NavaL Date: Fri, 17 Jun 2016 21:37:24 +0200 Subject: [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 --- src/leap/mail/walk.py | 5 +++-- 1 file 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() -- cgit v1.2.3