Lines Matching refs:i
133 size_t i; in mbedtls_mpi_shrink() local
144 for( i = X->n - 1; i > 0; i-- ) in mbedtls_mpi_shrink()
145 if( X->p[i] != 0 ) in mbedtls_mpi_shrink()
147 i++; in mbedtls_mpi_shrink()
149 if( i < nblimbs ) in mbedtls_mpi_shrink()
150 i = nblimbs; in mbedtls_mpi_shrink()
152 if( ( p = (mbedtls_mpi_uint*)mbedtls_calloc( i, ciL ) ) == NULL ) in mbedtls_mpi_shrink()
157 memcpy( p, X->p, i * ciL ); in mbedtls_mpi_shrink()
162 X->n = i; in mbedtls_mpi_shrink()
201 size_t i; in mbedtls_mpi_copy() local
218 for( i = Y->n - 1; i > 0; i-- ) in mbedtls_mpi_copy()
219 if( Y->p[i] != 0 ) in mbedtls_mpi_copy()
221 i++; in mbedtls_mpi_copy()
225 if( X->n < i ) in mbedtls_mpi_copy()
227 MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, i ) ); in mbedtls_mpi_copy()
231 memset( X->p + i, 0, ( X->n - i ) * ciL ); in mbedtls_mpi_copy()
234 memcpy( X->p, Y->p, i * ciL ); in mbedtls_mpi_copy()
332 size_t i, j, count = 0; in mbedtls_mpi_lsb() local
335 for( i = 0; i < X->n; i++ ) in mbedtls_mpi_lsb()
337 if( ( ( X->p[i] >> j ) & 1 ) != 0 ) in mbedtls_mpi_lsb()
382 size_t i, j, slen, n; in mbedtls_mpi_read_string() local
418 for( i = slen, j = 0; i > 0; i--, j++ ) in mbedtls_mpi_read_string()
420 MBEDTLS_MPI_CHK( mpi_get_digit( &d, radix, s[i - 1] ) ); in mbedtls_mpi_read_string()
428 for( i = 0; i < slen; i++ ) in mbedtls_mpi_read_string()
430 MBEDTLS_MPI_CHK( mpi_get_digit( &d, radix, s[i] ) ); in mbedtls_mpi_read_string()
535 size_t i, j, k; in mbedtls_mpi_write_string() local
537 for( i = X->n, k = 0; i > 0; i-- ) in mbedtls_mpi_write_string()
541 c = ( X->p[i - 1] >> ( ( j - 1 ) << 3) ) & 0xFF; in mbedtls_mpi_write_string()
543 if( c == 0 && k == 0 && ( i + j ) != 2 ) in mbedtls_mpi_write_string()
735 size_t i, v0, t1; in mbedtls_mpi_shift_l() local
742 i = mbedtls_mpi_bitlen( X ) + count; in mbedtls_mpi_shift_l()
744 if( X->n * biL < i ) in mbedtls_mpi_shift_l()
745 MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, BITS_TO_LIMBS( i ) ) ); in mbedtls_mpi_shift_l()
754 for( i = X->n; i > v0; i-- ) in mbedtls_mpi_shift_l()
755 X->p[i - 1] = X->p[i - v0 - 1]; in mbedtls_mpi_shift_l()
757 for( ; i > 0; i-- ) in mbedtls_mpi_shift_l()
758 X->p[i - 1] = 0; in mbedtls_mpi_shift_l()
766 for( i = v0; i < X->n; i++ ) in mbedtls_mpi_shift_l()
768 r1 = X->p[i] >> (biL - t1); in mbedtls_mpi_shift_l()
769 X->p[i] <<= t1; in mbedtls_mpi_shift_l()
770 X->p[i] |= r0; in mbedtls_mpi_shift_l()
796 size_t i, j; in mbedtls_mpi_cmp_abs() local
800 for( i = X->n; i > 0; i-- ) in mbedtls_mpi_cmp_abs()
801 if( X->p[i - 1] != 0 ) in mbedtls_mpi_cmp_abs()
808 if( i == 0 && j == 0 ) in mbedtls_mpi_cmp_abs()
811 if( i > j ) return( 1 ); in mbedtls_mpi_cmp_abs()
812 if( j > i ) return( -1 ); in mbedtls_mpi_cmp_abs()
814 for( ; i > 0; i-- ) in mbedtls_mpi_cmp_abs()
816 if( X->p[i - 1] > Y->p[i - 1] ) return( 1 ); in mbedtls_mpi_cmp_abs()
817 if( X->p[i - 1] < Y->p[i - 1] ) return( -1 ); in mbedtls_mpi_cmp_abs()
828 size_t i, j; in mbedtls_mpi_cmp_mpi() local
832 for( i = X->n; i > 0; i-- ) in mbedtls_mpi_cmp_mpi()
833 if( X->p[i - 1] != 0 ) in mbedtls_mpi_cmp_mpi()
840 if( i == 0 && j == 0 ) in mbedtls_mpi_cmp_mpi()
843 if( i > j ) return( X->s ); in mbedtls_mpi_cmp_mpi()
844 if( j > i ) return( -Y->s ); in mbedtls_mpi_cmp_mpi()
849 for( ; i > 0; i-- ) in mbedtls_mpi_cmp_mpi()
851 if( X->p[i - 1] > Y->p[i - 1] ) return( X->s ); in mbedtls_mpi_cmp_mpi()
852 if( X->p[i - 1] < Y->p[i - 1] ) return( -X->s ); in mbedtls_mpi_cmp_mpi()
1089 size_t i, j; in mbedtls_mpi_mul_mpi() local
1101 for( i = A->n; i > 0; i-- ) in mbedtls_mpi_mul_mpi()
1102 if( A->p[i - 1] != 0 ) in mbedtls_mpi_mul_mpi()
1104 if( i == 0 ) in mbedtls_mpi_mul_mpi()
1113 MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, i + j ) ); in mbedtls_mpi_mul_mpi()
1120 (void) mbedtls_mpi_core_mla( X->p + k, i + 1, in mbedtls_mpi_mul_mpi()
1121 A->p, i, in mbedtls_mpi_mul_mpi()
1281 size_t i, n, t, k; in mbedtls_mpi_div_mpi() local
1338 for( i = n; i > t ; i-- ) in mbedtls_mpi_div_mpi()
1340 if( X.p[i] >= Y.p[t] ) in mbedtls_mpi_div_mpi()
1341 Z.p[i - t - 1] = ~0; in mbedtls_mpi_div_mpi()
1344 Z.p[i - t - 1] = mbedtls_int_div_int( X.p[i], X.p[i - 1], in mbedtls_mpi_div_mpi()
1348 T2.p[0] = ( i < 2 ) ? 0 : X.p[i - 2]; in mbedtls_mpi_div_mpi()
1349 T2.p[1] = ( i < 1 ) ? 0 : X.p[i - 1]; in mbedtls_mpi_div_mpi()
1350 T2.p[2] = X.p[i]; in mbedtls_mpi_div_mpi()
1352 Z.p[i - t - 1]++; in mbedtls_mpi_div_mpi()
1355 Z.p[i - t - 1]--; in mbedtls_mpi_div_mpi()
1360 MBEDTLS_MPI_CHK( mbedtls_mpi_mul_int( &T1, &T1, Z.p[i - t - 1] ) ); in mbedtls_mpi_div_mpi()
1364 MBEDTLS_MPI_CHK( mbedtls_mpi_mul_int( &T1, &Y, Z.p[i - t - 1] ) ); in mbedtls_mpi_div_mpi()
1365 MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &T1, biL * ( i - t - 1 ) ) ); in mbedtls_mpi_div_mpi()
1371 MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &T1, biL * ( i - t - 1 ) ) ); in mbedtls_mpi_div_mpi()
1373 Z.p[i - t - 1]--; in mbedtls_mpi_div_mpi()
1452 size_t i; in mbedtls_mpi_mod_int() local
1481 for( i = A->n, y = 0; i > 0; i-- ) in mbedtls_mpi_mod_int()
1483 x = A->p[i - 1]; in mbedtls_mpi_mod_int()
1575 for( size_t i = 0; i < T_size; i++ ) in mpi_select() local
1577 MBEDTLS_MPI_CHK( mbedtls_mpi_safe_cond_assign( R, &T[i], in mpi_select()
1578 (unsigned char) mbedtls_ct_size_bool_eq( i, idx ) ) ); in mpi_select()
1594 size_t i, j, nblimbs; in mbedtls_mpi_exp_mod() local
1624 i = mbedtls_mpi_bitlen( E ); in mbedtls_mpi_exp_mod()
1626 window_bitsize = ( i > 671 ) ? 6 : ( i > 239 ) ? 5 : in mbedtls_mpi_exp_mod()
1627 ( i > 79 ) ? 4 : ( i > 23 ) ? 3 : 1; in mbedtls_mpi_exp_mod()
1750 for( i = 0; i < window_bitsize - 1; i++ ) in mbedtls_mpi_exp_mod()
1756 for( i = j + 1; i < w_table_used_size; i++ ) in mbedtls_mpi_exp_mod()
1758 MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &W[i], N->n + 1 ) ); in mbedtls_mpi_exp_mod()
1759 MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &W[i], &W[i - 1] ) ); in mbedtls_mpi_exp_mod()
1761 mpi_montmul( &W[i], &W[1], N, mm, &T ); in mbedtls_mpi_exp_mod()
1816 for( i = 0; i < window_bitsize; i++ ) in mbedtls_mpi_exp_mod()
1839 for( i = 0; i < nbits; i++ ) in mbedtls_mpi_exp_mod()
1873 for( i = w_table_used_size/2; i < w_table_used_size; i++ ) in mbedtls_mpi_exp_mod()
1874 mbedtls_mpi_free( &W[i] ); in mbedtls_mpi_exp_mod()
2243 size_t i; in mpi_check_small_factors() local
2249 for( i = 0; small_prime[i] > 0; i++ ) in mpi_check_small_factors()
2251 if( mbedtls_mpi_cmp_int( X, small_prime[i] ) <= 0 ) in mpi_check_small_factors()
2254 MBEDTLS_MPI_CHK( mbedtls_mpi_mod_int( &r, X, small_prime[i] ) ); in mpi_check_small_factors()
2272 size_t i, j, k, s; in mpi_miller_rabin() local
2291 for( i = 0; i < rounds; i++ ) in mpi_miller_rabin()
2536 int ret, i; in mbedtls_mpi_self_test() local
2658 for( i = 0; i < GCD_PAIR_COUNT; i++ ) in mbedtls_mpi_self_test()
2660 MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &X, gcd_pairs[i][0] ) ); in mbedtls_mpi_self_test()
2661 MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &Y, gcd_pairs[i][1] ) ); in mbedtls_mpi_self_test()
2665 if( mbedtls_mpi_cmp_int( &A, gcd_pairs[i][2] ) != 0 ) in mbedtls_mpi_self_test()
2668 mbedtls_printf( "failed at %d\n", i ); in mbedtls_mpi_self_test()