Const-correctness fix.
authormdw <mdw>
Thu, 8 Apr 2004 16:17:32 +0000 (16:17 +0000)
committermdw <mdw>
Thu, 8 Apr 2004 16:17:32 +0000 (16:17 +0000)
.cvsignore
Makefile.m4
ec-info.c
ec-test.h
mp-mem.c

index 6aeb347..ba5a1a8 100644 (file)
@@ -289,3 +289,4 @@ has160-hmac.c
 has160-hmac.h
 has160-mgf.c
 has160-mgf.h
+profile
index 890dc8f..bb976cc 100644 (file)
@@ -1,6 +1,6 @@
 ## -*-m4-*-
 ##
-## $Id: Makefile.m4,v 1.80 2004/04/08 01:36:15 mdw Exp $
+## $Id: Makefile.m4,v 1.81 2004/04/08 16:17:32 mdw Exp $
 ##
 ## Makefile for Catacomb
 ##
@@ -199,6 +199,7 @@ define(`PGEN_SOURCES',
        keycheck.c keycheck-mp.c keycheck-report.c \
        bbs-rand.c bbs-gen.c bbs-jump.c bbs-fetch.c \
        rsa-priv.c rsa-pub.c rsa-gen.c rsa-recover.c rsa-fetch.c \
+       oaep.c pkcs1.c pss.c \
        dh-gen.c dh-limlee.c dh-check.c dh-fetch.c dh-param.c \
        dsarand.c dsa-sign.c dsa-verify.c dsa-gen.c dsa-check.c \
        gdsa.c gkcdsa.c \
@@ -212,7 +213,7 @@ libcatacomb_la_SOURCES = \
        lcrand.c fibrand.c rc4.c seal.c rand.c noise.c fipstest.c maurer.c \
        arena.c \
        passphrase.c pixie-client.c pixie-common.c lmem.c \
-       oaep.c pkcs1.c pss.c tlsprf.c sslprf.c \
+       tlsprf.c sslprf.c \
        gfshare.c \
        MP_SOURCES karatsuba.h \
        gciphertab.c ghashtab.c gmactab.c \
index 1a95cd2..cf65584 100644 (file)
--- a/ec-info.c
+++ b/ec-info.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: ec-info.c,v 1.5 2004/04/08 01:36:15 mdw Exp $
+ * $Id: ec-info.c,v 1.6 2004/04/08 16:17:32 mdw Exp $
  *
  * Elliptic curve information management
  *
@@ -525,29 +525,48 @@ const char *ec_checkinfo(const ec_info *ei, grand *gr)
 
 #include "fibrand.h"
 
-int main(void)
+int main(int argc, char *argv[])
 {
   const ecentry *ee;
   const char *e;
   int ok = 1;
+  int i;
   grand *gr;
 
   gr = fibrand_create(0);
-  fputs("checking standard curves: ", stdout);
-  for (ee = ectab; ee->name; ee++) {
-    ec_info ei;
-    getinfo(&ei, ee->data);
-    e = ec_checkinfo(&ei, gr);
-    ec_freeinfo(&ei);
-    if (e) {
-      fprintf(stderr, "\n*** curve %s fails: %s\n", ee->name, e);
-      ok = 0;
+  if (argc > 1) {
+    for (i = 1; i < argc; i++) {
+      ec_info ei;
+      if ((e = ec_getinfo(&ei, argv[i])) != 0)
+       fprintf(stderr, "bad curve spec `%s': %s", argv[i], e);
+      else {
+       e = ec_checkinfo(&ei, gr);
+       ec_freeinfo(&ei);
+       if (!e)
+         printf("OK %s\n", argv[i]);
+       else {
+         printf("BAD %s: %s\n", argv[i], e);
+         ok = 0;
+       }
+      }
+    }
+  } else {
+    fputs("checking standard curves: ", stdout);
+    for (ee = ectab; ee->name; ee++) {
+      ec_info ei;
+      getinfo(&ei, ee->data);
+      e = ec_checkinfo(&ei, gr);
+      ec_freeinfo(&ei);
+      if (e) {
+       fprintf(stderr, "\n*** curve %s fails: %s\n", ee->name, e);
+       ok = 0;
+      }
+      putchar('.');
+      fflush(stdout);
     }
-    putchar('.');
-    fflush(stdout);
+    fputs(ok ? " ok\n" : " failed\n", stdout);
   }
   gr->ops->destroy(gr);
-  fputs(ok ? " ok\n" : " failed\n", stdout);
   return (!ok);
 }
 
index 875ffc6..dfc8a05 100644 (file)
--- a/ec-test.h
+++ b/ec-test.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: ec-test.h,v 1.2 2004/04/08 01:36:15 mdw Exp $
+ * $Id: ec-test.h,v 1.3 2004/04/08 16:17:32 mdw Exp $
  *
  * Elliptic curve test functions
  *
@@ -44,7 +44,7 @@
 
 /*----- Test vector types -------------------------------------------------*/
 
-extern test_type type_ecurve, type_ec;
+extern const test_type type_ecurve, type_ec;
 
 /*----- That's all, folks -------------------------------------------------*/
 
index 4d9ee48..5d345a0 100644 (file)
--- a/mp-mem.c
+++ b/mp-mem.c
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: mp-mem.c,v 1.7 2004/04/08 01:36:15 mdw Exp $
+ * $Id: mp-mem.c,v 1.8 2004/04/08 16:17:32 mdw Exp $
  *
  * Memory management for multiprecision numbers
  *
@@ -265,7 +265,7 @@ mp *mp_dest(mp *m, size_t sz, unsigned f)
     /* --- Otherwise check whether the destination is suitable --- */
 
     if (m->ref > 1 || (m->f & MP_CONST) ||
-       sz > m->sz || !((f & ~m->f) & MP_BURN)) {
+       sz > m->sz || ((f & ~m->f) & MP_BURN)) {
 
       /* --- No -- allocate a new buffer --- *
        *