Lines Matching refs:A

1417 int mbedtls_mpi_add_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B )  in mbedtls_mpi_add_abs()  argument
1423 MPI_VALIDATE_RET( A != NULL ); in mbedtls_mpi_add_abs()
1428 const mbedtls_mpi *T = A; A = X; B = T; in mbedtls_mpi_add_abs()
1431 if( X != A ) in mbedtls_mpi_add_abs()
1432 MBEDTLS_MPI_CHK( mbedtls_mpi_copy( X, A ) ); in mbedtls_mpi_add_abs()
1510 int mbedtls_mpi_sub_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ) in mbedtls_mpi_sub_abs() argument
1516 MPI_VALIDATE_RET( A != NULL ); in mbedtls_mpi_sub_abs()
1522 if( n > A->n ) in mbedtls_mpi_sub_abs()
1529 MBEDTLS_MPI_CHK( mbedtls_mpi_grow( X, A->n ) ); in mbedtls_mpi_sub_abs()
1534 if( A->n > n ) in mbedtls_mpi_sub_abs()
1535 memcpy( X->p + n, A->p + n, ( A->n - n ) * ciL ); in mbedtls_mpi_sub_abs()
1536 if( X->n > A->n ) in mbedtls_mpi_sub_abs()
1537 memset( X->p + A->n, 0, ( X->n - A->n ) * ciL ); in mbedtls_mpi_sub_abs()
1539 carry = mpi_sub_hlp( n, X->p, A->p, B->p ); in mbedtls_mpi_sub_abs()
1565 int mbedtls_mpi_add_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ) in mbedtls_mpi_add_mpi() argument
1569 MPI_VALIDATE_RET( A != NULL ); in mbedtls_mpi_add_mpi()
1572 s = A->s; in mbedtls_mpi_add_mpi()
1573 if( A->s * B->s < 0 ) in mbedtls_mpi_add_mpi()
1575 if( mbedtls_mpi_cmp_abs( A, B ) >= 0 ) in mbedtls_mpi_add_mpi()
1577 MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( X, A, B ) ); in mbedtls_mpi_add_mpi()
1582 MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( X, B, A ) ); in mbedtls_mpi_add_mpi()
1588 MBEDTLS_MPI_CHK( mbedtls_mpi_add_abs( X, A, B ) ); in mbedtls_mpi_add_mpi()
1600 int mbedtls_mpi_sub_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ) in mbedtls_mpi_sub_mpi() argument
1604 MPI_VALIDATE_RET( A != NULL ); in mbedtls_mpi_sub_mpi()
1607 s = A->s; in mbedtls_mpi_sub_mpi()
1608 if( A->s * B->s > 0 ) in mbedtls_mpi_sub_mpi()
1610 if( mbedtls_mpi_cmp_abs( A, B ) >= 0 ) in mbedtls_mpi_sub_mpi()
1612 MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( X, A, B ) ); in mbedtls_mpi_sub_mpi()
1617 MBEDTLS_MPI_CHK( mbedtls_mpi_sub_abs( X, B, A ) ); in mbedtls_mpi_sub_mpi()
1623 MBEDTLS_MPI_CHK( mbedtls_mpi_add_abs( X, A, B ) ); in mbedtls_mpi_sub_mpi()
1635 int mbedtls_mpi_add_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint b ) in mbedtls_mpi_add_int() argument
1640 MPI_VALIDATE_RET( A != NULL ); in mbedtls_mpi_add_int()
1647 return( mbedtls_mpi_add_mpi( X, A, &_B ) ); in mbedtls_mpi_add_int()
1653 int mbedtls_mpi_sub_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_sint b ) in mbedtls_mpi_sub_int() argument
1658 MPI_VALIDATE_RET( A != NULL ); in mbedtls_mpi_sub_int()
1665 return( mbedtls_mpi_sub_mpi( X, A, &_B ) ); in mbedtls_mpi_sub_int()
1759 int mbedtls_mpi_mul_mpi( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *B ) in mbedtls_mpi_mul_mpi() argument
1766 MPI_VALIDATE_RET( A != NULL ); in mbedtls_mpi_mul_mpi()
1771 if( X == A ) { MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TA, A ) ); A = &TA; } in mbedtls_mpi_mul_mpi()
1774 for( i = A->n; i > 0; i-- ) in mbedtls_mpi_mul_mpi()
1775 if( A->p[i - 1] != 0 ) in mbedtls_mpi_mul_mpi()
1790 mpi_mul_hlp( i, A->p, X->p + j - 1, B->p[j - 1] ); in mbedtls_mpi_mul_mpi()
1799 X->s = A->s * B->s; in mbedtls_mpi_mul_mpi()
1811 int mbedtls_mpi_mul_int( mbedtls_mpi *X, const mbedtls_mpi *A, mbedtls_mpi_uint b ) in mbedtls_mpi_mul_int() argument
1814 MPI_VALIDATE_RET( A != NULL ); in mbedtls_mpi_mul_int()
1817 size_t n = A->n; in mbedtls_mpi_mul_int()
1818 while( n > 0 && A->p[n - 1] == 0 ) in mbedtls_mpi_mul_int()
1839 MBEDTLS_MPI_CHK( mbedtls_mpi_copy( X, A ) ); in mbedtls_mpi_mul_int()
1840 mpi_mul_hlp( n, A->p, X->p, b - 1 ); in mbedtls_mpi_mul_int()
1945 int mbedtls_mpi_div_mpi( mbedtls_mpi *Q, mbedtls_mpi *R, const mbedtls_mpi *A, in mbedtls_mpi_div_mpi() argument
1952 MPI_VALIDATE_RET( A != NULL ); in mbedtls_mpi_div_mpi()
1971 if( mbedtls_mpi_cmp_abs( A, B ) < 0 ) in mbedtls_mpi_div_mpi()
1974 if( R != NULL ) MBEDTLS_MPI_CHK( mbedtls_mpi_copy( R, A ) ); in mbedtls_mpi_div_mpi()
1978 MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &X, A ) ); in mbedtls_mpi_div_mpi()
1982 MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &Z, A->n + 2 ) ); in mbedtls_mpi_div_mpi()
1984 MBEDTLS_MPI_CHK( mbedtls_mpi_grow( &T1, A->n + 2 ) ); in mbedtls_mpi_div_mpi()
2048 Q->s = A->s * B->s; in mbedtls_mpi_div_mpi()
2054 X.s = A->s; in mbedtls_mpi_div_mpi()
2074 const mbedtls_mpi *A, in mbedtls_mpi_div_int() argument
2079 MPI_VALIDATE_RET( A != NULL ); in mbedtls_mpi_div_int()
2086 return( mbedtls_mpi_div_mpi( Q, R, A, &_B ) ); in mbedtls_mpi_div_int()
2092 int mbedtls_mpi_mod_mpi( mbedtls_mpi *R, const mbedtls_mpi *A, const mbedtls_mpi *B ) in mbedtls_mpi_mod_mpi() argument
2096 MPI_VALIDATE_RET( A != NULL ); in mbedtls_mpi_mod_mpi()
2102 MBEDTLS_MPI_CHK( mbedtls_mpi_div_mpi( NULL, R, A, B ) ); in mbedtls_mpi_mod_mpi()
2118 int mbedtls_mpi_mod_int( mbedtls_mpi_uint *r, const mbedtls_mpi *A, mbedtls_mpi_sint b ) in mbedtls_mpi_mod_int() argument
2123 MPI_VALIDATE_RET( A != NULL ); in mbedtls_mpi_mod_int()
2142 *r = A->p[0] & 1; in mbedtls_mpi_mod_int()
2149 for( i = A->n, y = 0; i > 0; i-- ) in mbedtls_mpi_mod_int()
2151 x = A->p[i - 1]; in mbedtls_mpi_mod_int()
2166 if( A->s < 0 && y != 0 ) in mbedtls_mpi_mod_int()
2218 static void mpi_montmul( mbedtls_mpi *A, const mbedtls_mpi *B, const mbedtls_mpi *N, mbedtls_mpi_ui… in mpi_montmul() argument
2235 u0 = A->p[i]; in mpi_montmul()
2250 memcpy( A->p, d, n * ciL ); in mpi_montmul()
2262 mpi_safe_cond_assign( n, A->p, d, (unsigned char) d[n] ); in mpi_montmul()
2265 void mbedtls_mpi_montmul( mbedtls_mpi *A, const mbedtls_mpi *B, const mbedtls_mpi *N, mbedtls_mpi_u… in mbedtls_mpi_montmul() argument
2268 mpi_montmul( A, B, N, mm, T); in mbedtls_mpi_montmul()
2276 static void mpi_montred( mbedtls_mpi *A, const mbedtls_mpi *N, in mpi_montred() argument
2285 mpi_montmul( A, &U, N, mm, T ); in mpi_montred()
2288 void mbedtls_mpi_montred( mbedtls_mpi *A, const mbedtls_mpi *N, in mbedtls_mpi_montred() argument
2291 mpi_montred( A, N, mm, T ); in mbedtls_mpi_montred()
2362 int mbedtls_mpi_exp_mod( mbedtls_mpi *X, const mbedtls_mpi *A, in mbedtls_mpi_exp_mod() argument
2377 MPI_VALIDATE_RET( A != NULL ); in mbedtls_mpi_exp_mod()
2422 neg = ( A->s == -1 ); in mbedtls_mpi_exp_mod()
2425 MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &Apos, A ) ); in mbedtls_mpi_exp_mod()
2427 A = &Apos; in mbedtls_mpi_exp_mod()
2458 if( mbedtls_mpi_cmp_mpi( A, N ) >= 0 ) in mbedtls_mpi_exp_mod()
2460 MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &W[1], A, N ) ); in mbedtls_mpi_exp_mod()
2467 MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &W[1], A ) ); in mbedtls_mpi_exp_mod()
2612 int mbedtls_mpi_gcd( mbedtls_mpi *G, const mbedtls_mpi *A, const mbedtls_mpi *B ) in mbedtls_mpi_gcd() argument
2619 MPI_VALIDATE_RET( A != NULL ); in mbedtls_mpi_gcd()
2624 MBEDTLS_MPI_CHK( mbedtls_mpi_copy( &TA, A ) ); in mbedtls_mpi_gcd()
2636 ret = mbedtls_mpi_copy( G, A ); in mbedtls_mpi_gcd()
2856 int mbedtls_mpi_inv_mod( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi *N ) in mbedtls_mpi_inv_mod() argument
2861 MPI_VALIDATE_RET( A != NULL ); in mbedtls_mpi_inv_mod()
2873 MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( &G, A, N ) ); in mbedtls_mpi_inv_mod()
2881 MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &TA, A, N ) ); in mbedtls_mpi_inv_mod()
3022 mbedtls_mpi W, R, T, A, RR; in mpi_miller_rabin() local
3028 mbedtls_mpi_init_mempool( &T ); mbedtls_mpi_init_mempool( &A ); in mpi_miller_rabin()
3047 MBEDTLS_MPI_CHK( mbedtls_mpi_fill_random( &A, X->n * ciL, f_rng, p_rng ) ); in mpi_miller_rabin()
3049 j = mbedtls_mpi_bitlen( &A ); in mpi_miller_rabin()
3052 A.p[A.n - 1] &= ( (mbedtls_mpi_uint) 1 << ( k - ( A.n - 1 ) * biL - 1 ) ) - 1; in mpi_miller_rabin()
3060 } while ( mbedtls_mpi_cmp_mpi( &A, &W ) >= 0 || in mpi_miller_rabin()
3061 mbedtls_mpi_cmp_int( &A, 1 ) <= 0 ); in mpi_miller_rabin()
3066 MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &A, &A, &R, X, &RR ) ); in mpi_miller_rabin()
3068 if( mbedtls_mpi_cmp_mpi( &A, &W ) == 0 || in mpi_miller_rabin()
3069 mbedtls_mpi_cmp_int( &A, 1 ) == 0 ) in mpi_miller_rabin()
3073 while( j < s && mbedtls_mpi_cmp_mpi( &A, &W ) != 0 ) in mpi_miller_rabin()
3078 MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &T, &A, &A ) ); in mpi_miller_rabin()
3079 MBEDTLS_MPI_CHK( mbedtls_mpi_mod_mpi( &A, &T, X ) ); in mpi_miller_rabin()
3081 if( mbedtls_mpi_cmp_int( &A, 1 ) == 0 ) in mpi_miller_rabin()
3090 if( mbedtls_mpi_cmp_mpi( &A, &W ) != 0 || in mpi_miller_rabin()
3091 mbedtls_mpi_cmp_int( &A, 1 ) == 0 ) in mpi_miller_rabin()
3100 mbedtls_mpi_free( &T ); mbedtls_mpi_free( &A ); in mpi_miller_rabin()
3306 mbedtls_mpi A, E, N, X, Y, U, V; in mbedtls_mpi_self_test() local
3308 mbedtls_mpi_init_mempool( &A ); mbedtls_mpi_init_mempool( &E ); in mbedtls_mpi_self_test()
3313 MBEDTLS_MPI_CHK( mbedtls_mpi_read_string( &A, 16, in mbedtls_mpi_self_test()
3330 MBEDTLS_MPI_CHK( mbedtls_mpi_mul_mpi( &X, &A, &N ) ); in mbedtls_mpi_self_test()
3356 MBEDTLS_MPI_CHK( mbedtls_mpi_div_mpi( &X, &Y, &A, &N ) ); in mbedtls_mpi_self_test()
3382 MBEDTLS_MPI_CHK( mbedtls_mpi_exp_mod( &X, &A, &E, &N, NULL ) ); in mbedtls_mpi_self_test()
3404 MBEDTLS_MPI_CHK( mbedtls_mpi_inv_mod( &X, &A, &N ) ); in mbedtls_mpi_self_test()
3434 MBEDTLS_MPI_CHK( mbedtls_mpi_gcd( &A, &X, &Y ) ); in mbedtls_mpi_self_test()
3436 if( mbedtls_mpi_cmp_int( &A, gcd_pairs[i][2] ) != 0 ) in mbedtls_mpi_self_test()
3454 mbedtls_mpi_free( &A ); mbedtls_mpi_free( &E ); mbedtls_mpi_free( &N ); mbedtls_mpi_free( &X ); in mbedtls_mpi_self_test()