Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(5)

Unified Diff: Modules/_ssl.c

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Modules/signalmodule.c ('k') | Modules/timemodule.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Modules/_ssl.c Tue Jul 26 09:37:46 2011 +0300
+++ b/Modules/_ssl.c Mon Jul 25 09:47:18 2011 -0400
@@ -124,17 +124,6 @@
# undef HAVE_SSL_CTX_CLEAR_OPTIONS
#endif
-/* In case of 'tls-unique' it will be 12 bytes for TLS, 36 bytes for
- * older SSL, but let's be safe */
-#define PySSL_CB_MAXLEN 128
-
-/* SSL_get_finished got added to OpenSSL in 0.9.5 */
-#if OPENSSL_VERSION_NUMBER >= 0x0090500fL
-# define HAVE_OPENSSL_FINISHED 1
-#else
-# define HAVE_OPENSSL_FINISHED 0
-#endif
-
typedef struct {
PyObject_HEAD
SSL_CTX *ctx;
@@ -146,7 +135,6 @@
SSL *ssl;
X509 *peer_cert;
int shutdown_seen_zero;
- enum py_ssl_server_or_client socket_type;
} PySSLSocket;
static PyTypeObject PySSLContext_Type;
@@ -340,7 +328,6 @@
SSL_set_accept_state(self->ssl);
PySSL_END_ALLOW_THREADS
- self->socket_type = socket_type;
self->Socket = PyWeakref_NewRef((PyObject *) sock, NULL);
return self;
}
@@ -1390,41 +1377,6 @@
Does the SSL shutdown handshake with the remote end, and returns\n\
the underlying socket object.");
-#if HAVE_OPENSSL_FINISHED
-static PyObject *
-PySSL_tls_unique_cb(PySSLSocket *self)
-{
- PyObject *retval = NULL;
- char buf[PySSL_CB_MAXLEN];
- int len;
-
- if (SSL_session_reused(self->ssl) ^ !self->socket_type) {
- /* if session is resumed XOR we are the client */
- len = SSL_get_finished(self->ssl, buf, PySSL_CB_MAXLEN);
- }
- else {
- /* if a new session XOR we are the server */
- len = SSL_get_peer_finished(self->ssl, buf, PySSL_CB_MAXLEN);
- }
-
- /* It cannot be negative in current OpenSSL version as of July 2011 */
- assert(len >= 0);
- if (len == 0)
- Py_RETURN_NONE;
-
- retval = PyBytes_FromStringAndSize(buf, len);
-
- return retval;
-}
-
-PyDoc_STRVAR(PySSL_tls_unique_cb_doc,
-"tls_unique_cb() -> bytes\n\
-\n\
-Returns the 'tls-unique' channel binding data, as defined by RFC 5929.\n\
-\n\
-If the TLS handshake is not yet complete, None is returned");
-
-#endif /* HAVE_OPENSSL_FINISHED */
static PyMethodDef PySSLMethods[] = {
{"do_handshake", (PyCFunction)PySSL_SSLdo_handshake, METH_NOARGS},
@@ -1439,10 +1391,6 @@
{"cipher", (PyCFunction)PySSL_cipher, METH_NOARGS},
{"shutdown", (PyCFunction)PySSL_SSLshutdown, METH_NOARGS,
PySSL_SSLshutdown_doc},
-#if HAVE_OPENSSL_FINISHED
- {"tls_unique_cb", (PyCFunction)PySSL_tls_unique_cb, METH_NOARGS,
- PySSL_tls_unique_cb_doc},
-#endif
{NULL, NULL}
};
@@ -2153,24 +2101,6 @@
NULL
};
-
-static void
-parse_openssl_version(unsigned long libver,
- unsigned int *major, unsigned int *minor,
- unsigned int *fix, unsigned int *patch,
- unsigned int *status)
-{
- *status = libver & 0xF;
- libver >>= 4;
- *patch = libver & 0xFF;
- libver >>= 8;
- *fix = libver & 0xFF;
- libver >>= 8;
- *minor = libver & 0xFF;
- libver >>= 8;
- *major = libver & 0xFF;
-}
-
PyMODINIT_FUNC
PyInit__ssl(void)
{
@@ -2273,14 +2203,6 @@
Py_INCREF(r);
PyModule_AddObject(m, "HAS_SNI", r);
-#if HAVE_OPENSSL_FINISHED
- r = Py_True;
-#else
- r = Py_False;
-#endif
- Py_INCREF(r);
- PyModule_AddObject(m, "HAS_TLS_UNIQUE", r);
-
/* OpenSSL version */
/* SSLeay() gives us the version of the library linked against,
which could be different from the headers version.
@@ -2291,7 +2213,15 @@
return NULL;
if (PyModule_AddObject(m, "OPENSSL_VERSION_NUMBER", r))
return NULL;
- parse_openssl_version(libver, &major, &minor, &fix, &patch, &status);
+ status = libver & 0xF;
+ libver >>= 4;
+ patch = libver & 0xFF;
+ libver >>= 8;
+ fix = libver & 0xFF;
+ libver >>= 8;
+ minor = libver & 0xFF;
+ libver >>= 8;
+ major = libver & 0xFF;
r = Py_BuildValue("IIIII", major, minor, fix, patch, status);
if (r == NULL || PyModule_AddObject(m, "OPENSSL_VERSION_INFO", r))
return NULL;
@@ -2299,11 +2229,5 @@
if (r == NULL || PyModule_AddObject(m, "OPENSSL_VERSION", r))
return NULL;
- libver = OPENSSL_VERSION_NUMBER;
- parse_openssl_version(libver, &major, &minor, &fix, &patch, &status);
- r = Py_BuildValue("IIIII", major, minor, fix, patch, status);
- if (r == NULL || PyModule_AddObject(m, "_OPENSSL_API_VERSION", r))
- return NULL;
-
return m;
}
« no previous file with comments | « Modules/signalmodule.c ('k') | Modules/timemodule.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+