View | Details | Raw Unified | Return to bug 195511 | Differences between
and this patch

Collapse All | Expand All

(-)configure.ac (+7 lines)
Lines 2185-2190 Link Here
2185
AC_CHECK_LIB(dl, dlopen)	# Dynamic linking for SunOS/Solaris and SYSV
2185
AC_CHECK_LIB(dl, dlopen)	# Dynamic linking for SunOS/Solaris and SYSV
2186
AC_CHECK_LIB(dld, shl_load)	# Dynamic linking for HP-UX
2186
AC_CHECK_LIB(dld, shl_load)	# Dynamic linking for HP-UX
2187
2187
2188
### Fix build with LibreSSL (does not have RAND_egd)
2189
### PR195511, http://bugs.python.org/issue21356
2190
AC_CHECK_LIB(crypto, RAND_egd,
2191
             AC_DEFINE(HAVE_RAND_EGD, 1,
2192
             [Define if the libcrypto has RAND_egd]))
2193
### PR195511
2194
2188
# only check for sem_init if thread support is requested
2195
# only check for sem_init if thread support is requested
2189
if test "$with_threads" = "yes" -o -z "$with_threads"; then
2196
if test "$with_threads" = "yes" -o -z "$with_threads"; then
2190
    AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2197
    AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
(-)configure (+46 lines)
Lines 8827-8832 Link Here
8827
fi
8827
fi
8828
	# Dynamic linking for HP-UX
8828
	# Dynamic linking for HP-UX
8829
8829
8830
### Fix build with LibreSSL (does not have RAND_egd)
8831
### PR195511, http://bugs.python.org/issue21356
8832
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RAND_egd in -lcrypto" >&5
8833
$as_echo_n "checking for RAND_egd in -lcrypto... " >&6; }
8834
if ${ac_cv_lib_crypto_RAND_egd+:} false; then :
8835
  $as_echo_n "(cached) " >&6
8836
else
8837
  ac_check_lib_save_LIBS=$LIBS
8838
LIBS="-lcrypto  $LIBS"
8839
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
8840
/* end confdefs.h.  */
8841
8842
/* Override any GCC internal prototype to avoid an error.
8843
   Use char because int might match the return type of a GCC
8844
   builtin and then its argument prototype would still apply.  */
8845
#ifdef __cplusplus
8846
extern "C"
8847
#endif
8848
char RAND_egd ();
8849
int
8850
main ()
8851
{
8852
return RAND_egd ();
8853
  ;
8854
  return 0;
8855
}
8856
_ACEOF
8857
if ac_fn_c_try_link "$LINENO"; then :
8858
  ac_cv_lib_crypto_RAND_egd=yes
8859
else
8860
  ac_cv_lib_crypto_RAND_egd=no
8861
fi
8862
rm -f core conftest.err conftest.$ac_objext \
8863
    conftest$ac_exeext conftest.$ac_ext
8864
LIBS=$ac_check_lib_save_LIBS
8865
fi
8866
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_RAND_egd" >&5
8867
$as_echo "$ac_cv_lib_crypto_RAND_egd" >&6; }
8868
if test "x$ac_cv_lib_crypto_RAND_egd" = xyes; then :
8869
8870
$as_echo "#define HAVE_RAND_EGD 1" >>confdefs.h
8871
8872
fi
8873
8874
### PR195511
8875
8830
# only check for sem_init if thread support is requested
8876
# only check for sem_init if thread support is requested
8831
if test "$with_threads" = "yes" -o -z "$with_threads"; then
8877
if test "$with_threads" = "yes" -o -z "$with_threads"; then
8832
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sem_init" >&5
8878
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sem_init" >&5
(-)Lib/ssl.py (-1 / +9 lines)
Lines 78-84 Link Here
78
    from _ssl import OP_SINGLE_ECDH_USE
78
    from _ssl import OP_SINGLE_ECDH_USE
79
except ImportError:
79
except ImportError:
80
    pass
80
    pass
81
from _ssl import RAND_status, RAND_egd, RAND_add, RAND_bytes, RAND_pseudo_bytes
81
### Fix build with LibreSSL (does not have RAND_egd)
82
### PR195511, http://bugs.python.org/issue21356
83
from _ssl import RAND_status, RAND_add, RAND_bytes, RAND_pseudo_bytes
84
try:
85
    from _ssl import RAND_egd
86
except ImportError:
87
    # LibreSSL does not provide RAND_egd
88
    pass
89
### End PR195511
82
from _ssl import (
90
from _ssl import (
83
    SSL_ERROR_ZERO_RETURN,
91
    SSL_ERROR_ZERO_RETURN,
84
    SSL_ERROR_WANT_READ,
92
    SSL_ERROR_WANT_READ,
(-)Lib/test/test_ssl.py (-2 / +6 lines)
Lines 130-137 Link Here
130
        self.assertRaises(ValueError, ssl.RAND_bytes, -5)
130
        self.assertRaises(ValueError, ssl.RAND_bytes, -5)
131
        self.assertRaises(ValueError, ssl.RAND_pseudo_bytes, -5)
131
        self.assertRaises(ValueError, ssl.RAND_pseudo_bytes, -5)
132
132
133
        self.assertRaises(TypeError, ssl.RAND_egd, 1)
133
### Fix build with LibreSSL (does not have RAND_egd)
134
        self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1)
134
### PR195511, http://bugs.python.org/issue21356        
135
        if hasattr(ssl, 'RAND_egd'):
136
            self.assertRaises(TypeError, ssl.RAND_egd, 1)
137
            self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1)
138
### End PR195511
135
        ssl.RAND_add("this is a random string", 75.0)
139
        ssl.RAND_add("this is a random string", 75.0)
136
140
137
    @unittest.skipUnless(os.name == 'posix', 'requires posix')
141
    @unittest.skipUnless(os.name == 'posix', 'requires posix')
(-)pyconfig.h.in (+6 lines)
Lines 660-665 Link Here
660
/* Define to 1 if you have the `pwrite' function. */
660
/* Define to 1 if you have the `pwrite' function. */
661
#undef HAVE_PWRITE
661
#undef HAVE_PWRITE
662
662
663
/* ### Fix build with LibreSSL (does not have RAND_egd)
664
   ### PR195511, http://bugs.python.org/issue21356 */
665
/* Define if the libcrypto has RAND_egd */
666
#undef HAVE_RAND_EGD
667
/* ### PR195511 */
668
663
/* Define to 1 if you have the `readlink' function. */
669
/* Define to 1 if you have the `readlink' function. */
664
#undef HAVE_READLINK
670
#undef HAVE_READLINK
665
671
(-)Modules/_ssl.c (+10 lines)
Lines 2559-2564 Link Here
2559
It is necessary to seed the PRNG with RAND_add() on some platforms before\n\
2559
It is necessary to seed the PRNG with RAND_add() on some platforms before\n\
2560
using the ssl() function.");
2560
using the ssl() function.");
2561
2561
2562
/* ### Fix build with LibreSSL (does not have RAND_egd)
2563
   ### PR195511, http://bugs.python.org/issue21356 */
2564
#ifdef HAVE_RAND_EGD
2562
static PyObject *
2565
static PyObject *
2563
PySSL_RAND_egd(PyObject *self, PyObject *args)
2566
PySSL_RAND_egd(PyObject *self, PyObject *args)
2564
{
2567
{
Lines 2586-2591 Link Here
2586
Queries the entropy gather daemon (EGD) on the socket named by 'path'.\n\
2589
Queries the entropy gather daemon (EGD) on the socket named by 'path'.\n\
2587
Returns number of bytes read.  Raises SSLError if connection to EGD\n\
2590
Returns number of bytes read.  Raises SSLError if connection to EGD\n\
2588
fails or if it does not provide enough data to seed PRNG.");
2591
fails or if it does not provide enough data to seed PRNG.");
2592
#endif /* HAVE_RAND_EGD */
2593
/* ### End PR195511  */
2589
2594
2590
#endif /* HAVE_OPENSSL_RAND */
2595
#endif /* HAVE_OPENSSL_RAND */
2591
2596
Lines 2604-2611 Link Here
2604
     PySSL_RAND_bytes_doc},
2609
     PySSL_RAND_bytes_doc},
2605
    {"RAND_pseudo_bytes",   PySSL_RAND_pseudo_bytes, METH_VARARGS,
2610
    {"RAND_pseudo_bytes",   PySSL_RAND_pseudo_bytes, METH_VARARGS,
2606
     PySSL_RAND_pseudo_bytes_doc},
2611
     PySSL_RAND_pseudo_bytes_doc},
2612
/* ### Fix build with LibreSSL (does not have RAND_egd)
2613
   ### PR195511, http://bugs.python.org/issue21356 */
2614
#ifdef HAVE_RAND_EGD
2607
    {"RAND_egd",            PySSL_RAND_egd, METH_VARARGS,
2615
    {"RAND_egd",            PySSL_RAND_egd, METH_VARARGS,
2608
     PySSL_RAND_egd_doc},
2616
     PySSL_RAND_egd_doc},
2617
#endif /* HAVE_RAND_EGD */
2618
/* ### End PR195511  */
2609
    {"RAND_status",         (PyCFunction)PySSL_RAND_status, METH_NOARGS,
2619
    {"RAND_status",         (PyCFunction)PySSL_RAND_status, METH_NOARGS,
2610
     PySSL_RAND_status_doc},
2620
     PySSL_RAND_status_doc},
2611
#endif
2621
#endif

Return to bug 195511