Merge pull request #809 from lsfxz/master

Make compatible with more recent pyopenssl
readme-wiki
Chris Ross 2017-11-09 13:55:36 -05:00 committed by GitHub
commit 41bfb6cb07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 26 deletions

View File

@ -52,14 +52,9 @@ for name, ID in ADDITIONAL.items(): ADDITIONAL_IDS[ID] = name
# If a secure random number generator is unavailable, exit with an error.
try:
try:
import ssl
random_function = ssl.RAND_bytes
random_provider = "Python SSL"
except (AttributeError, ImportError):
import OpenSSL
random_function = OpenSSL.rand.bytes
random_provider = "OpenSSL"
import ssl
random_function = ssl.RAND_bytes
random_provider = "Python SSL"
except:
random_function = os.urandom
random_provider = "os.urandom"

View File

@ -55,14 +55,9 @@ for name, ID in ADDITIONAL.items(): ADDITIONAL_IDS[ID] = name
# If a secure random number generator is unavailable, exit with an error.
try:
try:
import ssl
random_function = ssl.RAND_bytes
random_provider = "Python SSL"
except (AttributeError, ImportError):
import OpenSSL
random_function = OpenSSL.rand.bytes
random_provider = "OpenSSL"
import ssl
random_function = ssl.RAND_bytes
random_provider = "Python SSL"
except:
random_function = os.urandom
random_provider = "os.urandom"

View File

@ -22,6 +22,7 @@ Includes:
import base64
import hashlib
import hmac
import os
import string
import M2Crypto
@ -57,11 +58,9 @@ try:
import ssl
random_function = ssl.RAND_bytes
random_provider = "Python SSL"
except (AttributeError, ImportError):
import OpenSSL
random_function = OpenSSL.rand.bytes
random_provider = "OpenSSL"
except:
random_function = os.urandom
random_provider = "os.urandom"
def pad(data):
"""
@ -285,7 +284,7 @@ class DiffieHellman(object):
_rand = int.from_bytes(random_function(_bytes), byteorder='big')
except:
# Python 2
_rand = int(OpenSSL.rand.bytes(_bytes).encode('hex'), 16)
_rand = int(random_function(_bytes).encode('hex'), 16)
return _rand

View File

@ -27,7 +27,7 @@ if lsb_release -d | grep -q "Fedora"; then
pip install flask
pip install macholib
pip install dropbox
pip install 'pyopenssl==17.2.0'
pip install pyopenssl
pip install pyinstaller
pip install zlib_wrapper
pip install netifaces
@ -44,7 +44,7 @@ elif lsb_release -d | grep -q "Kali"; then
pip install flask
pip install macholib
pip install dropbox
pip install 'pyopenssl==17.2.0'
pip install pyopenssl
pip install pyinstaller
pip install zlib_wrapper
pip install netifaces
@ -85,7 +85,7 @@ elif lsb_release -d | grep -q "Ubuntu"; then
pip install pyOpenSSL
pip install macholib
pip install dropbox
pip install 'pyopenssl==17.2.0'
pip install pyopenssl
pip install pyinstaller
pip install zlib_wrapper
pip install netifaces
@ -115,7 +115,7 @@ else
pip install dropbox
pip install cryptography
pip install pyOpenSSL
pip install 'pyopenssl==17.2.0'
pip install pyopenssl
pip install zlib_wrapper
pip install netifaces
pip install M2Crypto