| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -106,7 +106,12 @@ | |||
| 106 | 106 | from _ssl import (VERIFY_DEFAULT, VERIFY_CRL_CHECK_LEAF, VERIFY_CRL_CHECK_CHAIN, | |
| 107 | 107 | VERIFY_X509_STRICT) | |
| 108 | 108 | from _ssl import txt2obj as _txt2obj, nid2obj as _nid2obj | |
| 109 | - from _ssl import RAND_status, RAND_egd, RAND_add, RAND_bytes, RAND_pseudo_bytes | ||
| 109 | + from _ssl import RAND_status, RAND_add, RAND_bytes, RAND_pseudo_bytes | ||
| 110 | + try: | ||
| 111 | + from _ssl import RAND_egd | ||
| 112 | + except ImportError: | ||
| 113 | + # LibreSSL does not provide RAND_egd | ||
| 114 | + pass | ||
| 110 | 115 | ||
| 111 | 116 | def _import_symbols(prefix): | |
| 112 | 117 | for n in dir(_ssl): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -168,8 +168,9 @@ def test_random(self): | |||
| 168 | 168 | self.assertRaises(ValueError, ssl.RAND_bytes, -5) | |
| 169 | 169 | self.assertRaises(ValueError, ssl.RAND_pseudo_bytes, -5) | |
| 170 | 170 | ||
| 171 | - self.assertRaises(TypeError, ssl.RAND_egd, 1) | ||
| 172 | - self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1) | ||
| 171 | + if hasattr(ssl, 'RAND_egd'): | ||
| 172 | + self.assertRaises(TypeError, ssl.RAND_egd, 1) | ||
| 173 | + self.assertRaises(TypeError, ssl.RAND_egd, 'foo', 1) | ||
| 173 | 174 | ssl.RAND_add("this is a random string", 75.0) | |
| 174 | 175 | ||
| 175 | 176 | @unittest.skipUnless(os.name == 'posix', 'requires posix') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -191,6 +191,10 @@ Core and Builtins | |||
| 191 | 191 | Library | |
| 192 | 192 | ------- | |
| 193 | 193 | ||
| 194 | + - Issue #21356: Make ssl.RAND_egd() optional to support LibreSSL. The | ||
| 195 | + availability of the function is checked during the compilation. Patch written | ||
| 196 | + by Bernard Spil. | ||
| 197 | + | ||
| 194 | 198 | - Issue #22915: SAX parser now supports files opened with file descriptor or | |
| 195 | 199 | bytes path. | |
| 196 | 200 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3713,6 +3713,7 @@ Returns 1 if the OpenSSL PRNG has been seeded with enough data and 0 if not.\n\ | |||
| 3713 | 3713 | It is necessary to seed the PRNG with RAND_add() on some platforms before\n\ | |
| 3714 | 3714 | using the ssl() function."); | |
| 3715 | 3715 | ||
| 3716 | + #ifdef HAVE_RAND_EGD | ||
| 3716 | 3717 | static PyObject * | |
| 3717 | 3718 | PySSL_RAND_egd(PyObject *self, PyObject *args) | |
| 3718 | 3719 | { | |
@@ -3740,6 +3741,7 @@ PyDoc_STRVAR(PySSL_RAND_egd_doc, | |||
| 3740 | 3741 | Queries the entropy gather daemon (EGD) on the socket named by 'path'.\n\ | |
| 3741 | 3742 | Returns number of bytes read. Raises SSLError if connection to EGD\n\ | |
| 3742 | 3743 | fails or if it does not provide enough data to seed PRNG."); | |
| 3744 | + #endif /* HAVE_RAND_EGD */ | ||
| 3743 | 3745 | ||
| 3744 | 3746 | #endif /* HAVE_OPENSSL_RAND */ | |
| 3745 | 3747 | ||
@@ -4135,8 +4137,10 @@ static PyMethodDef PySSL_methods[] = { | |||
| 4135 | 4137 | PySSL_RAND_bytes_doc}, | |
| 4136 | 4138 | {"RAND_pseudo_bytes", PySSL_RAND_pseudo_bytes, METH_VARARGS, | |
| 4137 | 4139 | PySSL_RAND_pseudo_bytes_doc}, | |
| 4140 | + #ifdef HAVE_RAND_EGD | ||
| 4138 | 4141 | {"RAND_egd", PySSL_RAND_egd, METH_VARARGS, | |
| 4139 | 4142 | PySSL_RAND_egd_doc}, | |
| 4143 | + #endif | ||
| 4140 | 4144 | {"RAND_status", (PyCFunction)PySSL_RAND_status, METH_NOARGS, | |
| 4141 | 4145 | PySSL_RAND_status_doc}, | |
| 4142 | 4146 | #endif | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9046,6 +9046,48 @@ _ACEOF | |||
| 9046 | 9046 | ||
| 9047 | 9047 | fi | |
| 9048 | 9048 | # Dynamic linking for HP-UX | |
| 9049 | + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for RAND_egd in -lcrypto" >&5 | ||
| 9050 | + $as_echo_n "checking for RAND_egd in -lcrypto... " >&6; } | ||
| 9051 | + if ${ac_cv_lib_crypto_RAND_egd+:} false; then : | ||
| 9052 | + $as_echo_n "(cached) " >&6 | ||
| 9053 | + else | ||
| 9054 | + ac_check_lib_save_LIBS=$LIBS | ||
| 9055 | + LIBS="-lcrypto $LIBS" | ||
| 9056 | + cat confdefs.h - <<_ACEOF >conftest.$ac_ext | ||
| 9057 | + /* end confdefs.h. */ | ||
| 9058 | + | ||
| 9059 | + /* Override any GCC internal prototype to avoid an error. | ||
| 9060 | + Use char because int might match the return type of a GCC | ||
| 9061 | + builtin and then its argument prototype would still apply. */ | ||
| 9062 | + #ifdef __cplusplus | ||
| 9063 | + extern "C" | ||
| 9064 | + #endif | ||
| 9065 | + char RAND_egd (); | ||
| 9066 | + int | ||
| 9067 | + main () | ||
| 9068 | + { | ||
| 9069 | + return RAND_egd (); | ||
| 9070 | + ; | ||
| 9071 | + return 0; | ||
| 9072 | + } | ||
| 9073 | + _ACEOF | ||
| 9074 | + if ac_fn_c_try_link "$LINENO"; then : | ||
| 9075 | + ac_cv_lib_crypto_RAND_egd=yes | ||
| 9076 | + else | ||
| 9077 | + ac_cv_lib_crypto_RAND_egd=no | ||
| 9078 | + fi | ||
| 9079 | + rm -f core conftest.err conftest.$ac_objext \ | ||
| 9080 | + conftest$ac_exeext conftest.$ac_ext | ||
| 9081 | + LIBS=$ac_check_lib_save_LIBS | ||
| 9082 | + fi | ||
| 9083 | + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_RAND_egd" >&5 | ||
| 9084 | + $as_echo "$ac_cv_lib_crypto_RAND_egd" >&6; } | ||
| 9085 | + if test "x$ac_cv_lib_crypto_RAND_egd" = xyes; then : | ||
| 9086 | + | ||
| 9087 | + $as_echo "#define HAVE_RAND_EGD 1" >>confdefs.h | ||
| 9088 | + | ||
| 9089 | + fi | ||
| 9090 | + | ||
| 9049 | 9091 | ||
| 9050 | 9092 | # only check for sem_init if thread support is requested | |
| 9051 | 9093 | if test "$with_threads" = "yes" -o -z "$with_threads"; then | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2293,6 +2293,9 @@ AC_MSG_RESULT($SHLIBS) | |||
| 2293 | 2293 | AC_CHECK_LIB(sendfile, sendfile) | |
| 2294 | 2294 | AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV | |
| 2295 | 2295 | AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX | |
| 2296 | + AC_CHECK_LIB(crypto, RAND_egd, | ||
| 2297 | + AC_DEFINE(HAVE_RAND_EGD, 1, | ||
| 2298 | + [Define if the libcrypto has RAND_egd])) | ||
| 2296 | 2299 | ||
| 2297 | 2300 | # only check for sem_init if thread support is requested | |
| 2298 | 2301 | if test "$with_threads" = "yes" -o -z "$with_threads"; then | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -675,6 +675,9 @@ | |||
| 675 | 675 | /* Define to 1 if you have the `pwrite' function. */ | |
| 676 | 676 | #undef HAVE_PWRITE | |
| 677 | 677 | ||
| 678 | + /* Define if the libcrypto has RAND_egd */ | ||
| 679 | + #undef HAVE_RAND_EGD | ||
| 680 | + | ||
| 678 | 681 | /* Define to 1 if you have the `readlink' function. */ | |
| 679 | 682 | #undef HAVE_READLINK | |
| 680 | 683 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments