JNI: fix FB Infer warnings on OSX, potential threading issues

pull/81/head
Chris Conlon 2024-11-08 15:28:06 -07:00
parent c112d0d47c
commit cc05b61585
4 changed files with 51 additions and 31 deletions

View File

@ -77,7 +77,7 @@ infer --fail-on-issue run -- javac \
src/main/java/com/wolfssl/provider/jce/WolfCryptProvider.java \
src/main/java/com/wolfssl/provider/jce/WolfCryptRandom.java \
src/main/java/com/wolfssl/provider/jce/WolfCryptSecretKeyFactory.java \
src/main/java/com/wolfssl/provider/jce/WolfCryptSignature.java
src/main/java/com/wolfssl/provider/jce/WolfCryptSignature.java \
src/main/java/com/wolfssl/provider/jce/WolfSSLKeyStore.java
RETVAL=$?

View File

@ -150,10 +150,12 @@ public class Chacha extends NativeStruct {
checkStateAndInitialize();
throwIfKeyExists();
synchronized (pointerLock) {
wc_Chacha_setKey(Key);
synchronized (stateLock) {
synchronized (pointerLock) {
wc_Chacha_setKey(Key);
}
state = WolfCryptState.READY;
}
state = WolfCryptState.READY;
}
/**

View File

@ -166,10 +166,12 @@ public class Curve25519 extends NativeStruct {
checkStateAndInitialize();
throwIfKeyExists();
synchronized (pointerLock) {
wc_curve25519_make_key(rng, size);
synchronized (stateLock) {
synchronized (pointerLock) {
wc_curve25519_make_key(rng, size);
}
state = WolfCryptState.READY;
}
state = WolfCryptState.READY;
}
/**
@ -189,10 +191,12 @@ public class Curve25519 extends NativeStruct {
checkStateAndInitialize();
throwIfKeyExists();
synchronized (pointerLock) {
wc_curve25519_make_key_ex(rng, size, endian);
synchronized (stateLock) {
synchronized (pointerLock) {
wc_curve25519_make_key_ex(rng, size, endian);
}
state = WolfCryptState.READY;
}
state = WolfCryptState.READY;
}
/**
@ -230,10 +234,12 @@ public class Curve25519 extends NativeStruct {
checkStateAndInitialize();
throwIfKeyExists();
synchronized (pointerLock) {
wc_curve25519_import_private(privKey, xKey);
synchronized (stateLock) {
synchronized (pointerLock) {
wc_curve25519_import_private(privKey, xKey);
}
state = WolfCryptState.READY;
}
state = WolfCryptState.READY;
}
/**
@ -252,10 +258,12 @@ public class Curve25519 extends NativeStruct {
checkStateAndInitialize();
throwIfKeyExists();
synchronized (pointerLock) {
wc_curve25519_import_private_only(privKey);
synchronized (stateLock) {
synchronized (pointerLock) {
wc_curve25519_import_private_only(privKey);
}
state = WolfCryptState.READY;
}
state = WolfCryptState.READY;
}
/**
@ -274,10 +282,12 @@ public class Curve25519 extends NativeStruct {
checkStateAndInitialize();
throwIfKeyExists();
synchronized (pointerLock) {
wc_curve25519_import_public(pubKey);
synchronized (stateLock) {
synchronized (pointerLock) {
wc_curve25519_import_public(pubKey);
}
state = WolfCryptState.READY;
}
state = WolfCryptState.READY;
}
/**

View File

@ -165,10 +165,12 @@ public class Ed25519 extends NativeStruct {
checkStateAndInitialize();
throwIfKeyExists();
synchronized (pointerLock) {
wc_ed25519_make_key(rng, size);
synchronized (stateLock) {
synchronized (pointerLock) {
wc_ed25519_make_key(rng, size);
}
state = WolfCryptState.READY;
}
state = WolfCryptState.READY;
}
/**
@ -208,10 +210,12 @@ public class Ed25519 extends NativeStruct {
checkStateAndInitialize();
throwIfKeyExists();
synchronized (pointerLock) {
wc_ed25519_import_private(privKey, Key);
synchronized (stateLock) {
synchronized (pointerLock) {
wc_ed25519_import_private(privKey, Key);
}
state = WolfCryptState.READY;
}
state = WolfCryptState.READY;
}
/**
@ -230,10 +234,12 @@ public class Ed25519 extends NativeStruct {
checkStateAndInitialize();
throwIfKeyExists();
synchronized (pointerLock) {
wc_ed25519_import_private_only(privKey);
synchronized (stateLock) {
synchronized (pointerLock) {
wc_ed25519_import_private_only(privKey);
}
state = WolfCryptState.READY;
}
state = WolfCryptState.READY;
}
/**
@ -252,10 +258,12 @@ public class Ed25519 extends NativeStruct {
checkStateAndInitialize();
throwIfKeyExists();
synchronized (pointerLock) {
wc_ed25519_import_public(Key);
synchronized (stateLock) {
synchronized (pointerLock) {
wc_ed25519_import_public(Key);
}
state = WolfCryptState.READY;
}
state = WolfCryptState.READY;
}
/**