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