From ec2156ec428b0e888f66b227a13b2a34f1bb7572 Mon Sep 17 00:00:00 2001 From: Fedor Brunner Date: Mon, 17 Feb 2014 13:51:45 +0100 Subject: [PATCH] Update entropy gathering for interface changes of pyOpenSSL. Fixes: #7642 --- src/common/crypto.py | 4 ++-- src/common/jingle_xtls.py | 4 ++-- src/gajim.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/common/crypto.py b/src/common/crypto.py index e8ee300a5..70ef6e1e1 100644 --- a/src/common/crypto.py +++ b/src/common/crypto.py @@ -87,7 +87,7 @@ def add_entropy_sources_OpenSSL(): os.environ, os.getcwd(), os.getpid()] for s in sources: - OpenSSL.rand.add(str(s).encode('utf-8'), 0.01) + OpenSSL.rand.add(str(s).encode('utf-8'), 1) # On Windows add the current contents of the screen to the PRNG state. if os.name == 'nt': @@ -105,7 +105,7 @@ def add_entropy_sources_OpenSSL(): # Limit the ammount of read bytes, in case a memory # file was opened OpenSSL.rand.add(str(fp.read(5000)).encode('utf-8'), - 0.01) + 1) except: # Ignore all read and access errors pass diff --git a/src/common/jingle_xtls.py b/src/common/jingle_xtls.py index caf0331b6..864cc5f05 100644 --- a/src/common/jingle_xtls.py +++ b/src/common/jingle_xtls.py @@ -118,7 +118,7 @@ def get_context(fingerprint, verify_cb=None, remote_jid=None): dh_params_name = os.path.join(gajim.MY_CERT_DIR, DH_PARAMS) try: with open(dh_params_name, "r") as dh_params_file: - ctx.load_tmp_dh(dh_params_name) + ctx.load_tmp_dh(str(dh_params_name).encode('utf-8')) except IOError as err: log.warn('Unable to load DH parameter file: %s. You should generate it ' 'by using this command : "openssl dhparam 4096 -out ' @@ -128,7 +128,7 @@ def get_context(fingerprint, verify_cb=None, remote_jid=None): 'other', DEFAULT_DH_PARAMS) try: with open(default_dh_params_name, "r") as default_dh_params_file: - ctx.load_tmp_dh(default_dh_params_name) + ctx.load_tmp_dh(str(default_dh_params_name).encode('utf-8')) except IOError as err: log.error('Unable to load default DH parameter file: %s , %s' % (default_dh_params_name, err)) diff --git a/src/gajim.py b/src/gajim.py index 8f55214b8..f07badff8 100644 --- a/src/gajim.py +++ b/src/gajim.py @@ -320,7 +320,7 @@ try: from common import crypto PYOPENSSL_PRNG_PRESENT = True # Seed from file - OpenSSL.rand.load_file(RNG_SEED) + OpenSSL.rand.load_file(str(RNG_SEED).encode('utf-8')) crypto.add_entropy_sources_OpenSSL() except ImportError: log.info("PyOpenSSL PRNG not available") @@ -473,7 +473,7 @@ del pid_dir def on_exit(): # Save the entropy from OpenSSL PRNG if PYOPENSSL_PRNG_PRESENT: - OpenSSL.rand.write_file(RNG_SEED) + OpenSSL.rand.write_file(str(RNG_SEED).encode('utf-8')) # delete pid file on normal exit if os.path.exists(pid_filename): os.remove(pid_filename)