4 * \brief Consistency checks for configuration options
6 * Copyright (C) 2006-2014, Brainspark B.V.
8 * This file is part of PolarSSL (http://www.polarssl.org)
9 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
11 * All rights reserved.
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 * It is recommended to include this file from your config.h
30 * in order to catch dependency issues early.
33 #ifndef POLARSSL_CHECK_CONFIG_H
34 #define POLARSSL_CHECK_CONFIG_H
36 #if defined(POLARSSL_AESNI_C) && !defined(POLARSSL_HAVE_ASM)
37 #error "POLARSSL_AESNI_C defined, but not all prerequisites"
40 #if defined(POLARSSL_CERTS_C) && !defined(POLARSSL_PEM_PARSE_C)
41 #error "POLARSSL_CERTS_C defined, but not all prerequisites"
44 #if defined(POLARSSL_CTR_DRBG_C) && !defined(POLARSSL_AES_C)
45 #error "POLARSSL_CTR_DRBG_C defined, but not all prerequisites"
48 #if defined(POLARSSL_DHM_C) && !defined(POLARSSL_BIGNUM_C)
49 #error "POLARSSL_DHM_C defined, but not all prerequisites"
52 #if defined(POLARSSL_ECDH_C) && !defined(POLARSSL_ECP_C)
53 #error "POLARSSL_ECDH_C defined, but not all prerequisites"
56 #if defined(POLARSSL_ECDSA_C) && \
57 ( !defined(POLARSSL_ECP_C) || \
58 !defined(POLARSSL_ASN1_PARSE_C) || \
59 !defined(POLARSSL_ASN1_WRITE_C) )
60 #error "POLARSSL_ECDSA_C defined, but not all prerequisites"
63 #if defined(POLARSSL_ECDSA_DETERMINISTIC) && !defined(POLARSSL_HMAC_DRBG_C)
64 #error "POLARSSL_ECDSA_DETERMINISTIC defined, but not all prerequisites"
67 #if defined(POLARSSL_ECP_C) && ( !defined(POLARSSL_BIGNUM_C) || ( \
68 !defined(POLARSSL_ECP_DP_SECP192R1_ENABLED) && \
69 !defined(POLARSSL_ECP_DP_SECP224R1_ENABLED) && \
70 !defined(POLARSSL_ECP_DP_SECP256R1_ENABLED) && \
71 !defined(POLARSSL_ECP_DP_SECP384R1_ENABLED) && \
72 !defined(POLARSSL_ECP_DP_SECP521R1_ENABLED) && \
73 !defined(POLARSSL_ECP_DP_BP256R1_ENABLED) && \
74 !defined(POLARSSL_ECP_DP_BP384R1_ENABLED) && \
75 !defined(POLARSSL_ECP_DP_BP512R1_ENABLED) && \
76 !defined(POLARSSL_ECP_DP_SECP192K1_ENABLED) && \
77 !defined(POLARSSL_ECP_DP_SECP224K1_ENABLED) && \
78 !defined(POLARSSL_ECP_DP_SECP256K1_ENABLED) ) )
79 #error "POLARSSL_ECP_C defined, but not all prerequisites"
82 #if defined(POLARSSL_ENTROPY_C) && (!defined(POLARSSL_SHA512_C) && \
83 !defined(POLARSSL_SHA256_C))
84 #error "POLARSSL_ENTROPY_C defined, but not all prerequisites"
86 #if defined(POLARSSL_ENTROPY_C) && defined(POLARSSL_SHA512_C) && \
87 defined(CTR_DRBG_ENTROPY_LEN) && (CTR_DRBG_ENTROPY_LEN > 64)
88 #error "CTR_DRBG_ENTROPY_LEN value too high"
90 #if defined(POLARSSL_ENTROPY_C) && \
91 ( !defined(POLARSSL_SHA512_C) || defined(POLARSSL_ENTROPY_FORCE_SHA256) ) \
92 && defined(CTR_DRBG_ENTROPY_LEN) && (CTR_DRBG_ENTROPY_LEN > 32)
93 #error "CTR_DRBG_ENTROPY_LEN value too high"
95 #if defined(POLARSSL_ENTROPY_C) && \
96 defined(POLARSSL_ENTROPY_FORCE_SHA256) && !defined(POLARSSL_SHA256_C)
97 #error "POLARSSL_ENTROPY_FORCE_SHA256 defined, but not all prerequisites"
100 #if defined(POLARSSL_GCM_C) && ( \
101 !defined(POLARSSL_AES_C) && !defined(POLARSSL_CAMELLIA_C) )
102 #error "POLARSSL_GCM_C defined, but not all prerequisites"
105 #if defined(POLARSSL_HAVEGE_C) && !defined(POLARSSL_TIMING_C)
106 #error "POLARSSL_HAVEGE_C defined, but not all prerequisites"
109 #if defined(POLARSSL_HMAC_DRBG) && !defined(POLARSSL_MD_C)
110 #error "POLARSSL_HMAC_DRBG_C defined, but not all prerequisites"
113 #if defined(POLARSSL_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) && \
114 ( !defined(POLARSSL_ECDH_C) || !defined(POLARSSL_X509_CRT_PARSE_C) )
115 #error "POLARSSL_KEY_EXCHANGE_ECDH_ECDSA_ENABLED defined, but not all prerequisites"
118 #if defined(POLARSSL_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \
119 ( !defined(POLARSSL_ECDH_C) || !defined(POLARSSL_X509_CRT_PARSE_C) )
120 #error "POLARSSL_KEY_EXCHANGE_ECDH_RSA_ENABLED defined, but not all prerequisites"
123 #if defined(POLARSSL_KEY_EXCHANGE_DHE_PSK_ENABLED) && !defined(POLARSSL_DHM_C)
124 #error "POLARSSL_KEY_EXCHANGE_DHE_PSK_ENABLED defined, but not all prerequisites"
127 #if defined(POLARSSL_KEY_EXCHANGE_ECDHE_PSK_ENABLED) && \
128 !defined(POLARSSL_ECDH_C)
129 #error "POLARSSL_KEY_EXCHANGE_ECDHE_PSK_ENABLED defined, but not all prerequisites"
132 #if defined(POLARSSL_KEY_EXCHANGE_DHE_RSA_ENABLED) && \
133 ( !defined(POLARSSL_DHM_C) || !defined(POLARSSL_RSA_C) || \
134 !defined(POLARSSL_X509_CRT_PARSE_C) || !defined(POLARSSL_PKCS1_V15) )
135 #error "POLARSSL_KEY_EXCHANGE_DHE_RSA_ENABLED defined, but not all prerequisites"
138 #if defined(POLARSSL_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \
139 ( !defined(POLARSSL_ECDH_C) || !defined(POLARSSL_RSA_C) || \
140 !defined(POLARSSL_X509_CRT_PARSE_C) || !defined(POLARSSL_PKCS1_V15) )
141 #error "POLARSSL_KEY_EXCHANGE_ECDHE_RSA_ENABLED defined, but not all prerequisites"
144 #if defined(POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) && \
145 ( !defined(POLARSSL_ECDH_C) || !defined(POLARSSL_ECDSA_C) || \
146 !defined(POLARSSL_X509_CRT_PARSE_C) )
147 #error "POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED defined, but not all prerequisites"
150 #if defined(POLARSSL_KEY_EXCHANGE_RSA_PSK_ENABLED) && \
151 ( !defined(POLARSSL_RSA_C) || !defined(POLARSSL_X509_CRT_PARSE_C) ||\
152 !defined(POLARSSL_PKCS1_V15) )
153 #error "POLARSSL_KEY_EXCHANGE_RSA_PSK_ENABLED defined, but not all prerequisites"
156 #if defined(POLARSSL_KEY_EXCHANGE_RSA_ENABLED) && \
157 ( !defined(POLARSSL_RSA_C) || !defined(POLARSSL_X509_CRT_PARSE_C) ||\
158 !defined(POLARSSL_PKCS1_V15) )
159 #error "POLARSSL_KEY_EXCHANGE_RSA_ENABLED defined, but not all prerequisites"
162 #if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C) && \
163 ( !defined(POLARSSL_PLATFORM_C) || !defined(POLARSSL_PLATFORM_MEMORY) )
164 #error "POLARSSL_MEMORY_BUFFER_ALLOC_C defined, but not all prerequisites"
167 #if defined(POLARSSL_PADLOCK_C) && !defined(POLARSSL_HAVE_ASM)
168 #error "POLARSSL_PADLOCK_C defined, but not all prerequisites"
171 #if defined(POLARSSL_PBKDF2_C) && !defined(POLARSSL_MD_C)
172 #error "POLARSSL_PBKDF2_C defined, but not all prerequisites"
175 #if defined(POLARSSL_PEM_PARSE_C) && !defined(POLARSSL_BASE64_C)
176 #error "POLARSSL_PEM_PARSE_C defined, but not all prerequisites"
179 #if defined(POLARSSL_PEM_WRITE_C) && !defined(POLARSSL_BASE64_C)
180 #error "POLARSSL_PEM_WRITE_C defined, but not all prerequisites"
183 #if defined(POLARSSL_PK_PARSE_C) && !defined(POLARSSL_PK_C)
184 #error "POLARSSL_PK_PARSE_C defined, but not all prerequisites"
187 #if defined(POLARSSL_PK_WRITE_C) && !defined(POLARSSL_PK_C)
188 #error "POLARSSL_PK_WRITE_C defined, but not all prerequisites"
191 #if defined(POLARSSL_PKCS11_C) && !defined(POLARSSL_PK_C)
192 #error "POLARSSL_PKCS11_C defined, but not all prerequisites"
195 #if defined(POLARSSL_RSA_C) && ( !defined(POLARSSL_BIGNUM_C) || \
196 !defined(POLARSSL_OID_C) )
197 #error "POLARSSL_RSA_C defined, but not all prerequisites"
200 #if defined(POLARSSL_SSL_PROTO_SSL3) && ( !defined(POLARSSL_MD5_C) || \
201 !defined(POLARSSL_SHA1_C) )
202 #error "POLARSSL_SSL_PROTO_SSL3 defined, but not all prerequisites"
205 #if defined(POLARSSL_SSL_PROTO_TLS1) && ( !defined(POLARSSL_MD5_C) || \
206 !defined(POLARSSL_SHA1_C) )
207 #error "POLARSSL_SSL_PROTO_TLS1 defined, but not all prerequisites"
210 #if defined(POLARSSL_SSL_PROTO_TLS1_1) && ( !defined(POLARSSL_MD5_C) || \
211 !defined(POLARSSL_SHA1_C) )
212 #error "POLARSSL_SSL_PROTO_TLS1_1 defined, but not all prerequisites"
215 #if defined(POLARSSL_SSL_PROTO_TLS1_2) && ( !defined(POLARSSL_SHA1_C) && \
216 !defined(POLARSSL_SHA256_C) && !defined(POLARSSL_SHA512_C) )
217 #error "POLARSSL_SSL_PROTO_TLS1_2 defined, but not all prerequisites"
220 #if defined(POLARSSL_SSL_CLI_C) && !defined(POLARSSL_SSL_TLS_C)
221 #error "POLARSSL_SSL_CLI_C defined, but not all prerequisites"
224 #if defined(POLARSSL_SSL_TLS_C) && ( !defined(POLARSSL_CIPHER_C) || \
225 !defined(POLARSSL_MD_C) )
226 #error "POLARSSL_SSL_TLS_C defined, but not all prerequisites"
229 #if defined(POLARSSL_SSL_SRV_C) && !defined(POLARSSL_SSL_TLS_C)
230 #error "POLARSSL_SSL_SRV_C defined, but not all prerequisites"
233 #if defined(POLARSSL_SSL_TLS_C) && (!defined(POLARSSL_SSL_PROTO_SSL3) && \
234 !defined(POLARSSL_SSL_PROTO_TLS1) && !defined(POLARSSL_SSL_PROTO_TLS1_1) && \
235 !defined(POLARSSL_SSL_PROTO_TLS1_2))
236 #error "POLARSSL_SSL_TLS_C defined, but no protocols are active"
239 #if defined(POLARSSL_SSL_TLS_C) && (defined(POLARSSL_SSL_PROTO_SSL3) && \
240 defined(POLARSSL_SSL_PROTO_TLS1_1) && !defined(POLARSSL_SSL_PROTO_TLS1))
241 #error "Illegal protocol selection"
244 #if defined(POLARSSL_SSL_TLS_C) && (defined(POLARSSL_SSL_PROTO_TLS1) && \
245 defined(POLARSSL_SSL_PROTO_TLS1_2) && !defined(POLARSSL_SSL_PROTO_TLS1_1))
246 #error "Illegal protocol selection"
249 #if defined(POLARSSL_SSL_TLS_C) && (defined(POLARSSL_SSL_PROTO_SSL3) && \
250 defined(POLARSSL_SSL_PROTO_TLS1_2) && (!defined(POLARSSL_SSL_PROTO_TLS1) || \
251 !defined(POLARSSL_SSL_PROTO_TLS1_1)))
252 #error "Illegal protocol selection"
255 #if defined(POLARSSL_SSL_SESSION_TICKETS) && defined(POLARSSL_SSL_TLS_C) && \
256 ( !defined(POLARSSL_AES_C) || !defined(POLARSSL_SHA256_C) || \
257 !defined(POLARSSL_CIPHER_MODE_CBC) )
258 #error "POLARSSL_SSL_SESSION_TICKETS_C defined, but not all prerequisites"
261 #if defined(POLARSSL_SSL_SERVER_NAME_INDICATION) && \
262 !defined(POLARSSL_X509_CRT_PARSE_C)
263 #error "POLARSSL_SSL_SERVER_NAME_INDICATION defined, but not all prerequisites"
266 #if defined(POLARSSL_THREADING_PTHREAD)
267 #if !defined(POLARSSL_THREADING_C) || defined(POLARSSL_THREADING_IMPL)
268 #error "POLARSSL_THREADING_PTHREAD defined, but not all prerequisites"
270 #define POLARSSL_THREADING_IMPL
273 #if defined(POLARSSL_THREADING_ALT)
274 #if !defined(POLARSSL_THREADING_C) || defined(POLARSSL_THREADING_IMPL)
275 #error "POLARSSL_THREADING_ALT defined, but not all prerequisites"
277 #define POLARSSL_THREADING_IMPL
280 #if defined(POLARSSL_THREADING_C) && !defined(POLARSSL_THREADING_IMPL)
281 #error "POLARSSL_THREADING_C defined, single threading implementation required"
283 #undef POLARSSL_THREADING_IMPL
285 #if defined(POLARSSL_VERSION_FEATURES) && !defined(POLARSSL_VERSION_C)
286 #error "POLARSSL_VERSION_FEATURES defined, but not all prerequisites"
289 #if defined(POLARSSL_X509_USE_C) && ( !defined(POLARSSL_BIGNUM_C) || \
290 !defined(POLARSSL_OID_C) || !defined(POLARSSL_ASN1_PARSE_C) || \
291 !defined(POLARSSL_PK_PARSE_C) )
292 #error "POLARSSL_X509_USE_C defined, but not all prerequisites"
295 #if defined(POLARSSL_X509_CREATE_C) && ( !defined(POLARSSL_BIGNUM_C) || \
296 !defined(POLARSSL_OID_C) || !defined(POLARSSL_ASN1_WRITE_C) || \
297 !defined(POLARSSL_PK_WRITE_C) )
298 #error "POLARSSL_X509_CREATE_C defined, but not all prerequisites"
301 #if defined(POLARSSL_X509_CRT_PARSE_C) && ( !defined(POLARSSL_X509_USE_C) )
302 #error "POLARSSL_X509_CRT_PARSE_C defined, but not all prerequisites"
305 #if defined(POLARSSL_X509_CRL_PARSE_C) && ( !defined(POLARSSL_X509_USE_C) )
306 #error "POLARSSL_X509_CRL_PARSE_C defined, but not all prerequisites"
309 #if defined(POLARSSL_X509_CSR_PARSE_C) && ( !defined(POLARSSL_X509_USE_C) )
310 #error "POLARSSL_X509_CSR_PARSE_C defined, but not all prerequisites"
313 #if defined(POLARSSL_X509_CRT_WRITE_C) && ( !defined(POLARSSL_X509_CREATE_C) )
314 #error "POLARSSL_X509_CRT_WRITE_C defined, but not all prerequisites"
317 #if defined(POLARSSL_X509_CSR_WRITE_C) && ( !defined(POLARSSL_X509_CREATE_C) )
318 #error "POLARSSL_X509_CSR_WRITE_C defined, but not all prerequisites"
321 #endif /* POLARSSL_CHECK_CONFIG_H */