~mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bug fix for key_match
[catacomb]
/
catcrypt.c
diff --git
a/catcrypt.c
b/catcrypt.c
index
08fbb53
..
4c343a4
100644
(file)
--- a/
catcrypt.c
+++ b/
catcrypt.c
@@
-276,8
+276,7
@@
static int encrypt(int argc, char *argv[])
seq = 0;
for (;;) {
h = GM_INIT(m);
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);
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);
freeenc(e);
if (s) freesig(s);
freekem(km);
+ if (fp != stdin) fclose(fp);
if (of) fclose(ofp);
key_close(&kf);
dstr_destroy(&d);
if (of) fclose(ofp);
key_close(&kf);
dstr_destroy(&d);
@@
-366,7
+366,7
@@
static int decrypt(int argc, char *argv[])
{ "output", OPTF_ARGREQ, 0, 'o' },
{ 0, 0, 0, 0 }
};
{ "output", OPTF_ARGREQ, 0, 'o' },
{ 0, 0, 0, 0 }
};
- i = mdwopt(argc, argv, "af:o:qv", opt, 0, 0, 0);
+ i = mdwopt(argc, argv, "a
b
f:o:qv", opt, 0, 0, 0);
if (i < 0) break;
switch (i) {
case 'a': ef = "pem"; break;
if (i < 0) break;
switch (i) {
case 'a': ef = "pem"; break;
@@
-460,6
+460,7
@@
static int decrypt(int argc, char *argv[])
key_fulltag(sk, &d);
printf("INFO good-signature %s\n", d.buf);
}
key_fulltag(sk, &d);
printf("INFO good-signature %s\n", d.buf);
}
+ freesig(s);
} else if (verb)
printf("INFO no-signature\n");
} 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);
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) {
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);
}
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));
if (!BLEFT(&b))
break;
GC_DECRYPT(c, BCUR(&b), BCUR(&b), BLEFT(&b));
@@
-522,7
+523,7
@@
static int decrypt(int argc, char *argv[])
rewind(rfp);
dstr_reset(&d);
dstr_ensure(&d, 65536);
rewind(rfp);
dstr_reset(&d);
dstr_ensure(&d, 65536);
- if (ofp == stdout) printf("DATA\n");
+ if (
verb &&
ofp == stdout) printf("DATA\n");
for (;;) {
n = fread(d.buf, 1, d.sz, rfp);
if (!n) break;
for (;;) {
n = fread(d.buf, 1, d.sz, rfp);
if (!n) break;
@@
-543,6
+544,7
@@
static int decrypt(int argc, char *argv[])
GC_DESTROY(cx);
GM_DESTROY(m);
freekem(km);
GC_DESTROY(cx);
GM_DESTROY(m);
freekem(km);
+ if (fp != stdin) fclose(fp);
if (of) fclose(ofp);
key_close(&kf);
dstr_destroy(&d);
if (of) fclose(ofp);
key_close(&kf);
dstr_destroy(&d);