Skip to content

Commit 846a094

Browse files
committed
moved to Queue rather than Deque
1 parent 331b25d commit 846a094

File tree

1 file changed

+9
-7
lines changed
  • prov/src/main/java/org/bouncycastle/jcajce/provider/drbg

1 file changed

+9
-7
lines changed

prov/src/main/java/org/bouncycastle/jcajce/provider/drbg/DRBG.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99
import java.security.SecureRandom;
1010
import java.security.SecureRandomSpi;
1111
import java.security.Security;
12-
import java.util.concurrent.ConcurrentLinkedDeque;
12+
import java.util.concurrent.ConcurrentLinkedQueue;
1313
import java.util.concurrent.atomic.AtomicBoolean;
1414
import java.util.concurrent.atomic.AtomicInteger;
1515
import java.util.concurrent.atomic.AtomicReference;
1616
import java.util.logging.Level;
1717
import java.util.logging.Logger;
1818

19-
import org.bouncycastle.crypto.CryptoServicesRegistrar;
2019
import org.bouncycastle.crypto.digests.SHA512Digest;
2120
import org.bouncycastle.crypto.macs.HMac;
2221
import org.bouncycastle.crypto.prng.EntropySource;
@@ -33,7 +32,8 @@
3332

3433
/**
3534
* <b>DRBG Configuration</b><br/>
36-
* <p>org.bouncycastle.drbg.gather_pause_secs - is to stop the entropy collection thread from grabbing all
35+
* <p>
36+
* org.bouncycastle.drbg.gather_pause_secs - is to stop the entropy collection thread from grabbing all
3737
* available entropy on the system. The original motivation for the hybrid infrastructure was virtual machines
3838
* sometimes produce very few bits of entropy a second, the original approach (which "worked" at least for BC) was
3939
* to just read on the second thread and allow things to progress around it, but it did tend to hog the system
@@ -42,9 +42,11 @@
4242
* enough to allow everyone to work together, but small enough to ensure the provider's DRBG is being regularly
4343
* reseeded.
4444
* </p>
45-
* <p>org.bouncycastle.drbg.entropysource - is the class name for an implementation of EntropySourceProvider.
45+
* <p>
46+
* org.bouncycastle.drbg.entropysource - is the class name for an implementation of EntropySourceProvider.
4647
* For example, one could be provided which just reads directly from /dev/random and the extra infrastructure used here
47-
* could be avoided.</p>
48+
* could be avoided.
49+
* </p>
4850
*/
4951
public class DRBG
5052
{
@@ -301,7 +303,7 @@ private static byte[] generateNonceIVPersonalizationString(byte[] seed)
301303
private static class EntropyDaemon
302304
implements Runnable
303305
{
304-
private final ConcurrentLinkedDeque<Runnable> tasks = new ConcurrentLinkedDeque<Runnable>();
306+
private final ConcurrentLinkedQueue<Runnable> tasks = new ConcurrentLinkedQueue<Runnable>();
305307

306308
void addTask(Runnable task)
307309
{
@@ -313,7 +315,7 @@ public void run()
313315
{
314316
while (!Thread.currentThread().isInterrupted())
315317
{
316-
Runnable task = tasks.pollFirst();
318+
Runnable task = tasks.poll();
317319

318320
if (task != null)
319321
{

0 commit comments

Comments
 (0)