diff --git a/common/src/main/java/bisq/common/crypto/Encryption.java b/common/src/main/java/bisq/common/crypto/Encryption.java index bfa3adf020..a04ea2df34 100644 --- a/common/src/main/java/bisq/common/crypto/Encryption.java +++ b/common/src/main/java/bisq/common/crypto/Encryption.java @@ -25,6 +25,8 @@ import javax.crypto.Cipher; import javax.crypto.KeyGenerator; import javax.crypto.Mac; import javax.crypto.SecretKey; +import javax.crypto.spec.OAEPParameterSpec; +import javax.crypto.spec.PSource; import javax.crypto.spec.SecretKeySpec; import java.security.InvalidKeyException; @@ -36,6 +38,7 @@ import java.security.NoSuchProviderException; import java.security.PrivateKey; import java.security.PublicKey; import java.security.spec.InvalidKeySpecException; +import java.security.spec.MGF1ParameterSpec; import java.security.spec.X509EncodedKeySpec; import java.io.ByteArrayOutputStream; @@ -51,7 +54,7 @@ public class Encryption { private static final Logger log = LoggerFactory.getLogger(Encryption.class); public static final String ASYM_KEY_ALGO = "RSA"; - private static final String ASYM_CIPHER = "RSA/None/OAEPWithSHA256AndMGF1Padding"; + private static final String ASYM_CIPHER = "RSA/ECB/OAEPWithSHA-256AndMGF1PADDING"; private static final String SYM_KEY_ALGO = "AES"; private static final String SYM_CIPHER = "AES"; @@ -61,7 +64,7 @@ public class Encryption { public static KeyPair generateKeyPair() { long ts = System.currentTimeMillis(); try { - KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(ASYM_KEY_ALGO, "BC"); + KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(ASYM_KEY_ALGO); keyPairGenerator.initialize(2048); KeyPair keyPair = keyPairGenerator.genKeyPair(); log.trace("Generate msgEncryptionKeyPair needed {} ms", System.currentTimeMillis() - ts); @@ -80,7 +83,7 @@ public class Encryption { public static byte[] encrypt(byte[] payload, SecretKey secretKey) throws CryptoException { try { - Cipher cipher = Cipher.getInstance(SYM_CIPHER, "BC"); + Cipher cipher = Cipher.getInstance(SYM_CIPHER); cipher.init(Cipher.ENCRYPT_MODE, secretKey); return cipher.doFinal(payload); } catch (Throwable e) { @@ -91,7 +94,7 @@ public class Encryption { public static byte[] decrypt(byte[] encryptedPayload, SecretKey secretKey) throws CryptoException { try { - Cipher cipher = Cipher.getInstance(SYM_CIPHER, "BC"); + Cipher cipher = Cipher.getInstance(SYM_CIPHER); cipher.init(Cipher.DECRYPT_MODE, secretKey); return cipher.doFinal(encryptedPayload); } catch (Throwable e) { @@ -157,7 +160,7 @@ public class Encryption { } private static byte[] getHmac(byte[] payload, SecretKey secretKey) throws NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException { - Mac mac = Mac.getInstance(HMAC, "BC"); + Mac mac = Mac.getInstance(HMAC); mac.init(secretKey); return mac.doFinal(payload); } @@ -195,8 +198,10 @@ public class Encryption { public static byte[] encryptSecretKey(SecretKey secretKey, PublicKey publicKey) throws CryptoException { try { - Cipher cipher = Cipher.getInstance(ASYM_CIPHER, "BC"); - cipher.init(Cipher.WRAP_MODE, publicKey); + Cipher cipher = Cipher.getInstance(ASYM_CIPHER); + OAEPParameterSpec oaepParameterSpec = new OAEPParameterSpec("SHA-256", "MGF1", + MGF1ParameterSpec.SHA256, PSource.PSpecified.DEFAULT); + cipher.init(Cipher.WRAP_MODE, publicKey, oaepParameterSpec); return cipher.wrap(secretKey); } catch (Throwable e) { e.printStackTrace(); @@ -206,8 +211,10 @@ public class Encryption { public static SecretKey decryptSecretKey(byte[] encryptedSecretKey, PrivateKey privateKey) throws CryptoException { try { - Cipher cipher = Cipher.getInstance(ASYM_CIPHER, "BC"); - cipher.init(Cipher.UNWRAP_MODE, privateKey); + Cipher cipher = Cipher.getInstance(ASYM_CIPHER); + OAEPParameterSpec oaepParameterSpec = new OAEPParameterSpec("SHA-256", "MGF1", + MGF1ParameterSpec.SHA256, PSource.PSpecified.DEFAULT); + cipher.init(Cipher.UNWRAP_MODE, privateKey, oaepParameterSpec); return (SecretKey) cipher.unwrap(encryptedSecretKey, "AES", Cipher.SECRET_KEY); } catch (Throwable e) { // errors when trying to decrypt foreign network_messages are normal @@ -222,7 +229,7 @@ public class Encryption { public static SecretKey generateSecretKey(int bits) { try { - KeyGenerator keyPairGenerator = KeyGenerator.getInstance(SYM_KEY_ALGO, "BC"); + KeyGenerator keyPairGenerator = KeyGenerator.getInstance(SYM_KEY_ALGO); keyPairGenerator.init(bits); return keyPairGenerator.generateKey(); } catch (Throwable e) { @@ -242,8 +249,8 @@ public class Encryption { */ public static PublicKey getPublicKeyFromBytes(byte[] encryptionPubKeyBytes) { try { - return KeyFactory.getInstance(Encryption.ASYM_KEY_ALGO, "BC").generatePublic(new X509EncodedKeySpec(encryptionPubKeyBytes)); - } catch (InvalidKeySpecException | NoSuchAlgorithmException | NoSuchProviderException e) { + return KeyFactory.getInstance(Encryption.ASYM_KEY_ALGO).generatePublic(new X509EncodedKeySpec(encryptionPubKeyBytes)); + } catch (InvalidKeySpecException | NoSuchAlgorithmException e) { log.error("Error creating sigPublicKey from bytes. sigPublicKeyBytes as hex={}, error={}", Utilities.bytesAsHexString(encryptionPubKeyBytes), e); e.printStackTrace(); throw new KeyConversionException(e); diff --git a/common/src/main/java/bisq/common/crypto/Hash.java b/common/src/main/java/bisq/common/crypto/Hash.java index 820d8a1aa6..078582266a 100644 --- a/common/src/main/java/bisq/common/crypto/Hash.java +++ b/common/src/main/java/bisq/common/crypto/Hash.java @@ -25,7 +25,6 @@ import org.spongycastle.crypto.digests.RIPEMD160Digest; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; import java.nio.ByteBuffer; @@ -40,10 +39,10 @@ public class Hash { */ public static byte[] getSha256Hash(byte[] data) { try { - MessageDigest digest = MessageDigest.getInstance("SHA-256", "BC"); + MessageDigest digest = MessageDigest.getInstance("SHA-256"); digest.update(data, 0, data.length); return digest.digest(); - } catch (NoSuchAlgorithmException | NoSuchProviderException e) { + } catch (NoSuchAlgorithmException e) { log.error("Could not create MessageDigest for hash. " + e.toString()); e.printStackTrace(); throw new RuntimeException(e); diff --git a/common/src/main/java/bisq/common/crypto/KeyStorage.java b/common/src/main/java/bisq/common/crypto/KeyStorage.java index 1320cf36ec..1b1f00525d 100644 --- a/common/src/main/java/bisq/common/crypto/KeyStorage.java +++ b/common/src/main/java/bisq/common/crypto/KeyStorage.java @@ -28,7 +28,6 @@ import org.bouncycastle.openpgp.PGPKeyPair; import java.security.KeyFactory; import java.security.KeyPair; import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; import java.security.PrivateKey; import java.security.PublicKey; import java.security.interfaces.DSAParams; @@ -121,7 +120,7 @@ public class KeyStorage { FileUtil.rollingBackup(storageDir, keyEntry.getFileName() + ".key", 20); // long now = System.currentTimeMillis(); try { - KeyFactory keyFactory = KeyFactory.getInstance(keyEntry.getAlgorithm(), "BC"); + KeyFactory keyFactory = KeyFactory.getInstance(keyEntry.getAlgorithm()); PublicKey publicKey; PrivateKey privateKey; @@ -158,7 +157,7 @@ public class KeyStorage { log.debug("load completed in {} msec", System.currentTimeMillis() - new Date().getTime()); return new KeyPair(publicKey, privateKey); - } catch (NoSuchAlgorithmException | InvalidKeySpecException | NoSuchProviderException e) { + } catch (NoSuchAlgorithmException | InvalidKeySpecException e) { e.printStackTrace(); log.error(e.getMessage()); throw new RuntimeException("Could not load key " + keyEntry.toString(), e); diff --git a/common/src/main/java/bisq/common/crypto/Sig.java b/common/src/main/java/bisq/common/crypto/Sig.java index 6917bb9df0..85e1483896 100644 --- a/common/src/main/java/bisq/common/crypto/Sig.java +++ b/common/src/main/java/bisq/common/crypto/Sig.java @@ -28,7 +28,6 @@ import java.security.KeyFactory; import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; import java.security.PrivateKey; import java.security.PublicKey; import java.security.Signature; @@ -60,12 +59,12 @@ public class Sig { public static KeyPair generateKeyPair() { long ts = System.currentTimeMillis(); try { - KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(KEY_ALGO, "BC"); + KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(KEY_ALGO); keyPairGenerator.initialize(1024); KeyPair keyPair = keyPairGenerator.genKeyPair(); log.trace("Generate msgSignatureKeyPair needed {} ms", System.currentTimeMillis() - ts); return keyPair; - } catch (NoSuchAlgorithmException | NoSuchProviderException e) { + } catch (NoSuchAlgorithmException e) { e.printStackTrace(); log.error(e.toString()); throw new RuntimeException("Could not create key."); @@ -80,11 +79,11 @@ public class Sig { */ public static byte[] sign(PrivateKey privateKey, byte[] data) throws CryptoException { try { - Signature sig = Signature.getInstance(ALGO, "BC"); + Signature sig = Signature.getInstance(ALGO); sig.initSign(privateKey); sig.update(data); return sig.sign(); - } catch (SignatureException | NoSuchProviderException | InvalidKeyException | NoSuchAlgorithmException e) { + } catch (SignatureException | InvalidKeyException | NoSuchAlgorithmException e) { throw new CryptoException("Signing failed. " + e.getMessage()); } } @@ -107,11 +106,11 @@ public class Sig { */ public static boolean verify(PublicKey publicKey, byte[] data, byte[] signature) throws CryptoException { try { - Signature sig = Signature.getInstance(ALGO, "BC"); + Signature sig = Signature.getInstance(ALGO); sig.initVerify(publicKey); sig.update(data); return sig.verify(signature); - } catch (SignatureException | NoSuchProviderException | InvalidKeyException | NoSuchAlgorithmException e) { + } catch (SignatureException | InvalidKeyException | NoSuchAlgorithmException e) { throw new CryptoException("Signature verification failed. " + e.getMessage()); } } @@ -132,8 +131,8 @@ public class Sig { */ public static PublicKey getPublicKeyFromBytes(byte[] sigPublicKeyBytes) { try { - return KeyFactory.getInstance(Sig.KEY_ALGO, "BC").generatePublic(new X509EncodedKeySpec(sigPublicKeyBytes)); - } catch (InvalidKeySpecException | NoSuchAlgorithmException | NoSuchProviderException e) { + return KeyFactory.getInstance(Sig.KEY_ALGO).generatePublic(new X509EncodedKeySpec(sigPublicKeyBytes)); + } catch (InvalidKeySpecException | NoSuchAlgorithmException e) { log.error("Error creating sigPublicKey from bytes. sigPublicKeyBytes as hex={}, error={}", Utilities.bytesAsHexString(sigPublicKeyBytes), e); e.printStackTrace(); throw new KeyConversionException(e); diff --git a/common/src/main/java/bisq/common/setup/CommonSetup.java b/common/src/main/java/bisq/common/setup/CommonSetup.java index 6e934cdd54..c170c194c6 100644 --- a/common/src/main/java/bisq/common/setup/CommonSetup.java +++ b/common/src/main/java/bisq/common/setup/CommonSetup.java @@ -25,10 +25,7 @@ import org.bitcoinj.store.BlockStoreException; import org.apache.commons.lang3.exception.ExceptionUtils; -import org.bouncycastle.jce.provider.BouncyCastleProvider; - import java.security.NoSuchAlgorithmException; -import java.security.Security; import lombok.extern.slf4j.Slf4j; @@ -38,8 +35,6 @@ public class CommonSetup { public static void setup(UncaughtExceptionHandler uncaughtExceptionHandler) { setupErrorHandler(uncaughtExceptionHandler); - Security.addProvider(new BouncyCastleProvider()); - if (Utilities.isLinux()) System.setProperty("prism.lcdtext", "false"); } diff --git a/core/src/main/java/bisq/core/app/BisqSetup.java b/core/src/main/java/bisq/core/app/BisqSetup.java index 12dd775078..1fbb63757d 100644 --- a/core/src/main/java/bisq/core/app/BisqSetup.java +++ b/core/src/main/java/bisq/core/app/BisqSetup.java @@ -444,9 +444,6 @@ public class BisqSetup { ((Ping) tuple.getNetworkEnvelope()).getNonce() == payload.getNonce() && ((Ping) tuple.getNetworkEnvelope()).getLastRoundTripTime() == payload.getLastRoundTripTime()) { log.debug("Crypto test succeeded"); - - if (Security.getProvider("BC") == null) - throw new CryptoException("Security provider BountyCastle is not available."); } else { throw new CryptoException("Payload not correct after decryption"); } diff --git a/core/src/main/java/bisq/core/app/SetupUtils.java b/core/src/main/java/bisq/core/app/SetupUtils.java index 779228bc82..9bb28c553b 100644 --- a/core/src/main/java/bisq/core/app/SetupUtils.java +++ b/core/src/main/java/bisq/core/app/SetupUtils.java @@ -34,8 +34,6 @@ import bisq.common.proto.ProtobufferException; import javafx.beans.property.BooleanProperty; import javafx.beans.property.SimpleBooleanProperty; -import java.security.Security; - import java.util.Date; import java.util.function.Consumer; @@ -67,12 +65,6 @@ public class SetupUtils { ((Ping) tuple.getNetworkEnvelope()).getNonce() == payload.getNonce() && ((Ping) tuple.getNetworkEnvelope()).getLastRoundTripTime() == payload.getLastRoundTripTime()) { log.debug("Crypto test succeeded"); - - if (Security.getProvider("BC") != null) { - UserThread.execute(resultHandler::handleResult); - } else { - errorHandler.accept(new CryptoException("Security provider BountyCastle is not available.")); - } } else { errorHandler.accept(new CryptoException("Payload not correct after decryption")); } diff --git a/core/src/test/java/bisq/core/arbitration/ArbitratorManagerTest.java b/core/src/test/java/bisq/core/arbitration/ArbitratorManagerTest.java index 69a6bd77c0..a5ae6a713f 100644 --- a/core/src/test/java/bisq/core/arbitration/ArbitratorManagerTest.java +++ b/core/src/test/java/bisq/core/arbitration/ArbitratorManagerTest.java @@ -47,10 +47,7 @@ import static org.mockito.Mockito.mock; @PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) public class ArbitratorManagerTest { - @Before - public void setUp() { - Security.addProvider(new BouncyCastleProvider()); - } + @Test public void testIsArbitratorAvailableForLanguage() { diff --git a/core/src/test/java/bisq/core/crypto/EncryptionTest.java b/core/src/test/java/bisq/core/crypto/EncryptionTest.java index 42859aca12..e06ef08275 100644 --- a/core/src/test/java/bisq/core/crypto/EncryptionTest.java +++ b/core/src/test/java/bisq/core/crypto/EncryptionTest.java @@ -45,7 +45,7 @@ public class EncryptionTest { @Before public void setup() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, CryptoException { - Security.addProvider(new BouncyCastleProvider()); + dir = File.createTempFile("temp_tests", ""); //noinspection ResultOfMethodCallIgnored dir.delete(); diff --git a/core/src/test/java/bisq/core/crypto/SigTest.java b/core/src/test/java/bisq/core/crypto/SigTest.java index 349987f746..a66e0b72f2 100644 --- a/core/src/test/java/bisq/core/crypto/SigTest.java +++ b/core/src/test/java/bisq/core/crypto/SigTest.java @@ -51,7 +51,7 @@ public class SigTest { @Before public void setup() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, CryptoException { - Security.addProvider(new BouncyCastleProvider()); + dir = File.createTempFile("temp_tests", ""); //noinspection ResultOfMethodCallIgnored dir.delete(); diff --git a/core/src/test/java/bisq/core/network/p2p/seed/SeedNodeAddressLookupTest.java b/core/src/test/java/bisq/core/network/p2p/seed/SeedNodeAddressLookupTest.java index ca76150f59..8f63daefd8 100644 --- a/core/src/test/java/bisq/core/network/p2p/seed/SeedNodeAddressLookupTest.java +++ b/core/src/test/java/bisq/core/network/p2p/seed/SeedNodeAddressLookupTest.java @@ -36,10 +36,7 @@ import static org.junit.Assert.assertFalse; import static org.mockito.Mockito.mock; public class SeedNodeAddressLookupTest { - @Before - public void setUp() { - Security.addProvider(new BouncyCastleProvider()); - } + @Test public void testResolveNodeAddressesWhenLocalAddressSpecified() { diff --git a/core/src/test/java/bisq/core/network/p2p/seed/SeedNodeAddressesTest.java b/core/src/test/java/bisq/core/network/p2p/seed/SeedNodeAddressesTest.java index 580c3393e1..b036f98faf 100644 --- a/core/src/test/java/bisq/core/network/p2p/seed/SeedNodeAddressesTest.java +++ b/core/src/test/java/bisq/core/network/p2p/seed/SeedNodeAddressesTest.java @@ -37,10 +37,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; public class SeedNodeAddressesTest { - @Before - public void setUp() { - Security.addProvider(new BouncyCastleProvider()); - } + @Test public void testCollector() { diff --git a/desktop/src/test/java/bisq/desktop/main/market/trades/TradesChartsViewModelTest.java b/desktop/src/test/java/bisq/desktop/main/market/trades/TradesChartsViewModelTest.java index 9bd5d1bc7e..1b5e40005a 100644 --- a/desktop/src/test/java/bisq/desktop/main/market/trades/TradesChartsViewModelTest.java +++ b/desktop/src/test/java/bisq/desktop/main/market/trades/TradesChartsViewModelTest.java @@ -38,10 +38,6 @@ import org.bitcoinj.utils.Fiat; import javafx.collections.FXCollections; import javafx.collections.ObservableSet; -import org.bouncycastle.jce.provider.BouncyCastleProvider; - -import java.security.Security; - import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -128,7 +124,7 @@ public class TradesChartsViewModelTest { @Before public void setup() throws IOException { - Security.addProvider(new BouncyCastleProvider()); + dir = File.createTempFile("temp_tests1", ""); //noinspection ResultOfMethodCallIgnored dir.delete(); diff --git a/desktop/src/test/java/bisq/desktop/main/settings/preferences/PreferencesViewModelTest.java b/desktop/src/test/java/bisq/desktop/main/settings/preferences/PreferencesViewModelTest.java index cd07a7adda..42b368b145 100644 --- a/desktop/src/test/java/bisq/desktop/main/settings/preferences/PreferencesViewModelTest.java +++ b/desktop/src/test/java/bisq/desktop/main/settings/preferences/PreferencesViewModelTest.java @@ -27,17 +27,12 @@ import bisq.network.p2p.NodeAddress; import javafx.collections.FXCollections; import javafx.collections.ObservableMap; -import org.bouncycastle.jce.provider.BouncyCastleProvider; - -import java.security.Security; - import java.util.ArrayList; import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -50,10 +45,7 @@ import static org.mockito.Mockito.when; @PowerMockIgnore({"com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*"}) public class PreferencesViewModelTest { - @Before - public void setUp() { - Security.addProvider(new BouncyCastleProvider()); - } + @Test public void testGetArbitrationLanguages() { diff --git a/desktop/src/test/java/bisq/desktop/util/validation/AccountNrValidatorTest.java b/desktop/src/test/java/bisq/desktop/util/validation/AccountNrValidatorTest.java index 75047bec16..4584d98cd0 100644 --- a/desktop/src/test/java/bisq/desktop/util/validation/AccountNrValidatorTest.java +++ b/desktop/src/test/java/bisq/desktop/util/validation/AccountNrValidatorTest.java @@ -7,7 +7,6 @@ import java.util.Locale; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; public class AccountNrValidatorTest { diff --git a/p2p/src/test/java/bisq/network/crypto/EncryptionServiceTests.java b/p2p/src/test/java/bisq/network/crypto/EncryptionServiceTests.java index c3f92564ac..dc7bf58383 100644 --- a/p2p/src/test/java/bisq/network/crypto/EncryptionServiceTests.java +++ b/p2p/src/test/java/bisq/network/crypto/EncryptionServiceTests.java @@ -26,11 +26,8 @@ import bisq.common.storage.FileUtil; import io.bisq.generated.protobuffer.PB; -import org.bouncycastle.jce.provider.BouncyCastleProvider; - import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; -import java.security.Security; import java.security.cert.CertificateException; import java.io.File; @@ -56,7 +53,7 @@ public class EncryptionServiceTests { @Before public void setup() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException, CryptoException { - Security.addProvider(new BouncyCastleProvider()); + dir = File.createTempFile("temp_tests", ""); //noinspection ResultOfMethodCallIgnored dir.delete(); diff --git a/p2p/src/test/java/bisq/network/p2p/network/LocalhostNetworkNodeTest.java b/p2p/src/test/java/bisq/network/p2p/network/LocalhostNetworkNodeTest.java index 1ec4f8b8c1..1a09281e0d 100644 --- a/p2p/src/test/java/bisq/network/p2p/network/LocalhostNetworkNodeTest.java +++ b/p2p/src/test/java/bisq/network/p2p/network/LocalhostNetworkNodeTest.java @@ -19,10 +19,6 @@ package bisq.network.p2p.network; import bisq.network.p2p.TestUtils; -import org.bouncycastle.jce.provider.BouncyCastleProvider; - -import java.security.Security; - import java.io.IOException; import java.util.concurrent.CountDownLatch; @@ -30,7 +26,6 @@ import java.util.concurrent.CountDownLatch; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -43,10 +38,7 @@ import org.junit.Test; public class LocalhostNetworkNodeTest { private static final Logger log = LoggerFactory.getLogger(LocalhostNetworkNodeTest.class); - @Before - public void setup() { - Security.addProvider(new BouncyCastleProvider()); - } + @Test diff --git a/p2p/src/test/java/bisq/network/p2p/network/TorNetworkNodeTest.java b/p2p/src/test/java/bisq/network/p2p/network/TorNetworkNodeTest.java index bc4654d424..2245a3ebd9 100644 --- a/p2p/src/test/java/bisq/network/p2p/network/TorNetworkNodeTest.java +++ b/p2p/src/test/java/bisq/network/p2p/network/TorNetworkNodeTest.java @@ -24,10 +24,6 @@ import com.google.common.util.concurrent.FutureCallback; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.SettableFuture; -import org.bouncycastle.jce.provider.BouncyCastleProvider; - -import java.security.Security; - import java.io.File; import java.io.IOException; @@ -38,7 +34,6 @@ import org.slf4j.LoggerFactory; import org.jetbrains.annotations.NotNull; -import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -52,10 +47,7 @@ public class TorNetworkNodeTest { private static final Logger log = LoggerFactory.getLogger(TorNetworkNodeTest.class); private CountDownLatch latch; - @Before - public void setup() { - Security.addProvider(new BouncyCastleProvider()); - } + @Test public void testTorNodeBeforeSecondReady() throws InterruptedException, IOException { diff --git a/p2p/src/test/java/bisq/network/p2p/storage/P2PDataStorageTest.java b/p2p/src/test/java/bisq/network/p2p/storage/P2PDataStorageTest.java index 06d70e8a3d..b8cd84bea7 100644 --- a/p2p/src/test/java/bisq/network/p2p/storage/P2PDataStorageTest.java +++ b/p2p/src/test/java/bisq/network/p2p/storage/P2PDataStorageTest.java @@ -31,13 +31,10 @@ import bisq.common.proto.network.NetworkProtoResolver; import bisq.common.proto.persistable.PersistenceProtoResolver; import bisq.common.storage.FileUtil; -import org.bouncycastle.jce.provider.BouncyCastleProvider; - import java.security.InvalidKeyException; import java.security.KeyPair; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; -import java.security.Security; import java.security.SignatureException; import java.security.cert.CertificateException; @@ -84,7 +81,7 @@ public class P2PDataStorageTest { @Before public void setup() throws InterruptedException, NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException, CryptoException, SignatureException, InvalidKeyException { - Security.addProvider(new BouncyCastleProvider()); + dir1 = File.createTempFile("temp_tests1", ""); //noinspection ResultOfMethodCallIgnored dir1.delete(); diff --git a/p2p/src/test/java/bisq/network/p2p/storage/ProtectedDataStorageTest.java b/p2p/src/test/java/bisq/network/p2p/storage/ProtectedDataStorageTest.java index 3b01880ce5..3a1bb64107 100644 --- a/p2p/src/test/java/bisq/network/p2p/storage/ProtectedDataStorageTest.java +++ b/p2p/src/test/java/bisq/network/p2p/storage/ProtectedDataStorageTest.java @@ -34,14 +34,11 @@ import bisq.common.crypto.KeyStorage; import bisq.common.crypto.Sig; import bisq.common.storage.FileUtil; -import org.bouncycastle.jce.provider.BouncyCastleProvider; - import java.security.InvalidKeyException; import java.security.KeyPair; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; -import java.security.Security; import java.security.SignatureException; import java.security.cert.CertificateException; @@ -84,7 +81,7 @@ public class ProtectedDataStorageTest { @Before public void setup() throws InterruptedException, NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException, CryptoException, SignatureException, InvalidKeyException { - Security.addProvider(new BouncyCastleProvider()); + dir1 = File.createTempFile("temp_tests1", ""); //noinspection ResultOfMethodCallIgnored,ResultOfMethodCallIgnored dir1.delete(); diff --git a/p2p/src/test/java/bisq/network/p2p/storage/messages/AddDataMessageTest.java b/p2p/src/test/java/bisq/network/p2p/storage/messages/AddDataMessageTest.java index 4c79f85682..fd49b153ee 100644 --- a/p2p/src/test/java/bisq/network/p2p/storage/messages/AddDataMessageTest.java +++ b/p2p/src/test/java/bisq/network/p2p/storage/messages/AddDataMessageTest.java @@ -32,12 +32,9 @@ import io.bisq.generated.protobuffer.PB; import org.apache.commons.lang3.RandomUtils; -import org.bouncycastle.jce.provider.BouncyCastleProvider; - import java.security.InvalidKeyException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; -import java.security.Security; import java.security.SignatureException; import java.security.cert.CertificateException; @@ -60,7 +57,7 @@ public class AddDataMessageTest { @Before public void setup() throws InterruptedException, NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException, CryptoException, SignatureException, InvalidKeyException { - Security.addProvider(new BouncyCastleProvider()); + dir1 = File.createTempFile("temp_tests1", ""); //noinspection ResultOfMethodCallIgnored dir1.delete();