1 |
--- jdk8/jdk/src/share/classes/com/sun/crypto/provider/DHKeyPairGenerator.java Tue Mar 17 00:09:12 2015 +0300 |
diff --git a/src/share/classes/com/sun/crypto/provider/DHKeyPairGenerator.java b/src/share/classes/com/sun/crypto/provider/DHKeyPairGenerator.java |
2 |
+++ jdk8/jdk/src/share/classes/com/sun/crypto/provider/DHKeyPairGenerator.java Wed Apr 08 14:25:54 2015 +0100 |
--- openjdk/jdk/src/share/classes/com/sun/crypto/provider/DHKeyPairGenerator.java |
3 |
@@ -1,5 +1,6 @@ |
+++ openjdk/jdk/src/share/classes/com/sun/crypto/provider/DHKeyPairGenerator.java |
4 |
|
@@ -1,5 +1,6 @@ |
5 |
/* |
/* |
6 |
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
7 |
+ * Copyright (c) 2014 Red Hat Inc. |
+ * Copyright (c) 2014 Red Hat Inc. |
8 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9 |
* |
* |
10 |
* This code is free software; you can redistribute it and/or modify it |
* This code is free software; you can redistribute it and/or modify it |
11 |
@@ -80,10 +81,10 @@ |
@@ -74,10 +75,10 @@ |
12 |
* @param random the source of randomness |
private static void checkKeySize(int keysize) |
13 |
*/ |
throws InvalidParameterException { |
|
public void initialize(int keysize, SecureRandom random) { |
|
|
- if ((keysize < 512) || (keysize > 2048) || (keysize % 64 != 0)) { |
|
|
+ if ((keysize < 512) || (keysize > 4096) || (keysize % 64 != 0)) { |
|
|
throw new InvalidParameterException("Keysize must be multiple " |
|
|
+ "of 64, and can only range " |
|
|
- + "from 512 to 2048 " |
|
|
+ + "from 512 to 4096 " |
|
|
+ "(inclusive)"); |
|
|
} |
|
|
this.pSize = keysize; |
|
|
@@ -115,11 +116,11 @@ |
|
14 |
|
|
15 |
params = (DHParameterSpec)algParams; |
- if ((keysize < 512) || (keysize > 2048) || ((keysize & 0x3F) != 0)) { |
16 |
pSize = params.getP().bitLength(); |
+ if ((keysize < 512) || (keysize > 4096) || ((keysize & 0x3F) != 0)) { |
17 |
- if ((pSize < 512) || (pSize > 2048) || |
throw new InvalidParameterException( |
18 |
+ if ((pSize < 512) || (pSize > 4096) || |
"DH key size must be multiple of 64, and can only range " + |
19 |
(pSize % 64 != 0)) { |
- "from 512 to 2048 (inclusive). " + |
20 |
throw new InvalidAlgorithmParameterException |
+ "from 512 to 4096 (inclusive). " + |
21 |
("Prime size must be multiple of 64, and can only range " |
"The specific key size " + keysize + " is not supported"); |
|
- + "from 512 to 2048 (inclusive)"); |
|
|
+ + "from 512 to 4096 (inclusive)"); |
|
22 |
} |
} |
23 |
|
} |
24 |
// exponent size is optional, could be 0 |
diff --git a/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java b/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java |
25 |
--- jdk8/jdk/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java Tue Mar 17 00:09:12 2015 +0300 |
--- openjdk/jdk/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java |
26 |
+++ jdk8/jdk/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java Wed Apr 08 14:25:54 2015 +0100 |
+++ openjdk/jdk/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java |
27 |
@@ -1,5 +1,6 @@ |
@@ -1,5 +1,6 @@ |
28 |
/* |
/* |
29 |
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
30 |
+ * Copyright (c) 2014 Red Hat Inc. |
+ * Copyright (c) 2014 Red Hat Inc. |
31 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
32 |
* |
* |
33 |
* This code is free software; you can redistribute it and/or modify it |
* This code is free software; you can redistribute it and/or modify it |
34 |
@@ -60,11 +61,11 @@ |
@@ -60,11 +61,11 @@ |
35 |
|
|
36 |
private static void checkKeySize(int keysize) |
private static void checkKeySize(int keysize) |
37 |
throws InvalidAlgorithmParameterException { |
throws InvalidParameterException { |
38 |
- if ((keysize != 2048) && |
- if ((keysize != 2048) && |
39 |
+ if ((keysize != 2048) && (keysize != 4096) && |
+ if ((keysize != 2048) && (keysize != 4096) && |
40 |
((keysize < 512) || (keysize > 1024) || (keysize % 64 != 0))) { |
((keysize < 512) || (keysize > 1024) || (keysize % 64 != 0))) { |
41 |
throw new InvalidAlgorithmParameterException( |
throw new InvalidParameterException( |
42 |
"Keysize must be multiple of 64 ranging from " |
"DH key size must be multiple of 64 and range " + |
43 |
- + "512 to 1024 (inclusive), or 2048"); |
- "from 512 to 1024 (inclusive), or 2048. " + |
44 |
+ + "512 to 1024 (inclusive), or 2048, or 4096"); |
+ "from 512 to 1024 (inclusive), or 2048, or 4096. " + |
45 |
|
"The specific key size " + keysize + " is not supported"); |
46 |
} |
} |
47 |
} |
} |
48 |
|
diff --git a/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java b/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java |
49 |
--- jdk8/jdk/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java Tue Mar 17 00:09:12 2015 +0300 |
--- openjdk/jdk/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java |
50 |
+++ jdk8/jdk/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java Wed Apr 08 14:25:54 2015 +0100 |
+++ openjdk/jdk/src/share/classes/sun/security/pkcs11/P11KeyPairGenerator.java |
51 |
@@ -278,11 +278,11 @@ |
@@ -285,11 +285,11 @@ |
52 |
// this restriction is in the spec for DSA |
// this restriction is in the spec for DSA |
53 |
// since we currently use DSA parameters for DH as well, |
// since we currently use DSA parameters for DH as well, |
54 |
// it also applies to DH if no parameters are specified |
// it also applies to DH if no parameters are specified |
57 |
((keySize > 1024) || ((keySize & 0x3f) != 0))) { |
((keySize > 1024) || ((keySize & 0x3f) != 0))) { |
58 |
throw new InvalidAlgorithmParameterException(algorithm + |
throw new InvalidAlgorithmParameterException(algorithm + |
59 |
" key must be multiples of 64 if less than 1024 bits" + |
" key must be multiples of 64 if less than 1024 bits" + |
60 |
- ", or 2048 bits"); |
- ", or 2048 bits. " + |
61 |
+ ", or 2048 bits, or 4096 bits"); |
+ ", or 2048 bits, or 4096 bits. " + |
62 |
|
"The specific key size " + |
63 |
|
keySize + " is not supported"); |
64 |
} |
} |
65 |
} |
diff --git a/test/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java b/test/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java |
66 |
} |
--- openjdk/jdk/test/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java |
67 |
--- jdk8/jdk/test/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java Tue Mar 17 00:09:12 2015 +0300 |
+++ openjdk/jdk/test/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java |
68 |
+++ jdk8/jdk/test/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java Wed Apr 08 14:25:54 2015 +0100 |
@@ -1,5 +1,6 @@ |
|
@@ -1,5 +1,6 @@ |
|
69 |
/* |
/* |
70 |
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. |
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. |
71 |
+ * Copyright (c) 2014 Red Hat Inc. |
+ * Copyright (c) 2014 Red Hat Inc. |
72 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
73 |
* |
* |
74 |
* This code is free software; you can redistribute it and/or modify it |
* This code is free software; you can redistribute it and/or modify it |
75 |
@@ -58,7 +59,7 @@ |
@@ -58,7 +59,7 @@ |
76 |
*/ |
*/ |
77 |
private enum Sizes { |
private enum Sizes { |
78 |
two56(256), three84(384), five12(512), seven68(768), ten24(1024), |
two56(256), three84(384), five12(512), seven68(768), ten24(1024), |
81 |
|
|
82 |
private final int intSize; |
private final int intSize; |
83 |
private final BigInteger bigIntValue; |
private final BigInteger bigIntValue; |
84 |
@@ -130,6 +131,19 @@ |
@@ -130,6 +131,19 @@ |
85 |
kp = kpg.generateKeyPair(); |
kp = kpg.generateKeyPair(); |
86 |
checkKeyPair(kp, Sizes.twenty48, Sizes.five12); |
checkKeyPair(kp, Sizes.twenty48, Sizes.five12); |
87 |
|
|
101 |
System.out.println("OK"); |
System.out.println("OK"); |
102 |
} |
} |
103 |
|
|
|
|
|