More hash functions. Bug fix in getstring.
authormdw <mdw>
Sat, 15 Jul 2000 20:53:23 +0000 (20:53 +0000)
committermdw <mdw>
Sat, 15 Jul 2000 20:53:23 +0000 (20:53 +0000)
dsig.c

diff --git a/dsig.c b/dsig.c
index 32b5ea5..eb70191 100644 (file)
--- a/dsig.c
+++ b/dsig.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
 /* -*-c-*-
  *
- * $Id: dsig.c,v 1.2 2000/07/01 11:27:22 mdw Exp $
+ * $Id: dsig.c,v 1.3 2000/07/15 20:53:23 mdw Exp $
  *
  * Verify signatures on distribuitions of files
  *
  *
  * Verify signatures on distribuitions of files
  *
@@ -30,6 +30,9 @@
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: dsig.c,v $
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: dsig.c,v $
+ * Revision 1.3  2000/07/15 20:53:23  mdw
+ * More hash functions.  Bug fix in getstring.
+ *
  * Revision 1.2  2000/07/01 11:27:22  mdw
  * Use new PKCS#1 padding functions rather than rolling by hand.
  *
  * Revision 1.2  2000/07/01 11:27:22  mdw
  * Use new PKCS#1 padding functions rather than rolling by hand.
  *
 #include <mLib/report.h>
 #include <mLib/sub.h>
 
 #include <mLib/report.h>
 #include <mLib/sub.h>
 
-#include "dsa.h"
 #include "getdate.h"
 #include "grand.h"
 #include "ghash.h"
 #include "key.h"
 #include "key-data.h"
 #include "getdate.h"
 #include "grand.h"
 #include "ghash.h"
 #include "key.h"
 #include "key-data.h"
-#include "md5.h"
 #include "noise.h"
 #include "noise.h"
+
+#include "dsa.h"
+#include "rsa.h"
 #include "pkcs1.h"
 #include "pkcs1.h"
+
+#include "md4.h"
+#include "md5.h"
+#include "rmd128.h"
 #include "rmd160.h"
 #include "rmd160.h"
-#include "rsa.h"
+#include "rmd256.h"
+#include "rmd320.h"
 #include "sha.h"
 #include "sha.h"
+#include "tiger.h"
 
 /*----- Digital signature algorithm ---------------------------------------*/
 
 
 /*----- Digital signature algorithm ---------------------------------------*/
 
@@ -85,6 +95,8 @@ static int dsasign(key *k, const void *m, size_t msz, dstr *d)
     return (e);
   }
   sz = mp_octets(dp.dp.q);
     return (e);
   }
   sz = mp_octets(dp.dp.q);
+  if (sz < msz)
+    die(EXIT_FAILURE, "hash function too wide for this signing key");
   DENSURE(d, sz * 2);
   p = d->buf + d->len;
   rand_get(RAND_GLOBAL, p, sz);
   DENSURE(d, sz * 2);
   p = d->buf + d->len;
   rand_get(RAND_GLOBAL, p, sz);
@@ -175,7 +187,8 @@ typedef struct sig {
                const void */*s*/, size_t /*ssz*/);
 } sig;
 
                const void */*s*/, size_t /*ssz*/);
 } sig;
 
-static const gchash *hashtab[] = { &rmd160, &sha, &md5, 0 };
+static const gchash *hashtab[] = {
+  &rmd160, &tiger, &sha, &rmd128, &rmd256, &rmd320, &md5, &md4, 0 };
 static sig sigtab[] = {
   { "dsa", "dsig-dsa", dsasign, dsaverify },
   { "rsa", "dsig-rsa", rsasign, rsaverify },
 static sig sigtab[] = {
   { "dsa", "dsig-dsa", dsasign, dsaverify },
   { "rsa", "dsig-rsa", rsasign, rsaverify },
@@ -365,7 +378,7 @@ again:
       if (ch == EOF)
        break;
       switch (ch) {
       if (ch == EOF)
        break;
       switch (ch) {
-       case 'a': ch = '\n'; break;
+       case 'a': ch = '\a'; break;
        case 'b': ch = '\b'; break;
        case 'f': ch = '\f'; break;
        case 'n': ch = '\n'; break;
        case 'b': ch = '\b'; break;
        case 'f': ch = '\f'; break;
        case 'n': ch = '\n'; break;
@@ -374,6 +387,7 @@ again:
        case 'v': ch = '\v'; break;
       }
       DPUTC(d, ch);
        case 'v': ch = '\v'; break;
       }
       DPUTC(d, ch);
+      ch = getc(fp);
       continue;
     }
 
       continue;
     }