Lines Matching refs:curve
101 const struct ecc_curve *curve; member
224 const struct ecc_curve *curve) in kmb_ecc_point_mult() argument
227 u32 op_size = (curve->g.ndigits > ECC_CURVE_NIST_P256_DIGITS) ? in kmb_ecc_point_mult()
229 size_t nbytes = digits_to_bytes(curve->g.ndigits); in kmb_ecc_point_mult()
275 curve->p, nbytes); in kmb_ecc_point_mult()
279 curve->a, nbytes); in kmb_ecc_point_mult()
307 const struct ecc_curve *curve, in kmb_ecc_do_scalar_op() argument
333 curve->p, nbytes); in kmb_ecc_do_scalar_op()
350 const struct ecc_curve *curve, in kmb_ocs_ecc_is_pubkey_valid_partial() argument
358 if (WARN_ON(pk->ndigits != curve->g.ndigits)) in kmb_ocs_ecc_is_pubkey_valid_partial()
366 if (vli_cmp(curve->p, pk->x, pk->ndigits) != 1) in kmb_ocs_ecc_is_pubkey_valid_partial()
369 if (vli_cmp(curve->p, pk->y, pk->ndigits) != 1) in kmb_ocs_ecc_is_pubkey_valid_partial()
376 rc = kmb_ecc_do_scalar_op(ecc_dev, yy, pk->y, pk->y, curve, pk->ndigits, in kmb_ocs_ecc_is_pubkey_valid_partial()
385 rc = kmb_ecc_do_scalar_op(ecc_dev, xxx, pk->x, w, curve, pk->ndigits, in kmb_ocs_ecc_is_pubkey_valid_partial()
391 rc = kmb_ecc_do_scalar_op(ecc_dev, w, curve->a, pk->x, curve, in kmb_ocs_ecc_is_pubkey_valid_partial()
398 rc = kmb_ecc_do_scalar_op(ecc_dev, w, w, curve->b, curve, in kmb_ocs_ecc_is_pubkey_valid_partial()
405 rc = kmb_ecc_do_scalar_op(ecc_dev, w, xxx, w, curve, pk->ndigits, in kmb_ocs_ecc_is_pubkey_valid_partial()
425 const struct ecc_curve *curve, in kmb_ocs_ecc_is_pubkey_valid_full() argument
432 rc = kmb_ocs_ecc_is_pubkey_valid_partial(ecc_dev, curve, pk); in kmb_ocs_ecc_is_pubkey_valid_full()
441 rc = kmb_ecc_point_mult(ecc_dev, nQ, pk, curve->n, curve); in kmb_ocs_ecc_is_pubkey_valid_full()
454 static int kmb_ecc_is_key_valid(const struct ecc_curve *curve, in kmb_ecc_is_key_valid() argument
457 size_t ndigits = curve->g.ndigits; in kmb_ecc_is_key_valid()
471 vli_sub(res, curve->n, one, ndigits); in kmb_ecc_is_key_valid()
491 static int kmb_ecc_gen_privkey(const struct ecc_curve *curve, u64 *privkey) in kmb_ecc_gen_privkey() argument
493 size_t nbytes = digits_to_bytes(curve->g.ndigits); in kmb_ecc_gen_privkey()
498 nbits = vli_num_bits(curve->n, curve->g.ndigits); in kmb_ecc_gen_privkey()
501 if (nbits < 160 || curve->g.ndigits > ARRAY_SIZE(priv)) in kmb_ecc_gen_privkey()
523 rc = kmb_ecc_is_key_valid(curve, priv, nbytes); in kmb_ecc_gen_privkey()
527 ecc_swap_digits(priv, privkey, curve->g.ndigits); in kmb_ecc_gen_privkey()
547 if (params.key_size > digits_to_bytes(tctx->curve->g.ndigits)) { in kmb_ocs_ecdh_set_secret()
554 rc = kmb_ecc_gen_privkey(tctx->curve, tctx->private_key); in kmb_ocs_ecdh_set_secret()
558 rc = kmb_ecc_is_key_valid(tctx->curve, (const u64 *)params.key, in kmb_ocs_ecdh_set_secret()
564 tctx->curve->g.ndigits); in kmb_ocs_ecdh_set_secret()
569 tctx->curve = NULL; in kmb_ocs_ecdh_set_secret()
579 const struct ecc_curve *curve = tctx->curve; in kmb_ecc_do_shared_secret() local
586 nbytes = digits_to_bytes(curve->g.ndigits); in kmb_ecc_do_shared_secret()
599 pk = ecc_alloc_point(curve->g.ndigits); in kmb_ecc_do_shared_secret()
603 ecc_swap_digits(pubk_buf, pk->x, curve->g.ndigits); in kmb_ecc_do_shared_secret()
604 ecc_swap_digits(&pubk_buf[curve->g.ndigits], pk->y, curve->g.ndigits); in kmb_ecc_do_shared_secret()
612 rc = kmb_ocs_ecc_is_pubkey_valid_partial(ecc_dev, curve, pk); in kmb_ecc_do_shared_secret()
624 rc = kmb_ecc_point_mult(ecc_dev, result, pk, tctx->private_key, curve); in kmb_ecc_do_shared_secret()
661 const struct ecc_curve *curve = tctx->curve; in kmb_ecc_do_public_key() local
669 pubk_len = 2 * digits_to_bytes(curve->g.ndigits); in kmb_ecc_do_public_key()
671 pk = ecc_alloc_point(curve->g.ndigits); in kmb_ecc_do_public_key()
676 rc = kmb_ecc_point_mult(tctx->ecc_dev, pk, &curve->g, tctx->private_key, in kmb_ecc_do_public_key()
677 curve); in kmb_ecc_do_public_key()
682 if (kmb_ocs_ecc_is_pubkey_valid_full(tctx->ecc_dev, curve, pk)) { in kmb_ecc_do_public_key()
726 const struct ecc_curve *curve = tctx->curve; in kmb_ocs_ecdh_generate_public_key() local
729 if (!tctx->curve) in kmb_ocs_ecdh_generate_public_key()
737 if (req->dst_len < (2 * digits_to_bytes(curve->g.ndigits))) in kmb_ocs_ecdh_generate_public_key()
751 const struct ecc_curve *curve = tctx->curve; in kmb_ocs_ecdh_compute_shared_secret() local
754 if (!tctx->curve) in kmb_ocs_ecdh_compute_shared_secret()
769 if (req->src_len != 2 * digits_to_bytes(curve->g.ndigits)) in kmb_ocs_ecdh_compute_shared_secret()
788 tctx->curve = ecc_get_curve(curve_id); in kmb_ecc_tctx_init()
789 if (!tctx->curve) in kmb_ecc_tctx_init()
821 return digits_to_bytes(tctx->curve->g.ndigits) * 2; in kmb_ocs_ecdh_max_size()