1- # CMakeList .txt
1+ # CMakeLists .txt
22#
3- # Copyright (C) 2006-2023 wolfSSL Inc.
3+ # Copyright (C) 2006-2024 wolfSSL Inc.
44#
55# This file is part of wolfSSL. (formerly known as CyaSSL)
66#
@@ -539,16 +539,89 @@ add_option(WOLFSSL_OQS
539539 "Enable integration with the OQS (Open Quantum Safe) liboqs library (default: disabled)"
540540 "no" "yes;no" )
541541
542- if (WOLFSSL_OQS)
543- find_package (OQS )
542+ # Kyber
543+ add_option (WOLFSSL_KYBER
544+ "Enable the wolfSSL PQ Kyber library (default: disabled)"
545+ "no" "yes;no" )
544546
545- if (OQS_FOUND)
546- list (APPEND WOLFSSL_LINK_LIBS ${OQS_LIBRARY} )
547- list (APPEND WOLFSSL_INCLUDE_DIRS ${OQS_INCLUDE_DIR} )
548- set (HAVE_LIBOQS 1)
549- list (APPEND WOLFSSL_DEFINITIONS
550- "-DHAVE_TLS_EXTENSIONS"
551- "-DHAVE_LIBOQS" )
547+ # Experimental features
548+ add_option (WOLFSSL_EXPERIMENTAL
549+ "Enable experimental features (default: disabled)"
550+ "no" "yes;no" )
551+
552+ message (STATUS "Looking for WOLFSSL_EXPERIMENTAL" )
553+ if (WOLFSSL_EXPERIMENTAL)
554+ message (STATUS "Looking for WOLFSSL_EXPERIMENTAL - found" )
555+
556+ # We've enabled the experimental environment, but let's
557+ # check if any experimental features are also enabled:
558+ set (WOLFSSL_FOUND_EXPERIMENTAL_FEATURE 0)
559+
560+ set_wolfssl_definitions ("WOLFSSL_EXPERIMENTAL_SETTINGS" RESUlT )
561+
562+ # Checking for experimental feature: OQS
563+ message (STATUS "Looking for WOLFSSL_OQS" )
564+ if (WOLFSSL_OQS)
565+ set (WOLFSSL_FOUND_EXPERIMENTAL_FEATURE 1)
566+ message (STATUS "Looking for WOLFSSL_OQS - found" )
567+
568+ message (STATUS "Checking OQS" )
569+ find_package (OQS )
570+ if (OQS_FOUND)
571+ message (STATUS "Checking OQS - found" )
572+ list (APPEND WOLFSSL_LINK_LIBS ${OQS_LIBRARY} )
573+ list (APPEND WOLFSSL_INCLUDE_DIRS ${OQS_INCLUDE_DIR} )
574+
575+ set_wolfssl_definitions ("HAVE_LIBOQS" RESUlT )
576+ set_wolfssl_definitions ("HAVE_TLS_EXTENSIONS" RESUlT )
577+ set_wolfssl_definitions ("OPENSSL_EXTRA" RESUlT )
578+
579+ else ()
580+ message (STATUS "Checking OQS - not found" )
581+ message (STATUS "WARNING: WOLFSSL_OQS enabled but not found: OQS_LIBRARY=${OQS_LIBRARY} , OQS_INCLUDE_DIR=${OQS_INCLUDE_DIR} " )
582+ endif ()
583+ else ()
584+ message (STATUS "Looking for WOLFSSL_OQS - not found" )
585+ endif ()
586+
587+ # Checking for experimental feature: Kyber
588+ message (STATUS "Looking for WOLFSSL_KYBER" )
589+ if (WOLFSSL_KYBER)
590+ set (WOLFSSL_FOUND_EXPERIMENTAL_FEATURE 1)
591+
592+ message (STATUS "Automatically set related requirements for Kyber:" )
593+ set_wolfssl_definitions ("WOLFSSL_HAVE_KYBER" RESUlT )
594+ set_wolfssl_definitions ("WOLFSSL_WC_KYBER" RESUlT )
595+ set_wolfssl_definitions ("WOLFSSL_SHA3" RESUlT )
596+ set_wolfssl_definitions ("WOLFSSL_SHAKE128" RESUlT )
597+ set_wolfssl_definitions ("WOLFSSL_SHAKE256" RESUlT )
598+ message (STATUS "Looking for WOLFSSL_KYBER - found" )
599+ else ()
600+ message (STATUS "Looking for WOLFSSL_KYBER - not found" )
601+ endif ()
602+
603+ # Other experimental feature detection can be added here...
604+
605+ # Were any experimental features found? Display a message.
606+ if (WOLFSSL_FOUND_EXPERIMENTAL_FEATURE)
607+ message (STATUS "WOLFSSL_EXPERIMENTAL enabled, experimental features enabled." )
608+ else ()
609+ message (STATUS "Warning: WOLFSSL_EXPERIMENTAL enabled, but no experimental features enabled." )
610+ endif ()
611+
612+ # Sanity checks
613+ if (WOLFSSL_OQS AND WOLFSSL_KYBER)
614+ message (FATAL_ERROR "Error: cannot enable both WOLFSSL_OQS and WOLFSSL_KYBER at the same time." )
615+ endif ()
616+
617+ else ()
618+ # Experimental mode not enabled, but were any experimental features enabled? Error out if so:
619+ message (STATUS "Looking for WOLFSSL_EXPERIMENTAL - not found" )
620+ if (WOLFSSL_OQS)
621+ message (FATAL_ERROR "Error: WOLFSSL_OQS requires WOLFSSL_EXPERIMENTAL at this time." )
622+ endif ()
623+ if (WOLFSSL_KYBER)
624+ message (FATAL_ERROR "Error: WOLFSSL_KYBER requires WOLFSSL_EXPERIMENTAL at this time." )
552625 endif ()
553626endif ()
554627
@@ -565,6 +638,9 @@ endif()
565638# - Atomic user record layer
566639# - Public key callbacks
567640# - Microchip/Atmel CryptoAuthLib
641+ # - XMSS
642+ # - LMS
643+ # - dual-certs
568644
569645# AES-CBC
570646add_option ("WOLFSSL_AESCBC"
0 commit comments