* [PATCH] crypto: eseqiv - fix IV generation for sync algorithms
@ 2009-04-14 13:23 Steffen Klassert
2009-04-15 11:15 ` Herbert Xu
0 siblings, 1 reply; 4+ messages in thread
From: Steffen Klassert @ 2009-04-14 13:23 UTC (permalink / raw)
To: Herbert Xu; +Cc: linux-crypto
If crypto_ablkcipher_encrypt() returns synchronous,
eseqiv_complete2() is called even if req->giv is already the
pointer to the generated IV. The generated IV is overwritten
with some random data in this case. This patch fixes this by
calling eseqiv_complete2() just in the case where an asynchronous
algorithm would call eseqiv_complete() as the complete function.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
crypto/eseqiv.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/crypto/eseqiv.c b/crypto/eseqiv.c
index 2a342c8..2fa53b0 100644
--- a/crypto/eseqiv.c
+++ b/crypto/eseqiv.c
@@ -153,7 +153,8 @@ static int eseqiv_givencrypt(struct skcipher_givcrypt_request *req)
if (err)
goto out;
- eseqiv_complete2(req);
+ if (complete == eseqiv_complete)
+ eseqiv_complete2(req);
out:
return err;
--
1.5.4.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] crypto: eseqiv - fix IV generation for sync algorithms
2009-04-14 13:23 [PATCH] crypto: eseqiv - fix IV generation for sync algorithms Steffen Klassert
@ 2009-04-15 11:15 ` Herbert Xu
2009-04-15 12:19 ` Steffen Klassert
0 siblings, 1 reply; 4+ messages in thread
From: Herbert Xu @ 2009-04-15 11:15 UTC (permalink / raw)
To: Steffen Klassert; +Cc: linux-crypto
On Tue, Apr 14, 2009 at 03:23:51PM +0200, Steffen Klassert wrote:
> If crypto_ablkcipher_encrypt() returns synchronous,
> eseqiv_complete2() is called even if req->giv is already the
> pointer to the generated IV. The generated IV is overwritten
> with some random data in this case. This patch fixes this by
> calling eseqiv_complete2() just in the case where an asynchronous
> algorithm would call eseqiv_complete() as the complete function.
>
> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Well caught! Clearly no one has ever tried this before :)
> diff --git a/crypto/eseqiv.c b/crypto/eseqiv.c
> index 2a342c8..2fa53b0 100644
> --- a/crypto/eseqiv.c
> +++ b/crypto/eseqiv.c
> @@ -153,7 +153,8 @@ static int eseqiv_givencrypt(struct skcipher_givcrypt_request *req)
> if (err)
> goto out;
>
> - eseqiv_complete2(req);
> + if (complete == eseqiv_complete)
> + eseqiv_complete2(req);
Being paranoid it may just be possible for our caller (or one if
its ancestors) to be eseqiv, in which case this test will give a
false positive.
So how about doing what seqiv does and check
if (giv != req->giv)
Thanks,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] crypto: eseqiv - fix IV generation for sync algorithms
2009-04-15 11:15 ` Herbert Xu
@ 2009-04-15 12:19 ` Steffen Klassert
2009-04-15 12:45 ` Herbert Xu
0 siblings, 1 reply; 4+ messages in thread
From: Steffen Klassert @ 2009-04-15 12:19 UTC (permalink / raw)
To: Herbert Xu; +Cc: linux-crypto
On Wed, Apr 15, 2009 at 07:15:49PM +0800, Herbert Xu wrote:
>
> Well caught! Clearly no one has ever tried this before :)
>
I thought so :)
>
> So how about doing what seqiv does and check
>
> if (giv != req->giv)
>
Yes, that's probaply the better check.
An updated patch is below.
crypto: eseqiv - fix IV generation for sync algorithms
If crypto_ablkcipher_encrypt() returns synchronous,
eseqiv_complete2() is called even if req->giv is already the
pointer to the generated IV. The generated IV is overwritten
with some random data in this case. This patch fixes this by
calling eseqiv_complete2() just if the generated IV has to be
copied to req->giv.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
crypto/eseqiv.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/crypto/eseqiv.c b/crypto/eseqiv.c
index 2a342c8..3ca3b66 100644
--- a/crypto/eseqiv.c
+++ b/crypto/eseqiv.c
@@ -153,7 +153,8 @@ static int eseqiv_givencrypt(struct skcipher_givcrypt_request *req)
if (err)
goto out;
- eseqiv_complete2(req);
+ if (giv != req->giv)
+ eseqiv_complete2(req);
out:
return err;
--
1.5.4.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-04-15 12:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-14 13:23 [PATCH] crypto: eseqiv - fix IV generation for sync algorithms Steffen Klassert
2009-04-15 11:15 ` Herbert Xu
2009-04-15 12:19 ` Steffen Klassert
2009-04-15 12:45 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox