8154344: sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java fails on solaris
Reviewed-by: weijun
This commit is contained in:
parent
b962e07463
commit
155e6796dd
@ -71,18 +71,19 @@ public class SupportedDHKeys extends PKCS11Test {
|
||||
KeyPairGenerator.getInstance("DiffieHellman", provider);
|
||||
kpg.initialize(keySize.primeSize);
|
||||
KeyPair kp = kpg.generateKeyPair();
|
||||
checkKeyPair(kp, keySize.primeSize);
|
||||
checkKeyPair(kp, keySize.primeSize, provider);
|
||||
|
||||
DHPublicKey publicKey = (DHPublicKey)kp.getPublic();
|
||||
BigInteger p = publicKey.getParams().getP();
|
||||
BigInteger g = publicKey.getParams().getG();
|
||||
kpg.initialize(new DHParameterSpec(p, g));
|
||||
kp = kpg.generateKeyPair();
|
||||
checkKeyPair(kp, keySize.primeSize);
|
||||
checkKeyPair(kp, keySize.primeSize, provider);
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkKeyPair(KeyPair kp, int pSize) throws Exception {
|
||||
private static void checkKeyPair(KeyPair kp, int pSize,
|
||||
Provider provider) throws Exception {
|
||||
|
||||
DHPrivateKey privateKey = (DHPrivateKey)kp.getPrivate();
|
||||
BigInteger p = privateKey.getParams().getP();
|
||||
@ -106,18 +107,22 @@ public class SupportedDHKeys extends PKCS11Test {
|
||||
BigInteger leftOpen = BigInteger.ONE;
|
||||
BigInteger rightOpen = p.subtract(BigInteger.ONE);
|
||||
|
||||
BigInteger x = privateKey.getX();
|
||||
if ((x.compareTo(leftOpen) <= 0) ||
|
||||
(x.compareTo(rightOpen) >= 0)) {
|
||||
throw new Exception(
|
||||
"X outside range [2, p - 2]: x: " + x + " p: " + p);
|
||||
// ignore the private key range checking on Solaris at present
|
||||
if (provider.getName().equals("SunPKCS11-Solaris") &&
|
||||
!System.getProperty("os.name").equals("SunOS")) {
|
||||
BigInteger x = privateKey.getX();
|
||||
if ((x.compareTo(leftOpen) <= 0) ||
|
||||
(x.compareTo(rightOpen) >= 0)) {
|
||||
throw new Exception(
|
||||
"X outside range [2, p - 2]: x: " + x + " p: " + p);
|
||||
}
|
||||
}
|
||||
|
||||
BigInteger y = publicKey.getY();
|
||||
if ((y.compareTo(leftOpen) <= 0) ||
|
||||
(y.compareTo(rightOpen) >= 0)) {
|
||||
throw new Exception(
|
||||
"Y outside range [2, p - 2]: x: " + x + " p: " + p);
|
||||
"Y outside range [2, p - 2]: y: " + y + " p: " + p);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user