Author: nextgens
Date: 2006-12-13 20:37:43 +0000 (Wed, 13 Dec 2006)
New Revision: 11381

Modified:
   trunk/freenet/src/freenet/crypt/DSAGroupGenerator.java
   trunk/freenet/test/freenet/crypt/DSAGroupGeneratorTest.java
Log:
Fix the unit test, add GPL a header, and a comment

Modified: trunk/freenet/src/freenet/crypt/DSAGroupGenerator.java
===================================================================
--- trunk/freenet/src/freenet/crypt/DSAGroupGenerator.java      2006-12-13 
20:20:22 UTC (rev 11380)
+++ trunk/freenet/src/freenet/crypt/DSAGroupGenerator.java      2006-12-13 
20:37:43 UTC (rev 11381)
@@ -188,6 +188,9 @@
        return obuf;
        }

+       /**
+        * WARNING: it won't work reliably for integers above 30
+        */
        public static boolean isPrime(BigInteger b) {
         for (int i = 0; i < smallPrimes.length; i++) {
             if (b.mod(smallPrimes[i]).equals(BigInteger.ZERO)) return false;

Modified: trunk/freenet/test/freenet/crypt/DSAGroupGeneratorTest.java
===================================================================
--- trunk/freenet/test/freenet/crypt/DSAGroupGeneratorTest.java 2006-12-13 
20:20:22 UTC (rev 11380)
+++ trunk/freenet/test/freenet/crypt/DSAGroupGeneratorTest.java 2006-12-13 
20:37:43 UTC (rev 11381)
@@ -1,3 +1,18 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
 package test.freenet.crypt;

 import java.math.BigInteger;
@@ -5,15 +20,19 @@
 import freenet.crypt.DSAGroupGenerator;
 import junit.framework.TestCase;

+/**
+ * Test case for the {@link freenet.crypt.DSAGroupGeneratorTest} class.
+ * 
+ * @author Florent Daigni;egrave;re &gt;nextgens at freenetproject.org&gt;
+ */
 public class DSAGroupGeneratorTest extends TestCase {

-       public void testIsPrime() {
+       public void testIsPrime() { // No need to test below 30 as it won't 
work anyway
                assertFalse(DSAGroupGenerator.isPrime(BigInteger.ZERO));
                assertFalse(DSAGroupGenerator.isPrime(BigInteger.ONE));

                assertTrue(DSAGroupGenerator.isPrime(BigInteger.valueOf(2)));
-               assertTrue(DSAGroupGenerator.isPrime(BigInteger.valueOf(3)));
-               assertTrue(DSAGroupGenerator.isPrime(BigInteger.valueOf(1029)));
+               assertTrue(DSAGroupGenerator.isPrime(BigInteger.valueOf(1021)));

                assertFalse(DSAGroupGenerator.isPrime(BigInteger.valueOf(55)));
        }


Reply via email to