Mercurial > cpython-lru_cache-weakref
comparison Modules/socketmodule.c @ 17070:b650d7daa593 legacy-trunk
Committing patch 405101
| author | Moshe Zadka <moshez@math.huji.ac.il> |
|---|---|
| date | Sun, 18 Mar 2001 17:11:56 +0000 |
| parents | b25131bc6ec7 |
| children | 327efb59dbcd |
comparison
equal
deleted
inserted
replaced
| 17069:ee6793ae06c1 | 17070:b650d7daa593 |
|---|---|
| 192 #include "openssl/crypto.h" | 192 #include "openssl/crypto.h" |
| 193 #include "openssl/x509.h" | 193 #include "openssl/x509.h" |
| 194 #include "openssl/pem.h" | 194 #include "openssl/pem.h" |
| 195 #include "openssl/ssl.h" | 195 #include "openssl/ssl.h" |
| 196 #include "openssl/err.h" | 196 #include "openssl/err.h" |
| 197 #include "openssl/rand.h" | |
| 197 #endif /* USE_SSL */ | 198 #endif /* USE_SSL */ |
| 198 | 199 |
| 199 #if defined(MS_WINDOWS) || defined(__BEOS__) | 200 #if defined(MS_WINDOWS) || defined(__BEOS__) |
| 200 /* BeOS suffers from the same socket dichotomy as Win32... - [cjh] */ | 201 /* BeOS suffers from the same socket dichotomy as Win32... - [cjh] */ |
| 201 /* seem to be a few differences in the API */ | 202 /* seem to be a few differences in the API */ |
| 2542 PyDict_SetItemString(d, "sslerror", SSLErrorObject); | 2543 PyDict_SetItemString(d, "sslerror", SSLErrorObject); |
| 2543 Py_INCREF(&SSL_Type); | 2544 Py_INCREF(&SSL_Type); |
| 2544 if (PyDict_SetItemString(d, "SSLType", | 2545 if (PyDict_SetItemString(d, "SSLType", |
| 2545 (PyObject *)&SSL_Type) != 0) | 2546 (PyObject *)&SSL_Type) != 0) |
| 2546 return; | 2547 return; |
| 2548 if (RAND_status() == 0) { | |
| 2549 #ifdef USE_EGD | |
| 2550 char random_device[MAXPATHLEN+1]; | |
| 2551 if (!RAND_file_name (random_device, MAXPATHLEN + 1)) { | |
| 2552 PyErr_SetObject(SSLErrorObject, | |
| 2553 PyString_FromString("RAND_file_name error")); | |
| 2554 return; | |
| 2555 } | |
| 2556 if (RAND_egd (random_device) == -1) { | |
| 2557 PyErr_SetObject(SSLErrorObject, | |
| 2558 PyString_FromString("RAND_egd error")); | |
| 2559 return; | |
| 2560 } | |
| 2561 #else /* USE_EGD not defined */ | |
| 2562 char random_string[32]; | |
| 2563 int i; | |
| 2564 | |
| 2565 PyErr_Warn(PyExc_RuntimeWarning, | |
| 2566 "using insecure method to generate random numbers"); | |
| 2567 srand(time(NULL)); | |
| 2568 for(i=0; i<sizeof(random_string); i++) { | |
| 2569 random_string[i] = rand(); | |
| 2570 } | |
| 2571 RAND_seed(random_string, sizeof(random_string)); | |
| 2572 #endif /* USE_EGD */ | |
| 2573 } | |
| 2547 #endif /* USE_SSL */ | 2574 #endif /* USE_SSL */ |
| 2548 PyDict_SetItemString(d, "error", PySocket_Error); | 2575 PyDict_SetItemString(d, "error", PySocket_Error); |
| 2549 PySocketSock_Type.ob_type = &PyType_Type; | 2576 PySocketSock_Type.ob_type = &PyType_Type; |
| 2550 PySocketSock_Type.tp_doc = sockettype_doc; | 2577 PySocketSock_Type.tp_doc = sockettype_doc; |
| 2551 Py_INCREF(&PySocketSock_Type); | 2578 Py_INCREF(&PySocketSock_Type); |
