crypto: testmgr - limit IV copy length in aead tests
authorCristian Stoica <cristian.stoica@freescale.com>
Wed, 28 Jan 2015 09:03:05 +0000 (11:03 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 4 Feb 2015 09:59:41 +0000 (20:59 +1100)
The working copy of IV is the same size as the transformation's IV.
It is not necessary to copy more than that from the template since
iv_len is usually less than MAX_IVLEN and the rest of the copied data
is garbage.

Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/testmgr.c

index 758d02847308bb41bc80e06df8f2672739b4bc5c..f4ed6d4205e713880f1d3b8fb2a6b567c0a3154e 100644 (file)
@@ -429,7 +429,7 @@ static int __test_aead(struct crypto_aead *tfm, int enc,
        struct scatterlist *sgout;
        const char *e, *d;
        struct tcrypt_result result;
-       unsigned int authsize;
+       unsigned int authsize, iv_len;
        void *input;
        void *output;
        void *assoc;
@@ -500,10 +500,11 @@ static int __test_aead(struct crypto_aead *tfm, int enc,
 
                memcpy(input, template[i].input, template[i].ilen);
                memcpy(assoc, template[i].assoc, template[i].alen);
+               iv_len = crypto_aead_ivsize(tfm);
                if (template[i].iv)
-                       memcpy(iv, template[i].iv, MAX_IVLEN);
+                       memcpy(iv, template[i].iv, iv_len);
                else
-                       memset(iv, 0, MAX_IVLEN);
+                       memset(iv, 0, iv_len);
 
                crypto_aead_clear_flags(tfm, ~0);
                if (template[i].wk)
This page took 0.026203 seconds and 5 git commands to generate.