1 |
diff --git a/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java b/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java |
2 |
--- openjdk/jdk/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java |
3 |
+++ openjdk/jdk/src/share/classes/com/sun/crypto/provider/DHParameterGenerator.java |
4 |
@@ -1,5 +1,6 @@ |
5 |
/* |
6 |
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
7 |
+ * Copyright (c) 2014 Red Hat Inc. |
8 |
* 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 |
11 |
@@ -61,13 +62,13 @@ |
12 |
|
13 |
private static void checkKeySize(int keysize) |
14 |
throws InvalidParameterException { |
15 |
- boolean supported = ((keysize == 2048) || (keysize == 3072) || |
16 |
+ boolean supported = ((keysize == 2048) || (keysize == 3072) || (keysize == 4096) || |
17 |
((keysize >= 512) && (keysize <= 1024) && ((keysize & 0x3F) == 0))); |
18 |
|
19 |
if (!supported) { |
20 |
throw new InvalidParameterException( |
21 |
"DH key size must be multiple of 64 and range " + |
22 |
- "from 512 to 1024 (inclusive), or 2048, 3072. " + |
23 |
+ "from 512 to 1024 (inclusive), or 2048, 3072, 4096. " + |
24 |
"The specific key size " + keysize + " is not supported"); |
25 |
} |
26 |
} |
27 |
diff --git a/test/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java b/test/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java |
28 |
--- openjdk/jdk/test/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java |
29 |
+++ openjdk/jdk/test/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java |
30 |
@@ -1,5 +1,6 @@ |
31 |
/* |
32 |
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. |
33 |
+ * Copyright (c) 2014 Red Hat Inc. |
34 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
35 |
* |
36 |
* This code is free software; you can redistribute it and/or modify it |
37 |
@@ -58,7 +59,7 @@ |
38 |
*/ |
39 |
private enum Sizes { |
40 |
two56(256), three84(384), five12(512), seven68(768), ten24(1024), |
41 |
- twenty48(2048); |
42 |
+ twenty48(2048), forty96(4096); |
43 |
|
44 |
private final int intSize; |
45 |
private final BigInteger bigIntValue; |
46 |
@@ -130,6 +131,19 @@ |
47 |
kp = kpg.generateKeyPair(); |
48 |
checkKeyPair(kp, Sizes.twenty48, Sizes.five12); |
49 |
|
50 |
+ kpg.initialize(Sizes.forty96.getIntSize()); |
51 |
+ kp = kpg.generateKeyPair(); |
52 |
+ checkKeyPair(kp, Sizes.forty96, Sizes.twenty48); |
53 |
+ |
54 |
+ publicKey = (DHPublicKey)kp.getPublic(); |
55 |
+ p = publicKey.getParams().getP(); |
56 |
+ g = publicKey.getParams().getG(); |
57 |
+ |
58 |
+ // test w/ all values specified |
59 |
+ kpg.initialize(new DHParameterSpec(p, g, Sizes.ten24.getIntSize())); |
60 |
+ kp = kpg.generateKeyPair(); |
61 |
+ checkKeyPair(kp, Sizes.forty96, Sizes.ten24); |
62 |
+ |
63 |
System.out.println("OK"); |
64 |
} |
65 |
|
66 |
|