chiark / gitweb /
Import release 0.1.13
[secnet.git] / rsa.c
diff --git a/rsa.c b/rsa.c
index 03318ba16ba75849207a3be6311729fdceb56d43..2b4c7293f48071806a7ce4bcde40349a029a823e 100644 (file)
--- a/rsa.c
+++ b/rsa.c
@@ -1,29 +1,3 @@
-/***************************************************************************
- *
- *              Part II Project, "A secure, private IP network"
- *              Stephen Early <sde1000@cam.ac.uk>
- *   
- *
- *     $RCSfile: rsa.c,v $
- *
- *  Description: RSA signature making and checking functions
- *
- *    Copyright: (C) Stephen Early 1995
- *
- *    $Revision: 1.1 $
- *
- *        $Date: 1996/05/16 18:40:14 $
- *
- *       $State: Exp $
- *
- ***************************************************************************/
-
-/* $Log: rsa.c,v $
- * Revision 1.1  1996/05/16 18:40:14  sde1000
- * Initial revision
- *
- */
-
 #include <stdio.h>
 #include <gmp.h>
 #include "secnet.h"
@@ -62,6 +36,10 @@ static string_t rsa_sign(void *sst, uint8_t *data, uint32_t datalen)
 
     msize=mpz_sizeinbase(&st->n, 16);
 
+    if (datalen*2+4>=msize) {
+       fatal("rsa_sign: message too big\n");
+    }
+
     strcpy(buff,"0001");
 
     for (i=0; i<datalen; i++) {
@@ -69,7 +47,7 @@ static string_t rsa_sign(void *sst, uint8_t *data, uint32_t datalen)
        buff[5+i*2]=hexchars[data[i]&0xf];
     }
     buff[4+datalen*2]=0;
-
+    
     for (i=datalen*2+4; i<msize; i++)
        buff[i]='f';