From ab197b6b34bdb15d809945277e0e4b700db72a68 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Tue, 30 Oct 2018 10:26:05 +0000 Subject: [PATCH] symm/ecb-def.h: Simplify the discarding-output path. Because ECB is stateless, there is nothing to do if we discard the output. --- symm/ecb-def.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/symm/ecb-def.h b/symm/ecb-def.h index 957a16e3..c69790de 100644 --- a/symm/ecb-def.h +++ b/symm/ecb-def.h @@ -126,9 +126,9 @@ void pre##_ecbencrypt(pre##_ecbctx *ctx, \ octet y; \ unsigned i; \ \ - /* --- Empty blocks are trivial --- */ \ + /* --- Empty blocks are trivial, and ECB is stateless --- */ \ \ - if (!sz) return; \ + if (!sz || !d) return; \ \ /* --- Short blocks aren't allowed in ECB --- * \ * \ @@ -149,7 +149,7 @@ void pre##_ecbencrypt(pre##_ecbctx *ctx, \ if (!s) BLKC_ZERO(PRE, t); \ else { BLKC_LOAD(PRE, t, s); s += PRE##_BLKSZ; } \ pre##_eblk(&ctx->ctx, t, t); \ - if (d) { BLKC_STORE(PRE, d, t); d += PRE##_BLKSZ; } \ + BLKC_STORE(PRE, d, t); d += PRE##_BLKSZ; \ sz -= PRE##_BLKSZ; \ } \ \ @@ -183,11 +183,11 @@ void pre##_ecbencrypt(pre##_ecbctx *ctx, \ * ciphertext block. \ */ \ \ - if (d) d += PRE##_BLKSZ; \ - for (i = 0; i < sz; i++) { y = b[i]; b[i] = s[i]; if (d) d[i] = y; } \ + d += PRE##_BLKSZ; \ + for (i = 0; i < sz; i++) { y = b[i]; b[i] = s[i]; d[i] = y; } \ BLKC_LOAD(PRE, t, b); \ pre##_eblk(&ctx->ctx, t, t); \ - if (d) BLKC_STORE(PRE, d - PRE##_BLKSZ, t); \ + BLKC_STORE(PRE, d - PRE##_BLKSZ, t); \ } \ \ /* --- Done --- */ \ -- 2.11.0