Lines Matching refs:res

214   int     olduse, res, min, max;  in s_mp_add()  local
231 if ((res = mp_grow (c, max + 1)) != MP_OKAY) { in s_mp_add()
232 return res; in s_mp_add()
302 int olduse, res, min, max; in s_mp_sub() local
310 if ((res = mp_grow (c, max)) != MP_OKAY) { in s_mp_sub()
311 return res; in s_mp_sub()
421 int sa, sb, res; in mp_add() local
432 res = s_mp_add (a, b, c); in mp_add()
440 res = s_mp_sub (b, a, c); in mp_add()
443 res = s_mp_sub (a, b, c); in mp_add()
446 return res; in mp_add()
454 int sa, sb, res; in mp_sub() local
465 res = s_mp_add (a, b, c); in mp_sub()
475 res = s_mp_sub (a, b, c); in mp_sub()
481 res = s_mp_sub (b, a, c); in mp_sub()
484 return res; in mp_sub()
492 int res, neg; in mp_mul() local
498 res = mp_toom_mul(a, b, c); in mp_mul()
504 res = mp_karatsuba_mul (a, b, c); in mp_mul()
520 res = fast_s_mp_mul_digs (a, b, c, digs); in mp_mul()
524 res = s_mp_mul (a, b, c); /* uses s_mp_mul_digs */ in mp_mul()
527 res = MP_VAL; in mp_mul()
532 return res; in mp_mul()
540 int res; in mp_mulmod() local
543 if ((res = mp_init (&t)) != MP_OKAY) { in mp_mulmod()
544 return res; in mp_mulmod()
547 if ((res = mp_mul (a, b, &t)) != MP_OKAY) { in mp_mulmod()
549 return res; in mp_mulmod()
551 res = mp_mod (&t, c, d); in mp_mulmod()
553 return res; in mp_mulmod()
562 int res; in mp_mod() local
564 if ((res = mp_init (&t)) != MP_OKAY) { in mp_mod()
565 return res; in mp_mod()
568 if ((res = mp_div (a, b, NULL, &t)) != MP_OKAY) { in mp_mod()
570 return res; in mp_mod()
574 res = mp_add (b, &t, c); in mp_mod()
576 res = MP_OKAY; in mp_mod()
581 return res; in mp_mod()
775 int res; in mp_invmod_slow() local
783 if ((res = mp_init_multi(&x, &y, &u, &v, in mp_invmod_slow()
785 return res; in mp_invmod_slow()
789 if ((res = mp_mod(a, b, &x)) != MP_OKAY) { in mp_invmod_slow()
792 if ((res = mp_copy (b, &y)) != MP_OKAY) { in mp_invmod_slow()
798 res = MP_VAL; in mp_invmod_slow()
803 if ((res = mp_copy (&x, &u)) != MP_OKAY) { in mp_invmod_slow()
806 if ((res = mp_copy (&y, &v)) != MP_OKAY) { in mp_invmod_slow()
816 if ((res = mp_div_2 (&u, &u)) != MP_OKAY) { in mp_invmod_slow()
822 if ((res = mp_add (&A, &y, &A)) != MP_OKAY) { in mp_invmod_slow()
825 if ((res = mp_sub (&B, &x, &B)) != MP_OKAY) { in mp_invmod_slow()
830 if ((res = mp_div_2 (&A, &A)) != MP_OKAY) { in mp_invmod_slow()
833 if ((res = mp_div_2 (&B, &B)) != MP_OKAY) { in mp_invmod_slow()
841 if ((res = mp_div_2 (&v, &v)) != MP_OKAY) { in mp_invmod_slow()
847 if ((res = mp_add (&C, &y, &C)) != MP_OKAY) { in mp_invmod_slow()
850 if ((res = mp_sub (&D, &x, &D)) != MP_OKAY) { in mp_invmod_slow()
855 if ((res = mp_div_2 (&C, &C)) != MP_OKAY) { in mp_invmod_slow()
858 if ((res = mp_div_2 (&D, &D)) != MP_OKAY) { in mp_invmod_slow()
866 if ((res = mp_sub (&u, &v, &u)) != MP_OKAY) { in mp_invmod_slow()
870 if ((res = mp_sub (&A, &C, &A)) != MP_OKAY) { in mp_invmod_slow()
874 if ((res = mp_sub (&B, &D, &B)) != MP_OKAY) { in mp_invmod_slow()
879 if ((res = mp_sub (&v, &u, &v)) != MP_OKAY) { in mp_invmod_slow()
883 if ((res = mp_sub (&C, &A, &C)) != MP_OKAY) { in mp_invmod_slow()
887 if ((res = mp_sub (&D, &B, &D)) != MP_OKAY) { in mp_invmod_slow()
900 res = MP_VAL; in mp_invmod_slow()
906 if ((res = mp_add(&C, b, &C)) != MP_OKAY) { in mp_invmod_slow()
913 if ((res = mp_sub(&C, b, &C)) != MP_OKAY) { in mp_invmod_slow()
920 res = MP_OKAY; in mp_invmod_slow()
922 return res; in mp_invmod_slow()
967 int res; in mp_read_unsigned_bin() local
971 if ((res = mp_grow(a, 2)) != MP_OKAY) { in mp_read_unsigned_bin()
972 return res; in mp_read_unsigned_bin()
981 if ((res = mp_mul_2d (a, 8, a)) != MP_OKAY) { in mp_read_unsigned_bin()
982 return res; in mp_read_unsigned_bin()
1003 int x, res; in mp_to_unsigned_bin() local
1006 if ((res = mp_init_copy (&t, a)) != MP_OKAY) { in mp_to_unsigned_bin()
1007 return res; in mp_to_unsigned_bin()
1017 if ((res = mp_div_2d (&t, 8, &t, NULL)) != MP_OKAY) { in mp_to_unsigned_bin()
1019 return res; in mp_to_unsigned_bin()
1033 int x, res; in mp_div_2d() local
1039 res = mp_copy (a, c); in mp_div_2d()
1043 return res; in mp_div_2d()
1046 if ((res = mp_init (&t)) != MP_OKAY) { in mp_div_2d()
1047 return res; in mp_div_2d()
1052 if ((res = mp_mod_2d (a, b, &t)) != MP_OKAY) { in mp_div_2d()
1054 return res; in mp_div_2d()
1059 if ((res = mp_copy (a, c)) != MP_OKAY) { in mp_div_2d()
1061 return res; in mp_div_2d()
1109 int res; in mp_init_copy() local
1111 if ((res = mp_init (a)) != MP_OKAY) { in mp_init_copy()
1112 return res; in mp_init_copy()
1139 int res, n; in mp_copy() local
1148 if ((res = mp_grow (b, a->used)) != MP_OKAY) { in mp_copy()
1149 return res; in mp_copy()
1320 int res; in mp_abs() local
1324 if ((res = mp_copy (a, b)) != MP_OKAY) { in mp_abs()
1325 return res; in mp_abs()
1352 int x, res, oldused; in mp_div_2() local
1356 if ((res = mp_grow (b, a->used)) != MP_OKAY) { in mp_div_2()
1357 return res; in mp_div_2()
1403 int res; in mp_mul_2d() local
1407 if ((res = mp_copy (a, c)) != MP_OKAY) { in mp_mul_2d()
1408 return res; in mp_mul_2d()
1413 if ((res = mp_grow (c, c->used + b / DIGIT_BIT + 1)) != MP_OKAY) { in mp_mul_2d()
1414 return res; in mp_mul_2d()
1420 if ((res = mp_lshd (c, b / DIGIT_BIT)) != MP_OKAY) { in mp_mul_2d()
1421 return res; in mp_mul_2d()
1468 mp_err res = MP_OKAY; /* Assume ok until proven otherwise */ in mp_init_multi() local
1492 res = MP_MEM; in mp_init_multi()
1499 return res; /* Assumed ok, if error flagged above. */ in mp_init_multi()
1524 int x, res; in mp_lshd() local
1533 if ((res = mp_grow (a, a->used + b)) != MP_OKAY) { in mp_lshd()
1534 return res; in mp_lshd()
1597 int x, res; in mp_mod_2d() local
1607 res = mp_copy (a, c); in mp_mod_2d()
1608 return res; in mp_mod_2d()
1612 if ((res = mp_copy (a, c)) != MP_OKAY) { in mp_mod_2d()
1613 return res; in mp_mod_2d()
1635 int res, n, n2; in mp_div() local
1645 res = mp_copy (a, d); in mp_div()
1647 res = MP_OKAY; in mp_div()
1652 return res; in mp_div()
1656 if ((res = mp_init_multi(&ta, &tb, &tq, &q, NULL)) != MP_OKAY) { in mp_div()
1657 return res; in mp_div()
1663 if (((res = mp_abs(a, &ta)) != MP_OKAY) || in mp_div()
1664 ((res = mp_abs(b, &tb)) != MP_OKAY) || in mp_div()
1665 ((res = mp_mul_2d(&tb, n, &tb)) != MP_OKAY) || in mp_div()
1666 ((res = mp_mul_2d(&tq, n, &tq)) != MP_OKAY)) { in mp_div()
1672 if (((res = mp_sub(&ta, &tb, &ta)) != MP_OKAY) || in mp_div()
1673 ((res = mp_add(&q, &tq, &q)) != MP_OKAY)) { in mp_div()
1677 if (((res = mp_div_2d(&tb, 1, &tb, NULL)) != MP_OKAY) || in mp_div()
1678 ((res = mp_div_2d(&tq, 1, &tq, NULL)) != MP_OKAY)) { in mp_div()
1696 return res; in mp_div()
1718 int res, n, t, i, norm, neg; in mp_div() local
1728 res = mp_copy (a, d); in mp_div()
1730 res = MP_OKAY; in mp_div()
1735 return res; in mp_div()
1738 if ((res = mp_init_size (&q, a->used + 2)) != MP_OKAY) { in mp_div()
1739 return res; in mp_div()
1743 if ((res = mp_init (&t1)) != MP_OKAY) { in mp_div()
1747 if ((res = mp_init (&t2)) != MP_OKAY) { in mp_div()
1751 if ((res = mp_init_copy (&x, a)) != MP_OKAY) { in mp_div()
1755 if ((res = mp_init_copy (&y, b)) != MP_OKAY) { in mp_div()
1767 if ((res = mp_mul_2d (&x, norm, &x)) != MP_OKAY) { in mp_div()
1770 if ((res = mp_mul_2d (&y, norm, &y)) != MP_OKAY) { in mp_div()
1782 if ((res = mp_lshd (&y, n - t)) != MP_OKAY) { /* y = y*b**{n-t} */ in mp_div()
1788 if ((res = mp_sub (&x, &y, &x)) != MP_OKAY) { in mp_div()
1830 if ((res = mp_mul_d (&t1, q.dp[i - t - 1], &t1)) != MP_OKAY) { in mp_div()
1842 if ((res = mp_mul_d (&y, q.dp[i - t - 1], &t1)) != MP_OKAY) { in mp_div()
1846 if ((res = mp_lshd (&t1, i - t - 1)) != MP_OKAY) { in mp_div()
1850 if ((res = mp_sub (&x, &t1, &x)) != MP_OKAY) { in mp_div()
1856 if ((res = mp_copy (&y, &t1)) != MP_OKAY) { in mp_div()
1859 if ((res = mp_lshd (&t1, i - t - 1)) != MP_OKAY) { in mp_div()
1862 if ((res = mp_add (&x, &t1, &x)) != MP_OKAY) { in mp_div()
1888 res = MP_OKAY; in mp_div()
1895 return res; in mp_div()
1910 mp_int M[TAB_SIZE], res, mu; in s_mp_exptmod() local
2018 if ((err = mp_init (&res)) != MP_OKAY) { in s_mp_exptmod()
2021 mp_set (&res, 1); in s_mp_exptmod()
2058 if ((err = mp_sqr (&res, &res)) != MP_OKAY) { in s_mp_exptmod()
2061 if ((err = redux (&res, P, &mu)) != MP_OKAY) { in s_mp_exptmod()
2075 if ((err = mp_sqr (&res, &res)) != MP_OKAY) { in s_mp_exptmod()
2078 if ((err = redux (&res, P, &mu)) != MP_OKAY) { in s_mp_exptmod()
2084 if ((err = mp_mul (&res, &M[bitbuf], &res)) != MP_OKAY) { in s_mp_exptmod()
2087 if ((err = redux (&res, P, &mu)) != MP_OKAY) { in s_mp_exptmod()
2102 if ((err = mp_sqr (&res, &res)) != MP_OKAY) { in s_mp_exptmod()
2105 if ((err = redux (&res, P, &mu)) != MP_OKAY) { in s_mp_exptmod()
2112 if ((err = mp_mul (&res, &M[1], &res)) != MP_OKAY) { in s_mp_exptmod()
2115 if ((err = redux (&res, P, &mu)) != MP_OKAY) { in s_mp_exptmod()
2122 mp_exch (&res, Y); in s_mp_exptmod()
2124 LBL_RES:mp_clear (&res); in s_mp_exptmod()
2139 int res; in mp_sqr() local
2144 res = mp_toom_sqr(a, b); in mp_sqr()
2150 res = mp_karatsuba_sqr (a, b); in mp_sqr()
2159 res = fast_s_mp_sqr (a, b); in mp_sqr()
2163 res = s_mp_sqr (a, b); in mp_sqr()
2166 res = MP_VAL; in mp_sqr()
2170 return res; in mp_sqr()
2182 int p, res; in mp_reduce_2k_l() local
2184 if ((res = mp_init(&q)) != MP_OKAY) { in mp_reduce_2k_l()
2185 return res; in mp_reduce_2k_l()
2191 if ((res = mp_div_2d(a, p, &q, a)) != MP_OKAY) { in mp_reduce_2k_l()
2196 if ((res = mp_mul(&q, d, &q)) != MP_OKAY) { in mp_reduce_2k_l()
2201 if ((res = s_mp_add(a, &q, a)) != MP_OKAY) { in mp_reduce_2k_l()
2212 return res; in mp_reduce_2k_l()
2220 int res; in mp_reduce_2k_setup_l() local
2223 if ((res = mp_init(&tmp)) != MP_OKAY) { in mp_reduce_2k_setup_l()
2224 return res; in mp_reduce_2k_setup_l()
2227 if ((res = mp_2expt(&tmp, mp_count_bits(a))) != MP_OKAY) { in mp_reduce_2k_setup_l()
2231 if ((res = s_mp_sub(&tmp, a, d)) != MP_OKAY) { in mp_reduce_2k_setup_l()
2237 return res; in mp_reduce_2k_setup_l()
2249 int res; in mp_2expt() local
2255 if ((res = mp_grow (a, b / DIGIT_BIT + 1)) != MP_OKAY) { in mp_2expt()
2256 return res; in mp_2expt()
2275 int res; in mp_reduce_setup() local
2277 if ((res = mp_2expt (a, b->used * 2 * DIGIT_BIT)) != MP_OKAY) { in mp_reduce_setup()
2278 return res; in mp_reduce_setup()
2292 int res, um = m->used; in mp_reduce() local
2295 if ((res = mp_init_copy (&q, x)) != MP_OKAY) { in mp_reduce()
2296 return res; in mp_reduce()
2304 if ((res = mp_mul (&q, mu, &q)) != MP_OKAY) { in mp_reduce()
2309 if ((res = s_mp_mul_high_digs (&q, mu, &q, um)) != MP_OKAY) { in mp_reduce()
2313 if ((res = fast_s_mp_mul_high_digs (&q, mu, &q, um)) != MP_OKAY) { in mp_reduce()
2319 res = MP_VAL; in mp_reduce()
2329 if ((res = mp_mod_2d (x, DIGIT_BIT * (um + 1), x)) != MP_OKAY) { in mp_reduce()
2334 if ((res = s_mp_mul_digs (&q, m, &q, um + 1)) != MP_OKAY) { in mp_reduce()
2339 if ((res = mp_sub (x, &q, x)) != MP_OKAY) { in mp_reduce()
2346 if ((res = mp_lshd (&q, um + 1)) != MP_OKAY) { in mp_reduce()
2349 if ((res = mp_add (x, &q, x)) != MP_OKAY) { in mp_reduce()
2356 if ((res = s_mp_sub (x, m, x)) != MP_OKAY) { in mp_reduce()
2364 return res; in mp_reduce()
2376 int res, pa, pb, ix, iy; in s_mp_mul_digs() local
2388 if ((res = mp_init_size (&t, digs)) != MP_OKAY) { in s_mp_mul_digs()
2389 return res; in s_mp_mul_digs()
2458 int olduse, res, pa, ix, iz; in fast_s_mp_mul_digs() local
2464 if ((res = mp_grow (c, digs)) != MP_OKAY) { in fast_s_mp_mul_digs()
2465 return res; in fast_s_mp_mul_digs()
2561 int res, ix, iy, pa; in s_mp_sqr() local
2566 if ((res = mp_init_size (&t, 2*pa + 1)) != MP_OKAY) { in s_mp_sqr()
2567 return res; in s_mp_sqr()
2628 int res, pa, pb, ix, iy; in s_mp_mul_high_digs() local
2641 if ((res = mp_init_size (&t, a->used + b->used + 1)) != MP_OKAY) { in s_mp_mul_high_digs()
2642 return res; in s_mp_mul_high_digs()
2735 int ix, res, olduse; in fast_mp_montgomery_reduce() local
2743 if ((res = mp_grow (x, n->used + 1)) != MP_OKAY) { in fast_mp_montgomery_reduce()
2744 return res; in fast_mp_montgomery_reduce()
2883 int x, res, oldused; in mp_mul_2() local
2887 if ((res = mp_grow (b, a->used + 1)) != MP_OKAY) { in mp_mul_2()
2888 return res; in mp_mul_2()
2953 int x, bits, res; in mp_montgomery_calc_normalization() local
2959 if ((res = mp_2expt (a, (b->used - 1) * DIGIT_BIT + bits - 1)) != MP_OKAY) { in mp_montgomery_calc_normalization()
2960 return res; in mp_montgomery_calc_normalization()
2970 if ((res = mp_mul_2 (a, a)) != MP_OKAY) { in mp_montgomery_calc_normalization()
2971 return res; in mp_montgomery_calc_normalization()
2974 if ((res = s_mp_sub (a, b, a)) != MP_OKAY) { in mp_montgomery_calc_normalization()
2975 return res; in mp_montgomery_calc_normalization()
2997 mp_int M[TAB_SIZE], res; in mp_exptmod_fast() local
3099 if ((err = mp_init (&res)) != MP_OKAY) { in mp_exptmod_fast()
3113 if ((err = mp_montgomery_calc_normalization (&res, P)) != MP_OKAY) { in mp_exptmod_fast()
3122 if ((err = mp_mulmod (G, &res, P, &M[1])) != MP_OKAY) { in mp_exptmod_fast()
3126 mp_set(&res, 1); in mp_exptmod_fast()
3191 if ((err = mp_sqr (&res, &res)) != MP_OKAY) { in mp_exptmod_fast()
3194 if ((err = redux (&res, P, mp)) != MP_OKAY) { in mp_exptmod_fast()
3208 if ((err = mp_sqr (&res, &res)) != MP_OKAY) { in mp_exptmod_fast()
3211 if ((err = redux (&res, P, mp)) != MP_OKAY) { in mp_exptmod_fast()
3217 if ((err = mp_mul (&res, &M[bitbuf], &res)) != MP_OKAY) { in mp_exptmod_fast()
3220 if ((err = redux (&res, P, mp)) != MP_OKAY) { in mp_exptmod_fast()
3235 if ((err = mp_sqr (&res, &res)) != MP_OKAY) { in mp_exptmod_fast()
3238 if ((err = redux (&res, P, mp)) != MP_OKAY) { in mp_exptmod_fast()
3246 if ((err = mp_mul (&res, &M[1], &res)) != MP_OKAY) { in mp_exptmod_fast()
3249 if ((err = redux (&res, P, mp)) != MP_OKAY) { in mp_exptmod_fast()
3263 if ((err = redux(&res, P, mp)) != MP_OKAY) { in mp_exptmod_fast()
3269 mp_exch (&res, Y); in mp_exptmod_fast()
3271 LBL_RES:mp_clear (&res); in mp_exptmod_fast()
3296 int olduse, res, pa, ix, iz; in fast_s_mp_sqr() local
3303 if ((res = mp_grow (b, pa)) != MP_OKAY) { in fast_s_mp_sqr()
3304 return res; in fast_s_mp_sqr()
3386 int ix, res, olduse; in mp_mul_d() local
3390 if ((res = mp_grow (c, a->used + 1)) != MP_OKAY) { in mp_mul_d()
3391 return res; in mp_mul_d()