test/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java
Print this page
8072452 Support DHE sizes up to 8192-bits
@@ -21,12 +21,12 @@
* questions.
*/
/**
* @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
* @run main/othervm TestDH2048 sm
*/
@@ -52,16 +52,46 @@
if (p.getService("KeyPairGenerator", "DH") == null) {
System.out.println("KPG for DH not supported, skipping");
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 {
main(new TestDH2048(), args);
}
}