Skip to content

Commit d686a43

Browse files
authored
Merge pull request #233 from cconlon/pqc-lms
Add LMS/HSS (verify only) to wolfCrypt JNI and wolfJCE
2 parents 51648ba + ffa383b commit d686a43

30 files changed

Lines changed: 3219 additions & 18 deletions

.github/workflows/linux-common.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,17 @@ jobs:
5050
run: |
5151
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GITHUB_WORKSPACE/build-dir/lib" >> "$GITHUB_ENV"
5252
53-
# Only copy appropriate makefile for platform currently being tested
53+
# Only copy appropriate makefile for platform currently being tested.
54+
# Use 'cat > ' rather than 'cp': macOS runners intermittently fail 'cp'
55+
# with "fcopyfile failed: Illegal byte sequence" when copyfile() tries to
56+
# replicate the source's extended attributes (e.g. com.apple.provenance).
57+
# Redirecting content copies only the file data and avoids that path.
5458
- name: Copy makefile
5559
run: |
5660
if [ "$RUNNER_OS" == "Linux" ]; then
57-
cp makefile.linux makefile
61+
cat makefile.linux > makefile
5862
elif [ "$RUNNER_OS" == "macOS" ]; then
59-
cp makefile.macosx makefile
63+
cat makefile.macosx > makefile
6064
else
6165
echo "$RUNNER_OS not supported"
6266
exit 1

.github/workflows/main.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,38 @@ jobs:
144144
jdk_version: ${{ matrix.jdk_version }}
145145
wolfssl_configure: ${{ matrix.wolfssl_configure }}
146146

147+
# ----------------------- LMS / HSS (RFC 8554) ------------------------
148+
# LMS/HSS is verify-only in wolfJCE and requires wolfSSL to be built with
149+
# --enable-lms. It is not pulled in by --enable-all, so it is enabled
150+
# explicitly. The --enable-lms option is comma-separated and selects the
151+
# build variant and hash/parameter families:
152+
# (default) SHA-256/256 parameter sets, sign + verify
153+
# verify-only -> WOLFSSL_LMS_VERIFY_ONLY (wolfJCE production posture)
154+
# small -> WOLFSSL_WC_LMS_SMALL (low-memory, slower codepath)
155+
# sha256-192 -> WOLFSSL_LMS_SHA256_192 (RFC 9858 SHA-256/192 sets)
156+
# shake256 -> WOLFSSL_LMS_SHAKE256 (RFC 9858 SHAKE256 sets)
157+
# The LMS JUnit tests skip per hash family not compiled in (the JNI import
158+
# returns NOT_COMPILED_IN), so each permutation runs the KATs it can and
159+
# skips the rest. SHAKE parameter sets additionally require --enable-sha3.
160+
linux-zulu-lms:
161+
strategy:
162+
matrix:
163+
os: [ 'ubuntu-latest', 'macos-latest' ]
164+
jdk_version: [ '11', '21', '24' ]
165+
wolfssl_configure:
166+
- '--enable-jni --enable-lms'
167+
- '--enable-jni --enable-lms=verify-only'
168+
- '--enable-jni --enable-lms=verify-only,small'
169+
- '--enable-jni --enable-lms=sha256-192,shake256 --enable-sha3'
170+
- '--enable-jni --enable-all --enable-lms'
171+
name: ${{ matrix.os }} (Zulu JDK ${{ matrix.jdk_version }}, ${{ matrix.wolfssl_configure }})
172+
uses: ./.github/workflows/linux-common.yml
173+
with:
174+
os: ${{ matrix.os }}
175+
jdk_distro: "zulu"
176+
jdk_version: ${{ matrix.jdk_version }}
177+
wolfssl_configure: ${{ matrix.wolfssl_configure }}
178+
147179
# ------------------ Facebook Infer static analysis -------------------
148180
# Run Facebook infer over PR code, only running on Linux with one
149181
# JDK/version for now.

.github/workflows/maven.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,17 @@ jobs:
4242
run: |
4343
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GITHUB_WORKSPACE/build-dir/lib" >> "$GITHUB_ENV"
4444
45-
# Only copy appropriate makefile for platform currently being tested
45+
# Only copy appropriate makefile for platform currently being tested.
46+
# Use 'cat > ' rather than 'cp': macOS runners intermittently fail 'cp'
47+
# with "fcopyfile failed: Illegal byte sequence" when copyfile() tries to
48+
# replicate the source's extended attributes (e.g. com.apple.provenance).
49+
# Redirecting content copies only the file data and avoids that path.
4650
- name: Copy makefile
4751
run: |
4852
if [ "$RUNNER_OS" == "Linux" ]; then
49-
cp makefile.linux makefile
53+
cat makefile.linux > makefile
5054
elif [ "$RUNNER_OS" == "macOS" ]; then
51-
cp makefile.macosx makefile
55+
cat makefile.macosx > makefile
5256
else
5357
echo "$RUNNER_OS not supported"
5458
exit 1

.github/workflows/stable-wolfssl-releases.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,16 @@ jobs:
3737
# it is enabled explicitly. On stable releases older than 5.9.2 the XMSS
3838
# JUnit tests skip gracefully (FeatureDetect.XmssEnabled() returns
3939
# false), becoming real coverage once 5.9.2-stable rotates in.
40+
# LMS/HSS is verify-only in wolfJCE and is not pulled in by
41+
# --enable-all, so it is enabled explicitly. On stable releases that
42+
# predate a given LMS parameter family the LMS JUnit tests skip
43+
# gracefully (per-hash NOT_COMPILED_IN, or FeatureDetect.LmsEnabled()
44+
# returning false).
4045
wolfssl_configure:
4146
- '--enable-jni'
4247
- '--enable-jni --enable-all'
4348
- '--enable-jni --enable-all --enable-xmss'
49+
- '--enable-jni --enable-all --enable-lms'
4450
name: wolfSSL ${{ matrix.wolfssl_version }} (JDK ${{ matrix.jdk_version }}, ${{ matrix.wolfssl_configure }})
4551
steps:
4652
- uses: actions/checkout@v4

IDE/Android/app/src/main/cpp/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ add_library(wolfcryptjni SHARED
373373
${wolfcryptjni_DIR}/jni/jni_fips.c
374374
${wolfcryptjni_DIR}/jni/jni_hmac.c
375375
${wolfcryptjni_DIR}/jni/jni_jce_wolfsslkeystore.c
376+
${wolfcryptjni_DIR}/jni/jni_lms.c
376377
${wolfcryptjni_DIR}/jni/jni_logging.c
377378
${wolfcryptjni_DIR}/jni/jni_md5.c
378379
${wolfcryptjni_DIR}/jni/jni_mldsa.c

IDE/WIN/wolfcryptjni.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
<ClCompile Include="..\..\jni\jni_fips.c" />
9797
<ClCompile Include="..\..\jni\jni_hmac.c" />
9898
<ClCompile Include="..\..\jni\jni_jce_wolfsslkeystore.c" />
99+
<ClCompile Include="..\..\jni\jni_lms.c" />
99100
<ClCompile Include="..\..\jni\jni_logging.c" />
100101
<ClCompile Include="..\..\jni\jni_md5.c" />
101102
<ClCompile Include="..\..\jni\jni_mldsa.c" />

IDE/WIN/wolfcryptjni.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@
185185
<ClCompile Include="..\..\jni\jni_hmac.c">
186186
<Filter>Source Files</Filter>
187187
</ClCompile>
188+
<ClCompile Include="..\..\jni\jni_lms.c">
189+
<Filter>Source Files</Filter>
190+
</ClCompile>
188191
<ClCompile Include="..\..\jni\jni_logging.c">
189192
<Filter>Source Files</Filter>
190193
</ClCompile>

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ signing belongs in hardware (NIST SP 800-208). When `--enable-xmss` is missing
5555
or the native wolfSSL is older than 5.9.2, wolfJCE still compiles and runs
5656
normally but the XMSS services are not registered.
5757

58+
**Note on LMS/HSS (RFC 8554):** LMS support is **not** enabled by
59+
`--enable-jni` alone. Add `--enable-lms` (or `--enable-lms=verify-only`) to the
60+
native wolfSSL `./configure` line (for the SHAKE256 parameter sets also add
61+
`--enable-sha3`). wolfJCE provides **verify-only** LMS/HSS support, matching the
62+
JDK SUN provider: it registers the LMS `Signature` (verification) and
63+
`KeyFactory` (public-key) services. wolfJCE does not generate LMS keys or sign,
64+
since stateful hash-based signing belongs in hardware (NIST SP 800-208).
65+
5866
**wolfSSL Standard Build**:
5967
```
6068
$ cd wolfssl-x.x.x

README_JCE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ The JCE provider currently supports the following algorithms:
233233
OID: 1.3.6.1.5.5.7.6.34
234234
XMSSMT (verify-only)
235235
OID: 1.3.6.1.5.5.7.6.35
236+
LMS (also registered as HSS/LMS)
237+
OID: 1.2.840.113549.1.9.16.3.17
236238

237239
KeyAgreement Class
238240
DiffieHellman
@@ -279,6 +281,7 @@ The JCE provider currently supports the following algorithms:
279281
ML-KEM-1024 (alias OID: 2.16.840.1.101.3.4.4.3)
280282
XMSS (verify-only, alias OID: 1.3.6.1.5.5.7.6.34)
281283
XMSSMT (verify-only, alias OID: 1.3.6.1.5.5.7.6.35)
284+
LMS (also HSS/LMS, OID 1.2.840.113549.1.9.16.3.17)
282285

283286
KEM Class (javax.crypto.KEM, requires JDK 21 or later)
284287
ML-KEM
1.55 KB
Binary file not shown.

0 commit comments

Comments
 (0)