- /* --- Main encryption loop --- */ \
- \
- { \
- uint32 iv[PRE##_BLKSZ / 4]; \
- BLKC_LOAD(PRE, iv, ctx->iv); \
- \
- for (;;) { \
- pre##_eblk(&ctx->ctx, iv, iv); \
- if (sz < PRE##_BLKSZ) \
- break; \
- if (s) { \
- BLKC_XLOAD(PRE, iv, s); \
- s += PRE##_BLKSZ; \
- } \
- if (d) { \
- BLKC_STORE(PRE, d, iv); \
- d += PRE##_BLKSZ; \
- } \
- sz -= PRE##_BLKSZ; \
+ /* If the buffer is all used, then reset it ready for next time. */ \
+ ctx->off -= plan.from_rsvr; \
+ \
+ /* Handle multiple whole blocks. */ \
+ if (!d) { \
+ if (!s) while (plan.from_input) { \
+ pre##_eblk(&ctx->ctx, t, t); \
+ plan.from_input -= PRE##_BLKSZ; \
+ } else while (plan.from_input) { \
+ pre##_eblk(&ctx->ctx, t, t); \
+ BLKC_XLOAD(PRE, t, s); s += PRE##_BLKSZ; \
+ plan.from_input -= PRE##_BLKSZ; \
+ } \
+ } else { \
+ if (!s) while (plan.from_input) { \
+ pre##_eblk(&ctx->ctx, t, t); \
+ BLKC_STORE(PRE, d, t); d += PRE##_BLKSZ; \
+ plan.from_input -= PRE##_BLKSZ; \
+ } else while (plan.from_input) { \
+ pre##_eblk(&ctx->ctx, t, t); \
+ BLKC_XLOAD(PRE, t, s); s += PRE##_BLKSZ; \
+ BLKC_STORE(PRE, d, t); d += PRE##_BLKSZ; \
+ plan.from_input -= PRE##_BLKSZ; \