Commit 0b5a9b2a authored by Niels Möller's avatar Niels Möller
Browse files

Use GMP's mpz_combit if available.

parent 9deeaa4f
2013-05-02 Niels Möller <nisse@lysator.liu.se> 2013-05-02 Niels Möller <nisse@lysator.liu.se>
* testsuite/testutils.c (mpz_combit): Renamed. Define only if not
provided GMP. Updated all uses.
(mpz_togglebit): ... old name.
* sexp-format.c (sexp_vformat): Use type mpz_srcptr rather * sexp-format.c (sexp_vformat): Use type mpz_srcptr rather
than the old MP_INT *. than the old MP_INT *.
......
...@@ -647,19 +647,19 @@ test_armor(const struct nettle_armor *armor, ...@@ -647,19 +647,19 @@ test_armor(const struct nettle_armor *armor,
free(decode); free(decode);
} }
#if HAVE_LIBGMP #if WITH_HOGWEED
/* Missing in current gmp */
#ifndef mpz_combit
/* Missing in older gmp */
static void static void
mpz_togglebit (mpz_t x, unsigned long int bit) mpz_combit (mpz_t x, unsigned long int bit)
{ {
if (mpz_tstbit(x, bit)) if (mpz_tstbit(x, bit))
mpz_clrbit(x, bit); mpz_clrbit(x, bit);
else else
mpz_setbit(x, bit); mpz_setbit(x, bit);
} }
#endif /* HAVE_LIBGMP */ #endif
#if WITH_HOGWEED
mp_limb_t * mp_limb_t *
xalloc_limbs (mp_size_t n) xalloc_limbs (mp_size_t n)
...@@ -799,7 +799,7 @@ test_rsa_md5(struct rsa_public_key *pub, ...@@ -799,7 +799,7 @@ test_rsa_md5(struct rsa_public_key *pub,
"The magic words are squeamish ossifrage", signature)); "The magic words are squeamish ossifrage", signature));
/* Try bad signature */ /* Try bad signature */
mpz_togglebit(signature, 17); mpz_combit(signature, 17);
ASSERT (!VERIFY(pub, md5, ASSERT (!VERIFY(pub, md5,
"The magic words are squeamish ossifrage", signature)); "The magic words are squeamish ossifrage", signature));
...@@ -837,7 +837,7 @@ test_rsa_sha1(struct rsa_public_key *pub, ...@@ -837,7 +837,7 @@ test_rsa_sha1(struct rsa_public_key *pub,
"The magic words are squeamish ossifrage", signature)); "The magic words are squeamish ossifrage", signature));
/* Try bad signature */ /* Try bad signature */
mpz_togglebit(signature, 17); mpz_combit(signature, 17);
ASSERT (!VERIFY(pub, sha1, ASSERT (!VERIFY(pub, sha1,
"The magic words are squeamish ossifrage", signature)); "The magic words are squeamish ossifrage", signature));
...@@ -875,7 +875,7 @@ test_rsa_sha256(struct rsa_public_key *pub, ...@@ -875,7 +875,7 @@ test_rsa_sha256(struct rsa_public_key *pub,
"The magic words are squeamish ossifrage", signature)); "The magic words are squeamish ossifrage", signature));
/* Try bad signature */ /* Try bad signature */
mpz_togglebit(signature, 17); mpz_combit(signature, 17);
ASSERT (!VERIFY(pub, sha256, ASSERT (!VERIFY(pub, sha256,
"The magic words are squeamish ossifrage", signature)); "The magic words are squeamish ossifrage", signature));
...@@ -913,7 +913,7 @@ test_rsa_sha512(struct rsa_public_key *pub, ...@@ -913,7 +913,7 @@ test_rsa_sha512(struct rsa_public_key *pub,
"The magic words are squeamish ossifrage", signature)); "The magic words are squeamish ossifrage", signature));
/* Try bad signature */ /* Try bad signature */
mpz_togglebit(signature, 17); mpz_combit(signature, 17);
ASSERT (!VERIFY(pub, sha512, ASSERT (!VERIFY(pub, sha512,
"The magic words are squeamish ossifrage", signature)); "The magic words are squeamish ossifrage", signature));
...@@ -1036,7 +1036,7 @@ test_dsa160(const struct dsa_public_key *pub, ...@@ -1036,7 +1036,7 @@ test_dsa160(const struct dsa_public_key *pub,
&signature)); &signature));
/* Try bad signature */ /* Try bad signature */
mpz_togglebit(signature.r, 17); mpz_combit(signature.r, 17);
ASSERT (!DSA_VERIFY(pub, sha1, ASSERT (!DSA_VERIFY(pub, sha1,
"The magic words are squeamish ossifrage", "The magic words are squeamish ossifrage",
&signature)); &signature));
...@@ -1086,7 +1086,7 @@ test_dsa256(const struct dsa_public_key *pub, ...@@ -1086,7 +1086,7 @@ test_dsa256(const struct dsa_public_key *pub,
&signature)); &signature));
/* Try bad signature */ /* Try bad signature */
mpz_togglebit(signature.r, 17); mpz_combit(signature.r, 17);
ASSERT (!DSA_VERIFY(pub, sha256, ASSERT (!DSA_VERIFY(pub, sha256,
"The magic words are squeamish ossifrage", "The magic words are squeamish ossifrage",
&signature)); &signature));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment