Lines Matching refs:tfm
201 static int __test_hash(struct crypto_ahash *tfm, struct hash_testvec *template, in __test_hash() argument
205 const char *algo = crypto_tfm_alg_driver_name(crypto_ahash_tfm(tfm)); in __test_hash()
227 req = ahash_request_alloc(tfm, GFP_KERNEL); in __test_hash()
255 crypto_ahash_clear_flags(tfm, ~0); in __test_hash()
263 ret = crypto_ahash_setkey(tfm, key, template[i].ksize); in __test_hash()
302 crypto_ahash_digestsize(tfm))) { in __test_hash()
305 hexdump(result, crypto_ahash_digestsize(tfm)); in __test_hash()
346 crypto_ahash_clear_flags(tfm, ~0); in __test_hash()
348 ret = crypto_ahash_setkey(tfm, key, template[i].ksize); in __test_hash()
379 crypto_ahash_digestsize(tfm))) { in __test_hash()
382 hexdump(result, crypto_ahash_digestsize(tfm)); in __test_hash()
400 static int test_hash(struct crypto_ahash *tfm, struct hash_testvec *template, in test_hash() argument
406 ret = __test_hash(tfm, template, tcount, use_digest, 0); in test_hash()
411 ret = __test_hash(tfm, template, tcount, use_digest, 1); in test_hash()
415 alignmask = crypto_tfm_alg_alignmask(&tfm->base); in test_hash()
418 ret = __test_hash(tfm, template, tcount, use_digest, in test_hash()
427 static int __test_aead(struct crypto_aead *tfm, int enc, in __test_aead() argument
431 const char *algo = crypto_tfm_alg_driver_name(crypto_aead_tfm(tfm)); in __test_aead()
481 req = aead_request_alloc(tfm, GFP_KERNEL); in __test_aead()
511 iv_len = crypto_aead_ivsize(tfm); in __test_aead()
517 crypto_aead_clear_flags(tfm, ~0); in __test_aead()
519 crypto_aead_set_flags(tfm, CRYPTO_TFM_REQ_WEAK_KEY); in __test_aead()
530 ret = crypto_aead_setkey(tfm, key, template[i].klen); in __test_aead()
533 d, j, algo, crypto_aead_get_flags(tfm)); in __test_aead()
539 ret = crypto_aead_setauthsize(tfm, authsize); in __test_aead()
624 crypto_aead_clear_flags(tfm, ~0); in __test_aead()
626 crypto_aead_set_flags(tfm, CRYPTO_TFM_REQ_WEAK_KEY); in __test_aead()
635 ret = crypto_aead_setkey(tfm, key, template[i].klen); in __test_aead()
638 d, j, algo, crypto_aead_get_flags(tfm)); in __test_aead()
698 ret = crypto_aead_setauthsize(tfm, authsize); in __test_aead()
817 static int test_aead(struct crypto_aead *tfm, int enc, in test_aead() argument
824 ret = __test_aead(tfm, enc, template, tcount, false, 0); in test_aead()
829 ret = __test_aead(tfm, enc, template, tcount, true, 0); in test_aead()
834 ret = __test_aead(tfm, enc, template, tcount, true, 1); in test_aead()
838 alignmask = crypto_tfm_alg_alignmask(&tfm->base); in test_aead()
841 ret = __test_aead(tfm, enc, template, tcount, true, in test_aead()
850 static int test_cipher(struct crypto_cipher *tfm, int enc, in test_cipher() argument
853 const char *algo = crypto_tfm_alg_driver_name(crypto_cipher_tfm(tfm)); in test_cipher()
883 crypto_cipher_clear_flags(tfm, ~0); in test_cipher()
885 crypto_cipher_set_flags(tfm, CRYPTO_TFM_REQ_WEAK_KEY); in test_cipher()
887 ret = crypto_cipher_setkey(tfm, template[i].key, in test_cipher()
892 algo, crypto_cipher_get_flags(tfm)); in test_cipher()
898 k += crypto_cipher_blocksize(tfm)) { in test_cipher()
900 crypto_cipher_encrypt_one(tfm, data + k, in test_cipher()
903 crypto_cipher_decrypt_one(tfm, data + k, in test_cipher()
925 static int __test_skcipher(struct crypto_skcipher *tfm, int enc, in __test_skcipher() argument
930 crypto_tfm_alg_driver_name(crypto_skcipher_tfm(tfm)); in __test_skcipher()
943 unsigned int ivsize = crypto_skcipher_ivsize(tfm); in __test_skcipher()
963 req = skcipher_request_alloc(tfm, GFP_KERNEL); in __test_skcipher()
992 crypto_skcipher_clear_flags(tfm, ~0); in __test_skcipher()
994 crypto_skcipher_set_flags(tfm, in __test_skcipher()
997 ret = crypto_skcipher_setkey(tfm, template[i].key, in __test_skcipher()
1001 d, j, algo, crypto_skcipher_get_flags(tfm)); in __test_skcipher()
1046 crypto_skcipher_ivsize(tfm))) { in __test_skcipher()
1049 hexdump(iv, crypto_skcipher_ivsize(tfm)); in __test_skcipher()
1070 crypto_skcipher_clear_flags(tfm, ~0); in __test_skcipher()
1072 crypto_skcipher_set_flags(tfm, in __test_skcipher()
1075 ret = crypto_skcipher_setkey(tfm, template[i].key, in __test_skcipher()
1079 d, j, algo, crypto_skcipher_get_flags(tfm)); in __test_skcipher()
1183 static int test_skcipher(struct crypto_skcipher *tfm, int enc, in test_skcipher() argument
1190 ret = __test_skcipher(tfm, enc, template, tcount, false, 0); in test_skcipher()
1195 ret = __test_skcipher(tfm, enc, template, tcount, true, 0); in test_skcipher()
1200 ret = __test_skcipher(tfm, enc, template, tcount, true, 1); in test_skcipher()
1204 alignmask = crypto_tfm_alg_alignmask(&tfm->base); in test_skcipher()
1207 ret = __test_skcipher(tfm, enc, template, tcount, true, in test_skcipher()
1216 static int test_comp(struct crypto_comp *tfm, struct comp_testvec *ctemplate, in test_comp() argument
1219 const char *algo = crypto_tfm_alg_driver_name(crypto_comp_tfm(tfm)); in test_comp()
1231 ret = crypto_comp_compress(tfm, ctemplate[i].input, in test_comp()
1264 ret = crypto_comp_decompress(tfm, dtemplate[i].input, in test_comp()
1296 static int test_pcomp(struct crypto_pcomp *tfm, in test_pcomp() argument
1301 const char *algo = crypto_tfm_alg_driver_name(crypto_pcomp_tfm(tfm)); in test_pcomp()
1310 res = crypto_compress_setup(tfm, ctemplate[i].params, in test_pcomp()
1318 res = crypto_compress_init(tfm); in test_pcomp()
1332 res = crypto_compress_update(tfm, &req); in test_pcomp()
1344 res = crypto_compress_update(tfm, &req); in test_pcomp()
1356 res = crypto_compress_final(tfm, &req); in test_pcomp()
1391 res = crypto_decompress_setup(tfm, dtemplate[i].params, in test_pcomp()
1399 res = crypto_decompress_init(tfm); in test_pcomp()
1413 res = crypto_decompress_update(tfm, &req); in test_pcomp()
1425 res = crypto_decompress_update(tfm, &req); in test_pcomp()
1437 res = crypto_decompress_final(tfm, &req); in test_pcomp()
1473 static int test_cprng(struct crypto_rng *tfm, struct cprng_testvec *template, in test_cprng() argument
1476 const char *algo = crypto_tfm_alg_driver_name(crypto_rng_tfm(tfm)); in test_cprng()
1481 seedsize = crypto_rng_seedsize(tfm); in test_cprng()
1499 err = crypto_rng_reset(tfm, seed, seedsize); in test_cprng()
1507 err = crypto_rng_get_bytes(tfm, result, in test_cprng()
1537 struct crypto_aead *tfm; in alg_test_aead() local
1540 tfm = crypto_alloc_aead(driver, type | CRYPTO_ALG_INTERNAL, mask); in alg_test_aead()
1541 if (IS_ERR(tfm)) { in alg_test_aead()
1543 "%ld\n", driver, PTR_ERR(tfm)); in alg_test_aead()
1544 return PTR_ERR(tfm); in alg_test_aead()
1548 err = test_aead(tfm, ENCRYPT, desc->suite.aead.enc.vecs, in alg_test_aead()
1555 err = test_aead(tfm, DECRYPT, desc->suite.aead.dec.vecs, in alg_test_aead()
1559 crypto_free_aead(tfm); in alg_test_aead()
1566 struct crypto_cipher *tfm; in alg_test_cipher() local
1569 tfm = crypto_alloc_cipher(driver, type | CRYPTO_ALG_INTERNAL, mask); in alg_test_cipher()
1570 if (IS_ERR(tfm)) { in alg_test_cipher()
1572 "%s: %ld\n", driver, PTR_ERR(tfm)); in alg_test_cipher()
1573 return PTR_ERR(tfm); in alg_test_cipher()
1577 err = test_cipher(tfm, ENCRYPT, desc->suite.cipher.enc.vecs, in alg_test_cipher()
1584 err = test_cipher(tfm, DECRYPT, desc->suite.cipher.dec.vecs, in alg_test_cipher()
1588 crypto_free_cipher(tfm); in alg_test_cipher()
1595 struct crypto_skcipher *tfm; in alg_test_skcipher() local
1598 tfm = crypto_alloc_skcipher(driver, type | CRYPTO_ALG_INTERNAL, mask); in alg_test_skcipher()
1599 if (IS_ERR(tfm)) { in alg_test_skcipher()
1601 "%s: %ld\n", driver, PTR_ERR(tfm)); in alg_test_skcipher()
1602 return PTR_ERR(tfm); in alg_test_skcipher()
1606 err = test_skcipher(tfm, ENCRYPT, desc->suite.cipher.enc.vecs, in alg_test_skcipher()
1613 err = test_skcipher(tfm, DECRYPT, desc->suite.cipher.dec.vecs, in alg_test_skcipher()
1617 crypto_free_skcipher(tfm); in alg_test_skcipher()
1624 struct crypto_comp *tfm; in alg_test_comp() local
1627 tfm = crypto_alloc_comp(driver, type, mask); in alg_test_comp()
1628 if (IS_ERR(tfm)) { in alg_test_comp()
1630 "%ld\n", driver, PTR_ERR(tfm)); in alg_test_comp()
1631 return PTR_ERR(tfm); in alg_test_comp()
1634 err = test_comp(tfm, desc->suite.comp.comp.vecs, in alg_test_comp()
1639 crypto_free_comp(tfm); in alg_test_comp()
1646 struct crypto_pcomp *tfm; in alg_test_pcomp() local
1649 tfm = crypto_alloc_pcomp(driver, type, mask); in alg_test_pcomp()
1650 if (IS_ERR(tfm)) { in alg_test_pcomp()
1652 driver, PTR_ERR(tfm)); in alg_test_pcomp()
1653 return PTR_ERR(tfm); in alg_test_pcomp()
1656 err = test_pcomp(tfm, desc->suite.pcomp.comp.vecs, in alg_test_pcomp()
1661 crypto_free_pcomp(tfm); in alg_test_pcomp()
1668 struct crypto_ahash *tfm; in alg_test_hash() local
1671 tfm = crypto_alloc_ahash(driver, type | CRYPTO_ALG_INTERNAL, mask); in alg_test_hash()
1672 if (IS_ERR(tfm)) { in alg_test_hash()
1674 "%ld\n", driver, PTR_ERR(tfm)); in alg_test_hash()
1675 return PTR_ERR(tfm); in alg_test_hash()
1678 err = test_hash(tfm, desc->suite.hash.vecs, in alg_test_hash()
1681 err = test_hash(tfm, desc->suite.hash.vecs, in alg_test_hash()
1684 crypto_free_ahash(tfm); in alg_test_hash()
1691 struct crypto_shash *tfm; in alg_test_crc32c() local
1699 tfm = crypto_alloc_shash(driver, type | CRYPTO_ALG_INTERNAL, mask); in alg_test_crc32c()
1700 if (IS_ERR(tfm)) { in alg_test_crc32c()
1702 "%ld\n", driver, PTR_ERR(tfm)); in alg_test_crc32c()
1703 err = PTR_ERR(tfm); in alg_test_crc32c()
1708 SHASH_DESC_ON_STACK(shash, tfm); in alg_test_crc32c()
1711 shash->tfm = tfm; in alg_test_crc32c()
1729 crypto_free_shash(tfm); in alg_test_crc32c()
1849 static int do_test_rsa(struct crypto_akcipher *tfm, in do_test_rsa() argument
1864 req = akcipher_request_alloc(tfm, GFP_KERNEL); in do_test_rsa()
1871 err = crypto_akcipher_set_pub_key(tfm, vecs->key, in do_test_rsa()
1874 err = crypto_akcipher_set_priv_key(tfm, vecs->key, in do_test_rsa()
1879 out_len_max = crypto_akcipher_maxsize(tfm); in do_test_rsa()
1963 static int test_rsa(struct crypto_akcipher *tfm, struct akcipher_testvec *vecs, in test_rsa() argument
1969 ret = do_test_rsa(tfm, vecs++); in test_rsa()
1979 static int test_akcipher(struct crypto_akcipher *tfm, const char *alg, in test_akcipher() argument
1983 return test_rsa(tfm, vecs, tcount); in test_akcipher()
1991 struct crypto_akcipher *tfm; in alg_test_akcipher() local
1994 tfm = crypto_alloc_akcipher(driver, type | CRYPTO_ALG_INTERNAL, mask); in alg_test_akcipher()
1995 if (IS_ERR(tfm)) { in alg_test_akcipher()
1997 driver, PTR_ERR(tfm)); in alg_test_akcipher()
1998 return PTR_ERR(tfm); in alg_test_akcipher()
2001 err = test_akcipher(tfm, desc->alg, desc->suite.akcipher.vecs, in alg_test_akcipher()
2004 crypto_free_akcipher(tfm); in alg_test_akcipher()