Lines Matching refs:p
63 volatile mbedtls_mpi_uint *p = v; while( n-- ) *p++ = 0; in mbedtls_mpi_zeroize() local
89 X->p = NULL; in mbedtls_mpi_init()
100 if( X->p != NULL ) in mbedtls_mpi_free()
102 mbedtls_mpi_zeroize( X->p, X->n ); in mbedtls_mpi_free()
103 mbedtls_free( X->p ); in mbedtls_mpi_free()
108 X->p = NULL; in mbedtls_mpi_free()
116 mbedtls_mpi_uint *p; in mbedtls_mpi_grow() local
123 if( ( p = (mbedtls_mpi_uint*)mbedtls_calloc( nblimbs, ciL ) ) == NULL ) in mbedtls_mpi_grow()
126 if( X->p != NULL ) in mbedtls_mpi_grow()
128 memcpy( p, X->p, X->n * ciL ); in mbedtls_mpi_grow()
129 mbedtls_mpi_zeroize( X->p, X->n ); in mbedtls_mpi_grow()
130 mbedtls_free( X->p ); in mbedtls_mpi_grow()
134 X->p = p; in mbedtls_mpi_grow()
146 mbedtls_mpi_uint *p; in mbedtls_mpi_shrink() local
154 if( X->p[i] != 0 ) in mbedtls_mpi_shrink()
161 if( ( p = (mbedtls_mpi_uint*)mbedtls_calloc( i, ciL ) ) == NULL ) in mbedtls_mpi_shrink()
164 if( X->p != NULL ) in mbedtls_mpi_shrink()
166 memcpy( p, X->p, i * ciL ); in mbedtls_mpi_shrink()
167 mbedtls_mpi_zeroize( X->p, X->n ); in mbedtls_mpi_shrink()
168 mbedtls_free( X->p ); in mbedtls_mpi_shrink()
172 X->p = p; in mbedtls_mpi_shrink()
188 if( Y->p == NULL ) in mbedtls_mpi_copy()
195 if( Y->p[i] != 0 ) in mbedtls_mpi_copy()
203 memset( X->p, 0, X->n * ciL ); in mbedtls_mpi_copy()
204 memcpy( X->p, Y->p, i * ciL ); in mbedtls_mpi_copy()
241 X->p[i] = X->p[i] * ( 1 - assign ) + Y->p[i] * assign; in mbedtls_mpi_safe_cond_assign()
244 X->p[i] *= ( 1 - assign ); in mbedtls_mpi_safe_cond_assign()
278 tmp = X->p[i]; in mbedtls_mpi_safe_cond_swap()
279 X->p[i] = X->p[i] * ( 1 - swap ) + Y->p[i] * swap; in mbedtls_mpi_safe_cond_swap()
280 Y->p[i] = Y->p[i] * ( 1 - swap ) + tmp * swap; in mbedtls_mpi_safe_cond_swap()
295 memset( X->p, 0, X->n * ciL ); in mbedtls_mpi_lset()
297 X->p[0] = ( z < 0 ) ? -z : z; in mbedtls_mpi_lset()
313 return( ( X->p[pos / biL] >> ( pos % biL ) ) & 0x01 ); in mbedtls_mpi_get_bit()
336 X->p[off] &= ~( (mbedtls_mpi_uint) 0x01 << idx ); in mbedtls_mpi_set_bit()
337 X->p[off] |= (mbedtls_mpi_uint) val << idx; in mbedtls_mpi_set_bit()
353 if( ( ( X->p[i] >> j ) & 1 ) != 0 ) in mbedtls_mpi_lsb()
388 if( X->p[i] != 0 ) in mbedtls_mpi_bitlen()
391 j = biL - mbedtls_clz( X->p[i] ); in mbedtls_mpi_bitlen()
457 X->p[j / ( 2 * ciL )] |= d << ( ( j % ( 2 * ciL ) ) << 2 ); in mbedtls_mpi_read_string()
496 static int mpi_write_hlp( mbedtls_mpi *X, int radix, char **p ) in mpi_write_hlp() argument
508 MBEDTLS_MPI_CHK( mpi_write_hlp( X, radix, p ) ); in mpi_write_hlp()
511 *(*p)++ = (char)( r + 0x30 ); in mpi_write_hlp()
513 *(*p)++ = (char)( r + 0x37 ); in mpi_write_hlp()
528 char *p; in mbedtls_mpi_write_string() local
545 p = buf; in mbedtls_mpi_write_string()
549 *p++ = '-'; in mbedtls_mpi_write_string()
560 c = ( X->p[i - 1] >> ( ( j - 1 ) << 3) ) & 0xFF; in mbedtls_mpi_write_string()
565 *(p++) = "0123456789ABCDEF" [c / 16]; in mbedtls_mpi_write_string()
566 *(p++) = "0123456789ABCDEF" [c % 16]; in mbedtls_mpi_write_string()
578 MBEDTLS_MPI_CHK( mpi_write_hlp( &T, radix, &p ) ); in mbedtls_mpi_write_string()
581 *p++ = '\0'; in mbedtls_mpi_write_string()
582 *olen = p - buf; in mbedtls_mpi_write_string()
599 char *p; in mbedtls_mpi_read_file() local
617 p = s + slen; in mbedtls_mpi_read_file()
618 while( --p >= s ) in mbedtls_mpi_read_file()
619 if( mpi_get_digit( &d, radix, *p ) != 0 ) in mbedtls_mpi_read_file()
622 return( mbedtls_mpi_read_string( X, radix, p + 1 ) ); in mbedtls_mpi_read_file()
628 int mbedtls_mpi_write_file( const char *p, const mbedtls_mpi *X, int radix, FILE *fout ) in mbedtls_mpi_write_file() argument
642 if( p == NULL ) p = ""; in mbedtls_mpi_write_file()
644 plen = strlen( p ); in mbedtls_mpi_write_file()
651 if( fwrite( p, 1, plen, fout ) != plen || in mbedtls_mpi_write_file()
656 mbedtls_printf( "%s%s", p, s ); in mbedtls_mpi_write_file()
680 X->p[j / ciL] |= ((mbedtls_mpi_uint) buf[i - 1]) << ((j % ciL) << 3); in mbedtls_mpi_read_binary()
702 buf[i] = (unsigned char)( X->p[j / ciL] >> ((j % ciL) << 3) ); in mbedtls_mpi_write_binary()
732 X->p[i - 1] = X->p[i - v0 - 1]; in mbedtls_mpi_shift_l()
735 X->p[i - 1] = 0; in mbedtls_mpi_shift_l()
745 r1 = X->p[i] >> (biL - t1); in mbedtls_mpi_shift_l()
746 X->p[i] <<= t1; in mbedtls_mpi_shift_l()
747 X->p[i] |= r0; in mbedtls_mpi_shift_l()
777 X->p[i] = X->p[i + v0]; in mbedtls_mpi_shift_r()
780 X->p[i] = 0; in mbedtls_mpi_shift_r()
790 r1 = X->p[i - 1] << (biL - v1); in mbedtls_mpi_shift_r()
791 X->p[i - 1] >>= v1; in mbedtls_mpi_shift_r()
792 X->p[i - 1] |= r0; in mbedtls_mpi_shift_r()
808 if( X->p[i - 1] != 0 ) in mbedtls_mpi_cmp_abs()
812 if( Y->p[j - 1] != 0 ) in mbedtls_mpi_cmp_abs()
823 if( X->p[i - 1] > Y->p[i - 1] ) return( 1 ); in mbedtls_mpi_cmp_abs()
824 if( X->p[i - 1] < Y->p[i - 1] ) return( -1 ); in mbedtls_mpi_cmp_abs()
838 if( X->p[i - 1] != 0 ) in mbedtls_mpi_cmp_mpi()
842 if( Y->p[j - 1] != 0 ) in mbedtls_mpi_cmp_mpi()
856 if( X->p[i - 1] > Y->p[i - 1] ) return( X->s ); in mbedtls_mpi_cmp_mpi()
857 if( X->p[i - 1] < Y->p[i - 1] ) return( -X->s ); in mbedtls_mpi_cmp_mpi()
869 mbedtls_mpi_uint p[1]; in mbedtls_mpi_cmp_int() local
871 *p = ( z < 0 ) ? -z : z; in mbedtls_mpi_cmp_int()
874 Y.p = p; in mbedtls_mpi_cmp_int()
886 mbedtls_mpi_uint *o, *p, c, tmp; in mbedtls_mpi_add_abs() local
902 if( B->p[j - 1] != 0 ) in mbedtls_mpi_add_abs()
907 o = B->p; p = X->p; c = 0; in mbedtls_mpi_add_abs()
912 for( i = 0; i < j; i++, o++, p++ ) in mbedtls_mpi_add_abs()
915 *p += c; c = ( *p < c ); in mbedtls_mpi_add_abs()
916 *p += tmp; c += ( *p < tmp ); in mbedtls_mpi_add_abs()
924 p = X->p + i; in mbedtls_mpi_add_abs()
927 *p += c; c = ( *p < c ); i++; p++; in mbedtls_mpi_add_abs()
987 if( B->p[n - 1] != 0 ) in mbedtls_mpi_sub_abs()
990 mpi_sub_hlp( n, B->p, X->p ); in mbedtls_mpi_sub_abs()
1067 mbedtls_mpi_uint p[1]; in mbedtls_mpi_add_int() local
1069 p[0] = ( b < 0 ) ? -b : b; in mbedtls_mpi_add_int()
1072 _B.p = p; in mbedtls_mpi_add_int()
1083 mbedtls_mpi_uint p[1]; in mbedtls_mpi_sub_int() local
1085 p[0] = ( b < 0 ) ? -b : b; in mbedtls_mpi_sub_int()
1088 _B.p = p; in mbedtls_mpi_sub_int()
1180 if( A->p[i - 1] != 0 ) in mbedtls_mpi_mul_mpi()
1184 if( B->p[j - 1] != 0 ) in mbedtls_mpi_mul_mpi()
1191 mpi_mul_hlp( i - 1, A->p, X->p + j - 1, B->p[j - 1] ); in mbedtls_mpi_mul_mpi()
1208 mbedtls_mpi_uint p[1]; in mbedtls_mpi_mul_int() local
1212 _B.p = p; in mbedtls_mpi_mul_int()
1213 p[0] = b; in mbedtls_mpi_mul_int()
1360 Z.p[n - t]++; in mbedtls_mpi_div_mpi()
1367 if( X.p[i] >= Y.p[t] ) in mbedtls_mpi_div_mpi()
1368 Z.p[i - t - 1] = ~0; in mbedtls_mpi_div_mpi()
1371 Z.p[i - t - 1] = mbedtls_int_div_int( X.p[i], X.p[i - 1], in mbedtls_mpi_div_mpi()
1372 Y.p[t], NULL); in mbedtls_mpi_div_mpi()
1375 Z.p[i - t - 1]++; in mbedtls_mpi_div_mpi()
1378 Z.p[i - t - 1]--; in mbedtls_mpi_div_mpi()
1381 T1.p[0] = ( t < 1 ) ? 0 : Y.p[t - 1]; in mbedtls_mpi_div_mpi()
1382 T1.p[1] = Y.p[t]; in mbedtls_mpi_div_mpi()
1383 MBEDTLS_MPI_CHK( mbedtls_mpi_mul_int( &T1, &T1, Z.p[i - t - 1] ) ); in mbedtls_mpi_div_mpi()
1386 T2.p[0] = ( i < 2 ) ? 0 : X.p[i - 2]; in mbedtls_mpi_div_mpi()
1387 T2.p[1] = ( i < 1 ) ? 0 : X.p[i - 1]; in mbedtls_mpi_div_mpi()
1388 T2.p[2] = X.p[i]; in mbedtls_mpi_div_mpi()
1392 MBEDTLS_MPI_CHK( mbedtls_mpi_mul_int( &T1, &Y, Z.p[i - t - 1] ) ); in mbedtls_mpi_div_mpi()
1401 Z.p[i - t - 1]--; in mbedtls_mpi_div_mpi()
1435 mbedtls_mpi_uint p[1]; in mbedtls_mpi_div_int() local
1437 p[0] = ( b < 0 ) ? -b : b; in mbedtls_mpi_div_int()
1440 _B.p = p; in mbedtls_mpi_div_int()
1493 *r = A->p[0] & 1; in mbedtls_mpi_mod_int()
1502 x = A->p[i - 1]; in mbedtls_mpi_mod_int()
1530 mbedtls_mpi_uint x, m0 = N->p[0]; in mpi_montg_init()
1551 if( T->n < N->n + 1 || T->p == NULL ) in mpi_montmul()
1554 memset( T->p, 0, T->n * ciL ); in mpi_montmul()
1556 d = T->p; in mpi_montmul()
1565 u0 = A->p[i]; in mpi_montmul()
1566 u1 = ( d[0] + u0 * B->p[0] ) * mm; in mpi_montmul()
1568 mpi_mul_hlp( m, B->p, d, u0 ); in mpi_montmul()
1569 mpi_mul_hlp( n, N->p, d, u1 ); in mpi_montmul()
1574 memcpy( A->p, d, ( n + 1 ) * ciL ); in mpi_montmul()
1577 mpi_sub_hlp( n, N->p, A->p ); in mpi_montmul()
1580 mpi_sub_hlp( n, A->p, T->p ); in mpi_montmul()
1594 U.p = &z; in mpi_montred()
1612 if( mbedtls_mpi_cmp_int( N, 0 ) < 0 || ( N->p[0] & 1 ) == 0 ) in mbedtls_mpi_exp_mod()
1653 if( _RR == NULL || _RR->p == NULL ) in mbedtls_mpi_exp_mod()
1726 ei = (E->p[nblimbs] >> bufsize) & 1; in mbedtls_mpi_exp_mod()
1801 if( _RR == NULL || _RR->p == NULL ) in mbedtls_mpi_exp_mod()
1918 while( ( TU.p[0] & 1 ) == 0 ) in mbedtls_mpi_inv_mod()
1922 if( ( U1.p[0] & 1 ) != 0 || ( U2.p[0] & 1 ) != 0 ) in mbedtls_mpi_inv_mod()
1932 while( ( TV.p[0] & 1 ) == 0 ) in mbedtls_mpi_inv_mod()
1936 if( ( V1.p[0] & 1 ) != 0 || ( V2.p[0] & 1 ) != 0 ) in mbedtls_mpi_inv_mod()
2020 if( ( X->p[0] & 1 ) == 0 ) in mpi_check_small_factors()
2081 A.p[0] |= 3; in mpi_miller_rabin()
2154 XX.p = X->p; in mbedtls_mpi_is_prime()
2200 X->p[0] |= 1; in mbedtls_mpi_gen_prime()
2220 X->p[0] |= 2; in mbedtls_mpi_gen_prime()