@@ -713,14 +713,24 @@ else
713713 if test "x$ENABLED_FWTPM" = "xyes" && \
714714 test "x$ENABLED_WOLFCRYPT" = "xyes"
715715 then
716- AC_CHECK_HEADER ( [ wolfssl/wolfcrypt/dilithium.h] ,
717- [ WOLFTPM_HAVE_DILITHIUM_H=yes] ,
718- [ WOLFTPM_HAVE_DILITHIUM_H=no] )
719- AC_CHECK_HEADER ( [ wolfssl/wolfcrypt/mlkem.h] ,
720- [ WOLFTPM_HAVE_MLKEM_H=yes] ,
721- [ WOLFTPM_HAVE_MLKEM_H=no] )
722- if test "x$WOLFTPM_HAVE_DILITHIUM_H" = "xyes" && \
723- test "x$WOLFTPM_HAVE_MLKEM_H" = "xyes"
716+ # Probe the actual symbols, not just the headers. wolfSSL ships
717+ # dilithium.h / mlkem.h even without the implementation compiled
718+ # (function decls are gated behind HAVE_DILITHIUM / HAVE_MLKEM
719+ # which only get defined via wolfssl/options.h after the right
720+ # --enable-* flags). Include options.h first so the gate is set
721+ # before the header decls are parsed.
722+ AC_CHECK_DECL ( [ wc_dilithium_init] ,
723+ [ WOLFTPM_HAVE_DILITHIUM_FN=yes] ,
724+ [ WOLFTPM_HAVE_DILITHIUM_FN=no] ,
725+ [ [ #include <wolfssl/options.h>
726+ #include <wolfssl/wolfcrypt/dilithium.h>] ] )
727+ AC_CHECK_DECL ( [ wc_MlKemKey_Init] ,
728+ [ WOLFTPM_HAVE_MLKEM_FN=yes] ,
729+ [ WOLFTPM_HAVE_MLKEM_FN=no] ,
730+ [ [ #include <wolfssl/options.h>
731+ #include <wolfssl/wolfcrypt/mlkem.h>] ] )
732+ if test "x$WOLFTPM_HAVE_DILITHIUM_FN" = "xyes" && \
733+ test "x$WOLFTPM_HAVE_MLKEM_FN" = "xyes"
724734 then
725735 AC_MSG_NOTICE ( [ wolfCrypt ML-DSA + ML-KEM detected; auto-enabling --enable-v185 (use --disable-v185 or --disable-pqc to opt out)] )
726736 ENABLED_V185=yes
734744
735745if test "x$ENABLED_V185" = "xyes"
736746then
737- # When the user opted in explicitly we have not probed yet; verify the
738- # wolfSSL PQC headers are present so the build fails at configure time
739- # rather than deep inside the compile with a cryptic error.
740- AC_CHECK_HEADER ( [ wolfssl/wolfcrypt/dilithium.h] , [ ] ,
741- [ AC_MSG_ERROR ( [ --enable-v185/--enable-pqc requires wolfSSL built with --enable-dilithium --enable-experimental] ) ] )
742- AC_CHECK_HEADER ( [ wolfssl/wolfcrypt/mlkem.h] , [ ] ,
743- [ AC_MSG_ERROR ( [ --enable-v185/--enable-pqc requires wolfSSL built with --enable-mlkem --enable-experimental] ) ] )
747+ # Explicit opt-in: re-probe so we fail at configure time (with a
748+ # clear hint about wolfSSL flags) rather than deep inside the compile
749+ # with a cryptic error. Header existence alone is not enough -- the
750+ # actual functions must be declared (gated by HAVE_DILITHIUM /
751+ # HAVE_MLKEM in wolfssl/options.h).
752+ AC_CHECK_DECL ( [ wc_dilithium_init] , [ ] ,
753+ [ AC_MSG_ERROR ( [ --enable-v185/--enable-pqc requires wolfSSL built with --enable-dilithium --enable-experimental] ) ] ,
754+ [ [ #include <wolfssl/options.h>
755+ #include <wolfssl/wolfcrypt/dilithium.h>] ] )
756+ AC_CHECK_DECL ( [ wc_MlKemKey_Init] , [ ] ,
757+ [ AC_MSG_ERROR ( [ --enable-v185/--enable-pqc requires wolfSSL built with --enable-mlkem --enable-experimental] ) ] ,
758+ [ [ #include <wolfssl/options.h>
759+ #include <wolfssl/wolfcrypt/mlkem.h>] ] )
744760 AM_CFLAGS="$AM_CFLAGS -DWOLFTPM_V185"
745761fi
746762AM_CONDITIONAL([ BUILD_V185] , [ test "x$ENABLED_V185" = "xyes"] )
0 commit comments