diff --git a/demo/demo.c b/demo/demo.c index 9710151..357d26e 100644 --- a/demo/demo.c +++ b/demo/demo.c @@ -57,15 +57,15 @@ static int myrng(unsigned char *dst, int len, void *dat) fprintf(stderr, "\nno /dev/urandom\n"); # endif } else { - return fread(dst, 1, len, fd_urandom); + return fread(dst, 1uL, len, fd_urandom); } #endif for (x = 0; x < len;) { unsigned int r = (unsigned int)rand(); do { - dst[x++] = r & 0xFF; + dst[x++] = r & 0xFFu; r >>= 8; - } while ((r != 0) && (x < len)); + } while ((r != 0u) && (x < len)); } return len; } @@ -195,7 +195,7 @@ int main(void) return EXIT_FAILURE; } // a: -5-> b: -4 - mp_add_d(&a, 1, &b); + mp_add_d(&a, 1uL, &b); if (mp_isneg(&b) != MP_YES) { return EXIT_FAILURE; } @@ -203,18 +203,18 @@ int main(void) return EXIT_FAILURE; } // a: -5-> b: 1 - mp_add_d(&a, 6, &b); + mp_add_d(&a, 6uL, &b); if (mp_get_int(&b) != 1) { return EXIT_FAILURE; } // a: -5-> a: 1 - mp_add_d(&a, 6, &a); + mp_add_d(&a, 6uL, &a); if (mp_get_int(&a) != 1) { return EXIT_FAILURE; } mp_zero(&a); // a: 0-> a: 6 - mp_add_d(&a, 6, &a); + mp_add_d(&a, 6uL, &a); if (mp_get_int(&a) != 6) { return EXIT_FAILURE; } @@ -264,7 +264,7 @@ int main(void) // test mp_get_int printf("\n\nTesting: mp_get_int"); for (i = 0; i < 1000; ++i) { - t = ((unsigned long) rand() * rand() + 1) & 0xFFFFFFFF; + t = ((unsigned long) rand() * rand() + 1) & 0xFFFFFFFFuL; mp_set_int(&a, t); if (t != mp_get_int(&a)) { printf("\nmp_get_int() bad result!"); @@ -276,8 +276,8 @@ int main(void) printf("\nmp_get_int() bad result!"); return EXIT_FAILURE; } - mp_set_int(&a, 0xffffffff); - if (mp_get_int(&a) != 0xffffffff) { + mp_set_int(&a, 0xFFFFFFFFuL); + if (mp_get_int(&a) != 0xFFFFFFFFuL) { printf("\nmp_get_int() bad result!"); return EXIT_FAILURE; } @@ -364,7 +364,7 @@ int main(void) } /* test for false positives */ - mp_add_d(&a, 1, &a); + mp_add_d(&a, 1uL, &a); if (mp_is_square(&a, &n) != MP_OKAY) { printf("\nfp:mp_is_square() error!"); return EXIT_FAILURE; @@ -425,7 +425,7 @@ int main(void) return EXIT_FAILURE; } /* let's see if it's really a safe prime */ - mp_sub_d(&a, 1, &a); + mp_sub_d(&a, 1uL, &a); mp_div_2(&a, &a); mp_prime_is_prime(&a, 8, &cnt); if (cnt != MP_YES) { @@ -503,7 +503,7 @@ printf("compare no compare!\n"); return EXIT_FAILURE; /* test mp_cnt_lsb */ printf("\n\nTesting: mp_cnt_lsb"); - mp_set(&a, 1); + mp_set(&a, 1uL); for (ix = 0; ix < 1024; ix++) { if (mp_cnt_lsb(&a) != ix) { printf("Failed at %d, %d\n", ix, mp_cnt_lsb(&a)); @@ -518,7 +518,7 @@ printf("compare no compare!\n"); return EXIT_FAILURE; mp_digit tmp; mp_2expt(&a, cnt); - mp_sub_d(&a, 2, &a); /* a = 2**cnt - 2 */ + mp_sub_d(&a, 2uL, &a); /* a = 2**cnt - 2 */ printf("\r %4d bits", cnt); printf("(%d)", mp_reduce_is_2k(&a)); @@ -532,7 +532,7 @@ printf("compare no compare!\n"); return EXIT_FAILURE; mp_rand(&b, (cnt / DIGIT_BIT + 1) * 2); mp_copy(&c, &b); mp_mod(&c, &a, &c); - mp_reduce_2k(&b, &a, 2); + mp_reduce_2k(&b, &a, 2uL); if (mp_cmp(&c, &b)) { printf("FAILED\n"); return EXIT_FAILURE; @@ -542,7 +542,7 @@ printf("compare no compare!\n"); return EXIT_FAILURE; /* test mp_div_3 */ printf("\n\nTesting: mp_div_3...\n"); - mp_set(&d, 3); + mp_set(&d, 3uL); for (cnt = 0; cnt < 10000;) { mp_digit r2; @@ -582,7 +582,7 @@ printf("compare no compare!\n"); return EXIT_FAILURE; fflush(stdout); } mp_sqr(&b, &b); - mp_add_d(&b, 1, &b); + mp_add_d(&b, 1uL, &b); mp_copy(&b, &c); mp_mod(&b, &a, &b); @@ -632,10 +632,10 @@ printf("compare no compare!\n"); return EXIT_FAILURE; fflush(stdout); for (cnt = 0; cnt < (int)(1UL << 20); cnt++) { mp_sqr(&b, &b); - mp_add_d(&b, 1, &b); + mp_add_d(&b, 1uL, &b); mp_reduce_2k_l(&b, &a, &d); mp_sqr(&c, &c); - mp_add_d(&c, 1, &c); + mp_add_d(&c, 1uL, &c); mp_mod(&c, &a, &c); if (mp_cmp(&b, &c) != MP_EQ) { printf("mp_reduce_2k_l() failed at step %d\n", cnt); @@ -693,7 +693,7 @@ printf("compare no compare!\n"); return EXIT_FAILURE; add_n, sub_n, mul_n, div_n, sqr_n, mul2d_n, div2d_n, gcd_n, lcm_n, expt_n, inv_n, div2_n, mul2_n, add_d_n, sub_d_n); FGETS(cmd, 4095, stdin); - cmd[strlen(cmd) - 1] = 0; + cmd[strlen(cmd) - 1u] = '\0'; printf("%-6s ]\r", cmd); fflush(stdout); if (strcmp(cmd, "mul2d") == 0) { @@ -756,7 +756,7 @@ printf("compare no compare!\n"); return EXIT_FAILURE; rr = mp_signed_bin_size(&c); mp_to_signed_bin(&c, (unsigned char *) cmd); - memset(cmd + rr, rand() & 255, sizeof(cmd) - rr); + memset(cmd + rr, rand() & 0xFFu, sizeof(cmd) - rr); mp_read_signed_bin(&d, (unsigned char *) cmd, rr); if (mp_cmp(&c, &d) != MP_EQ) { printf("mp_signed_bin failure!\n"); @@ -768,7 +768,7 @@ printf("compare no compare!\n"); return EXIT_FAILURE; rr = mp_unsigned_bin_size(&c); mp_to_unsigned_bin(&c, (unsigned char *) cmd); - memset(cmd + rr, rand() & 255, sizeof(cmd) - rr); + memset(cmd + rr, rand() & 0xFFu, sizeof(cmd) - rr); mp_read_unsigned_bin(&d, (unsigned char *) cmd, rr); if (mp_cmp_mag(&c, &d) != MP_EQ) { printf("mp_unsigned_bin failure!\n"); @@ -921,7 +921,7 @@ printf("compare no compare!\n"); return EXIT_FAILURE; mp_read_radix(&c, buf, 64); mp_invmod(&a, &b, &d); mp_mulmod(&d, &a, &b, &e); - if (mp_cmp_d(&e, 1) != MP_EQ) { + if (mp_cmp_d(&e, 1uL) != MP_EQ) { printf("inv [wrong value from MPI?!] failure\n"); draw(&a); draw(&b); diff --git a/demo/timing.c b/demo/timing.c index de58278..2b4f30f 100644 --- a/demo/timing.c +++ b/demo/timing.c @@ -32,12 +32,12 @@ static void draw(mp_int *a) } -static unsigned long lfsr = 0xAAAAAAAAUL; +static unsigned long lfsr = 0xAAAAAAAAuL; static int lbit(void) { - if ((lfsr & 0x80000000UL) != 0UL) { - lfsr = ((lfsr << 1) ^ 0x8000001BUL) & 0xFFFFFFFFUL; + if ((lfsr & 0x80000000uL) != 0uL) { + lfsr = ((lfsr << 1) ^ 0x8000001BuL) & 0xFFFFFFFFuL; return 1; } else { lfsr <<= 1; @@ -126,15 +126,15 @@ int main(void) SLEEP; mp_rand(&a, cnt); mp_rand(&b, cnt); - rr = 0; - tt = -1; + rr = 0u; + tt = UINT64_MAX; do { gg = TIMFUNC(); DO(mp_add(&a, &b, &c)); gg = (TIMFUNC() - gg) >> 1; if (tt > gg) tt = gg; - } while (++rr < 100000); + } while (++rr < 100000u); printf("Adding\t\t%4d-bit => %9" PRIu64 "/sec, %9" PRIu64 " cycles\n", mp_count_bits(&a), CLK_PER_SEC / tt, tt); FPRINTF(log, "%d %9" PRIu64 "\n", cnt * DIGIT_BIT, tt); @@ -147,15 +147,15 @@ int main(void) SLEEP; mp_rand(&a, cnt); mp_rand(&b, cnt); - rr = 0; - tt = -1; + rr = 0u; + tt = UINT64_MAX; do { gg = TIMFUNC(); DO(mp_sub(&a, &b, &c)); gg = (TIMFUNC() - gg) >> 1; if (tt > gg) tt = gg; - } while (++rr < 100000); + } while (++rr < 100000u); printf("Subtracting\t\t%4d-bit => %9" PRIu64 "/sec, %9" PRIu64 " cycles\n", mp_count_bits(&a), CLK_PER_SEC / tt, tt); @@ -183,15 +183,15 @@ int main(void) SLEEP; mp_rand(&a, cnt); mp_rand(&b, cnt); - rr = 0; - tt = -1; + rr = 0u; + tt = UINT64_MAX; do { gg = TIMFUNC(); DO(mp_mul(&a, &b, &c)); gg = (TIMFUNC() - gg) >> 1; if (tt > gg) tt = gg; - } while (++rr < 100); + } while (++rr < 100u); printf("Multiplying\t%4d-bit => %9" PRIu64 "/sec, %9" PRIu64 " cycles\n", mp_count_bits(&a), CLK_PER_SEC / tt, tt); FPRINTF(log, "%d %9" PRIu64 "\n", mp_count_bits(&a), tt); @@ -203,15 +203,15 @@ int main(void) for (cnt = 4; cnt <= (10240 / DIGIT_BIT); cnt += 2) { SLEEP; mp_rand(&a, cnt); - rr = 0; - tt = -1; + rr = 0u; + tt = UINT64_MAX; do { gg = TIMFUNC(); DO(mp_sqr(&a, &b)); gg = (TIMFUNC() - gg) >> 1; if (tt > gg) tt = gg; - } while (++rr < 100); + } while (++rr < 100u); printf("Squaring\t%4d-bit => %9" PRIu64 "/sec, %9" PRIu64 " cycles\n", mp_count_bits(&a), CLK_PER_SEC / tt, tt); FPRINTF(log, "%d %9" PRIu64 "\n", mp_count_bits(&a), tt); @@ -267,23 +267,23 @@ int main(void) b.dp[0] |= lbit(); b.used += 1; } - mp_sub_d(&a, 1, &c); + mp_sub_d(&a, 1uL, &c); mp_mod(&b, &c, &b); - mp_set(&c, 3); - rr = 0; - tt = -1; + mp_set(&c, 3uL); + rr = 0u; + tt = UINT64_MAX; do { gg = TIMFUNC(); DO(mp_exptmod(&c, &b, &a, &d)); gg = (TIMFUNC() - gg) >> 1; if (tt > gg) tt = gg; - } while (++rr < 10); - mp_sub_d(&a, 1, &e); + } while (++rr < 10u); + mp_sub_d(&a, 1uL, &e); mp_sub(&e, &b, &b); mp_exptmod(&c, &b, &a, &e); /* c^(p-1-b) mod a */ mp_mulmod(&e, &d, &a, &d); /* c^b * c^(p-1-b) == c^p-1 == 1 */ - if (mp_cmp_d(&d, 1) != MP_EQ) { + if (mp_cmp_d(&d, 1uL) != MP_EQ) { printf("Different (%d)!!!\n", mp_count_bits(&a)); draw(&d); exit(0); @@ -306,21 +306,21 @@ int main(void) mp_rand(&b, cnt); do { - mp_add_d(&b, 1, &b); + mp_add_d(&b, 1uL, &b); mp_gcd(&a, &b, &c); - } while (mp_cmp_d(&c, 1) != MP_EQ); + } while (mp_cmp_d(&c, 1uL) != MP_EQ); - rr = 0; - tt = -1; + rr = 0u; + tt = UINT64_MAX; do { gg = TIMFUNC(); DO(mp_invmod(&b, &a, &c)); gg = (TIMFUNC() - gg) >> 1; if (tt > gg) tt = gg; - } while (++rr < 1000); + } while (++rr < 1000u); mp_mulmod(&b, &c, &a, &d); - if (mp_cmp_d(&d, 1) != MP_EQ) { + if (mp_cmp_d(&d, 1uL) != MP_EQ) { printf("Failed to invert\n"); return 0; } diff --git a/etc/2kprime.c b/etc/2kprime.c index f8761fb..803ece7 100644 --- a/etc/2kprime.c +++ b/etc/2kprime.c @@ -20,13 +20,13 @@ int main(void) for (x = 0; x < (int)(sizeof(sizes) / sizeof(sizes[0])); x++) { top: mp_2expt(&q, sizes[x]); - mp_add_d(&q, 3, &q); + mp_add_d(&q, 3uL, &q); z = -3; t1 = clock(); for (;;) { - mp_sub_d(&q, 4, &q); - z += 4; + mp_sub_d(&q, 4uL, &q); + z += 4uL; if (z > MP_MASK) { printf("No primes of size %d found\n", sizes[x]); @@ -47,7 +47,7 @@ top: } /* find (q-1)/2 */ - mp_sub_d(&q, 1, &p); + mp_sub_d(&q, 1uL, &p); mp_div_2(&p, &p); mp_prime_is_prime(&p, 3, &y); if (y == 0) { diff --git a/etc/drprime.c b/etc/drprime.c index 42504b9..dd1d9d6 100644 --- a/etc/drprime.c +++ b/etc/drprime.c @@ -31,13 +31,13 @@ top: /* now loop */ res = 0; for (;;) { - a.dp[0] += 4; + a.dp[0] += 4uL; if (a.dp[0] >= MP_MASK) break; mp_prime_is_prime(&a, 1, &res); if (res == 0) continue; printf("."); fflush(stdout); - mp_sub_d(&a, 1, &b); + mp_sub_d(&a, 1uL, &b); mp_div_2(&b, &b); mp_prime_is_prime(&b, 3, &res); if (res == 0) continue; diff --git a/etc/mersenne.c b/etc/mersenne.c index c5b1d6e..6e4759b 100644 --- a/etc/mersenne.c +++ b/etc/mersenne.c @@ -24,12 +24,12 @@ static int is_mersenne(long s, int *pp) if ((res = mp_2expt(&n, s)) != MP_OKAY) { goto LBL_MU; } - if ((res = mp_sub_d(&n, 1, &n)) != MP_OKAY) { + if ((res = mp_sub_d(&n, 1uL, &n)) != MP_OKAY) { goto LBL_MU; } /* set u=4 */ - mp_set(&u, 4); + mp_set(&u, 4uL); /* for k=1 to s-2 do */ for (k = 1; k <= (s - 2); k++) { @@ -37,7 +37,7 @@ static int is_mersenne(long s, int *pp) if ((res = mp_sqr(&u, &u)) != MP_OKAY) { goto LBL_MU; } - if ((res = mp_sub_d(&u, 2, &u)) != MP_OKAY) { + if ((res = mp_sub_d(&u, 2uL, &u)) != MP_OKAY) { goto LBL_MU; } @@ -49,7 +49,7 @@ static int is_mersenne(long s, int *pp) } /* reduce */ - if ((res = mp_reduce_2k(&u, &n, 1)) != MP_OKAY) { + if ((res = mp_reduce_2k(&u, &n, 1uL)) != MP_OKAY) { goto LBL_MU; } } diff --git a/etc/mont.c b/etc/mont.c index 368b1ca..97b36e1 100644 --- a/etc/mont.c +++ b/etc/mont.c @@ -18,7 +18,7 @@ int main(void) /* make up the odd modulus */ mp_rand(&modulus, x); - modulus.dp[0] |= 1; + modulus.dp[0] |= 1uL; /* now find the R value */ mp_montgomery_calc_normalization(&R, &modulus); diff --git a/etc/pprime.c b/etc/pprime.c index 50ee219..213f3c5 100644 --- a/etc/pprime.c +++ b/etc/pprime.c @@ -18,7 +18,7 @@ static mp_digit i_sqrt(mp_word x) x2 = x; do { x1 = x2; - x2 = x1 - ((x1 * x1) - x) / (2 * x1); + x2 = x1 - ((x1 * x1) - x) / (2u * x1); } while (x1 != x2); if ((x1 * x1) > x) { @@ -40,114 +40,114 @@ static void gen_prime(void) /* write first set of primes */ /* *INDENT-OFF* */ - r = 3; fwrite(&r, 1, sizeof(mp_digit), out); - r = 5; fwrite(&r, 1, sizeof(mp_digit), out); - r = 7; fwrite(&r, 1, sizeof(mp_digit), out); - r = 11; fwrite(&r, 1, sizeof(mp_digit), out); - r = 13; fwrite(&r, 1, sizeof(mp_digit), out); - r = 17; fwrite(&r, 1, sizeof(mp_digit), out); - r = 19; fwrite(&r, 1, sizeof(mp_digit), out); - r = 23; fwrite(&r, 1, sizeof(mp_digit), out); - r = 29; fwrite(&r, 1, sizeof(mp_digit), out); - r = 31; fwrite(&r, 1, sizeof(mp_digit), out); + r = 3uL; fwrite(&r, 1uL, sizeof(mp_digit), out); + r = 5uL; fwrite(&r, 1uL, sizeof(mp_digit), out); + r = 7uL; fwrite(&r, 1uL, sizeof(mp_digit), out); + r = 11uL; fwrite(&r, 1uL, sizeof(mp_digit), out); + r = 13uL; fwrite(&r, 1uL, sizeof(mp_digit), out); + r = 17uL; fwrite(&r, 1uL, sizeof(mp_digit), out); + r = 19uL; fwrite(&r, 1uL, sizeof(mp_digit), out); + r = 23uL; fwrite(&r, 1uL, sizeof(mp_digit), out); + r = 29uL; fwrite(&r, 1uL, sizeof(mp_digit), out); + r = 31uL; fwrite(&r, 1uL, sizeof(mp_digit), out); /* *INDENT-ON* */ /* get square root, since if 'r' is composite its factors must be < than this */ y = i_sqrt(r); - next = (y + 1) * (y + 1); + next = (y + 1uL) * (y + 1uL); for (;;) { do { - r += 2; /* next candidate */ + r += 2uL; /* next candidate */ r &= MP_MASK; - if (r < 31) break; + if (r < 31uL) break; /* update sqrt ? */ if (next <= r) { ++y; - next = (y + 1) * (y + 1); + next = (y + 1uL) * (y + 1uL); } /* loop if divisible by 3,5,7,11,13,17,19,23,29 */ - if ((r % 3) == 0) { - x = 0; + if ((r % 3uL) == 0uL) { + x = 0uL; continue; } - if ((r % 5) == 0) { - x = 0; + if ((r % 5uL) == 0uL) { + x = 0uL; continue; } - if ((r % 7) == 0) { - x = 0; + if ((r % 7uL) == 0uL) { + x = 0uL; continue; } - if ((r % 11) == 0) { - x = 0; + if ((r % 11uL) == 0uL) { + x = 0uL; continue; } - if ((r % 13) == 0) { - x = 0; + if ((r % 13uL) == 0uL) { + x = 0uL; continue; } - if ((r % 17) == 0) { - x = 0; + if ((r % 17uL) == 0uL) { + x = 0uL; continue; } - if ((r % 19) == 0) { - x = 0; + if ((r % 19uL) == 0uL) { + x = 0uL; continue; } - if ((r % 23) == 0) { - x = 0; + if ((r % 23uL) == 0uL) { + x = 0uL; continue; } - if ((r % 29) == 0) { - x = 0; + if ((r % 29uL) == 0uL) { + x = 0uL; continue; } /* now check if r is divisible by x + k={1,7,11,13,17,19,23,29} */ - for (x = 30; x <= y; x += 30) { - if ((r % (x + 1)) == 0) { - x = 0; + for (x = 30uL; x <= y; x += 30uL) { + if ((r % (x + 1uL)) == 0uL) { + x = 0uL; break; } - if ((r % (x + 7)) == 0) { - x = 0; + if ((r % (x + 7uL)) == 0uL) { + x = 0uL; break; } - if ((r % (x + 11)) == 0) { - x = 0; + if ((r % (x + 11uL)) == 0uL) { + x = 0uL; break; } - if ((r % (x + 13)) == 0) { - x = 0; + if ((r % (x + 13uL)) == 0uL) { + x = 0uL; break; } - if ((r % (x + 17)) == 0) { - x = 0; + if ((r % (x + 17uL)) == 0uL) { + x = 0uL; break; } - if ((r % (x + 19)) == 0) { - x = 0; + if ((r % (x + 19uL)) == 0uL) { + x = 0uL; break; } - if ((r % (x + 23)) == 0) { - x = 0; + if ((r % (x + 23uL)) == 0uL) { + x = 0uL; break; } - if ((r % (x + 29)) == 0) { - x = 0; + if ((r % (x + 29uL)) == 0uL) { + x = 0uL; break; } } - } while (x == 0); - if (r > 31) { - fwrite(&r, 1, sizeof(mp_digit), out); + } while (x == 0uL); + if (r > 31uL) { + fwrite(&r, 1uL, sizeof(mp_digit), out); printf("%9u\r", r); fflush(stdout); } - if (r < 31) break; + if (r < 31uL) break; } fclose(out); @@ -161,7 +161,7 @@ static void load_tab(void) gen_prime(); primes = fopen("pprime.dat", "rb"); } - fseek(primes, 0, SEEK_END); + fseek(primes, 0L, SEEK_END); n_prime = ftell(primes) / sizeof(mp_digit); } @@ -172,7 +172,7 @@ static mp_digit prime_digit(void) n = abs(rand()) % n_prime; fseek(primes, n * sizeof(mp_digit), SEEK_SET); - fread(&d, 1, sizeof(mp_digit), primes); + fread(&d, 1uL, sizeof(mp_digit), primes); return d; } @@ -254,7 +254,7 @@ top: } /* n = z + 1 */ - if ((res = mp_add_d(&z, 1, &n)) != MP_OKAY) { /* n = z + 1 */ + if ((res = mp_add_d(&z, 1uL, &n)) != MP_OKAY) { /* n = z + 1 */ goto LBL_Z; } @@ -263,7 +263,7 @@ top: goto LBL_Z; } - if (mp_cmp_d(&y, 1) != MP_EQ) + if (mp_cmp_d(&y, 1uL) != MP_EQ) goto top; /* now try base x=bases[ii] */ @@ -276,7 +276,7 @@ top: } /* if y == 1 loop */ - if (mp_cmp_d(&y, 1) == MP_EQ) + if (mp_cmp_d(&y, 1uL) == MP_EQ) continue; /* now x^2a mod n */ @@ -284,7 +284,7 @@ top: goto LBL_Z; } - if (mp_cmp_d(&y, 1) == MP_EQ) + if (mp_cmp_d(&y, 1uL) == MP_EQ) continue; /* compute x^b mod n */ @@ -293,7 +293,7 @@ top: } /* if y == 1 loop */ - if (mp_cmp_d(&y, 1) == MP_EQ) + if (mp_cmp_d(&y, 1uL) == MP_EQ) continue; /* now x^2b mod n */ @@ -301,7 +301,7 @@ top: goto LBL_Z; } - if (mp_cmp_d(&y, 1) == MP_EQ) + if (mp_cmp_d(&y, 1uL) == MP_EQ) continue; /* compute x^c mod n == x^ab mod n */ @@ -310,7 +310,7 @@ top: } /* if y == 1 loop */ - if (mp_cmp_d(&y, 1) == MP_EQ) + if (mp_cmp_d(&y, 1uL) == MP_EQ) continue; /* now compute (x^c mod n)^2 */ @@ -319,7 +319,7 @@ top: } /* y should be 1 */ - if (mp_cmp_d(&y, 1) != MP_EQ) + if (mp_cmp_d(&y, 1uL) != MP_EQ) continue; break; } @@ -345,7 +345,7 @@ top: } /* get q to be the order of the large prime subgroup */ - mp_sub_d(&n, 1, q); + mp_sub_d(&n, 1uL, q); mp_div_2(q, q); mp_div(q, &b, q, NULL);