diff --git a/testsuite/pkcs1-test.c b/testsuite/pkcs1-test.c
index 90e99b73291d78aa7939115b5e1b06904480fc4b..e52fc533745c6b0cc305e06ca96577710aab0828 100644
--- a/testsuite/pkcs1-test.c
+++ b/testsuite/pkcs1-test.c
@@ -1,6 +1,8 @@
 #include "testutils.h"
 
-#include "pkcs1.h"
+#if WITH_PUBLIC_KEY
+# include "pkcs1.h"
+#endif
 
 int
 test_main(void)
diff --git a/testsuite/rsa-encrypt-test.c b/testsuite/rsa-encrypt-test.c
index e733f79d869f5ac40fae493b1a8ac3491acc2e56..08cff25e0cd0a47461ae66a387fb9f30028e1e07 100644
--- a/testsuite/rsa-encrypt-test.c
+++ b/testsuite/rsa-encrypt-test.c
@@ -1,6 +1,9 @@
 #include "testutils.h"
 
-#include "rsa.h"
+#if WITH_PUBLIC_KEY
+# include "rsa.h"
+#endif
+
 #include "knuth-lfib.h"
 
 int
diff --git a/testsuite/sexp-format-test.c b/testsuite/sexp-format-test.c
index 2d8457b1a8a5fdd1d0093b4b951fbf3ffcccd6cc..33c585f41d216c75b438051095146dcf3aea5949 100644
--- a/testsuite/sexp-format-test.c
+++ b/testsuite/sexp-format-test.c
@@ -2,7 +2,10 @@
 #include "sexp.h"
 
 #include "buffer.h"
-#include "bignum.h"
+
+#if HAVE_LIBGMP
+# include "bignum.h"
+#endif
 
 int
 test_main(void)