Commit f3c400ef authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Herbert Xu

crypto: arm-aes - fix encryption of unaligned data

Fix the same alignment bug as in arm64 - we need to pass residue
unprocessed bytes as the last argument to blkcipher_walk_done.
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org	# 3.13+
Acked-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent f960d209
...@@ -137,7 +137,7 @@ static int aesbs_cbc_encrypt(struct blkcipher_desc *desc, ...@@ -137,7 +137,7 @@ static int aesbs_cbc_encrypt(struct blkcipher_desc *desc,
dst += AES_BLOCK_SIZE; dst += AES_BLOCK_SIZE;
} while (--blocks); } while (--blocks);
} }
err = blkcipher_walk_done(desc, &walk, 0); err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE);
} }
return err; return err;
} }
...@@ -158,7 +158,7 @@ static int aesbs_cbc_decrypt(struct blkcipher_desc *desc, ...@@ -158,7 +158,7 @@ static int aesbs_cbc_decrypt(struct blkcipher_desc *desc,
bsaes_cbc_encrypt(walk.src.virt.addr, walk.dst.virt.addr, bsaes_cbc_encrypt(walk.src.virt.addr, walk.dst.virt.addr,
walk.nbytes, &ctx->dec, walk.iv); walk.nbytes, &ctx->dec, walk.iv);
kernel_neon_end(); kernel_neon_end();
err = blkcipher_walk_done(desc, &walk, 0); err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE);
} }
while (walk.nbytes) { while (walk.nbytes) {
u32 blocks = walk.nbytes / AES_BLOCK_SIZE; u32 blocks = walk.nbytes / AES_BLOCK_SIZE;
...@@ -182,7 +182,7 @@ static int aesbs_cbc_decrypt(struct blkcipher_desc *desc, ...@@ -182,7 +182,7 @@ static int aesbs_cbc_decrypt(struct blkcipher_desc *desc,
dst += AES_BLOCK_SIZE; dst += AES_BLOCK_SIZE;
src += AES_BLOCK_SIZE; src += AES_BLOCK_SIZE;
} while (--blocks); } while (--blocks);
err = blkcipher_walk_done(desc, &walk, 0); err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE);
} }
return err; return err;
} }
...@@ -268,7 +268,7 @@ static int aesbs_xts_encrypt(struct blkcipher_desc *desc, ...@@ -268,7 +268,7 @@ static int aesbs_xts_encrypt(struct blkcipher_desc *desc,
bsaes_xts_encrypt(walk.src.virt.addr, walk.dst.virt.addr, bsaes_xts_encrypt(walk.src.virt.addr, walk.dst.virt.addr,
walk.nbytes, &ctx->enc, walk.iv); walk.nbytes, &ctx->enc, walk.iv);
kernel_neon_end(); kernel_neon_end();
err = blkcipher_walk_done(desc, &walk, 0); err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE);
} }
return err; return err;
} }
...@@ -292,7 +292,7 @@ static int aesbs_xts_decrypt(struct blkcipher_desc *desc, ...@@ -292,7 +292,7 @@ static int aesbs_xts_decrypt(struct blkcipher_desc *desc,
bsaes_xts_decrypt(walk.src.virt.addr, walk.dst.virt.addr, bsaes_xts_decrypt(walk.src.virt.addr, walk.dst.virt.addr,
walk.nbytes, &ctx->dec, walk.iv); walk.nbytes, &ctx->dec, walk.iv);
kernel_neon_end(); kernel_neon_end();
err = blkcipher_walk_done(desc, &walk, 0); err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE);
} }
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment