@@ -78,6 +78,16 @@ protected String getDetailMessageNoCipherSuite()
78
78
return "No selectable cipher suite" ;
79
79
}
80
80
81
+ protected int getMaximumDefaultCurveBits ()
82
+ {
83
+ return NamedGroup .getCurveBits (NamedGroup .secp521r1 );
84
+ }
85
+
86
+ protected int getMaximumDefaultFiniteFieldBits ()
87
+ {
88
+ return NamedGroup .getFiniteFieldBits (NamedGroup .ffdhe8192 );
89
+ }
90
+
81
91
protected int getMaximumNegotiableCurveBits ()
82
92
{
83
93
int maxBits = 0 ;
@@ -96,7 +106,7 @@ protected int getMaximumNegotiableCurveBits()
96
106
* extensions. In this case, the server is free to choose any one of the elliptic curves or point
97
107
* formats [...].
98
108
*/
99
- maxBits = NamedGroup . getMaximumCurveBits ();
109
+ maxBits = getMaximumDefaultCurveBits ();
100
110
}
101
111
return maxBits ;
102
112
}
@@ -121,7 +131,7 @@ protected int getMaximumNegotiableFiniteFieldBits()
121
131
* entirely or contains no FFDHE groups (i.e., no codepoints between 256 and 511, inclusive), then
122
132
* the server [...] MAY select an FFDHE cipher suite and offer an FFDHE group of its choice [...].
123
133
*/
124
- maxBits = NamedGroup . getMaximumFiniteFieldBits ();
134
+ maxBits = getMaximumDefaultFiniteFieldBits ();
125
135
}
126
136
return maxBits ;
127
137
}
@@ -153,22 +163,32 @@ protected boolean selectCipherSuite(int cipherSuite) throws IOException
153
163
154
164
protected int selectDH (int minimumFiniteFieldBits )
155
165
{
166
+ boolean anyPeerFF = false ;
156
167
int [] clientSupportedGroups = context .getSecurityParametersHandshake ().getClientSupportedGroups ();
157
- if (clientSupportedGroups == null )
158
- {
159
- return selectDHDefault (minimumFiniteFieldBits );
160
- }
161
-
162
- // Try to find a supported named group of the required size from the client's list.
163
- for (int i = 0 ; i < clientSupportedGroups .length ; ++i )
168
+ if (clientSupportedGroups != null )
164
169
{
165
- int namedGroup = clientSupportedGroups [ i ];
166
- if ( NamedGroup . getFiniteFieldBits ( namedGroup ) >= minimumFiniteFieldBits )
170
+ // Try to find a supported named group of the required size from the client's list.
171
+ for ( int i = 0 ; i < clientSupportedGroups . length ; ++ i )
167
172
{
168
- return namedGroup ;
173
+ int namedGroup = clientSupportedGroups [i ];
174
+ anyPeerFF |= NamedGroup .isFiniteField (namedGroup );
175
+
176
+ if (NamedGroup .getFiniteFieldBits (namedGroup ) >= minimumFiniteFieldBits )
177
+ {
178
+ // This default server implementation supports all NamedGroup finite fields
179
+ return namedGroup ;
180
+ }
169
181
}
170
182
}
171
-
183
+ if (!anyPeerFF )
184
+ {
185
+ /*
186
+ * RFC 7919 4. If [...] the Supported Groups extension is either absent from the ClientHello
187
+ * entirely or contains no FFDHE groups (i.e., no codepoints between 256 and 511, inclusive), then
188
+ * the server [...] MAY select an FFDHE cipher suite and offer an FFDHE group of its choice [...].
189
+ */
190
+ return selectDHDefault (minimumFiniteFieldBits );
191
+ }
172
192
return -1 ;
173
193
}
174
194
@@ -187,6 +207,11 @@ protected int selectECDH(int minimumCurveBits)
187
207
int [] clientSupportedGroups = context .getSecurityParametersHandshake ().getClientSupportedGroups ();
188
208
if (clientSupportedGroups == null )
189
209
{
210
+ /*
211
+ * RFC 4492 4. A client that proposes ECC cipher suites may choose not to include these
212
+ * extensions. In this case, the server is free to choose any one of the elliptic curves or point
213
+ * formats [...].
214
+ */
190
215
return selectECDHDefault (minimumCurveBits );
191
216
}
192
217
@@ -196,6 +221,7 @@ protected int selectECDH(int minimumCurveBits)
196
221
int namedGroup = clientSupportedGroups [i ];
197
222
if (NamedGroup .getCurveBits (namedGroup ) >= minimumCurveBits )
198
223
{
224
+ // This default server implementation supports all NamedGroup curves
199
225
return namedGroup ;
200
226
}
201
227
}
0 commit comments