Lines Matching refs:template
192 static int __test_hash(struct crypto_ahash *tfm, struct hash_testvec *template, in __test_hash() argument
229 if (template[i].np) in __test_hash()
233 if (WARN_ON(align_offset + template[i].psize > PAGE_SIZE)) in __test_hash()
242 memcpy(hash_buff, template[i].plaintext, template[i].psize); in __test_hash()
243 sg_init_one(&sg[0], hash_buff, template[i].psize); in __test_hash()
245 if (template[i].ksize) { in __test_hash()
247 if (template[i].ksize > MAX_KEYLEN) { in __test_hash()
249 j, algo, template[i].ksize, MAX_KEYLEN); in __test_hash()
253 memcpy(key, template[i].key, template[i].ksize); in __test_hash()
254 ret = crypto_ahash_setkey(tfm, key, template[i].ksize); in __test_hash()
263 ahash_request_set_crypt(req, sg, result, template[i].psize); in __test_hash()
292 if (memcmp(result, template[i].digest, in __test_hash()
308 if (!template[i].np) in __test_hash()
315 sg_init_table(sg, template[i].np); in __test_hash()
317 for (k = 0; k < template[i].np; k++) { in __test_hash()
319 template[i].tap[k] > PAGE_SIZE)) in __test_hash()
324 template[i].plaintext + temp, in __test_hash()
325 template[i].tap[k]), in __test_hash()
326 template[i].tap[k]); in __test_hash()
327 temp += template[i].tap[k]; in __test_hash()
330 if (template[i].ksize) { in __test_hash()
331 if (template[i].ksize > MAX_KEYLEN) { in __test_hash()
333 j, algo, template[i].ksize, MAX_KEYLEN); in __test_hash()
338 memcpy(key, template[i].key, template[i].ksize); in __test_hash()
339 ret = crypto_ahash_setkey(tfm, key, template[i].ksize); in __test_hash()
349 ahash_request_set_crypt(req, sg, result, template[i].psize); in __test_hash()
370 if (memcmp(result, template[i].digest, in __test_hash()
392 static int test_hash(struct crypto_ahash *tfm, struct hash_testvec *template, in test_hash() argument
398 ret = __test_hash(tfm, template, tcount, use_digest, 0); in test_hash()
403 ret = __test_hash(tfm, template, tcount, use_digest, 1); in test_hash()
410 ret = __test_hash(tfm, template, tcount, use_digest, in test_hash()
420 struct aead_testvec *template, unsigned int tcount, in __test_aead() argument
486 if (template[i].np) in __test_aead()
499 if (WARN_ON(align_offset + template[i].ilen > in __test_aead()
500 PAGE_SIZE || template[i].alen > PAGE_SIZE)) in __test_aead()
503 memcpy(input, template[i].input, template[i].ilen); in __test_aead()
504 memcpy(assoc, template[i].assoc, template[i].alen); in __test_aead()
505 if (template[i].iv) in __test_aead()
506 memcpy(iv, template[i].iv, MAX_IVLEN); in __test_aead()
511 if (template[i].wk) in __test_aead()
514 if (template[i].klen > MAX_KEYLEN) { in __test_aead()
516 d, j, algo, template[i].klen, in __test_aead()
521 memcpy(key, template[i].key, template[i].klen); in __test_aead()
523 ret = crypto_aead_setkey(tfm, key, template[i].klen); in __test_aead()
524 if (!ret == template[i].fail) { in __test_aead()
531 authsize = abs(template[i].rlen - template[i].ilen); in __test_aead()
542 sg_init_one(&sg[0], input, template[i].ilen); in __test_aead()
543 sg_init_one(&sgout[0], output, template[i].rlen); in __test_aead()
546 template[i].ilen + (enc ? authsize : 0)); in __test_aead()
550 sg_init_one(&asg[0], assoc, template[i].alen); in __test_aead()
553 template[i].ilen, iv); in __test_aead()
555 aead_request_set_assoc(req, asg, template[i].alen); in __test_aead()
561 if (template[i].novrfy) { in __test_aead()
579 if (template[i].novrfy) in __test_aead()
590 if (memcmp(q, template[i].result, template[i].rlen)) { in __test_aead()
593 hexdump(q, template[i].rlen); in __test_aead()
604 if (!template[i].np) in __test_aead()
609 if (template[i].iv) in __test_aead()
610 memcpy(iv, template[i].iv, MAX_IVLEN); in __test_aead()
615 if (template[i].wk) in __test_aead()
617 if (template[i].klen > MAX_KEYLEN) { in __test_aead()
619 d, j, algo, template[i].klen, MAX_KEYLEN); in __test_aead()
623 memcpy(key, template[i].key, template[i].klen); in __test_aead()
625 ret = crypto_aead_setkey(tfm, key, template[i].klen); in __test_aead()
626 if (!ret == template[i].fail) { in __test_aead()
633 authsize = abs(template[i].rlen - template[i].ilen); in __test_aead()
636 sg_init_table(sg, template[i].np); in __test_aead()
638 sg_init_table(sgout, template[i].np); in __test_aead()
639 for (k = 0, temp = 0; k < template[i].np; k++) { in __test_aead()
641 template[i].tap[k] > PAGE_SIZE)) in __test_aead()
645 memcpy(q, template[i].input + temp, template[i].tap[k]); in __test_aead()
646 sg_set_buf(&sg[k], q, template[i].tap[k]); in __test_aead()
652 memset(q, 0, template[i].tap[k]); in __test_aead()
654 sg_set_buf(&sgout[k], q, template[i].tap[k]); in __test_aead()
657 n = template[i].tap[k]; in __test_aead()
658 if (k == template[i].np - 1 && enc) in __test_aead()
663 temp += template[i].tap[k]; in __test_aead()
687 sg_init_table(asg, template[i].anp); in __test_aead()
689 for (k = 0, temp = 0; k < template[i].anp; k++) { in __test_aead()
691 template[i].atap[k] > PAGE_SIZE)) in __test_aead()
696 template[i].assoc + temp, in __test_aead()
697 template[i].atap[k]), in __test_aead()
698 template[i].atap[k]); in __test_aead()
699 temp += template[i].atap[k]; in __test_aead()
703 template[i].ilen, in __test_aead()
706 aead_request_set_assoc(req, asg, template[i].alen); in __test_aead()
712 if (template[i].novrfy) { in __test_aead()
730 if (template[i].novrfy) in __test_aead()
741 for (k = 0, temp = 0; k < template[i].np; k++) { in __test_aead()
749 n = template[i].tap[k]; in __test_aead()
750 if (k == template[i].np - 1) in __test_aead()
753 if (memcmp(q, template[i].result + temp, n)) { in __test_aead()
761 if (k == template[i].np - 1 && !enc) { in __test_aead()
763 memcmp(q, template[i].input + in __test_aead()
779 temp += template[i].tap[k]; in __test_aead()
802 struct aead_testvec *template, unsigned int tcount) in test_aead() argument
808 ret = __test_aead(tfm, enc, template, tcount, false, 0); in test_aead()
813 ret = __test_aead(tfm, enc, template, tcount, true, 0); in test_aead()
818 ret = __test_aead(tfm, enc, template, tcount, true, 1); in test_aead()
825 ret = __test_aead(tfm, enc, template, tcount, true, in test_aead()
835 struct cipher_testvec *template, unsigned int tcount) in test_cipher() argument
855 if (template[i].np) in test_cipher()
861 if (WARN_ON(template[i].ilen > PAGE_SIZE)) in test_cipher()
865 memcpy(data, template[i].input, template[i].ilen); in test_cipher()
868 if (template[i].wk) in test_cipher()
871 ret = crypto_cipher_setkey(tfm, template[i].key, in test_cipher()
872 template[i].klen); in test_cipher()
873 if (!ret == template[i].fail) { in test_cipher()
881 for (k = 0; k < template[i].ilen; in test_cipher()
892 if (memcmp(q, template[i].result, template[i].rlen)) { in test_cipher()
895 hexdump(q, template[i].rlen); in test_cipher()
910 struct cipher_testvec *template, unsigned int tcount, in __test_skcipher() argument
958 if (template[i].np && !template[i].also_non_np) in __test_skcipher()
961 if (template[i].iv) in __test_skcipher()
962 memcpy(iv, template[i].iv, MAX_IVLEN); in __test_skcipher()
968 if (WARN_ON(align_offset + template[i].ilen > PAGE_SIZE)) in __test_skcipher()
973 memcpy(data, template[i].input, template[i].ilen); in __test_skcipher()
976 if (template[i].wk) in __test_skcipher()
979 ret = crypto_ablkcipher_setkey(tfm, template[i].key, in __test_skcipher()
980 template[i].klen); in __test_skcipher()
981 if (!ret == template[i].fail) { in __test_skcipher()
988 sg_init_one(&sg[0], data, template[i].ilen); in __test_skcipher()
992 sg_init_one(&sgout[0], data, template[i].ilen); in __test_skcipher()
996 template[i].ilen, iv); in __test_skcipher()
1019 if (memcmp(q, template[i].result, template[i].rlen)) { in __test_skcipher()
1022 hexdump(q, template[i].rlen); in __test_skcipher()
1034 if (!template[i].np) in __test_skcipher()
1037 if (template[i].iv) in __test_skcipher()
1038 memcpy(iv, template[i].iv, MAX_IVLEN); in __test_skcipher()
1044 if (template[i].wk) in __test_skcipher()
1047 ret = crypto_ablkcipher_setkey(tfm, template[i].key, in __test_skcipher()
1048 template[i].klen); in __test_skcipher()
1049 if (!ret == template[i].fail) { in __test_skcipher()
1058 sg_init_table(sg, template[i].np); in __test_skcipher()
1060 sg_init_table(sgout, template[i].np); in __test_skcipher()
1061 for (k = 0; k < template[i].np; k++) { in __test_skcipher()
1063 template[i].tap[k] > PAGE_SIZE)) in __test_skcipher()
1068 memcpy(q, template[i].input + temp, template[i].tap[k]); in __test_skcipher()
1070 if (offset_in_page(q) + template[i].tap[k] < PAGE_SIZE) in __test_skcipher()
1071 q[template[i].tap[k]] = 0; in __test_skcipher()
1073 sg_set_buf(&sg[k], q, template[i].tap[k]); in __test_skcipher()
1078 sg_set_buf(&sgout[k], q, template[i].tap[k]); in __test_skcipher()
1080 memset(q, 0, template[i].tap[k]); in __test_skcipher()
1082 template[i].tap[k] < PAGE_SIZE) in __test_skcipher()
1083 q[template[i].tap[k]] = 0; in __test_skcipher()
1086 temp += template[i].tap[k]; in __test_skcipher()
1090 template[i].ilen, iv); in __test_skcipher()
1115 for (k = 0; k < template[i].np; k++) { in __test_skcipher()
1123 if (memcmp(q, template[i].result + temp, in __test_skcipher()
1124 template[i].tap[k])) { in __test_skcipher()
1127 hexdump(q, template[i].tap[k]); in __test_skcipher()
1131 q += template[i].tap[k]; in __test_skcipher()
1140 temp += template[i].tap[k]; in __test_skcipher()
1157 struct cipher_testvec *template, unsigned int tcount) in test_skcipher() argument
1163 ret = __test_skcipher(tfm, enc, template, tcount, false, 0); in test_skcipher()
1168 ret = __test_skcipher(tfm, enc, template, tcount, true, 0); in test_skcipher()
1173 ret = __test_skcipher(tfm, enc, template, tcount, true, 1); in test_skcipher()
1180 ret = __test_skcipher(tfm, enc, template, tcount, true, in test_skcipher()
1446 static int test_cprng(struct crypto_rng *tfm, struct cprng_testvec *template, in test_cprng() argument
1466 memcpy(seed, template[i].v, template[i].vlen); in test_cprng()
1467 memcpy(seed + template[i].vlen, template[i].key, in test_cprng()
1468 template[i].klen); in test_cprng()
1469 memcpy(seed + template[i].vlen + template[i].klen, in test_cprng()
1470 template[i].dt, template[i].dtlen); in test_cprng()
1479 for (j = 0; j < template[i].loops; j++) { in test_cprng()
1481 template[i].rlen); in test_cprng()
1482 if (err != template[i].rlen) { in test_cprng()
1486 template[i].rlen, err); in test_cprng()
1491 err = memcmp(result, template[i].result, in test_cprng()
1492 template[i].rlen); in test_cprng()
1496 hexdump(result, template[i].rlen); in test_cprng()
1803 struct drbg_testvec *template = desc->suite.drbg.vecs; in alg_test_drbg() local
1810 err = drbg_cavs_test(&template[i], pr, driver, type, mask); in alg_test_drbg()