Skip to content

Commit

Permalink
Merge pull request #8262 from embhorn/zd18968
Browse files Browse the repository at this point in the history
Add sanity check for configuration method
  • Loading branch information
JacobBarthelmeh authored Dec 10, 2024
2 parents 67fb29a + ba59f1a commit 0772cf6
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 9 deletions.
File renamed without changes.
1 change: 1 addition & 0 deletions .wolfssl_known_macro_extras
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ WOLFSSL_CLANG_TIDY
WOLFSSL_COMMERCIAL_LICENSE
WOLFSSL_CONTIKI
WOLFSSL_CRL_ALLOW_MISSING_CDP
WOLFSSL_CUSTOM_CONFIG
WOLFSSL_DILITHIUM_ASSIGN_KEY
WOLFSSL_DILITHIUM_MAKE_KEY_SMALL_MEM
WOLFSSL_DILITHIUM_NO_ASN1
Expand Down
2 changes: 1 addition & 1 deletion examples/echoclient/echoclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
#include <config.h>
#endif

#include <wolfssl/wolfcrypt/settings.h>
#ifndef WOLFSSL_USER_SETTINGS
#include <wolfssl/options.h>
#endif
#include <wolfssl/wolfcrypt/settings.h>

/* Force enable the compatibility macros for this example */
#undef TEST_OPENSSL_COEXIST
Expand Down
3 changes: 3 additions & 0 deletions mcapi/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef WOLFSSL_USER_SETTINGS
#include <wolfssl/options.h>
#endif
#include <wolfssl/wolfcrypt/settings.h>

#ifdef MICROCHIP_MPLAB_HARMONY
Expand Down
5 changes: 4 additions & 1 deletion mcapi/mcapi_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@
#include <config.h>
#endif

/* mc api header */
#ifndef WOLFSSL_USER_SETTINGS
#include <wolfssl/options.h>
#endif
#include <wolfssl/wolfcrypt/settings.h>

/* mc api header */
#include "crypto.h"

/* sanity test against our default implementation, wolfssl headers */
Expand Down
6 changes: 0 additions & 6 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,6 @@
* pair
*/


#ifdef EXTERNAL_OPTS_OPENVPN
#error EXTERNAL_OPTS_OPENVPN should not be defined\
when building wolfSSL
#endif

#ifndef WOLFCRYPT_ONLY

#include <wolfssl/internal.h>
Expand Down
3 changes: 3 additions & 0 deletions sslSniffer/sslSnifferTest/snifftest.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#include <config.h>
#endif

#ifndef WOLFSSL_USER_SETTINGS
#include <wolfssl/options.h>
#endif
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/types.h>
#include <wolfssl/wolfcrypt/logging.h>
Expand Down
3 changes: 3 additions & 0 deletions tests/srp.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#include <config.h>
#endif

#ifndef WOLFSSL_USER_SETTINGS
#include <wolfssl/options.h>
#endif
#include <wolfssl/wolfcrypt/settings.h>

#include <tests/unit.h>
Expand Down
2 changes: 1 addition & 1 deletion testsuite/testsuite.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
#include <config.h>
#endif

#include <wolfssl/wolfcrypt/settings.h>
#ifndef WOLFSSL_USER_SETTINGS
#include <wolfssl/options.h>
#endif
#include <wolfssl/wolfcrypt/settings.h>

#undef TEST_OPENSSL_COEXIST /* can't use this option with this example */
#undef OPENSSL_COEXIST /* can't use this option with this example */
Expand Down
14 changes: 14 additions & 0 deletions wolfssl/wolfcrypt/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
*
* ./configure CFLAGS="-DFEATURE_FLAG_TO_DEFINE -UFEATURE_FLAG_TO_CLEAR [...]"
*
* To build using a custom configuration method, define WOLFSSL_CUSTOM_CONFIG
*
* For more information see:
*
* https://www.wolfssl.com/how-do-i-manage-the-build-configuration-of-wolfssl/
Expand Down Expand Up @@ -317,6 +319,12 @@
#endif
#endif

#if (defined(BUILDING_WOLFSSL) && defined(WOLFSSL_USE_OPTIONS_H)) || \
(defined(BUILDING_WOLFSSL) && defined(WOLFSSL_OPTIONS_H) && \
!defined(EXTERNAL_OPTS_OPENVPN))
#error wolfssl/options.h included in compiled wolfssl library object.
#endif

#ifdef WOLFSSL_USER_SETTINGS
#include "user_settings.h"
#elif defined(USE_HAL_DRIVER) && !defined(HAVE_CONFIG_H)
Expand All @@ -326,6 +334,12 @@
/* NOTE: cyassl_nucleus_defs.h is akin to user_settings.h */
#include "nucleus.h"
#include "os/networking/ssl/lite/cyassl_nucleus_defs.h"
#elif !defined(BUILDING_WOLFSSL) && !defined(WOLFSSL_OPTIONS_H) && \
!defined(WOLFSSL_CUSTOM_CONFIG)
/* This warning indicates that the settings header may not be included before
* other wolfSSL headers. If you are using a custom configuration method,
* define WOLFSSL_CUSTOM_CONFIG to override this error. */
#warning "No configuration for wolfSSL detected, check header order"
#endif

#include <wolfssl/wolfcrypt/visibility.h>
Expand Down
4 changes: 4 additions & 0 deletions wolfssl/wolfcrypt/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ decouple library dependencies with standard string, memory and so on.
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/wc_port.h>

#if defined(EXTERNAL_OPTS_OPENVPN) && defined(BUILDING_WOLFSSL)
#error EXTERNAL_OPTS_OPENVPN should not be defined in compiled wolfssl library files.
#endif

#ifdef __APPLE__
#include <AvailabilityMacros.h>
#endif
Expand Down

0 comments on commit 0772cf6

Please sign in to comment.