Skip to content

Commit fad4ca4

Browse files
authored
Merge pull request #135 from cconlon/refreshDebugFlags
JCE: refresh debug flags when WolfCryptProvider is loaded
2 parents b94f30b + c522d9e commit fad4ca4

File tree

5 files changed

+540
-237
lines changed

5 files changed

+540
-237
lines changed

.github/workflows/windows-vs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ jobs:
274274
$content = Get-Content $userSettingsPath -Raw
275275
Write-Output "Original file size: $($content.Length) characters"
276276
277-
$newDefines = "#define WOLFSSL_KEY_GEN`n#define HAVE_CRL`n#define OPENSSL_ALL`n`n"
277+
$newDefines = "#define WOLFSSL_KEY_GEN`n#define HAVE_CRL`n#define OPENSSL_ALL`n#define WOLFSSL_SHA224`n`n"
278278
279279
# Try multiple possible insertion points
280280
$insertPoints = @(

src/main/java/com/wolfssl/provider/jce/WolfCryptProvider.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ public final class WolfCryptProvider extends Provider {
3838
*/
3939
public WolfCryptProvider() {
4040
super("wolfJCE", 1.8, "wolfCrypt JCE Provider");
41+
42+
/* Refresh debug flags in case system properties were set after
43+
* WolfCryptDebug class was first loaded (e.g., via JAVA_OPTS) */
44+
WolfCryptDebug.refreshDebugFlags();
45+
4146
registerServices();
4247
}
4348

src/main/java/com/wolfssl/provider/jce/WolfCryptRandom.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@ public WolfCryptRandom() {
5252
}
5353

5454
@Override
55-
protected byte[] engineGenerateSeed(int numBytes) {
55+
protected synchronized byte[] engineGenerateSeed(int numBytes) {
5656

5757
return rng.generateBlock(numBytes);
5858
}
5959

6060
@Override
61-
protected void engineNextBytes(byte[] bytes) {
61+
protected synchronized void engineNextBytes(byte[] bytes) {
6262

6363
rng.generateBlock(bytes);
6464
}
6565

6666
@Override
67-
protected void engineSetSeed(byte[] seed) {
67+
protected synchronized void engineSetSeed(byte[] seed) {
6868
/* wolfCrypt reseeds internally automatically */
6969
log("setSeed() not supported by wolfJCE");
7070
}
@@ -75,7 +75,7 @@ private void log(String msg) {
7575

7676
@SuppressWarnings("deprecation")
7777
@Override
78-
protected void finalize() throws Throwable {
78+
protected synchronized void finalize() throws Throwable {
7979
try {
8080

8181
if (this.rng != null) {
@@ -98,7 +98,9 @@ protected void finalize() throws Throwable {
9898
*
9999
* @throws IOException on error writing to ObjectOutputStream
100100
*/
101-
private void writeObject(ObjectOutputStream out) throws IOException {
101+
private synchronized void writeObject(ObjectOutputStream out)
102+
throws IOException {
103+
102104
if (this.rng != null) {
103105
this.rng.free();
104106
this.rng.releaseNativeStruct();
@@ -118,7 +120,7 @@ private void writeObject(ObjectOutputStream out) throws IOException {
118120
* @throws IOException on error reading from ObjectInputStream
119121
* @throws ClassNotFoundException if object class not found
120122
*/
121-
private void readObject(ObjectInputStream in)
123+
private synchronized void readObject(ObjectInputStream in)
122124
throws IOException, ClassNotFoundException {
123125

124126
if (rng == null) {

0 commit comments

Comments
 (0)