[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[minion-cvs] Halftested] Add support to MMTP for connection padding,...



Update of /home/minion/cvsroot/src/minion/src
In directory moria.mit.edu:/tmp/cvs-serv9624/src

Modified Files:
	tls.c 
Log Message:
[Halftested] Add support to MMTP for connection padding, key renegotiation,
protocol negotiation.  Bump protocol version to 0.2, since older servers don't
receive padding correctly.


Index: tls.c
===================================================================
RCS file: /home/minion/cvsroot/src/minion/src/tls.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- tls.c	10 Jan 2003 16:51:04 -0000	1.13
+++ tls.c	12 Jan 2003 04:27:19 -0000	1.14
@@ -539,6 +539,73 @@
         return (PyObject*) result;
 }
 
+static char mm_TLSSock_renegotiate__doc__[] =
+    "tlssock.renegotate()\n\n"
+        "DOCDOC";
+
+static PyObject*
+mm_TLSSock_renegotiate(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+        SSL *ssl;
+        int r;
+
+        assert(mm_TLSSock_Check(self));
+        FAIL_IF_ARGS();
+        ssl = ((mm_TLSSock*)self)->ssl;
+        
+        Py_BEGIN_ALLOW_THREADS
+        r = SSL_renegotiate(ssl);
+        Py_END_ALLOW_THREADS
+        if (!r) {
+                tls_error(ssl, r, 0);
+                return NULL;
+        }
+        Py_INCREF(Py_None);
+        return Py_None;
+}
+
+static char mm_TLSSock_do_handshake__doc__[] =
+    "tlssock.renegotate()\n\n"
+        "DOCDOC";
+
+static PyObject*
+mm_TLSSock_do_handshake(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+        SSL *ssl;
+        int r;
+
+        assert(mm_TLSSock_Check(self));
+        FAIL_IF_ARGS();
+        ssl = ((mm_TLSSock*)self)->ssl;
+        
+        Py_BEGIN_ALLOW_THREADS
+        r = SSL_do_handshake(ssl);
+        Py_END_ALLOW_THREADS
+        if (!r) {
+                tls_error(ssl, r, 0);
+                return NULL;
+        }
+        Py_INCREF(Py_None);
+        return Py_None;
+}
+
+static char mm_TLSSock_get_num_renegotiations__doc__[] =
+    "tlssock.get_num_renegotiations()\n\n"
+    "DOCDOC";
+
+static PyObject*
+mm_TLSSock_get_num_renegotiations(PyObject *self, PyObject *args, 
+                                  PyObject *kwargs)
+{
+        SSL *ssl;
+
+        assert(mm_TLSSock_Check(self));
+        FAIL_IF_ARGS();
+        ssl = ((mm_TLSSock*)self)->ssl;
+        
+        return PyInt_FromLong(SSL_num_renegotiations(ssl));
+}
+
 static PyMethodDef mm_TLSSock_methods[] = {
         METHOD(mm_TLSSock, accept),
         METHOD(mm_TLSSock, connect),
@@ -548,6 +615,9 @@
         METHOD(mm_TLSSock, shutdown),
         METHOD(mm_TLSSock, get_peer_cert_pk),
         METHOD(mm_TLSSock, fileno),
+        METHOD(mm_TLSSock, do_handshake),
+        METHOD(mm_TLSSock, renegotiate),
+        METHOD(mm_TLSSock, get_num_renegotiations),
         { NULL, NULL }
 };