Skip to content

Commit 65953c2

Browse files
committed
PQC: address review nits (drop experimental mentions, early-return inits)
1 parent ec3e26d commit 65953c2

5 files changed

Lines changed: 19 additions & 30 deletions

File tree

docs/INTEGRATION_GUIDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ sudo make install
8383
| `--enable-pwdbased` | PKCS#12 support |
8484
| `--enable-hmac-copy` | Faster repeated HMAC with same key (wolfSSL 5.7.8+) |
8585
| `--enable-sp=yes,asm --enable-sp-math-all` | SP Integer maths |
86-
| `--enable-mlkem --enable-mldsa` | ML-KEM and ML-DSA post-quantum algorithms (wolfSSL post-v5.9.1-stable). The `build-wolfprovider.sh --enable-pqc` flag sets these automatically. Neither algorithm requires `--enable-experimental`. |
86+
| `--enable-mlkem --enable-mldsa` | ML-KEM and ML-DSA post-quantum algorithms (wolfSSL post-v5.9.1-stable). The `build-wolfprovider.sh --enable-pqc` flag sets these automatically. |
8787

8888
**Optional CPPFLAGS:**
8989

@@ -175,7 +175,7 @@ ML-DSA uses pure mode with an empty context string (FIPS 204 sec 5.2, Algorithm
175175
./scripts/build-wolfprovider.sh --enable-pqc
176176
```
177177

178-
This adds `--enable-mlkem --enable-mldsa` to the wolfSSL configure step (neither flag requires `--enable-experimental`). wolfProvider auto-detects the resulting `WOLFSSL_HAVE_MLKEM` / `WOLFSSL_HAVE_MLDSA` macros via `include/wolfprovider/settings.h` (gated on `__has_include` of `<wolfssl/wolfcrypt/wc_mlkem.h>` / `<wolfssl/wolfcrypt/wc_mldsa.h>`) and registers the six PQC algorithms.
178+
This adds `--enable-mlkem --enable-mldsa` to the wolfSSL configure step. wolfProvider auto-detects the resulting `WOLFSSL_HAVE_MLKEM` / `WOLFSSL_HAVE_MLDSA` macros via `include/wolfprovider/settings.h` (gated on `__has_include` of `<wolfssl/wolfcrypt/wc_mlkem.h>` / `<wolfssl/wolfcrypt/wc_mldsa.h>`) and registers the six PQC algorithms.
179179

180180
### Usage Example
181181

include/wolfprovider/settings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
#ifdef HAVE_ED448
170170
#define WP_HAVE_ED448
171171
#endif
172-
/* PQC: gate on both the wolfSSL feature macro AND header availability. The
172+
/* Gate on both the wolfSSL feature macro AND header availability. The
173173
* canonical post-rename names (WOLFSSL_HAVE_MLKEM / WOLFSSL_HAVE_MLDSA and
174174
* wc_mlkem.h / wc_mldsa.h) are required. Older wolfSSL releases that only
175175
* exposed the pre-standardization names (HAVE_DILITHIUM, dilithium.h) are

scripts/utils-wolfssl.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ if [ "$WOLFPROV_SEED_SRC" = "1" ]; then
3939
fi
4040

4141
# Enable ML-KEM and ML-DSA in wolfSSL when --enable-pqc is requested.
42-
# Use the canonical FIPS 203 / FIPS 204 flag names. Neither algorithm
43-
# requires --enable-experimental anymore.
42+
# Use the canonical FIPS 203 / FIPS 204 flag names.
4443
if [ "$WOLFPROV_PQC" = "1" ]; then
4544
WOLFSSL_CONFIG_OPTS="${WOLFSSL_CONFIG_OPTS} --enable-mlkem --enable-mldsa"
4645
fi

src/wp_mldsa_sig.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -220,31 +220,25 @@ static wp_MlDsaSigCtx* wp_mldsa_dupctx(wp_MlDsaSigCtx* srcCtx)
220220
static int wp_mldsa_init(wp_MlDsaSigCtx* ctx, wp_MlDsa* mldsa,
221221
const OSSL_PARAM params[])
222222
{
223-
int ok = 1;
224-
225223
(void)params;
226224

227225
if (ctx == NULL) {
228-
ok = 0;
226+
return 0;
229227
}
230228
/* NULL key means "reinit, reuse the key already on the context" -- only
231229
* valid if the context actually has one. */
232-
if (ok && (mldsa == NULL) && (ctx->mldsa == NULL)) {
233-
ok = 0;
230+
if ((mldsa == NULL) && (ctx->mldsa == NULL)) {
231+
return 0;
234232
}
235-
if (ok && (mldsa != NULL)) {
233+
if (mldsa != NULL) {
236234
if (!wp_mldsa_up_ref(mldsa)) {
237-
ok = 0;
235+
return 0;
238236
}
239-
if (ok) {
240-
wp_mldsa_free(ctx->mldsa);
241-
ctx->mldsa = mldsa;
242-
}
243-
}
244-
if (ok) {
245-
wp_mldsa_buf_reset(ctx);
237+
wp_mldsa_free(ctx->mldsa);
238+
ctx->mldsa = mldsa;
246239
}
247-
return ok;
240+
wp_mldsa_buf_reset(ctx);
241+
return 1;
248242
}
249243

250244
static int wp_mldsa_sign_init(wp_MlDsaSigCtx* ctx, wp_MlDsa* mldsa,

src/wp_mlkem_kem.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,21 +124,17 @@ static wp_MlKemCtx* wp_mlkem_kem_dupctx(wp_MlKemCtx* srcCtx)
124124
static int wp_mlkem_kem_init(wp_MlKemCtx* ctx, wp_MlKem* mlkem,
125125
const OSSL_PARAM params[])
126126
{
127-
int ok = 1;
128-
129127
(void)params;
130128

131129
if ((ctx == NULL) || (mlkem == NULL)) {
132-
ok = 0;
133-
}
134-
if (ok && !wp_mlkem_up_ref(mlkem)) {
135-
ok = 0;
130+
return 0;
136131
}
137-
if (ok) {
138-
wp_mlkem_free(ctx->mlkem);
139-
ctx->mlkem = mlkem;
132+
if (!wp_mlkem_up_ref(mlkem)) {
133+
return 0;
140134
}
141-
return ok;
135+
wp_mlkem_free(ctx->mlkem);
136+
ctx->mlkem = mlkem;
137+
return 1;
142138
}
143139

144140
static int wp_mlkem_kem_encapsulate_init(wp_MlKemCtx* ctx, wp_MlKem* mlkem,

0 commit comments

Comments
 (0)