From 7ad00f9808510565512e36857f99ee2848065c9c Mon Sep 17 00:00:00 2001
From: Paul Bakker
Date: Thu, 18 Apr 2013 23:05:25 +0200
Subject: [PATCH] Sanity checks added to config.h
At the end of config.h sanity checks have been added to check for
prerequisites in the different module dependencies
---
include/polarssl/config.h | 75 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 74 insertions(+), 1 deletion(-)
diff --git a/include/polarssl/config.h b/include/polarssl/config.h
index 29d4f0d9e4..0a412b602d 100644
--- a/include/polarssl/config.h
+++ b/include/polarssl/config.h
@@ -905,7 +905,7 @@
* Caller: library/ssl_cli.c
* library/ssl_srv.c
*
- * Requires: POLARSSL_MD5_C, POLARSSL_SHA1_C, POLARSSL_X509_PARSE_C
+ * Requires: POLARSSL_MD5_C, POLARSSL_SHA1_C
*
* This module is required for SSL/TLS.
*/
@@ -976,4 +976,77 @@
/* \} name */
+/*
+ * Sanity checks on defines and dependencies
+ */
+#if defined(POLARSSL_DHM_C) && !defined(POLARSSL_BIGNUM_C)
+#error "POLARSSL_DHM_C defined, but not all prerequisites"
+#endif
+
+#if defined(POLARSSL_CTR_DRBG_C) && !defined(POLARSSL_AES_C)
+#error "POLARSSL_CTR_DRBG_C defined, but not all prerequisites"
+#endif
+
+#if defined(POLARSSL_ECDH_C) && !defined(POLARSSL_ECP_C)
+#error "POLARSSL_ECDH_C defined, but not all prerequisites"
+#endif
+
+#if defined(POLARSSL_ECDSA_C) && !defined(POLARSSL_ECP_C)
+#error "POLARSSL_ECDSA_C defined, but not all prerequisites"
+#endif
+
+#if defined(POLARSSL_ECP_C) && !defined(POLARSSL_BIGNUM_C)
+#error "POLARSSL_ECP_C defined, but not all prerequisites"
+#endif
+
+#if defined(POLARSSL_ENTROPY_C) && !defined(POLARSSL_SHA4_C)
+#error "POLARSSL_ENTROPY_C defined, but not all prerequisites"
+#endif
+
+#if defined(POLARSSL_GCM_C) && !defined(POLARSSL_AES_C)
+#error "POLARSSL_GCM_C defined, but not all prerequisites"
+#endif
+
+#if defined(POLARSSL_PBKDF2_C) && !defined(POLARSSL_MD_C)
+#error "POLARSSL_PBKDF2_C defined, but not all prerequisites"
+#endif
+
+#if defined(POLARSSL_PEM_C) && !defined(POLARSSL_PEM_C)
+#error "POLARSSL_PEM_C defined, but not all prerequisites"
+#endif
+
+#if defined(POLARSSL_PKCS11_C) && !defined(POLARSSL_SSL_TLS_C)
+#error "POLARSSL_PKCS11_C defined, but not all prerequisites"
+#endif
+
+#if defined(POLARSSL_RSA_C) && ( !defined(POLARSSL_BIGNUM_C) || \
+ !defined(POLARSSL_OID_C) )
+#error "POLARSSL_RSA_C defined, but not all prerequisites"
+#endif
+
+#if defined(POLARSSL_SSL_CLI_C) && !defined(POLARSSL_SSL_TLS_C)
+#error "POLARSSL_SSL_CLI_C defined, but not all prerequisites"
+#endif
+
+#if defined(POLARSSL_SSL_TLS_C) && ( !defined(POLARSSL_MD5_C) || \
+ !defined(POLARSSL_SHA1_C) )
+#error "POLARSSL_SSL_TLS_C defined, but not all prerequisites"
+#endif
+
+#if defined(POLARSSL_SSL_SRV_C) && !defined(POLARSSL_SSL_TLS_C)
+#error "POLARSSL_SSL_SRV_C defined, but not all prerequisites"
+#endif
+
+#if defined(POLARSSL_X509_PARSE_C) && ( !defined(POLARSSL_BIGNUM_C) || \
+ !defined(POLARSSL_OID_C) || !defined(POLARSSL_ASN1_PARSE_C) || \
+ !defined(POLARSSL_RSA_C) )
+#error "POLARSSL_X509_PARSE_C defined, but not all prerequisites"
+#endif
+
+#if defined(POLARSSL_X509_WRITE_C) && ( !defined(POLARSSL_BIGNUM_C) || \
+ !defined(POLARSSL_OID_C) || !defined(POLARSSL_ASN1_WRITE_C) || \
+ !defined(POLARSSL_RSA_C) )
+#error "POLARSSL_X509_WRITE_C defined, but not all prerequisites"
+#endif
+
#endif /* config.h */