Lines Matching refs:MP_OKAY
23 { MP_OKAY, "Successful" },
87 if ((res = mp_init_multi(&x, &y, &u, &v, &B, &D, NULL)) != MP_OKAY) {
92 if ((res = mp_copy (b, &x)) != MP_OKAY) {
97 if ((res = mp_mod (a, b, &y)) != MP_OKAY) {
102 if ((res = mp_copy (&x, &u)) != MP_OKAY) {
105 if ((res = mp_copy (&y, &v)) != MP_OKAY) {
114 if ((res = mp_div_2 (&u, &u)) != MP_OKAY) {
119 if ((res = mp_sub (&B, &x, &B)) != MP_OKAY) {
124 if ((res = mp_div_2 (&B, &B)) != MP_OKAY) {
132 if ((res = mp_div_2 (&v, &v)) != MP_OKAY) {
138 if ((res = mp_sub (&D, &x, &D)) != MP_OKAY) {
143 if ((res = mp_div_2 (&D, &D)) != MP_OKAY) {
151 if ((res = mp_sub (&u, &v, &u)) != MP_OKAY) {
155 if ((res = mp_sub (&B, &D, &B)) != MP_OKAY) {
160 if ((res = mp_sub (&v, &u, &v)) != MP_OKAY) {
164 if ((res = mp_sub (&D, &B, &D)) != MP_OKAY) {
185 if ((res = mp_add (&D, b, &D)) != MP_OKAY) {
191 res = MP_OKAY;
240 if ((res = mp_grow (x, n->used + 1)) != MP_OKAY) {
370 return MP_OKAY;
422 if ((res = mp_grow (c, digs)) != MP_OKAY) {
481 return MP_OKAY;
527 if ((res = mp_grow (c, pa)) != MP_OKAY) {
583 return MP_OKAY;
630 if ((res = mp_grow (b, pa)) != MP_OKAY) {
701 return MP_OKAY;
743 if ((res = mp_grow (a, b / DIGIT_BIT + 1)) != MP_OKAY) {
753 return MP_OKAY;
792 if ((res = mp_copy (a, b)) != MP_OKAY) {
800 return MP_OKAY;
894 if ((res = mp_grow(c, a->used + 1)) != MP_OKAY) {
972 return MP_OKAY;
1008 if ((res = mp_init (&t)) != MP_OKAY) {
1012 if ((res = mp_add (a, b, &t)) != MP_OKAY) {
1054 if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
1060 if ((res = mp_init_copy (&t, b)) != MP_OKAY) {
1079 return MP_OKAY;
1460 return MP_OKAY;
1465 if ((res = mp_grow (b, a->used)) != MP_OKAY) {
1496 return MP_OKAY;
1591 res = MP_OKAY;
1600 if ((res = mp_init_multi(&ta, &tb, &tq, &q, NULL) != MP_OKAY)) {
1607 if (((res = mp_abs(a, &ta)) != MP_OKAY) ||
1608 ((res = mp_abs(b, &tb)) != MP_OKAY) ||
1609 ((res = mp_mul_2d(&tb, n, &tb)) != MP_OKAY) ||
1610 ((res = mp_mul_2d(&tq, n, &tq)) != MP_OKAY)) {
1616 if (((res = mp_sub(&ta, &tb, &ta)) != MP_OKAY) ||
1617 ((res = mp_add(&q, &tq, &q)) != MP_OKAY)) {
1621 if (((res = mp_div_2d(&tb, 1, &tb, NULL)) != MP_OKAY) ||
1622 ((res = mp_div_2d(&tq, 1, &tq, NULL)) != MP_OKAY)) {
1673 res = MP_OKAY;
1681 if ((res = mp_init_size (&q, a->used + 2)) != MP_OKAY) {
1686 if ((res = mp_init (&t1)) != MP_OKAY) {
1690 if ((res = mp_init (&t2)) != MP_OKAY) {
1694 if ((res = mp_init_copy (&x, a)) != MP_OKAY) {
1698 if ((res = mp_init_copy (&y, b)) != MP_OKAY) {
1710 if ((res = mp_mul_2d (&x, norm, &x)) != MP_OKAY) {
1713 if ((res = mp_mul_2d (&y, norm, &y)) != MP_OKAY) {
1725 if ((res = mp_lshd (&y, n - t)) != MP_OKAY) { /* y = y*b**{n-t} */
1731 if ((res = mp_sub (&x, &y, &x)) != MP_OKAY) {
1773 if ((res = mp_mul_d (&t1, q.dp[i - t - 1], &t1)) != MP_OKAY) {
1785 if ((res = mp_mul_d (&y, q.dp[i - t - 1], &t1)) != MP_OKAY) {
1789 if ((res = mp_lshd (&t1, i - t - 1)) != MP_OKAY) {
1793 if ((res = mp_sub (&x, &t1, &x)) != MP_OKAY) {
1799 if ((res = mp_copy (&y, &t1)) != MP_OKAY) {
1802 if ((res = mp_lshd (&t1, i - t - 1)) != MP_OKAY) {
1805 if ((res = mp_add (&x, &t1, &x)) != MP_OKAY) {
1831 res = MP_OKAY;
1876 if ((res = mp_grow (b, a->used)) != MP_OKAY) {
1913 return MP_OKAY;
1958 if ((res = mp_init (&t)) != MP_OKAY) {
1964 if ((res = mp_mod_2d (a, b, &t)) != MP_OKAY) {
1971 if ((res = mp_copy (a, c)) != MP_OKAY) {
2014 return MP_OKAY;
2054 if ((res = mp_init_size(&q, a->used)) != MP_OKAY) {
2159 return MP_OKAY;
2170 return MP_OKAY;
2181 if ((res = mp_init_size(&q, a->used)) != MP_OKAY) {
2312 if ((err = mp_grow (x, m + m)) != MP_OKAY) {
2356 return MP_OKAY;
2464 if ((res = mp_init_copy (&g, a)) != MP_OKAY) {
2473 if ((res = mp_sqr (c, c)) != MP_OKAY) {
2480 if ((res = mp_mul (c, &g, c)) != MP_OKAY) {
2491 return MP_OKAY;
2541 if ((err = mp_init(&tmpG)) != MP_OKAY) {
2544 if ((err = mp_invmod(G, P, &tmpG)) != MP_OKAY) {
2550 if ((err = mp_init(&tmpX)) != MP_OKAY) {
2554 if ((err = mp_abs(X, &tmpX)) != MP_OKAY) {
2687 if ((err = mp_init(&M[1])) != MP_OKAY) {
2693 if ((err = mp_init(&M[x])) != MP_OKAY) {
2706 if ((err = mp_montgomery_setup (P, &mp)) != MP_OKAY) {
2742 if ((err = mp_reduce_2k_setup(P, &mp)) != MP_OKAY) {
2753 if ((err = mp_init (&res)) != MP_OKAY) {
2767 if ((err = mp_montgomery_calc_normalization (&res, P)) != MP_OKAY) {
2776 if ((err = mp_mulmod (G, &res, P, &M[1])) != MP_OKAY) {
2781 if ((err = mp_mod(G, P, &M[1])) != MP_OKAY) {
2787 if ((err = mp_copy (&M[1], &M[1 << (winsize - 1)])) != MP_OKAY) {
2792 if ((err = mp_sqr (&M[1 << (winsize - 1)], &M[1 << (winsize - 1)])) != MP_OKAY) {
2795 if ((err = redux (&M[1 << (winsize - 1)], P, mp)) != MP_OKAY) {
2802 if ((err = mp_mul (&M[x - 1], &M[1], &M[x])) != MP_OKAY) {
2805 if ((err = redux (&M[x], P, mp)) != MP_OKAY) {
2845 if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
2848 if ((err = redux (&res, P, mp)) != MP_OKAY) {
2862 if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
2865 if ((err = redux (&res, P, mp)) != MP_OKAY) {
2871 if ((err = mp_mul (&res, &M[bitbuf], &res)) != MP_OKAY) {
2874 if ((err = redux (&res, P, mp)) != MP_OKAY) {
2889 if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
2892 if ((err = redux (&res, P, mp)) != MP_OKAY) {
2900 if ((err = mp_mul (&res, &M[1], &res)) != MP_OKAY) {
2903 if ((err = redux (&res, P, mp)) != MP_OKAY) {
2917 if ((err = redux(&res, P, mp)) != MP_OKAY) {
2924 err = MP_OKAY;
2968 if ((err = mp_init_multi(&u1, &u2, &u3, &v1, &v2, &v3, &t1, &t2, &t3, &q, &tmp, NULL)) != MP_OKAY) {
2974 if ((err = mp_copy(a, &u3)) != MP_OKAY) { goto _ERR; }
2978 if ((err = mp_copy(b, &v3)) != MP_OKAY) { goto _ERR; }
2983 if ((err = mp_div(&u3, &v3, &q, NULL)) != MP_OKAY) { goto _ERR; }
2986 if ((err = mp_mul(&v1, &q, &tmp)) != MP_OKAY) { goto _ERR; }
2987 if ((err = mp_sub(&u1, &tmp, &t1)) != MP_OKAY) { goto _ERR; }
2988 if ((err = mp_mul(&v2, &q, &tmp)) != MP_OKAY) { goto _ERR; }
2989 if ((err = mp_sub(&u2, &tmp, &t2)) != MP_OKAY) { goto _ERR; }
2990 if ((err = mp_mul(&v3, &q, &tmp)) != MP_OKAY) { goto _ERR; }
2991 if ((err = mp_sub(&u3, &tmp, &t3)) != MP_OKAY) { goto _ERR; }
2994 if ((err = mp_copy(&v1, &u1)) != MP_OKAY) { goto _ERR; }
2995 if ((err = mp_copy(&v2, &u2)) != MP_OKAY) { goto _ERR; }
2996 if ((err = mp_copy(&v3, &u3)) != MP_OKAY) { goto _ERR; }
2999 if ((err = mp_copy(&t1, &v1)) != MP_OKAY) { goto _ERR; }
3000 if ((err = mp_copy(&t2, &v2)) != MP_OKAY) { goto _ERR; }
3001 if ((err = mp_copy(&t3, &v3)) != MP_OKAY) { goto _ERR; }
3016 err = MP_OKAY;
3075 if ((err = mp_mul_d(a, radix, a)) != MP_OKAY) {
3078 if ((err = mp_add_d(a, y, a)) != MP_OKAY) {
3088 return MP_OKAY;
3122 if ((err = mp_radix_size(a, radix, &len)) != MP_OKAY) {
3131 if ((err = mp_toradix(a, buf, radix)) != MP_OKAY) {
3144 return MP_OKAY;
3188 if ((res = mp_init_copy (&u, a)) != MP_OKAY) {
3192 if ((res = mp_init_copy (&v, b)) != MP_OKAY) {
3206 if ((res = mp_div_2d(&u, k, &u, NULL)) != MP_OKAY) {
3210 if ((res = mp_div_2d(&v, k, &v, NULL)) != MP_OKAY) {
3217 if ((res = mp_div_2d(&u, u_lsb - k, &u, NULL)) != MP_OKAY) {
3223 if ((res = mp_div_2d(&v, v_lsb - k, &v, NULL)) != MP_OKAY) {
3236 if ((res = s_mp_sub(&v, &u, &v)) != MP_OKAY) {
3241 if ((res = mp_div_2d(&v, mp_cnt_lsb(&v), &v, NULL)) != MP_OKAY) {
3247 if ((res = mp_mul_2d (&u, k, c)) != MP_OKAY) {
3251 res = MP_OKAY;
3364 return MP_OKAY;
3414 return MP_OKAY;
3447 if ((res = mp_init (a)) != MP_OKAY) {
3481 mp_err res = MP_OKAY; /* Assume ok until proven otherwise */
3488 if (mp_init(cur_arg) != MP_OKAY) {
3545 if ((err = mp_init(a)) != MP_OKAY) {
3581 if ((err = mp_init(a)) != MP_OKAY) {
3636 return MP_OKAY;
3724 &A, &B, &C, &D, NULL)) != MP_OKAY) {
3729 if ((res = mp_mod(a, b, &x)) != MP_OKAY) {
3732 if ((res = mp_copy (b, &y)) != MP_OKAY) {
3743 if ((res = mp_copy (&x, &u)) != MP_OKAY) {
3746 if ((res = mp_copy (&y, &v)) != MP_OKAY) {
3756 if ((res = mp_div_2 (&u, &u)) != MP_OKAY) {
3762 if ((res = mp_add (&A, &y, &A)) != MP_OKAY) {
3765 if ((res = mp_sub (&B, &x, &B)) != MP_OKAY) {
3770 if ((res = mp_div_2 (&A, &A)) != MP_OKAY) {
3773 if ((res = mp_div_2 (&B, &B)) != MP_OKAY) {
3781 if ((res = mp_div_2 (&v, &v)) != MP_OKAY) {
3787 if ((res = mp_add (&C, &y, &C)) != MP_OKAY) {
3790 if ((res = mp_sub (&D, &x, &D)) != MP_OKAY) {
3795 if ((res = mp_div_2 (&C, &C)) != MP_OKAY) {
3798 if ((res = mp_div_2 (&D, &D)) != MP_OKAY) {
3806 if ((res = mp_sub (&u, &v, &u)) != MP_OKAY) {
3810 if ((res = mp_sub (&A, &C, &A)) != MP_OKAY) {
3814 if ((res = mp_sub (&B, &D, &B)) != MP_OKAY) {
3819 if ((res = mp_sub (&v, &u, &v)) != MP_OKAY) {
3823 if ((res = mp_sub (&C, &A, &C)) != MP_OKAY) {
3827 if ((res = mp_sub (&D, &B, &D)) != MP_OKAY) {
3846 if ((res = mp_add(&C, b, &C)) != MP_OKAY) {
3853 if ((res = mp_sub(&C, b, &C)) != MP_OKAY) {
3860 res = MP_OKAY;
3929 return MP_OKAY;
3934 return MP_OKAY;
3938 if ((res = mp_mod_d(arg,105,&c)) != MP_OKAY) {
3942 return MP_OKAY;
3946 if ((res = mp_init_set_int(&t,11L*13L*17L*19L*23L*29L*31L)) != MP_OKAY) {
3949 if ((res = mp_mod(arg,&t,&t)) != MP_OKAY) {
3955 * is already equal to MP_OKAY from the mp_mod call
3966 if ((res = mp_sqrt(arg,&t)) != MP_OKAY) {
3969 if ((res = mp_sqr(&t,&t)) != MP_OKAY) {
4020 return MP_OKAY;
4026 return MP_OKAY;
4033 if ((res = mp_init_copy (&a1, a)) != MP_OKAY) {
4037 if ((res = mp_init (&p1)) != MP_OKAY) {
4043 if ((res = mp_div_2d(&a1, k, &a1, NULL)) != MP_OKAY) {
4071 if ((res = mp_mod (p, &a1, &p1)) != MP_OKAY) {
4074 if ((res = mp_jacobi (&p1, &a1, &r)) != MP_OKAY) {
4081 res = MP_OKAY;
4156 if (mp_init_size (&x0, B) != MP_OKAY)
4158 if (mp_init_size (&x1, a->used - B) != MP_OKAY)
4160 if (mp_init_size (&y0, B) != MP_OKAY)
4162 if (mp_init_size (&y1, b->used - B) != MP_OKAY)
4166 if (mp_init_size (&t1, B * 2) != MP_OKAY)
4168 if (mp_init_size (&x0y0, B * 2) != MP_OKAY)
4170 if (mp_init_size (&x1y1, B * 2) != MP_OKAY)
4214 if (mp_mul (&x0, &y0, &x0y0) != MP_OKAY)
4216 if (mp_mul (&x1, &y1, &x1y1) != MP_OKAY)
4220 if (s_mp_add (&x1, &x0, &t1) != MP_OKAY)
4222 if (s_mp_add (&y1, &y0, &x0) != MP_OKAY)
4224 if (mp_mul (&t1, &x0, &t1) != MP_OKAY)
4228 if (mp_add (&x0y0, &x1y1, &x0) != MP_OKAY)
4230 if (s_mp_sub (&t1, &x0, &t1) != MP_OKAY)
4234 if (mp_lshd (&t1, B) != MP_OKAY)
4236 if (mp_lshd (&x1y1, B * 2) != MP_OKAY)
4239 if (mp_add (&x0y0, &t1, &t1) != MP_OKAY)
4241 if (mp_add (&t1, &x1y1, c) != MP_OKAY)
4244 /* Algorithm succeeded set the return code to MP_OKAY */
4245 err = MP_OKAY;
4304 if (mp_init_size (&x0, B) != MP_OKAY)
4306 if (mp_init_size (&x1, a->used - B) != MP_OKAY)
4310 if (mp_init_size (&t1, a->used * 2) != MP_OKAY)
4312 if (mp_init_size (&t2, a->used * 2) != MP_OKAY)
4314 if (mp_init_size (&x0x0, B * 2) != MP_OKAY)
4316 if (mp_init_size (&x1x1, (a->used - B) * 2) != MP_OKAY)
4343 if (mp_sqr (&x0, &x0x0) != MP_OKAY)
4345 if (mp_sqr (&x1, &x1x1) != MP_OKAY)
4349 if (s_mp_add (&x1, &x0, &t1) != MP_OKAY)
4351 if (mp_sqr (&t1, &t1) != MP_OKAY)
4355 if (s_mp_add (&x0x0, &x1x1, &t2) != MP_OKAY)
4357 if (s_mp_sub (&t1, &t2, &t1) != MP_OKAY)
4361 if (mp_lshd (&t1, B) != MP_OKAY)
4363 if (mp_lshd (&x1x1, B * 2) != MP_OKAY)
4366 if (mp_add (&x0x0, &t1, &t1) != MP_OKAY)
4368 if (mp_add (&t1, &x1x1, b) != MP_OKAY)
4371 err = MP_OKAY;
4415 if ((res = mp_init_multi (&t1, &t2, NULL)) != MP_OKAY) {
4420 if ((res = mp_gcd (a, b, &t1)) != MP_OKAY) {
4427 if ((res = mp_div(a, &t1, &t2, NULL)) != MP_OKAY) {
4433 if ((res = mp_div(b, &t1, &t2, NULL)) != MP_OKAY) {
4479 return MP_OKAY;
4484 if ((res = mp_grow (a, a->used + b)) != MP_OKAY) {
4515 return MP_OKAY;
4550 if ((res = mp_init (&t)) != MP_OKAY) {
4554 if ((res = mp_div (a, b, NULL, &t)) != MP_OKAY) {
4562 res = MP_OKAY;
4604 return MP_OKAY;
4614 if ((res = mp_copy (a, c)) != MP_OKAY) {
4626 return MP_OKAY;
4699 if ((res = mp_2expt (a, (b->used - 1) * DIGIT_BIT + bits - 1)) != MP_OKAY) {
4710 if ((res = mp_mul_2 (a, a)) != MP_OKAY) {
4714 if ((res = s_mp_sub (a, b, a)) != MP_OKAY) {
4720 return MP_OKAY;
4770 if ((res = mp_grow (x, digs)) != MP_OKAY) {
4842 return MP_OKAY;
4905 return MP_OKAY;
5010 if ((res = mp_grow (b, a->used + 1)) != MP_OKAY) {
5061 return MP_OKAY;
5097 if ((res = mp_copy (a, c)) != MP_OKAY) {
5103 if ((res = mp_grow (c, c->used + b / DIGIT_BIT + 1)) != MP_OKAY) {
5110 if ((res = mp_lshd (c, b / DIGIT_BIT)) != MP_OKAY) {
5150 return MP_OKAY;
5188 if ((res = mp_grow (c, a->used + 1)) != MP_OKAY) {
5233 return MP_OKAY;
5267 if ((res = mp_init (&t)) != MP_OKAY) {
5271 if ((res = mp_mul (a, b, &t)) != MP_OKAY) {
5325 if ((res = mp_init (&t1)) != MP_OKAY) {
5329 if ((res = mp_init (&t2)) != MP_OKAY) {
5333 if ((res = mp_init (&t3)) != MP_OKAY) {
5346 if ((res = mp_copy (&t2, &t1)) != MP_OKAY) {
5353 if ((res = mp_expt_d (&t1, b - 1, &t3)) != MP_OKAY) {
5359 if ((res = mp_mul (&t3, &t1, &t2)) != MP_OKAY) {
5364 if ((res = mp_sub (&t2, a, &t2)) != MP_OKAY) {
5370 if ((res = mp_mul_d (&t3, b, &t3)) != MP_OKAY) {
5375 if ((res = mp_div (&t2, &t3, &t3, NULL)) != MP_OKAY) {
5379 if ((res = mp_sub (&t1, &t3, &t2)) != MP_OKAY) {
5386 if ((res = mp_expt_d (&t1, b, &t2)) != MP_OKAY) {
5391 if ((res = mp_sub_d (&t1, 1, &t1)) != MP_OKAY) {
5408 res = MP_OKAY;
5446 if ((res = mp_copy (a, b)) != MP_OKAY) {
5457 return MP_OKAY;
5492 if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
5498 if ((res = mp_init_copy (&t, b)) != MP_OKAY) {
5511 return MP_OKAY;
5561 if ((err = mp_init (&t)) != MP_OKAY) {
5566 if ((err = mp_exptmod (b, a, a, &t)) != MP_OKAY) {
5575 err = MP_OKAY;
5620 if ((err = mp_mod_d (a, ltm_prime_tab[ix], &res)) != MP_OKAY) {
5627 return MP_OKAY;
5631 return MP_OKAY;
5683 return MP_OKAY;
5688 if ((err = mp_prime_is_divisible (a, &res)) != MP_OKAY) {
5694 return MP_OKAY;
5698 if ((err = mp_init (&b)) != MP_OKAY) {
5706 if ((err = mp_prime_miller_rabin (a, &b, &res)) != MP_OKAY) {
5767 if ((err = mp_init_copy (&n1, a)) != MP_OKAY) {
5770 if ((err = mp_sub_d (&n1, 1, &n1)) != MP_OKAY) {
5775 if ((err = mp_init_copy (&r, &n1)) != MP_OKAY) {
5785 if ((err = mp_div_2d (&r, s, &r, NULL)) != MP_OKAY) {
5790 if ((err = mp_init (&y)) != MP_OKAY) {
5793 if ((err = mp_exptmod (b, &r, a, &y)) != MP_OKAY) {
5802 if ((err = mp_sqrmod (&y, a, &y)) != MP_OKAY) {
5889 return MP_OKAY;
5895 return MP_OKAY;
5902 return MP_OKAY;
5919 if ((err = mp_sub_d(a, (a->dp[0] & 3) + 1, a)) != MP_OKAY) { return err; };
5924 if ((err = mp_sub_d(a, 1, a)) != MP_OKAY) {
5932 if ((err = mp_mod_d(a, ltm_prime_tab[x], res_tab + x)) != MP_OKAY) {
5938 if ((err = mp_init(&b)) != MP_OKAY) {
5970 if ((err = mp_add_d(a, step, a)) != MP_OKAY) {
5982 if ((err = mp_prime_miller_rabin(a, &b, &res)) != MP_OKAY) {
5995 err = MP_OKAY;
6155 if ((err = mp_read_unsigned_bin(a, tmp, bsize)) != MP_OKAY) { goto error; }
6158 if ((err = mp_prime_is_prime(a, t, &res)) != MP_OKAY) { goto error; }
6165 if ((err = mp_sub_d(a, 1, a)) != MP_OKAY) { goto error; }
6166 if ((err = mp_div_2(a, a)) != MP_OKAY) { goto error; }
6169 if ((err = mp_prime_is_prime(a, t, &res)) != MP_OKAY) { goto error; }
6175 if ((err = mp_mul_2(a, a)) != MP_OKAY) { goto error; }
6176 if ((err = mp_add_d(a, 1, a)) != MP_OKAY) { goto error; }
6179 err = MP_OKAY;
6224 return MP_OKAY;
6234 return MP_OKAY;
6246 if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
6255 if ((res = mp_div_d (&t, (mp_digit) radix, &t, &d)) != MP_OKAY) {
6265 return MP_OKAY;
6331 return MP_OKAY;
6339 if ((res = mp_add_d (a, d, a)) != MP_OKAY) {
6344 if ((res = mp_lshd (a, 1)) != MP_OKAY) {
6348 if ((res = mp_add_d (a, ((mp_digit) abs (rand ())), a)) != MP_OKAY) {
6353 return MP_OKAY;
6426 if ((res = mp_mul_d (a, (mp_digit) radix, a)) != MP_OKAY) {
6429 if ((res = mp_add_d (a, (mp_digit) y, a)) != MP_OKAY) {
6442 return MP_OKAY;
6476 if ((res = mp_read_unsigned_bin (a, b + 1, c - 1)) != MP_OKAY) {
6487 return MP_OKAY;
6522 if ((res = mp_grow(a, 2)) != MP_OKAY) {
6532 if ((res = mp_mul_2d (a, 8, a)) != MP_OKAY) {
6546 return MP_OKAY;
6584 if ((res = mp_init_copy (&q, x)) != MP_OKAY) {
6593 if ((res = mp_mul (&q, mu, &q)) != MP_OKAY) {
6598 if ((res = s_mp_mul_high_digs (&q, mu, &q, um)) != MP_OKAY) {
6602 if ((res = fast_s_mp_mul_high_digs (&q, mu, &q, um)) != MP_OKAY) {
6617 if ((res = mp_mod_2d (x, DIGIT_BIT * (um + 1), x)) != MP_OKAY) {
6622 if ((res = s_mp_mul_digs (&q, m, &q, um + 1)) != MP_OKAY) {
6627 if ((res = mp_sub (x, &q, x)) != MP_OKAY) {
6634 if ((res = mp_lshd (&q, um + 1)) != MP_OKAY)
6636 if ((res = mp_add (x, &q, x)) != MP_OKAY)
6642 if ((res = s_mp_sub (x, m, x)) != MP_OKAY) {
6684 if ((res = mp_init(&q)) != MP_OKAY) {
6691 if ((res = mp_div_2d(a, p, &q, a)) != MP_OKAY) {
6697 if ((res = mp_mul_d(&q, d, &q)) != MP_OKAY) {
6703 if ((res = s_mp_add(a, &q, a)) != MP_OKAY) {
6752 if ((res = mp_init(&q)) != MP_OKAY) {
6759 if ((res = mp_div_2d(a, p, &q, a)) != MP_OKAY) {
6764 if ((res = mp_mul(&q, d, &q)) != MP_OKAY) {
6769 if ((res = s_mp_add(a, &q, a)) != MP_OKAY) {
6815 if ((res = mp_init(&tmp)) != MP_OKAY) {
6820 if ((res = mp_2expt(&tmp, p)) != MP_OKAY) {
6825 if ((res = s_mp_sub(&tmp, a, &tmp)) != MP_OKAY) {
6832 return MP_OKAY;
6866 if ((res = mp_init(&tmp)) != MP_OKAY) {
6870 if ((res = mp_2expt(&tmp, mp_count_bits(a))) != MP_OKAY) {
6874 if ((res = s_mp_sub(&tmp, a, d)) != MP_OKAY) {
7019 if ((res = mp_2expt (a, b->used * 2 * DIGIT_BIT)) != MP_OKAY) {
7169 if ((res = mp_mul_2d (a, 4, a)) != MP_OKAY) {
7183 return MP_OKAY;
7222 return MP_OKAY;
7350 if ((res = mp_init (&t)) != MP_OKAY) {
7354 if ((res = mp_sqr (a, &t)) != MP_OKAY) {
7402 return MP_OKAY;
7405 if ((res = mp_init_copy(&t1, arg)) != MP_OKAY) {
7409 if ((res = mp_init(&t2)) != MP_OKAY) {
7417 if ((res = mp_div(arg,&t1,&t2,NULL)) != MP_OKAY) {
7420 if ((res = mp_add(&t1,&t2,&t1)) != MP_OKAY) {
7423 if ((res = mp_div_2(&t1,&t1)) != MP_OKAY) {
7428 if ((res = mp_div(arg,&t1,&t2,NULL)) != MP_OKAY) {
7431 if ((res = mp_add(&t1,&t2,&t1)) != MP_OKAY) {
7434 if ((res = mp_div_2(&t1,&t1)) != MP_OKAY) {
7545 if ((res = mp_grow(c, a->used + 1)) != MP_OKAY) {
7604 return MP_OKAY;
7641 if ((res = mp_init (&t)) != MP_OKAY) {
7645 if ((res = mp_sub (a, b, &t)) != MP_OKAY) {
7684 if ((res = mp_to_unsigned_bin (a, b + 1)) != MP_OKAY) {
7688 return MP_OKAY;
7757 if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
7768 if ((res = mp_div_2d (&t, 8, &t, NULL)) != MP_OKAY) {
7775 return MP_OKAY;
7853 &b2, &tmp1, &tmp2, NULL)) != MP_OKAY) {
7861 MP_OKAY) {
7865 if ((res = mp_copy(a, &a1)) != MP_OKAY) {
7871 if ((res = mp_copy(a, &a2)) != MP_OKAY) {
7877 if ((res = mp_mod_2d(b, DIGIT_BIT * B, &b0)) != MP_OKAY) {
7881 if ((res = mp_copy(b, &b1)) != MP_OKAY) {
7887 if ((res = mp_copy(b, &b2)) != MP_OKAY) {
7893 if ((res = mp_mul(&a0, &b0, &w0)) != MP_OKAY) {
7898 if ((res = mp_mul(&a2, &b2, &w4)) != MP_OKAY) {
7903 if ((res = mp_mul_2(&a0, &tmp1)) != MP_OKAY) {
7906 if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) {
7909 if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) {
7912 if ((res = mp_add(&tmp1, &a2, &tmp1)) != MP_OKAY) {
7916 if ((res = mp_mul_2(&b0, &tmp2)) != MP_OKAY) {
7919 if ((res = mp_add(&tmp2, &b1, &tmp2)) != MP_OKAY) {
7922 if ((res = mp_mul_2(&tmp2, &tmp2)) != MP_OKAY) {
7925 if ((res = mp_add(&tmp2, &b2, &tmp2)) != MP_OKAY) {
7929 if ((res = mp_mul(&tmp1, &tmp2, &w1)) != MP_OKAY) {
7934 if ((res = mp_mul_2(&a2, &tmp1)) != MP_OKAY) {
7937 if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) {
7940 if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) {
7943 if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) {
7947 if ((res = mp_mul_2(&b2, &tmp2)) != MP_OKAY) {
7950 if ((res = mp_add(&tmp2, &b1, &tmp2)) != MP_OKAY) {
7953 if ((res = mp_mul_2(&tmp2, &tmp2)) != MP_OKAY) {
7956 if ((res = mp_add(&tmp2, &b0, &tmp2)) != MP_OKAY) {
7960 if ((res = mp_mul(&tmp1, &tmp2, &w3)) != MP_OKAY) {
7966 if ((res = mp_add(&a2, &a1, &tmp1)) != MP_OKAY) {
7969 if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) {
7972 if ((res = mp_add(&b2, &b1, &tmp2)) != MP_OKAY) {
7975 if ((res = mp_add(&tmp2, &b0, &tmp2)) != MP_OKAY) {
7978 if ((res = mp_mul(&tmp1, &tmp2, &w2)) != MP_OKAY) {
7995 if ((res = mp_sub(&w1, &w4, &w1)) != MP_OKAY) {
7999 if ((res = mp_sub(&w3, &w0, &w3)) != MP_OKAY) {
8003 if ((res = mp_div_2(&w1, &w1)) != MP_OKAY) {
8007 if ((res = mp_div_2(&w3, &w3)) != MP_OKAY) {
8011 if ((res = mp_sub(&w2, &w0, &w2)) != MP_OKAY) {
8014 if ((res = mp_sub(&w2, &w4, &w2)) != MP_OKAY) {
8018 if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
8022 if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
8026 if ((res = mp_mul_2d(&w0, 3, &tmp1)) != MP_OKAY) {
8029 if ((res = mp_sub(&w1, &tmp1, &w1)) != MP_OKAY) {
8033 if ((res = mp_mul_2d(&w4, 3, &tmp1)) != MP_OKAY) {
8036 if ((res = mp_sub(&w3, &tmp1, &w3)) != MP_OKAY) {
8040 if ((res = mp_mul_d(&w2, 3, &w2)) != MP_OKAY) {
8043 if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) {
8046 if ((res = mp_sub(&w2, &w3, &w2)) != MP_OKAY) {
8050 if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
8054 if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
8058 if ((res = mp_div_3(&w1, &w1, NULL)) != MP_OKAY) {
8062 if ((res = mp_div_3(&w3, &w3, NULL)) != MP_OKAY) {
8067 if ((res = mp_lshd(&w1, 1*B)) != MP_OKAY) {
8070 if ((res = mp_lshd(&w2, 2*B)) != MP_OKAY) {
8073 if ((res = mp_lshd(&w3, 3*B)) != MP_OKAY) {
8076 if ((res = mp_lshd(&w4, 4*B)) != MP_OKAY) {
8080 if ((res = mp_add(&w0, &w1, c)) != MP_OKAY) {
8083 if ((res = mp_add(&w2, &w3, &tmp1)) != MP_OKAY) {
8086 if ((res = mp_add(&w4, &tmp1, &tmp1)) != MP_OKAY) {
8089 if ((res = mp_add(&tmp1, c, c)) != MP_OKAY) {
8134 if ((res = mp_init_multi(&w0, &w1, &w2, &w3, &w4, &a0, &a1, &a2, &tmp1, NULL)) != MP_OKAY) {
8142 if ((res = mp_mod_2d(a, DIGIT_BIT * B, &a0)) != MP_OKAY) {
8146 if ((res = mp_copy(a, &a1)) != MP_OKAY) {
8152 if ((res = mp_copy(a, &a2)) != MP_OKAY) {
8158 if ((res = mp_sqr(&a0, &w0)) != MP_OKAY) {
8163 if ((res = mp_sqr(&a2, &w4)) != MP_OKAY) {
8168 if ((res = mp_mul_2(&a0, &tmp1)) != MP_OKAY) {
8171 if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) {
8174 if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) {
8177 if ((res = mp_add(&tmp1, &a2, &tmp1)) != MP_OKAY) {
8181 if ((res = mp_sqr(&tmp1, &w1)) != MP_OKAY) {
8186 if ((res = mp_mul_2(&a2, &tmp1)) != MP_OKAY) {
8189 if ((res = mp_add(&tmp1, &a1, &tmp1)) != MP_OKAY) {
8192 if ((res = mp_mul_2(&tmp1, &tmp1)) != MP_OKAY) {
8195 if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) {
8199 if ((res = mp_sqr(&tmp1, &w3)) != MP_OKAY) {
8205 if ((res = mp_add(&a2, &a1, &tmp1)) != MP_OKAY) {
8208 if ((res = mp_add(&tmp1, &a0, &tmp1)) != MP_OKAY) {
8211 if ((res = mp_sqr(&tmp1, &w2)) != MP_OKAY) {
8227 if ((res = mp_sub(&w1, &w4, &w1)) != MP_OKAY) {
8231 if ((res = mp_sub(&w3, &w0, &w3)) != MP_OKAY) {
8235 if ((res = mp_div_2(&w1, &w1)) != MP_OKAY) {
8239 if ((res = mp_div_2(&w3, &w3)) != MP_OKAY) {
8243 if ((res = mp_sub(&w2, &w0, &w2)) != MP_OKAY) {
8246 if ((res = mp_sub(&w2, &w4, &w2)) != MP_OKAY) {
8250 if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
8254 if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
8258 if ((res = mp_mul_2d(&w0, 3, &tmp1)) != MP_OKAY) {
8261 if ((res = mp_sub(&w1, &tmp1, &w1)) != MP_OKAY) {
8265 if ((res = mp_mul_2d(&w4, 3, &tmp1)) != MP_OKAY) {
8268 if ((res = mp_sub(&w3, &tmp1, &w3)) != MP_OKAY) {
8272 if ((res = mp_mul_d(&w2, 3, &w2)) != MP_OKAY) {
8275 if ((res = mp_sub(&w2, &w1, &w2)) != MP_OKAY) {
8278 if ((res = mp_sub(&w2, &w3, &w2)) != MP_OKAY) {
8282 if ((res = mp_sub(&w1, &w2, &w1)) != MP_OKAY) {
8286 if ((res = mp_sub(&w3, &w2, &w3)) != MP_OKAY) {
8290 if ((res = mp_div_3(&w1, &w1, NULL)) != MP_OKAY) {
8294 if ((res = mp_div_3(&w3, &w3, NULL)) != MP_OKAY) {
8299 if ((res = mp_lshd(&w1, 1*B)) != MP_OKAY) {
8302 if ((res = mp_lshd(&w2, 2*B)) != MP_OKAY) {
8305 if ((res = mp_lshd(&w3, 3*B)) != MP_OKAY) {
8308 if ((res = mp_lshd(&w4, 4*B)) != MP_OKAY) {
8312 if ((res = mp_add(&w0, &w1, b)) != MP_OKAY) {
8315 if ((res = mp_add(&w2, &w3, &tmp1)) != MP_OKAY) {
8318 if ((res = mp_add(&w4, &tmp1, &tmp1)) != MP_OKAY) {
8321 if ((res = mp_add(&tmp1, b, b)) != MP_OKAY) {
8373 return MP_OKAY;
8376 if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
8389 if ((res = mp_div_d (&t, (mp_digit) radix, &t, &d)) != MP_OKAY) {
8406 return MP_OKAY;
8455 return MP_OKAY;
8458 if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
8481 if ((res = mp_div_d (&t, (mp_digit) radix, &t, &d)) != MP_OKAY) {
8498 return MP_OKAY;
8567 if ((res = mp_init_copy (&t, a)) != MP_OKAY) {
8573 if ((res = mp_init_copy (&t, b)) != MP_OKAY) {
8586 return MP_OKAY;
8784 if ((res = mp_grow (c, max + 1)) != MP_OKAY) {
8847 return MP_OKAY;
8913 if ((err = mp_init(&M[1])) != MP_OKAY) {
8919 if ((err = mp_init(&M[x])) != MP_OKAY) {
8929 if ((err = mp_init (&mu)) != MP_OKAY) {
8934 if ((err = mp_reduce_setup (&mu, P)) != MP_OKAY) {
8939 if ((err = mp_reduce_2k_setup_l (P, &mu)) != MP_OKAY) {
8953 if ((err = mp_mod (G, P, &M[1])) != MP_OKAY) {
8960 if ((err = mp_copy (&M[1], &M[1 << (winsize - 1)])) != MP_OKAY) {
8967 &M[1 << (winsize - 1)])) != MP_OKAY) {
8972 if ((err = redux (&M[1 << (winsize - 1)], P, &mu)) != MP_OKAY) {
8981 if ((err = mp_mul (&M[x - 1], &M[1], &M[x])) != MP_OKAY) {
8984 if ((err = redux (&M[x], P, &mu)) != MP_OKAY) {
8990 if ((err = mp_init (&res)) != MP_OKAY) {
9030 if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
9033 if ((err = redux (&res, P, &mu)) != MP_OKAY) {
9047 if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
9050 if ((err = redux (&res, P, &mu)) != MP_OKAY) {
9056 if ((err = mp_mul (&res, &M[bitbuf], &res)) != MP_OKAY) {
9059 if ((err = redux (&res, P, &mu)) != MP_OKAY) {
9074 if ((err = mp_sqr (&res, &res)) != MP_OKAY) {
9077 if ((err = redux (&res, P, &mu)) != MP_OKAY) {
9084 if ((err = mp_mul (&res, &M[1], &res)) != MP_OKAY) {
9087 if ((err = redux (&res, P, &mu)) != MP_OKAY) {
9095 err = MP_OKAY;
9150 if ((res = mp_init_size (&t, digs)) != MP_OKAY) {
9197 return MP_OKAY;
9245 if ((res = mp_init_size (&t, a->used + b->used + 1)) != MP_OKAY) {
9282 return MP_OKAY;
9319 if ((res = mp_init_size (&t, 2*pa + 1)) != MP_OKAY) {
9370 return MP_OKAY;
9410 if ((res = mp_grow (c, max)) != MP_OKAY) {
9462 return MP_OKAY;