Update of /cvsroot/freenet/freenet/src/freenet/crypt
In directory sc8-pr-cvs1:/tmp/cvs-serv5586/src/freenet/crypt
Modified Files:
Yarrow.java DiffieHellman.java
ThrottledAsyncEntropyYarrow.java
Log Message:
Work around problem with ThrottleAsyncEntropyYarrow/Yarrow initialization order.
Made randSource in Core private and started exposing it though a getter instead of
directly.
Index: Yarrow.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/crypt/Yarrow.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -w -r1.10 -r1.11
--- Yarrow.java 27 Oct 2003 13:39:00 -0000 1.10
+++ Yarrow.java 27 Oct 2003 14:45:16 -0000 1.11
@@ -82,14 +82,18 @@
consumeString(java.net.InetAddress.getLocalHost().toString());
} catch (Exception e) {}
+ readStartupEntropy(startupEntropy);
+
+ read_seed(seed);
+ }
+
+ protected void readStartupEntropy(EntropySource startupEntropy) {
// Consume the current time
acceptEntropy(startupEntropy, System.currentTimeMillis(), 0);
// Free memory
acceptEntropy(startupEntropy, Runtime.getRuntime().freeMemory(), 0);
// Total memory
acceptEntropy(startupEntropy, Runtime.getRuntime().totalMemory(), 0);
-
- read_seed(seed);
}
/**
Index: DiffieHellman.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/crypt/DiffieHellman.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -r1.3 -r1.4
--- DiffieHellman.java 3 Jul 2003 03:33:42 -0000 1.3
+++ DiffieHellman.java 27 Oct 2003 14:45:16 -0000 1.4
@@ -13,7 +13,7 @@
public class DiffieHellman {
private static final int PRECALC = 15;
- private static Random r = Core.randSource;
+ private static Random r = Core.getRandSource();
private static DHGroup group = Global.DHgroupA;
private static Stack precalcBuffer = new Stack();
Index: ThrottledAsyncEntropyYarrow.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/crypt/ThrottledAsyncEntropyYarrow.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -r1.1 -r1.2
--- ThrottledAsyncEntropyYarrow.java 27 Oct 2003 13:39:00 -0000 1.1
+++ ThrottledAsyncEntropyYarrow.java 27 Oct 2003 14:45:16 -0000 1.2
@@ -16,7 +16,7 @@
public class ThrottledAsyncEntropyYarrow extends Yarrow {
long maxEntropyQueueSize;
Thread entropyProcessor;
- BlockingQueue entropy= new BlockingQueue();
+ BlockingQueue entropy;
private class EntropyQueueItem {
EntropySource source;
long data;
@@ -31,13 +31,27 @@
{
super(seed,digest,cipher);
this.maxEntropyQueueSize = maxEntropyQueueSize;
+ initialize();
+ }
+
+ public int acceptEntropy(EntropySource source, long data, int entropyGuess) {
+ int i;
+ if(entropy.size() < maxEntropyQueueSize)
+ entropy.enqueue(new
EntropyQueueItem(source,data,entropyGuess));
+ else
+ i = 0;
+ return 32; //TODO: What should we do here.. seem like no part of fred
currently uses the retuned value /[EMAIL PROTECTED]
+ }
+ private void initialize() {
+ //entropy = new BlockingQueue(); Done in readStartupEntropy below
entropyProcessor = new Thread(new Runnable() {
public void run(){
while(true)
try{
EntropyQueueItem e =
(EntropyQueueItem)entropy.dequeue();
ThrottledAsyncEntropyYarrow.super.acceptEntropy(e.source, e.data, e.entropyGuess);
- }catch(InterruptedException e){}
+ } catch (InterruptedException e) {
+ }
}
});
entropyProcessor.setDaemon(true);
@@ -45,13 +59,15 @@
entropyProcessor.start();
}
- public int acceptEntropy(EntropySource source, long data, int entropyGuess) {
- int i;
- if(entropy.size() < maxEntropyQueueSize)
- entropy.enqueue(new
EntropyQueueItem(source,data,entropyGuess));
- else
- i = 0;
- return 32; //TODO: What should we do here.. seem like no part of fred
currently uses the retuned value /[EMAIL PROTECTED]
+ protected void readStartupEntropy(EntropySource startupEntropy) {
+ //This method is called during Yarrow:s initialization which is run
before our own..
+ //this is how I splice in the instanciation of the BlockingQueue and a
temporary queuesize..
+ //Quite ugly way of doing it but, well if someone knows a better way
of doing it then
+ //feel free...
+ if(maxEntropyQueueSize == 0)
+ maxEntropyQueueSize = 100;
+ entropy = new BlockingQueue();
+ super.readStartupEntropy(startupEntropy);
}
}
_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs