All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: testmgr: limit IV copy length in aead tests
@ 2015-01-28  9:03 Cristian Stoica
  0 siblings, 0 replies; only message in thread
From: Cristian Stoica @ 2015-01-28  9:03 UTC (permalink / raw)
  To: herbert, linux-crypto; +Cc: davem, Cristian Stoica

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>
---
 crypto/testmgr.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 758d028..f4ed6d4 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -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)
-- 
2.2.0

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-01-28 20:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-28  9:03 [PATCH] crypto: testmgr: limit IV copy length in aead tests Cristian Stoica

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.