Manuel Pégourié-Gonnard | 14d5595 | 2014-04-30 12:35:08 +0200 | [diff] [blame^] | 1 | /** |
| 2 | * \file check_config.h |
| 3 | * |
| 4 | * \brief Consistency checks for configuration options |
| 5 | * |
| 6 | * Copyright (C) 2006-2014, Brainspark B.V. |
| 7 | * |
| 8 | * This file is part of PolarSSL (http://www.polarssl.org) |
| 9 | * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> |
| 10 | * |
| 11 | * All rights reserved. |
| 12 | * |
| 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. |
| 17 | * |
| 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. |
| 22 | * |
| 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. |
| 26 | */ |
| 27 | |
| 28 | /* |
| 29 | * It is recommended to include this file from your config.h |
| 30 | * in order to catch dependency issues early. |
| 31 | */ |
| 32 | |
| 33 | #ifndef POLARSSL_CHECK_CONFIG_H |
| 34 | #define POLARSSL_CHECK_CONFIG_H |
| 35 | |
| 36 | #if defined(POLARSSL_AESNI_C) && !defined(POLARSSL_HAVE_ASM) |
| 37 | #error "POLARSSL_AESNI_C defined, but not all prerequisites" |
| 38 | #endif |
| 39 | |
| 40 | #if defined(POLARSSL_CERTS_C) && !defined(POLARSSL_PEM_PARSE_C) |
| 41 | #error "POLARSSL_CERTS_C defined, but not all prerequisites" |
| 42 | #endif |
| 43 | |
| 44 | #if defined(POLARSSL_CTR_DRBG_C) && !defined(POLARSSL_AES_C) |
| 45 | #error "POLARSSL_CTR_DRBG_C defined, but not all prerequisites" |
| 46 | #endif |
| 47 | |
| 48 | #if defined(POLARSSL_DHM_C) && !defined(POLARSSL_BIGNUM_C) |
| 49 | #error "POLARSSL_DHM_C defined, but not all prerequisites" |
| 50 | #endif |
| 51 | |
| 52 | #if defined(POLARSSL_ECDH_C) && !defined(POLARSSL_ECP_C) |
| 53 | #error "POLARSSL_ECDH_C defined, but not all prerequisites" |
| 54 | #endif |
| 55 | |
| 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" |
| 61 | #endif |
| 62 | |
| 63 | #if defined(POLARSSL_ECDSA_DETERMINISTIC) && !defined(POLARSSL_HMAC_DRBG_C) |
| 64 | #error "POLARSSL_ECDSA_DETERMINISTIC defined, but not all prerequisites" |
| 65 | #endif |
| 66 | |
| 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_M255_ENABLED) && \ |
| 77 | !defined(POLARSSL_ECP_DP_SECP192K1_ENABLED) && \ |
| 78 | !defined(POLARSSL_ECP_DP_SECP224K1_ENABLED) && \ |
| 79 | !defined(POLARSSL_ECP_DP_SECP256K1_ENABLED) ) ) |
| 80 | #error "POLARSSL_ECP_C defined, but not all prerequisites" |
| 81 | #endif |
| 82 | |
| 83 | #if defined(POLARSSL_ENTROPY_C) && (!defined(POLARSSL_SHA512_C) && \ |
| 84 | !defined(POLARSSL_SHA256_C)) |
| 85 | #error "POLARSSL_ENTROPY_C defined, but not all prerequisites" |
| 86 | #endif |
| 87 | #if defined(POLARSSL_ENTROPY_C) && defined(POLARSSL_SHA512_C) && \ |
| 88 | defined(POLARSSL_CONFIG_OPTIONS) && (CTR_DRBG_ENTROPY_LEN > 64) |
| 89 | #error "CTR_DRBG_ENTROPY_LEN value too high" |
| 90 | #endif |
| 91 | #if defined(POLARSSL_ENTROPY_C) && \ |
| 92 | ( !defined(POLARSSL_SHA512_C) || defined(POLARSSL_ENTROPY_FORCE_SHA256) ) \ |
| 93 | && defined(POLARSSL_CONFIG_OPTIONS) && (CTR_DRBG_ENTROPY_LEN > 32) |
| 94 | #error "CTR_DRBG_ENTROPY_LEN value too high" |
| 95 | #endif |
| 96 | #if defined(POLARSSL_ENTROPY_C) && \ |
| 97 | defined(POLARSSL_ENTROPY_FORCE_SHA256) && !defined(POLARSSL_SHA256_C) |
| 98 | #error "POLARSSL_ENTROPY_FORCE_SHA256 defined, but not all prerequisites" |
| 99 | #endif |
| 100 | |
| 101 | #if defined(POLARSSL_GCM_C) && ( \ |
| 102 | !defined(POLARSSL_AES_C) && !defined(POLARSSL_CAMELLIA_C) ) |
| 103 | #error "POLARSSL_GCM_C defined, but not all prerequisites" |
| 104 | #endif |
| 105 | |
| 106 | #if defined(POLARSSL_HAVEGE_C) && !defined(POLARSSL_TIMING_C) |
| 107 | #error "POLARSSL_HAVEGE_C defined, but not all prerequisites" |
| 108 | #endif |
| 109 | |
| 110 | #if defined(POLARSSL_HMAC_DRBG) && !defined(POLARSSL_MD_C) |
| 111 | #error "POLARSSL_HMAC_DRBG_C defined, but not all prerequisites" |
| 112 | #endif |
| 113 | |
| 114 | #if defined(POLARSSL_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) && \ |
| 115 | ( !defined(POLARSSL_ECDH_C) || !defined(POLARSSL_X509_CRT_PARSE_C) ) |
| 116 | #error "POLARSSL_KEY_EXCHANGE_ECDH_ECDSA_ENABLED defined, but not all prerequisites" |
| 117 | #endif |
| 118 | |
| 119 | #if defined(POLARSSL_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \ |
| 120 | ( !defined(POLARSSL_ECDH_C) || !defined(POLARSSL_X509_CRT_PARSE_C) ) |
| 121 | #error "POLARSSL_KEY_EXCHANGE_ECDH_RSA_ENABLED defined, but not all prerequisites" |
| 122 | #endif |
| 123 | |
| 124 | #if defined(POLARSSL_KEY_EXCHANGE_DHE_PSK_ENABLED) && !defined(POLARSSL_DHM_C) |
| 125 | #error "POLARSSL_KEY_EXCHANGE_DHE_PSK_ENABLED defined, but not all prerequisites" |
| 126 | #endif |
| 127 | |
| 128 | #if defined(POLARSSL_KEY_EXCHANGE_ECDHE_PSK_ENABLED) && \ |
| 129 | !defined(POLARSSL_ECDH_C) |
| 130 | #error "POLARSSL_KEY_EXCHANGE_ECDHE_PSK_ENABLED defined, but not all prerequisites" |
| 131 | #endif |
| 132 | |
| 133 | #if defined(POLARSSL_KEY_EXCHANGE_DHE_RSA_ENABLED) && \ |
| 134 | ( !defined(POLARSSL_DHM_C) || !defined(POLARSSL_RSA_C) || \ |
| 135 | !defined(POLARSSL_X509_CRT_PARSE_C) || !defined(POLARSSL_PKCS1_V15) ) |
| 136 | #error "POLARSSL_KEY_EXCHANGE_DHE_RSA_ENABLED defined, but not all prerequisites" |
| 137 | #endif |
| 138 | |
| 139 | #if defined(POLARSSL_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \ |
| 140 | ( !defined(POLARSSL_ECDH_C) || !defined(POLARSSL_RSA_C) || \ |
| 141 | !defined(POLARSSL_X509_CRT_PARSE_C) || !defined(POLARSSL_PKCS1_V15) ) |
| 142 | #error "POLARSSL_KEY_EXCHANGE_ECDHE_RSA_ENABLED defined, but not all prerequisites" |
| 143 | #endif |
| 144 | |
| 145 | #if defined(POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) && \ |
| 146 | ( !defined(POLARSSL_ECDH_C) || !defined(POLARSSL_ECDSA_C) || \ |
| 147 | !defined(POLARSSL_X509_CRT_PARSE_C) ) |
| 148 | #error "POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED defined, but not all prerequisites" |
| 149 | #endif |
| 150 | |
| 151 | #if defined(POLARSSL_KEY_EXCHANGE_RSA_PSK_ENABLED) && \ |
| 152 | ( !defined(POLARSSL_RSA_C) || !defined(POLARSSL_X509_CRT_PARSE_C) ||\ |
| 153 | !defined(POLARSSL_PKCS1_V15) ) |
| 154 | #error "POLARSSL_KEY_EXCHANGE_RSA_PSK_ENABLED defined, but not all prerequisites" |
| 155 | #endif |
| 156 | |
| 157 | #if defined(POLARSSL_KEY_EXCHANGE_RSA_ENABLED) && \ |
| 158 | ( !defined(POLARSSL_RSA_C) || !defined(POLARSSL_X509_CRT_PARSE_C) ||\ |
| 159 | !defined(POLARSSL_PKCS1_V15) ) |
| 160 | #error "POLARSSL_KEY_EXCHANGE_RSA_ENABLED defined, but not all prerequisites" |
| 161 | #endif |
| 162 | |
| 163 | #if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C) && \ |
| 164 | ( !defined(POLARSSL_PLATFORM_C) || !defined(POLARSSL_PLATFORM_MEMORY) ) |
| 165 | #error "POLARSSL_MEMORY_BUFFER_ALLOC_C defined, but not all prerequisites" |
| 166 | #endif |
| 167 | |
| 168 | #if defined(POLARSSL_PADLOCK_C) && !defined(POLARSSL_HAVE_ASM) |
| 169 | #error "POLARSSL_PADLOCK_C defined, but not all prerequisites" |
| 170 | #endif |
| 171 | |
| 172 | #if defined(POLARSSL_PBKDF2_C) && !defined(POLARSSL_MD_C) |
| 173 | #error "POLARSSL_PBKDF2_C defined, but not all prerequisites" |
| 174 | #endif |
| 175 | |
| 176 | #if defined(POLARSSL_PEM_PARSE_C) && !defined(POLARSSL_BASE64_C) |
| 177 | #error "POLARSSL_PEM_PARSE_C defined, but not all prerequisites" |
| 178 | #endif |
| 179 | |
| 180 | #if defined(POLARSSL_PEM_WRITE_C) && !defined(POLARSSL_BASE64_C) |
| 181 | #error "POLARSSL_PEM_WRITE_C defined, but not all prerequisites" |
| 182 | #endif |
| 183 | |
| 184 | #if defined(POLARSSL_PK_PARSE_C) && !defined(POLARSSL_PK_C) |
| 185 | #error "POLARSSL_PK_PARSE_C defined, but not all prerequisites" |
| 186 | #endif |
| 187 | |
| 188 | #if defined(POLARSSL_PK_WRITE_C) && !defined(POLARSSL_PK_C) |
| 189 | #error "POLARSSL_PK_WRITE_C defined, but not all prerequisites" |
| 190 | #endif |
| 191 | |
| 192 | #if defined(POLARSSL_PKCS11_C) && !defined(POLARSSL_PK_C) |
| 193 | #error "POLARSSL_PKCS11_C defined, but not all prerequisites" |
| 194 | #endif |
| 195 | |
| 196 | #if defined(POLARSSL_RSA_C) && ( !defined(POLARSSL_BIGNUM_C) || \ |
| 197 | !defined(POLARSSL_OID_C) ) |
| 198 | #error "POLARSSL_RSA_C defined, but not all prerequisites" |
| 199 | #endif |
| 200 | |
| 201 | #if defined(POLARSSL_SSL_PROTO_SSL3) && ( !defined(POLARSSL_MD5_C) || \ |
| 202 | !defined(POLARSSL_SHA1_C) ) |
| 203 | #error "POLARSSL_SSL_PROTO_SSL3 defined, but not all prerequisites" |
| 204 | #endif |
| 205 | |
| 206 | #if defined(POLARSSL_SSL_PROTO_TLS1) && ( !defined(POLARSSL_MD5_C) || \ |
| 207 | !defined(POLARSSL_SHA1_C) ) |
| 208 | #error "POLARSSL_SSL_PROTO_TLS1 defined, but not all prerequisites" |
| 209 | #endif |
| 210 | |
| 211 | #if defined(POLARSSL_SSL_PROTO_TLS1_1) && ( !defined(POLARSSL_MD5_C) || \ |
| 212 | !defined(POLARSSL_SHA1_C) ) |
| 213 | #error "POLARSSL_SSL_PROTO_TLS1_1 defined, but not all prerequisites" |
| 214 | #endif |
| 215 | |
| 216 | #if defined(POLARSSL_SSL_PROTO_TLS1_2) && ( !defined(POLARSSL_SHA1_C) && \ |
| 217 | !defined(POLARSSL_SHA256_C) && !defined(POLARSSL_SHA512_C) ) |
| 218 | #error "POLARSSL_SSL_PROTO_TLS1_2 defined, but not all prerequisites" |
| 219 | #endif |
| 220 | |
| 221 | #if defined(POLARSSL_SSL_CLI_C) && !defined(POLARSSL_SSL_TLS_C) |
| 222 | #error "POLARSSL_SSL_CLI_C defined, but not all prerequisites" |
| 223 | #endif |
| 224 | |
| 225 | #if defined(POLARSSL_SSL_TLS_C) && ( !defined(POLARSSL_CIPHER_C) || \ |
| 226 | !defined(POLARSSL_MD_C) ) |
| 227 | #error "POLARSSL_SSL_TLS_C defined, but not all prerequisites" |
| 228 | #endif |
| 229 | |
| 230 | #if defined(POLARSSL_SSL_SRV_C) && !defined(POLARSSL_SSL_TLS_C) |
| 231 | #error "POLARSSL_SSL_SRV_C defined, but not all prerequisites" |
| 232 | #endif |
| 233 | |
| 234 | #if defined(POLARSSL_SSL_TLS_C) && (!defined(POLARSSL_SSL_PROTO_SSL3) && \ |
| 235 | !defined(POLARSSL_SSL_PROTO_TLS1) && !defined(POLARSSL_SSL_PROTO_TLS1_1) && \ |
| 236 | !defined(POLARSSL_SSL_PROTO_TLS1_2)) |
| 237 | #error "POLARSSL_SSL_TLS_C defined, but no protocols are active" |
| 238 | #endif |
| 239 | |
| 240 | #if defined(POLARSSL_SSL_TLS_C) && (defined(POLARSSL_SSL_PROTO_SSL3) && \ |
| 241 | defined(POLARSSL_SSL_PROTO_TLS1_1) && !defined(POLARSSL_SSL_PROTO_TLS1)) |
| 242 | #error "Illegal protocol selection" |
| 243 | #endif |
| 244 | |
| 245 | #if defined(POLARSSL_SSL_TLS_C) && (defined(POLARSSL_SSL_PROTO_TLS1) && \ |
| 246 | defined(POLARSSL_SSL_PROTO_TLS1_2) && !defined(POLARSSL_SSL_PROTO_TLS1_1)) |
| 247 | #error "Illegal protocol selection" |
| 248 | #endif |
| 249 | |
| 250 | #if defined(POLARSSL_SSL_TLS_C) && (defined(POLARSSL_SSL_PROTO_SSL3) && \ |
| 251 | defined(POLARSSL_SSL_PROTO_TLS1_2) && (!defined(POLARSSL_SSL_PROTO_TLS1) || \ |
| 252 | !defined(POLARSSL_SSL_PROTO_TLS1_1))) |
| 253 | #error "Illegal protocol selection" |
| 254 | #endif |
| 255 | |
| 256 | #if defined(POLARSSL_SSL_SESSION_TICKETS) && defined(POLARSSL_SSL_TLS_C) && \ |
| 257 | ( !defined(POLARSSL_AES_C) || !defined(POLARSSL_SHA256_C) || \ |
| 258 | !defined(POLARSSL_CIPHER_MODE_CBC) ) |
| 259 | #error "POLARSSL_SSL_SESSION_TICKETS_C defined, but not all prerequisites" |
| 260 | #endif |
| 261 | |
| 262 | #if defined(POLARSSL_SSL_SERVER_NAME_INDICATION) && \ |
| 263 | !defined(POLARSSL_X509_CRT_PARSE_C) |
| 264 | #error "POLARSSL_SSL_SERVER_NAME_INDICATION defined, but not all prerequisites" |
| 265 | #endif |
| 266 | |
| 267 | #if defined(POLARSSL_THREADING_PTHREAD) |
| 268 | #if !defined(POLARSSL_THREADING_C) || defined(POLARSSL_THREADING_IMPL) |
| 269 | #error "POLARSSL_THREADING_PTHREAD defined, but not all prerequisites" |
| 270 | #endif |
| 271 | #define POLARSSL_THREADING_IMPL |
| 272 | #endif |
| 273 | |
| 274 | #if defined(POLARSSL_THREADING_ALT) |
| 275 | #if !defined(POLARSSL_THREADING_C) || defined(POLARSSL_THREADING_IMPL) |
| 276 | #error "POLARSSL_THREADING_ALT defined, but not all prerequisites" |
| 277 | #endif |
| 278 | #define POLARSSL_THREADING_IMPL |
| 279 | #endif |
| 280 | |
| 281 | #if defined(POLARSSL_THREADING_C) && !defined(POLARSSL_THREADING_IMPL) |
| 282 | #error "POLARSSL_THREADING_C defined, single threading implementation required" |
| 283 | #endif |
| 284 | #undef POLARSSL_THREADING_IMPL |
| 285 | |
| 286 | #if defined(POLARSSL_VERSION_FEATURES) && !defined(POLARSSL_VERSION_C) |
| 287 | #error "POLARSSL_VERSION_FEATURES defined, but not all prerequisites" |
| 288 | #endif |
| 289 | |
| 290 | #if defined(POLARSSL_X509_USE_C) && ( !defined(POLARSSL_BIGNUM_C) || \ |
| 291 | !defined(POLARSSL_OID_C) || !defined(POLARSSL_ASN1_PARSE_C) || \ |
| 292 | !defined(POLARSSL_PK_PARSE_C) ) |
| 293 | #error "POLARSSL_X509_USE_C defined, but not all prerequisites" |
| 294 | #endif |
| 295 | |
| 296 | #if defined(POLARSSL_X509_CREATE_C) && ( !defined(POLARSSL_BIGNUM_C) || \ |
| 297 | !defined(POLARSSL_OID_C) || !defined(POLARSSL_ASN1_WRITE_C) || \ |
| 298 | !defined(POLARSSL_PK_WRITE_C) ) |
| 299 | #error "POLARSSL_X509_CREATE_C defined, but not all prerequisites" |
| 300 | #endif |
| 301 | |
| 302 | #if defined(POLARSSL_X509_CRT_PARSE_C) && ( !defined(POLARSSL_X509_USE_C) ) |
| 303 | #error "POLARSSL_X509_CRT_PARSE_C defined, but not all prerequisites" |
| 304 | #endif |
| 305 | |
| 306 | #if defined(POLARSSL_X509_CRL_PARSE_C) && ( !defined(POLARSSL_X509_USE_C) ) |
| 307 | #error "POLARSSL_X509_CRL_PARSE_C defined, but not all prerequisites" |
| 308 | #endif |
| 309 | |
| 310 | #if defined(POLARSSL_X509_CSR_PARSE_C) && ( !defined(POLARSSL_X509_USE_C) ) |
| 311 | #error "POLARSSL_X509_CSR_PARSE_C defined, but not all prerequisites" |
| 312 | #endif |
| 313 | |
| 314 | #if defined(POLARSSL_X509_CRT_WRITE_C) && ( !defined(POLARSSL_X509_CREATE_C) ) |
| 315 | #error "POLARSSL_X509_CRT_WRITE_C defined, but not all prerequisites" |
| 316 | #endif |
| 317 | |
| 318 | #if defined(POLARSSL_X509_CSR_WRITE_C) && ( !defined(POLARSSL_X509_CREATE_C) ) |
| 319 | #error "POLARSSL_X509_CSR_WRITE_C defined, but not all prerequisites" |
| 320 | #endif |
| 321 | |
| 322 | #endif /* POLARSSL_CHECK_CONFIG_H */ |