SlideShare a Scribd company logo
1 of 53
Download to read offline
Python Hashlib &
A True Story of One Bug
Dmitry Alimov
$ whoami
Software engineer
Python Software Foundation (PSF) contributing member
Python meetups member & speaker
Co-organized Python meetups/drinkups
Played CTF with SiBears
2
Plan
A True Story of One Bug
3
hashlib
A True Story
of One Bug
Test Framework
Cloud
Telephony
Services
Shared storage
IP Phone
Test Automation Framework
5
Authentication with remote machine "SERVER" for user "user" will be using NTLM v1 authentication (with extended
security)
Now switching over to SMB2 protocol communication
SMB2 dialect negotiation successful
Performing NTLMv2 authentication (on SMB2) with server challenge "b'da16c5c3e38ca2df'"
Performing NTLMv1 authentication (on SMB2) with server challenge "b'da16c5c3e38ca2df'"
Server supports SMB signing
SMB signing deactivated. SMB messages will NOT be signed.
Authentication (on SMB2) failed. Please check username and password.
Traceback (most recent call last):
File "/home/user/proj/smb_module.py", line 43, in <module>
downloader.list_dir()
File "/home/user/proj/
smb_module.py", line 36, in list_dir
all_builds = self._connection.listPath(self.service_name, path)
File "/home/user/proj/venv/lib/python3.9/site-packages/smb/SMBConnection.py", line 201, in listPath
self._listPath(service_name, path, cb, eb, search = search, pattern = pattern, timeout = timeout)
File "/home/user/proj/venv/lib/python3.9/site-packages/smb/base.py", line 601, in _listPath_SMB2
raise NotReadyError('SMB connection not authenticated')
smb.base.NotReadyError: SMB connection not authenticated
Problem
6
Code
import logging
from smb.SMBConnection import SMBConnection
logging.getLogger().setLevel(logging.INFO)
logging.getLogger().addHandler(logging.StreamHandler())
class SMBDownloader:
def __init__(self, host: str, username: str, password: str, service_name: str = 'BIN'):
self.service_name = service_name
self._connection = SMBConnection(
remote_name=host, username=username, password=password, my_name='...')
self._connection.connect(remote_name)
def list_dir(self, path: str = '.'):
all_files = self._connection.listPath(
self.service_name, path)
print([item.filename for item in all_files])
downloader = SMBDownloader(
'server', 'user', 'password')
downloader.list_dir()
7
Analysis
8
Analysis
9
Analysis
10
Analysis
11
Analysis
12
Analysis
13
Analysis
14
Analysis
15
Python verbose mode
$ python -v ...
$ PYTHONVERBOSE=1 python ...
Source: [1]
16
Run in verbose mode, to analyse imported modules
$ python -v smb_module.py # on host where OK
...
import 'nmb.utils' # <_frozen_importlib_external.SourceFileLoader object at 0x7f3199c4b370>
import 'nmb.base' # <_frozen_importlib_external.SourceFileLoader object at 0x7f3199c42ca0>
# /usr/local/lib/python3.9/site-packages/smb/__pycache__/ntlm.cpython-39.pyc matches
/usr/local/lib/python3.9/site-packages/smb/ntlm.py
# code object from '/usr/local/lib/python3.9/site-packages/smb/__pycache__/ntlm.cpython-39.pyc'
# /usr/local/lib/python3.9/site-packages/smb/utils/__pycache__/rc4.cpython-39.pyc matches
/usr/local/lib/python3.9/site-packages/smb/utils/rc4.py
# code object from '/usr/local/lib/python3.9/site-packages/smb/utils/__pycache__/rc4.cpython-39.pyc'
import 'smb.utils.rc4' # <_frozen_importlib_external.SourceFileLoader object at 0x7f319bdd2a00>
# /usr/local/lib/python3.9/site-packages/smb/utils/__pycache__/pyDes.cpython-39.pyc matches
/usr/local/lib/python3.9/site-packages/smb/utils/pyDes.py
# code object from '/usr/local/lib/python3.9/site-packages/smb/utils/__pycache__/pyDes.cpython-39.pyc'
import 'smb.utils.pyDes' # <_frozen_importlib_external.SourceFileLoader object at 0x7f319bdd2970>
import 'smb.ntlm' # <_frozen_importlib_external.SourceFileLoader object at 0x7f3199c4b220>
...
17
Run in verbose mode, to analyse imported modules
$ python -v smb_module.py # on host where FAILS
...
import 'nmb.utils' # <_frozen_importlib_external.SourceFileLoader object at 0x7f3b9ea1a700>
import 'nmb.base' # <_frozen_importlib_external.SourceFileLoader object at 0x7f3b9ea0ca90>
# /home/user/proj/venv/lib/python3.9/site-packages/smb/__pycache__/ntlm.cpython-39.pyc matches
/home/user/proj/venv/lib/python3.9/site-packages/smb/ntlm.py
# code object from '/home/user/proj/venv/lib/python3.9/site-packages/smb/__pycache__/ntlm.cpython-39.pyc'
# /home/user/proj/venv/lib/python3.9/site-packages/smb/utils/__pycache__/rc4.cpython-39.pyc matches
/home/user/proj/venv/lib/python3.9/site-packages/smb/utils/rc4.py
# code object from '/home/user/proj/venv/lib/python3.9/site-packages/smb/utils/__pycache__/rc4.cpython-39.pyc'
import 'smb.utils.rc4' # <_frozen_importlib_external.SourceFileLoader object at 0x7f3b9ea03640>
# /home/user/proj/venv/lib/python3.9/site-packages/smb/utils/__pycache__/pyDes.cpython-39.pyc matches
/home/user/proj/venv/lib/python3.9/site-packages/smb/utils/pyDes.py
# code object from '/home/user/proj/venv/lib/python3.9/site-packages/smb/utils/__pycache__/pyDes.cpython-39.pyc'
import 'smb.utils.pyDes' # <_frozen_importlib_external.SourceFileLoader object at 0x7f3b9ea03580>
# /home/user/proj/venv/lib/python3.9/site-packages/smb/utils/__pycache__/md4.cpython-39.pyc matches
/home/user/proj/venv/lib/python3.9/site-packages/smb/utils/md4.py
# code object from '/home/user/proj/venv/lib/python3.9/site-packages/smb/utils/__pycache__/md4.cpython-39.pyc'
# /home/user/proj/venv/lib/python3.9/site-packages/smb/utils/__pycache__/U32.cpython-39.pyc matches
/home/user/proj/venv/lib/python3.9/site-packages/smb/utils/U32.py
# code object from '/home/user/proj/venv/lib/python3.9/site-packages/smb/utils/__pycache__/U32.cpython-39.pyc'
import 'smb.utils.U32' # <_frozen_importlib_external.SourceFileLoader object at 0x7f3b9e572a00>
import 'smb.utils.md4' # <_frozen_importlib_external.SourceFileLoader object at 0x7f3b9e572550>
import 'smb.ntlm' # <_frozen_importlib_external.SourceFileLoader object at 0x7f3b9ea03e80>
...
18
Where is it imported from?
Source: [2]
19
try:
import hashlib
hashlib.new('md4')
def MD4(): return hashlib.new('md4')
except ( ImportError, ValueError ):
from .utils.md4 import MD4
Try to use hash type – OK
(venv) $ python # on host where OK
Python 3.9.15 (main, Oct 12 2022, 19:14:37)
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> hashlib.new( 'md4')
<md4 _hashlib.HASH object @ 0x7ffbedfbbc70>
20
Try to use hash type – FAILS
21
(venv) $ python # on host where FAILS
Python 3.9.15 (main, Oct 12 2022, 19:14:37)
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> hashlib.new( 'md4')
Traceback (most recent call last):
File "/usr/lib/python3.9/hashlib.py", line 160, in __hash_new
return _hashlib.new(name, data, **kwargs)
ValueError: [digital envelope routines] unsupported
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.9/hashlib.py", line 166, in __hash_new
return __get_builtin_constructor(name)(data)
File "/usr/lib/python3.9/hashlib.py", line 123, in __get_builtin_constructor
raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type md4
pysmb-provided MD4 implementation for Python3 is broken
https:/
/github.com/miketeo/pysmb/issues/196
pysmb 1.2.8 fixes this issue
Bug
22
Source: [3]
Fix
23
b'x01x00x02x00x03x00'
b'x01x02x03'
Fix embedded MD4 algorithm
https:/
/github.com/miketeo/pysmb/pull/198
Source: [4]
1. Update pysmb in project to 1.2.8
2. Enable legacy providers in openssl config
Solutions
24
$ openssl version -d
OPENSSLDIR: "/usr/lib/ssl"
Update /usr/lib/ssl/openssl.cnf
...
openssl_conf = openssl_init
[openssl_init]
providers = provider_sect
[provider_sect]
default = default_sect
legacy = legacy_sect
[default_sect]
activate = 1
[legacy_sect]
activate = 1
...
How to enable legacy providers in config
Source: [5]
25
Try to use hash type after enable legacy providers
(venv) $ python # on host where FAILED
Python 3.9.15 (main, Oct 12 2022, 19:14:37)
[GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hashlib
>>> hashlib.new( 'md4')
<md4 _hashlib.HASH object @ 0x7fe885fade10>
26
Authentication with remote machine "SERVER" for user "user" will be using NTLM v1 authentication (with extended
security)
Now switching over to SMB2 protocol communication
SMB2 dialect negotiation successful
Performing NTLMv2 authentication (on SMB2) with server challenge "b'137550e8bf56b78d'"
Performing NTLMv1 authentication (on SMB2) with server challenge "b'137550e8bf56b78d'"
Server supports SMB signing
SMB signing deactivated. SMB messages will NOT be signed.
Authentication (on SMB2) successful!
...
Problem solved
27
How hashlib is related to OpenSSL
28
hashlib.py _hashlib.so libcrypto.so
python3.9
$ objdump -T python3.9 | egrep "blake|md4|md5|sha1|sha3|sha256|sha512"
003a90df g DF .text 0000008c Base PyInit__sha512
003a5998 g DF .text 00000058 Base PyInit__sha1
003a5e9d g DF .text 000001da Base PyInit__sha3
00304aca g DF .text 00000058 Base PyInit__md5
00388b47 g DF .text 000002fb Base PyInit__blake2
003a5b7f g DF .text 0000008c Base PyInit__sha256
$ objdump -T libcrypto.so
...
... g DF .text ...0c OPENSSL_1_1_1 EVP_sha3_384
... g DF .text ...0c OPENSSL_1_1_0 EVP_md4
... g DF .text ...0c OPENSSL_1_1_0 EVP_md5
... g DF .text ...0c OPENSSL_1_1_0
EVP_blake2s256
... g DF .text ...0c OPENSSL_1_1_0 EVP_sha1
... g DF .text ...0c OPENSSL_1_1_0 EVP_md5_sha1
...
$ objdump -T _hashlib.cpython-39-x86_64-linux-gnu.so
...
00000000 DF *UND* 00000000 OPENSSL_1_1_0
EVP_blake2s256
00000000 DF *UND* 00000000 OPENSSL_1_1_0 EVP_sha384
00000000 DF *UND* 00000000 OPENSSL_1_1_1 EVP_sha3_512
00000000 DF *UND* 00000000 OPENSSL_1_1_1 EVP_shake128
00000000 DF *UND* 00000000 OPENSSL_1_1_0 EVP_md5
00000000 DF *UND* 00000000 OPENSSL_1_1_0 EVP_sha1
...
OpenSSL consists of two libraries: libcrypto and libssl
Changes between 1.1.1 and 3.0.0 [7 sep 2021]
...
* The implementation of the EVP digests MD2, MD4, MDC2, WHIRLPOOL and
RIPEMD-160 have been moved to the legacy provider.
…
* The low-level MD2, MD4, MD5, MDC2, RIPEMD160 and Whirlpool digest
functions have been deprecated.
…
MD4 is deprecated and disabled by default in OpenSSL 3.0.0
29
Source: [6]
>>> import hashlib
>>> import ssl
>>> print(ssl.OPENSSL_VERSION)
>>> print(hashlib.algorithms_available)
>>> hashlib.new( 'md4')
OpenSSL 1.1.1g 21 Apr 2020
{'sha3_224', 'sha512', 'shake_128' , 'md4', 'sha3_256', 'sha3_384', 'shake_256' , 'ripemd160',
'sha384', 'blake2b', 'sha1', 'whirlpool', 'sha3_512', 'md5', 'sha224', 'sha512_224' , 'md5-sha1',
'blake2s', 'sha256', 'sha512_256' , 'sm3'}
OpenSSL 3.0.2 15 Mar 2022
{'sha3_224', 'sm3', 'sha3_384', 'sha512_256' , 'sha224', 'blake2b', 'sha512', 'sha3_512', 'sha384',
'blake2s', 'sha1', 'shake_128' , 'md5', 'sha256', 'sha512_224' , 'md5-sha1', 'sha3_256',
'shake_256' }
...
ValueError: unsupported hash type md4
Hashlib and OpenSSL version
30
Hashlib
and OpenSSL
version
algorithms_guaranteed
OpenSSL 1.1.1
algorithms_available
OpenSSL 3.0.2
algorithms_available
BLAKE2B BLAKE2B BLAKE2B
BLAKE2S BLAKE2S BLAKE2S
MD4
MD5 MD5 MD5
MD5-SHA1 MD5-SHA1
RIPEMD160
SHA1 SHA1 SHA1
SHA224 SHA224 SHA224
SHA256 SHA256 SHA256
SHA384 SHA384 SHA384
SHA3_224 SHA3_224 SHA3_224
SHA3_256 SHA3_256 SHA3_256
SHA3_384 SHA3_384 SHA3_384
SHA3_512 SHA3_512 SHA3_512
SHA512 SHA512 SHA512
SHA512_224 SHA512_224
SHA512_256 SHA512_256
SHAKE_128 SHAKE_128 SHAKE_128
SHAKE_256 SHAKE_256 SHAKE_256
SM3 SM3
WHIRLPOOL
31
hashlib
Source: [7]
33
Source: [7]
hashlib.py – algorithms constants
34
Source: [8]
hashlib.py – algorithms_guaranteed
35
# This tuple and __get_builtin_constructor() must be modified if a new
# always available algorithm is added.
__always_supported = ( 'md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512',
'blake2b', 'blake2s',
'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512',
'shake_128' , 'shake_256' )
algorithms_guaranteed = set(__always_supported)
algorithms_available = set(__always_supported)
...
try:
import _hashlib
new = __hash_new
__get_hash = __get_openssl_constructor
algorithms_available = algorithms_available.union(
_hashlib.openssl_md_meth_names)
except ImportError :
new = __py_new
__get_hash = __get_builtin_constructor
hashlib.py – algorithms_available
Source: [9]
36
hashlib.py _hashlib.so
$ objdump -T _hashlib.cpython-39-x86_64-linux-gnu.so
...
00000000 DF *UND* 00000000 OPENSSL_1_1_0
EVP_blake2s256
00000000 DF *UND* 00000000 OPENSSL_1_1_0 EVP_sha384
00000000 DF *UND* 00000000 OPENSSL_1_1_1 EVP_sha3_512
00000000 DF *UND* 00000000 OPENSSL_1_1_1 EVP_shake128
00000000 DF *UND* 00000000 OPENSSL_1_1_0 EVP_md5
00000000 DF *UND* 00000000 OPENSSL_1_1_0 EVP_sha1
...
libcrypto.so
/* Ask OpenSSL for a list of supported ciphers, filling in a Python set. */
static int
hashlib_md_meth_names(PyObject *module)
{
...
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
// get algorithms from all activated providers in default context
EVP_MD_do_all_provided(NULL, &_openssl_hash_name_mapper, &state);
#else
EVP_MD_do_all(&_openssl_hash_name_mapper, &state);
#endif
...
if (PyModule_AddObject(module, "openssl_md_meth_names", state.set) < 0) {
Py_DECREF(state.set);
return -1;
}
return 0;
}
_hashopenssl.c
Source: [10]
OpenSSL API functions
>= OpenSSL 3.0.0
37
>>> import hashlib
>>> import _hashlib
>>> import ssl
>>> _hashlib.openssl_md_meth_names
frozenset({'sha3_512', 'sha3_384', 'md5', 'ripemd160' , 'sha512', 'sha256', 'whirlpool' , 'blake2b',
'sha3_224', 'blake2s', 'sha1', 'shake_128' , 'shake_256' , 'sha3_256', 'sm3', 'sha224', 'md4',
'sha512_256' , 'sha512_224' , 'sha384', 'md5-sha1'})
>>> print(ssl.OPENSSL_VERSION)
OpenSSL 1.1.1g 21 Apr 2020
>>> print(hashlib.algorithms_available)
{'sha3_512', 'sha3_384', 'md5', 'ripemd160' , 'sha512', 'sha256', 'whirlpool' , 'blake2b',
'sha3_224', 'sha1', 'blake2s', 'shake_128' , 'shake_256' , 'sha3_256', 'sm3', 'sha224', 'md4',
'sha512_256' , 'sha512_224' , 'sha384', 'md5-sha1'}
>>> hashlib.algorithms_available ^ hashlib.algorithms_guaranteed
{'whirlpool' , 'md4', 'sha512_256' , 'sha512_224' , 'ripemd160' , 'sm3', 'md5-sha1'}
hashlib.py – algorithms available
38
hashlib.py
and OpenSSL*
algorithms
available
39
algorithms_guaranteed
OpenSSL 1.1.1
algorithms_available
BLAKE2B BLAKE2B
BLAKE2S BLAKE2S
MD4
MD5 MD5
MD5-SHA1
RIPEMD160
SHA1 SHA1
SHA224 SHA224
SHA256 SHA256
SHA384 SHA384
SHA3_224 SHA3_224
SHA3_256 SHA3_256
SHA3_384 SHA3_384
SHA3_512 SHA3_512
SHA512 SHA512
SHA512_224
SHA512_256
SHAKE_128 SHAKE_128
SHAKE_256 SHAKE_256
SM3
WHIRLPOOL
* OpenSSL 1.1.1
Sources: [7], [11]
hashlib.py – new
40
allows using insecure hashes
in OpenSSL FIPS mode
try:
import _hashlib
new = __hash_new
__get_hash = __get_openssl_constructor
algorithms_available = algorithms_available.union(
_hashlib.openssl_md_meth_names)
except ImportError :
new = __py_new
__get_hash = __get_builtin_constructor
hashlib.py – new
Source: [12]
41
__get_builtin_constructor
def __hash_new(name, data= b'', **kwargs):
"""new(name, data=b'') - Return a new hashing object using the named algorithm;
optionally initialized with data (which must be a bytes-like object).
"""
if name in __block_openssl_constructor:
# Prefer our builtin blake2 implementation.
return __get_builtin_constructor(name)(data, **kwargs)
try:
return _hashlib.new(name, data, **kwargs)
except ValueError:
# If the _hashlib module (OpenSSL) doesn't support the named
# hash, try using our builtin implementations.
# This allows for SHA224/256 and SHA384/512 support even though
# the OpenSSL library prior to 0.9.8 doesn't provide them.
return __get_builtin_constructor(name)(data)
hashlib.py – __hash_new
Source: [13]
'blake2b', 'blake2s'
42
def __get_builtin_constructor(name):
cache = __builtin_constructor_cache
constructor = cache.get(name)
if constructor is not None:
return constructor
try:
if name in {'SHA1', 'sha1'}:
import _sha1
cache['SHA1'] = cache['sha1'] = _sha1.sha1
elif name in {'MD5', 'md5'}:
import _md5
cache['MD5'] = cache['md5'] = _md5.md5
...
elif name in {'blake2b', 'blake2s'}:
import _blake2
cache['blake2b'] = _blake2.blake2b
cache['blake2s'] = _blake2.blake2s
...
except ImportError:
pass # no extension module, this hash is unsupported.
constructor = cache.get(name)
if constructor is not None:
return constructor
raise ValueError('unsupported hash type ' + name)
hashlib.py – __get_builtin_constructor
Source: [14]
43
hashlib.py
python3.9
$ objdump -T python3.9 | egrep "blake|md4|md5|sha1|sha3|sha256|sha512"
003a90df g DF .text 0000008c Base PyInit__sha512
003a5998 g DF .text 00000058 Base PyInit__sha1
003a5e9d g DF .text 000001da Base PyInit__sha3
00304aca g DF .text 00000058 Base PyInit__md5
00388b47 g DF .text 000002fb Base PyInit__blake2
003a5b7f g DF .text 0000008c Base PyInit__sha256
try:
import _hashlib
new = __hash_new
__get_hash = __get_openssl_constructor
algorithms_available = algorithms_available.union(
_hashlib.openssl_md_meth_names)
except ImportError :
new = __py_new
__get_hash = __get_builtin_constructor
hashlib.py – __get_hash
Source: [15]
44
to prepare named constructors
def __get_openssl_constructor (name):
if name in __block_openssl_constructor:
# Prefer our builtin blake2 implementation.
return __get_builtin_constructor(name)
try:
# MD5, SHA1, and SHA2 are in all supported OpenSSL versions
# SHA3/shake are available in OpenSSL 1.1.1+
f = getattr(_hashlib, 'openssl_' + name)
# Allow the C module to raise ValueError. The function will be
# defined but the hash not actually available. Don't fall back to
# builtin if the current security policy blocks a digest, bpo#40695.
f(usedforsecurity =False)
# Use the C function directly (very fast)
return f
except (AttributeError , ValueError):
return __get_builtin_constructor(name)
hashlib.py – __get_openssl_constructor
Source: [16]
'blake2b', 'blake2s'
45
for __func_name in __always_supported:
# try them all, some may not work due to the OpenSSL
# version not supporting that algorithm.
try:
globals()[__func_name] = __get_hash(__func_name)
except ValueError:
import logging
logging.exception( 'code for hash %s was not found.' , __func_name)
hashlib.py – prepare all named constructors for algorithms_guaranteed
>>> hashlib. __dict__
{..., 'md5': <built-in function openssl_md5>, 'sha1': <built-in function openssl_sha1>,
'sha224': <built-in function openssl_sha224>, 'sha256': <built-in function openssl_sha256>,
'sha384': <built-in function openssl_sha384>, 'sha512': <built-in function openssl_sha512>,
'blake2b': <class '_blake2.blake2b'>, 'blake2s': <class '_blake2.blake2s'>, 'sha3_224': <built-in
function openssl_sha3_224>, 'sha3_256': <built-in function openssl_sha3_256>, 'sha3_384':
<built-in function openssl_sha3_384>, 'sha3_512': <built-in function openssl_sha3_512>,
'shake_128' : <built-in function openssl_shake_128>, 'shake_256' : <built-in function
openssl_shake_256>}
Source: [17]
__get_openssl_constructor
or
__get_builtin_constructor
46
,,
What else?
hashlib.py – key derivation
Source: [7]
48
hashlib.py – new feature in Python 3.11
Source: [7]
49
Sources: [18], [19]
PEP 644 – Require OpenSSL 1.1.1 or newer
Version 3.0 will be supported until 2026-09-07 (LTS).
Version 1.1.1 will be supported until 2023-09-11 (LTS).
Version 1.0.2 is no longer supported. Extended support for 1.0.2 to gain access to security fixes
for that version is available.
Versions 1.1.0, 1.0.1, 1.0.0 and 0.9.8 are no longer supported.
50
OpenSSL 1.1.1 -> TLS 1.3 version with faster handshake and more secure.
OpenSSL 1.1.0c+ -> Fully fork and thread safe.
OpenSSL 1.1.0+ ships with SHA-3 and SHAKE. Python could rely on OpenSSL’s libcrypto.
Benefits:
Summary
51
Python has a set of guaranteed hash algorithms.
Some extra algorithms Python loads from OpenSSL’s libcrypto.
The available OpenSSL algorithms may differ depending on the versions.
Remember about “python -v” verbose mode for analysis.
References
52
1. https:/
/docs.python.org/3/using/cmdline.html
2. https:/
/github.com/miketeo/pysmb/blob/pysmb-1.2.6/python3/smb/ntlm.py#L6-L12
3. https:/
/github.com/miketeo/pysmb/issues/196/
4. https:/
/github.com/miketeo/pysmb/pull/198/files/
5. https:/
/wiki.openssl.org/index.php/OpenSSL_3.0
6. https:/
/www.openssl.org/news/changelog.txt
7. https:/
/docs.python.org/3/library/hashlib.html
8. https:/
/github.com/python/cpython/blob/v3.9.15/Lib/hashlib.py#L56-L65
9. https:/
/github.com/python/cpython/blob/v3.9.15/Lib/hashlib.py#L169-L178
10. https:/
/github.com/python/cpython/blob/v3.9.15/Modules/_hashopenssl.c#L1891-L1921
11. https:/
/peps.python.org/pep-0452
12. https:/
/github.com/python/cpython/blob/v3.9.15/Lib/hashlib.py#L169-L178
13. https:/
/github.com/python/cpython/blob/v3.9.15/Lib/hashlib.py#L152-L166
14. https:/
/github.com/python/cpython/blob/v3.9.15/Lib/hashlib.py#L82-L123
15. https:/
/github.com/python/cpython/blob/v3.9.15/Lib/hashlib.py#L169-L178
16. https:/
/github.com/python/cpython/blob/v3.9.15/Lib/hashlib.py#L126-L141
17. https:/
/github.com/python/cpython/blob/v3.9.15/Lib/hashlib.py#L250-L257
18. https:/
/peps.python.org/pep-0644
19. https:/
/www.openssl.org/policies/releasestrat.html
Thank you! Questions?

More Related Content

Similar to Python Hashlib & A True Story of One Bug

Openstack Third-Party CI and the review of a few Openstack Infrastructure pro...
Openstack Third-Party CI and the review of a few Openstack Infrastructure pro...Openstack Third-Party CI and the review of a few Openstack Infrastructure pro...
Openstack Third-Party CI and the review of a few Openstack Infrastructure pro...Evgeny Antyshev
 
Parallel Processing with IPython
Parallel Processing with IPythonParallel Processing with IPython
Parallel Processing with IPythonEnthought, Inc.
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newYiwei Ma
 
Software Quality Assurance Tooling 2023
Software Quality Assurance Tooling 2023Software Quality Assurance Tooling 2023
Software Quality Assurance Tooling 2023Henry Schreiner
 
Integration of neutron, nova and designate how to use it and how to configur...
Integration of neutron, nova and designate  how to use it and how to configur...Integration of neutron, nova and designate  how to use it and how to configur...
Integration of neutron, nova and designate how to use it and how to configur...Miguel Lavalle
 
6. hands on - open mano demonstration in remote pool of servers
6. hands on - open mano demonstration in remote pool of servers6. hands on - open mano demonstration in remote pool of servers
6. hands on - open mano demonstration in remote pool of serversvideos
 
Linux Security APIs and the Chromium Sandbox
Linux Security APIs and the Chromium SandboxLinux Security APIs and the Chromium Sandbox
Linux Security APIs and the Chromium SandboxPatricia Aas
 
Chromium Sandbox on Linux (NDC Security 2019)
Chromium Sandbox on Linux (NDC Security 2019)Chromium Sandbox on Linux (NDC Security 2019)
Chromium Sandbox on Linux (NDC Security 2019)Patricia Aas
 
Год в Github bugbounty, опыт участия
Год в Github bugbounty, опыт участияГод в Github bugbounty, опыт участия
Год в Github bugbounty, опыт участияdefcon_kz
 
Chromium Sandbox on Linux (BlackHoodie 2018)
Chromium Sandbox on Linux (BlackHoodie 2018)Chromium Sandbox on Linux (BlackHoodie 2018)
Chromium Sandbox on Linux (BlackHoodie 2018)Patricia Aas
 
Hacking Highly Secured Enterprise Environments by Zoltan Balazs
Hacking Highly Secured Enterprise Environments by Zoltan BalazsHacking Highly Secured Enterprise Environments by Zoltan Balazs
Hacking Highly Secured Enterprise Environments by Zoltan BalazsShakacon
 
Advanced System Security and Digital Forensics
Advanced System Security and Digital ForensicsAdvanced System Security and Digital Forensics
Advanced System Security and Digital ForensicsDr. Ramchandra Mangrulkar
 
26.1.7 lab snort and firewall rules
26.1.7 lab   snort and firewall rules26.1.7 lab   snort and firewall rules
26.1.7 lab snort and firewall rulesFreddy Buenaño
 
DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)Soshi Nemoto
 
Denis Zhuchinski Ways of enhancing application security
Denis Zhuchinski Ways of enhancing application securityDenis Zhuchinski Ways of enhancing application security
Denis Zhuchinski Ways of enhancing application securityАліна Шепшелей
 
SE2016 Android Denis Zhuchinski "Ways of enhancing application security"
SE2016 Android Denis Zhuchinski "Ways of enhancing application security"SE2016 Android Denis Zhuchinski "Ways of enhancing application security"
SE2016 Android Denis Zhuchinski "Ways of enhancing application security"Inhacking
 
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, KyivKubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, KyivAleksey Asiutin
 
Formbook - In-depth malware analysis (Botconf 2018)
Formbook - In-depth malware analysis (Botconf 2018)Formbook - In-depth malware analysis (Botconf 2018)
Formbook - In-depth malware analysis (Botconf 2018)Rémi Jullian
 
introduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraformintroduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraformniyof97
 
[OpenStack 하반기 스터디] HA using DVR
[OpenStack 하반기 스터디] HA using DVR[OpenStack 하반기 스터디] HA using DVR
[OpenStack 하반기 스터디] HA using DVROpenStack Korea Community
 

Similar to Python Hashlib & A True Story of One Bug (20)

Openstack Third-Party CI and the review of a few Openstack Infrastructure pro...
Openstack Third-Party CI and the review of a few Openstack Infrastructure pro...Openstack Third-Party CI and the review of a few Openstack Infrastructure pro...
Openstack Third-Party CI and the review of a few Openstack Infrastructure pro...
 
Parallel Processing with IPython
Parallel Processing with IPythonParallel Processing with IPython
Parallel Processing with IPython
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 new
 
Software Quality Assurance Tooling 2023
Software Quality Assurance Tooling 2023Software Quality Assurance Tooling 2023
Software Quality Assurance Tooling 2023
 
Integration of neutron, nova and designate how to use it and how to configur...
Integration of neutron, nova and designate  how to use it and how to configur...Integration of neutron, nova and designate  how to use it and how to configur...
Integration of neutron, nova and designate how to use it and how to configur...
 
6. hands on - open mano demonstration in remote pool of servers
6. hands on - open mano demonstration in remote pool of servers6. hands on - open mano demonstration in remote pool of servers
6. hands on - open mano demonstration in remote pool of servers
 
Linux Security APIs and the Chromium Sandbox
Linux Security APIs and the Chromium SandboxLinux Security APIs and the Chromium Sandbox
Linux Security APIs and the Chromium Sandbox
 
Chromium Sandbox on Linux (NDC Security 2019)
Chromium Sandbox on Linux (NDC Security 2019)Chromium Sandbox on Linux (NDC Security 2019)
Chromium Sandbox on Linux (NDC Security 2019)
 
Год в Github bugbounty, опыт участия
Год в Github bugbounty, опыт участияГод в Github bugbounty, опыт участия
Год в Github bugbounty, опыт участия
 
Chromium Sandbox on Linux (BlackHoodie 2018)
Chromium Sandbox on Linux (BlackHoodie 2018)Chromium Sandbox on Linux (BlackHoodie 2018)
Chromium Sandbox on Linux (BlackHoodie 2018)
 
Hacking Highly Secured Enterprise Environments by Zoltan Balazs
Hacking Highly Secured Enterprise Environments by Zoltan BalazsHacking Highly Secured Enterprise Environments by Zoltan Balazs
Hacking Highly Secured Enterprise Environments by Zoltan Balazs
 
Advanced System Security and Digital Forensics
Advanced System Security and Digital ForensicsAdvanced System Security and Digital Forensics
Advanced System Security and Digital Forensics
 
26.1.7 lab snort and firewall rules
26.1.7 lab   snort and firewall rules26.1.7 lab   snort and firewall rules
26.1.7 lab snort and firewall rules
 
DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)
 
Denis Zhuchinski Ways of enhancing application security
Denis Zhuchinski Ways of enhancing application securityDenis Zhuchinski Ways of enhancing application security
Denis Zhuchinski Ways of enhancing application security
 
SE2016 Android Denis Zhuchinski "Ways of enhancing application security"
SE2016 Android Denis Zhuchinski "Ways of enhancing application security"SE2016 Android Denis Zhuchinski "Ways of enhancing application security"
SE2016 Android Denis Zhuchinski "Ways of enhancing application security"
 
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, KyivKubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
 
Formbook - In-depth malware analysis (Botconf 2018)
Formbook - In-depth malware analysis (Botconf 2018)Formbook - In-depth malware analysis (Botconf 2018)
Formbook - In-depth malware analysis (Botconf 2018)
 
introduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraformintroduction-infra-as-a-code using terraform
introduction-infra-as-a-code using terraform
 
[OpenStack 하반기 스터디] HA using DVR
[OpenStack 하반기 스터디] HA using DVR[OpenStack 하반기 스터디] HA using DVR
[OpenStack 하반기 스터디] HA using DVR
 

More from delimitry

JIT compilation for CPython
JIT compilation for CPythonJIT compilation for CPython
JIT compilation for CPythondelimitry
 
Data storage systems
Data storage systemsData storage systems
Data storage systemsdelimitry
 
Fuzzing python modules
Fuzzing python modulesFuzzing python modules
Fuzzing python modulesdelimitry
 
Writing file system in CPython
Writing file system in CPythonWriting file system in CPython
Writing file system in CPythondelimitry
 
CPython logo
CPython logoCPython logo
CPython logodelimitry
 
Contribute to CPython
Contribute to CPythonContribute to CPython
Contribute to CPythondelimitry
 
Buzzword poem generator in Python
Buzzword poem generator in PythonBuzzword poem generator in Python
Buzzword poem generator in Pythondelimitry
 
True stories on the analysis of network activity using Python
True stories on the analysis of network activity using PythonTrue stories on the analysis of network activity using Python
True stories on the analysis of network activity using Pythondelimitry
 
Numbers obfuscation in Python
Numbers obfuscation in PythonNumbers obfuscation in Python
Numbers obfuscation in Pythondelimitry
 
ITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
ITGM #9 - Коварный CodeType, или от segfault'а к работающему кодуITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
ITGM #9 - Коварный CodeType, или от segfault'а к работающему кодуdelimitry
 
Python dictionary : past, present, future
Python dictionary: past, present, futurePython dictionary: past, present, future
Python dictionary : past, present, futuredelimitry
 
Python dict: прошлое, настоящее, будущее
Python dict: прошлое, настоящее, будущееPython dict: прошлое, настоящее, будущее
Python dict: прошлое, настоящее, будущееdelimitry
 
Разработка фреймворка на Python для автоматизации тестирования STB боксов
Разработка фреймворка на Python для автоматизации тестирования STB боксовРазработка фреймворка на Python для автоматизации тестирования STB боксов
Разработка фреймворка на Python для автоматизации тестирования STB боксовdelimitry
 
SchoolCTF 2012 - Tpircsavaj
SchoolCTF 2012 - TpircsavajSchoolCTF 2012 - Tpircsavaj
SchoolCTF 2012 - Tpircsavajdelimitry
 
SchoolCTF 2012 - See Shark
SchoolCTF 2012 - See SharkSchoolCTF 2012 - See Shark
SchoolCTF 2012 - See Sharkdelimitry
 
SchoolCTF 2012 - Rings
SchoolCTF 2012 - RingsSchoolCTF 2012 - Rings
SchoolCTF 2012 - Ringsdelimitry
 
SchoolCTF 2012 - Bin Pix
SchoolCTF 2012 - Bin PixSchoolCTF 2012 - Bin Pix
SchoolCTF 2012 - Bin Pixdelimitry
 
SchoolCTF 2012 - Acid
SchoolCTF 2012 - AcidSchoolCTF 2012 - Acid
SchoolCTF 2012 - Aciddelimitry
 

More from delimitry (19)

JIT compilation for CPython
JIT compilation for CPythonJIT compilation for CPython
JIT compilation for CPython
 
Data storage systems
Data storage systemsData storage systems
Data storage systems
 
Fuzzing python modules
Fuzzing python modulesFuzzing python modules
Fuzzing python modules
 
Writing file system in CPython
Writing file system in CPythonWriting file system in CPython
Writing file system in CPython
 
CPython logo
CPython logoCPython logo
CPython logo
 
Contribute to CPython
Contribute to CPythonContribute to CPython
Contribute to CPython
 
Buzzword poem generator in Python
Buzzword poem generator in PythonBuzzword poem generator in Python
Buzzword poem generator in Python
 
True stories on the analysis of network activity using Python
True stories on the analysis of network activity using PythonTrue stories on the analysis of network activity using Python
True stories on the analysis of network activity using Python
 
Numbers obfuscation in Python
Numbers obfuscation in PythonNumbers obfuscation in Python
Numbers obfuscation in Python
 
ITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
ITGM #9 - Коварный CodeType, или от segfault'а к работающему кодуITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
ITGM #9 - Коварный CodeType, или от segfault'а к работающему коду
 
Python dictionary : past, present, future
Python dictionary: past, present, futurePython dictionary: past, present, future
Python dictionary : past, present, future
 
Python dict: прошлое, настоящее, будущее
Python dict: прошлое, настоящее, будущееPython dict: прошлое, настоящее, будущее
Python dict: прошлое, настоящее, будущее
 
Разработка фреймворка на Python для автоматизации тестирования STB боксов
Разработка фреймворка на Python для автоматизации тестирования STB боксовРазработка фреймворка на Python для автоматизации тестирования STB боксов
Разработка фреймворка на Python для автоматизации тестирования STB боксов
 
SchoolCTF 2012 - Tpircsavaj
SchoolCTF 2012 - TpircsavajSchoolCTF 2012 - Tpircsavaj
SchoolCTF 2012 - Tpircsavaj
 
SchoolCTF 2012 - See Shark
SchoolCTF 2012 - See SharkSchoolCTF 2012 - See Shark
SchoolCTF 2012 - See Shark
 
SchoolCTF 2012 - Rings
SchoolCTF 2012 - RingsSchoolCTF 2012 - Rings
SchoolCTF 2012 - Rings
 
SchoolCTF 2012 - Bin Pix
SchoolCTF 2012 - Bin PixSchoolCTF 2012 - Bin Pix
SchoolCTF 2012 - Bin Pix
 
SchoolCTF 2012 - Acid
SchoolCTF 2012 - AcidSchoolCTF 2012 - Acid
SchoolCTF 2012 - Acid
 
Python GC
Python GCPython GC
Python GC
 

Recently uploaded

data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spaintimesproduction05
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSrknatarajan
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01KreezheaRecto
 

Recently uploaded (20)

Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 

Python Hashlib & A True Story of One Bug

  • 1. Python Hashlib & A True Story of One Bug Dmitry Alimov
  • 2. $ whoami Software engineer Python Software Foundation (PSF) contributing member Python meetups member & speaker Co-organized Python meetups/drinkups Played CTF with SiBears 2
  • 3. Plan A True Story of One Bug 3 hashlib
  • 4. A True Story of One Bug
  • 6. Authentication with remote machine "SERVER" for user "user" will be using NTLM v1 authentication (with extended security) Now switching over to SMB2 protocol communication SMB2 dialect negotiation successful Performing NTLMv2 authentication (on SMB2) with server challenge "b'da16c5c3e38ca2df'" Performing NTLMv1 authentication (on SMB2) with server challenge "b'da16c5c3e38ca2df'" Server supports SMB signing SMB signing deactivated. SMB messages will NOT be signed. Authentication (on SMB2) failed. Please check username and password. Traceback (most recent call last): File "/home/user/proj/smb_module.py", line 43, in <module> downloader.list_dir() File "/home/user/proj/ smb_module.py", line 36, in list_dir all_builds = self._connection.listPath(self.service_name, path) File "/home/user/proj/venv/lib/python3.9/site-packages/smb/SMBConnection.py", line 201, in listPath self._listPath(service_name, path, cb, eb, search = search, pattern = pattern, timeout = timeout) File "/home/user/proj/venv/lib/python3.9/site-packages/smb/base.py", line 601, in _listPath_SMB2 raise NotReadyError('SMB connection not authenticated') smb.base.NotReadyError: SMB connection not authenticated Problem 6
  • 7. Code import logging from smb.SMBConnection import SMBConnection logging.getLogger().setLevel(logging.INFO) logging.getLogger().addHandler(logging.StreamHandler()) class SMBDownloader: def __init__(self, host: str, username: str, password: str, service_name: str = 'BIN'): self.service_name = service_name self._connection = SMBConnection( remote_name=host, username=username, password=password, my_name='...') self._connection.connect(remote_name) def list_dir(self, path: str = '.'): all_files = self._connection.listPath( self.service_name, path) print([item.filename for item in all_files]) downloader = SMBDownloader( 'server', 'user', 'password') downloader.list_dir() 7
  • 16. Python verbose mode $ python -v ... $ PYTHONVERBOSE=1 python ... Source: [1] 16
  • 17. Run in verbose mode, to analyse imported modules $ python -v smb_module.py # on host where OK ... import 'nmb.utils' # <_frozen_importlib_external.SourceFileLoader object at 0x7f3199c4b370> import 'nmb.base' # <_frozen_importlib_external.SourceFileLoader object at 0x7f3199c42ca0> # /usr/local/lib/python3.9/site-packages/smb/__pycache__/ntlm.cpython-39.pyc matches /usr/local/lib/python3.9/site-packages/smb/ntlm.py # code object from '/usr/local/lib/python3.9/site-packages/smb/__pycache__/ntlm.cpython-39.pyc' # /usr/local/lib/python3.9/site-packages/smb/utils/__pycache__/rc4.cpython-39.pyc matches /usr/local/lib/python3.9/site-packages/smb/utils/rc4.py # code object from '/usr/local/lib/python3.9/site-packages/smb/utils/__pycache__/rc4.cpython-39.pyc' import 'smb.utils.rc4' # <_frozen_importlib_external.SourceFileLoader object at 0x7f319bdd2a00> # /usr/local/lib/python3.9/site-packages/smb/utils/__pycache__/pyDes.cpython-39.pyc matches /usr/local/lib/python3.9/site-packages/smb/utils/pyDes.py # code object from '/usr/local/lib/python3.9/site-packages/smb/utils/__pycache__/pyDes.cpython-39.pyc' import 'smb.utils.pyDes' # <_frozen_importlib_external.SourceFileLoader object at 0x7f319bdd2970> import 'smb.ntlm' # <_frozen_importlib_external.SourceFileLoader object at 0x7f3199c4b220> ... 17
  • 18. Run in verbose mode, to analyse imported modules $ python -v smb_module.py # on host where FAILS ... import 'nmb.utils' # <_frozen_importlib_external.SourceFileLoader object at 0x7f3b9ea1a700> import 'nmb.base' # <_frozen_importlib_external.SourceFileLoader object at 0x7f3b9ea0ca90> # /home/user/proj/venv/lib/python3.9/site-packages/smb/__pycache__/ntlm.cpython-39.pyc matches /home/user/proj/venv/lib/python3.9/site-packages/smb/ntlm.py # code object from '/home/user/proj/venv/lib/python3.9/site-packages/smb/__pycache__/ntlm.cpython-39.pyc' # /home/user/proj/venv/lib/python3.9/site-packages/smb/utils/__pycache__/rc4.cpython-39.pyc matches /home/user/proj/venv/lib/python3.9/site-packages/smb/utils/rc4.py # code object from '/home/user/proj/venv/lib/python3.9/site-packages/smb/utils/__pycache__/rc4.cpython-39.pyc' import 'smb.utils.rc4' # <_frozen_importlib_external.SourceFileLoader object at 0x7f3b9ea03640> # /home/user/proj/venv/lib/python3.9/site-packages/smb/utils/__pycache__/pyDes.cpython-39.pyc matches /home/user/proj/venv/lib/python3.9/site-packages/smb/utils/pyDes.py # code object from '/home/user/proj/venv/lib/python3.9/site-packages/smb/utils/__pycache__/pyDes.cpython-39.pyc' import 'smb.utils.pyDes' # <_frozen_importlib_external.SourceFileLoader object at 0x7f3b9ea03580> # /home/user/proj/venv/lib/python3.9/site-packages/smb/utils/__pycache__/md4.cpython-39.pyc matches /home/user/proj/venv/lib/python3.9/site-packages/smb/utils/md4.py # code object from '/home/user/proj/venv/lib/python3.9/site-packages/smb/utils/__pycache__/md4.cpython-39.pyc' # /home/user/proj/venv/lib/python3.9/site-packages/smb/utils/__pycache__/U32.cpython-39.pyc matches /home/user/proj/venv/lib/python3.9/site-packages/smb/utils/U32.py # code object from '/home/user/proj/venv/lib/python3.9/site-packages/smb/utils/__pycache__/U32.cpython-39.pyc' import 'smb.utils.U32' # <_frozen_importlib_external.SourceFileLoader object at 0x7f3b9e572a00> import 'smb.utils.md4' # <_frozen_importlib_external.SourceFileLoader object at 0x7f3b9e572550> import 'smb.ntlm' # <_frozen_importlib_external.SourceFileLoader object at 0x7f3b9ea03e80> ... 18
  • 19. Where is it imported from? Source: [2] 19 try: import hashlib hashlib.new('md4') def MD4(): return hashlib.new('md4') except ( ImportError, ValueError ): from .utils.md4 import MD4
  • 20. Try to use hash type – OK (venv) $ python # on host where OK Python 3.9.15 (main, Oct 12 2022, 19:14:37) [GCC 11.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import hashlib >>> hashlib.new( 'md4') <md4 _hashlib.HASH object @ 0x7ffbedfbbc70> 20
  • 21. Try to use hash type – FAILS 21 (venv) $ python # on host where FAILS Python 3.9.15 (main, Oct 12 2022, 19:14:37) [GCC 11.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import hashlib >>> hashlib.new( 'md4') Traceback (most recent call last): File "/usr/lib/python3.9/hashlib.py", line 160, in __hash_new return _hashlib.new(name, data, **kwargs) ValueError: [digital envelope routines] unsupported During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.9/hashlib.py", line 166, in __hash_new return __get_builtin_constructor(name)(data) File "/usr/lib/python3.9/hashlib.py", line 123, in __get_builtin_constructor raise ValueError('unsupported hash type ' + name) ValueError: unsupported hash type md4
  • 22. pysmb-provided MD4 implementation for Python3 is broken https:/ /github.com/miketeo/pysmb/issues/196 pysmb 1.2.8 fixes this issue Bug 22 Source: [3]
  • 23. Fix 23 b'x01x00x02x00x03x00' b'x01x02x03' Fix embedded MD4 algorithm https:/ /github.com/miketeo/pysmb/pull/198 Source: [4]
  • 24. 1. Update pysmb in project to 1.2.8 2. Enable legacy providers in openssl config Solutions 24
  • 25. $ openssl version -d OPENSSLDIR: "/usr/lib/ssl" Update /usr/lib/ssl/openssl.cnf ... openssl_conf = openssl_init [openssl_init] providers = provider_sect [provider_sect] default = default_sect legacy = legacy_sect [default_sect] activate = 1 [legacy_sect] activate = 1 ... How to enable legacy providers in config Source: [5] 25
  • 26. Try to use hash type after enable legacy providers (venv) $ python # on host where FAILED Python 3.9.15 (main, Oct 12 2022, 19:14:37) [GCC 11.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import hashlib >>> hashlib.new( 'md4') <md4 _hashlib.HASH object @ 0x7fe885fade10> 26
  • 27. Authentication with remote machine "SERVER" for user "user" will be using NTLM v1 authentication (with extended security) Now switching over to SMB2 protocol communication SMB2 dialect negotiation successful Performing NTLMv2 authentication (on SMB2) with server challenge "b'137550e8bf56b78d'" Performing NTLMv1 authentication (on SMB2) with server challenge "b'137550e8bf56b78d'" Server supports SMB signing SMB signing deactivated. SMB messages will NOT be signed. Authentication (on SMB2) successful! ... Problem solved 27
  • 28. How hashlib is related to OpenSSL 28 hashlib.py _hashlib.so libcrypto.so python3.9 $ objdump -T python3.9 | egrep "blake|md4|md5|sha1|sha3|sha256|sha512" 003a90df g DF .text 0000008c Base PyInit__sha512 003a5998 g DF .text 00000058 Base PyInit__sha1 003a5e9d g DF .text 000001da Base PyInit__sha3 00304aca g DF .text 00000058 Base PyInit__md5 00388b47 g DF .text 000002fb Base PyInit__blake2 003a5b7f g DF .text 0000008c Base PyInit__sha256 $ objdump -T libcrypto.so ... ... g DF .text ...0c OPENSSL_1_1_1 EVP_sha3_384 ... g DF .text ...0c OPENSSL_1_1_0 EVP_md4 ... g DF .text ...0c OPENSSL_1_1_0 EVP_md5 ... g DF .text ...0c OPENSSL_1_1_0 EVP_blake2s256 ... g DF .text ...0c OPENSSL_1_1_0 EVP_sha1 ... g DF .text ...0c OPENSSL_1_1_0 EVP_md5_sha1 ... $ objdump -T _hashlib.cpython-39-x86_64-linux-gnu.so ... 00000000 DF *UND* 00000000 OPENSSL_1_1_0 EVP_blake2s256 00000000 DF *UND* 00000000 OPENSSL_1_1_0 EVP_sha384 00000000 DF *UND* 00000000 OPENSSL_1_1_1 EVP_sha3_512 00000000 DF *UND* 00000000 OPENSSL_1_1_1 EVP_shake128 00000000 DF *UND* 00000000 OPENSSL_1_1_0 EVP_md5 00000000 DF *UND* 00000000 OPENSSL_1_1_0 EVP_sha1 ... OpenSSL consists of two libraries: libcrypto and libssl
  • 29. Changes between 1.1.1 and 3.0.0 [7 sep 2021] ... * The implementation of the EVP digests MD2, MD4, MDC2, WHIRLPOOL and RIPEMD-160 have been moved to the legacy provider. … * The low-level MD2, MD4, MD5, MDC2, RIPEMD160 and Whirlpool digest functions have been deprecated. … MD4 is deprecated and disabled by default in OpenSSL 3.0.0 29 Source: [6]
  • 30. >>> import hashlib >>> import ssl >>> print(ssl.OPENSSL_VERSION) >>> print(hashlib.algorithms_available) >>> hashlib.new( 'md4') OpenSSL 1.1.1g 21 Apr 2020 {'sha3_224', 'sha512', 'shake_128' , 'md4', 'sha3_256', 'sha3_384', 'shake_256' , 'ripemd160', 'sha384', 'blake2b', 'sha1', 'whirlpool', 'sha3_512', 'md5', 'sha224', 'sha512_224' , 'md5-sha1', 'blake2s', 'sha256', 'sha512_256' , 'sm3'} OpenSSL 3.0.2 15 Mar 2022 {'sha3_224', 'sm3', 'sha3_384', 'sha512_256' , 'sha224', 'blake2b', 'sha512', 'sha3_512', 'sha384', 'blake2s', 'sha1', 'shake_128' , 'md5', 'sha256', 'sha512_224' , 'md5-sha1', 'sha3_256', 'shake_256' } ... ValueError: unsupported hash type md4 Hashlib and OpenSSL version 30
  • 31. Hashlib and OpenSSL version algorithms_guaranteed OpenSSL 1.1.1 algorithms_available OpenSSL 3.0.2 algorithms_available BLAKE2B BLAKE2B BLAKE2B BLAKE2S BLAKE2S BLAKE2S MD4 MD5 MD5 MD5 MD5-SHA1 MD5-SHA1 RIPEMD160 SHA1 SHA1 SHA1 SHA224 SHA224 SHA224 SHA256 SHA256 SHA256 SHA384 SHA384 SHA384 SHA3_224 SHA3_224 SHA3_224 SHA3_256 SHA3_256 SHA3_256 SHA3_384 SHA3_384 SHA3_384 SHA3_512 SHA3_512 SHA3_512 SHA512 SHA512 SHA512 SHA512_224 SHA512_224 SHA512_256 SHA512_256 SHAKE_128 SHAKE_128 SHAKE_128 SHAKE_256 SHAKE_256 SHAKE_256 SM3 SM3 WHIRLPOOL 31
  • 34. Source: [7] hashlib.py – algorithms constants 34
  • 35. Source: [8] hashlib.py – algorithms_guaranteed 35 # This tuple and __get_builtin_constructor() must be modified if a new # always available algorithm is added. __always_supported = ( 'md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'blake2b', 'blake2s', 'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512', 'shake_128' , 'shake_256' ) algorithms_guaranteed = set(__always_supported)
  • 36. algorithms_available = set(__always_supported) ... try: import _hashlib new = __hash_new __get_hash = __get_openssl_constructor algorithms_available = algorithms_available.union( _hashlib.openssl_md_meth_names) except ImportError : new = __py_new __get_hash = __get_builtin_constructor hashlib.py – algorithms_available Source: [9] 36 hashlib.py _hashlib.so $ objdump -T _hashlib.cpython-39-x86_64-linux-gnu.so ... 00000000 DF *UND* 00000000 OPENSSL_1_1_0 EVP_blake2s256 00000000 DF *UND* 00000000 OPENSSL_1_1_0 EVP_sha384 00000000 DF *UND* 00000000 OPENSSL_1_1_1 EVP_sha3_512 00000000 DF *UND* 00000000 OPENSSL_1_1_1 EVP_shake128 00000000 DF *UND* 00000000 OPENSSL_1_1_0 EVP_md5 00000000 DF *UND* 00000000 OPENSSL_1_1_0 EVP_sha1 ... libcrypto.so
  • 37. /* Ask OpenSSL for a list of supported ciphers, filling in a Python set. */ static int hashlib_md_meth_names(PyObject *module) { ... #if OPENSSL_VERSION_NUMBER >= 0x30000000L // get algorithms from all activated providers in default context EVP_MD_do_all_provided(NULL, &_openssl_hash_name_mapper, &state); #else EVP_MD_do_all(&_openssl_hash_name_mapper, &state); #endif ... if (PyModule_AddObject(module, "openssl_md_meth_names", state.set) < 0) { Py_DECREF(state.set); return -1; } return 0; } _hashopenssl.c Source: [10] OpenSSL API functions >= OpenSSL 3.0.0 37
  • 38. >>> import hashlib >>> import _hashlib >>> import ssl >>> _hashlib.openssl_md_meth_names frozenset({'sha3_512', 'sha3_384', 'md5', 'ripemd160' , 'sha512', 'sha256', 'whirlpool' , 'blake2b', 'sha3_224', 'blake2s', 'sha1', 'shake_128' , 'shake_256' , 'sha3_256', 'sm3', 'sha224', 'md4', 'sha512_256' , 'sha512_224' , 'sha384', 'md5-sha1'}) >>> print(ssl.OPENSSL_VERSION) OpenSSL 1.1.1g 21 Apr 2020 >>> print(hashlib.algorithms_available) {'sha3_512', 'sha3_384', 'md5', 'ripemd160' , 'sha512', 'sha256', 'whirlpool' , 'blake2b', 'sha3_224', 'sha1', 'blake2s', 'shake_128' , 'shake_256' , 'sha3_256', 'sm3', 'sha224', 'md4', 'sha512_256' , 'sha512_224' , 'sha384', 'md5-sha1'} >>> hashlib.algorithms_available ^ hashlib.algorithms_guaranteed {'whirlpool' , 'md4', 'sha512_256' , 'sha512_224' , 'ripemd160' , 'sm3', 'md5-sha1'} hashlib.py – algorithms available 38
  • 39. hashlib.py and OpenSSL* algorithms available 39 algorithms_guaranteed OpenSSL 1.1.1 algorithms_available BLAKE2B BLAKE2B BLAKE2S BLAKE2S MD4 MD5 MD5 MD5-SHA1 RIPEMD160 SHA1 SHA1 SHA224 SHA224 SHA256 SHA256 SHA384 SHA384 SHA3_224 SHA3_224 SHA3_256 SHA3_256 SHA3_384 SHA3_384 SHA3_512 SHA3_512 SHA512 SHA512 SHA512_224 SHA512_256 SHAKE_128 SHAKE_128 SHAKE_256 SHAKE_256 SM3 WHIRLPOOL * OpenSSL 1.1.1
  • 40. Sources: [7], [11] hashlib.py – new 40 allows using insecure hashes in OpenSSL FIPS mode
  • 41. try: import _hashlib new = __hash_new __get_hash = __get_openssl_constructor algorithms_available = algorithms_available.union( _hashlib.openssl_md_meth_names) except ImportError : new = __py_new __get_hash = __get_builtin_constructor hashlib.py – new Source: [12] 41 __get_builtin_constructor
  • 42. def __hash_new(name, data= b'', **kwargs): """new(name, data=b'') - Return a new hashing object using the named algorithm; optionally initialized with data (which must be a bytes-like object). """ if name in __block_openssl_constructor: # Prefer our builtin blake2 implementation. return __get_builtin_constructor(name)(data, **kwargs) try: return _hashlib.new(name, data, **kwargs) except ValueError: # If the _hashlib module (OpenSSL) doesn't support the named # hash, try using our builtin implementations. # This allows for SHA224/256 and SHA384/512 support even though # the OpenSSL library prior to 0.9.8 doesn't provide them. return __get_builtin_constructor(name)(data) hashlib.py – __hash_new Source: [13] 'blake2b', 'blake2s' 42
  • 43. def __get_builtin_constructor(name): cache = __builtin_constructor_cache constructor = cache.get(name) if constructor is not None: return constructor try: if name in {'SHA1', 'sha1'}: import _sha1 cache['SHA1'] = cache['sha1'] = _sha1.sha1 elif name in {'MD5', 'md5'}: import _md5 cache['MD5'] = cache['md5'] = _md5.md5 ... elif name in {'blake2b', 'blake2s'}: import _blake2 cache['blake2b'] = _blake2.blake2b cache['blake2s'] = _blake2.blake2s ... except ImportError: pass # no extension module, this hash is unsupported. constructor = cache.get(name) if constructor is not None: return constructor raise ValueError('unsupported hash type ' + name) hashlib.py – __get_builtin_constructor Source: [14] 43 hashlib.py python3.9 $ objdump -T python3.9 | egrep "blake|md4|md5|sha1|sha3|sha256|sha512" 003a90df g DF .text 0000008c Base PyInit__sha512 003a5998 g DF .text 00000058 Base PyInit__sha1 003a5e9d g DF .text 000001da Base PyInit__sha3 00304aca g DF .text 00000058 Base PyInit__md5 00388b47 g DF .text 000002fb Base PyInit__blake2 003a5b7f g DF .text 0000008c Base PyInit__sha256
  • 44. try: import _hashlib new = __hash_new __get_hash = __get_openssl_constructor algorithms_available = algorithms_available.union( _hashlib.openssl_md_meth_names) except ImportError : new = __py_new __get_hash = __get_builtin_constructor hashlib.py – __get_hash Source: [15] 44 to prepare named constructors
  • 45. def __get_openssl_constructor (name): if name in __block_openssl_constructor: # Prefer our builtin blake2 implementation. return __get_builtin_constructor(name) try: # MD5, SHA1, and SHA2 are in all supported OpenSSL versions # SHA3/shake are available in OpenSSL 1.1.1+ f = getattr(_hashlib, 'openssl_' + name) # Allow the C module to raise ValueError. The function will be # defined but the hash not actually available. Don't fall back to # builtin if the current security policy blocks a digest, bpo#40695. f(usedforsecurity =False) # Use the C function directly (very fast) return f except (AttributeError , ValueError): return __get_builtin_constructor(name) hashlib.py – __get_openssl_constructor Source: [16] 'blake2b', 'blake2s' 45
  • 46. for __func_name in __always_supported: # try them all, some may not work due to the OpenSSL # version not supporting that algorithm. try: globals()[__func_name] = __get_hash(__func_name) except ValueError: import logging logging.exception( 'code for hash %s was not found.' , __func_name) hashlib.py – prepare all named constructors for algorithms_guaranteed >>> hashlib. __dict__ {..., 'md5': <built-in function openssl_md5>, 'sha1': <built-in function openssl_sha1>, 'sha224': <built-in function openssl_sha224>, 'sha256': <built-in function openssl_sha256>, 'sha384': <built-in function openssl_sha384>, 'sha512': <built-in function openssl_sha512>, 'blake2b': <class '_blake2.blake2b'>, 'blake2s': <class '_blake2.blake2s'>, 'sha3_224': <built-in function openssl_sha3_224>, 'sha3_256': <built-in function openssl_sha3_256>, 'sha3_384': <built-in function openssl_sha3_384>, 'sha3_512': <built-in function openssl_sha3_512>, 'shake_128' : <built-in function openssl_shake_128>, 'shake_256' : <built-in function openssl_shake_256>} Source: [17] __get_openssl_constructor or __get_builtin_constructor 46
  • 48. hashlib.py – key derivation Source: [7] 48
  • 49. hashlib.py – new feature in Python 3.11 Source: [7] 49
  • 50. Sources: [18], [19] PEP 644 – Require OpenSSL 1.1.1 or newer Version 3.0 will be supported until 2026-09-07 (LTS). Version 1.1.1 will be supported until 2023-09-11 (LTS). Version 1.0.2 is no longer supported. Extended support for 1.0.2 to gain access to security fixes for that version is available. Versions 1.1.0, 1.0.1, 1.0.0 and 0.9.8 are no longer supported. 50 OpenSSL 1.1.1 -> TLS 1.3 version with faster handshake and more secure. OpenSSL 1.1.0c+ -> Fully fork and thread safe. OpenSSL 1.1.0+ ships with SHA-3 and SHAKE. Python could rely on OpenSSL’s libcrypto. Benefits:
  • 51. Summary 51 Python has a set of guaranteed hash algorithms. Some extra algorithms Python loads from OpenSSL’s libcrypto. The available OpenSSL algorithms may differ depending on the versions. Remember about “python -v” verbose mode for analysis.
  • 52. References 52 1. https:/ /docs.python.org/3/using/cmdline.html 2. https:/ /github.com/miketeo/pysmb/blob/pysmb-1.2.6/python3/smb/ntlm.py#L6-L12 3. https:/ /github.com/miketeo/pysmb/issues/196/ 4. https:/ /github.com/miketeo/pysmb/pull/198/files/ 5. https:/ /wiki.openssl.org/index.php/OpenSSL_3.0 6. https:/ /www.openssl.org/news/changelog.txt 7. https:/ /docs.python.org/3/library/hashlib.html 8. https:/ /github.com/python/cpython/blob/v3.9.15/Lib/hashlib.py#L56-L65 9. https:/ /github.com/python/cpython/blob/v3.9.15/Lib/hashlib.py#L169-L178 10. https:/ /github.com/python/cpython/blob/v3.9.15/Modules/_hashopenssl.c#L1891-L1921 11. https:/ /peps.python.org/pep-0452 12. https:/ /github.com/python/cpython/blob/v3.9.15/Lib/hashlib.py#L169-L178 13. https:/ /github.com/python/cpython/blob/v3.9.15/Lib/hashlib.py#L152-L166 14. https:/ /github.com/python/cpython/blob/v3.9.15/Lib/hashlib.py#L82-L123 15. https:/ /github.com/python/cpython/blob/v3.9.15/Lib/hashlib.py#L169-L178 16. https:/ /github.com/python/cpython/blob/v3.9.15/Lib/hashlib.py#L126-L141 17. https:/ /github.com/python/cpython/blob/v3.9.15/Lib/hashlib.py#L250-L257 18. https:/ /peps.python.org/pep-0644 19. https:/ /www.openssl.org/policies/releasestrat.html