Lines Matching refs:P
520 mbedtls_mpi_init(&grp->P); in mbedtls_ecp_group_init()
617 int mbedtls_ecp_copy(mbedtls_ecp_point *P, const mbedtls_ecp_point *Q) in mbedtls_ecp_copy() argument
620 MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&P->X, &Q->X)); in mbedtls_ecp_copy()
621 MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&P->Y, &Q->Y)); in mbedtls_ecp_copy()
622 MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&P->Z, &Q->Z)); in mbedtls_ecp_copy()
661 int mbedtls_ecp_point_cmp(const mbedtls_ecp_point *P, in mbedtls_ecp_point_cmp() argument
664 if (mbedtls_mpi_cmp_mpi(&P->X, &Q->X) == 0 && in mbedtls_ecp_point_cmp()
665 mbedtls_mpi_cmp_mpi(&P->Y, &Q->Y) == 0 && in mbedtls_ecp_point_cmp()
666 mbedtls_mpi_cmp_mpi(&P->Z, &Q->Z) == 0) { in mbedtls_ecp_point_cmp()
676 int mbedtls_ecp_point_read_string(mbedtls_ecp_point *P, int radix, in mbedtls_ecp_point_read_string() argument
680 MBEDTLS_MPI_CHK(mbedtls_mpi_read_string(&P->X, radix, x)); in mbedtls_ecp_point_read_string()
681 MBEDTLS_MPI_CHK(mbedtls_mpi_read_string(&P->Y, radix, y)); in mbedtls_ecp_point_read_string()
682 MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&P->Z, 1)); in mbedtls_ecp_point_read_string()
692 const mbedtls_ecp_point *P, in mbedtls_ecp_point_write_binary() argument
703 plen = mbedtls_mpi_size(&grp->P); in mbedtls_ecp_point_write_binary()
713 MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary_le(&P->X, buf, plen)); in mbedtls_ecp_point_write_binary()
721 if (mbedtls_mpi_cmp_int(&P->Z, 0) == 0) { in mbedtls_ecp_point_write_binary()
740 MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&P->X, buf + 1, plen)); in mbedtls_ecp_point_write_binary()
741 MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&P->Y, buf + 1 + plen, plen)); in mbedtls_ecp_point_write_binary()
749 buf[0] = 0x02 + mbedtls_mpi_get_bit(&P->Y, 0); in mbedtls_ecp_point_write_binary()
750 MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&P->X, buf + 1, plen)); in mbedtls_ecp_point_write_binary()
779 plen = mbedtls_mpi_size(&grp->P); in mbedtls_ecp_point_read_binary()
1005 return mbedtls_mpi_mod_mpi(N, N, &grp->P); in ecp_modp()
1018 MBEDTLS_MPI_CHK(mbedtls_mpi_add_mpi(N, N, &grp->P)); in ecp_modp()
1021 while (mbedtls_mpi_cmp_mpi(N, &grp->P) >= 0) { in ecp_modp()
1023 MBEDTLS_MPI_CHK(mbedtls_mpi_sub_abs(N, N, &grp->P)); in ecp_modp()
1075 MBEDTLS_MPI_CHK(mbedtls_mpi_add_mpi((N), (N), &grp->P)); \
1104 while (mbedtls_mpi_cmp_mpi((N), &grp->P) >= 0) \
1105 MBEDTLS_MPI_CHK(mbedtls_mpi_sub_abs((N), (N), &grp->P))
1187 MBEDTLS_MPI_CHK(mbedtls_mpi_inv_mod((dst), (src), &grp->P))
1206 MBEDTLS_MPI_CHK(mbedtls_mpi_random((X), 2, &grp->P, f_rng, p_rng))
1214 MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mpi(&tmp, &grp->P, (X))); \
1276 if (mbedtls_mpi_get_bit(&grp->P, 0) != 1 || in mbedtls_ecp_sw_derive_y()
1277 mbedtls_mpi_get_bit(&grp->P, 1) != 1) { in mbedtls_ecp_sw_derive_y()
1290 MBEDTLS_MPI_CHK(mbedtls_mpi_add_int(&exp, &grp->P, 1)); in mbedtls_ecp_sw_derive_y()
1293 MBEDTLS_MPI_CHK(mbedtls_mpi_exp_mod(Y, Y /*y^2*/, &exp, &grp->P, NULL)); in mbedtls_ecp_sw_derive_y()
1301 MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mpi(Y, &grp->P, Y)); in mbedtls_ecp_sw_derive_y()
1441 MBEDTLS_MPI_CHK(mbedtls_mpi_shrink(&T[i]->X, grp->P.n)); in ecp_normalize_jac_many()
1442 MBEDTLS_MPI_CHK(mbedtls_mpi_shrink(&T[i]->Y, grp->P.n)); in ecp_normalize_jac_many()
1495 const mbedtls_ecp_point *P, in ecp_double_jac() argument
1504 return mbedtls_internal_ecp_double_jac(grp, R, P); in ecp_double_jac()
1516 MPI_ECP_SQR(&tmp[1], &P->Z); in ecp_double_jac()
1517 MPI_ECP_ADD(&tmp[2], &P->X, &tmp[1]); in ecp_double_jac()
1518 MPI_ECP_SUB(&tmp[3], &P->X, &tmp[1]); in ecp_double_jac()
1523 MPI_ECP_SQR(&tmp[1], &P->X); in ecp_double_jac()
1529 MPI_ECP_SQR(&tmp[1], &P->Z); in ecp_double_jac()
1537 MPI_ECP_SQR(&tmp[2], &P->Y); in ecp_double_jac()
1539 MPI_ECP_MUL(&tmp[1], &P->X, &tmp[2]); in ecp_double_jac()
1557 MPI_ECP_MUL(&tmp[3], &P->Y, &P->Z); in ecp_double_jac()
1592 const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q, in ecp_add_mixed() argument
1601 return mbedtls_internal_ecp_add_mixed(grp, R, P, Q); in ecp_add_mixed()
1624 if (MPI_ECP_CMP_INT(&P->Z, 0) == 0) { in ecp_add_mixed()
1629 return mbedtls_ecp_copy(R, P); in ecp_add_mixed()
1639 MPI_ECP_SQR(&tmp[0], &P->Z); in ecp_add_mixed()
1640 MPI_ECP_MUL(&tmp[1], &tmp[0], &P->Z); in ecp_add_mixed()
1643 MPI_ECP_SUB(&tmp[0], &tmp[0], &P->X); in ecp_add_mixed()
1644 MPI_ECP_SUB(&tmp[1], &tmp[1], &P->Y); in ecp_add_mixed()
1649 ret = ecp_double_jac(grp, R, P, tmp); in ecp_add_mixed()
1658 MPI_ECP_MUL(Z, &P->Z, &tmp[0]); in ecp_add_mixed()
1661 MPI_ECP_MUL(&tmp[2], &tmp[2], &P->X); in ecp_add_mixed()
1672 MPI_ECP_MUL(&tmp[3], &tmp[3], &P->Y); in ecp_add_mixed()
1858 mbedtls_ecp_point T[], const mbedtls_ecp_point *P, in ecp_precompute_comb() argument
1905 MBEDTLS_MPI_CHK(mbedtls_ecp_copy(&T[0], P)); in ecp_precompute_comb()
2298 const mbedtls_mpi *m, const mbedtls_ecp_point *P, in ecp_mul_comb() argument
2313 p_eq_g = (MPI_ECP_CMP(&P->Y, &grp->G.Y) == 0 && in ecp_mul_comb()
2314 MPI_ECP_CMP(&P->X, &grp->G.X) == 0); in ecp_mul_comb()
2359 MBEDTLS_MPI_CHK(ecp_precompute_comb(grp, T, P, w, d, rs_ctx)); in ecp_mul_comb()
2431 static int ecp_normalize_mxz(const mbedtls_ecp_group *grp, mbedtls_ecp_point *P) in ecp_normalize_mxz() argument
2435 return mbedtls_internal_ecp_normalize_mxz(grp, P); in ecp_normalize_mxz()
2443 MPI_ECP_INV(&P->Z, &P->Z); in ecp_normalize_mxz()
2444 MPI_ECP_MUL(&P->X, &P->X, &P->Z); in ecp_normalize_mxz()
2445 MPI_ECP_LSET(&P->Z, 1); in ecp_normalize_mxz()
2460 static int ecp_randomize_mxz(const mbedtls_ecp_group *grp, mbedtls_ecp_point *P, in ecp_randomize_mxz() argument
2465 return mbedtls_internal_ecp_randomize_mxz(grp, P, f_rng, p_rng); in ecp_randomize_mxz()
2479 MPI_ECP_MUL(&P->X, &P->X, &l); in ecp_randomize_mxz()
2480 MPI_ECP_MUL(&P->Z, &P->Z, &l); in ecp_randomize_mxz()
2509 const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q, in ecp_double_add_mxz() argument
2515 return mbedtls_internal_ecp_double_add_mxz(grp, R, S, P, Q, d); in ecp_double_add_mxz()
2524 MPI_ECP_ADD(&T[0], &P->X, &P->Z); /* Pp := PX + PZ */ in ecp_double_add_mxz()
2525 MPI_ECP_SUB(&T[1], &P->X, &P->Z); /* Pm := PX - PZ */ in ecp_double_add_mxz()
2554 const mbedtls_mpi *m, const mbedtls_ecp_point *P, in ecp_mul_mxz() argument
2573 MPI_ECP_MOV(&PX, &P->X); in ecp_mul_mxz()
2574 MBEDTLS_MPI_CHK(mbedtls_ecp_copy(&RP, P)); in ecp_mul_mxz()
2635 const mbedtls_mpi *m, const mbedtls_ecp_point *P, in ecp_mul_restartable_internal() argument
2670 MBEDTLS_MPI_CHK(mbedtls_ecp_check_pubkey(grp, P)); in ecp_mul_restartable_internal()
2676 MBEDTLS_MPI_CHK(ecp_mul_mxz(grp, R, m, P, f_rng, p_rng)); in ecp_mul_restartable_internal()
2681 MBEDTLS_MPI_CHK(ecp_mul_comb(grp, R, m, P, f_rng, p_rng, rs_ctx)); in ecp_mul_restartable_internal()
2706 const mbedtls_mpi *m, const mbedtls_ecp_point *P, in mbedtls_ecp_mul_restartable() argument
2714 return ecp_mul_restartable_internal(grp, R, m, P, f_rng, p_rng, rs_ctx); in mbedtls_ecp_mul_restartable()
2721 const mbedtls_mpi *m, const mbedtls_ecp_point *P, in mbedtls_ecp_mul() argument
2724 return mbedtls_ecp_mul_restartable(grp, R, m, P, f_rng, p_rng, NULL); in mbedtls_ecp_mul()
2740 mbedtls_mpi_cmp_mpi(&pt->X, &grp->P) >= 0 || in ecp_check_pubkey_sw()
2741 mbedtls_mpi_cmp_mpi(&pt->Y, &grp->P) >= 0) { in ecp_check_pubkey_sw()
2774 const mbedtls_ecp_point *P, in mbedtls_ecp_mul_shortcuts() argument
2782 MBEDTLS_MPI_CHK(mbedtls_ecp_check_pubkey(grp, P)); in mbedtls_ecp_mul_shortcuts()
2785 MBEDTLS_MPI_CHK(mbedtls_ecp_check_pubkey(grp, P)); in mbedtls_ecp_mul_shortcuts()
2786 MBEDTLS_MPI_CHK(mbedtls_ecp_copy(R, P)); in mbedtls_ecp_mul_shortcuts()
2788 MBEDTLS_MPI_CHK(mbedtls_ecp_check_pubkey(grp, P)); in mbedtls_ecp_mul_shortcuts()
2789 MBEDTLS_MPI_CHK(mbedtls_ecp_copy(R, P)); in mbedtls_ecp_mul_shortcuts()
2792 MBEDTLS_MPI_CHK(ecp_mul_restartable_internal(grp, R, m, P, in mbedtls_ecp_mul_shortcuts()
2808 const mbedtls_mpi *m, const mbedtls_ecp_point *P, in mbedtls_ecp_muladd_restartable() argument
2848 MBEDTLS_MPI_CHK(mbedtls_ecp_mul_shortcuts(grp, pmP, m, P, rs_ctx)); in mbedtls_ecp_muladd_restartable()
2911 const mbedtls_mpi *m, const mbedtls_ecp_point *P, in mbedtls_ecp_muladd() argument
2914 return mbedtls_ecp_muladd_restartable(grp, R, m, P, n, Q, NULL); in mbedtls_ecp_muladd()
2952 static int ecp_check_bad_points_mx(const mbedtls_mpi *X, const mbedtls_mpi *P, in ecp_check_bad_points_mx() argument
2963 while (mbedtls_mpi_cmp_mpi(&XmP, P) >= 0) { in ecp_check_bad_points_mx()
2964 MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mpi(&XmP, &XmP, P)); in ecp_check_bad_points_mx()
2993 if (mbedtls_mpi_cmp_mpi(&XmP, P) == 0) { in ecp_check_bad_points_mx()
3025 return ecp_check_bad_points_mx(&pt->X, &grp->P, grp->id); in ecp_check_pubkey_mx()
3448 const mbedtls_ecp_point *P, in self_test_point() argument
3461 MBEDTLS_MPI_CHK(mbedtls_ecp_mul(grp, R, m, P, self_test_rng, NULL)); in self_test_point()
3473 MBEDTLS_MPI_CHK(mbedtls_ecp_mul(grp, R, m, P, self_test_rng, NULL)); in self_test_point()
3501 mbedtls_ecp_point R, P; in mbedtls_ecp_self_test() local
3535 mbedtls_ecp_point_init(&P); in mbedtls_ecp_self_test()
3551 MBEDTLS_MPI_CHK(mbedtls_ecp_mul(&grp, &P, &m, &grp.G, self_test_rng, NULL)); in mbedtls_ecp_self_test()
3565 &grp, &R, &m, &P, in mbedtls_ecp_self_test()
3604 mbedtls_ecp_point_free(&P); in mbedtls_ecp_self_test()