Lines Matching refs:template
191 static int __test_hash(struct crypto_ahash *tfm, struct hash_testvec *template, in __test_hash() argument
228 if (template[i].np) in __test_hash()
232 if (WARN_ON(align_offset + template[i].psize > PAGE_SIZE)) in __test_hash()
241 memcpy(hash_buff, template[i].plaintext, template[i].psize); in __test_hash()
242 sg_init_one(&sg[0], hash_buff, template[i].psize); in __test_hash()
244 if (template[i].ksize) { in __test_hash()
246 if (template[i].ksize > MAX_KEYLEN) { in __test_hash()
248 j, algo, template[i].ksize, MAX_KEYLEN); in __test_hash()
252 memcpy(key, template[i].key, template[i].ksize); in __test_hash()
253 ret = crypto_ahash_setkey(tfm, key, template[i].ksize); in __test_hash()
262 ahash_request_set_crypt(req, sg, result, template[i].psize); in __test_hash()
291 if (memcmp(result, template[i].digest, in __test_hash()
307 if (!template[i].np) in __test_hash()
314 sg_init_table(sg, template[i].np); in __test_hash()
316 for (k = 0; k < template[i].np; k++) { in __test_hash()
318 template[i].tap[k] > PAGE_SIZE)) in __test_hash()
323 template[i].plaintext + temp, in __test_hash()
324 template[i].tap[k]), in __test_hash()
325 template[i].tap[k]); in __test_hash()
326 temp += template[i].tap[k]; in __test_hash()
329 if (template[i].ksize) { in __test_hash()
330 if (template[i].ksize > MAX_KEYLEN) { in __test_hash()
332 j, algo, template[i].ksize, MAX_KEYLEN); in __test_hash()
337 memcpy(key, template[i].key, template[i].ksize); in __test_hash()
338 ret = crypto_ahash_setkey(tfm, key, template[i].ksize); in __test_hash()
348 ahash_request_set_crypt(req, sg, result, template[i].psize); in __test_hash()
368 if (memcmp(result, template[i].digest, in __test_hash()
390 static int test_hash(struct crypto_ahash *tfm, struct hash_testvec *template, in test_hash() argument
396 ret = __test_hash(tfm, template, tcount, use_digest, 0); in test_hash()
401 ret = __test_hash(tfm, template, tcount, use_digest, 1); in test_hash()
408 ret = __test_hash(tfm, template, tcount, use_digest, in test_hash()
418 struct aead_testvec *template, unsigned int tcount, in __test_aead() argument
484 if (template[i].np) in __test_aead()
497 if (WARN_ON(align_offset + template[i].ilen > in __test_aead()
498 PAGE_SIZE || template[i].alen > PAGE_SIZE)) in __test_aead()
501 memcpy(input, template[i].input, template[i].ilen); in __test_aead()
502 memcpy(assoc, template[i].assoc, template[i].alen); in __test_aead()
504 if (template[i].iv) in __test_aead()
505 memcpy(iv, template[i].iv, iv_len); in __test_aead()
510 if (template[i].wk) in __test_aead()
513 if (template[i].klen > MAX_KEYLEN) { in __test_aead()
515 d, j, algo, template[i].klen, in __test_aead()
520 memcpy(key, template[i].key, template[i].klen); in __test_aead()
522 ret = crypto_aead_setkey(tfm, key, template[i].klen); in __test_aead()
523 if (!ret == template[i].fail) { in __test_aead()
530 authsize = abs(template[i].rlen - template[i].ilen); in __test_aead()
541 sg_init_one(&sg[0], input, template[i].ilen); in __test_aead()
542 sg_init_one(&sgout[0], output, template[i].rlen); in __test_aead()
545 template[i].ilen + (enc ? authsize : 0)); in __test_aead()
549 sg_init_one(&asg[0], assoc, template[i].alen); in __test_aead()
552 template[i].ilen, iv); in __test_aead()
554 aead_request_set_assoc(req, asg, template[i].alen); in __test_aead()
560 if (template[i].novrfy) { in __test_aead()
577 if (template[i].novrfy) in __test_aead()
588 if (memcmp(q, template[i].result, template[i].rlen)) { in __test_aead()
591 hexdump(q, template[i].rlen); in __test_aead()
602 if (!template[i].np) in __test_aead()
607 if (template[i].iv) in __test_aead()
608 memcpy(iv, template[i].iv, MAX_IVLEN); in __test_aead()
613 if (template[i].wk) in __test_aead()
615 if (template[i].klen > MAX_KEYLEN) { in __test_aead()
617 d, j, algo, template[i].klen, MAX_KEYLEN); in __test_aead()
621 memcpy(key, template[i].key, template[i].klen); in __test_aead()
623 ret = crypto_aead_setkey(tfm, key, template[i].klen); in __test_aead()
624 if (!ret == template[i].fail) { in __test_aead()
631 authsize = abs(template[i].rlen - template[i].ilen); in __test_aead()
634 sg_init_table(sg, template[i].np); in __test_aead()
636 sg_init_table(sgout, template[i].np); in __test_aead()
637 for (k = 0, temp = 0; k < template[i].np; k++) { in __test_aead()
639 template[i].tap[k] > PAGE_SIZE)) in __test_aead()
643 memcpy(q, template[i].input + temp, template[i].tap[k]); in __test_aead()
644 sg_set_buf(&sg[k], q, template[i].tap[k]); in __test_aead()
650 memset(q, 0, template[i].tap[k]); in __test_aead()
652 sg_set_buf(&sgout[k], q, template[i].tap[k]); in __test_aead()
655 n = template[i].tap[k]; in __test_aead()
656 if (k == template[i].np - 1 && enc) in __test_aead()
661 temp += template[i].tap[k]; in __test_aead()
685 sg_init_table(asg, template[i].anp); in __test_aead()
687 for (k = 0, temp = 0; k < template[i].anp; k++) { in __test_aead()
689 template[i].atap[k] > PAGE_SIZE)) in __test_aead()
694 template[i].assoc + temp, in __test_aead()
695 template[i].atap[k]), in __test_aead()
696 template[i].atap[k]); in __test_aead()
697 temp += template[i].atap[k]; in __test_aead()
701 template[i].ilen, in __test_aead()
704 aead_request_set_assoc(req, asg, template[i].alen); in __test_aead()
710 if (template[i].novrfy) { in __test_aead()
727 if (template[i].novrfy) in __test_aead()
738 for (k = 0, temp = 0; k < template[i].np; k++) { in __test_aead()
746 n = template[i].tap[k]; in __test_aead()
747 if (k == template[i].np - 1) in __test_aead()
750 if (memcmp(q, template[i].result + temp, n)) { in __test_aead()
758 if (k == template[i].np - 1 && !enc) { in __test_aead()
760 memcmp(q, template[i].input + in __test_aead()
776 temp += template[i].tap[k]; in __test_aead()
799 struct aead_testvec *template, unsigned int tcount) in test_aead() argument
805 ret = __test_aead(tfm, enc, template, tcount, false, 0); in test_aead()
810 ret = __test_aead(tfm, enc, template, tcount, true, 0); in test_aead()
815 ret = __test_aead(tfm, enc, template, tcount, true, 1); in test_aead()
822 ret = __test_aead(tfm, enc, template, tcount, true, in test_aead()
832 struct cipher_testvec *template, unsigned int tcount) in test_cipher() argument
852 if (template[i].np) in test_cipher()
858 if (WARN_ON(template[i].ilen > PAGE_SIZE)) in test_cipher()
862 memcpy(data, template[i].input, template[i].ilen); in test_cipher()
865 if (template[i].wk) in test_cipher()
868 ret = crypto_cipher_setkey(tfm, template[i].key, in test_cipher()
869 template[i].klen); in test_cipher()
870 if (!ret == template[i].fail) { in test_cipher()
878 for (k = 0; k < template[i].ilen; in test_cipher()
889 if (memcmp(q, template[i].result, template[i].rlen)) { in test_cipher()
892 hexdump(q, template[i].rlen); in test_cipher()
907 struct cipher_testvec *template, unsigned int tcount, in __test_skcipher() argument
955 if (template[i].np && !template[i].also_non_np) in __test_skcipher()
958 if (template[i].iv) in __test_skcipher()
959 memcpy(iv, template[i].iv, MAX_IVLEN); in __test_skcipher()
965 if (WARN_ON(align_offset + template[i].ilen > PAGE_SIZE)) in __test_skcipher()
970 memcpy(data, template[i].input, template[i].ilen); in __test_skcipher()
973 if (template[i].wk) in __test_skcipher()
976 ret = crypto_ablkcipher_setkey(tfm, template[i].key, in __test_skcipher()
977 template[i].klen); in __test_skcipher()
978 if (!ret == template[i].fail) { in __test_skcipher()
985 sg_init_one(&sg[0], data, template[i].ilen); in __test_skcipher()
989 sg_init_one(&sgout[0], data, template[i].ilen); in __test_skcipher()
993 template[i].ilen, iv); in __test_skcipher()
1015 if (memcmp(q, template[i].result, template[i].rlen)) { in __test_skcipher()
1018 hexdump(q, template[i].rlen); in __test_skcipher()
1030 if (!template[i].np) in __test_skcipher()
1033 if (template[i].iv) in __test_skcipher()
1034 memcpy(iv, template[i].iv, MAX_IVLEN); in __test_skcipher()
1040 if (template[i].wk) in __test_skcipher()
1043 ret = crypto_ablkcipher_setkey(tfm, template[i].key, in __test_skcipher()
1044 template[i].klen); in __test_skcipher()
1045 if (!ret == template[i].fail) { in __test_skcipher()
1054 sg_init_table(sg, template[i].np); in __test_skcipher()
1056 sg_init_table(sgout, template[i].np); in __test_skcipher()
1057 for (k = 0; k < template[i].np; k++) { in __test_skcipher()
1059 template[i].tap[k] > PAGE_SIZE)) in __test_skcipher()
1064 memcpy(q, template[i].input + temp, template[i].tap[k]); in __test_skcipher()
1066 if (offset_in_page(q) + template[i].tap[k] < PAGE_SIZE) in __test_skcipher()
1067 q[template[i].tap[k]] = 0; in __test_skcipher()
1069 sg_set_buf(&sg[k], q, template[i].tap[k]); in __test_skcipher()
1074 sg_set_buf(&sgout[k], q, template[i].tap[k]); in __test_skcipher()
1076 memset(q, 0, template[i].tap[k]); in __test_skcipher()
1078 template[i].tap[k] < PAGE_SIZE) in __test_skcipher()
1079 q[template[i].tap[k]] = 0; in __test_skcipher()
1082 temp += template[i].tap[k]; in __test_skcipher()
1086 template[i].ilen, iv); in __test_skcipher()
1110 for (k = 0; k < template[i].np; k++) { in __test_skcipher()
1118 if (memcmp(q, template[i].result + temp, in __test_skcipher()
1119 template[i].tap[k])) { in __test_skcipher()
1122 hexdump(q, template[i].tap[k]); in __test_skcipher()
1126 q += template[i].tap[k]; in __test_skcipher()
1135 temp += template[i].tap[k]; in __test_skcipher()
1152 struct cipher_testvec *template, unsigned int tcount) in test_skcipher() argument
1158 ret = __test_skcipher(tfm, enc, template, tcount, false, 0); in test_skcipher()
1163 ret = __test_skcipher(tfm, enc, template, tcount, true, 0); in test_skcipher()
1168 ret = __test_skcipher(tfm, enc, template, tcount, true, 1); in test_skcipher()
1175 ret = __test_skcipher(tfm, enc, template, tcount, true, in test_skcipher()
1441 static int test_cprng(struct crypto_rng *tfm, struct cprng_testvec *template, in test_cprng() argument
1461 memcpy(seed, template[i].v, template[i].vlen); in test_cprng()
1462 memcpy(seed + template[i].vlen, template[i].key, in test_cprng()
1463 template[i].klen); in test_cprng()
1464 memcpy(seed + template[i].vlen + template[i].klen, in test_cprng()
1465 template[i].dt, template[i].dtlen); in test_cprng()
1474 for (j = 0; j < template[i].loops; j++) { in test_cprng()
1476 template[i].rlen); in test_cprng()
1481 template[i].rlen); in test_cprng()
1486 err = memcmp(result, template[i].result, in test_cprng()
1487 template[i].rlen); in test_cprng()
1491 hexdump(result, template[i].rlen); in test_cprng()
1798 struct drbg_testvec *template = desc->suite.drbg.vecs; in alg_test_drbg() local
1805 err = drbg_cavs_test(&template[i], pr, driver, type, mask); in alg_test_drbg()