Blame SOURCES/rh1163501-increase_2048_bit_dh_upper_bound_fedora_infrastructure_in_dhparametergenerator.patch

53c576
diff --git a/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java b/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java
53c576
--- openjdk/jdk/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java
53c576
+++ openjdk/jdk/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java
53c576
@@ -1,5 +1,6 @@
53c576
 /*
53c576
  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
53c576
+ * Copyright (c) 2014 Red Hat Inc.
53c576
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
53c576
  *
53c576
  * This code is free software; you can redistribute it and/or modify it
53c576
@@ -61,13 +62,13 @@
53c576
 
53c576
     private static void checkKeySize(int keysize)
53c576
             throws InvalidParameterException {
53c576
-        boolean supported = ((keysize == 2048) || (keysize == 3072) ||
53c576
+        boolean supported = ((keysize == 2048) || (keysize == 3072) || (keysize == 4096) ||
53c576
             ((keysize >= 512) && (keysize <= 1024) && ((keysize & 0x3F) == 0)));
53c576
 
53c576
         if (!supported) {
53c576
             throw new InvalidParameterException(
53c576
                     "DH key size must be multiple of 64 and range " +
53c576
-                    "from 512 to 1024 (inclusive), or 2048, 3072. " +
53c576
+                    "from 512 to 1024 (inclusive), or 2048, 3072, 4096. " +
53c576
                     "The specific key size " + keysize + " is not supported");
53c576
         }
53c576
     }
53c576
diff --git a/test/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java b/test/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java
53c576
--- openjdk/jdk/test/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java
53c576
+++ openjdk/jdk/test/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java
53c576
@@ -1,5 +1,6 @@
53c576
 /*
53c576
  * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
53c576
+ * Copyright (c) 2014 Red Hat Inc.
53c576
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
53c576
  *
53c576
  * This code is free software; you can redistribute it and/or modify it
53c576
@@ -58,7 +59,7 @@
53c576
      */
53c576
     private enum Sizes {
53c576
         two56(256), three84(384), five12(512), seven68(768), ten24(1024),
53c576
-        twenty48(2048);
53c576
+        twenty48(2048), forty96(4096);
53c576
 
53c576
         private final int intSize;
53c576
         private final BigInteger bigIntValue;
53c576
@@ -130,6 +131,19 @@
53c576
         kp = kpg.generateKeyPair();
53c576
         checkKeyPair(kp, Sizes.twenty48, Sizes.five12);
53c576
 
53c576
+        kpg.initialize(Sizes.forty96.getIntSize());
53c576
+        kp = kpg.generateKeyPair();
53c576
+        checkKeyPair(kp, Sizes.forty96, Sizes.twenty48);
53c576
+
53c576
+        publicKey = (DHPublicKey)kp.getPublic();
53c576
+        p = publicKey.getParams().getP();
53c576
+        g = publicKey.getParams().getG();
53c576
+
53c576
+        // test w/ all values specified
53c576
+        kpg.initialize(new DHParameterSpec(p, g, Sizes.ten24.getIntSize()));
53c576
+        kp = kpg.generateKeyPair();
53c576
+        checkKeyPair(kp, Sizes.forty96, Sizes.ten24);
53c576
+
53c576
         System.out.println("OK");
53c576
     }
53c576
 
53c576