aboutsummaryrefslogtreecommitdiff
path: root/drivers/crypto/geode-aes.c
diff options
context:
space:
mode:
authorSebastian Siewior <sebastian@breakpoint.cc>2007-10-21 16:04:23 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2008-01-11 08:16:04 +1100
commit2d506d4fa1df18aa9505820722f834426edc907f (patch)
treeb39bcf3cf414e472e9ddd7aaaf58496afef27078 /drivers/crypto/geode-aes.c
parent89e12654312dddbbdbf17b5adc95b22cb672f947 (diff)
downloadlinux-linaro-stable-2d506d4fa1df18aa9505820722f834426edc907f.tar.gz
[CRYPTO] geode: use consistent IV copy
It is enough if the IV is copied before and after the while loop. With DM-Crypt is seems not be required to save the IV after encrytion because a new one is used in the request (dunno about other users). It is not save to load the IV within while loop and not save afterwards because we mill end up with the wrong IV if the request goes consists of more than one page. Signed-off-by: Sebastian Siewior <sebastian@breakpoint.cc> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/geode-aes.c')
-rw-r--r--drivers/crypto/geode-aes.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/crypto/geode-aes.c b/drivers/crypto/geode-aes.c
index 5008a1cddffb..6c04f1363e6d 100644
--- a/drivers/crypto/geode-aes.c
+++ b/drivers/crypto/geode-aes.c
@@ -226,6 +226,7 @@ geode_cbc_decrypt(struct blkcipher_desc *desc,
blkcipher_walk_init(&walk, dst, src, nbytes);
err = blkcipher_walk_virt(desc, &walk);
+ memcpy(op->iv, walk.iv, AES_IV_LENGTH);
while((nbytes = walk.nbytes)) {
op->src = walk.src.virt.addr,
@@ -234,16 +235,13 @@ geode_cbc_decrypt(struct blkcipher_desc *desc,
op->len = nbytes - (nbytes % AES_MIN_BLOCK_SIZE);
op->dir = AES_DIR_DECRYPT;
- memcpy(op->iv, walk.iv, AES_IV_LENGTH);
-
ret = geode_aes_crypt(op);
- memcpy(walk.iv, op->iv, AES_IV_LENGTH);
nbytes -= ret;
-
err = blkcipher_walk_done(desc, &walk, nbytes);
}
+ memcpy(walk.iv, op->iv, AES_IV_LENGTH);
return err;
}
@@ -258,6 +256,7 @@ geode_cbc_encrypt(struct blkcipher_desc *desc,
blkcipher_walk_init(&walk, dst, src, nbytes);
err = blkcipher_walk_virt(desc, &walk);
+ memcpy(op->iv, walk.iv, AES_IV_LENGTH);
while((nbytes = walk.nbytes)) {
op->src = walk.src.virt.addr,
@@ -266,13 +265,12 @@ geode_cbc_encrypt(struct blkcipher_desc *desc,
op->len = nbytes - (nbytes % AES_MIN_BLOCK_SIZE);
op->dir = AES_DIR_ENCRYPT;
- memcpy(op->iv, walk.iv, AES_IV_LENGTH);
-
ret = geode_aes_crypt(op);
nbytes -= ret;
err = blkcipher_walk_done(desc, &walk, nbytes);
}
+ memcpy(walk.iv, op->iv, AES_IV_LENGTH);
return err;
}