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,11 +150,13 @@ public class Chacha extends NativeStruct {
checkStateAndInitialize();
throwIfKeyExists();
synchronized (stateLock) {
synchronized (pointerLock) {
wc_Chacha_setKey(Key);
}
state = WolfCryptState.READY;
}
}
/**
* Set ChaCha initialization vector

View File

@ -166,11 +166,13 @@ public class Curve25519 extends NativeStruct {
checkStateAndInitialize();
throwIfKeyExists();
synchronized (stateLock) {
synchronized (pointerLock) {
wc_curve25519_make_key(rng, size);
}
state = WolfCryptState.READY;
}
}
/**
* Generate new Curve25519 key with specified endianness.
@ -189,11 +191,13 @@ public class Curve25519 extends NativeStruct {
checkStateAndInitialize();
throwIfKeyExists();
synchronized (stateLock) {
synchronized (pointerLock) {
wc_curve25519_make_key_ex(rng, size, endian);
}
state = WolfCryptState.READY;
}
}
/**
* Check Curve25519 key for correctness.
@ -230,11 +234,13 @@ public class Curve25519 extends NativeStruct {
checkStateAndInitialize();
throwIfKeyExists();
synchronized (stateLock) {
synchronized (pointerLock) {
wc_curve25519_import_private(privKey, xKey);
}
state = WolfCryptState.READY;
}
}
/**
* Import private key from byte array.
@ -252,11 +258,13 @@ public class Curve25519 extends NativeStruct {
checkStateAndInitialize();
throwIfKeyExists();
synchronized (stateLock) {
synchronized (pointerLock) {
wc_curve25519_import_private_only(privKey);
}
state = WolfCryptState.READY;
}
}
/**
* Import public key from byte array.
@ -274,11 +282,13 @@ public class Curve25519 extends NativeStruct {
checkStateAndInitialize();
throwIfKeyExists();
synchronized (stateLock) {
synchronized (pointerLock) {
wc_curve25519_import_public(pubKey);
}
state = WolfCryptState.READY;
}
}
/**
* Export private key as byte array.

View File

@ -165,11 +165,13 @@ public class Ed25519 extends NativeStruct {
checkStateAndInitialize();
throwIfKeyExists();
synchronized (stateLock) {
synchronized (pointerLock) {
wc_ed25519_make_key(rng, size);
}
state = WolfCryptState.READY;
}
}
/**
* Check correctness of Ed25519 key.
@ -208,11 +210,13 @@ public class Ed25519 extends NativeStruct {
checkStateAndInitialize();
throwIfKeyExists();
synchronized (stateLock) {
synchronized (pointerLock) {
wc_ed25519_import_private(privKey, Key);
}
state = WolfCryptState.READY;
}
}
/**
* Import only private Ed25519 key.
@ -230,11 +234,13 @@ public class Ed25519 extends NativeStruct {
checkStateAndInitialize();
throwIfKeyExists();
synchronized (stateLock) {
synchronized (pointerLock) {
wc_ed25519_import_private_only(privKey);
}
state = WolfCryptState.READY;
}
}
/**
* Import only public Ed25519 key.
@ -252,11 +258,13 @@ public class Ed25519 extends NativeStruct {
checkStateAndInitialize();
throwIfKeyExists();
synchronized (stateLock) {
synchronized (pointerLock) {
wc_ed25519_import_public(Key);
}
state = WolfCryptState.READY;
}
}
/**
* Export raw private Ed25519 key including public part.