On Wednesday 08 April 2009 01:28:41 Daniel Cheng wrote:
> On Wed, Apr 8, 2009 at 4:02 AM, Matthew Toseland
> <toad at amphibian.dyndns.org> wrote:
> > On Tuesday 07 April 2009 16:26:42 j16sdiz at freenetproject.org wrote:
> >> Author: j16sdiz
> >> Date: 2009-04-07 15:26:41 +0000 (Tue, 07 Apr 2009)
> >> New Revision: 26609
> >>
> >> Modified:
> >> ? ?trunk/freenet/src/freenet/crypt/Yarrow.java
> >> Log:
> >> Use int[] instead of Integer, save autoboxing and put()
> >>
> >> Modified: trunk/freenet/src/freenet/crypt/Yarrow.java
> >> ===================================================================
> >> --- trunk/freenet/src/freenet/crypt/Yarrow.java ? ? ? 2009-04-07 15:06:39 
UTC (rev
> > 26608)
> >> +++ trunk/freenet/src/freenet/crypt/Yarrow.java ? ? ? 2009-04-07 15:26:41 
UTC (rev
> > 26609)
> >> @@ -444,12 +444,12 @@
> >> ? ? ? private MessageDigest fast_pool, ?slow_pool;
> >> ? ? ? private int fast_entropy, ?slow_entropy;
> >> ? ? ? private boolean fast_select;
> >> - ? ? private Map<EntropySource, Integer> entropySeen;
> >> + ? ? private Map<EntropySource, int[]> entropySeen;
> >>
> >> ? ? ? private void accumulator_init(String digest) throws
> > NoSuchAlgorithmException {
> >> ? ? ? ? ? ? ? fast_pool = MessageDigest.getInstance(digest);
> >> ? ? ? ? ? ? ? slow_pool = MessageDigest.getInstance(digest);
> >> - ? ? ? ? ? ? entropySeen = new HashMap<EntropySource, Integer>();
> >> + ? ? ? ? ? ? entropySeen = new HashMap<EntropySource, int[]>();
> >> ? ? ? }
> >>
> >> ? ? ? @Override
> >> @@ -515,21 +515,21 @@
> >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? slow_entropy += actualEntropy;
> >>
> >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if(source != null) {
> >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Integer contributedEntropy = 
entropySeen.get(source);
> >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if(contributedEntropy == null)
> >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? contributedEntropy = 
Integer.valueOf(actualEntropy);
> >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? else
> >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? contributedEntropy = 
Integer.valueOf(actualEntropy +
> > contributedEntropy.intValue());
> >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? entropySeen.put(source, 
contributedEntropy);
> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int[] contributedEntropy = 
entropySeen.get(source);
> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? if(contributedEntropy == null) {
> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? contributedEntropy = new 
int[] { actualEntropy };
> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? entropySeen.put(source, 
contributedEntropy);
> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? } else
> >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? contributedEntropy[0]++;
> >
> > Wrong.
> > contributedEntropy[0] += actualEntropy;
> > Please do not make mistakes in crypt/!
> > Otherwise it's a neat optimisation, although using a MutableInt would be
> > cleaner.
> 
> fixed in r26629.
> 
> (this is in the reseed from entropy source code path.)
> btw, the current code maybe reseeding too infrequent.
> 
> This is the current reseed logic:
>    (1) we have more then  (SLOW_THRESHOLD * 2) bits in slow_entropy
>  _AND_
>    (2) those entropy are from TWO DIFFERENT source, each contribute more 
then
>           THRESHOLD bits
> 
> However, we have ONLY TWO sources,
> the TWO DIFFERENT sources requirement is too hard to meet.

Yeah. And one of the sources (incoming packet hashes) always reports 0, as it 
may be observable/influencible. Ideas?

BTW, what are the two sources?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
URL: 
<https://emu.freenetproject.org/pipermail/devl/attachments/20090408/2d7fc1a9/attachment.pgp>

Reply via email to