Subject: [PATCH] [crypto] Geode: Copy the IV back in case of an fallback.

Jan pointed this out to me and fixed it in the fallback code for s390
and now I remembered that this could also be fixed here :)

Signed-off-by: Sebastian Siewior <[email protected]>
---
drivers/crypto/geode-aes.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/crypto/geode-aes.c b/drivers/crypto/geode-aes.c
index 68be7d0..c7d5ed0 100644
--- a/drivers/crypto/geode-aes.c
+++ b/drivers/crypto/geode-aes.c
@@ -187,6 +187,9 @@ static int fallback_blk_dec(struct blkcipher_desc *desc,
struct crypto_blkcipher *tfm;
struct geode_aes_op *op = crypto_blkcipher_ctx(desc->tfm);

+ memcpy(crypto_blkcipher_crt(op->fallback.blk)->iv, desc->info,
+ AES_BLOCK_SIZE);
+
tfm = desc->tfm;
desc->tfm = op->fallback.blk;

@@ -203,6 +206,9 @@ static int fallback_blk_enc(struct blkcipher_desc *desc,
struct crypto_blkcipher *tfm;
struct geode_aes_op *op = crypto_blkcipher_ctx(desc->tfm);

+ memcpy(crypto_blkcipher_crt(op->fallback.blk)->iv, desc->info,
+ AES_BLOCK_SIZE);
+
tfm = desc->tfm;
desc->tfm = op->fallback.blk;

--
1.5.3.4


2007-12-08 01:46:44

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] [crypto] Geode: Copy the IV back in case of an fallback.

On Fri, Dec 07, 2007 at 07:24:05PM +0100, Sebastian Siewior wrote:
> Jan pointed this out to me and fixed it in the fallback code for s390
> and now I remembered that this could also be fixed here :)
>
> Signed-off-by: Sebastian Siewior <[email protected]>

No, the default IV is put into desc->info by the system.

I see where the problem is though. We should never call the
functions crypto_blkcipher_encrypt/decrypt, it should always be
crypto_blkcipher_encrypt_iv/crypto_blkcipher_decrypt_iv.

Please make a patch to get the fallback to do that.

Thanks,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Subject: Re: [PATCH] [crypto] Geode: Copy the IV back in case of an fallback.

* Herbert Xu | 2007-12-08 09:46:41 [+0800]:

>On Fri, Dec 07, 2007 at 07:24:05PM +0100, Sebastian Siewior wrote:
>> Jan pointed this out to me and fixed it in the fallback code for s390
>> and now I remembered that this could also be fixed here :)
>>
>> Signed-off-by: Sebastian Siewior <[email protected]>
>
>No, the default IV is put into desc->info by the system.
>
>I see where the problem is though. We should never call the
>functions crypto_blkcipher_encrypt/decrypt, it should always be
>crypto_blkcipher_encrypt_iv/crypto_blkcipher_decrypt_iv.
>
>Please make a patch to get the fallback to do that.
Haven't seen that function before. Patch is on the way.

>Thanks,
Sebastian