diff options
author | Sebastian Siewior <sebastian@breakpoint.cc> | 2007-10-21 04:04:23 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2008-01-10 16:16:04 -0500 |
commit | 2d506d4fa1df18aa9505820722f834426edc907f (patch) | |
tree | b39bcf3cf414e472e9ddd7aaaf58496afef27078 /drivers/crypto/geode-aes.c | |
parent | 89e12654312dddbbdbf17b5adc95b22cb672f947 (diff) |
[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.c | 10 |
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, | |||
226 | 226 | ||
227 | blkcipher_walk_init(&walk, dst, src, nbytes); | 227 | blkcipher_walk_init(&walk, dst, src, nbytes); |
228 | err = blkcipher_walk_virt(desc, &walk); | 228 | err = blkcipher_walk_virt(desc, &walk); |
229 | memcpy(op->iv, walk.iv, AES_IV_LENGTH); | ||
229 | 230 | ||
230 | while((nbytes = walk.nbytes)) { | 231 | while((nbytes = walk.nbytes)) { |
231 | op->src = walk.src.virt.addr, | 232 | op->src = walk.src.virt.addr, |
@@ -234,16 +235,13 @@ geode_cbc_decrypt(struct blkcipher_desc *desc, | |||
234 | op->len = nbytes - (nbytes % AES_MIN_BLOCK_SIZE); | 235 | op->len = nbytes - (nbytes % AES_MIN_BLOCK_SIZE); |
235 | op->dir = AES_DIR_DECRYPT; | 236 | op->dir = AES_DIR_DECRYPT; |
236 | 237 | ||
237 | memcpy(op->iv, walk.iv, AES_IV_LENGTH); | ||
238 | |||
239 | ret = geode_aes_crypt(op); | 238 | ret = geode_aes_crypt(op); |
240 | 239 | ||
241 | memcpy(walk.iv, op->iv, AES_IV_LENGTH); | ||
242 | nbytes -= ret; | 240 | nbytes -= ret; |
243 | |||
244 | err = blkcipher_walk_done(desc, &walk, nbytes); | 241 | err = blkcipher_walk_done(desc, &walk, nbytes); |
245 | } | 242 | } |
246 | 243 | ||
244 | memcpy(walk.iv, op->iv, AES_IV_LENGTH); | ||
247 | return err; | 245 | return err; |
248 | } | 246 | } |
249 | 247 | ||
@@ -258,6 +256,7 @@ geode_cbc_encrypt(struct blkcipher_desc *desc, | |||
258 | 256 | ||
259 | blkcipher_walk_init(&walk, dst, src, nbytes); | 257 | blkcipher_walk_init(&walk, dst, src, nbytes); |
260 | err = blkcipher_walk_virt(desc, &walk); | 258 | err = blkcipher_walk_virt(desc, &walk); |
259 | memcpy(op->iv, walk.iv, AES_IV_LENGTH); | ||
261 | 260 | ||
262 | while((nbytes = walk.nbytes)) { | 261 | while((nbytes = walk.nbytes)) { |
263 | op->src = walk.src.virt.addr, | 262 | op->src = walk.src.virt.addr, |
@@ -266,13 +265,12 @@ geode_cbc_encrypt(struct blkcipher_desc *desc, | |||
266 | op->len = nbytes - (nbytes % AES_MIN_BLOCK_SIZE); | 265 | op->len = nbytes - (nbytes % AES_MIN_BLOCK_SIZE); |
267 | op->dir = AES_DIR_ENCRYPT; | 266 | op->dir = AES_DIR_ENCRYPT; |
268 | 267 | ||
269 | memcpy(op->iv, walk.iv, AES_IV_LENGTH); | ||
270 | |||
271 | ret = geode_aes_crypt(op); | 268 | ret = geode_aes_crypt(op); |
272 | nbytes -= ret; | 269 | nbytes -= ret; |
273 | err = blkcipher_walk_done(desc, &walk, nbytes); | 270 | err = blkcipher_walk_done(desc, &walk, nbytes); |
274 | } | 271 | } |
275 | 272 | ||
273 | memcpy(walk.iv, op->iv, AES_IV_LENGTH); | ||
276 | return err; | 274 | return err; |
277 | } | 275 | } |
278 | 276 | ||