Lines Matching refs:P

519     mbedtls_mpi_init(&grp->P);  in mbedtls_ecp_group_init()
590 mbedtls_mpi_free(&grp->P); in mbedtls_ecp_group_free()
621 int mbedtls_ecp_copy(mbedtls_ecp_point *P, const mbedtls_ecp_point *Q) in mbedtls_ecp_copy() argument
624 MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&P->X, &Q->X)); in mbedtls_ecp_copy()
625 MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&P->Y, &Q->Y)); in mbedtls_ecp_copy()
626 MBEDTLS_MPI_CHK(mbedtls_mpi_copy(&P->Z, &Q->Z)); in mbedtls_ecp_copy()
665 int mbedtls_ecp_point_cmp(const mbedtls_ecp_point *P, in mbedtls_ecp_point_cmp() argument
668 if (mbedtls_mpi_cmp_mpi(&P->X, &Q->X) == 0 && in mbedtls_ecp_point_cmp()
669 mbedtls_mpi_cmp_mpi(&P->Y, &Q->Y) == 0 && in mbedtls_ecp_point_cmp()
670 mbedtls_mpi_cmp_mpi(&P->Z, &Q->Z) == 0) { in mbedtls_ecp_point_cmp()
680 int mbedtls_ecp_point_read_string(mbedtls_ecp_point *P, int radix, in mbedtls_ecp_point_read_string() argument
684 MBEDTLS_MPI_CHK(mbedtls_mpi_read_string(&P->X, radix, x)); in mbedtls_ecp_point_read_string()
685 MBEDTLS_MPI_CHK(mbedtls_mpi_read_string(&P->Y, radix, y)); in mbedtls_ecp_point_read_string()
686 MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&P->Z, 1)); in mbedtls_ecp_point_read_string()
696 const mbedtls_ecp_point *P, in mbedtls_ecp_point_write_binary() argument
707 plen = mbedtls_mpi_size(&grp->P); in mbedtls_ecp_point_write_binary()
717 MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary_le(&P->X, buf, plen)); in mbedtls_ecp_point_write_binary()
725 if (mbedtls_mpi_cmp_int(&P->Z, 0) == 0) { in mbedtls_ecp_point_write_binary()
744 MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&P->X, buf + 1, plen)); in mbedtls_ecp_point_write_binary()
745 MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&P->Y, buf + 1 + plen, plen)); in mbedtls_ecp_point_write_binary()
753 buf[0] = 0x02 + mbedtls_mpi_get_bit(&P->Y, 0); in mbedtls_ecp_point_write_binary()
754 MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&P->X, buf + 1, plen)); in mbedtls_ecp_point_write_binary()
783 plen = mbedtls_mpi_size(&grp->P); in mbedtls_ecp_point_read_binary()
1008 return mbedtls_mpi_mod_mpi(N, N, &grp->P); in ecp_modp()
1021 MBEDTLS_MPI_CHK(mbedtls_mpi_add_mpi(N, N, &grp->P)); in ecp_modp()
1024 while (mbedtls_mpi_cmp_mpi(N, &grp->P) >= 0) { in ecp_modp()
1026 MBEDTLS_MPI_CHK(mbedtls_mpi_sub_abs(N, N, &grp->P)); in ecp_modp()
1078 MBEDTLS_MPI_CHK(mbedtls_mpi_add_mpi((N), (N), &grp->P)); \
1100 while (mbedtls_mpi_cmp_mpi((N), &grp->P) >= 0) \
1101 MBEDTLS_MPI_CHK(mbedtls_mpi_sub_abs((N), (N), &grp->P))
1180 MBEDTLS_MPI_CHK(mbedtls_mpi_inv_mod((dst), (src), &grp->P))
1199 MBEDTLS_MPI_CHK(mbedtls_mpi_random((X), 2, &grp->P, f_rng, p_rng))
1207 MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mpi(&tmp, &grp->P, (X))); \
1269 if (mbedtls_mpi_get_bit(&grp->P, 0) != 1 || in mbedtls_ecp_sw_derive_y()
1270 mbedtls_mpi_get_bit(&grp->P, 1) != 1) { in mbedtls_ecp_sw_derive_y()
1283 MBEDTLS_MPI_CHK(mbedtls_mpi_add_int(&exp, &grp->P, 1)); in mbedtls_ecp_sw_derive_y()
1286 MBEDTLS_MPI_CHK(mbedtls_mpi_exp_mod(Y, Y /*y^2*/, &exp, &grp->P, NULL)); in mbedtls_ecp_sw_derive_y()
1294 MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mpi(Y, &grp->P, Y)); in mbedtls_ecp_sw_derive_y()
1437 MBEDTLS_MPI_CHK(mbedtls_mpi_shrink(&T[i]->X, grp->P.n)); in ecp_normalize_jac_many()
1438 MBEDTLS_MPI_CHK(mbedtls_mpi_shrink(&T[i]->Y, grp->P.n)); in ecp_normalize_jac_many()
1491 const mbedtls_ecp_point *P, in ecp_double_jac() argument
1500 return mbedtls_internal_ecp_double_jac(grp, R, P); in ecp_double_jac()
1512 MPI_ECP_SQR(&tmp[1], &P->Z); in ecp_double_jac()
1513 MPI_ECP_ADD(&tmp[2], &P->X, &tmp[1]); in ecp_double_jac()
1514 MPI_ECP_SUB(&tmp[3], &P->X, &tmp[1]); in ecp_double_jac()
1519 MPI_ECP_SQR(&tmp[1], &P->X); in ecp_double_jac()
1525 MPI_ECP_SQR(&tmp[1], &P->Z); in ecp_double_jac()
1533 MPI_ECP_SQR(&tmp[2], &P->Y); in ecp_double_jac()
1535 MPI_ECP_MUL(&tmp[1], &P->X, &tmp[2]); in ecp_double_jac()
1553 MPI_ECP_MUL(&tmp[3], &P->Y, &P->Z); in ecp_double_jac()
1588 const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q, in ecp_add_mixed() argument
1597 return mbedtls_internal_ecp_add_mixed(grp, R, P, Q); in ecp_add_mixed()
1620 if (MPI_ECP_CMP_INT(&P->Z, 0) == 0) { in ecp_add_mixed()
1625 return mbedtls_ecp_copy(R, P); in ecp_add_mixed()
1635 MPI_ECP_SQR(&tmp[0], &P->Z); in ecp_add_mixed()
1636 MPI_ECP_MUL(&tmp[1], &tmp[0], &P->Z); in ecp_add_mixed()
1639 MPI_ECP_SUB(&tmp[0], &tmp[0], &P->X); in ecp_add_mixed()
1640 MPI_ECP_SUB(&tmp[1], &tmp[1], &P->Y); in ecp_add_mixed()
1645 ret = ecp_double_jac(grp, R, P, tmp); in ecp_add_mixed()
1654 MPI_ECP_MUL(Z, &P->Z, &tmp[0]); in ecp_add_mixed()
1657 MPI_ECP_MUL(&tmp[2], &tmp[2], &P->X); in ecp_add_mixed()
1668 MPI_ECP_MUL(&tmp[3], &tmp[3], &P->Y); in ecp_add_mixed()
1854 mbedtls_ecp_point T[], const mbedtls_ecp_point *P, in ecp_precompute_comb() argument
1901 MBEDTLS_MPI_CHK(mbedtls_ecp_copy(&T[0], P)); in ecp_precompute_comb()
2294 const mbedtls_mpi *m, const mbedtls_ecp_point *P, in ecp_mul_comb() argument
2309 p_eq_g = (MPI_ECP_CMP(&P->Y, &grp->G.Y) == 0 && in ecp_mul_comb()
2310 MPI_ECP_CMP(&P->X, &grp->G.X) == 0); in ecp_mul_comb()
2355 MBEDTLS_MPI_CHK(ecp_precompute_comb(grp, T, P, w, d, rs_ctx)); in ecp_mul_comb()
2427 static int ecp_normalize_mxz(const mbedtls_ecp_group *grp, mbedtls_ecp_point *P) in ecp_normalize_mxz() argument
2431 return mbedtls_internal_ecp_normalize_mxz(grp, P); in ecp_normalize_mxz()
2439 MPI_ECP_INV(&P->Z, &P->Z); in ecp_normalize_mxz()
2440 MPI_ECP_MUL(&P->X, &P->X, &P->Z); in ecp_normalize_mxz()
2441 MPI_ECP_LSET(&P->Z, 1); in ecp_normalize_mxz()
2456 static int ecp_randomize_mxz(const mbedtls_ecp_group *grp, mbedtls_ecp_point *P, in ecp_randomize_mxz() argument
2461 return mbedtls_internal_ecp_randomize_mxz(grp, P, f_rng, p_rng); in ecp_randomize_mxz()
2475 MPI_ECP_MUL(&P->X, &P->X, &l); in ecp_randomize_mxz()
2476 MPI_ECP_MUL(&P->Z, &P->Z, &l); in ecp_randomize_mxz()
2505 const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q, in ecp_double_add_mxz() argument
2511 return mbedtls_internal_ecp_double_add_mxz(grp, R, S, P, Q, d); in ecp_double_add_mxz()
2520 MPI_ECP_ADD(&T[0], &P->X, &P->Z); /* Pp := PX + PZ */ in ecp_double_add_mxz()
2521 MPI_ECP_SUB(&T[1], &P->X, &P->Z); /* Pm := PX - PZ */ in ecp_double_add_mxz()
2550 const mbedtls_mpi *m, const mbedtls_ecp_point *P, in ecp_mul_mxz() argument
2569 MPI_ECP_MOV(&PX, &P->X); in ecp_mul_mxz()
2570 MBEDTLS_MPI_CHK(mbedtls_ecp_copy(&RP, P)); in ecp_mul_mxz()
2631 const mbedtls_mpi *m, const mbedtls_ecp_point *P, in ecp_mul_restartable_internal() argument
2666 MBEDTLS_MPI_CHK(mbedtls_ecp_check_pubkey(grp, P)); in ecp_mul_restartable_internal()
2672 MBEDTLS_MPI_CHK(ecp_mul_mxz(grp, R, m, P, f_rng, p_rng)); in ecp_mul_restartable_internal()
2677 MBEDTLS_MPI_CHK(ecp_mul_comb(grp, R, m, P, f_rng, p_rng, rs_ctx)); in ecp_mul_restartable_internal()
2702 const mbedtls_mpi *m, const mbedtls_ecp_point *P, in mbedtls_ecp_mul_restartable() argument
2710 return ecp_mul_restartable_internal(grp, R, m, P, f_rng, p_rng, rs_ctx); in mbedtls_ecp_mul_restartable()
2717 const mbedtls_mpi *m, const mbedtls_ecp_point *P, in mbedtls_ecp_mul() argument
2720 return mbedtls_ecp_mul_restartable(grp, R, m, P, f_rng, p_rng, NULL); in mbedtls_ecp_mul()
2737 mbedtls_mpi_cmp_mpi(&pt->X, &grp->P) >= 0 || in ecp_check_pubkey_sw()
2738 mbedtls_mpi_cmp_mpi(&pt->Y, &grp->P) >= 0) { in ecp_check_pubkey_sw()
2772 const mbedtls_ecp_point *P, in mbedtls_ecp_mul_shortcuts() argument
2780 MBEDTLS_MPI_CHK(mbedtls_ecp_check_pubkey(grp, P)); in mbedtls_ecp_mul_shortcuts()
2783 MBEDTLS_MPI_CHK(mbedtls_ecp_check_pubkey(grp, P)); in mbedtls_ecp_mul_shortcuts()
2784 MBEDTLS_MPI_CHK(mbedtls_ecp_copy(R, P)); in mbedtls_ecp_mul_shortcuts()
2786 MBEDTLS_MPI_CHK(mbedtls_ecp_check_pubkey(grp, P)); in mbedtls_ecp_mul_shortcuts()
2787 MBEDTLS_MPI_CHK(mbedtls_ecp_copy(R, P)); in mbedtls_ecp_mul_shortcuts()
2790 MBEDTLS_MPI_CHK(ecp_mul_restartable_internal(grp, R, m, P, in mbedtls_ecp_mul_shortcuts()
2806 const mbedtls_mpi *m, const mbedtls_ecp_point *P, in mbedtls_ecp_muladd_restartable() argument
2846 MBEDTLS_MPI_CHK(mbedtls_ecp_mul_shortcuts(grp, pmP, m, P, rs_ctx)); in mbedtls_ecp_muladd_restartable()
2909 const mbedtls_mpi *m, const mbedtls_ecp_point *P, in mbedtls_ecp_muladd() argument
2912 return mbedtls_ecp_muladd_restartable(grp, R, m, P, n, Q, NULL); in mbedtls_ecp_muladd()
2951 static int ecp_check_bad_points_mx(const mbedtls_mpi *X, const mbedtls_mpi *P, in ecp_check_bad_points_mx() argument
2962 while (mbedtls_mpi_cmp_mpi(&XmP, P) >= 0) { in ecp_check_bad_points_mx()
2963 MBEDTLS_MPI_CHK(mbedtls_mpi_sub_mpi(&XmP, &XmP, P)); in ecp_check_bad_points_mx()
2992 if (mbedtls_mpi_cmp_mpi(&XmP, P) == 0) { in ecp_check_bad_points_mx()
3024 return ecp_check_bad_points_mx(&pt->X, &grp->P, grp->id); in ecp_check_pubkey_mx()
3531 const mbedtls_ecp_point *P, in self_test_point() argument
3544 MBEDTLS_MPI_CHK(mbedtls_ecp_mul(grp, R, m, P, self_test_rng, NULL)); in self_test_point()
3556 MBEDTLS_MPI_CHK(mbedtls_ecp_mul(grp, R, m, P, self_test_rng, NULL)); in self_test_point()
3586 mbedtls_ecp_point R, P; in mbedtls_ecp_self_test() local
3620 mbedtls_ecp_point_init(&P); in mbedtls_ecp_self_test()
3636 MBEDTLS_MPI_CHK(mbedtls_ecp_mul(&grp, &P, &m, &grp.G, self_test_rng, NULL)); in mbedtls_ecp_self_test()
3650 &grp, &R, &m, &P, in mbedtls_ecp_self_test()
3689 mbedtls_ecp_point_free(&P); in mbedtls_ecp_self_test()