Lines Matching refs:tctx

203 static struct ocs_ecc_dev *kmb_ocs_ecc_find_dev(struct ocs_ecc_ctx *tctx)
205 if (tctx->ecc_dev)
206 return tctx->ecc_dev;
211 tctx->ecc_dev = list_first_entry(&ocs_ecc.dev_list, struct ocs_ecc_dev,
216 return tctx->ecc_dev;
538 struct ocs_ecc_ctx *tctx = kpp_tfm_ctx(tfm);
547 if (params.key_size > digits_to_bytes(tctx->curve->g.ndigits)) {
554 rc = kmb_ecc_gen_privkey(tctx->curve, tctx->private_key);
558 rc = kmb_ecc_is_key_valid(tctx->curve, (const u64 *)params.key,
563 ecc_swap_digits((const u64 *)params.key, tctx->private_key,
564 tctx->curve->g.ndigits);
569 tctx->curve = NULL;
575 static int kmb_ecc_do_shared_secret(struct ocs_ecc_ctx *tctx,
578 struct ocs_ecc_dev *ecc_dev = tctx->ecc_dev;
579 const struct ecc_curve *curve = tctx->curve;
624 rc = kmb_ecc_point_mult(ecc_dev, result, pk, tctx->private_key, curve);
658 static int kmb_ecc_do_public_key(struct ocs_ecc_ctx *tctx,
661 const struct ecc_curve *curve = tctx->curve;
676 rc = kmb_ecc_point_mult(tctx->ecc_dev, pk, &curve->g, tctx->private_key,
682 if (kmb_ocs_ecc_is_pubkey_valid_full(tctx->ecc_dev, curve, pk)) {
709 struct ocs_ecc_ctx *tctx = kmb_ocs_ecc_tctx(req);
710 struct ocs_ecc_dev *ecc_dev = tctx->ecc_dev;
714 rc = kmb_ecc_do_shared_secret(tctx, req);
716 rc = kmb_ecc_do_public_key(tctx, req);
725 struct ocs_ecc_ctx *tctx = kmb_ocs_ecc_tctx(req);
726 const struct ecc_curve *curve = tctx->curve;
729 if (!tctx->curve)
744 return crypto_transfer_kpp_request_to_engine(tctx->ecc_dev->engine,
750 struct ocs_ecc_ctx *tctx = kmb_ocs_ecc_tctx(req);
751 const struct ecc_curve *curve = tctx->curve;
754 if (!tctx->curve)
772 return crypto_transfer_kpp_request_to_engine(tctx->ecc_dev->engine,
776 static int kmb_ecc_tctx_init(struct ocs_ecc_ctx *tctx, unsigned int curve_id)
778 memset(tctx, 0, sizeof(*tctx));
780 tctx->ecc_dev = kmb_ocs_ecc_find_dev(tctx);
782 if (IS_ERR(tctx->ecc_dev)) {
784 PTR_ERR(tctx->ecc_dev));
785 return PTR_ERR(tctx->ecc_dev);
788 tctx->curve = ecc_get_curve(curve_id);
789 if (!tctx->curve)
797 struct ocs_ecc_ctx *tctx = kpp_tfm_ctx(tfm);
799 return kmb_ecc_tctx_init(tctx, ECC_CURVE_NIST_P256);
804 struct ocs_ecc_ctx *tctx = kpp_tfm_ctx(tfm);
806 return kmb_ecc_tctx_init(tctx, ECC_CURVE_NIST_P384);
811 struct ocs_ecc_ctx *tctx = kpp_tfm_ctx(tfm);
813 memzero_explicit(tctx->private_key, sizeof(*tctx->private_key));
818 struct ocs_ecc_ctx *tctx = kpp_tfm_ctx(tfm);
821 return digits_to_bytes(tctx->curve->g.ndigits) * 2;