Skip to content

Commit 74a4bcb

Browse files
committed
Enforce all configure.ac rules in settings.h also. Keeping configure.ac for early error checking.
1 parent 4574a0c commit 74a4bcb

File tree

1 file changed

+190
-0
lines changed

1 file changed

+190
-0
lines changed

wolfssl/wolfcrypt/settings.h

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4779,6 +4779,196 @@ extern void uITRON4_free(void *p) ;
47794779
#endif
47804780
#endif /* HAVE_ENTROPY_MEMUSE */
47814781

4782+
/* ---------------------------------------------------------------------------*/
4783+
/* Configuration validation rules */
4784+
/* These enforce build constraints across all platforms */
4785+
/* ---------------------------------------------------------------------------*/
4786+
4787+
/* Mutual Exclusivity Rules */
4788+
#if defined(WOLFSSL_SP_MATH) && defined(WOLFSSL_SP_MATH_ALL)
4789+
#error "WOLFSSL_SP_MATH and WOLFSSL_SP_MATH_ALL are incompatible"
4790+
#endif
4791+
#if defined(WOLFCRYPT_ONLY) && defined(OPENSSL_ALL)
4792+
#error "WOLFCRYPT_ONLY and OPENSSL_ALL are mutually incompatible"
4793+
#endif
4794+
#if defined(WOLFSSL_MAX_STRENGTH) && defined(WOLFSSL_LEANPSK)
4795+
#error "Cannot use Max Strength and Lean PSK at the same time"
4796+
#endif
4797+
#if defined(WOLFSSL_HAVE_WOLFSCEP) && defined(WOLFSSL_LEANTLS)
4798+
#error "Cannot use SCEP and Lean TLS at the same time"
4799+
#endif
4800+
#if defined(WOLFSSL_MAX_STRENGTH) && defined(WOLFSSL_ALLOW_SSLV3)
4801+
#error "Cannot use Max Strength and SSLv3 at the same time"
4802+
#endif
4803+
4804+
/* Dependency Rules (Feature X requires Feature Y) */
4805+
#if defined(WOLFSSL_SHA224) && defined(NO_SHA256)
4806+
#error "SHA-224 requires SHA-256"
4807+
#endif
4808+
#if defined(WOLFSSL_SM2) && !defined(HAVE_ECC)
4809+
#error "SM2 requires ECC"
4810+
#endif
4811+
#if defined(HAVE_ECC_BRAINPOOL) && !defined(WOLFSSL_CUSTOM_CURVES)
4812+
#error "Brainpool curves require WOLFSSL_CUSTOM_CURVES"
4813+
#endif
4814+
#if defined(FP_ECC) && !defined(HAVE_ECC)
4815+
#error "FP_ECC requires ECC"
4816+
#endif
4817+
#if defined(HAVE_ECC_ENCRYPT) && !defined(HAVE_ECC)
4818+
#error "ECC encrypt requires ECC"
4819+
#endif
4820+
#if defined(HAVE_ECC_ENCRYPT) && !defined(HAVE_HKDF)
4821+
#error "ECC encrypt requires HKDF"
4822+
#endif
4823+
#if defined(WOLFCRYPT_HAVE_ECCSI) && !defined(HAVE_ECC)
4824+
#error "ECCSI requires ECC"
4825+
#endif
4826+
#if defined(WOLFCRYPT_HAVE_SAKKE) && !defined(HAVE_ECC)
4827+
#error "SAKKE requires ECC"
4828+
#endif
4829+
#if !defined(WOLFCRYPT_ONLY) && defined(HAVE_ANON) && defined(NO_DH)
4830+
#error "Anonymous ciphers require DH"
4831+
#endif
4832+
#if defined(FORTRESS) && defined(NO_AES)
4833+
#error "Fortress requires AES"
4834+
#endif
4835+
#if defined(HAVE_AESGCM) && defined(NO_AES)
4836+
#error "AES-GCM requires AES"
4837+
#endif
4838+
#if defined(HAVE_AESCCM) && defined(NO_AES)
4839+
#error "AES-CCM requires AES"
4840+
#endif
4841+
#if defined(WOLFSSL_AES_COUNTER) && defined(NO_AES)
4842+
#error "AES-CTR requires AES"
4843+
#endif
4844+
#if defined(HAVE_ED448) && !defined(WOLFSSL_SHA512)
4845+
#error "ED448 requires SHA-512"
4846+
#endif
4847+
#if defined(WOLFSSL_SHAKE128) && !defined(WOLFSSL_SHA3)
4848+
#error "SHAKE128 requires SHA-3"
4849+
#endif
4850+
#if defined(WOLFSSL_SHAKE256) && !defined(WOLFSSL_SHA3)
4851+
#error "SHAKE256 requires SHA-3"
4852+
#endif
4853+
#if defined(HAVE_XCHACHA) && !defined(HAVE_CHACHA)
4854+
#error "XChaCha requires ChaCha"
4855+
#endif
4856+
#if !defined(WOLFCRYPT_ONLY) && defined(WOLFSSL_REQUIRE_FFDHE) && \
4857+
defined(NO_DH)
4858+
#error "FFDHE-only requires DH"
4859+
#endif
4860+
#if !defined(WOLFCRYPT_ONLY) && defined(WOLFSSL_REQUIRE_FFDHE) && \
4861+
!defined(HAVE_SUPPORTED_CURVES)
4862+
#error "FFDHE-only requires Supported Curves extension"
4863+
#endif
4864+
#if defined(HAVE_SCRYPT) && defined(NO_PWDBASED)
4865+
#error "scrypt requires pwdbased"
4866+
#endif
4867+
#if defined(HAVE_OCSP) && defined(NO_ASN)
4868+
#error "OCSP requires ASN"
4869+
#endif
4870+
#if defined(HAVE_SMIME) && defined(NO_ASN)
4871+
#error "S/MIME requires ASN"
4872+
#endif
4873+
#if defined(HAVE_OCSP) && defined(NO_RSA) && !defined(HAVE_ECC)
4874+
#error "OCSP requires RSA or ECC"
4875+
#endif
4876+
#if defined(HAVE_PKCS7) && defined(NO_RSA) && !defined(HAVE_ECC)
4877+
#error "PKCS7 requires RSA or ECC"
4878+
#endif
4879+
#if defined(HAVE_PKCS7) && defined(NO_SHA) && defined(NO_SHA256)
4880+
#error "PKCS7 requires SHA or SHA-256"
4881+
#endif
4882+
#if defined(WOLFSSL_HAVE_WOLFSCEP) && defined(NO_AES) && defined(NO_DES3)
4883+
#error "SCEP requires AES or 3DES"
4884+
#endif
4885+
#if !defined(WOLFCRYPT_ONLY) && defined(WOLFSSL_SNIFFER) && \
4886+
defined(NO_RSA) && !defined(HAVE_ECC) && !defined(HAVE_CURVE25519)
4887+
#error "Sniffer requires RSA, ECC, or Curve25519"
4888+
#endif
4889+
#if !defined(NO_RSA) && !defined(WOLFSSL_RSA_VERIFY_ONLY) && \
4890+
defined(NO_ASN) && !defined(WOLFCRYPT_ONLY)
4891+
#error "RSA requires ASN"
4892+
#endif
4893+
#if !defined(NO_DSA) && defined(NO_ASN)
4894+
#error "DSA requires ASN"
4895+
#endif
4896+
#if !defined(WOLFCRYPT_ONLY) && defined(NO_PSK) && defined(NO_ASN)
4897+
#error "Please enable PSK if disabling ASN"
4898+
#endif
4899+
#if defined(WOLFSSL_WOLFSSH) && defined(NO_HMAC)
4900+
#error "WOLFSSH requires HMAC"
4901+
#endif
4902+
4903+
/* Conflicting Feature Rules */
4904+
#if defined(WOLFSSL_SP_MATH) && !defined(WOLFSSL_SP_MATH_ALL)
4905+
#if defined(WOLFSSL_CUSTOM_CURVES)
4906+
#error "Cannot use single precision math and custom curves"
4907+
#endif
4908+
#if !defined(NO_DSA)
4909+
#error "Cannot use single precision math and DSA"
4910+
#endif
4911+
#if defined(WOLFCRYPT_HAVE_SRP)
4912+
#error "Cannot use single precision math and SRP"
4913+
#endif
4914+
#endif
4915+
#if defined(USE_INTEGER_HEAP_MATH) && defined(WOLFSSL_STATIC_MEMORY)
4916+
#error "Heap math is incompatible with static memory"
4917+
#endif
4918+
#if defined(WC_16BIT_CPU) && \
4919+
(defined(WOLFSSL_SP_MATH) || defined(WOLFSSL_SP_MATH_ALL))
4920+
#error "16-bit build is not available with SP math"
4921+
#endif
4922+
4923+
/* Streaming Feature Rules */
4924+
#if defined(WOLFSSL_AESGCM_STREAM) && !defined(HAVE_AESGCM)
4925+
#error "AES-GCM streaming requires AES-GCM"
4926+
#endif
4927+
#if defined(WOLFSSL_AESXTS_STREAM) && !defined(WOLFSSL_AES_XTS)
4928+
#error "AES-XTS streaming requires AES-XTS"
4929+
#endif
4930+
#if defined(WOLFSSL_ED25519_STREAMING_VERIFY) && !defined(HAVE_ED25519)
4931+
#error "ED25519 streaming verify requires ED25519"
4932+
#endif
4933+
#if defined(WOLFSSL_ED448_STREAMING_VERIFY) && !defined(HAVE_ED448)
4934+
#error "ED448 streaming verify requires ED448"
4935+
#endif
4936+
4937+
/* QUIC Rules */
4938+
#if !defined(WOLFCRYPT_ONLY) && defined(WOLFSSL_QUIC) && \
4939+
!defined(WOLFSSL_TLS13)
4940+
#error "QUIC requires TLS 1.3"
4941+
#endif
4942+
#if !defined(WOLFCRYPT_ONLY) && defined(WOLFSSL_QUIC) && \
4943+
!defined(HAVE_AESGCM)
4944+
#error "QUIC requires AES-GCM"
4945+
#endif
4946+
4947+
/* Crypto Callback Rules */
4948+
#if defined(WC_TEST_NO_CRYPTOCB_SW_TEST) && !defined(WOLF_CRYPTO_CB)
4949+
#error "Crypto callback SW test requires WOLF_CRYPTO_CB"
4950+
#endif
4951+
#if (defined(WOLF_CRYPTO_CB_COPY) || defined(WOLF_CRYPTO_CB_FREE)) && \
4952+
!defined(WOLF_CRYPTO_CB)
4953+
#error "Crypto callback utilities require WOLF_CRYPTO_CB"
4954+
#endif
4955+
4956+
/* Early Data / Session Rules */
4957+
#if !defined(WOLFCRYPT_ONLY) && defined(WOLFSSL_EARLY_DATA) && \
4958+
!defined(WOLFSSL_TLS13)
4959+
#error "Early data requires TLS 1.3"
4960+
#endif
4961+
#if !defined(WOLFCRYPT_ONLY) && defined(WOLFSSL_EARLY_DATA) && \
4962+
!defined(HAVE_SESSION_TICKET) && defined(NO_PSK)
4963+
#error "Early data requires session tickets or PSK"
4964+
#endif
4965+
4966+
/* DES3 TLS Suite Rule */
4967+
#if !defined(WOLFCRYPT_ONLY) && !defined(NO_DES3_TLS_SUITES) && \
4968+
defined(NO_DES3)
4969+
#error "DES3 TLS suites require DES3"
4970+
#endif
4971+
47824972
#if defined(NO_WOLFSSL_CLIENT) && defined(NO_WOLFSSL_SERVER) && \
47834973
!defined(WOLFCRYPT_ONLY) && !defined(NO_TLS)
47844974
#error "If TLS is enabled please make sure either client or server is enabled."

0 commit comments

Comments
 (0)