Skip to content

fips: define DH_MIN_SIZE for the FIPS PILOT build#425

Open
aidangarske wants to merge 3 commits into
masterfrom
fips-pilot-dh-min-size
Open

fips: define DH_MIN_SIZE for the FIPS PILOT build#425
aidangarske wants to merge 3 commits into
masterfrom
fips-pilot-dh-min-size

Conversation

@aidangarske

Copy link
Copy Markdown
Member

Description

The FIPS PILOT build (--enable-fips=v5, fips-check-PILOT.sh) fails to compile:

wolfcrypt/src/dh.c: 'DH_MIN_SIZE' undeclared (first use in this function)
    if (mp_count_bits(&key->p) < DH_MIN_SIZE)   // GeneratePrivateDh / GeneratePublicDh / wc_DhAgree_Sync

Root cause

The PILOT builds BASE_TAG=v5.2.1-stable and overlays FIPS-module crypto files.
The module dh.c now carries a < DH_MIN_SIZE bounds check, but the
v5.2.1-stable base settings.h predates the DH_MIN_SIZE definition (added to
wolfSSL master only recently), so the symbol is undeclared in that build.

The PILOT runs ./configure --enable-fips=$FIPS_OPTION with no CFLAGS, so the
build inherits flags from the environment.

Fix

Supply the FIPS DH_MIN_SIZE value (2048, matching master's settings.h
HAVE_FIPS branch) via CPPFLAGS, scoped to the PILOT invocation. CPPFLAGS
(not CFLAGS) is used so autoconf's default -g -O2 is preserved — important so
the FIPS in-core integrity hash is computed against the normal optimized build.

Scoped to the PILOT path only; the linuxv5.*/linuxv6.* bundles are
self-consistent and unaffected.

Copilot AI review requested due to automatic review settings July 1, 2026 23:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a build break in the FIPS PILOT flow by ensuring DH_MIN_SIZE is defined when building older v5.x FIPS bases that don’t provide the macro in their settings.h, while preserving the optimized build settings required for the FIPS integrity hash.

Changes:

  • Adds a scoped CPPFLAGS define (-DDH_MIN_SIZE=2048) to the fips-check-PILOT.sh invocation path to avoid DH_MIN_SIZE being undeclared during compilation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/utils-wolfssl.sh Outdated
@aidangarske aidangarske force-pushed the fips-pilot-dh-min-size branch from ef19f24 to f43d9ef Compare July 2, 2026 00:00
@aidangarske aidangarske force-pushed the fips-pilot-dh-min-size branch from f43d9ef to d54e893 Compare July 2, 2026 16:02
Comment thread scripts/utils-wolfssl.sh
if [ "$fips_check_script" = "fips-check-PILOT.sh" ]; then
# PILOT script has different usage: [flavor] [keep]
LD_LIBRARY_PATH="" ./$fips_check_script "$fips_tag" keep >$LOG_FILE 2>&1
# v5.2.1 FIPS base predates DH_MIN_SIZE; add it to the FIPS wolfSSL build only - WOLFSSL_CONFIG_CFLAGS feeds the XXX-fips-test rebuilds, CPPFLAGS the PILOT's own configure.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this comment is quite long

Comment thread test/test_rsa.c
const int newKeySize = 3072;
const int badKeyGenSizes[] = {512, 1024};
/* FIPS 186 requires the RSA public exponent >= 65537; e=3 is rejected. */
const long newKeyExp = 65537;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be useful to check other values here to confirm the fix. Eg:

const int badKeyGenExps[] =  {3, 65535};

And maybe check another good value too, eg 65539.

Edit: maybe this belongs in wolfcrypt (as well?). AI tells me that there is no "too small" test there either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants