Skip to content

Commit

Permalink
crypto: testmgr - delay execution of set-up code
Browse files Browse the repository at this point in the history
Prepare IV array only if the dependent code is executed.

Signed-off-by: Cristian Stoica <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
Cristian Stoica authored and herbertx committed Aug 25, 2014
1 parent a1aa44a commit bbb9a7d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions crypto/testmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -961,16 +961,15 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc,

j = 0;
for (i = 0; i < tcount; i++) {
if (template[i].np && !template[i].also_non_np)
continue;

if (template[i].iv)
memcpy(iv, template[i].iv, MAX_IVLEN);
else
memset(iv, 0, MAX_IVLEN);

if (template[i].np && !template[i].also_non_np)
continue;

j++;

ret = -EINVAL;
if (WARN_ON(align_offset + template[i].ilen > PAGE_SIZE))
goto out;
Expand Down Expand Up @@ -1038,16 +1037,15 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc,
if (align_offset != 0)
break;

if (!template[i].np)
continue;

if (template[i].iv)
memcpy(iv, template[i].iv, MAX_IVLEN);
else
memset(iv, 0, MAX_IVLEN);

if (!template[i].np)
continue;

j++;

crypto_ablkcipher_clear_flags(tfm, ~0);
if (template[i].wk)
crypto_ablkcipher_set_flags(tfm, CRYPTO_TFM_REQ_WEAK_KEY);
Expand Down

0 comments on commit bbb9a7d

Please sign in to comment.