Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 63 additions & 9 deletions IDE/WINVS/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ Four configurations, x64 only:
| `Static Debug\|x64` | same, debug CRT |

The static library exists only so the unit tests can link wolfProvider
internals. A `.lib` cannot act as a provider: OpenSSL loads one with
`LoadLibraryA` followed by a lookup of `OSSL_provider_init`.
internals. A `.lib` cannot act as a provider.


Prerequisites
Expand All @@ -25,6 +24,9 @@ Prerequisites
- Visual Studio 2022 with the C++ toolset (v143) and MASM (`ml64.exe`).
- Perl, NASM and git, to build OpenSSL. Strawberry Perl includes NASM.

Run everything below from an x64 Native Tools Command Prompt, or after
`vcvars64.bat`. `msbuild` and `nmake` are not on `PATH` otherwise.

No `configure` step is involved anywhere on Windows.


Expand Down Expand Up @@ -52,6 +54,9 @@ Building
perl Configure VC-WIN64A shared no-tests --prefix=C:\out\openssl --openssldir=C:\out\openssl\ssl
nmake
nmake install_sw
nmake install_ssldirs

`install_sw` alone does not write `openssl.cnf`.

Two paths come out of this and they are not interchangeable. The **build tree**
(`C:\src\openssl`) is `openSslDir` and must hold `libcrypto.lib` directly. The
Expand Down Expand Up @@ -89,9 +94,21 @@ does not add the module's own directory to the search path, so **putting
`wolfssl.dll` beside `libwolfprov.dll` does not work.** Put it on the loading
process's `PATH`:

$env:PATH = "C:\src\wolfssl\DLL Release\x64;$env:PATH"
set "PATH=C:\src\wolfssl\DLL Release\x64;C:\out\openssl\bin;%PATH%"
openssl list -providers -provider-path "C:\src\wolfProvider\IDE\WINVS\DLL Release\x64" -provider libwolfprov

Under FIPS the dependency is `wolfssl-fips.dll`, inside the bundle:

set "PATH=C:\src\wolfssl-fips\IDE\WIN10\DLL Release\x64;C:\out\openssl\bin;%PATH%"

In `openssl.cnf`, use forward slashes in the `module` path.

The module is `libwolfprov` but the property it registers is `provider=wolfprov`
(plus `fips=yes` under FIPS):

openssl dgst -sha256 -provider-path "...\DLL Release\x64" ^
-provider libwolfprov -propquery "provider=wolfprov" file.bin


User macros
-----------
Expand All @@ -113,25 +130,62 @@ FIPS
----

A FIPS build is wolfSSL's standard Windows FIPS procedure, then wolfProvider
pointed at the bundle. wolfSSL is linked **shared**, including FIPS; the module
passes its in-core integrity check that way.
pointed at the bundle. Unpack it alongside the other trees; the commands below
assume `C:\src\wolfssl-fips`. `DLL Release|x64` and `DLL Debug|x64` are the
approved FIPS configurations.

Enable FIPS near the top of the bundle's `IDE\WIN10\user_settings.h`. For a
commercial bundle, enable the block for the module shipped in that bundle and
keep its supplied `HAVE_FIPS_VERSION` and related version macros. For FIPS
Ready, enable the bundle's FIPS Ready selector (`WOLFSSL_FIPS_READY` where
supplied).

Copy `user_settings-fips.h` from this directory next to it and include it after
the `#endif` closing `_WIN_USER_SETTINGS_H_`:

#include "user_settings-fips.h"

Build the FIPS DLL and the test app that reports its hash. Both are pinned to
`v110`, so retarget on the command line, and name the `.vcxproj` files rather
than `wolfssl-fips.sln`, which MSBuild 17 cannot load (`MSB4025`).

cd C:\src\wolfssl-fips\IDE\WIN10
msbuild wolfssl-fips.vcxproj /p:Configuration="DLL Release" /p:Platform=x64 ^
/p:PlatformToolset=v143 /p:WindowsTargetPlatformVersion=10.0
msbuild test.vcxproj /p:Configuration="DLL Release" /p:Platform=x64 ^
/p:PlatformToolset=v143 /p:WindowsTargetPlatformVersion=10.0

Leave the project's optimiser and linker settings as shipped.

Run `test.exe` from `DLL Release\x64\`. Paste the hash it prints into
`verifyCore` in `wolfcrypt\src\fips_test.c`, rebuild `wolfssl-fips.vcxproj` and
rerun `test.exe` to confirm it passes. The hash covers only the wolfSSL DLL, so
rebuilding wolfProvider never invalidates it.

Then build wolfProvider against the bundle, from the wolfProvider root:

cd C:\src\wolfProvider
msbuild IDE\WINVS\wolfprovider.sln /p:Configuration="DLL Release" /p:Platform=x64 ^
/p:wolfCryptDir="C:\src\wolfssl-fips" ^
/p:userSettingsDir="C:\src\wolfssl-fips\IDE\WIN10" ^
/p:wolfCryptDllRelease64="C:\src\wolfssl-fips\IDE\WIN10\DLL Release\x64" ^
/p:wolfSslLib=wolfssl-fips.lib

wolfSSL and wolfProvider must compile against the **same** `user_settings.h`, so
`userSettingsDir` points at the bundle's copy. A layout-changing macro going
asymmetric between the two builds is silent and fatal.
Both builds must compile against the same `user_settings.h`, which is why
`userSettingsDir` points at the bundle's copy.

For `DLL Debug`, replace `DLL Release` with `DLL Debug` throughout and pass
`wolfCryptDllDebug64` in place of `wolfCryptDllRelease64`. The Debug DLL has its
own `verifyCore` hash.


Unit tests
----------

Build `Static Release|x64` and run `IDE\WINVS\Static Release\x64\unit-test.exe`
with the wolfSSL and OpenSSL DLL directories on `PATH`. `WP_UNIT_STATIC_PROVIDER`
with the wolfSSL DLL directory and `C:\out\openssl\bin` on `PATH`. Against a
FIPS bundle pass the same overrides as the provider build, `wolfCryptDllRelease64`
included; the Static configurations link it too. `WP_UNIT_STATIC_PROVIDER`
is defined in the Static configurations only, so the test registers the linked-in
provider instead of loading the DLL; defining it elsewhere would put two copies
of wolfProvider in one process.
Expand Down
1 change: 1 addition & 0 deletions IDE/WINVS/include.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

EXTRA_DIST+= IDE/WINVS/README.md
EXTRA_DIST+= IDE/WINVS/user_settings.h
EXTRA_DIST+= IDE/WINVS/user_settings-fips.h
EXTRA_DIST+= IDE/WINVS/wolfprovider.sln
EXTRA_DIST+= IDE/WINVS/wolfprovider.props
EXTRA_DIST+= IDE/WINVS/wolfprovider/wolfprovider.vcxproj
Expand Down
68 changes: 68 additions & 0 deletions IDE/WINVS/user_settings-fips.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* user_settings-fips.h
*
* Copyright (C) 2006-2026 wolfSSL Inc.
*
* This file is part of wolfProvider.
*
* wolfProvider is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* wolfProvider is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with wolfProvider. If not, see <http://www.gnu.org/licenses/>.
*/

/* What configure supplies for a wolfSSL FIPS build on Linux. Include this at the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add configuration-contract coverage for the FIPS overlay

The new overlay controls ABI-affecting sp_int layout and version-dependent feature gates, but the PR adds no automated check that includes it under representative commercial and FIPS Ready macro sets. Manual Windows build instructions do not detect missing or incorrectly advertised features before release.

Suggested fix: Add a preprocessor configuration test for representative FIPS versions, plus interoperability coverage for RSA-PSS automatic salt verification and the expected DH property registration.

* end of the bundle's IDE\WIN10\user_settings.h -- wolfSSL and wolfProvider must
* compile against the same one. */

#ifndef WOLFPROV_USER_SETTINGS_FIPS_H
#define WOLFPROV_USER_SETTINGS_FIPS_H

#ifndef HAVE_FIPS
#error "Enable FIPS in user_settings.h before including user_settings-fips.h"
#endif

/* The bundle enables this under HAVE_FIPS; configure does not. */
#undef OPENSSL_EXTRA

/* --enable-opensslcoexist */
#define OPENSSL_COEXIST
#define NO_OLD_WC_NAMES
#define NO_OLD_SSL_NAMES
#define NO_OLD_SHA_NAMES
#define NO_OLD_MD5_NAME

/* wolfProvider hardcodes the old OID values. */
#define WOLFSSL_OLD_OID_SUM

/* Match --enable-dh. wolfCrypt requires an explicit opt-in for FIPS v7+. */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do not advertise out-of-boundary DH as FIPS approved

These settings force DH on for FIPS v7 and enable it at runtime, although wolfSSL documents DH as outside the v7 FIPS module boundary. In a HAVE_FIPS build, src/wp_wolfprov.c registers every enabled implementation with provider=wolfprov,fips=yes; therefore the newly enabled DH key-management and key-exchange implementations are returned for fips=yes queries despite being outside the validated module. Applications relying on that property can unknowingly perform a non-validated DH operation.

Suggested fix: For FIPS v7, either leave DH disabled or register the outside-boundary DH implementations without fips=yes; confirm the selected behavior against each bundle's Security Policy.
Basis: OpenSSL OSSL_PROVIDER-FIPS(7) defines fips=yes as selecting FIPS-approved implementations, while wolfSSL's FIPS v7 documentation states that DH is outside the FIPS module boundary.

#undef NO_DH
#ifndef HAVE_DH
#define HAVE_DH
#endif
#define WOLFSSL_DH_EXTRA
/* A FIPS Ready build can select v7 after reading user_settings.h. */
#if defined(WOLFSSL_FIPS_READY) || \
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 7))
#undef WC_DH_INITIAL_RUNTIME_ENABLEMENT
#define WC_DH_INITIAL_RUNTIME_ENABLEMENT 1
#endif

/* Required for RSA_PSS_SALTLEN_MAX. */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Enable automatic RSA-PSS salt discovery

The new overlay defines WOLFSSL_PSS_LONG_SALT but omits WOLFSSL_PSS_SALT_LEN_DISCOVER, even though wolfSSL's --enable-wolfprovider configuration and the existing Windows provider settings define both. Consequently, wp_pss_salt_len_to_wc() converts OpenSSL's RSA_PSS_SALTLEN_AUTO to the mathematical maximum rather than RSA_PSS_SALT_LEN_DISCOVER. Verification then rejects valid OpenSSL-generated signatures using a non-maximum salt, including the common digest-length salt. This leaves the Windows FIPS build with the RSA-PSS interoperability failure the PR is intended to fix.

Suggested fix: Define WOLFSSL_PSS_SALT_LEN_DISCOVER and verify an OpenSSL-generated RSA-PSS signature with RSA_PSS_SALTLEN_AUTO using a digest-length salt.
Basis: wolfSSL manual, WOLFSSL_PSS_SALT_LEN_DISCOVER: the macro makes RSA-PSS verification recover the salt length from the encoded padding instead of requiring a caller-supplied length.

Suggestion:

Suggested change
/* Required for RSA_PSS_SALTLEN_MAX. */
/* Required for RSA_PSS_SALTLEN_MAX and automatic salt discovery. */
#define WOLFSSL_PSS_LONG_SALT
#define WOLFSSL_PSS_SALT_LEN_DISCOVER

#define WOLFSSL_PSS_LONG_SALT

/* Match the FIPS SP math build's sp_int layout after clearing OPENSSL_EXTRA. */
#define WOLFSSL_SP_INT_NEGATIVE

#ifdef _M_X64
#define WOLFSSL_X86_64_BUILD
Comment thread
aidangarske marked this conversation as resolved.
Resolved
#endif

#endif /* WOLFPROV_USER_SETTINGS_FIPS_H */
Loading