Skip to content

Commit 26fb139

Browse files
committed
Update naming to be consistent, doc updates per comments
1 parent 0115b55 commit 26fb139

14 files changed

+237
-93
lines changed

docs/FIPS_INTEGRATION_GUIDE.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ For non-FIPS builds and general wolfProvider setup, see the [Integration Guide](
2323

2424
### Patch OpenSSL
2525

26-
Apply FIPS baseline restrictions to your OpenSSL source tree. See [FIPS Baseline Patches](../patches/openssl-fips-baseline/README.md) for detailed options and common errors.
26+
Apply FIPS baseline restrictions to your OpenSSL source tree. This mode disables non-FIPS approved algorithms so one can evaluate their application before integrating wolfProvider. See [FIPS Baseline Patches](../patches/openssl-fips-baseline/README.md) for detailed options and common errors.
2727

2828
```bash
2929
./scripts/patch-openssl-fips.sh --openssl-src=/path/to/openssl-3.x
@@ -50,7 +50,7 @@ openssl list -providers
5050
| Restriction | Requirement |
5151
|-------------|-------------|
5252
| RSA Key Size | 2048 bits minimum |
53-
| SHA1 Signing | Blocked (verification allowed) |
53+
| SHA1 Signing | Blocked for signing (verification and hashing/digests still allowed) |
5454
| ECDSA Curves | P-256, P-384, P-521 only |
5555
| PBKDF2 Password | 14 bytes minimum |
5656
| DH Groups | FFDHE only (no MODP) |
@@ -60,6 +60,9 @@ openssl list -providers
6060
Run your application's test suite against the baseline build. Fix any failures before proceeding.
6161
The goal should be an application test suite that only uses FIPS compliant algorithms.
6262

63+
If you encounter failures, consult the **Common Failures** table below for quick fixes. For additional
64+
assistance, contact [wolfSSL support](mailto:support@wolfssl.com) for consulting.
65+
6366
```bash
6467
# Example tests
6568
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 # Should succeed
@@ -68,16 +71,6 @@ openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:1024 # Should fail
6871
/path/to/your/application/test-suite # Ensure your application test suite works properly
6972
```
7073

71-
### Important Limitations
72-
73-
> **Note:** FIPS baseline testing filters non-approved algorithms at the OpenSSL provider level, but passing these tests does not guarantee full FIPS compliance. You should also review your application for:
74-
>
75-
> - **Inline cryptography** - Custom crypto implementations that don't use OpenSSL APIs
76-
> - **Legacy OpenSSL 1.x APIs** - Some older APIs bypass the provider architecture entirely
77-
> - **Non-provider operations** - Direct calls to low-level OpenSSL functions
78-
>
79-
> A thorough code review is recommended to ensure all cryptographic operations route through OpenSSL's provider interface.
80-
8174
### Common Failures
8275

8376
| Issue | Symptom | Solution |
@@ -88,12 +81,21 @@ openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:1024 # Should fail
8881
| Short PBKDF2 password | `invalid salt length` | Use 14+ byte passwords |
8982
| MODP DH groups | Group not available | Use FFDHE groups |
9083

84+
### Important Limitations
85+
86+
> **Note:** FIPS baseline testing filters non-approved algorithms at the OpenSSL provider level, but passing these tests does not guarantee full FIPS compliance. You should also review your application for:
87+
>
88+
> - **Inline cryptography** - Custom crypto implementations that don't use OpenSSL APIs
89+
> - **Legacy OpenSSL 1.x APIs** - Some older APIs bypass the provider architecture entirely
90+
> - **Non-provider operations** - Direct calls to low-level OpenSSL functions
91+
>
92+
> A thorough code review is recommended to ensure all cryptographic operations route through OpenSSL's provider interface.
93+
9194
---
9295

9396
## Replace Default Mode (Recommended for FIPS)
9497

95-
FIPS certification applies system-wide, meaning all cryptographic operations should use the FIPS-validated module. wolfProvider's replace-default mode ensures this by making wolfProvider the primary cryptographic provider for all OpenSSL operations. In this model it is impossible for an application
96-
to use the default provider, any attempts to do so will yield wolfProvider instead.
98+
FIPS certification applies system-wide, meaning all cryptographic operations should use the FIPS-validated module. wolfProvider's replace-default mode ensures this by making wolfProvider the primary cryptographic provider for all OpenSSL operations. In this model it is impossible for an application to use the default provider, any attempts to do so will yield wolfProvider instead.
9799

98100
**Why use replace-default for FIPS:**
99101
- Ensures all crypto operations use wolfSSL's FIPS-validated implementations
@@ -106,12 +108,12 @@ to use the default provider, any attempts to do so will yield wolfProvider inste
106108

107109
Once baseline testing passes, build wolfProvider with your FIPS bundle. You have two options:
108110

109-
- **Build Script** - A convenience wrapper that fetches dependencies (OpenSSL, wolfSSL) and handles configuration automatically
111+
- **Build Script (Recommended)** - A convenience wrapper that fetches dependencies (OpenSSL, wolfSSL) and handles configuration automatically
110112
- **Manual Build** - Build each component directly using autotools
111113

112114
Choose the approach that fits your workflow.
113115

114-
### Build Script
116+
### Option A: Build Script (Recommended)
115117

116118
The build script (`scripts/build-wolfprovider.sh`) is a convenience wrapper that automates:
117119

docs/INTEGRATION_GUIDE.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,34 @@ See comments in that file for examples.
188188

189189
---
190190

191+
## Verifying Installation
192+
193+
After building and installing wolfProvider, confirm that it is working correctly.
194+
195+
### Check Provider Availability
196+
197+
```bash
198+
openssl list -providers
199+
```
200+
201+
This should list wolfProvider among the available providers.
202+
203+
### Run Unit Tests
204+
205+
```bash
206+
make test
207+
```
208+
209+
### Run Command Line Tests
210+
211+
```bash
212+
./scripts/run-tests.sh
213+
```
214+
215+
If any tests fail, enable debug logging (see the [Debugging](#debugging) section) and review the output for details.
216+
217+
---
218+
191219
## Support
192220

193221
- [GitHub Issues](https://github.com/wolfssl/wolfProvider/issues)

test/standalone/tests/fips_baseline/run.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ echo ""
3535
# Detect FIPS version
3636
FIPS_VERSION="unknown"
3737

38-
# Check if provider output indicates FIPS mode
39-
if ${OPENSSL_BIN} list -providers 2>/dev/null | grep -qi "fips"; then
38+
# Check if provider output indicates FIPS baseline mode
39+
if ${OPENSSL_BIN} list -providers 2>/dev/null | grep -qi "Baseline"; then
4040
FIPS_VERSION="fips"
41-
echo "FIPS provider detected"
41+
echo "FIPS Baseline provider detected"
4242
else
4343
FIPS_VERSION="none"
44-
echo "No FIPS provider detected (running in non-FIPS mode)"
44+
echo "No FIPS Baseline provider detected (running in non-FIPS Baseline mode)"
4545
fi
4646

4747
# Try to get more specific version info from openssl

test/standalone/tests/fips_baseline/test_fips_baseline.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ extern OSSL_PROVIDER *g_default_prov;
3636
extern OSSL_PROVIDER *g_wolfprov;
3737

3838
/* Global library contexts - one for each provider (defined in test_fips_baseline.c) */
39-
extern OSSL_LIB_CTX *g_default_libctx;
40-
extern OSSL_LIB_CTX *g_wolfprov_libctx;
39+
extern OSSL_LIB_CTX *osslLibCtx;
40+
extern OSSL_LIB_CTX *wpLibCtx;
4141

4242
/* Setup and cleanup functions (implemented in test_fips_baseline.c) */
4343
int setup_and_verify_providers(void);
4444
void cleanup_providers(void);
4545

46+
/* FIPS sanity check (implemented in test_fips_baseline_digest.c) */
47+
int test_fips_sanity(void);
48+
4649
/* Digest restriction tests (implemented in test_fips_baseline_digest.c) */
4750
int test_md5_restriction(void);
4851

test/standalone/tests/fips_baseline/test_fips_baseline_ciphers.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ static int test_des_restriction(void)
6868
TEST_INFO(" Testing DES cipher restriction:");
6969

7070
/* Test with wolfProvider */
71-
if (test_cipher_unavailable(g_wolfprov_libctx, "DES-CBC", "wolfProvider") != TEST_SUCCESS) {
71+
if (test_cipher_unavailable(wpLibCtx, "DES-CBC", "wolfProvider") != TEST_SUCCESS) {
7272
TEST_ERROR(" DES restriction test failed for wolfProvider");
7373
return TEST_FAILURE;
7474
}
7575

7676
/* Test with default (baseline) provider */
77-
if (test_cipher_unavailable(g_default_libctx, "DES-CBC", "default (baseline)") != TEST_SUCCESS) {
77+
if (test_cipher_unavailable(osslLibCtx, "DES-CBC", "default (baseline)") != TEST_SUCCESS) {
7878
TEST_ERROR(" DES restriction test failed for default (baseline) provider");
7979
return TEST_FAILURE;
8080
}
@@ -93,13 +93,13 @@ static int test_3des_restriction(void)
9393
TEST_INFO(" Testing 3DES cipher restriction:");
9494

9595
/* Test with wolfProvider */
96-
if (test_cipher_unavailable(g_wolfprov_libctx, "DES-EDE3-CBC", "wolfProvider") != TEST_SUCCESS) {
96+
if (test_cipher_unavailable(wpLibCtx, "DES-EDE3-CBC", "wolfProvider") != TEST_SUCCESS) {
9797
TEST_ERROR(" 3DES restriction test failed for wolfProvider");
9898
return TEST_FAILURE;
9999
}
100100

101101
/* Test with default (baseline) provider */
102-
if (test_cipher_unavailable(g_default_libctx, "DES-EDE3-CBC", "default (baseline)") != TEST_SUCCESS) {
102+
if (test_cipher_unavailable(osslLibCtx, "DES-EDE3-CBC", "default (baseline)") != TEST_SUCCESS) {
103103
TEST_ERROR(" 3DES restriction test failed for default (baseline) provider");
104104
return TEST_FAILURE;
105105
}
@@ -118,13 +118,13 @@ static int test_chacha20_restriction(void)
118118
TEST_INFO(" Testing ChaCha20 cipher restriction:");
119119

120120
/* Test with wolfProvider */
121-
if (test_cipher_unavailable(g_wolfprov_libctx, "ChaCha20", "wolfProvider") != TEST_SUCCESS) {
121+
if (test_cipher_unavailable(wpLibCtx, "ChaCha20", "wolfProvider") != TEST_SUCCESS) {
122122
TEST_ERROR(" ChaCha20 restriction test failed for wolfProvider");
123123
return TEST_FAILURE;
124124
}
125125

126126
/* Test with default (baseline) provider */
127-
if (test_cipher_unavailable(g_default_libctx, "ChaCha20", "default (baseline)") != TEST_SUCCESS) {
127+
if (test_cipher_unavailable(osslLibCtx, "ChaCha20", "default (baseline)") != TEST_SUCCESS) {
128128
TEST_ERROR(" ChaCha20 restriction test failed for default (baseline) provider");
129129
return TEST_FAILURE;
130130
}
@@ -143,13 +143,13 @@ static int test_chacha20_poly1305_restriction(void)
143143
TEST_INFO(" Testing ChaCha20-Poly1305 cipher restriction:");
144144

145145
/* Test with wolfProvider */
146-
if (test_cipher_unavailable(g_wolfprov_libctx, "ChaCha20-Poly1305", "wolfProvider") != TEST_SUCCESS) {
146+
if (test_cipher_unavailable(wpLibCtx, "ChaCha20-Poly1305", "wolfProvider") != TEST_SUCCESS) {
147147
TEST_ERROR(" ChaCha20-Poly1305 restriction test failed for wolfProvider");
148148
return TEST_FAILURE;
149149
}
150150

151151
/* Test with default (baseline) provider */
152-
if (test_cipher_unavailable(g_default_libctx, "ChaCha20-Poly1305", "default (baseline)") != TEST_SUCCESS) {
152+
if (test_cipher_unavailable(osslLibCtx, "ChaCha20-Poly1305", "default (baseline)") != TEST_SUCCESS) {
153153
TEST_ERROR(" ChaCha20-Poly1305 restriction test failed for default (baseline) provider");
154154
return TEST_FAILURE;
155155
}

test/standalone/tests/fips_baseline/test_fips_baseline_dh.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static int test_modp_2048_blocked(void)
126126
TEST_INFO(" Test 1: modp_2048 named group (must be BLOCKED)");
127127

128128
/* wolfProvider should block */
129-
wolf_blocked = (try_dh_named_group(g_wolfprov_libctx, "modp_2048") == 0);
129+
wolf_blocked = (try_dh_named_group(wpLibCtx, "modp_2048") == 0);
130130
TEST_INFO(" [wolfProvider] modp_2048: %s",
131131
wolf_blocked ? "BLOCKED" : "ALLOWED");
132132

@@ -136,7 +136,7 @@ static int test_modp_2048_blocked(void)
136136
}
137137

138138
/* Baseline should also block (after patch) */
139-
baseline_blocked = (try_dh_named_group(g_default_libctx, "modp_2048") == 0);
139+
baseline_blocked = (try_dh_named_group(osslLibCtx, "modp_2048") == 0);
140140
TEST_INFO(" [baseline] modp_2048: %s",
141141
baseline_blocked ? "BLOCKED" : "ALLOWED");
142142

@@ -160,7 +160,7 @@ static int test_small_custom_dh_blocked(void)
160160
TEST_INFO(" Test 2: 1024-bit custom DH keygen (must be BLOCKED)");
161161

162162
/* wolfProvider should block */
163-
wolf_blocked = (try_dh_custom_keygen(g_wolfprov_libctx, 1024) == 0);
163+
wolf_blocked = (try_dh_custom_keygen(wpLibCtx, 1024) == 0);
164164
TEST_INFO(" [wolfProvider] 1024-bit custom DH: %s",
165165
wolf_blocked ? "BLOCKED" : "ALLOWED");
166166

@@ -170,7 +170,7 @@ static int test_small_custom_dh_blocked(void)
170170
}
171171

172172
/* Baseline should also block (after patch) */
173-
baseline_blocked = (try_dh_custom_keygen(g_default_libctx, 1024) == 0);
173+
baseline_blocked = (try_dh_custom_keygen(osslLibCtx, 1024) == 0);
174174
TEST_INFO(" [baseline] 1024-bit custom DH: %s",
175175
baseline_blocked ? "BLOCKED" : "ALLOWED");
176176

@@ -200,7 +200,7 @@ static int test_ffdhe2048_allowed(void)
200200
TEST_INFO(" Test 3: ffdhe2048 named group (must be ALLOWED)");
201201

202202
/* wolfProvider should allow */
203-
wolf_allowed = (try_dh_named_group(g_wolfprov_libctx, "ffdhe2048") == 1);
203+
wolf_allowed = (try_dh_named_group(wpLibCtx, "ffdhe2048") == 1);
204204
TEST_INFO(" [wolfProvider] ffdhe2048: %s",
205205
wolf_allowed ? "ALLOWED" : "BLOCKED");
206206

@@ -210,7 +210,7 @@ static int test_ffdhe2048_allowed(void)
210210
}
211211

212212
/* Baseline should also allow */
213-
baseline_allowed = (try_dh_named_group(g_default_libctx, "ffdhe2048") == 1);
213+
baseline_allowed = (try_dh_named_group(osslLibCtx, "ffdhe2048") == 1);
214214
TEST_INFO(" [baseline] ffdhe2048: %s",
215215
baseline_allowed ? "ALLOWED" : "BLOCKED");
216216

test/standalone/tests/fips_baseline/test_fips_baseline_digest.c

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,96 @@
2626

2727
#include "test_fips_baseline.h"
2828

29+
/**
30+
* Test that a basic FIPS-approved operation (SHA-256 digest) works.
31+
* This provides a positive sanity check before running restriction tests.
32+
*
33+
* @param libctx Library context with provider loaded
34+
* @param desc Description for logging
35+
* @return TEST_SUCCESS if SHA-256 works, TEST_FAILURE otherwise.
36+
*/
37+
static int test_sha256_available(OSSL_LIB_CTX *libctx, const char *desc)
38+
{
39+
EVP_MD *sha256 = NULL;
40+
EVP_MD_CTX *mdctx = NULL;
41+
unsigned char digest[EVP_MAX_MD_SIZE];
42+
unsigned int digest_len = 0;
43+
const char *test_data = "FIPS sanity check test data";
44+
int ret = TEST_FAILURE;
45+
46+
TEST_INFO(" Testing with %s...", desc);
47+
48+
sha256 = EVP_MD_fetch(libctx, "SHA256", NULL);
49+
if (sha256 == NULL) {
50+
TEST_ERROR(" ✗ SHA-256 is unavailable (should be available in FIPS)");
51+
ERR_clear_error();
52+
goto cleanup;
53+
}
54+
55+
mdctx = EVP_MD_CTX_new();
56+
if (mdctx == NULL) {
57+
TEST_ERROR(" ✗ Failed to create EVP_MD_CTX");
58+
goto cleanup;
59+
}
60+
61+
if (EVP_DigestInit_ex(mdctx, sha256, NULL) != 1) {
62+
TEST_ERROR(" ✗ SHA-256 DigestInit failed");
63+
ERR_clear_error();
64+
goto cleanup;
65+
}
66+
67+
if (EVP_DigestUpdate(mdctx, test_data, strlen(test_data)) != 1) {
68+
TEST_ERROR(" ✗ SHA-256 DigestUpdate failed");
69+
ERR_clear_error();
70+
goto cleanup;
71+
}
72+
73+
if (EVP_DigestFinal_ex(mdctx, digest, &digest_len) != 1) {
74+
TEST_ERROR(" ✗ SHA-256 DigestFinal failed");
75+
ERR_clear_error();
76+
goto cleanup;
77+
}
78+
79+
if (digest_len != 32) {
80+
TEST_ERROR(" ✗ SHA-256 digest length is %u (expected 32)", digest_len);
81+
goto cleanup;
82+
}
83+
84+
TEST_INFO(" ✓ SHA-256 digest works correctly (len=%u)", digest_len);
85+
ret = TEST_SUCCESS;
86+
87+
cleanup:
88+
EVP_MD_CTX_free(mdctx);
89+
EVP_MD_free(sha256);
90+
return ret;
91+
}
92+
93+
/**
94+
* FIPS sanity check: verify that SHA-256 (a FIPS-approved algorithm) works
95+
* with both providers before testing restrictions.
96+
*
97+
* @return TEST_SUCCESS if both providers support SHA-256, TEST_FAILURE otherwise.
98+
*/
99+
int test_fips_sanity(void)
100+
{
101+
TEST_INFO("Testing FIPS sanity (SHA-256 should work with both providers):");
102+
103+
/* Test with wolfProvider */
104+
if (test_sha256_available(wpLibCtx, "wolfProvider") != TEST_SUCCESS) {
105+
TEST_ERROR("FIPS sanity check failed for wolfProvider");
106+
return TEST_FAILURE;
107+
}
108+
109+
/* Test with default (baseline) provider */
110+
if (test_sha256_available(osslLibCtx, "default (baseline)") != TEST_SUCCESS) {
111+
TEST_ERROR("FIPS sanity check failed for default (baseline) provider");
112+
return TEST_FAILURE;
113+
}
114+
115+
TEST_INFO("✓ Both providers support SHA-256 (FIPS sanity check passed)");
116+
return TEST_SUCCESS;
117+
}
118+
29119
/**
30120
* Test that MD5 digest is unavailable in FIPS mode.
31121
*
@@ -66,13 +156,13 @@ int test_md5_restriction(void)
66156
TEST_INFO("Testing MD5 restriction with both providers:");
67157

68158
/* Test with wolfProvider */
69-
if (test_md5_unavailable(g_wolfprov_libctx, "wolfProvider") != TEST_SUCCESS) {
159+
if (test_md5_unavailable(wpLibCtx, "wolfProvider") != TEST_SUCCESS) {
70160
TEST_ERROR("MD5 restriction test failed for wolfProvider");
71161
return TEST_FAILURE;
72162
}
73163

74164
/* Test with default (baseline) provider */
75-
if (test_md5_unavailable(g_default_libctx, "default (baseline)") != TEST_SUCCESS) {
165+
if (test_md5_unavailable(osslLibCtx, "default (baseline)") != TEST_SUCCESS) {
76166
TEST_ERROR("MD5 restriction test failed for default (baseline) provider");
77167
return TEST_FAILURE;
78168
}

0 commit comments

Comments
 (0)