Lines Matching full:curve
100 * @curve: The elliptic curve used by this transformation.
106 const struct ecc_curve *curve; member
229 const struct ecc_curve *curve) in kmb_ecc_point_mult() argument
232 u32 op_size = (curve->g.ndigits > ECC_CURVE_NIST_P256_DIGITS) ? in kmb_ecc_point_mult()
234 size_t nbytes = digits_to_bytes(curve->g.ndigits); in kmb_ecc_point_mult()
278 /* Write p = curve prime(GF modulus). */ in kmb_ecc_point_mult()
280 curve->p, nbytes); in kmb_ecc_point_mult()
282 /* Write a = curve coefficient. */ in kmb_ecc_point_mult()
284 curve->a, nbytes); in kmb_ecc_point_mult()
304 * @curve: The curve on which the operation is performed.
312 const struct ecc_curve *curve, in kmb_ecc_do_scalar_op() argument
336 /* Write p = curve prime(GF modulus).*/ in kmb_ecc_do_scalar_op()
338 curve->p, nbytes); in kmb_ecc_do_scalar_op()
355 const struct ecc_curve *curve, in kmb_ocs_ecc_is_pubkey_valid_partial() argument
363 if (WARN_ON(pk->ndigits != curve->g.ndigits)) in kmb_ocs_ecc_is_pubkey_valid_partial()
371 if (vli_cmp(curve->p, pk->x, pk->ndigits) != 1) in kmb_ocs_ecc_is_pubkey_valid_partial()
374 if (vli_cmp(curve->p, pk->y, pk->ndigits) != 1) in kmb_ocs_ecc_is_pubkey_valid_partial()
381 rc = kmb_ecc_do_scalar_op(ecc_dev, yy, pk->y, pk->y, curve, pk->ndigits, in kmb_ocs_ecc_is_pubkey_valid_partial()
390 rc = kmb_ecc_do_scalar_op(ecc_dev, xxx, pk->x, w, curve, pk->ndigits, in kmb_ocs_ecc_is_pubkey_valid_partial()
396 rc = kmb_ecc_do_scalar_op(ecc_dev, w, curve->a, pk->x, curve, in kmb_ocs_ecc_is_pubkey_valid_partial()
403 rc = kmb_ecc_do_scalar_op(ecc_dev, w, w, curve->b, curve, in kmb_ocs_ecc_is_pubkey_valid_partial()
410 rc = kmb_ecc_do_scalar_op(ecc_dev, w, xxx, w, curve, pk->ndigits, in kmb_ocs_ecc_is_pubkey_valid_partial()
430 const struct ecc_curve *curve, in kmb_ocs_ecc_is_pubkey_valid_full() argument
437 rc = kmb_ocs_ecc_is_pubkey_valid_partial(ecc_dev, curve, pk); in kmb_ocs_ecc_is_pubkey_valid_full()
446 rc = kmb_ecc_point_mult(ecc_dev, nQ, pk, curve->n, curve); in kmb_ocs_ecc_is_pubkey_valid_full()
459 static int kmb_ecc_is_key_valid(const struct ecc_curve *curve, in kmb_ecc_is_key_valid() argument
462 size_t ndigits = curve->g.ndigits; in kmb_ecc_is_key_valid()
476 vli_sub(res, curve->n, one, ndigits); in kmb_ecc_is_key_valid()
496 static int kmb_ecc_gen_privkey(const struct ecc_curve *curve, u64 *privkey) in kmb_ecc_gen_privkey() argument
498 size_t nbytes = digits_to_bytes(curve->g.ndigits); in kmb_ecc_gen_privkey()
503 nbits = vli_num_bits(curve->n, curve->g.ndigits); in kmb_ecc_gen_privkey()
506 if (nbits < 160 || curve->g.ndigits > ARRAY_SIZE(priv)) in kmb_ecc_gen_privkey()
528 rc = kmb_ecc_is_key_valid(curve, priv, nbytes); in kmb_ecc_gen_privkey()
532 ecc_swap_digits(priv, privkey, curve->g.ndigits); in kmb_ecc_gen_privkey()
552 if (params.key_size > digits_to_bytes(tctx->curve->g.ndigits)) { in kmb_ocs_ecdh_set_secret()
559 rc = kmb_ecc_gen_privkey(tctx->curve, tctx->private_key); in kmb_ocs_ecdh_set_secret()
563 rc = kmb_ecc_is_key_valid(tctx->curve, (const u64 *)params.key, in kmb_ocs_ecdh_set_secret()
569 tctx->curve->g.ndigits); in kmb_ocs_ecdh_set_secret()
574 tctx->curve = NULL; in kmb_ocs_ecdh_set_secret()
584 const struct ecc_curve *curve = tctx->curve; in kmb_ecc_do_shared_secret() local
591 nbytes = digits_to_bytes(curve->g.ndigits); in kmb_ecc_do_shared_secret()
604 pk = ecc_alloc_point(curve->g.ndigits); in kmb_ecc_do_shared_secret()
608 ecc_swap_digits(pubk_buf, pk->x, curve->g.ndigits); in kmb_ecc_do_shared_secret()
609 ecc_swap_digits(&pubk_buf[curve->g.ndigits], pk->y, curve->g.ndigits); in kmb_ecc_do_shared_secret()
617 rc = kmb_ocs_ecc_is_pubkey_valid_partial(ecc_dev, curve, pk); in kmb_ecc_do_shared_secret()
629 rc = kmb_ecc_point_mult(ecc_dev, result, pk, tctx->private_key, curve); in kmb_ecc_do_shared_secret()
666 const struct ecc_curve *curve = tctx->curve; in kmb_ecc_do_public_key() local
674 pubk_len = 2 * digits_to_bytes(curve->g.ndigits); in kmb_ecc_do_public_key()
676 pk = ecc_alloc_point(curve->g.ndigits); in kmb_ecc_do_public_key()
681 rc = kmb_ecc_point_mult(tctx->ecc_dev, pk, &curve->g, tctx->private_key, in kmb_ecc_do_public_key()
682 curve); in kmb_ecc_do_public_key()
687 if (kmb_ocs_ecc_is_pubkey_valid_full(tctx->ecc_dev, curve, pk)) { in kmb_ecc_do_public_key()
731 const struct ecc_curve *curve = tctx->curve; in kmb_ocs_ecdh_generate_public_key() local
734 if (!tctx->curve) in kmb_ocs_ecdh_generate_public_key()
742 if (req->dst_len < (2 * digits_to_bytes(curve->g.ndigits))) in kmb_ocs_ecdh_generate_public_key()
756 const struct ecc_curve *curve = tctx->curve; in kmb_ocs_ecdh_compute_shared_secret() local
759 if (!tctx->curve) in kmb_ocs_ecdh_compute_shared_secret()
774 if (req->src_len != 2 * digits_to_bytes(curve->g.ndigits)) in kmb_ocs_ecdh_compute_shared_secret()
793 tctx->curve = ecc_get_curve(curve_id); in kmb_ecc_tctx_init()
794 if (!tctx->curve) in kmb_ecc_tctx_init()
830 return digits_to_bytes(tctx->curve->g.ndigits) * 2; in kmb_ocs_ecdh_max_size()