chiark / gitweb /
Rename ethereal -> wireshark.
[tripe] / keymgmt.c
index c7199e566cb4bfc6f7a8acb88ea137fe7e9a1333..edd31b2a443b7bc52e59637190390550e479a2de 100644 (file)
--- a/keymgmt.c
+++ b/keymgmt.c
@@ -34,7 +34,9 @@
 
 group *gg;
 mp *kpriv;
+ge *kpub;
 algswitch algs;
+size_t indexsz;
 
 /*----- Static variables --------------------------------------------------*/
 
@@ -301,7 +303,13 @@ static int algs_samep(const algswitch *a, const algswitch *aa)
  */
 
 static void keymoan(const char *file, int line, const char *msg, void *p)
-  { a_warn("KEYMGMT key-file-error %s:%i -- %s", file, line, msg); }
+{
+  a_warn("KEYMGMT",
+        "key-file-error",
+        "%s:%i", file, line,
+        "%s", msg,
+        A_END);
+}
 
 /* --- @loadpriv@ --- *
  *
@@ -392,6 +400,12 @@ tymatch:;
   if (kpriv)
     mp_drop(kpriv);
 
+  if (kpub)
+    G_DESTROY(g, kpub);
+  kpub = G_CREATE(g);
+  G_EXP(g, kpub, g->g, x);
+  indexsz = mp_octets(g->r);
+
   /* --- Dump out the group --- */
 
   IF_TRACING(T_KEYMGMT, {
@@ -471,7 +485,7 @@ int km_reload(void)
     T( trace(T_KEYMGMT, "keymgmt: private keyring updated: reloading..."); )
     DRESET(&d);
     if (loadpriv(&d))
-      a_warn("KEYMGMT bad-private-key -- %s", d.buf);
+      a_warn("KEYMGMT", "bad-private-key", "%s", d.buf, A_END);
     else
       reload = 1;
   }
@@ -483,7 +497,7 @@ int km_reload(void)
     kf = kf_pub;
     DRESET(&d);
     if (loadpub(&d))
-      a_warn("KEYMGMT bad-public-keyring -- %s", d.buf);
+      a_warn("KEYMGMT", "bad-public-keyring", "%s", d.buf, A_END);
     else {
       reload = 1;
       key_close(kf);
@@ -558,7 +572,7 @@ int km_getpubkey(const char *tag, ge *kpub, time_t *t_exp)
   /* --- Find the key --- */
 
   if (key_qtag(kf_pub, tag, &t, &k, &kd)) {
-    a_warn("KEYMGMT public-key %s not-found", tag);
+    a_warn("KEYMGMT", "public-key", "%s", tag, "not-found", A_END);
     goto done;
   }
 
@@ -568,14 +582,17 @@ int km_getpubkey(const char *tag, ge *kpub, time_t *t_exp)
     if (strcmp((*ko)->ty, k->type) == 0)
       goto tymatch;
   }
-  a_warn("KEYMGMT public-key %s unknown-type %s", t.buf, k->type);
+  a_warn("KEYMGMT",
+        "public-key", "%s", t.buf,
+        "unknown-type", "%s", k->type,
+        A_END);
   goto done;
 tymatch:;
 
   /* --- Load the key --- */
 
   if ((e = (*ko)->loadpub(*kd, &g, &p, &t)) != 0) {
-    a_warn("KEYMGMT public-key %s bad -- %s", t.buf, e);
+    a_warn("KEYMGMT", "public-key", "%s", t.buf, "bad", "%s", e, A_END);
     goto done;
   }
 
@@ -586,25 +603,34 @@ tymatch:;
    */
 
   if (!group_samep(gg, g)) {
-    a_warn("KEYMGMT public-key %s incorrect-group", t.buf);
+    a_warn("KEYMGMT", "public-key", "%s", t.buf, "incorrect-group", A_END);
     goto done;
   }
 
   /* --- Check the public group element --- */
 
   if (group_check(gg, p)) {
-    a_warn("KEYMGMT public-key %s bad-public-group-element", t.buf);
+    a_warn("KEYMGMT",
+          "public-key", "%s", t.buf,
+          "bad-public-group-element",
+          A_END);
     goto done;
   }
 
   /* --- Check the algorithms --- */
 
   if ((e = algs_get(&a, kf_pub, k)) != 0) {
-    a_warn("KEYMGMT public-key %s bad-algorithm-selection %s", t.buf, e);
+    a_warn("KEYMGMT",
+          "public-key", "%s", t.buf,
+          "bad-algorithm-selection", e,
+          A_END);
     goto done;
   }
   if (!algs_samep(&a, &algs)) {
-    a_warn("KEYMGMT public-key %s algorithm-mismatch", t.buf);
+    a_warn("KEYMGMT",
+          "public-key", "%s", t.buf,
+          "algorithm-mismatch",
+          A_END);
     goto done;
   }