diff options
author | Cristian Stoica <cristian.stoica@freescale.com> | 2014-08-08 07:27:50 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2014-08-25 08:27:17 -0400 |
commit | 5f2b424e5c6c2d4de2c72875ea970e5984fe9268 (patch) | |
tree | 211c2dfc10872e8880ef88f79d7de94dd5c262b2 /crypto/testmgr.c | |
parent | 05b1d3386f33ef09500db471e7a7b92ebd2f5d5f (diff) |
crypto: testmgr - white space removal on __test_hash
This patch inverts one if condition to remove code block indentation.
Several white space clean-ups follow.
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.c | 123 |
1 files changed, 60 insertions, 63 deletions
diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 68082d45573d..66d536421448 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c | |||
@@ -311,78 +311,75 @@ static int __test_hash(struct crypto_ahash *tfm, struct hash_testvec *template, | |||
311 | if (align_offset != 0) | 311 | if (align_offset != 0) |
312 | break; | 312 | break; |
313 | 313 | ||
314 | if (template[i].np) { | 314 | if (!template[i].np) |
315 | j++; | 315 | continue; |
316 | memset(result, 0, MAX_DIGEST_SIZE); | ||
317 | 316 | ||
318 | temp = 0; | 317 | j++; |
319 | sg_init_table(sg, template[i].np); | 318 | memset(result, 0, MAX_DIGEST_SIZE); |
320 | ret = -EINVAL; | ||
321 | for (k = 0; k < template[i].np; k++) { | ||
322 | if (WARN_ON(offset_in_page(IDX[k]) + | ||
323 | template[i].tap[k] > PAGE_SIZE)) | ||
324 | goto out; | ||
325 | sg_set_buf(&sg[k], | ||
326 | memcpy(xbuf[IDX[k] >> PAGE_SHIFT] + | ||
327 | offset_in_page(IDX[k]), | ||
328 | template[i].plaintext + temp, | ||
329 | template[i].tap[k]), | ||
330 | template[i].tap[k]); | ||
331 | temp += template[i].tap[k]; | ||
332 | } | ||
333 | 319 | ||
334 | if (template[i].ksize) { | 320 | temp = 0; |
335 | if (template[i].ksize > MAX_KEYLEN) { | 321 | sg_init_table(sg, template[i].np); |
336 | pr_err("alg: hash: setkey failed on test %d for %s: key size %d > %d\n", | 322 | ret = -EINVAL; |
337 | j, algo, template[i].ksize, | 323 | for (k = 0; k < template[i].np; k++) { |
338 | MAX_KEYLEN); | 324 | if (WARN_ON(offset_in_page(IDX[k]) + |
339 | ret = -EINVAL; | 325 | template[i].tap[k] > PAGE_SIZE)) |
340 | goto out; | 326 | goto out; |
341 | } | 327 | sg_set_buf(&sg[k], |
342 | crypto_ahash_clear_flags(tfm, ~0); | 328 | memcpy(xbuf[IDX[k] >> PAGE_SHIFT] + |
343 | memcpy(key, template[i].key, template[i].ksize); | 329 | offset_in_page(IDX[k]), |
344 | ret = crypto_ahash_setkey(tfm, key, | 330 | template[i].plaintext + temp, |
345 | template[i].ksize); | 331 | template[i].tap[k]), |
332 | template[i].tap[k]); | ||
333 | temp += template[i].tap[k]; | ||
334 | } | ||
346 | 335 | ||
347 | if (ret) { | 336 | if (template[i].ksize) { |
348 | printk(KERN_ERR "alg: hash: setkey " | 337 | if (template[i].ksize > MAX_KEYLEN) { |
349 | "failed on chunking test %d " | 338 | pr_err("alg: hash: setkey failed on test %d for %s: key size %d > %d\n", |
350 | "for %s: ret=%d\n", j, algo, | 339 | j, algo, template[i].ksize, MAX_KEYLEN); |
351 | -ret); | 340 | ret = -EINVAL; |
352 | goto out; | 341 | goto out; |
353 | } | ||
354 | } | 342 | } |
343 | crypto_ahash_clear_flags(tfm, ~0); | ||
344 | memcpy(key, template[i].key, template[i].ksize); | ||
345 | ret = crypto_ahash_setkey(tfm, key, template[i].ksize); | ||
355 | 346 | ||
356 | ahash_request_set_crypt(req, sg, result, | 347 | if (ret) { |
357 | template[i].psize); | 348 | printk(KERN_ERR "alg: hash: setkey " |
358 | ret = crypto_ahash_digest(req); | 349 | "failed on chunking test %d " |
359 | switch (ret) { | 350 | "for %s: ret=%d\n", j, algo, -ret); |
360 | case 0: | ||
361 | break; | ||
362 | case -EINPROGRESS: | ||
363 | case -EBUSY: | ||
364 | ret = wait_for_completion_interruptible( | ||
365 | &tresult.completion); | ||
366 | if (!ret && !(ret = tresult.err)) { | ||
367 | reinit_completion(&tresult.completion); | ||
368 | break; | ||
369 | } | ||
370 | /* fall through */ | ||
371 | default: | ||
372 | printk(KERN_ERR "alg: hash: digest failed " | ||
373 | "on chunking test %d for %s: " | ||
374 | "ret=%d\n", j, algo, -ret); | ||
375 | goto out; | 351 | goto out; |
376 | } | 352 | } |
353 | } | ||
377 | 354 | ||
378 | if (memcmp(result, template[i].digest, | 355 | ahash_request_set_crypt(req, sg, result, template[i].psize); |
379 | crypto_ahash_digestsize(tfm))) { | 356 | ret = crypto_ahash_digest(req); |
380 | printk(KERN_ERR "alg: hash: Chunking test %d " | 357 | switch (ret) { |
381 | "failed for %s\n", j, algo); | 358 | case 0: |
382 | hexdump(result, crypto_ahash_digestsize(tfm)); | 359 | break; |
383 | ret = -EINVAL; | 360 | case -EINPROGRESS: |
384 | goto out; | 361 | case -EBUSY: |
362 | ret = wait_for_completion_interruptible( | ||
363 | &tresult.completion); | ||
364 | if (!ret && !(ret = tresult.err)) { | ||
365 | reinit_completion(&tresult.completion); | ||
366 | break; | ||
385 | } | 367 | } |
368 | /* fall through */ | ||
369 | default: | ||
370 | printk(KERN_ERR "alg: hash: digest failed " | ||
371 | "on chunking test %d for %s: " | ||
372 | "ret=%d\n", j, algo, -ret); | ||
373 | goto out; | ||
374 | } | ||
375 | |||
376 | if (memcmp(result, template[i].digest, | ||
377 | crypto_ahash_digestsize(tfm))) { | ||
378 | printk(KERN_ERR "alg: hash: Chunking test %d " | ||
379 | "failed for %s\n", j, algo); | ||
380 | hexdump(result, crypto_ahash_digestsize(tfm)); | ||
381 | ret = -EINVAL; | ||
382 | goto out; | ||
386 | } | 383 | } |
387 | } | 384 | } |
388 | 385 | ||