Page MenuHomeFreeBSD

D33531.id100188.diff
No OneTemporary

D33531.id100188.diff

Index: sys/opencrypto/cryptosoft.c
===================================================================
--- sys/opencrypto/cryptosoft.c
+++ sys/opencrypto/cryptosoft.c
@@ -105,7 +105,7 @@
const struct enc_xform *exf;
const struct swcr_encdec *sw;
void *ctx;
- size_t inlen, outlen;
+ size_t inlen, outlen, todo;
int blks, resid;
struct crypto_buffer_cursor cc_in, cc_out;
const unsigned char *inblk;
@@ -172,33 +172,38 @@
if (inlen < blks) {
crypto_cursor_copydata(&cc_in, blks, blk);
inblk = blk;
+ inlen = blks;
}
- if (outlen < blks)
- outblk = blk;
-
- if (encrypting)
- exf->encrypt(ctx, inblk, outblk);
- else
- exf->decrypt(ctx, inblk, outblk);
-
- if (inlen < blks) {
- inblk = crypto_cursor_segment(&cc_in, &inlen);
- } else {
- crypto_cursor_advance(&cc_in, blks);
- inlen -= blks;
- inblk += blks;
- }
-
if (outlen < blks) {
+ outblk = blk;
+ outlen = blks;
+ }
+
+ todo = rounddown2(MIN(resid, MIN(inlen, outlen)), blks);
+
+ if (encrypting)
+ exf->encrypt_multi(ctx, inblk, outblk, todo);
+ else
+ exf->decrypt_multi(ctx, inblk, outblk, todo);
+
+ if (inblk == blk) {
+ inblk = crypto_cursor_segment(&cc_in, &inlen);
+ } else {
+ crypto_cursor_advance(&cc_in, todo);
+ inlen -= todo;
+ inblk += todo;
+ }
+
+ if (outblk == blk) {
crypto_cursor_copyback(&cc_out, blks, blk);
outblk = crypto_cursor_segment(&cc_out, &outlen);
} else {
- crypto_cursor_advance(&cc_out, blks);
- outlen -= blks;
- outblk += blks;
+ crypto_cursor_advance(&cc_out, todo);
+ outlen -= todo;
+ outblk += todo;
}
- resid -= blks;
+ resid -= todo;
}
/* Handle trailing partial block for stream ciphers. */

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 11, 4:49 PM (21 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25172142
Default Alt Text
D33531.id100188.diff (1 KB)

Event Timeline