OpenJDK / loom / loom
changeset 37875:3d1383fb1d51
8154344: sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java fails on solaris
Reviewed-by: weijun
author | xuelei |
---|---|
date | Tue, 10 May 2016 00:44:28 +0000 |
parents | 02589df0999a |
children | 8c1ab93d657a |
files | jdk/test/sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java |
diffstat | 1 files changed, 14 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/jdk/test/sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java Mon May 09 23:33:09 2016 +0100 +++ b/jdk/test/sun/security/pkcs11/KeyAgreement/SupportedDHKeys.java Tue May 10 00:44:28 2016 +0000 @@ -71,18 +71,19 @@ 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 @@ 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); } }