diff --git a/rsa-keygen.c b/rsa-keygen.c
index 4305c0a84942947465a73c8cc5ab98147a7fb7ea..a6434223b005bd41d4249817dd33e7901cc116dc 100644
--- a/rsa-keygen.c
+++ b/rsa-keygen.c
@@ -27,7 +27,7 @@
 #include "config.h"
 #endif
 
-#if HAVE_LIBGMP
+#if WITH_PUBLIC_KEY
 
 #include "rsa.h"
 #include "bignum.h"
@@ -350,4 +350,4 @@ rsa_generate_keypair(struct rsa_public_key *pub,
   return 1;
 }
 
-#endif /* HAVE_LIBGMP */
+#endif /* WITH_PUBLIC_KEY */
diff --git a/rsa.c b/rsa.c
index d64cb061faa2ec288be471fe623e508be0f6a33c..ab4650561a67150963ce34f45b5abbbc1f84f792 100644
--- a/rsa.c
+++ b/rsa.c
@@ -27,7 +27,7 @@
 #include "config.h"
 #endif
 
-#if HAVE_LIBGMP
+#if WITH_PUBLIC_KEY
 
 #include "rsa.h"
 
@@ -190,4 +190,4 @@ rsa_compute_root(struct rsa_private_key *key, mpz_t x, const mpz_t m)
   mpz_clear(xp); mpz_clear(xq);
 }
 
-#endif /* HAVE_LIBGMP */
+#endif /* WITH_PUBLIC_KEY */
diff --git a/rsa2sexp.c b/rsa2sexp.c
index 9a087cae052583a2c82e92a6a8b227939eff5eab..eb6f7e8909c5aabd3511f6604e2fc554a2ca0ab6 100644
--- a/rsa2sexp.c
+++ b/rsa2sexp.c
@@ -26,7 +26,7 @@
 #include "config.h"
 #endif
 
-#if HAVE_LIBGMP
+#if WITH_PUBLIC_KEY
 
 #include "rsa.h"
 
@@ -49,4 +49,4 @@ rsa_keypair_to_sexp(struct nettle_buffer *buffer,
 		       "public-key", "rsa", "n", pub->n, "e", pub->e);
 }
 
-#endif /* HAVE_LIBGMP */
+#endif /* WITH_PUBLIC_KEY */
diff --git a/rsa_md5.c b/rsa_md5.c
index cd72ad2741f414106073bc558e7f0f87d9e0a1c7..05487ef62add1b6fcb78f86c28f716472246b55f 100644
--- a/rsa_md5.c
+++ b/rsa_md5.c
@@ -27,7 +27,7 @@
 #include "config.h"
 #endif
 
-#if HAVE_LIBGMP
+#if WITH_PUBLIC_KEY
 
 #include "rsa.h"
 
@@ -131,4 +131,4 @@ pkcs1_encode_md5(mpz_t m, unsigned length, struct md5_ctx *hash)
   nettle_mpz_set_str_256(m, length, em);
 }
 
-#endif /* HAVE_LIBGMP */
+#endif /* WITH_PUBLIC_KEY */
diff --git a/rsa_sha1.c b/rsa_sha1.c
index 5bf5613fd7f310f869535adc4ceaa582de3afd8d..ecc697c4e28650f779a98226413069b6772d8064 100644
--- a/rsa_sha1.c
+++ b/rsa_sha1.c
@@ -27,7 +27,7 @@
 #include "config.h"
 #endif
 
-#if HAVE_LIBGMP
+#if WITH_PUBLIC_KEY
 
 #include "rsa.h"
 
@@ -131,4 +131,4 @@ pkcs1_encode_sha1(mpz_t m, unsigned length, struct sha1_ctx *hash)
   nettle_mpz_set_str_256(m, length, em);
 }
 
-#endif /* HAVE_LIBGMP */
+#endif /* WITH_PUBLIC_KEY */
diff --git a/sexp2rsa.c b/sexp2rsa.c
index 940296c2445b8475aa227713b9d689759de4497b..2c0006ed087f7a4c2ca2d1b6aa2f03b97837dff2 100644
--- a/sexp2rsa.c
+++ b/sexp2rsa.c
@@ -26,7 +26,7 @@
 #include "config.h"
 #endif
 
-#if HAVE_LIBGMP
+#if WITH_PUBLIC_KEY
 
 #include "rsa.h"
 
@@ -119,4 +119,4 @@ rsa_keypair_from_sexp(struct rsa_public_key *pub,
   return 1;
 }
 
-#endif /* HAVE_LIBGMP */
+#endif /* WITH_PUBLIC_KEY */
diff --git a/testsuite/rsa-keygen-test.c b/testsuite/rsa-keygen-test.c
index 8a2498da4d867fe21143432ea83873251e328872..438a6298209713160dfc77c112be4f7dab284b26 100644
--- a/testsuite/rsa-keygen-test.c
+++ b/testsuite/rsa-keygen-test.c
@@ -17,7 +17,7 @@ progress(void *ctx UNUSED, int c)
 int
 test_main(void)
 {
-#if HAVE_LIBGMP
+#if WITH_PUBLIC_KEY
 
   struct rsa_public_key pub;
   struct rsa_private_key key;
@@ -85,7 +85,7 @@ test_main(void)
 
   SUCCESS();
   
-#else /* !HAVE_LIBGMP */
+#else /* !WITH_PUBLIC_KEY */
   SKIP();
-#endif /* !HAVE_LIBGMP */
+#endif /* !WITH_PUBLIC_KEY */
 }
diff --git a/testsuite/rsa-test.c b/testsuite/rsa-test.c
index 40161738020bcfe6980f188920b5c95f71483f67..a43c43d8b8d3e706c4432222873f1408acb0ac8e 100644
--- a/testsuite/rsa-test.c
+++ b/testsuite/rsa-test.c
@@ -3,7 +3,7 @@
 int
 test_main(void)
 {
-#if HAVE_LIBGMP
+#if WITH_PUBLIC_KEY
 
   struct rsa_public_key pub;
   struct rsa_private_key key;
@@ -240,7 +240,7 @@ test_main(void)
 
   SUCCESS();
   
-#else /* !HAVE_LIBGMP */
+#else /* !WITH_PUBLIC_KEY */
   SKIP();
-#endif /* !HAVE_LIBGMP */
+#endif /* !WITH_PUBLIC_KEY */
 }
diff --git a/testsuite/rsa2sexp-test.c b/testsuite/rsa2sexp-test.c
index 7ff85dabe95d0b4836061daf3ae69e56747df172..f4ddcf853b41b8e1989cbd2162c8b2c602424eb7 100644
--- a/testsuite/rsa2sexp-test.c
+++ b/testsuite/rsa2sexp-test.c
@@ -6,7 +6,7 @@
 int
 test_main(void)
 {
-#if HAVE_LIBGMP
+#if WITH_PUBLIC_KEY
   struct rsa_public_key pub;
   struct rsa_private_key priv;
 
@@ -87,7 +87,7 @@ test_main(void)
   
   SUCCESS();
   
-#else /* !HAVE_LIBGMP */
+#else /* !WITH_PUBLIC_KEY */
   SKIP();
-#endif /* !HAVE_LIBGMP */
+#endif /* !WITH_PUBLIC_KEY */
 }
diff --git a/testsuite/sexp2rsa-test.c b/testsuite/sexp2rsa-test.c
index 3296644ed46e09e5cd4b0fd592aabbd6b0a23e7b..e19d50cde4910cb548ffb2cd4e9d210aca45f4e9 100644
--- a/testsuite/sexp2rsa-test.c
+++ b/testsuite/sexp2rsa-test.c
@@ -5,7 +5,7 @@
 int
 test_main(void)
 {
-#if HAVE_LIBGMP
+#if WITH_PUBLIC_KEY
   struct rsa_public_key pub;
   struct rsa_private_key priv;
   
@@ -43,8 +43,8 @@ test_main(void)
   
   SUCCESS();
   
-#else /* !HAVE_LIBGMP */
+#else /* !WITH_PUBLIC_KEY */
   SKIP();
-#endif /* !HAVE_LIBGMP */
+#endif /* !WITH_PUBLIC_KEY */
 }
 
diff --git a/testsuite/testutils.c b/testsuite/testutils.c
index 203f827119eb1b77f85caa25b2bc361b6f4aaa64..a954a37437bb56a235cd27657d95cf5e078dea8c 100644
--- a/testsuite/testutils.c
+++ b/testsuite/testutils.c
@@ -1,6 +1,5 @@
 /* testutils.c */
 
-
 #include "testutils.h"
 
 #include "cbc.h"
@@ -269,17 +268,6 @@ test_armor(const struct nettle_armor *armor,
 }
 
 #if HAVE_LIBGMP
-#define SIGN(key, hash, msg, signature) do {	\
-  hash##_update(&hash, LDATA(msg));		\
-  rsa_##hash##_sign(key, &hash, signature);	\
-} while(0)
-
-#define VERIFY(key, hash, msg, signature) (	\
-  hash##_update(&hash, LDATA(msg)),		\
-  rsa_##hash##_verify(key, &hash, signature)	\
-)
-
-
 /* Missing in current gmp */
 static void
 mpz_togglebit (mpz_t x, unsigned long int bit)
@@ -289,6 +277,18 @@ mpz_togglebit (mpz_t x, unsigned long int bit)
   else
     mpz_setbit(x, bit);
 }
+#endif /* HAVE_LIBGMP */
+
+#if WITH_PUBLIC_KEY
+#define SIGN(key, hash, msg, signature) do {	\
+  hash##_update(&hash, LDATA(msg));		\
+  rsa_##hash##_sign(key, &hash, signature);	\
+} while(0)
+
+#define VERIFY(key, hash, msg, signature) (	\
+  hash##_update(&hash, LDATA(msg)),		\
+  rsa_##hash##_verify(key, &hash, signature)	\
+)
 
 void
 test_rsa_md5(struct rsa_public_key *pub,
@@ -376,7 +376,6 @@ test_rsa_sha1(struct rsa_public_key *pub,
   mpz_clear(signature);
 }
 
-#if HAVE_LIBGMP
 void
 test_rsa_key(struct rsa_public_key *pub,
 	     struct rsa_private_key *key)
@@ -447,6 +446,5 @@ test_rsa_key(struct rsa_public_key *pub,
   
   mpz_clear(tmp); mpz_clear(phi);
 }
-#endif /* HAVE_LIBGMP */
+#endif /* WITH_PUBLIC_KEY */
 
-#endif /* HAVE_LIBGMP */
diff --git a/testsuite/testutils.h b/testsuite/testutils.h
index d82aa51a68f9f856a022a743be443594acd78d06..d1f9f7648de3dbc5b5a5a3941b0f6b4e98f254ea 100644
--- a/testsuite/testutils.h
+++ b/testsuite/testutils.h
@@ -12,6 +12,10 @@
 #include <stdio.h>
 
 #if HAVE_LIBGMP
+# include "bignum.h"
+#endif
+
+#if WITH_PUBLIC_KEY
 # include "rsa.h"
 #endif
 
@@ -67,7 +71,7 @@ test_armor(const struct nettle_armor *armor,
            const uint8_t *data,
            const uint8_t *ascii);
 
-#if HAVE_LIBGMP
+#if WITH_PUBLIC_KEY
 void
 test_rsa_md5(struct rsa_public_key *pub,
 	     struct rsa_private_key *key,
@@ -82,7 +86,7 @@ void
 test_rsa_key(struct rsa_public_key *pub,
 	     struct rsa_private_key *key);
 
-#endif /* HAVE_LIBGMP */
+#endif /* WITH_PUBLIC_KEY */
 
 #define H2(d, s) decode_hex((d), (s))
 #define H(x) decode_hex_dup(x)