diff options
author | Martin Schiller <mschiller@tdt.de> | 2016-08-18 12:03:16 +0200 |
---|---|---|
committer | John Crispin <john@phrozen.org> | 2016-08-20 05:32:56 +0200 |
commit | 93916613943ae095027f01acc521b4fcf174dea2 (patch) | |
tree | fb99e78feaa3f2f3406277fdd3a411f814d104bf /package/kernel/lantiq/ltq-deu/src/ifxmips_des.c | |
parent | 8dba24cfc2de8303da436a6ec19d3eb0314d1ca1 (diff) | |
download | mtk-20170518-93916613943ae095027f01acc521b4fcf174dea2.zip mtk-20170518-93916613943ae095027f01acc521b4fcf174dea2.tar.gz mtk-20170518-93916613943ae095027f01acc521b4fcf174dea2.tar.bz2 |
ltq-deu: fix handling of data blocks with sizes != AES/DES block size
This fix is a backport from the lantiq UGW-6.1.1-MR1
Signed-off-by: Martin Schiller <mschiller@tdt.de>
Diffstat (limited to 'package/kernel/lantiq/ltq-deu/src/ifxmips_des.c')
-rw-r--r-- | package/kernel/lantiq/ltq-deu/src/ifxmips_des.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c b/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c index dcf6c18..513c916 100644 --- a/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c +++ b/package/kernel/lantiq/ltq-deu/src/ifxmips_des.c @@ -465,14 +465,15 @@ int ecb_des_encrypt(struct blkcipher_desc *desc, struct des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); struct blkcipher_walk walk; int err; + unsigned int enc_bytes; blkcipher_walk_init(&walk, dst, src, nbytes); err = blkcipher_walk_virt(desc, &walk); - while ((nbytes = walk.nbytes)) { - nbytes -= (nbytes % DES_BLOCK_SIZE); + while ((nbytes = enc_bytes = walk.nbytes)) { + enc_bytes -= (nbytes % DES_BLOCK_SIZE); ifx_deu_des_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr, - NULL, nbytes, CRYPTO_DIR_ENCRYPT, 0); + NULL, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); nbytes &= DES_BLOCK_SIZE - 1; err = blkcipher_walk_done(desc, &walk, nbytes); } @@ -496,15 +497,16 @@ int ecb_des_decrypt(struct blkcipher_desc *desc, struct des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); struct blkcipher_walk walk; int err; + unsigned int dec_bytes; DPRINTF(1, "\n"); blkcipher_walk_init(&walk, dst, src, nbytes); err = blkcipher_walk_virt(desc, &walk); - while ((nbytes = walk.nbytes)) { - nbytes -= (nbytes % DES_BLOCK_SIZE); + while ((nbytes = dec_bytes = walk.nbytes)) { + dec_bytes -= (nbytes % DES_BLOCK_SIZE); ifx_deu_des_ecb(ctx, walk.dst.virt.addr, walk.src.virt.addr, - NULL, nbytes, CRYPTO_DIR_DECRYPT, 0); + NULL, dec_bytes, CRYPTO_DIR_DECRYPT, 0); nbytes &= DES_BLOCK_SIZE - 1; err = blkcipher_walk_done(desc, &walk, nbytes); } @@ -574,16 +576,17 @@ int cbc_des_encrypt(struct blkcipher_desc *desc, struct des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); struct blkcipher_walk walk; int err; + unsigned int enc_bytes; DPRINTF(1, "\n"); blkcipher_walk_init(&walk, dst, src, nbytes); err = blkcipher_walk_virt(desc, &walk); - while ((nbytes = walk.nbytes)) { + while ((nbytes = enc_bytes = walk.nbytes)) { u8 *iv = walk.iv; - nbytes -= (nbytes % DES_BLOCK_SIZE); + enc_bytes -= (nbytes % DES_BLOCK_SIZE); ifx_deu_des_cbc(ctx, walk.dst.virt.addr, walk.src.virt.addr, - iv, nbytes, CRYPTO_DIR_ENCRYPT, 0); + iv, enc_bytes, CRYPTO_DIR_ENCRYPT, 0); nbytes &= DES_BLOCK_SIZE - 1; err = blkcipher_walk_done(desc, &walk, nbytes); } @@ -607,16 +610,17 @@ int cbc_des_decrypt(struct blkcipher_desc *desc, struct des_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); struct blkcipher_walk walk; int err; + unsigned int dec_bytes; DPRINTF(1, "\n"); blkcipher_walk_init(&walk, dst, src, nbytes); err = blkcipher_walk_virt(desc, &walk); - while ((nbytes = walk.nbytes)) { + while ((nbytes = dec_bytes = walk.nbytes)) { u8 *iv = walk.iv; - nbytes -= (nbytes % DES_BLOCK_SIZE); + dec_bytes -= (nbytes % DES_BLOCK_SIZE); ifx_deu_des_cbc(ctx, walk.dst.virt.addr, walk.src.virt.addr, - iv, nbytes, CRYPTO_DIR_DECRYPT, 0); + iv, dec_bytes, CRYPTO_DIR_DECRYPT, 0); nbytes &= DES_BLOCK_SIZE - 1; err = blkcipher_walk_done(desc, &walk, nbytes); } |