chiark / gitweb /
progs/cc-kem.c (getkem): Parse the `kdf' spec after bulk crypto.
authorMark Wooding <mdw@distorted.org.uk>
Sat, 10 Nov 2018 17:26:43 +0000 (17:26 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 24 Nov 2018 20:12:25 +0000 (20:12 +0000)
Otherwise the buffer holding the remains of the kemalgspec is clobbered.

progs/cc-kem.c

index cf53eaf101afe55333d8711181ad7d2bf265411c..1e99e05d913f51b57455e79c3772f6af9232731a 100644 (file)
@@ -860,16 +860,6 @@ k_found:;
        halg, t.buf);
   }
 
-  dstr_reset(&d);
-  if ((q = key_getattr(0, k, "kdf")) == 0) {
-    dstr_putf(&d, "%s-mgf", kk->hc->name);
-    q = d.buf;
-  }
-  if ((kk->cxc = gcipher_byname(q)) == 0) {
-    die(EXIT_FAILURE, "encryption scheme (KDF) `%s' not found in key `%s'",
-       q, t.buf);
-  }
-
   if (!balg)
     bt = bulktab;
   else {
@@ -887,6 +877,16 @@ k_found:;
   *bc = bo->init(k, balg, kk->hc->name);
   (*bc)->ops = bo;
 
+  dstr_reset(&d);
+  if ((q = key_getattr(0, k, "kdf")) == 0) {
+    dstr_putf(&d, "%s-mgf", kk->hc->name);
+    q = d.buf;
+  }
+  if ((kk->cxc = gcipher_byname(q)) == 0) {
+    die(EXIT_FAILURE, "encryption scheme (KDF) `%s' not found in key `%s'",
+       q, t.buf);
+  }
+
   /* --- Tidy up --- */
 
   dstr_destroy(&d);