X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/64459c9813ec87450978d0f89cf36f5491a08f7a..f387fcb17a980fe165218d217b0187a8c279508a:/catcrypt.c diff --git a/catcrypt.c b/catcrypt.c index 4e54712..4c343a4 100644 --- a/catcrypt.c +++ b/catcrypt.c @@ -276,8 +276,7 @@ static int encrypt(int argc, char *argv[]) seq = 0; for (;;) { h = GM_INIT(m); - STORE32(bb, seq); - GH_HASH(h, bb, 4); + GH_HASHU32(h, seq); seq++; if (GC_CLASS(c)->blksz) { GC_ENCRYPT(cx, 0, bb, GC_CLASS(c)->blksz); @@ -314,6 +313,7 @@ static int encrypt(int argc, char *argv[]) freeenc(e); if (s) freesig(s); freekem(km); + if (fp != stdin) fclose(fp); if (of) fclose(ofp); key_close(&kf); dstr_destroy(&d); @@ -460,6 +460,7 @@ static int decrypt(int argc, char *argv[]) key_fulltag(sk, &d); printf("INFO good-signature %s\n", d.buf); } + freesig(s); } else if (verb) printf("INFO no-signature\n"); @@ -487,8 +488,7 @@ static int decrypt(int argc, char *argv[]) GC_SETIV(c, d.buf); } h = GM_INIT(m); - STORE32(d.buf, seq); - GH_HASH(h, d.buf, 4); + GH_HASHU32(h, seq); seq++; chunk_read(e, &d, &b); if ((tag = buf_get(&b, GM_CLASS(m)->hashsz)) == 0) { @@ -501,6 +501,7 @@ static int decrypt(int argc, char *argv[]) printf("FAIL bad ciphertext chunk: authentication failure\n"); exit(EXIT_FAILURE); } + GH_DESTROY(h); if (!BLEFT(&b)) break; GC_DECRYPT(c, BCUR(&b), BCUR(&b), BLEFT(&b)); @@ -543,6 +544,7 @@ static int decrypt(int argc, char *argv[]) GC_DESTROY(cx); GM_DESTROY(m); freekem(km); + if (fp != stdin) fclose(fp); if (of) fclose(ofp); key_close(&kf); dstr_destroy(&d);