Author: j16sdiz
Date: 2008-10-24 15:25:16 +0000 (Fri, 24 Oct 2008)
New Revision: 23083
Modified:
trunk/freenet/src/freenet/crypt/DSAGroup.java
trunk/freenet/src/freenet/crypt/Yarrow.java
Log:
unused fields and methods, restrict access
Modified: trunk/freenet/src/freenet/crypt/DSAGroup.java
===================================================================
--- trunk/freenet/src/freenet/crypt/DSAGroup.java 2008-10-24 15:24:54 UTC
(rev 23082)
+++ trunk/freenet/src/freenet/crypt/DSAGroup.java 2008-10-24 15:25:16 UTC
(rev 23083)
@@ -5,10 +5,7 @@
import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
import java.math.BigInteger;
-import java.util.Random;
-import java.util.Vector;
import net.i2p.util.NativeBigInteger;
import freenet.node.FSParseException;
@@ -24,16 +21,10 @@
public class DSAGroup extends CryptoKey {
private static final long serialVersionUID = -1;
- public static final int Q_BIT_LENGTH = 256;
+ protected static final int Q_BIT_LENGTH = 256;
private final BigInteger p, q, g;
- // of the
- // hexadecimal
- // string
- // representations
- // of p,q and g
-
public DSAGroup(BigInteger p, BigInteger q, BigInteger g) {
this.p = p;
this.q = q;
@@ -42,28 +33,6 @@
throw new IllegalArgumentException();
}
- public DSAGroup(String pAsHexString, String qAsHexString,
- String gAsHexString) throws NumberFormatException {
- //Sanity check. Needed because of the Kaffe workaround further down
- if ((pAsHexString == null) || (qAsHexString == null)
- || (gAsHexString == null))
- throw new NullPointerException("Invalid DSAGroup");
-
- try {
- this.p = new NativeBigInteger(pAsHexString, 16);
- this.q = new NativeBigInteger(qAsHexString, 16);
- this.g = new NativeBigInteger(gAsHexString, 16);
- } catch (NullPointerException e) {
- // yea, i know, don't catch NPEs .. but _some_ JVMs don't
- // throw the NFE like they are supposed to (*cough* kaffe)
- throw new NumberFormatException(e + " while converting "
- + pAsHexString + ',' + qAsHexString + " and "
- + gAsHexString + " to integers");
- }
- if(p.signum() != 1 || q.signum() != 1 || g.signum() != 1)
- throw new IllegalArgumentException();
- }
-
/**
* Parses a DSA Group from a string, where p, q, and g are in unsigned
* hex-strings, separated by a commas
@@ -91,17 +60,6 @@
}
}
- public void writeForWire(OutputStream out) throws IOException {
- Util.writeMPI(p, out);
- Util.writeMPI(q, out);
- Util.writeMPI(g, out);
- }
-
- // public void write(OutputStream out) throws IOException {
- // write(out, getClass().getName());
- // writeForWire(out);
- // }
-
@Override
public String keyType() {
return "DSA.g-" + p.bitLength();
@@ -128,59 +86,6 @@
return fingerprint(fp);
}
- static class QG extends Thread {
-
- public Vector qs = new Vector();
-
- protected Random r;
-
- public QG(Random r) {
- setDaemon(true);
- this.r = r;
- }
-
- @Override
- public void run() {
- while (true) {
- qs.addElement(makePrime(DSAGroup.Q_BIT_LENGTH, 80, r));
- synchronized (this) {
- notifyAll();
- }
- while (qs.size() >= 3) {
- synchronized (this) {
- try {
- wait(50);
- } catch (InterruptedException ie) {
- }
- }
- }
- }
- }
- }
-
- static BigInteger smallPrimes[] = new BigInteger[] { BigInteger.valueOf(3),
- BigInteger.valueOf(5), BigInteger.valueOf(7),
- BigInteger.valueOf(11), BigInteger.valueOf(13),
- BigInteger.valueOf(17), BigInteger.valueOf(19),
- BigInteger.valueOf(23), BigInteger.valueOf(29)};
-
- public static BigInteger makePrime(int bits, int confidence, Random r) {
- BigInteger rv;
- do {
- // FIXME: is this likely to get modPow()ed?
- // I don't suppose it matters, there isn't much overhead
- rv = new NativeBigInteger(bits, r).setBit(0).setBit(bits - 1);
- } while (!isPrime(rv, confidence));
- return rv;
- }
-
- public static boolean isPrime(BigInteger b, int confidence) {
- for (int i = 0; i < smallPrimes.length; i++) {
- if (b.mod(smallPrimes[i]).equals(BigInteger.ZERO)) return false;
- }
- return b.isProbablePrime(80);
- }
-
@Override
public byte[] asBytes() {
byte[] pb = Util.MPIbytes(p);
Modified: trunk/freenet/src/freenet/crypt/Yarrow.java
===================================================================
--- trunk/freenet/src/freenet/crypt/Yarrow.java 2008-10-24 15:24:54 UTC (rev
23082)
+++ trunk/freenet/src/freenet/crypt/Yarrow.java 2008-10-24 15:25:16 UTC (rev
23083)
@@ -102,7 +102,7 @@
slow_pool_reseed();
}
- public void seedFromExternalStuff(boolean canBlock) {
+ private void seedFromExternalStuff(boolean canBlock) {
byte[] buf = new byte[32];
if(File.separatorChar == '/') {
DataInputStream dis = null;
@@ -450,7 +450,7 @@
return totalRealEntropy;
}
- public int acceptEntropy(
+ private int acceptEntropy(
EntropySource source,
long data,
int entropyGuess,
@@ -498,7 +498,7 @@
if(slow_entropy >= (SLOW_THRESHOLD *
2)) {
int kc = 0;
- for(Enumeration enu =
entropySeen.keys(); enu.hasMoreElements();) {
+ for(Enumeration<EntropySource>
enu = entropySeen.keys(); enu.hasMoreElements();) {
Object key =
enu.nextElement();
Integer v =
entropySeen.get(key);
if(DEBUG)
@@ -768,16 +768,4 @@
slow_pool.update(bytes, 0, bytes.length);
fast_select = !fast_select;
}
-
- public String getCheckpointName() {
- return "Yarrow random number generator checkpoint";
- }
-
- public long nextCheckpoint() {
- return System.currentTimeMillis() + 60 * 60 * 1000;
- }
-
- public void checkpoint() {
- seedFromExternalStuff(true);
- }
}