--- old/test/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java Wed Mar 23 16:12:16 2016 +++ new/test/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java Wed Mar 23 16:12:16 2016 @@ -23,8 +23,8 @@ /** * @test - * @bug 7196382 - * @summary Ensure that 2048-bit DH key pairs can be generated + * @bug 7196382 8072452 + * @summary Ensure that DH key pairs can be generated for 512 - 4096 bits * @author Valerie Peng * @library .. * @run main/othervm TestDH2048 @@ -54,11 +54,41 @@ return; } KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH", p); - kpg.initialize(2048); + kpg.initialize(512); KeyPair kp1 = kpg.generateKeyPair(); - checkUnsupportedKeySize(kpg, 1536); - checkUnsupportedKeySize(kpg, 2176); - checkUnsupportedKeySize(kpg, 3072); + + kpg.initialize(1024); + kp1 = kpg.generateKeyPair(); + + kpg.initialize(1536); + kp1 = kpg.generateKeyPair(); + + kpg.initialize(2048); + kp1 = kpg.generateKeyPair(); + + try { + kpg.initialize(3072); + kp1 = kpg.generateKeyPair(); + + kpg.initialize(4096); + kp1 = kpg.generateKeyPair(); + + kpg.initialize(6144); + kp1 = kpg.generateKeyPair(); + + kpg.initialize(8192); + kp1 = kpg.generateKeyPair(); + } catch (InvalidParameterException ipe) { + // NSS has a hard coded maximum limit of 2236 bits for DHE keys + System.out.println("4096-bit DH key pair generation: " + ipe); + if (!p.getName().equals("SunPKCS11-NSS")) { + throw ipe; + } + } + + // key size must be multiples of 64 though + checkUnsupportedKeySize(kpg, 2048 + 63); + checkUnsupportedKeySize(kpg, 3072 + 32); } public static void main(String[] args) throws Exception {