Skip to content

Commit

Permalink
added extra SHA1hmac oid
Browse files Browse the repository at this point in the history
work with threads to avoid Java 11 issues
  • Loading branch information
dghgit committed Apr 20, 2020
1 parent 22cfb08 commit 9da262f
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ public interface MiscObjectIdentifiers
*/
ASN1ObjectIdentifier cast5CBC = entrust.branch("66.10");

//
// HMAC-SHA1 hMAC-SHA1 OBJECT IDENTIFIER ::= { iso(1) identified-organization(3)
// dod(6) internet(1) security(5) mechanisms(5) 8 1 2 }
//
ASN1ObjectIdentifier hMAC_SHA1 = new ASN1ObjectIdentifier("1.3.6.1.5.5.8.1.2");

//
// Ascom
//
Expand Down
13 changes: 3 additions & 10 deletions prov/src/main/java/org/bouncycastle/jcajce/provider/drbg/DRBG.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import java.security.SecureRandom;
import java.security.SecureRandomSpi;
import java.security.Security;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
Expand Down Expand Up @@ -370,8 +368,6 @@ public Integer run()
private static class HybridSecureRandom
extends SecureRandom
{
private final ExecutorService rngThread = Executors.newFixedThreadPool(1);

private final AtomicBoolean seedAvailable = new AtomicBoolean(false);
private final AtomicInteger samples = new AtomicInteger(0);
private final SecureRandom baseRandom = createInitialEntropySource();
Expand Down Expand Up @@ -427,11 +423,6 @@ public byte[] generateSeed(int numBytes)
return data;
}

public void finalize()
{
rngThread.shutdown();
}

private class SignallingEntropySource
implements EntropySource
{
Expand Down Expand Up @@ -464,7 +455,9 @@ public byte[] getEntropy()

if (!scheduled.getAndSet(true))
{
rngThread.execute(new EntropyGatherer(byteLength));
Thread gatherer = new Thread(new EntropyGatherer(byteLength));
gatherer.setDaemon(true);
gatherer.start();
}

return seed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public void run()
}
}
});
t.setDaemon(true);
t.setPriority(Thread.MIN_PRIORITY);
t.start();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ public int open(byte[] response)
this.response = response;
Thread t = new Thread(this);
t.setPriority(Thread.MIN_PRIORITY);
t.setDaemon(true);
t.start();
ready.await(5, TimeUnit.SECONDS);
return port;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ static void handshakeCompleted(Runnable notifyRunnable)
{
String name = "BCJSSE-HandshakeCompleted-" + (threadNumber.getAndIncrement() & 0x7FFFFFFF);

new Thread(notifyRunnable, name).start();
Thread t = new Thread(notifyRunnable, name);
t.setDaemon(true);
t.start();
}

static BCExtendedSSLSession importHandshakeSession(SSLSocket sslSocket)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ static void handshakeCompleted(Runnable notifyRunnable)
{
String name = "BCJSSE-HandshakeCompleted-" + Integer.toUnsignedString(threadNumber.getAndIncrement());

new Thread(null, notifyRunnable, name, 0, false).start();
Thread t = new Thread(null, notifyRunnable, name, 0, false);
t.setDaemon(true);
t.start();
}

static BCExtendedSSLSession importHandshakeSession(SSLSocket sslSocket)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ public void run()
}
};

new Thread(serverTask).start();
Thread t = new Thread(serverTask);
t.setDaemon(true);
t.start();

try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
import java.net.Socket;
import java.util.concurrent.Callable;

import org.bouncycastle.util.Strings;

import junit.framework.Assert;
import org.bouncycastle.util.Strings;

class TestProtocolUtil
{
Expand Down Expand Up @@ -52,11 +51,13 @@ public static void runClientAndServer(BlockingCallable server, BlockingCallable
{
TestProtocolUtil.Task serverTask = new TestProtocolUtil.Task(server);
Thread serverThread = new Thread(serverTask);
serverThread.setDaemon(true);
serverThread.start();
server.await();

TestProtocolUtil.Task clientTask = new TestProtocolUtil.Task(client);
Thread clientThread = new Thread(clientTask);
clientThread.setDaemon(true);
clientThread.start();
client.await();

Expand Down

0 comments on commit 9da262f

Please sign in to comment.