Issue 36263: test_hashlib.test_scrypt() fails on Fedora 29 (original) (raw)

$ ./python -m test -v test_hashlib -m test_scrypt ... ERROR: test_scrypt (test.test_hashlib.KDFTests)

Traceback (most recent call last): File "/home/vstinner/prog/python/master/Lib/test/test_hashlib.py", line 941, in test_scrypt result = hashlib.scrypt(password, salt=salt, n=n, r=r, p=p) ValueError: Invalid parameter combination for n, r, p, maxmem. ...

The patch pass with the following patch:

diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c index e560c18b63..22682ea86d 100644 --- a/Modules/_hashopenssl.c +++ b/Modules/_hashopenssl.c @@ -770,6 +770,7 @@ _hashlib_scrypt_impl(PyObject *module, Py_buffer *password, Py_buffer salt, return NULL; } +#if 0 / let OpenSSL validate the rest */ retval = EVP_PBE_scrypt(NULL, 0, NULL, 0, n, r, p, maxmem, NULL, 0); if (!retval) { @@ -778,6 +779,7 @@ _hashlib_scrypt_impl(PyObject *module, Py_buffer *password, Py_buffer *salt, "Invalid parameter combination for n, r, p, maxmem."); return NULL; } +#endif key_obj = PyBytes_FromStringAndSize(NULL, dklen); if (key_obj == NULL) {

$ ./python -m test.pythoninfo|grep -E '^ssl|libc_ver' platform.libc_ver: glibc 2.28 ssl.HAS_SNI: True ssl.OPENSSL_VERSION: OpenSSL 1.1.1b FIPS 26 Feb 2019 ssl.OPENSSL_VERSION_INFO: (1, 1, 1, 2, 15) ssl.OP_ALL: 0x80000054 ssl.OP_NO_TLSv1_1: 0x10000000

Note: I don't think that libxcrypt is related, but just in case:

$ rpm -q libxcrypt libxcrypt-4.4.4-1.fc29.x86_64 libxcrypt-4.4.4-1.fc29.i686 vstinner@apu$

Note 2: It seems like bpo-27928 "Add hashlib.scrypt" is still open whereas it has been implemented in Python 3.6.