Lines Matching refs:p

92     void * const p[2] = { X->p, Y->p };  in mbedtls_mpi_lt_mpi_ct()  local
94 mbedtls_ct_condition_t lt = mbedtls_mpi_core_lt_ct(p[i], p[i ^ 1], X->n); in mbedtls_mpi_lt_mpi_ct()
134 mbedtls_mpi_core_cond_assign(X->p, Y->p, Y->n, do_assign); in mbedtls_mpi_safe_cond_assign()
138 X->p[i] = mbedtls_ct_mpi_uint_if_else_0(do_not_assign, X->p[i]); in mbedtls_mpi_safe_cond_assign()
172 mbedtls_mpi_core_cond_swap(X->p, Y->p, X->n, do_swap); in mbedtls_mpi_safe_cond_swap()
195 X->p = NULL; in mpi_init()
217 if (X->p != NULL) { in mbedtls_mpi_free()
219 mbedtls_mpi_zeroize(X->p, X->n); in mbedtls_mpi_free()
220 mempool_free(mbedtls_mpi_mempool, X->p); in mbedtls_mpi_free()
222 mbedtls_mpi_zeroize_and_free(X->p, X->n); in mbedtls_mpi_free()
228 X->p = NULL; in mbedtls_mpi_free()
236 mbedtls_mpi_uint *p; in mbedtls_mpi_grow() local
244 p = mempool_alloc(mbedtls_mpi_mempool, nblimbs * ciL); in mbedtls_mpi_grow()
245 if(p == NULL) in mbedtls_mpi_grow()
247 memset(p, 0, nblimbs * ciL); in mbedtls_mpi_grow()
249 p = (mbedtls_mpi_uint *) mbedtls_calloc(nblimbs, ciL); in mbedtls_mpi_grow()
250 if (p == NULL) in mbedtls_mpi_grow()
254 if (X->p != NULL) { in mbedtls_mpi_grow()
255 memcpy(p, X->p, X->n * ciL); in mbedtls_mpi_grow()
258 mbedtls_mpi_zeroize(X->p, X->n); in mbedtls_mpi_grow()
259 mempool_free(mbedtls_mpi_mempool, X->p); in mbedtls_mpi_grow()
261 mbedtls_mpi_zeroize_and_free(X->p, X->n); in mbedtls_mpi_grow()
268 X->p = p; in mbedtls_mpi_grow()
280 mbedtls_mpi_uint *p; in mbedtls_mpi_shrink() local
294 if (X->p[i] != 0) { in mbedtls_mpi_shrink()
305 p = mempool_alloc(mbedtls_mpi_mempool, i * ciL); in mbedtls_mpi_shrink()
306 if (p == NULL) in mbedtls_mpi_shrink()
308 memset(p, 0, i * ciL); in mbedtls_mpi_shrink()
310 if ((p = (mbedtls_mpi_uint *) mbedtls_calloc(i, ciL)) == NULL) in mbedtls_mpi_shrink()
314 if (X->p != NULL) { in mbedtls_mpi_shrink()
315 memcpy(p, X->p, i * ciL); in mbedtls_mpi_shrink()
318 mbedtls_mpi_zeroize(X->p, X->n); in mbedtls_mpi_shrink()
319 mempool_free(mbedtls_mpi_mempool, X->p); in mbedtls_mpi_shrink()
322 mbedtls_mpi_zeroize_and_free(X->p, X->n); in mbedtls_mpi_shrink()
329 X->p = p; in mbedtls_mpi_shrink()
341 memset(X->p, 0, limbs * ciL); in mbedtls_mpi_resize_clear()
370 memset(X->p, 0, X->n * ciL); in mbedtls_mpi_copy()
376 if (Y->p[i] != 0) { in mbedtls_mpi_copy()
387 memset(X->p + i, 0, (X->n - i) * ciL); in mbedtls_mpi_copy()
390 memcpy(X->p, Y->p, i * ciL); in mbedtls_mpi_copy()
433 memset(X->p, 0, X->n * ciL); in mbedtls_mpi_lset()
435 X->p[0] = mpi_sint_abs(z); in mbedtls_mpi_lset()
452 return (X->p[pos / biL] >> (pos % biL)) & 0x01; in mbedtls_mpi_get_bit()
476 X->p[off] &= ~((mbedtls_mpi_uint) 0x01 << idx); in mbedtls_mpi_set_bit()
477 X->p[off] |= (mbedtls_mpi_uint) val << idx; in mbedtls_mpi_set_bit()
503 if (X->p[i] != 0) { in mbedtls_mpi_lsb()
504 return i * biL + mbedtls_mpi_uint_ctz(X->p[i]); in mbedtls_mpi_lsb()
511 if (((X->p[i] >> j) & 1) != 0) { in mbedtls_mpi_lsb()
526 return mbedtls_mpi_core_bitlen(X->p, X->n); in mbedtls_mpi_bitlen()
602 X->p[j / (2 * ciL)] |= d << ((j % (2 * ciL)) << 2); in mbedtls_mpi_read_string()
629 char **p, const size_t buflen) in mpi_write_hlp() argument
634 char *p_end = *p + buflen; in mpi_write_hlp()
655 memmove(*p, p_end, length); in mpi_write_hlp()
656 *p += length; in mpi_write_hlp()
671 char *p; in mbedtls_mpi_write_string() local
702 p = buf; in mbedtls_mpi_write_string()
706 *p++ = '-'; in mbedtls_mpi_write_string()
716 c = (X->p[i - 1] >> ((j - 1) << 3)) & 0xFF; in mbedtls_mpi_write_string()
722 *(p++) = "0123456789ABCDEF" [c / 16]; in mbedtls_mpi_write_string()
723 *(p++) = "0123456789ABCDEF" [c % 16]; in mbedtls_mpi_write_string()
734 MBEDTLS_MPI_CHK(mpi_write_hlp(&T, radix, &p, buflen)); in mbedtls_mpi_write_string()
737 *p++ = '\0'; in mbedtls_mpi_write_string()
738 *olen = (size_t) (p - buf); in mbedtls_mpi_write_string()
755 char *p; in mbedtls_mpi_read_file() local
783 p = s + slen; in mbedtls_mpi_read_file()
784 while (p-- > s) { in mbedtls_mpi_read_file()
785 if (mpi_get_digit(&d, radix, *p) != 0) { in mbedtls_mpi_read_file()
790 return mbedtls_mpi_read_string(X, radix, p + 1); in mbedtls_mpi_read_file()
796 int mbedtls_mpi_write_file(const char *p, const mbedtls_mpi *X, int radix, FILE *fout) in mbedtls_mpi_write_file() argument
814 if (p == NULL) { in mbedtls_mpi_write_file()
815 p = ""; in mbedtls_mpi_write_file()
818 plen = strlen(p); in mbedtls_mpi_write_file()
824 if (fwrite(p, 1, plen, fout) != plen || in mbedtls_mpi_write_file()
829 mbedtls_printf("%s%s", p, s); in mbedtls_mpi_write_file()
853 MBEDTLS_MPI_CHK(mbedtls_mpi_core_read_le(X->p, X->n, buf, buflen)); in mbedtls_mpi_read_binary_le()
879 MBEDTLS_MPI_CHK(mbedtls_mpi_core_read_be(X->p, X->n, buf, buflen)); in mbedtls_mpi_read_binary()
897 return mbedtls_mpi_core_write_le(X->p, X->n, buf, buflen); in mbedtls_mpi_write_binary_le()
906 return mbedtls_mpi_core_write_be(X->p, X->n, buf, buflen); in mbedtls_mpi_write_binary()
925 mbedtls_mpi_core_shift_l(X->p, X->n, count); in mbedtls_mpi_shift_l()
937 mbedtls_mpi_core_shift_r(X->p, X->n, count); in mbedtls_mpi_shift_r()
950 if (X->p[i - 1] != 0) { in mbedtls_mpi_cmp_abs()
956 if (Y->p[j - 1] != 0) { in mbedtls_mpi_cmp_abs()
972 if (X->p[i - 1] > Y->p[i - 1]) { in mbedtls_mpi_cmp_abs()
975 if (X->p[i - 1] < Y->p[i - 1]) { in mbedtls_mpi_cmp_abs()
991 if (X->p[i - 1] != 0) { in mbedtls_mpi_cmp_mpi()
997 if (Y->p[j - 1] != 0) { in mbedtls_mpi_cmp_mpi()
1021 if (X->p[i - 1] > Y->p[i - 1]) { in mbedtls_mpi_cmp_mpi()
1024 if (X->p[i - 1] < Y->p[i - 1]) { in mbedtls_mpi_cmp_mpi()
1038 mbedtls_mpi_uint p[1]; in mbedtls_mpi_cmp_int() local
1040 *p = mpi_sint_abs(z); in mbedtls_mpi_cmp_int()
1043 Y.p = p; in mbedtls_mpi_cmp_int()
1055 mbedtls_mpi_uint *p; in mbedtls_mpi_add_abs() local
1072 if (B->p[j - 1] != 0) { in mbedtls_mpi_add_abs()
1087 p = X->p; in mbedtls_mpi_add_abs()
1089 c = mbedtls_mpi_core_add(p, p, B->p, j); in mbedtls_mpi_add_abs()
1091 p += j; in mbedtls_mpi_add_abs()
1098 p = X->p + j; in mbedtls_mpi_add_abs()
1101 *p += c; c = (*p < c); j++; p++; in mbedtls_mpi_add_abs()
1119 if (B->p[n - 1] != 0) { in mbedtls_mpi_sub_abs()
1135 memcpy(X->p + n, A->p + n, (A->n - n) * ciL); in mbedtls_mpi_sub_abs()
1138 memset(X->p + A->n, 0, (X->n - A->n) * ciL); in mbedtls_mpi_sub_abs()
1141 carry = mbedtls_mpi_core_sub(X->p, A->p, B->p, n); in mbedtls_mpi_sub_abs()
1144 carry = mbedtls_mpi_core_sub_int(X->p + n, X->p + n, carry, X->n - n); in mbedtls_mpi_sub_abs()
1215 mbedtls_mpi_uint p[1]; in mbedtls_mpi_add_int() local
1217 p[0] = mpi_sint_abs(b); in mbedtls_mpi_add_int()
1220 B.p = p; in mbedtls_mpi_add_int()
1231 mbedtls_mpi_uint p[1]; in mbedtls_mpi_sub_int() local
1233 p[0] = mpi_sint_abs(b); in mbedtls_mpi_sub_int()
1236 B.p = p; in mbedtls_mpi_sub_int()
1262 if (A->p[i - 1] != 0) { in mbedtls_mpi_mul_mpi()
1271 if (B->p[j - 1] != 0) { in mbedtls_mpi_mul_mpi()
1282 mbedtls_mpi_core_mul(X->p, A->p, i, B->p, j); in mbedtls_mpi_mul_mpi()
1307 while (n > 0 && A->p[n - 1] == 0) { in mbedtls_mpi_mul_int()
1331 mbedtls_mpi_core_mla(X->p, X->n, A->p, n, b - 1); in mbedtls_mpi_mul_int()
1467 T2.p = TP2; in mbedtls_mpi_div_mpi()
1501 Z.p[n - t]++; in mbedtls_mpi_div_mpi()
1507 if (X.p[i] >= Y.p[t]) { in mbedtls_mpi_div_mpi()
1508 Z.p[i - t - 1] = ~(mbedtls_mpi_uint) 0u; in mbedtls_mpi_div_mpi()
1510 Z.p[i - t - 1] = mbedtls_int_div_int(X.p[i], X.p[i - 1], in mbedtls_mpi_div_mpi()
1511 Y.p[t], NULL); in mbedtls_mpi_div_mpi()
1514 T2.p[0] = (i < 2) ? 0 : X.p[i - 2]; in mbedtls_mpi_div_mpi()
1515 T2.p[1] = (i < 1) ? 0 : X.p[i - 1]; in mbedtls_mpi_div_mpi()
1516 T2.p[2] = X.p[i]; in mbedtls_mpi_div_mpi()
1518 Z.p[i - t - 1]++; in mbedtls_mpi_div_mpi()
1520 Z.p[i - t - 1]--; in mbedtls_mpi_div_mpi()
1523 T1.p[0] = (t < 1) ? 0 : Y.p[t - 1]; in mbedtls_mpi_div_mpi()
1524 T1.p[1] = Y.p[t]; in mbedtls_mpi_div_mpi()
1525 MBEDTLS_MPI_CHK(mbedtls_mpi_mul_int(&T1, &T1, Z.p[i - t - 1])); in mbedtls_mpi_div_mpi()
1528 MBEDTLS_MPI_CHK(mbedtls_mpi_mul_int(&T1, &Y, Z.p[i - t - 1])); in mbedtls_mpi_div_mpi()
1536 Z.p[i - t - 1]--; in mbedtls_mpi_div_mpi()
1572 mbedtls_mpi_uint p[1]; in mbedtls_mpi_div_int() local
1574 p[0] = mpi_sint_abs(b); in mbedtls_mpi_div_int()
1577 B.p = p; in mbedtls_mpi_div_int()
1633 *r = A->p[0] & 1; in mbedtls_mpi_mod_int()
1641 x = A->p[i - 1]; in mbedtls_mpi_mod_int()
1671 *mm = mbedtls_mpi_core_montmul_init(N->p); in mbedtls_mpi_montg_init()
1701 mbedtls_mpi_core_montmul(A->p, A->p, B->p, B->n, N->p, N->n, mm, T->p); in mbedtls_mpi_montmul()
1719 U.p = &z; in mbedtls_mpi_montred()
1734 if (mbedtls_mpi_cmp_int(N, 0) <= 0 || (N->p[0] & 1) == 0) { in mbedtls_mpi_exp_mod_optionally_safe()
1771 if (prec_RR == NULL || prec_RR->p == NULL) { in mbedtls_mpi_exp_mod_optionally_safe()
1812 mbedtls_mpi_uint mm = mbedtls_mpi_core_montmul_init(N->p); in mbedtls_mpi_exp_mod_optionally_safe()
1813 mbedtls_mpi_core_to_mont_rep(X->p, X->p, N->p, N->n, mm, RR.p, T); in mbedtls_mpi_exp_mod_optionally_safe()
1815 mbedtls_mpi_core_exp_mod_unsafe(X->p, X->p, N->p, N->n, E->p, E->n, RR.p, T); in mbedtls_mpi_exp_mod_optionally_safe()
1817 mbedtls_mpi_core_exp_mod(X->p, X->p, N->p, N->n, E->p, E->n, RR.p, T); in mbedtls_mpi_exp_mod_optionally_safe()
1819 mbedtls_mpi_core_from_mont_rep(X->p, X->p, N->p, N->n, mm, T); in mbedtls_mpi_exp_mod_optionally_safe()
1825 if (A->s == -1 && (E->p[0] & 1) != 0) { in mbedtls_mpi_exp_mod_optionally_safe()
1826 mbedtls_ct_condition_t is_x_non_zero = mbedtls_mpi_core_check_zero_ct(X->p, X->n); in mbedtls_mpi_exp_mod_optionally_safe()
1837 if (prec_RR == NULL || prec_RR->p == NULL) { in mbedtls_mpi_exp_mod_optionally_safe()
1992 ret = mbedtls_mpi_core_fill_random(X->p, X->n, size, f_rng, p_rng); in mbedtls_mpi_fill_random()
2019 return mbedtls_mpi_core_random(X->p, min, N->p, X->n, f_rng, p_rng); in mbedtls_mpi_random()
2058 while ((TU.p[0] & 1) == 0) { in mbedtls_mpi_inv_mod()
2061 if ((U1.p[0] & 1) != 0 || (U2.p[0] & 1) != 0) { in mbedtls_mpi_inv_mod()
2070 while ((TV.p[0] & 1) == 0) { in mbedtls_mpi_inv_mod()
2073 if ((V1.p[0] & 1) != 0 || (V2.p[0] & 1) != 0) { in mbedtls_mpi_inv_mod()
2154 unsigned p = 3; /* The first odd prime */ in mpi_check_small_factors() local
2156 if ((X->p[0] & 1) == 0) { in mpi_check_small_factors()
2160 for (i = 0; i < sizeof(small_prime_gaps); p += small_prime_gaps[i], i++) { in mpi_check_small_factors()
2161 MBEDTLS_MPI_CHK(mbedtls_mpi_mod_int(&r, X, p)); in mpi_check_small_factors()
2163 if (mbedtls_mpi_cmp_int(X, p) == 0) { in mpi_check_small_factors()
2210 A.p[A.n - 1] &= ((mbedtls_mpi_uint) 1 << (k - (A.n - 1) * biL - 1)) - 1; in mpi_miller_rabin()
2276 XX.p = X->p; in mbedtls_mpi_is_prime_ext()
2351 if (X->p[n-1] < CEIL_MAXUINT_DIV_SQRT2) { in mbedtls_mpi_gen_prime()
2359 X->p[0] |= 1; in mbedtls_mpi_gen_prime()
2374 X->p[0] |= 2; in mbedtls_mpi_gen_prime()