Lines Matching defs:curve

96  * @curve:	 The elliptic curve used by this transformation.
101 const struct ecc_curve *curve;
224 const struct ecc_curve *curve)
227 u32 op_size = (curve->g.ndigits > ECC_CURVE_NIST_P256_DIGITS) ?
229 size_t nbytes = digits_to_bytes(curve->g.ndigits);
273 /* Write p = curve prime(GF modulus). */
275 curve->p, nbytes);
277 /* Write a = curve coefficient. */
279 curve->a, nbytes);
299 * @curve: The curve on which the operation is performed.
307 const struct ecc_curve *curve,
331 /* Write p = curve prime(GF modulus).*/
333 curve->p, nbytes);
350 const struct ecc_curve *curve,
358 if (WARN_ON(pk->ndigits != curve->g.ndigits))
366 if (vli_cmp(curve->p, pk->x, pk->ndigits) != 1)
369 if (vli_cmp(curve->p, pk->y, pk->ndigits) != 1)
376 rc = kmb_ecc_do_scalar_op(ecc_dev, yy, pk->y, pk->y, curve, pk->ndigits,
385 rc = kmb_ecc_do_scalar_op(ecc_dev, xxx, pk->x, w, curve, pk->ndigits,
391 rc = kmb_ecc_do_scalar_op(ecc_dev, w, curve->a, pk->x, curve,
398 rc = kmb_ecc_do_scalar_op(ecc_dev, w, w, curve->b, curve,
405 rc = kmb_ecc_do_scalar_op(ecc_dev, w, xxx, w, curve, pk->ndigits,
425 const struct ecc_curve *curve,
432 rc = kmb_ocs_ecc_is_pubkey_valid_partial(ecc_dev, curve, pk);
441 rc = kmb_ecc_point_mult(ecc_dev, nQ, pk, curve->n, curve);
454 static int kmb_ecc_is_key_valid(const struct ecc_curve *curve,
457 size_t ndigits = curve->g.ndigits;
471 vli_sub(res, curve->n, one, ndigits);
491 static int kmb_ecc_gen_privkey(const struct ecc_curve *curve, u64 *privkey)
493 size_t nbytes = digits_to_bytes(curve->g.ndigits);
498 nbits = vli_num_bits(curve->n, curve->g.ndigits);
501 if (nbits < 160 || curve->g.ndigits > ARRAY_SIZE(priv))
523 rc = kmb_ecc_is_key_valid(curve, priv, nbytes);
527 ecc_swap_digits(priv, privkey, curve->g.ndigits);
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,
564 tctx->curve->g.ndigits);
569 tctx->curve = NULL;
579 const struct ecc_curve *curve = tctx->curve;
586 nbytes = digits_to_bytes(curve->g.ndigits);
599 pk = ecc_alloc_point(curve->g.ndigits);
603 ecc_swap_digits(pubk_buf, pk->x, curve->g.ndigits);
604 ecc_swap_digits(&pubk_buf[curve->g.ndigits], pk->y, curve->g.ndigits);
612 rc = kmb_ocs_ecc_is_pubkey_valid_partial(ecc_dev, curve, pk);
624 rc = kmb_ecc_point_mult(ecc_dev, result, pk, tctx->private_key, curve);
661 const struct ecc_curve *curve = tctx->curve;
669 pubk_len = 2 * digits_to_bytes(curve->g.ndigits);
671 pk = ecc_alloc_point(curve->g.ndigits);
676 rc = kmb_ecc_point_mult(tctx->ecc_dev, pk, &curve->g, tctx->private_key,
677 curve);
682 if (kmb_ocs_ecc_is_pubkey_valid_full(tctx->ecc_dev, curve, pk)) {
726 const struct ecc_curve *curve = tctx->curve;
729 if (!tctx->curve)
737 if (req->dst_len < (2 * digits_to_bytes(curve->g.ndigits)))
751 const struct ecc_curve *curve = tctx->curve;
754 if (!tctx->curve)
769 if (req->src_len != 2 * digits_to_bytes(curve->g.ndigits))
788 tctx->curve = ecc_get_curve(curve_id);
789 if (!tctx->curve)
821 return digits_to_bytes(tctx->curve->g.ndigits) * 2;