Blame SOURCES/rh1163501.patch

c4ba7e
diff --git a/src/share/classes/com/sun/crypto/provider/DHKeyPairGenerator.java b/src/share/classes/com/sun/crypto/provider/DHKeyPairGenerator.java
c4ba7e
--- openjdk/jdk/src/share/classes/com/sun/crypto/provider/DHKeyPairGenerator.java
c4ba7e
+++ openjdk/jdk/src/share/classes/com/sun/crypto/provider/DHKeyPairGenerator.java
c4ba7e
@@ -1,5 +1,6 @@
c2cb23
 /*
a42b25
  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
c2cb23
+ * Copyright (c) 2014 Red Hat Inc.
c2cb23
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c2cb23
  *
c2cb23
  * This code is free software; you can redistribute it and/or modify it
c4ba7e
@@ -74,10 +75,10 @@
c4ba7e
     private static void checkKeySize(int keysize)
c4ba7e
             throws InvalidParameterException {
c2cb23
 
c4ba7e
-        if ((keysize < 512) || (keysize > 2048) || ((keysize & 0x3F) != 0)) {
c4ba7e
+        if ((keysize < 512) || (keysize > 4096) || ((keysize & 0x3F) != 0)) {
c4ba7e
             throw new InvalidParameterException(
c4ba7e
                     "DH key size must be multiple of 64, and can only range " +
c4ba7e
-                    "from 512 to 2048 (inclusive). " +
c4ba7e
+                    "from 512 to 4096 (inclusive). " +
c4ba7e
                     "The specific key size " + keysize + " is not supported");
c2cb23
         }
c4ba7e
     }
c4ba7e
diff --git a/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java b/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java
c4ba7e
--- openjdk/jdk/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java
c4ba7e
+++ openjdk/jdk/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java
c4ba7e
@@ -1,5 +1,6 @@
c2cb23
 /*
a42b25
  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
c2cb23
+ * Copyright (c) 2014 Red Hat Inc.
c2cb23
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c2cb23
  *
c2cb23
  * This code is free software; you can redistribute it and/or modify it
a42b25
@@ -61,11 +62,11 @@
c2cb23
 
c2cb23
     private static void checkKeySize(int keysize)
c4ba7e
             throws InvalidParameterException {
c4ba7e
-            if ((keysize != 2048) &&
c4ba7e
+            if ((keysize != 2048) && (keysize != 4096) &&
c2cb23
             ((keysize < 512) || (keysize > 1024) || (keysize % 64 != 0))) {
c4ba7e
             throw new InvalidParameterException(
c4ba7e
                     "DH key size must be multiple of 64 and range " +
c4ba7e
-                    "from 512 to 1024 (inclusive), or 2048. " +
c4ba7e
+                    "from 512 to 1024 (inclusive), or 2048, or 4096. " +
c4ba7e
                     "The specific key size " + keysize + " is not supported");
c2cb23
         }
c2cb23
     }
c4ba7e
diff --git a/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java b/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java
c4ba7e
--- openjdk/jdk/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java
c4ba7e
+++ openjdk/jdk/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java
a42b25
@@ -292,11 +292,11 @@
c2cb23
                     // this restriction is in the spec for DSA
c2cb23
                     // since we currently use DSA parameters for DH as well,
c2cb23
                     // it also applies to DH if no parameters are specified
c2cb23
-                    if ((keySize != 2048) &&
c2cb23
+                    if ((keySize != 2048) && (keySize != 4096) &&
c2cb23
                         ((keySize > 1024) || ((keySize & 0x3f) != 0))) {
c2cb23
                         throw new InvalidAlgorithmParameterException(algorithm +
c2cb23
                             " key must be multiples of 64 if less than 1024 bits" +
c4ba7e
-                            ", or 2048 bits. " +
c4ba7e
+                            ", or 2048 bits, or 4096 bits. " +
c4ba7e
                             "The specific key size " +
c4ba7e
                             keySize + " is not supported");
c2cb23
                     }
c4ba7e
diff --git a/test/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java b/test/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java
c4ba7e
--- openjdk/jdk/test/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java
c4ba7e
+++ openjdk/jdk/test/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java
c4ba7e
@@ -1,5 +1,6 @@
c2cb23
 /*
c2cb23
  * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
c2cb23
+ * Copyright (c) 2014 Red Hat Inc.
c2cb23
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c2cb23
  *
c2cb23
  * This code is free software; you can redistribute it and/or modify it
c4ba7e
@@ -58,7 +59,7 @@
c2cb23
      */
c2cb23
     private enum Sizes {
c2cb23
         two56(256), three84(384), five12(512), seven68(768), ten24(1024),
c2cb23
-        twenty48(2048);
c2cb23
+        twenty48(2048), forty96(4096);
c2cb23
 
c2cb23
         private final int intSize;
c2cb23
         private final BigInteger bigIntValue;
c4ba7e
@@ -130,6 +131,19 @@
c2cb23
         kp = kpg.generateKeyPair();
c2cb23
         checkKeyPair(kp, Sizes.twenty48, Sizes.five12);
c2cb23
 
c2cb23
+        kpg.initialize(Sizes.forty96.getIntSize());
c2cb23
+        kp = kpg.generateKeyPair();
c2cb23
+        checkKeyPair(kp, Sizes.forty96, Sizes.twenty48);
c2cb23
+
c2cb23
+        publicKey = (DHPublicKey)kp.getPublic();
c2cb23
+        p = publicKey.getParams().getP();
c2cb23
+        g = publicKey.getParams().getG();
c2cb23
+
c2cb23
+        // test w/ all values specified
c2cb23
+        kpg.initialize(new DHParameterSpec(p, g, Sizes.ten24.getIntSize()));
c2cb23
+        kp = kpg.generateKeyPair();
c2cb23
+        checkKeyPair(kp, Sizes.forty96, Sizes.ten24);
c2cb23
+
c2cb23
         System.out.println("OK");
c2cb23
     }
c2cb23