Lines Matching refs:curve
911 const struct ecc_curve *curve) in vli_mmod_fast() argument
914 const u64 *curve_prime = curve->p; in vli_mmod_fast()
915 const unsigned int ndigits = curve->g.ndigits; in vli_mmod_fast()
918 if (strncmp(curve->name, "nist_", 5) != 0) { in vli_mmod_fast()
967 const struct ecc_curve *curve) in vli_mod_mult_fast() argument
971 vli_mult(product, left, right, curve->g.ndigits); in vli_mod_mult_fast()
972 vli_mmod_fast(result, product, curve); in vli_mod_mult_fast()
977 const struct ecc_curve *curve) in vli_mod_square_fast() argument
981 vli_square(product, left, curve->g.ndigits); in vli_mod_square_fast()
982 vli_mmod_fast(result, product, curve); in vli_mod_square_fast()
1081 const struct ecc_curve *curve) in ecc_point_double_jacobian() argument
1086 const u64 *curve_prime = curve->p; in ecc_point_double_jacobian()
1087 const unsigned int ndigits = curve->g.ndigits; in ecc_point_double_jacobian()
1093 vli_mod_square_fast(t4, y1, curve); in ecc_point_double_jacobian()
1095 vli_mod_mult_fast(t5, x1, t4, curve); in ecc_point_double_jacobian()
1097 vli_mod_square_fast(t4, t4, curve); in ecc_point_double_jacobian()
1099 vli_mod_mult_fast(y1, y1, z1, curve); in ecc_point_double_jacobian()
1101 vli_mod_square_fast(z1, z1, curve); in ecc_point_double_jacobian()
1110 vli_mod_mult_fast(x1, x1, z1, curve); in ecc_point_double_jacobian()
1127 vli_mod_square_fast(z1, x1, curve); in ecc_point_double_jacobian()
1135 vli_mod_mult_fast(x1, x1, t5, curve); in ecc_point_double_jacobian()
1145 static void apply_z(u64 *x1, u64 *y1, u64 *z, const struct ecc_curve *curve) in apply_z() argument
1149 vli_mod_square_fast(t1, z, curve); /* z^2 */ in apply_z()
1150 vli_mod_mult_fast(x1, x1, t1, curve); /* x1 * z^2 */ in apply_z()
1151 vli_mod_mult_fast(t1, t1, z, curve); /* z^3 */ in apply_z()
1152 vli_mod_mult_fast(y1, y1, t1, curve); /* y1 * z^3 */ in apply_z()
1157 u64 *p_initial_z, const struct ecc_curve *curve) in xycz_initial_double() argument
1160 const unsigned int ndigits = curve->g.ndigits; in xycz_initial_double()
1171 apply_z(x1, y1, z, curve); in xycz_initial_double()
1173 ecc_point_double_jacobian(x1, y1, z, curve); in xycz_initial_double()
1175 apply_z(x2, y2, z, curve); in xycz_initial_double()
1183 const struct ecc_curve *curve) in xycz_add() argument
1187 const u64 *curve_prime = curve->p; in xycz_add()
1188 const unsigned int ndigits = curve->g.ndigits; in xycz_add()
1193 vli_mod_square_fast(t5, t5, curve); in xycz_add()
1195 vli_mod_mult_fast(x1, x1, t5, curve); in xycz_add()
1197 vli_mod_mult_fast(x2, x2, t5, curve); in xycz_add()
1201 vli_mod_square_fast(t5, y2, curve); in xycz_add()
1210 vli_mod_mult_fast(y1, y1, x2, curve); in xycz_add()
1214 vli_mod_mult_fast(y2, y2, x2, curve); in xycz_add()
1226 const struct ecc_curve *curve) in xycz_add_c() argument
1232 const u64 *curve_prime = curve->p; in xycz_add_c()
1233 const unsigned int ndigits = curve->g.ndigits; in xycz_add_c()
1238 vli_mod_square_fast(t5, t5, curve); in xycz_add_c()
1240 vli_mod_mult_fast(x1, x1, t5, curve); in xycz_add_c()
1242 vli_mod_mult_fast(x2, x2, t5, curve); in xycz_add_c()
1251 vli_mod_mult_fast(y1, y1, t6, curve); in xycz_add_c()
1255 vli_mod_square_fast(x2, y2, curve); in xycz_add_c()
1262 vli_mod_mult_fast(y2, y2, t7, curve); in xycz_add_c()
1267 vli_mod_square_fast(t7, t5, curve); in xycz_add_c()
1273 vli_mod_mult_fast(t6, t6, t5, curve); in xycz_add_c()
1282 u64 *initial_z, const struct ecc_curve *curve, in ecc_point_mult() argument
1290 u64 *curve_prime = curve->p; in ecc_point_mult()
1295 carry = vli_add(sk[0], scalar, curve->n, ndigits); in ecc_point_mult()
1296 vli_add(sk[1], sk[0], curve->n, ndigits); in ecc_point_mult()
1303 xycz_initial_double(rx[1], ry[1], rx[0], ry[0], initial_z, curve); in ecc_point_mult()
1307 xycz_add_c(rx[1 - nb], ry[1 - nb], rx[nb], ry[nb], curve); in ecc_point_mult()
1308 xycz_add(rx[nb], ry[nb], rx[1 - nb], ry[1 - nb], curve); in ecc_point_mult()
1312 xycz_add_c(rx[1 - nb], ry[1 - nb], rx[nb], ry[nb], curve); in ecc_point_mult()
1318 vli_mod_mult_fast(z, z, ry[1 - nb], curve); in ecc_point_mult()
1320 vli_mod_mult_fast(z, z, point->x, curve); in ecc_point_mult()
1326 vli_mod_mult_fast(z, z, point->y, curve); in ecc_point_mult()
1328 vli_mod_mult_fast(z, z, rx[1 - nb], curve); in ecc_point_mult()
1331 xycz_add(rx[nb], ry[nb], rx[1 - nb], ry[1 - nb], curve); in ecc_point_mult()
1333 apply_z(rx[0], ry[0], z, curve); in ecc_point_mult()
1342 const struct ecc_curve *curve) in ecc_point_add() argument
1347 unsigned int ndigits = curve->g.ndigits; in ecc_point_add()
1351 vli_mod_sub(z, result->x, p->x, curve->p, ndigits); in ecc_point_add()
1354 xycz_add(px, py, result->x, result->y, curve); in ecc_point_add()
1355 vli_mod_inv(z, z, curve->p, ndigits); in ecc_point_add()
1356 apply_z(result->x, result->y, z, curve); in ecc_point_add()
1365 const struct ecc_curve *curve) in ecc_point_mult_shamir() argument
1371 unsigned int ndigits = curve->g.ndigits; in ecc_point_mult_shamir()
1379 ecc_point_add(&sum, p, q, curve); in ecc_point_mult_shamir()
1396 ecc_point_double_jacobian(rx, ry, z, curve); in ecc_point_mult_shamir()
1406 apply_z(tx, ty, z, curve); in ecc_point_mult_shamir()
1407 vli_mod_sub(tz, rx, tx, curve->p, ndigits); in ecc_point_mult_shamir()
1408 xycz_add(tx, ty, rx, ry, curve); in ecc_point_mult_shamir()
1409 vli_mod_mult_fast(z, z, tz, curve); in ecc_point_mult_shamir()
1412 vli_mod_inv(z, z, curve->p, ndigits); in ecc_point_mult_shamir()
1413 apply_z(rx, ry, z, curve); in ecc_point_mult_shamir()
1417 static int __ecc_is_key_valid(const struct ecc_curve *curve, in __ecc_is_key_valid() argument
1426 if (curve->g.ndigits != ndigits) in __ecc_is_key_valid()
1432 vli_sub(res, curve->n, one, ndigits); in __ecc_is_key_valid()
1444 const struct ecc_curve *curve = ecc_get_curve(curve_id); in ecc_is_key_valid() local
1451 return __ecc_is_key_valid(curve, private_key, ndigits); in ecc_is_key_valid()
1469 const struct ecc_curve *curve = ecc_get_curve(curve_id); in ecc_gen_privkey() local
1472 unsigned int nbits = vli_num_bits(curve->n, ndigits); in ecc_gen_privkey()
1499 if (__ecc_is_key_valid(curve, priv, ndigits)) in ecc_gen_privkey()
1514 const struct ecc_curve *curve = ecc_get_curve(curve_id); in ecc_make_pub_key() local
1516 if (!private_key || !curve || ndigits > ARRAY_SIZE(priv)) { in ecc_make_pub_key()
1529 ecc_point_mult(pk, &curve->g, priv, NULL, curve, ndigits); in ecc_make_pub_key()
1532 if (ecc_is_pubkey_valid_full(curve, pk)) { in ecc_make_pub_key()
1548 int ecc_is_pubkey_valid_partial(const struct ecc_curve *curve, in ecc_is_pubkey_valid_partial() argument
1553 if (WARN_ON(pk->ndigits != curve->g.ndigits)) in ecc_is_pubkey_valid_partial()
1561 if (vli_cmp(curve->p, pk->x, pk->ndigits) != 1) in ecc_is_pubkey_valid_partial()
1563 if (vli_cmp(curve->p, pk->y, pk->ndigits) != 1) in ecc_is_pubkey_valid_partial()
1567 vli_mod_square_fast(yy, pk->y, curve); /* y^2 */ in ecc_is_pubkey_valid_partial()
1568 vli_mod_square_fast(xxx, pk->x, curve); /* x^2 */ in ecc_is_pubkey_valid_partial()
1569 vli_mod_mult_fast(xxx, xxx, pk->x, curve); /* x^3 */ in ecc_is_pubkey_valid_partial()
1570 vli_mod_mult_fast(w, curve->a, pk->x, curve); /* a·x */ in ecc_is_pubkey_valid_partial()
1571 vli_mod_add(w, w, curve->b, curve->p, pk->ndigits); /* a·x + b */ in ecc_is_pubkey_valid_partial()
1572 vli_mod_add(w, w, xxx, curve->p, pk->ndigits); /* x^3 + a·x + b */ in ecc_is_pubkey_valid_partial()
1581 int ecc_is_pubkey_valid_full(const struct ecc_curve *curve, in ecc_is_pubkey_valid_full() argument
1587 int ret = ecc_is_pubkey_valid_partial(curve, pk); in ecc_is_pubkey_valid_full()
1597 ecc_point_mult(nQ, pk, curve->n, NULL, curve, pk->ndigits); in ecc_is_pubkey_valid_full()
1616 const struct ecc_curve *curve = ecc_get_curve(curve_id); in crypto_ecdh_shared_secret() local
1618 if (!private_key || !public_key || !curve || in crypto_ecdh_shared_secret()
1636 ret = ecc_is_pubkey_valid_partial(curve, pk); in crypto_ecdh_shared_secret()
1648 ecc_point_mult(product, pk, priv, rand_z, curve, ndigits); in crypto_ecdh_shared_secret()