Lines Matching full:rsa

11 #include <crypto/internal/rsa.h>
127 struct hpre_rsa_ctx rsa; member
142 struct akcipher_request *rsa; member
470 areq = req->areq.rsa; in hpre_rsa_cb()
535 h_req->areq.rsa = akreq; in hpre_msg_request_set()
810 akcipher_request_set_tfm(req, ctx->rsa.soft_tfm); in hpre_rsa_enc()
816 if (unlikely(!ctx->rsa.pubkey)) in hpre_rsa_enc()
824 msg->key = cpu_to_le64(ctx->rsa.dma_pubkey); in hpre_rsa_enc()
858 akcipher_request_set_tfm(req, ctx->rsa.soft_tfm); in hpre_rsa_dec()
864 if (unlikely(!ctx->rsa.prikey)) in hpre_rsa_dec()
872 msg->key = cpu_to_le64(ctx->rsa.dma_crt_prikey); in hpre_rsa_dec()
876 msg->key = cpu_to_le64(ctx->rsa.dma_prikey); in hpre_rsa_dec()
914 ctx->rsa.pubkey = dma_alloc_coherent(ctx->dev, vlen << 1, in hpre_rsa_set_n()
915 &ctx->rsa.dma_pubkey, in hpre_rsa_set_n()
917 if (!ctx->rsa.pubkey) in hpre_rsa_set_n()
921 ctx->rsa.prikey = dma_alloc_coherent(ctx->dev, vlen << 1, in hpre_rsa_set_n()
922 &ctx->rsa.dma_prikey, in hpre_rsa_set_n()
924 if (!ctx->rsa.prikey) { in hpre_rsa_set_n()
926 ctx->rsa.pubkey, in hpre_rsa_set_n()
927 ctx->rsa.dma_pubkey); in hpre_rsa_set_n()
928 ctx->rsa.pubkey = NULL; in hpre_rsa_set_n()
931 memcpy(ctx->rsa.prikey + vlen, ptr, vlen); in hpre_rsa_set_n()
933 memcpy(ctx->rsa.pubkey + vlen, ptr, vlen); in hpre_rsa_set_n()
935 /* Using hardware HPRE to do RSA */ in hpre_rsa_set_n()
949 memcpy(ctx->rsa.pubkey + ctx->key_sz - vlen, ptr, vlen); in hpre_rsa_set_e()
964 memcpy(ctx->rsa.prikey + ctx->key_sz - vlen, ptr, vlen); in hpre_rsa_set_d()
991 ctx->rsa.crt_prikey = dma_alloc_coherent(dev, hlf_ksz * HPRE_CRT_PRMS, in hpre_rsa_setkey_crt()
992 &ctx->rsa.dma_crt_prikey, in hpre_rsa_setkey_crt()
994 if (!ctx->rsa.crt_prikey) in hpre_rsa_setkey_crt()
997 ret = hpre_crt_para_get(ctx->rsa.crt_prikey, hlf_ksz, in hpre_rsa_setkey_crt()
1003 ret = hpre_crt_para_get(ctx->rsa.crt_prikey + offset, hlf_ksz, in hpre_rsa_setkey_crt()
1009 ret = hpre_crt_para_get(ctx->rsa.crt_prikey + offset, hlf_ksz, in hpre_rsa_setkey_crt()
1015 ret = hpre_crt_para_get(ctx->rsa.crt_prikey + offset, hlf_ksz, in hpre_rsa_setkey_crt()
1021 ret = hpre_crt_para_get(ctx->rsa.crt_prikey + offset, hlf_ksz, in hpre_rsa_setkey_crt()
1032 memzero_explicit(ctx->rsa.crt_prikey, offset); in hpre_rsa_setkey_crt()
1033 dma_free_coherent(dev, hlf_ksz * HPRE_CRT_PRMS, ctx->rsa.crt_prikey, in hpre_rsa_setkey_crt()
1034 ctx->rsa.dma_crt_prikey); in hpre_rsa_setkey_crt()
1035 ctx->rsa.crt_prikey = NULL; in hpre_rsa_setkey_crt()
1050 if (ctx->rsa.pubkey) { in hpre_rsa_clear_ctx()
1052 ctx->rsa.pubkey, ctx->rsa.dma_pubkey); in hpre_rsa_clear_ctx()
1053 ctx->rsa.pubkey = NULL; in hpre_rsa_clear_ctx()
1056 if (ctx->rsa.crt_prikey) { in hpre_rsa_clear_ctx()
1057 memzero_explicit(ctx->rsa.crt_prikey, in hpre_rsa_clear_ctx()
1060 ctx->rsa.crt_prikey, ctx->rsa.dma_crt_prikey); in hpre_rsa_clear_ctx()
1061 ctx->rsa.crt_prikey = NULL; in hpre_rsa_clear_ctx()
1064 if (ctx->rsa.prikey) { in hpre_rsa_clear_ctx()
1065 memzero_explicit(ctx->rsa.prikey, ctx->key_sz); in hpre_rsa_clear_ctx()
1066 dma_free_coherent(dev, ctx->key_sz << 1, ctx->rsa.prikey, in hpre_rsa_clear_ctx()
1067 ctx->rsa.dma_prikey); in hpre_rsa_clear_ctx()
1068 ctx->rsa.prikey = NULL; in hpre_rsa_clear_ctx()
1124 if ((private && !ctx->rsa.prikey) || !ctx->rsa.pubkey) { in hpre_rsa_setkey()
1142 ret = crypto_akcipher_set_pub_key(ctx->rsa.soft_tfm, key, keylen); in hpre_rsa_setpubkey()
1155 ret = crypto_akcipher_set_priv_key(ctx->rsa.soft_tfm, key, keylen); in hpre_rsa_setprivkey()
1169 return crypto_akcipher_maxsize(ctx->rsa.soft_tfm); in hpre_rsa_max_size()
1179 ctx->rsa.soft_tfm = crypto_alloc_akcipher("rsa-generic", 0, 0); in hpre_rsa_init_tfm()
1180 if (IS_ERR(ctx->rsa.soft_tfm)) { in hpre_rsa_init_tfm()
1182 return PTR_ERR(ctx->rsa.soft_tfm); in hpre_rsa_init_tfm()
1190 crypto_free_akcipher(ctx->rsa.soft_tfm); in hpre_rsa_init_tfm()
1200 crypto_free_akcipher(ctx->rsa.soft_tfm); in hpre_rsa_exit_tfm()
2008 static struct akcipher_alg rsa = { variable
2019 .cra_name = "rsa",
2020 .cra_driver_name = "hpre-rsa",
2110 rsa.base.cra_flags = 0; in hpre_register_rsa()
2111 ret = crypto_register_akcipher(&rsa); in hpre_register_rsa()
2113 dev_err(&qm->pdev->dev, "failed to register rsa (%d)!\n", ret); in hpre_register_rsa()
2123 crypto_unregister_akcipher(&rsa); in hpre_unregister_rsa()