Commit a1aa44a2 authored by Cristian Stoica's avatar Cristian Stoica Committed by Herbert Xu

crypto: testmgr - white space removal on __test_skcipher

This patch inverts two if conditions to remove code blocks
indentation. Several white space clean-ups follow.
Signed-off-by: default avatarCristian Stoica <cristian.stoica@freescale.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 5f2b424e
...@@ -966,73 +966,69 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, ...@@ -966,73 +966,69 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc,
else else
memset(iv, 0, MAX_IVLEN); memset(iv, 0, MAX_IVLEN);
if (!(template[i].np) || (template[i].also_non_np)) { if (template[i].np && !template[i].also_non_np)
j++; continue;
ret = -EINVAL; j++;
if (WARN_ON(align_offset + template[i].ilen >
PAGE_SIZE))
goto out;
data = xbuf[0]; ret = -EINVAL;
data += align_offset; if (WARN_ON(align_offset + template[i].ilen > PAGE_SIZE))
memcpy(data, template[i].input, template[i].ilen); goto out;
crypto_ablkcipher_clear_flags(tfm, ~0);
if (template[i].wk)
crypto_ablkcipher_set_flags(
tfm, CRYPTO_TFM_REQ_WEAK_KEY);
ret = crypto_ablkcipher_setkey(tfm, template[i].key,
template[i].klen);
if (!ret == template[i].fail) {
pr_err("alg: skcipher%s: setkey failed on test %d for %s: flags=%x\n",
d, j, algo,
crypto_ablkcipher_get_flags(tfm));
goto out;
} else if (ret)
continue;
sg_init_one(&sg[0], data, template[i].ilen); data = xbuf[0];
if (diff_dst) { data += align_offset;
data = xoutbuf[0]; memcpy(data, template[i].input, template[i].ilen);
data += align_offset;
sg_init_one(&sgout[0], data, template[i].ilen);
}
ablkcipher_request_set_crypt(req, sg, crypto_ablkcipher_clear_flags(tfm, ~0);
(diff_dst) ? sgout : sg, if (template[i].wk)
template[i].ilen, iv); crypto_ablkcipher_set_flags(tfm, CRYPTO_TFM_REQ_WEAK_KEY);
ret = enc ?
crypto_ablkcipher_encrypt(req) :
crypto_ablkcipher_decrypt(req);
switch (ret) { ret = crypto_ablkcipher_setkey(tfm, template[i].key,
case 0: template[i].klen);
if (!ret == template[i].fail) {
pr_err("alg: skcipher%s: setkey failed on test %d for %s: flags=%x\n",
d, j, algo, crypto_ablkcipher_get_flags(tfm));
goto out;
} else if (ret)
continue;
sg_init_one(&sg[0], data, template[i].ilen);
if (diff_dst) {
data = xoutbuf[0];
data += align_offset;
sg_init_one(&sgout[0], data, template[i].ilen);
}
ablkcipher_request_set_crypt(req, sg, (diff_dst) ? sgout : sg,
template[i].ilen, iv);
ret = enc ? crypto_ablkcipher_encrypt(req) :
crypto_ablkcipher_decrypt(req);
switch (ret) {
case 0:
break;
case -EINPROGRESS:
case -EBUSY:
ret = wait_for_completion_interruptible(
&result.completion);
if (!ret && !((ret = result.err))) {
reinit_completion(&result.completion);
break; break;
case -EINPROGRESS:
case -EBUSY:
ret = wait_for_completion_interruptible(
&result.completion);
if (!ret && !((ret = result.err))) {
reinit_completion(&result.completion);
break;
}
/* fall through */
default:
pr_err("alg: skcipher%s: %s failed on test %d for %s: ret=%d\n",
d, e, j, algo, -ret);
goto out;
} }
/* fall through */
default:
pr_err("alg: skcipher%s: %s failed on test %d for %s: ret=%d\n",
d, e, j, algo, -ret);
goto out;
}
q = data; q = data;
if (memcmp(q, template[i].result, template[i].rlen)) { if (memcmp(q, template[i].result, template[i].rlen)) {
pr_err("alg: skcipher%s: Test %d failed on %s for %s\n", pr_err("alg: skcipher%s: Test %d failed on %s for %s\n",
d, j, e, algo); d, j, e, algo);
hexdump(q, template[i].rlen); hexdump(q, template[i].rlen);
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
}
} }
} }
...@@ -1047,116 +1043,109 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc, ...@@ -1047,116 +1043,109 @@ static int __test_skcipher(struct crypto_ablkcipher *tfm, int enc,
else else
memset(iv, 0, MAX_IVLEN); memset(iv, 0, MAX_IVLEN);
if (template[i].np) { if (!template[i].np)
j++; continue;
crypto_ablkcipher_clear_flags(tfm, ~0); j++;
if (template[i].wk)
crypto_ablkcipher_set_flags(
tfm, CRYPTO_TFM_REQ_WEAK_KEY);
ret = crypto_ablkcipher_setkey(tfm, template[i].key, crypto_ablkcipher_clear_flags(tfm, ~0);
template[i].klen); if (template[i].wk)
if (!ret == template[i].fail) { crypto_ablkcipher_set_flags(tfm, CRYPTO_TFM_REQ_WEAK_KEY);
pr_err("alg: skcipher%s: setkey failed on chunk test %d for %s: flags=%x\n",
d, j, algo,
crypto_ablkcipher_get_flags(tfm));
goto out;
} else if (ret)
continue;
temp = 0; ret = crypto_ablkcipher_setkey(tfm, template[i].key,
ret = -EINVAL; template[i].klen);
sg_init_table(sg, template[i].np); if (!ret == template[i].fail) {
if (diff_dst) pr_err("alg: skcipher%s: setkey failed on chunk test %d for %s: flags=%x\n",
sg_init_table(sgout, template[i].np); d, j, algo, crypto_ablkcipher_get_flags(tfm));
for (k = 0; k < template[i].np; k++) { goto out;
if (WARN_ON(offset_in_page(IDX[k]) + } else if (ret)
template[i].tap[k] > PAGE_SIZE)) continue;
goto out;
q = xbuf[IDX[k] >> PAGE_SHIFT] + temp = 0;
offset_in_page(IDX[k]); ret = -EINVAL;
sg_init_table(sg, template[i].np);
if (diff_dst)
sg_init_table(sgout, template[i].np);
for (k = 0; k < template[i].np; k++) {
if (WARN_ON(offset_in_page(IDX[k]) +
template[i].tap[k] > PAGE_SIZE))
goto out;
memcpy(q, template[i].input + temp, q = xbuf[IDX[k] >> PAGE_SHIFT] + offset_in_page(IDX[k]);
template[i].tap[k]);
if (offset_in_page(q) + template[i].tap[k] < memcpy(q, template[i].input + temp, template[i].tap[k]);
PAGE_SIZE)
q[template[i].tap[k]] = 0;
sg_set_buf(&sg[k], q, template[i].tap[k]); if (offset_in_page(q) + template[i].tap[k] < PAGE_SIZE)
if (diff_dst) { q[template[i].tap[k]] = 0;
q = xoutbuf[IDX[k] >> PAGE_SHIFT] +
offset_in_page(IDX[k]);
sg_set_buf(&sgout[k], q, sg_set_buf(&sg[k], q, template[i].tap[k]);
template[i].tap[k]); if (diff_dst) {
q = xoutbuf[IDX[k] >> PAGE_SHIFT] +
offset_in_page(IDX[k]);
memset(q, 0, template[i].tap[k]); sg_set_buf(&sgout[k], q, template[i].tap[k]);
if (offset_in_page(q) +
template[i].tap[k] < PAGE_SIZE)
q[template[i].tap[k]] = 0;
}
temp += template[i].tap[k]; memset(q, 0, template[i].tap[k]);
if (offset_in_page(q) +
template[i].tap[k] < PAGE_SIZE)
q[template[i].tap[k]] = 0;
} }
ablkcipher_request_set_crypt(req, sg, temp += template[i].tap[k];
(diff_dst) ? sgout : sg, }
template[i].ilen, iv);
ret = enc ? ablkcipher_request_set_crypt(req, sg, (diff_dst) ? sgout : sg,
crypto_ablkcipher_encrypt(req) : template[i].ilen, iv);
crypto_ablkcipher_decrypt(req);
switch (ret) { ret = enc ? crypto_ablkcipher_encrypt(req) :
case 0: crypto_ablkcipher_decrypt(req);
break;
case -EINPROGRESS: switch (ret) {
case -EBUSY: case 0:
ret = wait_for_completion_interruptible( break;
case -EINPROGRESS:
case -EBUSY:
ret = wait_for_completion_interruptible(
&result.completion); &result.completion);
if (!ret && !((ret = result.err))) { if (!ret && !((ret = result.err))) {
reinit_completion(&result.completion); reinit_completion(&result.completion);
break; break;
}
/* fall through */
default:
pr_err("alg: skcipher%s: %s failed on chunk test %d for %s: ret=%d\n",
d, e, j, algo, -ret);
goto out;
} }
/* fall through */
default:
pr_err("alg: skcipher%s: %s failed on chunk test %d for %s: ret=%d\n",
d, e, j, algo, -ret);
goto out;
}
temp = 0; temp = 0;
ret = -EINVAL; ret = -EINVAL;
for (k = 0; k < template[i].np; k++) { for (k = 0; k < template[i].np; k++) {
if (diff_dst) if (diff_dst)
q = xoutbuf[IDX[k] >> PAGE_SHIFT] + q = xoutbuf[IDX[k] >> PAGE_SHIFT] +
offset_in_page(IDX[k]); offset_in_page(IDX[k]);
else else
q = xbuf[IDX[k] >> PAGE_SHIFT] + q = xbuf[IDX[k] >> PAGE_SHIFT] +
offset_in_page(IDX[k]); offset_in_page(IDX[k]);
if (memcmp(q, template[i].result + temp, if (memcmp(q, template[i].result + temp,
template[i].tap[k])) { template[i].tap[k])) {
pr_err("alg: skcipher%s: Chunk test %d failed on %s at page %u for %s\n", pr_err("alg: skcipher%s: Chunk test %d failed on %s at page %u for %s\n",
d, j, e, k, algo); d, j, e, k, algo);
hexdump(q, template[i].tap[k]); hexdump(q, template[i].tap[k]);
goto out; goto out;
} }
q += template[i].tap[k]; q += template[i].tap[k];
for (n = 0; offset_in_page(q + n) && q[n]; n++) for (n = 0; offset_in_page(q + n) && q[n]; n++)
; ;
if (n) { if (n) {
pr_err("alg: skcipher%s: Result buffer corruption in chunk test %d on %s at page %u for %s: %u bytes:\n", pr_err("alg: skcipher%s: Result buffer corruption in chunk test %d on %s at page %u for %s: %u bytes:\n",
d, j, e, k, algo, n); d, j, e, k, algo, n);
hexdump(q, n); hexdump(q, n);
goto out; goto out;
}
temp += template[i].tap[k];
} }
temp += template[i].tap[k];
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment