Skip to content

Commit 6a80586

Browse files
ebiggersherbertx
authored andcommitted
crypto: x86/aes-xts - simplify loop in xts_crypt_slowpath()
Since the total length processed by the loop in xts_crypt_slowpath() is a multiple of AES_BLOCK_SIZE, just round the length down to AES_BLOCK_SIZE even on the last step. This doesn't change behavior, as the last step will process a multiple of AES_BLOCK_SIZE regardless. Signed-off-by: Eric Biggers <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent c819d7b commit 6a80586

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

arch/x86/crypto/aesni-intel_glue.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -935,16 +935,13 @@ xts_crypt_slowpath(struct skcipher_request *req, xts_crypt_func crypt_func)
935935
err = skcipher_walk_virt(&walk, req, false);
936936

937937
while (walk.nbytes) {
938-
unsigned int nbytes = walk.nbytes;
939-
940-
if (nbytes < walk.total)
941-
nbytes = round_down(nbytes, AES_BLOCK_SIZE);
942-
943938
kernel_fpu_begin();
944-
(*crypt_func)(&ctx->crypt_ctx, walk.src.virt.addr,
945-
walk.dst.virt.addr, nbytes, req->iv);
939+
(*crypt_func)(&ctx->crypt_ctx,
940+
walk.src.virt.addr, walk.dst.virt.addr,
941+
walk.nbytes & ~(AES_BLOCK_SIZE - 1), req->iv);
946942
kernel_fpu_end();
947-
err = skcipher_walk_done(&walk, walk.nbytes - nbytes);
943+
err = skcipher_walk_done(&walk,
944+
walk.nbytes & (AES_BLOCK_SIZE - 1));
948945
}
949946

950947
if (err || !tail)

0 commit comments

Comments
 (0)