Author: toad
Date: 2007-03-17 15:45:47 +0000 (Sat, 17 Mar 2007)
New Revision: 12193
Modified:
trunk/freenet/src/freenet/crypt/DSAGroup.java
Log:
Delete old group generator code (obsoleted by DSAGroupGenerator)
Modified: trunk/freenet/src/freenet/crypt/DSAGroup.java
===================================================================
--- trunk/freenet/src/freenet/crypt/DSAGroup.java 2007-03-17 15:45:27 UTC
(rev 12192)
+++ trunk/freenet/src/freenet/crypt/DSAGroup.java 2007-03-17 15:45:47 UTC
(rev 12193)
@@ -175,96 +175,6 @@
return b.isProbablePrime(80);
}
- static boolean multithread = true;
-
- public static DSAGroup generate(int bits, Random r) {
- BigInteger p, q, g;
- int cc = 0;
- QG qg = null;
- if (multithread) {
- qg = new QG(r);
- qg.start();
- }
-
- assert(qg != null);
-
- do {
- if ((cc++) % 15 == 0) System.err.print(".");
- if (multithread) {
- while (qg.qs.size() < 1) {
- try {
- synchronized (qg) {
- qg.wait(50);
- }
- } catch (InterruptedException ie) {
- }
- }
- q = (BigInteger) qg.qs.elementAt(0);
- qg.qs.removeElementAt(0);
-
- synchronized (qg) {
- qg.notifyAll();
- }
- } else
- q = makePrime(DSAGroup.Q_BIT_LENGTH, 80, r);
-
- BigInteger X = new BigInteger(bits, r).setBit(bits - 1);
-
- BigInteger c = X.mod(q.multiply(Util.TWO));
- p = X.subtract(c.subtract(BigInteger.ONE));
- if (isPrime(p, 80)) break;
- } while (true);
- qg.qs.trimToSize();
- BigInteger pmin1 = p.subtract(BigInteger.ONE);
- BigInteger h;
- do {
- if ((cc++) % 5 == 0) System.err.print("+");
- h = new NativeBigInteger(bits, r);
- g = h.modPow(pmin1.divide(q), p);
- } while ((h.compareTo(p.subtract(BigInteger.ONE)) != -1)
- || (h.compareTo(BigInteger.ONE) < 1)
- || (g.compareTo(BigInteger.ONE) == 0)
- || (g.bitLength() != bits));
- return new DSAGroup(p, q, g);
- }
-
- public static boolean testGroup(DSAGroup grp) {
- BigInteger p, q, g;
- p = grp.getP();
- q = grp.getQ();
- g = grp.getG();
- BigInteger pmin1 = p.subtract(BigInteger.ONE);
- // TODO: that's FIPS-186-1, we should consider implementing 3 insteed!
- //
http://csrc.nist.gov/publications/drafts/fips_186-3/Draft-FIPS-186-3%20_March2006.pdf
- boolean rv = !((p.bitLength() > 1024) || (p.bitLength() < 512))
- && ((p.bitLength() % 64) == 0) && (q.bitLength() ==
DSAGroup.Q_BIT_LENGTH)
- && (q.compareTo(p) == -1) && isPrime(p, 80) && isPrime(q, 80)
- && pmin1.mod(q).equals(BigInteger.ZERO)
- && (g.compareTo(BigInteger.ONE) == 1)
- && !g.equals(pmin1.modPow(pmin1.divide(q), p));
- return rv;
- }
-
- // public static void main(String[] args) throws IOException {
- // if (args[0].equals("test")) {
- // System.out.print("GroupA: ");
- // System.out.println(testGroup(Global.DSAgroupA));
- // System.out.print("GroupB: ");
- // System.out.println(testGroup(Global.DSAgroupB));
- // System.out.print("GroupC: ");
- // System.out.println(testGroup(Global.DSAgroupC));
- // } else {
- // DSAGroup g =
- // generate(
- // Integer.parseInt(args[0]),
- // new Yarrow("/dev/urandom", "SHA1",
"Rijndael",true));
- // System.err.print("\nVerifying group: ");
- // System.err.println(testGroup(g) ? "passed" : "failed");
- // g.write(System.out);
- // // System.out.println("Identity.group="+g.writeAsField());
- // }
- // }
- //
public byte[] asBytes() {
byte[] pb = Util.MPIbytes(p);
byte[] qb = Util.MPIbytes(q);