Skip to content

Commit

Permalink
crypto: x86/cast5-avx - fix ECB encryption when long sg follows short…
Browse files Browse the repository at this point in the history
… one

With ecb-cast5-avx, if a 128+ byte scatterlist element followed a
shorter one, then the algorithm accidentally encrypted/decrypted only 8
bytes instead of the expected 128 bytes.  Fix it by setting the
encryption/decryption 'fn' correctly.

Fixes: c12ab20 ("crypto: cast5/avx - avoid using temporary stack buffers")
Cc: <[email protected]> # v3.8+
Signed-off-by: Eric Biggers <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
ebiggers authored and herbertx committed Mar 2, 2018
1 parent 0e6ab46 commit 8f461b1
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions arch/x86/crypto/cast5_avx_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ static int ecb_crypt(struct blkcipher_desc *desc, struct blkcipher_walk *walk,
void (*fn)(struct cast5_ctx *ctx, u8 *dst, const u8 *src);
int err;

fn = (enc) ? cast5_ecb_enc_16way : cast5_ecb_dec_16way;

err = blkcipher_walk_virt(desc, walk);
desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;

Expand All @@ -79,6 +77,7 @@ static int ecb_crypt(struct blkcipher_desc *desc, struct blkcipher_walk *walk,

/* Process multi-block batch */
if (nbytes >= bsize * CAST5_PARALLEL_BLOCKS) {
fn = (enc) ? cast5_ecb_enc_16way : cast5_ecb_dec_16way;
do {
fn(ctx, wdst, wsrc);

Expand Down

0 comments on commit 8f461b1

Please sign in to comment.