aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto/geode-aes.c
diff options
context:
space:
mode:
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,
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