X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/0fee61eb2ff1807c5f32a34499ef2753b6fcd9a5..e275090f9f712a8d9dda4e309ce38bb520778016:/symm/cbc-def.h diff --git a/symm/cbc-def.h b/symm/cbc-def.h index 59c76f8a..480f5796 100644 --- a/symm/cbc-def.h +++ b/symm/cbc-def.h @@ -155,7 +155,7 @@ void pre##_cbcencrypt(pre##_cbcctx *ctx, \ { \ const octet *s = src; \ octet *d = dest; \ - octet b[PRE##_BLKSZ]; \ + octet b[PRE##_BLKSZ], bb[PRE##_BLKSZ]; \ octet y; \ unsigned i; \ \ @@ -173,7 +173,8 @@ void pre##_cbcencrypt(pre##_cbcctx *ctx, \ if (sz < PRE##_BLKSZ) { \ pre##_eblk(&ctx->ctx, ctx->a, ctx->a); \ BLKC_STORE(PRE, b, ctx->a); \ - if (d) { for (i = 0; i < sz; i++) d[i] = b[i] ^ (s ? s[i] : 0); } \ + if (!d) d = bb; \ + for (i = 0; i < sz; i++) d[i] = b[i] ^ (s ? s[i] : 0); \ memmove(b, b + sz, PRE##_BLKSZ - sz); \ memcpy(b + PRE##_BLKSZ - sz, d, sz); \ BLKC_LOAD(PRE, ctx->a, b); \