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

Collapse All | Expand All

(-)pyconfig.h.in (+6 lines)
Lines 544-549 Link Here
544
/* Define to 1 if you have the `putenv' function. */
544
/* Define to 1 if you have the `putenv' function. */
545
#undef HAVE_PUTENV
545
#undef HAVE_PUTENV
546
546
547
/* ### Fix build with LibreSSL (does not have RAND_egd)
548
   ### PR192511, http://bugs.python.org/issue21356 */
549
/* Define if the libcrypto has RAND_egd */
550
#undef HAVE_RAND_EGD
551
552
/* ### End PR192511 */
547
/* Define to 1 if you have the `readlink' function. */
553
/* Define to 1 if you have the `readlink' function. */
548
#undef HAVE_READLINK
554
#undef HAVE_READLINK
549
555
(-)Lib/test/test_ssl.py (-2 / +6 lines)
Lines 96-103 Link Here
96
            sys.stdout.write("\n RAND_status is %d (%s)\n"
96
            sys.stdout.write("\n RAND_status is %d (%s)\n"
97
                             % (v, (v and "sufficient randomness") or
97
                             % (v, (v and "sufficient randomness") or
98
                                "insufficient randomness"))
98
                                "insufficient randomness"))
99
        self.assertRaises(TypeError, ssl.RAND_egd, 1)
99
### Fix build with LibreSSL (does not have RAND_egd)
100
        self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1)
100
### PR192511, http://bugs.python.org/issue21356        
101
        if hasattr(ssl, 'RAND_egd'):
102
            self.assertRaises(TypeError, ssl.RAND_egd, 1)
103
            self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1)
104
### End PR192511
101
        ssl.RAND_add("this is a random string", 75.0)
105
        ssl.RAND_add("this is a random string", 75.0)
102
106
103
    def test_parse_cert(self):
107
    def test_parse_cert(self):
(-)Lib/ssl.py 2014-11-29 22:11:34.566005456 +0100 (-1 / +10 lines)
Lines 62-68 Link Here
62
from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
62
from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
63
from _ssl import SSLError
63
from _ssl import SSLError
64
from _ssl import CERT_NONE, CERT_OPTIONAL, CERT_REQUIRED
64
from _ssl import CERT_NONE, CERT_OPTIONAL, CERT_REQUIRED
65
from _ssl import RAND_status, RAND_egd, RAND_add
65
from _ssl import RAND_status, RAND_add
66
### Fix build with LibreSSL (does not have RAND_egd)
67
### PR192511, http://bugs.python.org/issue21356
68
from _ssl import RAND_status, RAND_add
69
try:
70
    from _ssl import RAND_egd
71
except ImportError:
72
    # LibreSSL does not provide RAND_egd
73
    pass
74
### End PR192511
66
from _ssl import \
75
from _ssl import \
67
     SSL_ERROR_ZERO_RETURN, \
76
     SSL_ERROR_ZERO_RETURN, \
68
     SSL_ERROR_WANT_READ, \
77
     SSL_ERROR_WANT_READ, \
(-)configure.ac (+7 lines)
Lines 2216-2221 Link Here
2216
AC_CHECK_LIB(dl, dlopen)	# Dynamic linking for SunOS/Solaris and SYSV
2216
AC_CHECK_LIB(dl, dlopen)	# Dynamic linking for SunOS/Solaris and SYSV
2217
AC_CHECK_LIB(dld, shl_load)	# Dynamic linking for HP-UX
2217
AC_CHECK_LIB(dld, shl_load)	# Dynamic linking for HP-UX
2218
2218
2219
### Fix build with LibreSSL (does not have RAND_egd)
2220
### PR192511, http://bugs.python.org/issue21356
2221
AC_CHECK_LIB(crypto, RAND_egd,
2222
             AC_DEFINE(HAVE_RAND_EGD, 1,
2223
             [Define if the libcrypto has RAND_egd]))
2224
### End PR192511
2225
2219
# only check for sem_init if thread support is requested
2226
# only check for sem_init if thread support is requested
2220
if test "$with_threads" = "yes" -o -z "$with_threads"; then
2227
if test "$with_threads" = "yes" -o -z "$with_threads"; then
2221
    AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
2228
    AC_SEARCH_LIBS(sem_init, pthread rt posix4) # 'Real Time' functions on Solaris
(-)configure (+46 lines)
Lines 8529-8534 Link Here
8529
fi
8529
fi
8530
	# Dynamic linking for HP-UX
8530
	# Dynamic linking for HP-UX
8531
8531
8532
### Fix build with LibreSSL (does not have RAND_egd)
8533
### PR192511, http://bugs.python.org/issue21356
8534
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RAND_egd in -lcrypto" >&5
8535
$as_echo_n "checking for RAND_egd in -lcrypto... " >&6; }
8536
if ${ac_cv_lib_crypto_RAND_egd+:} false; then :
8537
  $as_echo_n "(cached) " >&6
8538
else
8539
  ac_check_lib_save_LIBS=$LIBS
8540
LIBS="-lcrypto  $LIBS"
8541
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
8542
/* end confdefs.h.  */
8543
8544
/* Override any GCC internal prototype to avoid an error.
8545
   Use char because int might match the return type of a GCC
8546
   builtin and then its argument prototype would still apply.  */
8547
#ifdef __cplusplus
8548
extern "C"
8549
#endif
8550
char RAND_egd ();
8551
int
8552
main ()
8553
{
8554
return RAND_egd ();
8555
  ;
8556
  return 0;
8557
}
8558
_ACEOF
8559
if ac_fn_c_try_link "$LINENO"; then :
8560
  ac_cv_lib_crypto_RAND_egd=yes
8561
else
8562
  ac_cv_lib_crypto_RAND_egd=no
8563
fi
8564
rm -f core conftest.err conftest.$ac_objext \
8565
    conftest$ac_exeext conftest.$ac_ext
8566
LIBS=$ac_check_lib_save_LIBS
8567
fi
8568
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_RAND_egd" >&5
8569
$as_echo "$ac_cv_lib_crypto_RAND_egd" >&6; }
8570
if test "x$ac_cv_lib_crypto_RAND_egd" = xyes; then :
8571
8572
$as_echo "#define HAVE_RAND_EGD 1" >>confdefs.h
8573
8574
fi
8575
8576
### End PR192511
8577
8532
# only check for sem_init if thread support is requested
8578
# only check for sem_init if thread support is requested
8533
if test "$with_threads" = "yes" -o -z "$with_threads"; then
8579
if test "$with_threads" = "yes" -o -z "$with_threads"; then
8534
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sem_init" >&5
8580
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sem_init" >&5
(-)Lib/socket.py (-1 / +8 lines)
Lines 67-73 Link Here
67
    from _ssl import SSLError as sslerror
67
    from _ssl import SSLError as sslerror
68
    from _ssl import \
68
    from _ssl import \
69
         RAND_add, \
69
         RAND_add, \
70
         RAND_egd, \
71
         RAND_status, \
70
         RAND_status, \
72
         SSL_ERROR_ZERO_RETURN, \
71
         SSL_ERROR_ZERO_RETURN, \
73
         SSL_ERROR_WANT_READ, \
72
         SSL_ERROR_WANT_READ, \
Lines 78-83 Link Here
78
         SSL_ERROR_WANT_CONNECT, \
77
         SSL_ERROR_WANT_CONNECT, \
79
         SSL_ERROR_EOF, \
78
         SSL_ERROR_EOF, \
80
         SSL_ERROR_INVALID_ERROR_CODE
79
         SSL_ERROR_INVALID_ERROR_CODE
80
### Fix build with LibreSSL (does not have RAND_egd)
81
### PR192511, http://bugs.python.org/issue21356
82
    try:
83
         from _ssl import RAND_egd
84
         # LibreSSL does not provide RAND_egd
85
    except ImportError:
86
         pass
87
### End PR192511
81
88
82
import os, sys, warnings
89
import os, sys, warnings
83
90
(-)Modules/_ssl.c (+10 lines)
Lines 1601-1606 Link Here
1601
It is necessary to seed the PRNG with RAND_add() on some platforms before\n\
1601
It is necessary to seed the PRNG with RAND_add() on some platforms before\n\
1602
using the ssl() function.");
1602
using the ssl() function.");
1603
1603
1604
/* ### Fix build with LibreSSL (does not have RAND_egd)
1605
   ### PR192511, http://bugs.python.org/issue21356 */
1606
#ifdef HAVE_RAND_EGD
1604
static PyObject *
1607
static PyObject *
1605
PySSL_RAND_egd(PyObject *self, PyObject *arg)
1608
PySSL_RAND_egd(PyObject *self, PyObject *arg)
1606
{
1609
{
Lines 1626-1631 Link Here
1626
Queries the entropy gather daemon (EGD) on the socket named by 'path'.\n\
1629
Queries the entropy gather daemon (EGD) on the socket named by 'path'.\n\
1627
Returns number of bytes read.  Raises SSLError if connection to EGD\n\
1630
Returns number of bytes read.  Raises SSLError if connection to EGD\n\
1628
fails or if it does not provide enough data to seed PRNG.");
1631
fails or if it does not provide enough data to seed PRNG.");
1632
#endif /* HAVE_RAND_EGD */
1633
/* ### End PR192511 */
1629
1634
1630
#endif /* HAVE_OPENSSL_RAND */
1635
#endif /* HAVE_OPENSSL_RAND */
1631
1636
Lines 1640-1647 Link Here
1640
#ifdef HAVE_OPENSSL_RAND
1645
#ifdef HAVE_OPENSSL_RAND
1641
    {"RAND_add",            PySSL_RAND_add, METH_VARARGS,
1646
    {"RAND_add",            PySSL_RAND_add, METH_VARARGS,
1642
     PySSL_RAND_add_doc},
1647
     PySSL_RAND_add_doc},
1648
/* ### Fix build with LibreSSL (does not have RAND_egd)
1649
   ### PR192511, http://bugs.python.org/issue21356 */
1650
#ifdef HAVE_RAND_EGD 
1643
    {"RAND_egd",            PySSL_RAND_egd, METH_O,
1651
    {"RAND_egd",            PySSL_RAND_egd, METH_O,
1644
     PySSL_RAND_egd_doc},
1652
     PySSL_RAND_egd_doc},
1653
#endif /* HAVE_RAND_EGD */
1654
/* ### End PR192551 */
1645
    {"RAND_status",         (PyCFunction)PySSL_RAND_status, METH_NOARGS,
1655
    {"RAND_status",         (PyCFunction)PySSL_RAND_status, METH_NOARGS,
1646
     PySSL_RAND_status_doc},
1656
     PySSL_RAND_status_doc},
1647
#endif
1657
#endif

Return to bug 192511