2
|
1 |
/*
|
715
|
2 |
* Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
|
2
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation. Sun designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Sun in the LICENSE file that accompanied this code.
|
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
23 |
* have any questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
|
|
27 |
package sun.security.ssl;
|
|
28 |
|
|
29 |
import java.util.*;
|
|
30 |
|
|
31 |
import java.security.NoSuchAlgorithmException;
|
|
32 |
import java.security.InvalidKeyException;
|
|
33 |
|
|
34 |
import javax.crypto.SecretKey;
|
|
35 |
import javax.crypto.spec.IvParameterSpec;
|
|
36 |
import javax.crypto.spec.SecretKeySpec;
|
|
37 |
|
|
38 |
import sun.security.ssl.CipherSuite.*;
|
|
39 |
import static sun.security.ssl.CipherSuite.KeyExchange.*;
|
|
40 |
import static sun.security.ssl.JsseJce.*;
|
|
41 |
|
|
42 |
/**
|
|
43 |
* An SSL/TLS CipherSuite. Constants for the standard key exchange, cipher,
|
|
44 |
* and mac algorithms are also defined in this class.
|
|
45 |
*
|
|
46 |
* The CipherSuite class and the inner classes defined in this file roughly
|
|
47 |
* follow the type safe enum pattern described in Effective Java. This means:
|
|
48 |
*
|
|
49 |
* . instances are immutable, classes are final
|
|
50 |
*
|
|
51 |
* . there is a unique instance of every value, i.e. there are never two
|
|
52 |
* instances representing the same CipherSuite, etc. This means equality
|
|
53 |
* tests can be performed using == instead of equals() (although that works
|
|
54 |
* as well). [A minor exception are *unsupported* CipherSuites read from a
|
|
55 |
* handshake message, but this is usually irrelevant]
|
|
56 |
*
|
|
57 |
* . instances are obtained using the static valueOf() factory methods.
|
|
58 |
*
|
|
59 |
* . properties are defined as final variables and made available as
|
|
60 |
* package private variables without method accessors
|
|
61 |
*
|
|
62 |
* . if the member variable allowed is false, the given algorithm is either
|
|
63 |
* unavailable or disabled at compile time
|
|
64 |
*
|
|
65 |
*/
|
|
66 |
final class CipherSuite implements Comparable {
|
|
67 |
|
|
68 |
// minimum priority for supported CipherSuites
|
|
69 |
final static int SUPPORTED_SUITES_PRIORITY = 1;
|
|
70 |
|
|
71 |
// minimum priority for default enabled CipherSuites
|
|
72 |
final static int DEFAULT_SUITES_PRIORITY = 300;
|
|
73 |
|
|
74 |
// Flag indicating if CipherSuite availability can change dynamically.
|
|
75 |
// This is the case when we rely on a JCE cipher implementation that
|
|
76 |
// may not be available in the installed JCE providers.
|
|
77 |
// It is true because we do not have a Java ECC implementation.
|
|
78 |
final static boolean DYNAMIC_AVAILABILITY = true;
|
|
79 |
|
|
80 |
private final static boolean ALLOW_ECC = Debug.getBooleanProperty
|
|
81 |
("com.sun.net.ssl.enableECC", true);
|
|
82 |
|
|
83 |
// Map Integer(id) -> CipherSuite
|
|
84 |
// contains all known CipherSuites
|
|
85 |
private final static Map<Integer,CipherSuite> idMap;
|
|
86 |
|
|
87 |
// Map String(name) -> CipherSuite
|
|
88 |
// contains only supported CipherSuites (i.e. allowed == true)
|
|
89 |
private final static Map<String,CipherSuite> nameMap;
|
|
90 |
|
|
91 |
// Protocol defined CipherSuite name, e.g. SSL_RSA_WITH_RC4_128_MD5
|
|
92 |
// we use TLS_* only for new CipherSuites, still SSL_* for old ones
|
|
93 |
final String name;
|
|
94 |
|
|
95 |
// id in 16 bit MSB format, i.e. 0x0004 for SSL_RSA_WITH_RC4_128_MD5
|
|
96 |
final int id;
|
|
97 |
|
|
98 |
// priority for the internal default preference order. the higher the
|
|
99 |
// better. Each supported CipherSuite *must* have a unique priority.
|
|
100 |
// Ciphersuites with priority >= DEFAULT_SUITES_PRIORITY are enabled
|
|
101 |
// by default
|
|
102 |
final int priority;
|
|
103 |
|
|
104 |
// key exchange, bulk cipher, and mac algorithms. See those classes below.
|
|
105 |
final KeyExchange keyExchange;
|
|
106 |
final BulkCipher cipher;
|
|
107 |
final MacAlg macAlg;
|
|
108 |
|
|
109 |
// whether a CipherSuite qualifies as exportable under 512/40 bit rules.
|
|
110 |
final boolean exportable;
|
|
111 |
|
|
112 |
// true iff implemented and enabled at compile time
|
|
113 |
final boolean allowed;
|
|
114 |
|
|
115 |
private CipherSuite(String name, int id, int priority,
|
|
116 |
KeyExchange keyExchange, BulkCipher cipher, boolean allowed) {
|
|
117 |
this.name = name;
|
|
118 |
this.id = id;
|
|
119 |
this.priority = priority;
|
|
120 |
this.keyExchange = keyExchange;
|
|
121 |
this.cipher = cipher;
|
|
122 |
this.exportable = cipher.exportable;
|
|
123 |
if (name.endsWith("_MD5")) {
|
|
124 |
macAlg = M_MD5;
|
|
125 |
} else if (name.endsWith("_SHA")) {
|
|
126 |
macAlg = M_SHA;
|
|
127 |
} else if (name.endsWith("_NULL")) {
|
|
128 |
macAlg = M_NULL;
|
|
129 |
} else {
|
|
130 |
throw new IllegalArgumentException
|
|
131 |
("Unknown MAC algorithm for ciphersuite " + name);
|
|
132 |
}
|
|
133 |
|
|
134 |
allowed &= keyExchange.allowed;
|
|
135 |
allowed &= cipher.allowed;
|
|
136 |
this.allowed = allowed;
|
|
137 |
}
|
|
138 |
|
|
139 |
private CipherSuite(String name, int id) {
|
|
140 |
this.name = name;
|
|
141 |
this.id = id;
|
|
142 |
this.allowed = false;
|
|
143 |
|
|
144 |
this.priority = 0;
|
|
145 |
this.keyExchange = null;
|
|
146 |
this.cipher = null;
|
|
147 |
this.macAlg = null;
|
|
148 |
this.exportable = false;
|
|
149 |
}
|
|
150 |
|
|
151 |
/**
|
|
152 |
* Return whether this CipherSuite is available for use. A
|
|
153 |
* CipherSuite may be unavailable even if it is supported
|
|
154 |
* (i.e. allowed == true) if the required JCE cipher is not installed.
|
|
155 |
* In some configuration, this situation may change over time, call
|
|
156 |
* CipherSuiteList.clearAvailableCache() before this method to obtain
|
|
157 |
* the most current status.
|
|
158 |
*/
|
|
159 |
boolean isAvailable() {
|
|
160 |
return allowed && keyExchange.isAvailable() && cipher.isAvailable();
|
|
161 |
}
|
|
162 |
|
|
163 |
/**
|
|
164 |
* Compares CipherSuites based on their priority. Has the effect of
|
|
165 |
* sorting CipherSuites when put in a sorted collection, which is
|
|
166 |
* used by CipherSuiteList. Follows standard Comparable contract.
|
|
167 |
*
|
|
168 |
* Note that for unsupported CipherSuites parsed from a handshake
|
|
169 |
* message we violate the equals() contract.
|
|
170 |
*/
|
|
171 |
public int compareTo(Object o) {
|
|
172 |
return ((CipherSuite)o).priority - priority;
|
|
173 |
}
|
|
174 |
|
|
175 |
/**
|
|
176 |
* Returns this.name.
|
|
177 |
*/
|
|
178 |
public String toString() {
|
|
179 |
return name;
|
|
180 |
}
|
|
181 |
|
|
182 |
/**
|
|
183 |
* Return a CipherSuite for the given name. The returned CipherSuite
|
|
184 |
* is supported by this implementation but may not actually be
|
|
185 |
* currently useable. See isAvailable().
|
|
186 |
*
|
|
187 |
* @exception IllegalArgumentException if the CipherSuite is unknown or
|
|
188 |
* unsupported.
|
|
189 |
*/
|
|
190 |
static CipherSuite valueOf(String s) {
|
|
191 |
if (s == null) {
|
|
192 |
throw new IllegalArgumentException("Name must not be null");
|
|
193 |
}
|
51
|
194 |
CipherSuite c = nameMap.get(s);
|
2
|
195 |
if ((c == null) || (c.allowed == false)) {
|
|
196 |
throw new IllegalArgumentException("Unsupported ciphersuite " + s);
|
|
197 |
}
|
|
198 |
return c;
|
|
199 |
}
|
|
200 |
|
|
201 |
/**
|
|
202 |
* Return a CipherSuite with the given ID. A temporary object is
|
|
203 |
* constructed if the ID is unknown. Use isAvailable() to verify that
|
|
204 |
* the CipherSuite can actually be used.
|
|
205 |
*/
|
|
206 |
static CipherSuite valueOf(int id1, int id2) {
|
|
207 |
id1 &= 0xff;
|
|
208 |
id2 &= 0xff;
|
|
209 |
int id = (id1 << 8) | id2;
|
|
210 |
CipherSuite c = idMap.get(id);
|
|
211 |
if (c == null) {
|
|
212 |
String h1 = Integer.toString(id1, 16);
|
|
213 |
String h2 = Integer.toString(id2, 16);
|
|
214 |
c = new CipherSuite("Unknown 0x" + h1 + ":0x" + h2, id);
|
|
215 |
}
|
|
216 |
return c;
|
|
217 |
}
|
|
218 |
|
|
219 |
// for use by CipherSuiteList only
|
|
220 |
static Collection<CipherSuite> allowedCipherSuites() {
|
|
221 |
return nameMap.values();
|
|
222 |
}
|
|
223 |
|
|
224 |
private static void add(String name, int id, int priority,
|
|
225 |
KeyExchange keyExchange, BulkCipher cipher, boolean allowed) {
|
|
226 |
CipherSuite c = new CipherSuite(name, id, priority, keyExchange,
|
|
227 |
cipher, allowed);
|
|
228 |
if (idMap.put(id, c) != null) {
|
|
229 |
throw new RuntimeException("Duplicate ciphersuite definition: "
|
|
230 |
+ id + ", " + name);
|
|
231 |
}
|
|
232 |
if (c.allowed) {
|
|
233 |
if (nameMap.put(name, c) != null) {
|
|
234 |
throw new RuntimeException("Duplicate ciphersuite definition: "
|
|
235 |
+ id + ", " + name);
|
|
236 |
}
|
|
237 |
}
|
|
238 |
}
|
|
239 |
|
|
240 |
private static void add(String name, int id) {
|
|
241 |
CipherSuite c = new CipherSuite(name, id);
|
|
242 |
if (idMap.put(id, c) != null) {
|
|
243 |
throw new RuntimeException("Duplicate ciphersuite definition: "
|
|
244 |
+ id + ", " + name);
|
|
245 |
}
|
|
246 |
}
|
|
247 |
|
|
248 |
/**
|
|
249 |
* An SSL/TLS key exchange algorithm.
|
|
250 |
*/
|
|
251 |
static enum KeyExchange {
|
|
252 |
|
|
253 |
// key exchange algorithms
|
|
254 |
K_NULL ("NULL", false),
|
|
255 |
K_RSA ("RSA", true),
|
|
256 |
K_RSA_EXPORT ("RSA_EXPORT", true),
|
|
257 |
K_DH_RSA ("DH_RSA", false),
|
|
258 |
K_DH_DSS ("DH_DSS", false),
|
|
259 |
K_DHE_DSS ("DHE_DSS", true),
|
|
260 |
K_DHE_RSA ("DHE_RSA", true),
|
|
261 |
K_DH_ANON ("DH_anon", true),
|
|
262 |
|
|
263 |
K_ECDH_ECDSA ("ECDH_ECDSA", ALLOW_ECC),
|
|
264 |
K_ECDH_RSA ("ECDH_RSA", ALLOW_ECC),
|
|
265 |
K_ECDHE_ECDSA("ECDHE_ECDSA", ALLOW_ECC),
|
|
266 |
K_ECDHE_RSA ("ECDHE_RSA", ALLOW_ECC),
|
|
267 |
K_ECDH_ANON ("ECDH_anon", ALLOW_ECC),
|
|
268 |
|
|
269 |
// Kerberos cipher suites
|
|
270 |
K_KRB5 ("KRB5", true),
|
|
271 |
K_KRB5_EXPORT("KRB5_EXPORT", true);
|
|
272 |
|
|
273 |
// name of the key exchange algorithm, e.g. DHE_DSS
|
|
274 |
final String name;
|
|
275 |
final boolean allowed;
|
|
276 |
private final boolean alwaysAvailable;
|
|
277 |
|
|
278 |
KeyExchange(String name, boolean allowed) {
|
|
279 |
this.name = name;
|
|
280 |
this.allowed = allowed;
|
|
281 |
this.alwaysAvailable = allowed && (name.startsWith("EC") == false);
|
|
282 |
}
|
|
283 |
|
|
284 |
boolean isAvailable() {
|
|
285 |
if (alwaysAvailable) {
|
|
286 |
return true;
|
|
287 |
}
|
|
288 |
return allowed && JsseJce.isEcAvailable();
|
|
289 |
}
|
|
290 |
|
|
291 |
public String toString() {
|
|
292 |
return name;
|
|
293 |
}
|
|
294 |
}
|
|
295 |
|
|
296 |
/**
|
|
297 |
* An SSL/TLS bulk cipher algorithm. One instance per combination of
|
|
298 |
* cipher and key length.
|
|
299 |
*
|
|
300 |
* Also contains a factory method to obtain in initialized CipherBox
|
|
301 |
* for this algorithm.
|
|
302 |
*/
|
|
303 |
final static class BulkCipher {
|
|
304 |
|
|
305 |
// Map BulkCipher -> Boolean(available)
|
|
306 |
private final static Map<BulkCipher,Boolean> availableCache =
|
|
307 |
new HashMap<BulkCipher,Boolean>(8);
|
|
308 |
|
|
309 |
// descriptive name including key size, e.g. AES/128
|
|
310 |
final String description;
|
|
311 |
|
|
312 |
// JCE cipher transformation string, e.g. AES/CBC/NoPadding
|
|
313 |
final String transformation;
|
|
314 |
|
|
315 |
// algorithm name, e.g. AES
|
|
316 |
final String algorithm;
|
|
317 |
|
|
318 |
// supported and compile time enabled. Also see isAvailable()
|
|
319 |
final boolean allowed;
|
|
320 |
|
|
321 |
// number of bytes of entropy in the key
|
|
322 |
final int keySize;
|
|
323 |
|
|
324 |
// length of the actual cipher key in bytes.
|
|
325 |
// for non-exportable ciphers, this is the same as keySize
|
|
326 |
final int expandedKeySize;
|
|
327 |
|
|
328 |
// size of the IV (also block size)
|
|
329 |
final int ivSize;
|
|
330 |
|
|
331 |
// exportable under 512/40 bit rules
|
|
332 |
final boolean exportable;
|
|
333 |
|
|
334 |
BulkCipher(String transformation, int keySize,
|
|
335 |
int expandedKeySize, int ivSize, boolean allowed) {
|
|
336 |
this.transformation = transformation;
|
|
337 |
this.algorithm = transformation.split("/")[0];
|
|
338 |
this.description = this.algorithm + "/" + (keySize << 3);
|
|
339 |
this.keySize = keySize;
|
|
340 |
this.ivSize = ivSize;
|
|
341 |
this.allowed = allowed;
|
|
342 |
|
|
343 |
this.expandedKeySize = expandedKeySize;
|
|
344 |
this.exportable = true;
|
|
345 |
}
|
|
346 |
|
|
347 |
BulkCipher(String transformation, int keySize, int ivSize, boolean allowed) {
|
|
348 |
this.transformation = transformation;
|
|
349 |
this.algorithm = transformation.split("/")[0];
|
|
350 |
this.description = this.algorithm + "/" + (keySize << 3);
|
|
351 |
this.keySize = keySize;
|
|
352 |
this.ivSize = ivSize;
|
|
353 |
this.allowed = allowed;
|
|
354 |
|
|
355 |
this.expandedKeySize = keySize;
|
|
356 |
this.exportable = false;
|
|
357 |
}
|
|
358 |
|
|
359 |
/**
|
|
360 |
* Return an initialized CipherBox for this BulkCipher.
|
|
361 |
* IV must be null for stream ciphers.
|
|
362 |
*
|
|
363 |
* @exception NoSuchAlgorithmException if anything goes wrong
|
|
364 |
*/
|
|
365 |
CipherBox newCipher(ProtocolVersion version, SecretKey key, IvParameterSpec iv,
|
|
366 |
boolean encrypt) throws NoSuchAlgorithmException {
|
|
367 |
return CipherBox.newCipherBox(version, this, key, iv, encrypt);
|
|
368 |
}
|
|
369 |
|
|
370 |
/**
|
|
371 |
* Test if this bulk cipher is available. For use by CipherSuite.
|
|
372 |
*
|
|
373 |
* Currently all supported ciphers except AES are always available
|
|
374 |
* via the JSSE internal implementations. We also assume AES/128
|
|
375 |
* is always available since it is shipped with the SunJCE provider.
|
|
376 |
* However, AES/256 is unavailable when the default JCE policy
|
|
377 |
* jurisdiction files are installed because of key length restrictions.
|
|
378 |
*/
|
|
379 |
boolean isAvailable() {
|
|
380 |
if (allowed == false) {
|
|
381 |
return false;
|
|
382 |
}
|
|
383 |
if (this == B_AES_256) {
|
|
384 |
return isAvailable(this);
|
|
385 |
}
|
|
386 |
// always available
|
|
387 |
return true;
|
|
388 |
}
|
|
389 |
|
|
390 |
// for use by CipherSuiteList.clearAvailableCache();
|
|
391 |
static synchronized void clearAvailableCache() {
|
|
392 |
if (DYNAMIC_AVAILABILITY) {
|
|
393 |
availableCache.clear();
|
|
394 |
}
|
|
395 |
}
|
|
396 |
|
|
397 |
private static synchronized boolean isAvailable(BulkCipher cipher) {
|
51
|
398 |
Boolean b = availableCache.get(cipher);
|
2
|
399 |
if (b == null) {
|
|
400 |
try {
|
|
401 |
SecretKey key = new SecretKeySpec
|
|
402 |
(new byte[cipher.expandedKeySize], cipher.algorithm);
|
|
403 |
IvParameterSpec iv = new IvParameterSpec(new byte[cipher.ivSize]);
|
|
404 |
cipher.newCipher(ProtocolVersion.DEFAULT, key, iv, true);
|
|
405 |
b = Boolean.TRUE;
|
|
406 |
} catch (NoSuchAlgorithmException e) {
|
|
407 |
b = Boolean.FALSE;
|
|
408 |
}
|
|
409 |
availableCache.put(cipher, b);
|
|
410 |
}
|
|
411 |
return b.booleanValue();
|
|
412 |
}
|
|
413 |
|
|
414 |
public String toString() {
|
|
415 |
return description;
|
|
416 |
}
|
|
417 |
}
|
|
418 |
|
|
419 |
/**
|
|
420 |
* An SSL/TLS key MAC algorithm.
|
|
421 |
*
|
|
422 |
* Also contains a factory method to obtain in initialized MAC
|
|
423 |
* for this algorithm.
|
|
424 |
*/
|
|
425 |
final static class MacAlg {
|
|
426 |
|
|
427 |
// descriptive name, e.g. MD5
|
|
428 |
final String name;
|
|
429 |
|
|
430 |
// size of the MAC value (and MAC key) in bytes
|
|
431 |
final int size;
|
|
432 |
|
|
433 |
MacAlg(String name, int size) {
|
|
434 |
this.name = name;
|
|
435 |
this.size = size;
|
|
436 |
}
|
|
437 |
|
|
438 |
/**
|
|
439 |
* Return an initialized MAC for this MacAlg. ProtocolVersion
|
|
440 |
* must either be SSL30 (SSLv3 custom MAC) or TLS10 (std. HMAC).
|
|
441 |
*
|
|
442 |
* @exception NoSuchAlgorithmException if anything goes wrong
|
|
443 |
*/
|
|
444 |
MAC newMac(ProtocolVersion protocolVersion, SecretKey secret)
|
|
445 |
throws NoSuchAlgorithmException, InvalidKeyException {
|
|
446 |
return new MAC(this, protocolVersion, secret);
|
|
447 |
}
|
|
448 |
|
|
449 |
public String toString() {
|
|
450 |
return name;
|
|
451 |
}
|
|
452 |
}
|
|
453 |
|
|
454 |
// export strength ciphers
|
|
455 |
final static BulkCipher B_NULL = new BulkCipher("NULL", 0, 0, 0, true);
|
|
456 |
final static BulkCipher B_RC4_40 = new BulkCipher(CIPHER_RC4, 5, 16, 0, true);
|
|
457 |
final static BulkCipher B_RC2_40 = new BulkCipher("RC2", 5, 16, 8, false);
|
|
458 |
final static BulkCipher B_DES_40 = new BulkCipher(CIPHER_DES, 5, 8, 8, true);
|
|
459 |
|
|
460 |
// domestic strength ciphers
|
|
461 |
final static BulkCipher B_RC4_128 = new BulkCipher(CIPHER_RC4, 16, 0, true);
|
|
462 |
final static BulkCipher B_DES = new BulkCipher(CIPHER_DES, 8, 8, true);
|
|
463 |
final static BulkCipher B_3DES = new BulkCipher(CIPHER_3DES, 24, 8, true);
|
|
464 |
final static BulkCipher B_IDEA = new BulkCipher("IDEA", 16, 8, false);
|
|
465 |
final static BulkCipher B_AES_128 = new BulkCipher(CIPHER_AES, 16, 16, true);
|
|
466 |
final static BulkCipher B_AES_256 = new BulkCipher(CIPHER_AES, 32, 16, true);
|
|
467 |
|
|
468 |
// MACs
|
|
469 |
final static MacAlg M_NULL = new MacAlg("NULL", 0);
|
|
470 |
final static MacAlg M_MD5 = new MacAlg("MD5", 16);
|
|
471 |
final static MacAlg M_SHA = new MacAlg("SHA", 20);
|
|
472 |
|
|
473 |
static {
|
|
474 |
idMap = new HashMap<Integer,CipherSuite>();
|
|
475 |
nameMap = new HashMap<String,CipherSuite>();
|
|
476 |
|
|
477 |
final boolean F = false;
|
|
478 |
final boolean T = true;
|
|
479 |
// N: ciphersuites only allowed if we are not in FIPS mode
|
|
480 |
final boolean N = (SunJSSE.isFIPS() == false);
|
|
481 |
|
|
482 |
add("SSL_NULL_WITH_NULL_NULL", 0x0000, 1, K_NULL, B_NULL, F);
|
|
483 |
|
|
484 |
// Definition of the CipherSuites that are enabled by default.
|
|
485 |
// They are listed in preference order, most preferred first.
|
|
486 |
int p = DEFAULT_SUITES_PRIORITY * 2;
|
|
487 |
|
|
488 |
add("SSL_RSA_WITH_RC4_128_MD5", 0x0004, --p, K_RSA, B_RC4_128, N);
|
|
489 |
add("SSL_RSA_WITH_RC4_128_SHA", 0x0005, --p, K_RSA, B_RC4_128, N);
|
|
490 |
add("TLS_RSA_WITH_AES_128_CBC_SHA", 0x002f, --p, K_RSA, B_AES_128, T);
|
|
491 |
add("TLS_RSA_WITH_AES_256_CBC_SHA", 0x0035, --p, K_RSA, B_AES_256, T);
|
|
492 |
|
|
493 |
add("TLS_ECDH_ECDSA_WITH_RC4_128_SHA", 0xC002, --p, K_ECDH_ECDSA, B_RC4_128, N);
|
|
494 |
add("TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA", 0xC004, --p, K_ECDH_ECDSA, B_AES_128, T);
|
|
495 |
add("TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA", 0xC005, --p, K_ECDH_ECDSA, B_AES_256, T);
|
|
496 |
add("TLS_ECDH_RSA_WITH_RC4_128_SHA", 0xC00C, --p, K_ECDH_RSA, B_RC4_128, N);
|
|
497 |
add("TLS_ECDH_RSA_WITH_AES_128_CBC_SHA", 0xC00E, --p, K_ECDH_RSA, B_AES_128, T);
|
|
498 |
add("TLS_ECDH_RSA_WITH_AES_256_CBC_SHA", 0xC00F, --p, K_ECDH_RSA, B_AES_256, T);
|
|
499 |
|
|
500 |
add("TLS_ECDHE_ECDSA_WITH_RC4_128_SHA", 0xC007, --p, K_ECDHE_ECDSA,B_RC4_128, N);
|
|
501 |
add("TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", 0xC009, --p, K_ECDHE_ECDSA,B_AES_128, T);
|
|
502 |
add("TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", 0xC00A, --p, K_ECDHE_ECDSA,B_AES_256, T);
|
|
503 |
add("TLS_ECDHE_RSA_WITH_RC4_128_SHA", 0xC011, --p, K_ECDHE_RSA, B_RC4_128, N);
|
|
504 |
add("TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", 0xC013, --p, K_ECDHE_RSA, B_AES_128, T);
|
|
505 |
add("TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", 0xC014, --p, K_ECDHE_RSA, B_AES_256, T);
|
|
506 |
|
|
507 |
add("TLS_DHE_RSA_WITH_AES_128_CBC_SHA", 0x0033, --p, K_DHE_RSA, B_AES_128, T);
|
|
508 |
add("TLS_DHE_RSA_WITH_AES_256_CBC_SHA", 0x0039, --p, K_DHE_RSA, B_AES_256, T);
|
|
509 |
add("TLS_DHE_DSS_WITH_AES_128_CBC_SHA", 0x0032, --p, K_DHE_DSS, B_AES_128, T);
|
|
510 |
add("TLS_DHE_DSS_WITH_AES_256_CBC_SHA", 0x0038, --p, K_DHE_DSS, B_AES_256, T);
|
|
511 |
|
|
512 |
add("SSL_RSA_WITH_3DES_EDE_CBC_SHA", 0x000a, --p, K_RSA, B_3DES, T);
|
|
513 |
add("TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA", 0xC003, --p, K_ECDH_ECDSA, B_3DES, T);
|
|
514 |
add("TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA", 0xC00D, --p, K_ECDH_RSA, B_3DES, T);
|
|
515 |
add("TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA", 0xC008, --p, K_ECDHE_ECDSA,B_3DES, T);
|
|
516 |
add("TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA", 0xC012, --p, K_ECDHE_RSA, B_3DES, T);
|
|
517 |
add("SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA", 0x0016, --p, K_DHE_RSA, B_3DES, T);
|
|
518 |
add("SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA", 0x0013, --p, K_DHE_DSS, B_3DES, N);
|
|
519 |
|
|
520 |
add("SSL_RSA_WITH_DES_CBC_SHA", 0x0009, --p, K_RSA, B_DES, N);
|
|
521 |
add("SSL_DHE_RSA_WITH_DES_CBC_SHA", 0x0015, --p, K_DHE_RSA, B_DES, N);
|
|
522 |
add("SSL_DHE_DSS_WITH_DES_CBC_SHA", 0x0012, --p, K_DHE_DSS, B_DES, N);
|
|
523 |
add("SSL_RSA_EXPORT_WITH_RC4_40_MD5", 0x0003, --p, K_RSA_EXPORT, B_RC4_40, N);
|
|
524 |
add("SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", 0x0008, --p, K_RSA_EXPORT, B_DES_40, N);
|
|
525 |
add("SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", 0x0014, --p, K_DHE_RSA, B_DES_40, N);
|
|
526 |
add("SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", 0x0011, --p, K_DHE_DSS, B_DES_40, N);
|
|
527 |
|
|
528 |
// Definition of the CipherSuites that are supported but not enabled
|
|
529 |
// by default.
|
|
530 |
// They are listed in preference order, preferred first.
|
|
531 |
p = DEFAULT_SUITES_PRIORITY;
|
|
532 |
|
|
533 |
// Anonymous key exchange and the NULL ciphers
|
|
534 |
add("SSL_RSA_WITH_NULL_MD5", 0x0001, --p, K_RSA, B_NULL, N);
|
|
535 |
add("SSL_RSA_WITH_NULL_SHA", 0x0002, --p, K_RSA, B_NULL, N);
|
|
536 |
add("TLS_ECDH_ECDSA_WITH_NULL_SHA", 0xC001, --p, K_ECDH_ECDSA, B_NULL, N);
|
|
537 |
add("TLS_ECDH_RSA_WITH_NULL_SHA", 0xC00B, --p, K_ECDH_RSA, B_NULL, N);
|
|
538 |
add("TLS_ECDHE_ECDSA_WITH_NULL_SHA", 0xC006, --p, K_ECDHE_ECDSA,B_NULL, N);
|
|
539 |
add("TLS_ECDHE_RSA_WITH_NULL_SHA", 0xC010, --p, K_ECDHE_RSA, B_NULL, N);
|
|
540 |
|
|
541 |
add("SSL_DH_anon_WITH_RC4_128_MD5", 0x0018, --p, K_DH_ANON, B_RC4_128, N);
|
|
542 |
add("TLS_DH_anon_WITH_AES_128_CBC_SHA", 0x0034, --p, K_DH_ANON, B_AES_128, N);
|
|
543 |
add("TLS_DH_anon_WITH_AES_256_CBC_SHA", 0x003a, --p, K_DH_ANON, B_AES_256, N);
|
|
544 |
add("SSL_DH_anon_WITH_3DES_EDE_CBC_SHA", 0x001b, --p, K_DH_ANON, B_3DES, N);
|
|
545 |
add("SSL_DH_anon_WITH_DES_CBC_SHA", 0x001a, --p, K_DH_ANON, B_DES, N);
|
|
546 |
|
|
547 |
add("TLS_ECDH_anon_WITH_RC4_128_SHA", 0xC016, --p, K_ECDH_ANON, B_RC4_128, N);
|
|
548 |
add("TLS_ECDH_anon_WITH_AES_128_CBC_SHA", 0xC018, --p, K_ECDH_ANON, B_AES_128, T);
|
|
549 |
add("TLS_ECDH_anon_WITH_AES_256_CBC_SHA", 0xC019, --p, K_ECDH_ANON, B_AES_256, T);
|
|
550 |
add("TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA", 0xC017, --p, K_ECDH_ANON, B_3DES, T);
|
|
551 |
|
|
552 |
add("SSL_DH_anon_EXPORT_WITH_RC4_40_MD5", 0x0017, --p, K_DH_ANON, B_RC4_40, N);
|
|
553 |
add("SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", 0x0019, --p, K_DH_ANON, B_DES_40, N);
|
|
554 |
|
|
555 |
add("TLS_ECDH_anon_WITH_NULL_SHA", 0xC015, --p, K_ECDH_ANON, B_NULL, N);
|
|
556 |
|
|
557 |
// Supported Kerberos ciphersuites from RFC2712
|
|
558 |
add("TLS_KRB5_WITH_RC4_128_SHA", 0x0020, --p, K_KRB5, B_RC4_128, N);
|
|
559 |
add("TLS_KRB5_WITH_RC4_128_MD5", 0x0024, --p, K_KRB5, B_RC4_128, N);
|
|
560 |
add("TLS_KRB5_WITH_3DES_EDE_CBC_SHA", 0x001f, --p, K_KRB5, B_3DES, N);
|
|
561 |
add("TLS_KRB5_WITH_3DES_EDE_CBC_MD5", 0x0023, --p, K_KRB5, B_3DES, N);
|
|
562 |
add("TLS_KRB5_WITH_DES_CBC_SHA", 0x001e, --p, K_KRB5, B_DES, N);
|
|
563 |
add("TLS_KRB5_WITH_DES_CBC_MD5", 0x0022, --p, K_KRB5, B_DES, N);
|
|
564 |
add("TLS_KRB5_EXPORT_WITH_RC4_40_SHA", 0x0028, --p, K_KRB5_EXPORT, B_RC4_40, N);
|
|
565 |
add("TLS_KRB5_EXPORT_WITH_RC4_40_MD5", 0x002b, --p, K_KRB5_EXPORT, B_RC4_40, N);
|
|
566 |
add("TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA", 0x0026, --p, K_KRB5_EXPORT, B_DES_40, N);
|
|
567 |
add("TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5", 0x0029, --p, K_KRB5_EXPORT, B_DES_40, N);
|
|
568 |
|
|
569 |
|
|
570 |
// Register the names of a few additional CipherSuites.
|
|
571 |
// Makes them show up as names instead of numbers in
|
|
572 |
// the debug output.
|
|
573 |
|
|
574 |
// remaining unsupported ciphersuites defined in RFC2246.
|
|
575 |
add("SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5", 0x0006);
|
|
576 |
add("SSL_RSA_WITH_IDEA_CBC_SHA", 0x0007);
|
|
577 |
add("SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA", 0x000b);
|
|
578 |
add("SSL_DH_DSS_WITH_DES_CBC_SHA", 0x000c);
|
|
579 |
add("SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA", 0x000d);
|
|
580 |
add("SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA", 0x000e);
|
|
581 |
add("SSL_DH_RSA_WITH_DES_CBC_SHA", 0x000f);
|
|
582 |
add("SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA", 0x0010);
|
|
583 |
|
|
584 |
// SSL 3.0 Fortezza ciphersuites
|
|
585 |
add("SSL_FORTEZZA_DMS_WITH_NULL_SHA", 0x001c);
|
|
586 |
add("SSL_FORTEZZA_DMS_WITH_FORTEZZA_CBC_SHA", 0x001d);
|
|
587 |
|
|
588 |
// 1024/56 bit exportable ciphersuites from expired internet draft
|
|
589 |
add("SSL_RSA_EXPORT1024_WITH_DES_CBC_SHA", 0x0062);
|
|
590 |
add("SSL_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA", 0x0063);
|
|
591 |
add("SSL_RSA_EXPORT1024_WITH_RC4_56_SHA", 0x0064);
|
|
592 |
add("SSL_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA", 0x0065);
|
|
593 |
add("SSL_DHE_DSS_WITH_RC4_128_SHA", 0x0066);
|
|
594 |
|
|
595 |
// Netscape old and new SSL 3.0 FIPS ciphersuites
|
|
596 |
// see http://www.mozilla.org/projects/security/pki/nss/ssl/fips-ssl-ciphersuites.html
|
|
597 |
add("NETSCAPE_RSA_FIPS_WITH_3DES_EDE_CBC_SHA", 0xffe0);
|
|
598 |
add("NETSCAPE_RSA_FIPS_WITH_DES_CBC_SHA", 0xffe1);
|
|
599 |
add("SSL_RSA_FIPS_WITH_DES_CBC_SHA", 0xfefe);
|
|
600 |
add("SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA", 0xfeff);
|
|
601 |
|
|
602 |
// Unsupported Kerberos cipher suites from RFC 2712
|
|
603 |
add("TLS_KRB5_WITH_IDEA_CBC_SHA", 0x0021);
|
|
604 |
add("TLS_KRB5_WITH_IDEA_CBC_MD5", 0x0025);
|
|
605 |
add("TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA", 0x0027);
|
|
606 |
add("TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5", 0x002a);
|
|
607 |
|
|
608 |
}
|
|
609 |
|
|
610 |
// ciphersuite SSL_NULL_WITH_NULL_NULL
|
|
611 |
final static CipherSuite C_NULL = CipherSuite.valueOf(0, 0);
|
|
612 |
|
|
613 |
}
|