Make flags be macros rather than enumerations, to ensure that they're
[u/mdw/catacomb] / dsig.c
diff --git a/dsig.c b/dsig.c
index e591538..a34cca2 100644 (file)
--- a/dsig.c
+++ b/dsig.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: dsig.c,v 1.4 2000/08/04 23:23:44 mdw Exp $
+ * $Id: dsig.c,v 1.6 2000/12/06 20:33:27 mdw Exp $
  *
  * Verify signatures on distribuitions of files
  *
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: dsig.c,v $
+ * Revision 1.6  2000/12/06 20:33:27  mdw
+ * Make flags be macros rather than enumerations, to ensure that they're
+ * unsigned.
+ *
+ * Revision 1.5  2000/10/08 12:12:09  mdw
+ * Shut up some warnings.
+ *
  * Revision 1.4  2000/08/04 23:23:44  mdw
  * Various <ctype.h> fixes.
  *
@@ -101,7 +108,7 @@ static int dsasign(key *k, const void *m, size_t msz, dstr *d)
   if (sz < msz)
     die(EXIT_FAILURE, "hash function too wide for this signing key");
   DENSURE(d, sz * 2);
-  p = d->buf + d->len;
+  p = (octet *)d->buf + d->len;
   rand_get(RAND_GLOBAL, p, sz);
   dsa_sign(&dp.dp, dp.x, m, msz, p, sz, p, sz, p + sz, sz);
   d->len += sz * 2;
@@ -116,6 +123,7 @@ static int dsaverify(key *k, const void *m, size_t msz,
   key_packstruct ks[DSA_PUBFETCHSZ];
   key_packdef *kp;
   size_t sz;
+  const octet *p = s;
   int e;
 
   kp = key_fetchinit(dsa_pubfetch, ks, &dp);
@@ -124,7 +132,7 @@ static int dsaverify(key *k, const void *m, size_t msz,
     return (e);
   }
   sz = ssz / 2;
-  e = dsa_verify(&dp.dp, dp.y, m, msz, s, sz, s + sz, sz);
+  e = dsa_verify(&dp.dp, dp.y, m, msz, p, sz, p + sz, sz);
   key_fetchdone(kp);
   return (e);  
 }
@@ -816,14 +824,14 @@ static void keyreport(const char *file, int line, const char *err, void *p)
  *
  * Arguments:  @const gchash *c@ = pointer to hash class
  *             @const char *file@ = file to hash
- *             @octet *b@ = pointer to output buffer
+ *             @void *b@ = pointer to output buffer
  *
  * Returns:    Zero if it worked, or nonzero for a system error.
  *
  * Use:                Hashes a file.
  */
 
-static int fhash(const gchash *c, const char *file, octet *b)
+static int fhash(const gchash *c, const char *file, void *b)
 {
   FILE *fp = fopen(file, "rb");
   ghash *h = c->init();
@@ -872,11 +880,9 @@ static void fhex(FILE *fp, const void *p, size_t sz)
 
 static int sign(int argc, char *argv[])
 {
-  enum {
-    f_raw = 1,
-    f_bin = 2,
-    f_bogus = 4
-  };
+#define f_raw 1u
+#define f_bin 2u
+#define f_bogus 4u
 
   unsigned f = 0;
   const char *kt = 0;
@@ -1114,17 +1120,19 @@ static int sign(int argc, char *argv[])
   if (f & f_bogus)
     die(EXIT_FAILURE, "error(s) occurred while creating signature");
   return (EXIT_SUCCESS);
+
+#undef f_raw
+#undef f_bin
+#undef f_bogus
 }
 
 /*----- Signature verification --------------------------------------------*/
 
 static int verify(int argc, char *argv[])
 {
-  enum {
-    f_bogus = 1,
-    f_bin = 2,
-    f_ok = 4
-  };
+#define f_bogus 1u
+#define f_bin 2u
+#define f_ok 4u
 
   unsigned f = 0;
   unsigned verb = 1;
@@ -1133,7 +1141,7 @@ static int verify(int argc, char *argv[])
   sig *s = sigtab;
   const gchash *gch = &rmd160;
   dstr d = DSTR_INIT;
-  ghash *h;
+  ghash *h = 0;
   FILE *fp;
   block b;
   int e;
@@ -1343,6 +1351,10 @@ done:
       puts("OK signature verified");
   }
   return (f & f_bogus ? EXIT_FAILURE : EXIT_SUCCESS);
+
+#undef f_bogus
+#undef f_bin
+#undef f_ok
 }
 
 /*----- Main code ---------------------------------------------------------*/
@@ -1405,9 +1417,7 @@ int main(int argc, char *argv[])
   cmd *c = 0, *cc = 0;
   size_t n;
 
-  enum {
-    f_bogus = 1
-  };
+#define f_bogus 1u
 
   /* --- Initialize the library --- */
 
@@ -1475,6 +1485,8 @@ int main(int argc, char *argv[])
   if (!cc)
     die(EXIT_FAILURE, "unknown command `%s'", argv[0]);
   return (cc->func(argc, argv));
+
+#undef f_bogus
 }
 
 /*----- That's all, folks -------------------------------------------------*/