aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/testmgr.c
diff options
context:
space:
mode:
authorCristian Stoica <cristian.stoica@freescale.com>2014-08-08 07:27:52 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2014-08-25 08:27:18 -0400
commitbbb9a7dd7fd1ec076b034e6f5bce3fb5a215f050 (patch)
tree7ceb161c28576825c336b760154f9123b3b71e03 /crypto/testmgr.c
parenta1aa44a2eb498d17e725578f5c30c160a8ed9f8d (diff)
crypto: testmgr - delay execution of set-up code
Prepare IV array only if the dependent code is executed. Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/testmgr.c')
-rw-r--r--crypto/testmgr.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/crypto/testmgr.c b/crypto/testmgr.c
index 7fe4225b5513..f217c622bc41 100644
--- a/crypto/testmgr.c
+++ b/crypto/testmgr.c
@@ -961,16 +961,15 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc,
961 961
962 j = 0; 962 j = 0;
963 for (i = 0; i < tcount; i++) { 963 for (i = 0; i < tcount; i++) {
964 if (template[i].np && !template[i].also_non_np)
965 continue;
966
964 if (template[i].iv) 967 if (template[i].iv)
965 memcpy(iv, template[i].iv, MAX_IVLEN); 968 memcpy(iv, template[i].iv, MAX_IVLEN);
966 else 969 else
967 memset(iv, 0, MAX_IVLEN); 970 memset(iv, 0, MAX_IVLEN);
968 971
969 if (template[i].np && !template[i].also_non_np)
970 continue;
971
972 j++; 972 j++;
973
974 ret = -EINVAL; 973 ret = -EINVAL;
975 if (WARN_ON(align_offset + template[i].ilen > PAGE_SIZE)) 974 if (WARN_ON(align_offset + template[i].ilen > PAGE_SIZE))
976 goto out; 975 goto out;
@@ -1038,16 +1037,15 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc,
1038 if (align_offset != 0) 1037 if (align_offset != 0)
1039 break; 1038 break;
1040 1039
1040 if (!template[i].np)
1041 continue;
1042
1041 if (template[i].iv) 1043 if (template[i].iv)
1042 memcpy(iv, template[i].iv, MAX_IVLEN); 1044 memcpy(iv, template[i].iv, MAX_IVLEN);
1043 else 1045 else
1044 memset(iv, 0, MAX_IVLEN); 1046 memset(iv, 0, MAX_IVLEN);
1045 1047
1046 if (!template[i].np)
1047 continue;
1048
1049 j++; 1048 j++;
1050
1051 crypto_ablkcipher_clear_flags(tfm, ~0); 1049 crypto_ablkcipher_clear_flags(tfm, ~0);
1052 if (template[i].wk) 1050 if (template[i].wk)
1053 crypto_ablkcipher_set_flags(tfm, CRYPTO_TFM_REQ_WEAK_KEY); 1051 crypto_ablkcipher_set_flags(tfm, CRYPTO_TFM_REQ_WEAK_KEY);