aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/crypto/padlock-aes.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/crypto/padlock-aes.c b/drivers/crypto/padlock-aes.c
index c5b58fae95f2..71407c578afe 100644
--- a/drivers/crypto/padlock-aes.c
+++ b/drivers/crypto/padlock-aes.c
@@ -400,8 +400,8 @@ static inline void padlock_xcrypt_ecb(const u8 *input, u8 *output, void *key,
400 : "d"(control_word), "b"(key), "c"(count)); 400 : "d"(control_word), "b"(key), "c"(count));
401} 401}
402 402
403static inline void padlock_xcrypt_cbc(const u8 *input, u8 *output, void *key, 403static inline u8 *padlock_xcrypt_cbc(const u8 *input, u8 *output, void *key,
404 u8 *iv, void *control_word, u32 count) 404 u8 *iv, void *control_word, u32 count)
405{ 405{
406 /* Enforce key reload. */ 406 /* Enforce key reload. */
407 asm volatile ("pushfl; popfl"); 407 asm volatile ("pushfl; popfl");
@@ -409,6 +409,7 @@ static inline void padlock_xcrypt_cbc(const u8 *input, u8 *output, void *key,
409 asm volatile (".byte 0xf3,0x0f,0xa7,0xd0" 409 asm volatile (".byte 0xf3,0x0f,0xa7,0xd0"
410 : "+S" (input), "+D" (output), "+a" (iv) 410 : "+S" (input), "+D" (output), "+a" (iv)
411 : "d" (control_word), "b" (key), "c" (count)); 411 : "d" (control_word), "b" (key), "c" (count));
412 return iv;
412} 413}
413 414
414static void 415static void
@@ -447,8 +448,12 @@ static unsigned int aes_encrypt_cbc(const struct cipher_desc *desc, u8 *out,
447 const u8 *in, unsigned int nbytes) 448 const u8 *in, unsigned int nbytes)
448{ 449{
449 struct aes_ctx *ctx = aes_ctx(crypto_tfm_ctx(desc->tfm)); 450 struct aes_ctx *ctx = aes_ctx(crypto_tfm_ctx(desc->tfm));
450 padlock_xcrypt_cbc(in, out, ctx->E, desc->info, &ctx->cword.encrypt, 451 u8 *iv;
451 nbytes / AES_BLOCK_SIZE); 452
453 iv = padlock_xcrypt_cbc(in, out, ctx->E, desc->info,
454 &ctx->cword.encrypt, nbytes / AES_BLOCK_SIZE);
455 memcpy(desc->info, iv, AES_BLOCK_SIZE);
456
452 return nbytes & ~(AES_BLOCK_SIZE - 1); 457 return nbytes & ~(AES_BLOCK_SIZE - 1);
453} 458}
454 459