Lines Matching refs:N
1528 static void mpi_montg_init( mbedtls_mpi_uint *mm, const mbedtls_mpi *N ) in mpi_montg_init() argument
1530 mbedtls_mpi_uint x, m0 = N->p[0]; in mpi_montg_init()
1545 static int mpi_montmul( mbedtls_mpi *A, const mbedtls_mpi *B, const mbedtls_mpi *N, mbedtls_mpi_uin… in mpi_montmul() argument
1551 if( T->n < N->n + 1 || T->p == NULL ) in mpi_montmul()
1557 n = N->n; in mpi_montmul()
1569 mpi_mul_hlp( n, N->p, d, u1 ); in mpi_montmul()
1576 if( mbedtls_mpi_cmp_abs( A, N ) >= 0 ) in mpi_montmul()
1577 mpi_sub_hlp( n, N->p, A->p ); in mpi_montmul()
1588 static int mpi_montred( mbedtls_mpi *A, const mbedtls_mpi *N, mbedtls_mpi_uint mm, const mbedtls_mp… in mpi_montred() argument
1596 return( mpi_montmul( A, &U, N, mm, T ) ); in mpi_montred()
1602 …bedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *E, const mbedtls_mpi *N, mbedtls_mpi *_RR ) in mbedtls_mpi_exp_mod() argument
1612 if( mbedtls_mpi_cmp_int( N, 0 ) < 0 || ( N->p[0] & 1 ) == 0 ) in mbedtls_mpi_exp_mod()
1621 mpi_montg_init( &mm, N ); in mbedtls_mpi_exp_mod()
1634 j = N->n + 1; in mbedtls_mpi_exp_mod()
1656 MBEDTLS_MPI_CHK( mbedtls_mpi_shift_l( &RR, N->n * 2 * biL ) ); in mbedtls_mpi_exp_mod()
1657 MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &RR, &RR, N ) ); in mbedtls_mpi_exp_mod()
1668 if( mbedtls_mpi_cmp_mpi( A, N ) >= 0 ) in mbedtls_mpi_exp_mod()
1669 MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &W[1], A, N ) ); in mbedtls_mpi_exp_mod()
1673 MBEDTLS_MPI_CHK( mpi_montmul( &W[1], &RR, N, mm, &T ) ); in mbedtls_mpi_exp_mod()
1679 MBEDTLS_MPI_CHK( mpi_montred( X, N, mm, &T ) ); in mbedtls_mpi_exp_mod()
1688 MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &W[j], N->n + 1 ) ); in mbedtls_mpi_exp_mod()
1692 MBEDTLS_MPI_CHK( mpi_montmul( &W[j], &W[j], N, mm, &T ) ); in mbedtls_mpi_exp_mod()
1699 MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &W[i], N->n + 1 ) ); in mbedtls_mpi_exp_mod()
1702 MBEDTLS_MPI_CHK( mpi_montmul( &W[i], &W[1], N, mm, &T ) ); in mbedtls_mpi_exp_mod()
1739 MBEDTLS_MPI_CHK( mpi_montmul( X, X, N, mm, &T ) ); in mbedtls_mpi_exp_mod()
1757 MBEDTLS_MPI_CHK( mpi_montmul( X, X, N, mm, &T ) ); in mbedtls_mpi_exp_mod()
1762 MBEDTLS_MPI_CHK( mpi_montmul( X, &W[wbits], N, mm, &T ) ); in mbedtls_mpi_exp_mod()
1775 MBEDTLS_MPI_CHK( mpi_montmul( X, X, N, mm, &T ) ); in mbedtls_mpi_exp_mod()
1780 MBEDTLS_MPI_CHK( mpi_montmul( X, &W[1], N, mm, &T ) ); in mbedtls_mpi_exp_mod()
1786 MBEDTLS_MPI_CHK( mpi_montred( X, N, mm, &T ) ); in mbedtls_mpi_exp_mod()
1791 MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( X, N, X ) ); in mbedtls_mpi_exp_mod()
1886 int mbedtls_mpi_inv_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *N ) in mbedtls_mpi_inv_mod() argument
1891 if( mbedtls_mpi_cmp_int( N, 0 ) <= 0 ) in mbedtls_mpi_inv_mod()
1898 MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( &G, A, N ) ); in mbedtls_mpi_inv_mod()
1906 MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &TA, A, N ) ); in mbedtls_mpi_inv_mod()
1908 MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TB, N ) ); in mbedtls_mpi_inv_mod()
1909 MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TV, N ) ); in mbedtls_mpi_inv_mod()
1962 MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( &V1, &V1, N ) ); in mbedtls_mpi_inv_mod()
1964 while( mbedtls_mpi_cmp_mpi( &V1, N ) >= 0 ) in mbedtls_mpi_inv_mod()
1965 MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( &V1, &V1, N ) ); in mbedtls_mpi_inv_mod()
2285 mbedtls_mpi A, E, N, X, Y, U, V; in mbedtls_mpi_self_test() local
2287 mbedtls_mpi_init( &A ); mbedtls_mpi_init( &E ); mbedtls_mpi_init( &N ); mbedtls_mpi_init( &X ); in mbedtls_mpi_self_test()
2302 MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &N, 16, in mbedtls_mpi_self_test()
2307 MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &X, &A, &N ) ); in mbedtls_mpi_self_test()
2333 MBEDTLS_MPI_CHK( mbedtls_mpi_div_mpi( &X, &Y, &A, &N ) ); in mbedtls_mpi_self_test()
2359 MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &X, &A, &E, &N, NULL ) ); in mbedtls_mpi_self_test()
2381 MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &X, &A, &N ) ); in mbedtls_mpi_self_test()
2431 mbedtls_mpi_free( &A ); mbedtls_mpi_free( &E ); mbedtls_mpi_free( &N ); mbedtls_mpi_free( &X ); in mbedtls_mpi_self_test()