Lines Matching refs:template
187 static int test_hash(struct crypto_ahash *tfm, struct hash_testvec *template, in test_hash() argument
216 if (template[i].np) in test_hash()
224 memcpy(hash_buff, template[i].plaintext, template[i].psize); in test_hash()
225 sg_init_one(&sg[0], hash_buff, template[i].psize); in test_hash()
227 if (template[i].ksize) { in test_hash()
229 ret = crypto_ahash_setkey(tfm, template[i].key, in test_hash()
230 template[i].ksize); in test_hash()
239 ahash_request_set_crypt(req, sg, result, template[i].psize); in test_hash()
272 if (memcmp(result, template[i].digest, in test_hash()
284 if (template[i].np) { in test_hash()
289 sg_init_table(sg, template[i].np); in test_hash()
291 for (k = 0; k < template[i].np; k++) { in test_hash()
293 template[i].tap[k] > PAGE_SIZE)) in test_hash()
298 template[i].plaintext + temp, in test_hash()
299 template[i].tap[k]), in test_hash()
300 template[i].tap[k]); in test_hash()
301 temp += template[i].tap[k]; in test_hash()
304 if (template[i].ksize) { in test_hash()
306 ret = crypto_ahash_setkey(tfm, template[i].key, in test_hash()
307 template[i].ksize); in test_hash()
319 template[i].psize); in test_hash()
340 if (memcmp(result, template[i].digest, in test_hash()
362 struct aead_testvec *template, unsigned int tcount, in __test_aead() argument
423 if (!template[i].np) { in __test_aead()
433 if (WARN_ON(template[i].ilen > PAGE_SIZE || in __test_aead()
434 template[i].alen > PAGE_SIZE)) in __test_aead()
437 memcpy(input, template[i].input, template[i].ilen); in __test_aead()
438 memcpy(assoc, template[i].assoc, template[i].alen); in __test_aead()
439 if (template[i].iv) in __test_aead()
440 memcpy(iv, template[i].iv, MAX_IVLEN); in __test_aead()
445 if (template[i].wk) in __test_aead()
449 key = template[i].key; in __test_aead()
452 template[i].klen); in __test_aead()
453 if (!ret == template[i].fail) { in __test_aead()
460 authsize = abs(template[i].rlen - template[i].ilen); in __test_aead()
469 template[i].ilen + (enc ? authsize : 0)); in __test_aead()
474 template[i].ilen + in __test_aead()
480 sg_init_one(&asg[0], assoc, template[i].alen); in __test_aead()
483 template[i].ilen, iv); in __test_aead()
485 aead_request_set_assoc(req, asg, template[i].alen); in __test_aead()
493 if (template[i].novrfy) { in __test_aead()
511 if (template[i].novrfy) in __test_aead()
522 if (memcmp(q, template[i].result, template[i].rlen)) { in __test_aead()
525 hexdump(q, template[i].rlen); in __test_aead()
533 if (template[i].np) { in __test_aead()
536 if (template[i].iv) in __test_aead()
537 memcpy(iv, template[i].iv, MAX_IVLEN); in __test_aead()
542 if (template[i].wk) in __test_aead()
545 key = template[i].key; in __test_aead()
547 ret = crypto_aead_setkey(tfm, key, template[i].klen); in __test_aead()
548 if (!ret == template[i].fail) { in __test_aead()
555 authsize = abs(template[i].rlen - template[i].ilen); in __test_aead()
558 sg_init_table(sg, template[i].np); in __test_aead()
560 sg_init_table(sgout, template[i].np); in __test_aead()
561 for (k = 0, temp = 0; k < template[i].np; k++) { in __test_aead()
563 template[i].tap[k] > PAGE_SIZE)) in __test_aead()
569 memcpy(q, template[i].input + temp, in __test_aead()
570 template[i].tap[k]); in __test_aead()
572 n = template[i].tap[k]; in __test_aead()
573 if (k == template[i].np - 1 && enc) in __test_aead()
578 sg_set_buf(&sg[k], q, template[i].tap[k]); in __test_aead()
584 memset(q, 0, template[i].tap[k]); in __test_aead()
589 template[i].tap[k]); in __test_aead()
592 temp += template[i].tap[k]; in __test_aead()
616 sg_init_table(asg, template[i].anp); in __test_aead()
618 for (k = 0, temp = 0; k < template[i].anp; k++) { in __test_aead()
620 template[i].atap[k] > PAGE_SIZE)) in __test_aead()
625 template[i].assoc + temp, in __test_aead()
626 template[i].atap[k]), in __test_aead()
627 template[i].atap[k]); in __test_aead()
628 temp += template[i].atap[k]; in __test_aead()
632 template[i].ilen, in __test_aead()
635 aead_request_set_assoc(req, asg, template[i].alen); in __test_aead()
643 if (template[i].novrfy) { in __test_aead()
661 if (template[i].novrfy) in __test_aead()
672 for (k = 0, temp = 0; k < template[i].np; k++) { in __test_aead()
680 n = template[i].tap[k]; in __test_aead()
681 if (k == template[i].np - 1) in __test_aead()
684 if (memcmp(q, template[i].result + temp, n)) { in __test_aead()
692 if (k == template[i].np - 1 && !enc) { in __test_aead()
694 memcmp(q, template[i].input + in __test_aead()
711 temp += template[i].tap[k]; in __test_aead()
733 struct aead_testvec *template, unsigned int tcount) in test_aead() argument
738 ret = __test_aead(tfm, enc, template, tcount, false); in test_aead()
743 return __test_aead(tfm, enc, template, tcount, true); in test_aead()
747 struct cipher_testvec *template, unsigned int tcount) in test_cipher() argument
767 if (template[i].np) in test_cipher()
773 if (WARN_ON(template[i].ilen > PAGE_SIZE)) in test_cipher()
777 memcpy(data, template[i].input, template[i].ilen); in test_cipher()
780 if (template[i].wk) in test_cipher()
783 ret = crypto_cipher_setkey(tfm, template[i].key, in test_cipher()
784 template[i].klen); in test_cipher()
785 if (!ret == template[i].fail) { in test_cipher()
793 for (k = 0; k < template[i].ilen; in test_cipher()
804 if (memcmp(q, template[i].result, template[i].rlen)) { in test_cipher()
807 hexdump(q, template[i].rlen); in test_cipher()
822 struct cipher_testvec *template, unsigned int tcount, in __test_skcipher() argument
870 if (template[i].iv) in __test_skcipher()
871 memcpy(iv, template[i].iv, MAX_IVLEN); in __test_skcipher()
875 if (!(template[i].np) || (template[i].also_non_np)) { in __test_skcipher()
879 if (WARN_ON(template[i].ilen > PAGE_SIZE)) in __test_skcipher()
883 memcpy(data, template[i].input, template[i].ilen); in __test_skcipher()
886 if (template[i].wk) in __test_skcipher()
890 ret = crypto_ablkcipher_setkey(tfm, template[i].key, in __test_skcipher()
891 template[i].klen); in __test_skcipher()
892 if (!ret == template[i].fail) { in __test_skcipher()
900 sg_init_one(&sg[0], data, template[i].ilen); in __test_skcipher()
903 sg_init_one(&sgout[0], data, template[i].ilen); in __test_skcipher()
908 template[i].ilen, iv); in __test_skcipher()
932 if (memcmp(q, template[i].result, template[i].rlen)) { in __test_skcipher()
935 hexdump(q, template[i].rlen); in __test_skcipher()
945 if (template[i].iv) in __test_skcipher()
946 memcpy(iv, template[i].iv, MAX_IVLEN); in __test_skcipher()
950 if (template[i].np) { in __test_skcipher()
954 if (template[i].wk) in __test_skcipher()
958 ret = crypto_ablkcipher_setkey(tfm, template[i].key, in __test_skcipher()
959 template[i].klen); in __test_skcipher()
960 if (!ret == template[i].fail) { in __test_skcipher()
970 sg_init_table(sg, template[i].np); in __test_skcipher()
972 sg_init_table(sgout, template[i].np); in __test_skcipher()
973 for (k = 0; k < template[i].np; k++) { in __test_skcipher()
975 template[i].tap[k] > PAGE_SIZE)) in __test_skcipher()
981 memcpy(q, template[i].input + temp, in __test_skcipher()
982 template[i].tap[k]); in __test_skcipher()
984 if (offset_in_page(q) + template[i].tap[k] < in __test_skcipher()
986 q[template[i].tap[k]] = 0; in __test_skcipher()
988 sg_set_buf(&sg[k], q, template[i].tap[k]); in __test_skcipher()
994 template[i].tap[k]); in __test_skcipher()
996 memset(q, 0, template[i].tap[k]); in __test_skcipher()
998 template[i].tap[k] < PAGE_SIZE) in __test_skcipher()
999 q[template[i].tap[k]] = 0; in __test_skcipher()
1002 temp += template[i].tap[k]; in __test_skcipher()
1007 template[i].ilen, iv); in __test_skcipher()
1033 for (k = 0; k < template[i].np; k++) { in __test_skcipher()
1041 if (memcmp(q, template[i].result + temp, in __test_skcipher()
1042 template[i].tap[k])) { in __test_skcipher()
1045 hexdump(q, template[i].tap[k]); in __test_skcipher()
1049 q += template[i].tap[k]; in __test_skcipher()
1058 temp += template[i].tap[k]; in __test_skcipher()
1076 struct cipher_testvec *template, unsigned int tcount) in test_skcipher() argument
1081 ret = __test_skcipher(tfm, enc, template, tcount, false); in test_skcipher()
1086 return __test_skcipher(tfm, enc, template, tcount, true); in test_skcipher()
1346 static int test_cprng(struct crypto_rng *tfm, struct cprng_testvec *template, in test_cprng() argument
1366 memcpy(seed, template[i].v, template[i].vlen); in test_cprng()
1367 memcpy(seed + template[i].vlen, template[i].key, in test_cprng()
1368 template[i].klen); in test_cprng()
1369 memcpy(seed + template[i].vlen + template[i].klen, in test_cprng()
1370 template[i].dt, template[i].dtlen); in test_cprng()
1379 for (j = 0; j < template[i].loops; j++) { in test_cprng()
1381 template[i].rlen); in test_cprng()
1382 if (err != template[i].rlen) { in test_cprng()
1386 template[i].rlen, err); in test_cprng()
1391 err = memcmp(result, template[i].result, in test_cprng()
1392 template[i].rlen); in test_cprng()
1396 hexdump(result, template[i].rlen); in test_cprng()