[freenet-cvs] r15520 - trunk/freenet/src/freenet/crypt
nextgens at freenetproject.org
nextgens at freenetproject.org
Wed Oct 24 09:42:01 UTC 2007
Author: nextgens
Date: 2007-10-24 09:42:00 +0000 (Wed, 24 Oct 2007)
New Revision: 15520
Modified:
trunk/freenet/src/freenet/crypt/DiffieHellman.java
Log:
Add the missing test to DiffieHellman.checkDHExponentialValidity
Modified: trunk/freenet/src/freenet/crypt/DiffieHellman.java
===================================================================
--- trunk/freenet/src/freenet/crypt/DiffieHellman.java 2007-10-24 09:26:37 UTC (rev 15519)
+++ trunk/freenet/src/freenet/crypt/DiffieHellman.java 2007-10-24 09:42:00 UTC (rev 15520)
@@ -40,7 +40,8 @@
public static final BigInteger MIN_EXPONENTIAL_VALUE = new BigInteger("2").pow(24);
public static final BigInteger MAX_EXPONENTIAL_VALUE = group.getP().subtract(MIN_EXPONENTIAL_VALUE);
-
+ public static final BigInteger FORBIDDEN_VALUE = group.getP().subtract(BigInteger.ONE);
+
static {
precalcThread = new PrecalcBufferFill();
}
@@ -174,14 +175,18 @@
return false;
}
- //TODO: Shall we test if p-1 = -1 here ?
+ // Ensure that g^x != (p-1)
+ if(FORBIDDEN_VALUE.compareTo(exponential) == 0) {
+ Logger.error(caller, "The provided exponential is p-1 which is unacceptable!");
+ return false;
+ }
// Ensure that g^x > 2^24
if(MIN_EXPONENTIAL_VALUE.compareTo(exponential) > -1) {
Logger.error(caller, "The provided exponential is smaller than 2^24 which is unacceptable!");
return false;
}
- // Ensure that g^x < (p - 2^24)
+ // Ensure that g^x < (p-2^24)
if(MAX_EXPONENTIAL_VALUE.compareTo(exponential) < 1) {
Logger.error(DiffieHellman.class, "The provided exponential is bigger than (p - 2^24) which is unacceptable!");
return false;
More information about the cvs
mailing list