/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 6330287 6331386
* @summary verify that DHKeyPairGenerator returns keys of the expected size
* (modulus and exponent)
* -and-
* DHKeyPairGenerator is using BigInteger.setBit
* @author Andreas Sterbenz
*/
/*
* NOTE: BigInteger's bitlength() doesn't report leading zeros, only
* the number of bits needed to actually represent the number. i.e.
*
* new BigInteger("4").bitLength() = 3
*
* Since the private key x can vary 1 <= x <= p-2, we can't do any
* bitlength-based calculations here. But we can check that p conforms
* as expected.
*
* If not specified, we're currently using an lsize of Math.max(384, psize/2).
*/
public class TestExponentSize {
/*
* Sizes and values for various lengths.
*/
private enum Sizes {
private final int intSize;
}
int getIntSize() {
return intSize;
}
return bigIntValue;
}
}
// Sun's default uses a default psize of 1024/lsize of 512
}
exponentSize + ")");
}
throw new Exception("X has more bits than expected: " +
x.bitLength());
}
throw new Exception(
"X outside range 1<=x<p-2: x: " + x + " p: " + p);
}
}
}