Lines Matching refs:ndigits
69 static u64 *ecc_alloc_digits_space(unsigned int ndigits) in ecc_alloc_digits_space() argument
71 size_t len = ndigits * sizeof(u64); in ecc_alloc_digits_space()
84 struct ecc_point *ecc_alloc_point(unsigned int ndigits) in ecc_alloc_point() argument
91 p->x = ecc_alloc_digits_space(ndigits); in ecc_alloc_point()
95 p->y = ecc_alloc_digits_space(ndigits); in ecc_alloc_point()
99 p->ndigits = ndigits; in ecc_alloc_point()
122 static void vli_clear(u64 *vli, unsigned int ndigits) in vli_clear() argument
126 for (i = 0; i < ndigits; i++) in vli_clear()
131 bool vli_is_zero(const u64 *vli, unsigned int ndigits) in vli_is_zero() argument
135 for (i = 0; i < ndigits; i++) { in vli_is_zero()
150 static bool vli_is_negative(const u64 *vli, unsigned int ndigits) in vli_is_negative() argument
152 return vli_test_bit(vli, ndigits * 64 - 1); in vli_is_negative()
156 static unsigned int vli_num_digits(const u64 *vli, unsigned int ndigits) in vli_num_digits() argument
164 for (i = ndigits - 1; i >= 0 && vli[i] == 0; i--); in vli_num_digits()
170 unsigned int vli_num_bits(const u64 *vli, unsigned int ndigits) in vli_num_bits() argument
175 num_digits = vli_num_digits(vli, ndigits); in vli_num_bits()
188 void vli_from_be64(u64 *dest, const void *src, unsigned int ndigits) in vli_from_be64() argument
193 for (i = 0; i < ndigits; i++) in vli_from_be64()
194 dest[i] = get_unaligned_be64(&from[ndigits - 1 - i]); in vli_from_be64()
198 void vli_from_le64(u64 *dest, const void *src, unsigned int ndigits) in vli_from_le64() argument
203 for (i = 0; i < ndigits; i++) in vli_from_le64()
209 static void vli_set(u64 *dest, const u64 *src, unsigned int ndigits) in vli_set() argument
213 for (i = 0; i < ndigits; i++) in vli_set()
218 int vli_cmp(const u64 *left, const u64 *right, unsigned int ndigits) in vli_cmp() argument
222 for (i = ndigits - 1; i >= 0; i--) { in vli_cmp()
237 unsigned int ndigits) in vli_lshift() argument
242 for (i = 0; i < ndigits; i++) { in vli_lshift()
253 static void vli_rshift1(u64 *vli, unsigned int ndigits) in vli_rshift1() argument
258 vli += ndigits; in vli_rshift1()
269 unsigned int ndigits) in vli_add() argument
274 for (i = 0; i < ndigits; i++) { in vli_add()
289 unsigned int ndigits) in vli_uadd() argument
294 for (i = 0; i < ndigits; i++) { in vli_uadd()
311 unsigned int ndigits) in vli_sub() argument
316 for (i = 0; i < ndigits; i++) { in vli_sub()
332 unsigned int ndigits) in vli_usub() argument
337 for (i = 0; i < ndigits; i++) { in vli_usub()
392 unsigned int ndigits) in vli_mult() argument
401 for (k = 0; k < ndigits * 2 - 1; k++) { in vli_mult()
404 if (k < ndigits) in vli_mult()
407 min = (k + 1) - ndigits; in vli_mult()
409 for (i = min; i <= k && i < ndigits; i++) { in vli_mult()
424 result[ndigits * 2 - 1] = r01.m_low; in vli_mult()
429 unsigned int ndigits) in vli_umult() argument
434 for (k = 0; k < ndigits; k++) { in vli_umult()
445 for (++k; k < ndigits * 2; k++) in vli_umult()
449 static void vli_square(u64 *result, const u64 *left, unsigned int ndigits) in vli_square() argument
455 for (k = 0; k < ndigits * 2 - 1; k++) { in vli_square()
458 if (k < ndigits) in vli_square()
461 min = (k + 1) - ndigits; in vli_square()
485 result[ndigits * 2 - 1] = r01.m_low; in vli_square()
492 const u64 *mod, unsigned int ndigits) in vli_mod_add() argument
496 carry = vli_add(result, left, right, ndigits); in vli_mod_add()
501 if (carry || vli_cmp(result, mod, ndigits) >= 0) in vli_mod_add()
502 vli_sub(result, result, mod, ndigits); in vli_mod_add()
509 const u64 *mod, unsigned int ndigits) in vli_mod_sub() argument
511 u64 borrow = vli_sub(result, left, right, ndigits); in vli_mod_sub()
518 vli_add(result, result, mod, ndigits); in vli_mod_sub()
531 const u64 *mod, unsigned int ndigits) in vli_mmod_special() argument
537 vli_set(r, product, ndigits * 2); in vli_mmod_special()
538 while (!vli_is_zero(r + ndigits, ndigits)) { in vli_mmod_special()
539 vli_umult(t, r + ndigits, c, ndigits); in vli_mmod_special()
540 vli_clear(r + ndigits, ndigits); in vli_mmod_special()
541 vli_add(r, r, t, ndigits * 2); in vli_mmod_special()
543 vli_set(t, mod, ndigits); in vli_mmod_special()
544 vli_clear(t + ndigits, ndigits); in vli_mmod_special()
545 while (vli_cmp(r, t, ndigits * 2) >= 0) in vli_mmod_special()
546 vli_sub(r, r, t, ndigits * 2); in vli_mmod_special()
547 vli_set(result, r, ndigits); in vli_mmod_special()
565 const u64 *mod, unsigned int ndigits) in vli_mmod_special2() argument
574 vli_set(m, mod, ndigits); in vli_mmod_special2()
575 vli_clear(m + ndigits, ndigits); in vli_mmod_special2()
577 vli_set(r, product, ndigits); in vli_mmod_special2()
579 vli_set(q, product + ndigits, ndigits); in vli_mmod_special2()
580 vli_clear(r + ndigits, ndigits); in vli_mmod_special2()
581 carry = vli_is_negative(r, ndigits); in vli_mmod_special2()
583 r[ndigits - 1] &= (1ull << 63) - 1; in vli_mmod_special2()
584 for (i = 1; carry || !vli_is_zero(q, ndigits); i++) { in vli_mmod_special2()
587 vli_umult(qc, q, c2, ndigits); in vli_mmod_special2()
589 vli_uadd(qc, qc, mod[0], ndigits * 2); in vli_mmod_special2()
590 vli_set(q, qc + ndigits, ndigits); in vli_mmod_special2()
591 vli_clear(qc + ndigits, ndigits); in vli_mmod_special2()
592 carry = vli_is_negative(qc, ndigits); in vli_mmod_special2()
594 qc[ndigits - 1] &= (1ull << 63) - 1; in vli_mmod_special2()
596 vli_sub(r, r, qc, ndigits * 2); in vli_mmod_special2()
598 vli_add(r, r, qc, ndigits * 2); in vli_mmod_special2()
600 while (vli_is_negative(r, ndigits * 2)) in vli_mmod_special2()
601 vli_add(r, r, m, ndigits * 2); in vli_mmod_special2()
602 while (vli_cmp(r, m, ndigits * 2) >= 0) in vli_mmod_special2()
603 vli_sub(r, r, m, ndigits * 2); in vli_mmod_special2()
605 vli_set(result, r, ndigits); in vli_mmod_special2()
614 unsigned int ndigits) in vli_mmod_slow() argument
622 int shift = (ndigits * 2 * 64) - vli_num_bits(mod, ndigits); in vli_mmod_slow()
628 for (i = 0; i < ndigits; ++i) { in vli_mmod_slow()
633 vli_set(mod_m + word_shift, mod, ndigits); in vli_mmod_slow()
639 for (j = 0; j < ndigits * 2; ++j) { in vli_mmod_slow()
647 vli_rshift1(mod_m, ndigits); in vli_mmod_slow()
648 mod_m[ndigits - 1] |= mod_m[ndigits] << (64 - 1); in vli_mmod_slow()
649 vli_rshift1(mod_m + ndigits, ndigits); in vli_mmod_slow()
651 vli_set(result, v[i], ndigits); in vli_mmod_slow()
664 unsigned int ndigits) in vli_mmod_barrett() argument
668 const u64 *mu = mod + ndigits; in vli_mmod_barrett()
670 vli_mult(q, product + ndigits, mu, ndigits); in vli_mmod_barrett()
671 if (mu[ndigits]) in vli_mmod_barrett()
672 vli_add(q + ndigits, q + ndigits, product + ndigits, ndigits); in vli_mmod_barrett()
673 vli_mult(r, mod, q + ndigits, ndigits); in vli_mmod_barrett()
674 vli_sub(r, product, r, ndigits * 2); in vli_mmod_barrett()
675 while (!vli_is_zero(r + ndigits, ndigits) || in vli_mmod_barrett()
676 vli_cmp(r, mod, ndigits) != -1) { in vli_mmod_barrett()
679 carry = vli_sub(r, r, mod, ndigits); in vli_mmod_barrett()
680 vli_usub(r + ndigits, r + ndigits, carry, ndigits); in vli_mmod_barrett()
682 vli_set(result, r, ndigits); in vli_mmod_barrett()
692 const unsigned int ndigits = 3; in vli_mmod_fast_192() local
695 vli_set(result, product, ndigits); in vli_mmod_fast_192()
697 vli_set(tmp, &product[3], ndigits); in vli_mmod_fast_192()
698 carry = vli_add(result, result, tmp, ndigits); in vli_mmod_fast_192()
703 carry += vli_add(result, result, tmp, ndigits); in vli_mmod_fast_192()
707 carry += vli_add(result, result, tmp, ndigits); in vli_mmod_fast_192()
709 while (carry || vli_cmp(curve_prime, result, ndigits) != 1) in vli_mmod_fast_192()
710 carry -= vli_sub(result, result, curve_prime, ndigits); in vli_mmod_fast_192()
720 const unsigned int ndigits = 4; in vli_mmod_fast_256() local
723 vli_set(result, product, ndigits); in vli_mmod_fast_256()
730 carry = vli_lshift(tmp, tmp, 1, ndigits); in vli_mmod_fast_256()
731 carry += vli_add(result, result, tmp, ndigits); in vli_mmod_fast_256()
737 carry += vli_lshift(tmp, tmp, 1, ndigits); in vli_mmod_fast_256()
738 carry += vli_add(result, result, tmp, ndigits); in vli_mmod_fast_256()
745 carry += vli_add(result, result, tmp, ndigits); in vli_mmod_fast_256()
752 carry += vli_add(result, result, tmp, ndigits); in vli_mmod_fast_256()
759 carry -= vli_sub(result, result, tmp, ndigits); in vli_mmod_fast_256()
766 carry -= vli_sub(result, result, tmp, ndigits); in vli_mmod_fast_256()
773 carry -= vli_sub(result, result, tmp, ndigits); in vli_mmod_fast_256()
780 carry -= vli_sub(result, result, tmp, ndigits); in vli_mmod_fast_256()
784 carry += vli_add(result, result, curve_prime, ndigits); in vli_mmod_fast_256()
787 while (carry || vli_cmp(curve_prime, result, ndigits) != 1) in vli_mmod_fast_256()
788 carry -= vli_sub(result, result, curve_prime, ndigits); in vli_mmod_fast_256()
803 const unsigned int ndigits = 6; in vli_mmod_fast_384() local
806 vli_set(result, product, ndigits); in vli_mmod_fast_384()
815 carry = vli_lshift(tmp, tmp, 1, ndigits); in vli_mmod_fast_384()
816 carry += vli_add(result, result, tmp, ndigits); in vli_mmod_fast_384()
825 carry += vli_add(result, result, tmp, ndigits); in vli_mmod_fast_384()
834 carry += vli_add(result, result, tmp, ndigits); in vli_mmod_fast_384()
843 carry += vli_add(result, result, tmp, ndigits); in vli_mmod_fast_384()
852 carry += vli_add(result, result, tmp, ndigits); in vli_mmod_fast_384()
861 carry += vli_add(result, result, tmp, ndigits); in vli_mmod_fast_384()
870 carry -= vli_sub(result, result, tmp, ndigits); in vli_mmod_fast_384()
879 carry -= vli_sub(result, result, tmp, ndigits); in vli_mmod_fast_384()
888 carry -= vli_sub(result, result, tmp, ndigits); in vli_mmod_fast_384()
892 carry += vli_add(result, result, curve_prime, ndigits); in vli_mmod_fast_384()
895 while (carry || vli_cmp(curve_prime, result, ndigits) != 1) in vli_mmod_fast_384()
896 carry -= vli_sub(result, result, curve_prime, ndigits); in vli_mmod_fast_384()
915 const unsigned int ndigits = curve->g.ndigits; in vli_mmod_fast() local
920 if (curve_prime[ndigits - 1] == -1ull) { in vli_mmod_fast()
922 ndigits); in vli_mmod_fast()
924 } else if (curve_prime[ndigits - 1] == 1ull << 63 && in vli_mmod_fast()
925 curve_prime[ndigits - 2] == 0) { in vli_mmod_fast()
927 ndigits); in vli_mmod_fast()
930 vli_mmod_barrett(result, product, curve_prime, ndigits); in vli_mmod_fast()
934 switch (ndigits) { in vli_mmod_fast()
956 const u64 *mod, unsigned int ndigits) in vli_mod_mult_slow() argument
960 vli_mult(product, left, right, ndigits); in vli_mod_mult_slow()
961 vli_mmod_slow(result, product, mod, ndigits); in vli_mod_mult_slow()
971 vli_mult(product, left, right, curve->g.ndigits); in vli_mod_mult_fast()
981 vli_square(product, left, curve->g.ndigits); in vli_mod_square_fast()
991 unsigned int ndigits) in vli_mod_inv() argument
998 if (vli_is_zero(input, ndigits)) { in vli_mod_inv()
999 vli_clear(result, ndigits); in vli_mod_inv()
1003 vli_set(a, input, ndigits); in vli_mod_inv()
1004 vli_set(b, mod, ndigits); in vli_mod_inv()
1005 vli_clear(u, ndigits); in vli_mod_inv()
1007 vli_clear(v, ndigits); in vli_mod_inv()
1009 while ((cmp_result = vli_cmp(a, b, ndigits)) != 0) { in vli_mod_inv()
1013 vli_rshift1(a, ndigits); in vli_mod_inv()
1016 carry = vli_add(u, u, mod, ndigits); in vli_mod_inv()
1018 vli_rshift1(u, ndigits); in vli_mod_inv()
1020 u[ndigits - 1] |= 0x8000000000000000ull; in vli_mod_inv()
1022 vli_rshift1(b, ndigits); in vli_mod_inv()
1025 carry = vli_add(v, v, mod, ndigits); in vli_mod_inv()
1027 vli_rshift1(v, ndigits); in vli_mod_inv()
1029 v[ndigits - 1] |= 0x8000000000000000ull; in vli_mod_inv()
1031 vli_sub(a, a, b, ndigits); in vli_mod_inv()
1032 vli_rshift1(a, ndigits); in vli_mod_inv()
1034 if (vli_cmp(u, v, ndigits) < 0) in vli_mod_inv()
1035 vli_add(u, u, mod, ndigits); in vli_mod_inv()
1037 vli_sub(u, u, v, ndigits); in vli_mod_inv()
1039 carry = vli_add(u, u, mod, ndigits); in vli_mod_inv()
1041 vli_rshift1(u, ndigits); in vli_mod_inv()
1043 u[ndigits - 1] |= 0x8000000000000000ull; in vli_mod_inv()
1045 vli_sub(b, b, a, ndigits); in vli_mod_inv()
1046 vli_rshift1(b, ndigits); in vli_mod_inv()
1048 if (vli_cmp(v, u, ndigits) < 0) in vli_mod_inv()
1049 vli_add(v, v, mod, ndigits); in vli_mod_inv()
1051 vli_sub(v, v, u, ndigits); in vli_mod_inv()
1053 carry = vli_add(v, v, mod, ndigits); in vli_mod_inv()
1055 vli_rshift1(v, ndigits); in vli_mod_inv()
1057 v[ndigits - 1] |= 0x8000000000000000ull; in vli_mod_inv()
1061 vli_set(result, u, ndigits); in vli_mod_inv()
1070 return (vli_is_zero(point->x, point->ndigits) && in ecc_point_is_zero()
1071 vli_is_zero(point->y, point->ndigits)); in ecc_point_is_zero()
1087 const unsigned int ndigits = curve->g.ndigits; in ecc_point_double_jacobian() local
1089 if (vli_is_zero(z1, ndigits)) in ecc_point_double_jacobian()
1104 vli_mod_add(x1, x1, z1, curve_prime, ndigits); in ecc_point_double_jacobian()
1106 vli_mod_add(z1, z1, z1, curve_prime, ndigits); in ecc_point_double_jacobian()
1108 vli_mod_sub(z1, x1, z1, curve_prime, ndigits); in ecc_point_double_jacobian()
1113 vli_mod_add(z1, x1, x1, curve_prime, ndigits); in ecc_point_double_jacobian()
1115 vli_mod_add(x1, x1, z1, curve_prime, ndigits); in ecc_point_double_jacobian()
1117 u64 carry = vli_add(x1, x1, curve_prime, ndigits); in ecc_point_double_jacobian()
1119 vli_rshift1(x1, ndigits); in ecc_point_double_jacobian()
1120 x1[ndigits - 1] |= carry << 63; in ecc_point_double_jacobian()
1122 vli_rshift1(x1, ndigits); in ecc_point_double_jacobian()
1129 vli_mod_sub(z1, z1, t5, curve_prime, ndigits); in ecc_point_double_jacobian()
1131 vli_mod_sub(z1, z1, t5, curve_prime, ndigits); in ecc_point_double_jacobian()
1133 vli_mod_sub(t5, t5, z1, curve_prime, ndigits); in ecc_point_double_jacobian()
1137 vli_mod_sub(t4, x1, t4, curve_prime, ndigits); in ecc_point_double_jacobian()
1139 vli_set(x1, z1, ndigits); in ecc_point_double_jacobian()
1140 vli_set(z1, y1, ndigits); in ecc_point_double_jacobian()
1141 vli_set(y1, t4, ndigits); in ecc_point_double_jacobian()
1160 const unsigned int ndigits = curve->g.ndigits; in xycz_initial_double() local
1162 vli_set(x2, x1, ndigits); in xycz_initial_double()
1163 vli_set(y2, y1, ndigits); in xycz_initial_double()
1165 vli_clear(z, ndigits); in xycz_initial_double()
1169 vli_set(z, p_initial_z, ndigits); in xycz_initial_double()
1188 const unsigned int ndigits = curve->g.ndigits; in xycz_add() local
1191 vli_mod_sub(t5, x2, x1, curve_prime, ndigits); in xycz_add()
1199 vli_mod_sub(y2, y2, y1, curve_prime, ndigits); in xycz_add()
1204 vli_mod_sub(t5, t5, x1, curve_prime, ndigits); in xycz_add()
1206 vli_mod_sub(t5, t5, x2, curve_prime, ndigits); in xycz_add()
1208 vli_mod_sub(x2, x2, x1, curve_prime, ndigits); in xycz_add()
1212 vli_mod_sub(x2, x1, t5, curve_prime, ndigits); in xycz_add()
1216 vli_mod_sub(y2, y2, y1, curve_prime, ndigits); in xycz_add()
1218 vli_set(x2, t5, ndigits); in xycz_add()
1233 const unsigned int ndigits = curve->g.ndigits; in xycz_add_c() local
1236 vli_mod_sub(t5, x2, x1, curve_prime, ndigits); in xycz_add_c()
1244 vli_mod_add(t5, y2, y1, curve_prime, ndigits); in xycz_add_c()
1246 vli_mod_sub(y2, y2, y1, curve_prime, ndigits); in xycz_add_c()
1249 vli_mod_sub(t6, x2, x1, curve_prime, ndigits); in xycz_add_c()
1253 vli_mod_add(t6, x1, x2, curve_prime, ndigits); in xycz_add_c()
1257 vli_mod_sub(x2, x2, t6, curve_prime, ndigits); in xycz_add_c()
1260 vli_mod_sub(t7, x1, x2, curve_prime, ndigits); in xycz_add_c()
1264 vli_mod_sub(y2, y2, y1, curve_prime, ndigits); in xycz_add_c()
1269 vli_mod_sub(t7, t7, t6, curve_prime, ndigits); in xycz_add_c()
1271 vli_mod_sub(t6, t7, x1, curve_prime, ndigits); in xycz_add_c()
1275 vli_mod_sub(y1, t6, y1, curve_prime, ndigits); in xycz_add_c()
1277 vli_set(x1, t7, ndigits); in xycz_add_c()
1283 unsigned int ndigits) in ecc_point_mult() argument
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()
1298 num_bits = sizeof(u64) * ndigits * 8 + 1; in ecc_point_mult()
1300 vli_set(rx[1], point->x, ndigits); in ecc_point_mult()
1301 vli_set(ry[1], point->y, ndigits); in ecc_point_mult()
1316 vli_mod_sub(z, rx[1], rx[0], curve_prime, ndigits); in ecc_point_mult()
1323 vli_mod_inv(z, z, curve_prime, point->ndigits); in ecc_point_mult()
1335 vli_set(result->x, rx[0], ndigits); in ecc_point_mult()
1336 vli_set(result->y, ry[0], ndigits); in ecc_point_mult()
1347 unsigned int ndigits = curve->g.ndigits; in ecc_point_add() local
1349 vli_set(result->x, q->x, ndigits); in ecc_point_add()
1350 vli_set(result->y, q->y, ndigits); in ecc_point_add()
1351 vli_mod_sub(z, result->x, p->x, curve->p, ndigits); in ecc_point_add()
1352 vli_set(px, p->x, ndigits); in ecc_point_add()
1353 vli_set(py, p->y, ndigits); in ecc_point_add()
1355 vli_mod_inv(z, z, curve->p, ndigits); in ecc_point_add()
1371 unsigned int ndigits = curve->g.ndigits; in ecc_point_mult_shamir() local
1373 struct ecc_point sum = ECC_POINT_INIT(sump[0], sump[1], ndigits); in ecc_point_mult_shamir()
1385 num_bits = max(vli_num_bits(u1, ndigits), vli_num_bits(u2, ndigits)); in ecc_point_mult_shamir()
1390 vli_set(rx, point->x, ndigits); in ecc_point_mult_shamir()
1391 vli_set(ry, point->y, ndigits); in ecc_point_mult_shamir()
1392 vli_clear(z + 1, ndigits - 1); in ecc_point_mult_shamir()
1404 vli_set(tx, point->x, ndigits); in ecc_point_mult_shamir()
1405 vli_set(ty, point->y, ndigits); in ecc_point_mult_shamir()
1407 vli_mod_sub(tz, rx, tx, curve->p, ndigits); in ecc_point_mult_shamir()
1412 vli_mod_inv(z, z, curve->p, ndigits); in ecc_point_mult_shamir()
1418 const u64 *private_key, unsigned int ndigits) in __ecc_is_key_valid() argument
1426 if (curve->g.ndigits != ndigits) in __ecc_is_key_valid()
1430 if (vli_cmp(one, private_key, ndigits) != -1) in __ecc_is_key_valid()
1432 vli_sub(res, curve->n, one, ndigits); in __ecc_is_key_valid()
1433 vli_sub(res, res, one, ndigits); in __ecc_is_key_valid()
1434 if (vli_cmp(res, private_key, ndigits) != 1) in __ecc_is_key_valid()
1440 int ecc_is_key_valid(unsigned int curve_id, unsigned int ndigits, in ecc_is_key_valid() argument
1446 nbytes = ndigits << ECC_DIGITS_TO_BYTES_SHIFT; in ecc_is_key_valid()
1451 return __ecc_is_key_valid(curve, private_key, ndigits); in ecc_is_key_valid()
1467 int ecc_gen_privkey(unsigned int curve_id, unsigned int ndigits, u64 *privkey) in ecc_gen_privkey() argument
1471 unsigned int nbytes = ndigits << ECC_DIGITS_TO_BYTES_SHIFT; in ecc_gen_privkey()
1472 unsigned int nbits = vli_num_bits(curve->n, ndigits); in ecc_gen_privkey()
1476 if (nbits < 160 || ndigits > ARRAY_SIZE(priv)) in ecc_gen_privkey()
1499 if (__ecc_is_key_valid(curve, priv, ndigits)) in ecc_gen_privkey()
1502 ecc_swap_digits(priv, privkey, ndigits); in ecc_gen_privkey()
1508 int ecc_make_pub_key(unsigned int curve_id, unsigned int ndigits, in ecc_make_pub_key() argument
1516 if (!private_key || !curve || ndigits > ARRAY_SIZE(priv)) { in ecc_make_pub_key()
1521 ecc_swap_digits(private_key, priv, ndigits); in ecc_make_pub_key()
1523 pk = ecc_alloc_point(ndigits); in ecc_make_pub_key()
1529 ecc_point_mult(pk, &curve->g, priv, NULL, curve, ndigits); in ecc_make_pub_key()
1537 ecc_swap_digits(pk->x, public_key, ndigits); in ecc_make_pub_key()
1538 ecc_swap_digits(pk->y, &public_key[ndigits], ndigits); in ecc_make_pub_key()
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()
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()
1573 if (vli_cmp(yy, w, pk->ndigits) != 0) /* Equation */ in ecc_is_pubkey_valid_partial()
1593 nQ = ecc_alloc_point(pk->ndigits); in ecc_is_pubkey_valid_full()
1597 ecc_point_mult(nQ, pk, curve->n, NULL, curve, pk->ndigits); in ecc_is_pubkey_valid_full()
1607 int crypto_ecdh_shared_secret(unsigned int curve_id, unsigned int ndigits, in crypto_ecdh_shared_secret() argument
1619 ndigits > ARRAY_SIZE(priv) || ndigits > ARRAY_SIZE(rand_z)) { in crypto_ecdh_shared_secret()
1624 nbytes = ndigits << ECC_DIGITS_TO_BYTES_SHIFT; in crypto_ecdh_shared_secret()
1628 pk = ecc_alloc_point(ndigits); in crypto_ecdh_shared_secret()
1634 ecc_swap_digits(public_key, pk->x, ndigits); in crypto_ecdh_shared_secret()
1635 ecc_swap_digits(&public_key[ndigits], pk->y, ndigits); in crypto_ecdh_shared_secret()
1640 ecc_swap_digits(private_key, priv, ndigits); in crypto_ecdh_shared_secret()
1642 product = ecc_alloc_point(ndigits); in crypto_ecdh_shared_secret()
1648 ecc_point_mult(product, pk, priv, rand_z, curve, ndigits); in crypto_ecdh_shared_secret()
1655 ecc_swap_digits(product->x, secret, ndigits); in crypto_ecdh_shared_secret()