Skip to content

JCE: refresh debug flags when WolfCryptProvider is loaded#135

Merged
rlm2002 merged 6 commits intowolfSSL:masterfrom
cconlon:refreshDebugFlags
Aug 18, 2025
Merged

JCE: refresh debug flags when WolfCryptProvider is loaded#135
rlm2002 merged 6 commits intowolfSSL:masterfrom
cconlon:refreshDebugFlags

Conversation

@cconlon
Copy link
Member

@cconlon cconlon commented Jul 28, 2025

This PR includes fixes and cleanup, including:

  • Refresh Debug Flags

    • The WolfCryptDebug class caches the debug flag during static initialization, sometimes before system properties like -Dwolfjce.debug=true are set (ex: via JAVA_OPTS). This can cause debug logging to remain disabled even when the property is correctly set at runtime.
    • This PR adds a call to WolfCryptDebug.refreshDebugFlags() in the WolfCryptProvider constructor to refresh the debug state when the provider is loaded, to make sure logging shows up correctly when enabled via system properties.
  • Defines WOLFSSL_SHA224 in the Windows Visual Studio GitHub action, to fix this issue:

Testcase: testRsaPssComprehensiveMgfTesting took 0.439 sec
	FAILED
RSA-PSS MGF test failed for MGF type 4 with hash type 5: Hash type not enabled/available
junit.framework.AssertionFailedError: RSA-PSS MGF test failed for MGF type 4 with hash type 5: Hash type not enabled/available
	at com.wolfssl.wolfcrypt.test.RsaTest.testRsaPssComprehensiveMgfTesting(RsaTest.java:1134)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

Testcase: testRsaPssIndividualMgfTypes took 0.188 sec
	FAILED
MGF type 4 with hash type 5 failed: Hash type not enabled/available
junit.framework.AssertionFailedError: MGF type 4 with hash type 5 failed: Hash type not enabled/available
	at com.wolfssl.wolfcrypt.test.RsaTest.testRsaPssIndividualMgfTypes(RsaTest.java:1249)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  • Remove rngLock synchronization around ECC sign operation in WolfCryptSignature.engineSign(), since the underlying Ecc class should already have synchronization protection for the incoming Rng.
  • Add more debug diagnostic information to WolfCryptSignatureTest.testWolfSignInteropVerify() to help in debugging future sporadic CI failures.
  • Synchronize methods in WolfCryptRandom, in case higher level JCE does not do synchronization before calling us.
  • Add lock around hash operations in WolfCryptSignature to prevent threading issues.

@cconlon cconlon self-assigned this Jul 28, 2025
@cconlon cconlon force-pushed the refreshDebugFlags branch from 7d499c4 to 8a59eaf Compare July 29, 2025 22:37
@cconlon cconlon force-pushed the refreshDebugFlags branch from d76b6ad to c522d9e Compare August 15, 2025 19:25
@cconlon cconlon requested a review from Copilot August 15, 2025 19:37
Copy link

Copilot AI left a comment

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 enhances debugging and diagnostics for the WolfCryptProvider by refreshing debug flags during provider initialization and adding comprehensive diagnostic information to test failures. It also includes several synchronization improvements and a Windows build fix.

  • Refreshes debug flags in WolfCryptProvider constructor to ensure system properties set via JAVA_OPTS are properly recognized
  • Adds extensive diagnostic logging to signature verification test failures for better debugging of sporadic CI issues
  • Improves thread safety with synchronized methods in WolfCryptRandom and hash operation locks in WolfCryptSignature

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/main/java/com/wolfssl/provider/jce/WolfCryptProvider.java Adds debug flag refresh during provider initialization
src/main/java/com/wolfssl/provider/jce/WolfCryptSignature.java Adds hash operation synchronization and removes redundant ECC signing lock
src/main/java/com/wolfssl/provider/jce/WolfCryptRandom.java Synchronizes all methods for thread safety
src/test/java/com/wolfssl/provider/jce/test/WolfCryptSignatureTest.java Expands diagnostic information for test failure debugging
.github/workflows/windows-vs.yml Adds WOLFSSL_SHA224 define to fix Windows build issues

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@cconlon cconlon assigned rlm2002 and unassigned cconlon Aug 15, 2025
@rlm2002 rlm2002 merged commit fad4ca4 into wolfSSL:master Aug 18, 2025
46 checks passed
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