[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[minion-cvs] Start making stuff work on win32 -- much more work need...



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

Modified Files:
	_minionlib.h crypt.c main.c 
Log Message:
Start making stuff work on win32 -- much more work needed, but at least it builds and passes all but 5 tests

Index: _minionlib.h
===================================================================
RCS file: /home/minion/cvsroot/src/minion/src/_minionlib.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- _minionlib.h	10 Jul 2003 18:39:15 -0000	1.16
+++ _minionlib.h	10 Jul 2003 20:01:31 -0000	1.17
@@ -67,6 +67,10 @@
 FUNC_DOC(mm_aes_ctr128_crypt);
 FUNC_DOC(mm_strxor);
 FUNC_DOC(mm_openssl_seed);
+#ifdef MS_WINDOWS
+FUNC_DOC(mm_openssl_seed_win32);
+#endif
+FUNC_DOC(mm_openssl_rand);
 FUNC_DOC(mm_add_oaep_padding);
 FUNC_DOC(mm_check_oaep_padding);
 FUNC_DOC(mm_rsa_generate);

Index: crypt.c
===================================================================
RCS file: /home/minion/cvsroot/src/minion/src/crypt.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- crypt.c	10 Jul 2003 18:39:16 -0000	1.25
+++ crypt.c	10 Jul 2003 20:01:31 -0000	1.26
@@ -278,6 +278,66 @@
         return Py_None;
 }
 
+#ifdef MS_WINDOWS
+const char mm_openssl_seed_win32__doc__[]=
+  "openssl_seed_win32()\n\n"
+  "DOCDOC\n";
+
+PyObject *
+mm_openssl_seed_win32(PyObject *self, PyObject *args, PyObject *kwdict)
+{
+        static char *kwlist[] = { NULL };
+
+        if (!PyArg_ParseTupleAndKeywords(args, kwdict, ":openssl_seed_win32",
+                                         kwlist))
+                return NULL;
+
+        Py_BEGIN_ALLOW_THREADS
+        RAND_screen();
+        Py_END_ALLOW_THREADS
+
+        Py_INCREF(Py_None);
+        return Py_None;
+}
+#endif
+
+const char mm_openssl_rand__doc__[]=
+  "DOCDOC\n";
+
+PyObject *
+mm_openssl_rand(PyObject *self, PyObject *args, PyObject *kwdict)
+{
+        static char *kwlist[] = { "bytes", NULL };
+        int bytes;
+        PyObject *result;
+        int r;
+
+        if (!PyArg_ParseTupleAndKeywords(args, kwdict, "i:openssl_rand",
+                                         kwlist, &bytes))
+                return NULL;
+
+        if (bytes < 0) {
+                TYPE_ERR("bytes must be >= 0");
+        }
+
+        if (!(result = PyString_FromStringAndSize(NULL,bytes))) {
+                PyErr_NoMemory(); return NULL;
+        }
+
+        Py_BEGIN_ALLOW_THREADS
+        r = RAND_bytes(PyString_AsString(result), bytes);
+        Py_END_ALLOW_THREADS
+        
+        if (!r) {
+                Py_DECREF(result);
+                mm_SSL_ERR(1);
+                return NULL;  
+        }
+
+        return result;
+}
+
+
 
 static void
 mm_RSA_dealloc(mm_RSA *self)

Index: main.c
===================================================================
RCS file: /home/minion/cvsroot/src/minion/src/main.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- main.c	10 Jul 2003 18:39:16 -0000	1.16
+++ main.c	10 Jul 2003 20:01:31 -0000	1.17
@@ -31,6 +31,10 @@
         ENTRY(aes_ctr128_crypt),
         ENTRY(strxor),
         ENTRY(openssl_seed),
+#ifdef MS_WINDOWS
+        ENTRY(openssl_seed_win32),
+#endif
+        ENTRY(openssl_rand),
         ENTRY(add_oaep_padding),
         ENTRY(check_oaep_padding),
         ENTRY(rsa_generate),