On Saturday 03 May 2008 12:48, nextgens at freenetproject.org wrote:
> Author: nextgens
> Date: 2008-05-03 11:48:01 +0000 (Sat, 03 May 2008)
> New Revision: 19694
>
> Modified:
>
trunk/freenet/src/freenet/support/io/PaddedEphemerallyEncryptedBucket.java
> Log:
> Don't instanciate a new MT; use the existing one.
Does this mean we use the MT for key generation? We ought to use Yarrow for
that.
>
> Modified:
trunk/freenet/src/freenet/support/io/PaddedEphemerallyEncryptedBucket.java
> ===================================================================
> ---
trunk/freenet/src/freenet/support/io/PaddedEphemerallyEncryptedBucket.java
2008-05-03 11:45:09 UTC (rev 19693)
> +++
trunk/freenet/src/freenet/support/io/PaddedEphemerallyEncryptedBucket.java
2008-05-03 11:48:01 UTC (rev 19694)
> @@ -28,7 +28,7 @@
>
> private final Bucket bucket;
> private final int minPaddedSize;
> - private final RandomSource origRandom;
> + private final RandomSource randomSource;
> private SoftReference /* <Rijndael> */ aesRef;
> /** The decryption key. */
> private final byte[] key;
> @@ -45,7 +45,7 @@
> * @throws UnsupportedCipherException
> */
> public PaddedEphemerallyEncryptedBucket(Bucket bucket, int minSize,
RandomSource origRandom) {
> - this.origRandom = origRandom;
> + this.randomSource = origRandom;
> this.bucket = bucket;
> if(bucket.size() != 0) throw new
> IllegalArgumentException("Bucket must be
empty");
> byte[] tempKey = new byte[32];
> @@ -72,7 +72,7 @@
> if(bucket.size() < knownSize)
> throw new IOException("Bucket "+bucket+" is too small
> on disk -
knownSize="+knownSize+" but bucket.size="+bucket.size()+" for "+bucket);
> this.dataLength = knownSize;
> - this.origRandom = origRandom;
> + this.randomSource = origRandom;
> this.bucket = bucket;
> if(key.length != 32) throw new IllegalArgumentException("Key
> wrong
length: "+key.length);
> this.key = key;
> @@ -82,7 +82,7 @@
> }
>
> public PaddedEphemerallyEncryptedBucket(SimpleFieldSet fs, RandomSource
origRandom, PersistentFileTracker f) throws CannotCreateFromFieldSetException
{
> - this.origRandom = origRandom;
> + this.randomSource = origRandom;
> String tmp = fs.get("DataLength");
> if(tmp == null)
> throw new CannotCreateFromFieldSetException("No
> DataLength");
> @@ -180,14 +180,13 @@
> return;
> }
>
> synchronized(PaddedEphemerallyEncryptedBucket.this) {
> - MersenneTwister paddingSource = new
MersenneTwister(origRandom.nextLong());
> long finalLength = paddedLength();
> long padding = finalLength - dataLength;
> byte[] buf = new byte[4096];
> long writtenPadding = 0;
> while(writtenPadding < padding) {
> int left = (int)
> Math.min((padding - writtenPadding),
(long)buf.length);
> - paddingSource.nextBytes(buf);
> + randomSource.nextBytes(buf);
> out.write(buf, 0, left);
> writtenPadding += left;
> }
>
> _______________________________________________
> cvs mailing list
> cvs at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL:
<https://emu.freenetproject.org/pipermail/devl/attachments/20080503/9b2179b6/attachment.pgp>