From c90ce6bb395bac18afa5b189e4664151d4d8ea2c Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sat, 10 Nov 2018 17:26:43 +0000 Subject: [PATCH] progs/cc-kem.c (getkem): Parse the `kdf' spec after bulk crypto. Otherwise the buffer holding the remains of the kemalgspec is clobbered. --- progs/cc-kem.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/progs/cc-kem.c b/progs/cc-kem.c index cf53eaf1..1e99e05d 100644 --- a/progs/cc-kem.c +++ b/progs/cc-kem.c @@ -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); -- 2.11.0