diff --git a/rsa-compat.c b/rsa-compat.c
index 79e3858f661ee7ed4e358e9dd104d0e1aaa4841f..edcc0ddd471e0c1c3e17d4c4b69207276efc0d2a 100644
--- a/rsa-compat.c
+++ b/rsa-compat.c
@@ -23,6 +23,12 @@
  * MA 02111-1307, USA.
  */
 
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#if WITH_PUBLIC_KEY
+
 #include "rsa-compat.h"
 
 #include "bignum.h"
@@ -149,3 +155,4 @@ R_VerifyFinal(R_SIGNATURE_CTX *ctx,
   return res;
 }
 
+#endif /* WITH_PUBLIC_KEY */