Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

[PATCH 1/3] crypto: properly handle null input and assoc data aead test vectors

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


jarod at redhat

Apr 15, 2009, 6:36 AM

Post #1 of 3 (160 views)
Permalink
[PATCH 1/3] crypto: properly handle null input and assoc data aead test vectors

Currenty, if either input or associated data are null in an aead
test vector, we'll have random contents of the input and assoc
arrays. Similar to the iv, play it safe and zero out the contents.

Signed-off-by: Jarod Wilson <jarod [at] redhat>

---
crypto/testmgr.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index bfee6e9..a8bdcb3 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -314,8 +314,18 @@ static int test_aead(struct crypto_aead *tfm, int enc,
input = xbuf[0];
assoc = axbuf[0];

- memcpy(input, template[i].input, template[i].ilen);
- memcpy(assoc, template[i].assoc, template[i].alen);
+ if (template[i].input)
+ memcpy(input, template[i].input,
+ template[i].ilen);
+ else
+ memset(input, 0, MAX_IVLEN);
+
+ if (template[i].assoc)
+ memcpy(assoc, template[i].assoc,
+ template[i].alen);
+ else
+ memset(assoc, 0, MAX_IVLEN);
+
if (template[i].iv)
memcpy(iv, template[i].iv, MAX_IVLEN);
else
--
1.6.2.2


--
Jarod Wilson
jarod [at] redhat
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


herbert at gondor

Apr 19, 2009, 11:23 PM

Post #2 of 3 (127 views)
Permalink
Re: [PATCH 1/3] crypto: properly handle null input and assoc data aead test vectors [In reply to]

On Wed, Apr 15, 2009 at 09:36:10AM -0400, Jarod Wilson wrote:
> Currenty, if either input or associated data are null in an aead
> test vector, we'll have random contents of the input and assoc
> arrays. Similar to the iv, play it safe and zero out the contents.
>
> Signed-off-by: Jarod Wilson <jarod [at] redhat>

This patch doesn't make sense unless you were getting a crash
without it.

> diff --git a/crypto/testmgr.c b/crypto/testmgr.c
> index bfee6e9..a8bdcb3 100644
> --- a/crypto/testmgr.c
> +++ b/crypto/testmgr.c
> @@ -314,8 +314,18 @@ static int test_aead(struct crypto_aead *tfm, int enc,
> input = xbuf[0];
> assoc = axbuf[0];
>
> - memcpy(input, template[i].input, template[i].ilen);
> - memcpy(assoc, template[i].assoc, template[i].alen);
> + if (template[i].input)
> + memcpy(input, template[i].input,
> + template[i].ilen);
> + else
> + memset(input, 0, MAX_IVLEN);

If template[i].input was really NULL then the memcpy should crash.

Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert [at] gondor>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


jarod at redhat

Apr 23, 2009, 10:30 AM

Post #3 of 3 (137 views)
Permalink
Re: [PATCH 1/3] crypto: properly handle null input and assoc data aead test vectors [In reply to]

On 04/20/2009 02:23 AM, Herbert Xu wrote:
> On Wed, Apr 15, 2009 at 09:36:10AM -0400, Jarod Wilson wrote:
>> Currenty, if either input or associated data are null in an aead
>> test vector, we'll have random contents of the input and assoc
>> arrays. Similar to the iv, play it safe and zero out the contents.
>>
>> Signed-off-by: Jarod Wilson<jarod [at] redhat>
>
> This patch doesn't make sense unless you were getting a crash
> without it.
>
>> diff --git a/crypto/testmgr.c b/crypto/testmgr.c
>> index bfee6e9..a8bdcb3 100644
>> --- a/crypto/testmgr.c
>> +++ b/crypto/testmgr.c
>> @@ -314,8 +314,18 @@ static int test_aead(struct crypto_aead *tfm, int enc,
>> input = xbuf[0];
>> assoc = axbuf[0];
>>
>> - memcpy(input, template[i].input, template[i].ilen);
>> - memcpy(assoc, template[i].assoc, template[i].alen);
>> + if (template[i].input)
>> + memcpy(input, template[i].input,
>> + template[i].ilen);
>> + else
>> + memset(input, 0, MAX_IVLEN);
>
> If template[i].input was really NULL then the memcpy should crash.

I needed to do this for some extended testing elsewhere in
similar-looking code, where input could indeed be NULL and I did
encounter crashes, but its not reproduceable within tcrypt/testmgr
itself, so indeed, not necessary here.

--
Jarod Wilson
jarod [at] redhat
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.