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

[minion-cvs] Maybe save a few bytes of memory in check_oaep_padding



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

Modified Files:
	crypt.c 
Log Message:
Maybe save a few bytes of memory in check_oaep_padding

Index: crypt.c
===================================================================
RCS file: /home/minion/cvsroot/src/minion/src/crypt.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- crypt.c	16 Dec 2002 02:40:11 -0000	1.15
+++ crypt.c	16 Dec 2002 15:18:33 -0000	1.16
@@ -737,6 +737,8 @@
         (char*)mm_RSA_Type__doc__
 };
 
+#define OAEP_OVERHEAD 42
+
 const char mm_add_oaep_padding__doc__[]=
    "add_oaep_padding(s, param, keylen) -> str\n\n"
    "Adds OAEP padding to a string.  Keylen is the length of the RSA key to\n"
@@ -810,11 +812,12 @@
                 return NULL;
         }
 
-        if (!(output = PyString_FromStringAndSize(NULL,keylen))) {
+        r = keylen-OAEP_OVERHEAD;
+        if (!(output = PyString_FromStringAndSize(NULL, r))) {
                 PyErr_NoMemory(); return NULL;
         }
 
-        r = RSA_padding_check_PKCS1_OAEP(PyString_AS_STRING(output), keylen,
+        r = RSA_padding_check_PKCS1_OAEP(PyString_AS_STRING(output), r,
                                          input+1, inputlen-1, keylen,
                                          param, paramlen);
         if (r <= 0) {