Showing the changes to java/pkg/sun/security/ssl/CipherSuite.java (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,1274 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. | |
| 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. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * 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 | +import java.security.SecureRandom; | |
| 34 | + | |
| 35 | +import javax.crypto.SecretKey; | |
| 36 | +import javax.crypto.spec.IvParameterSpec; | |
| 37 | +import javax.crypto.spec.SecretKeySpec; | |
| 38 | + | |
| 39 | +import sun.security.ssl.CipherSuite.*; | |
| 40 | +import static sun.security.ssl.CipherSuite.KeyExchange.*; | |
| 41 | +import static sun.security.ssl.CipherSuite.PRF.*; | |
| 42 | +import static sun.security.ssl.JsseJce.*; | |
| 43 | + | |
| 44 | +/** | |
| 45 | + * An SSL/TLS CipherSuite. Constants for the standard key exchange, cipher, | |
| 46 | + * and mac algorithms are also defined in this class. | |
| 47 | + * | |
| 48 | + * The CipherSuite class and the inner classes defined in this file roughly | |
| 49 | + * follow the type safe enum pattern described in Effective Java. This means: | |
| 50 | + * | |
| 51 | + * . instances are immutable, classes are final | |
| 52 | + * | |
| 53 | + * . there is a unique instance of every value, i.e. there are never two | |
| 54 | + * instances representing the same CipherSuite, etc. This means equality | |
| 55 | + * tests can be performed using == instead of equals() (although that works | |
| 56 | + * as well). [A minor exception are *unsupported* CipherSuites read from a | |
| 57 | + * handshake message, but this is usually irrelevant] | |
| 58 | + * | |
| 59 | + * . instances are obtained using the static valueOf() factory methods. | |
| 60 | + * | |
| 61 | + * . properties are defined as final variables and made available as | |
| 62 | + * package private variables without method accessors | |
| 63 | + * | |
| 64 | + * . if the member variable allowed is false, the given algorithm is either | |
| 65 | + * unavailable or disabled at compile time | |
| 66 | + * | |
| 67 | + */ | |
| 68 | +final class CipherSuite implements Comparable { | |
| 69 | + | |
| 70 | + // minimum priority for supported CipherSuites | |
| 71 | + final static int SUPPORTED_SUITES_PRIORITY = 1; | |
| 72 | + | |
| 73 | + // minimum priority for default enabled CipherSuites | |
| 74 | + final static int DEFAULT_SUITES_PRIORITY = 300; | |
| 75 | + | |
| 76 | + // Flag indicating if CipherSuite availability can change dynamically. | |
| 77 | + // This is the case when we rely on a JCE cipher implementation that | |
| 78 | + // may not be available in the installed JCE providers. | |
| 79 | + // It is true because we might not have an ECC implementation. | |
| 80 | + final static boolean DYNAMIC_AVAILABILITY = true; | |
| 81 | + | |
| 82 | + private final static boolean ALLOW_ECC = Debug.getBooleanProperty | |
| 83 | + ("com.sun.net.ssl.enableECC", true); | |
| 84 | + | |
| 85 | + // Map Integer(id) -> CipherSuite | |
| 86 | + // contains all known CipherSuites | |
| 87 | + private final static Map<Integer,CipherSuite> idMap; | |
| 88 | + | |
| 89 | + // Map String(name) -> CipherSuite | |
| 90 | + // contains only supported CipherSuites (i.e. allowed == true) | |
| 91 | + private final static Map<String,CipherSuite> nameMap; | |
| 92 | + | |
| 93 | + // Protocol defined CipherSuite name, e.g. SSL_RSA_WITH_RC4_128_MD5 | |
| 94 | + // we use TLS_* only for new CipherSuites, still SSL_* for old ones | |
| 95 | + final String name; | |
| 96 | + | |
| 97 | + // id in 16 bit MSB format, i.e. 0x0004 for SSL_RSA_WITH_RC4_128_MD5 | |
| 98 | + final int id; | |
| 99 | + | |
| 100 | + // priority for the internal default preference order. the higher the | |
| 101 | + // better. Each supported CipherSuite *must* have a unique priority. | |
| 102 | + // Ciphersuites with priority >= DEFAULT_SUITES_PRIORITY are enabled | |
| 103 | + // by default | |
| 104 | + final int priority; | |
| 105 | + | |
| 106 | + // key exchange, bulk cipher, mac and prf algorithms. See those | |
| 107 | + // classes below. | |
| 108 | + final KeyExchange keyExchange; | |
| 109 | + final BulkCipher cipher; | |
| 110 | + final MacAlg macAlg; | |
| 111 | + final PRF prfAlg; | |
| 112 | + | |
| 113 | + // whether a CipherSuite qualifies as exportable under 512/40 bit rules. | |
| 114 | + // TLS 1.1+ (RFC 4346) must not negotiate to these suites. | |
| 115 | + final boolean exportable; | |
| 116 | + | |
| 117 | + // true iff implemented and enabled at compile time | |
| 118 | + final boolean allowed; | |
| 119 | + | |
| 120 | + // obsoleted since protocol version | |
| 121 | + final int obsoleted; | |
| 122 | + | |
| 123 | + // supported since protocol version | |
| 124 | + final int supported; | |
| 125 | + | |
| 126 | + /** | |
| 127 | + * Constructor for implemented CipherSuites. | |
| 128 | + */ | |
| 129 | + private CipherSuite(String name, int id, int priority, | |
| 130 | + KeyExchange keyExchange, BulkCipher cipher, | |
| 131 | + boolean allowed, int obsoleted, int supported, PRF prfAlg) { | |
| 132 | + this.name = name; | |
| 133 | + this.id = id; | |
| 134 | + this.priority = priority; | |
| 135 | + this.keyExchange = keyExchange; | |
| 136 | + this.cipher = cipher; | |
| 137 | + this.exportable = cipher.exportable; | |
| 138 | + if (name.endsWith("_MD5")) { | |
| 139 | + macAlg = M_MD5; | |
| 140 | + } else if (name.endsWith("_SHA")) { | |
| 141 | + macAlg = M_SHA; | |
| 142 | + } else if (name.endsWith("_SHA256")) { | |
| 143 | + macAlg = M_SHA256; | |
| 144 | + } else if (name.endsWith("_SHA384")) { | |
| 145 | + macAlg = M_SHA384; | |
| 146 | + } else if (name.endsWith("_NULL")) { | |
| 147 | + macAlg = M_NULL; | |
| 148 | + } else if (name.endsWith("_SCSV")) { | |
| 149 | + macAlg = M_NULL; | |
| 150 | + } else { | |
| 151 | + throw new IllegalArgumentException | |
| 152 | + ("Unknown MAC algorithm for ciphersuite " + name); | |
| 153 | + } | |
| 154 | + | |
| 155 | + allowed &= keyExchange.allowed; | |
| 156 | + allowed &= cipher.allowed; | |
| 157 | + this.allowed = allowed; | |
| 158 | + this.obsoleted = obsoleted; | |
| 159 | + this.supported = supported; | |
| 160 | + this.prfAlg = prfAlg; | |
| 161 | + } | |
| 162 | + | |
| 163 | + /** | |
| 164 | + * Constructor for unimplemented CipherSuites. | |
| 165 | + */ | |
| 166 | + private CipherSuite(String name, int id) { | |
| 167 | + this.name = name; | |
| 168 | + this.id = id; | |
| 169 | + this.allowed = false; | |
| 170 | + | |
| 171 | + this.priority = 0; | |
| 172 | + this.keyExchange = null; | |
| 173 | + this.cipher = null; | |
| 174 | + this.macAlg = null; | |
| 175 | + this.exportable = false; | |
| 176 | + this.obsoleted = ProtocolVersion.LIMIT_MAX_VALUE; | |
| 177 | + this.supported = ProtocolVersion.LIMIT_MIN_VALUE; | |
| 178 | + this.prfAlg = P_NONE; | |
| 179 | + } | |
| 180 | + | |
| 181 | + /** | |
| 182 | + * Return whether this CipherSuite is available for use. A | |
| 183 | + * CipherSuite may be unavailable even if it is supported | |
| 184 | + * (i.e. allowed == true) if the required JCE cipher is not installed. | |
| 185 | + * In some configuration, this situation may change over time, call | |
| 186 | + * CipherSuiteList.clearAvailableCache() before this method to obtain | |
| 187 | + * the most current status. | |
| 188 | + */ | |
| 189 | + boolean isAvailable() { | |
| 190 | + return allowed && keyExchange.isAvailable() && cipher.isAvailable(); | |
| 191 | + } | |
| 192 | + | |
| 193 | + boolean isNegotiable() { | |
| 194 | + return this != C_SCSV && isAvailable(); | |
| 195 | + } | |
| 196 | + | |
| 197 | + /** | |
| 198 | + * Compares CipherSuites based on their priority. Has the effect of | |
| 199 | + * sorting CipherSuites when put in a sorted collection, which is | |
| 200 | + * used by CipherSuiteList. Follows standard Comparable contract. | |
| 201 | + * | |
| 202 | + * Note that for unsupported CipherSuites parsed from a handshake | |
| 203 | + * message we violate the equals() contract. | |
| 204 | + */ | |
| 205 | + public int compareTo(Object o) { | |
| 206 | + return ((CipherSuite)o).priority - priority; | |
| 207 | + } | |
| 208 | + | |
| 209 | + /** | |
| 210 | + * Returns this.name. | |
| 211 | + */ | |
| 212 | + public String toString() { | |
| 213 | + return name; | |
| 214 | + } | |
| 215 | + | |
| 216 | + /** | |
| 217 | + * Return a CipherSuite for the given name. The returned CipherSuite | |
| 218 | + * is supported by this implementation but may not actually be | |
| 219 | + * currently useable. See isAvailable(). | |
| 220 | + * | |
| 221 | + * @exception IllegalArgumentException if the CipherSuite is unknown or | |
| 222 | + * unsupported. | |
| 223 | + */ | |
| 224 | + static CipherSuite valueOf(String s) { | |
| 225 | + if (s == null) { | |
| 226 | + throw new IllegalArgumentException("Name must not be null"); | |
| 227 | + } | |
| 228 | + | |
| 229 | + CipherSuite c = nameMap.get(s); | |
| 230 | + if ((c == null) || (c.allowed == false)) { | |
| 231 | + throw new IllegalArgumentException("Unsupported ciphersuite " + s); | |
| 232 | + } | |
| 233 | + | |
| 234 | + return c; | |
| 235 | + } | |
| 236 | + | |
| 237 | + /** | |
| 238 | + * Return a CipherSuite with the given ID. A temporary object is | |
| 239 | + * constructed if the ID is unknown. Use isAvailable() to verify that | |
| 240 | + * the CipherSuite can actually be used. | |
| 241 | + */ | |
| 242 | + static CipherSuite valueOf(int id1, int id2) { | |
| 243 | + id1 &= 0xff; | |
| 244 | + id2 &= 0xff; | |
| 245 | + int id = (id1 << 8) | id2; | |
| 246 | + CipherSuite c = idMap.get(id); | |
| 247 | + if (c == null) { | |
| 248 | + String h1 = Integer.toString(id1, 16); | |
| 249 | + String h2 = Integer.toString(id2, 16); | |
| 250 | + c = new CipherSuite("Unknown 0x" + h1 + ":0x" + h2, id); | |
| 251 | + } | |
| 252 | + return c; | |
| 253 | + } | |
| 254 | + | |
| 255 | + // for use by CipherSuiteList only | |
| 256 | + static Collection<CipherSuite> allowedCipherSuites() { | |
| 257 | + return nameMap.values(); | |
| 258 | + } | |
| 259 | + | |
| 260 | + /* | |
| 261 | + * Use this method when all of the values need to be specified. | |
| 262 | + * This is primarily used when defining a new ciphersuite for | |
| 263 | + * TLS 1.2+ that doesn't use the "default" PRF. | |
| 264 | + */ | |
| 265 | + private static void add(String name, int id, int priority, | |
| 266 | + KeyExchange keyExchange, BulkCipher cipher, | |
| 267 | + boolean allowed, int obsoleted, int supported, PRF prf) { | |
| 268 | + | |
| 269 | + CipherSuite c = new CipherSuite(name, id, priority, keyExchange, | |
| 270 | + cipher, allowed, obsoleted, supported, prf); | |
| 271 | + if (idMap.put(id, c) != null) { | |
| 272 | + throw new RuntimeException("Duplicate ciphersuite definition: " | |
| 273 | + + id + ", " + name); | |
| 274 | + } | |
| 275 | + if (c.allowed) { | |
| 276 | + if (nameMap.put(name, c) != null) { | |
| 277 | + throw new RuntimeException("Duplicate ciphersuite definition: " | |
| 278 | + + id + ", " + name); | |
| 279 | + } | |
| 280 | + } | |
| 281 | + } | |
| 282 | + | |
| 283 | + /* | |
| 284 | + * Use this method when there is no lower protocol limit where this | |
| 285 | + * suite can be used, and the PRF is P_SHA256. That is, the | |
| 286 | + * existing ciphersuites. From RFC 5246: | |
| 287 | + * | |
| 288 | + * All cipher suites in this document use P_SHA256. | |
| 289 | + */ | |
| 290 | + private static void add(String name, int id, int priority, | |
| 291 | + KeyExchange keyExchange, BulkCipher cipher, | |
| 292 | + boolean allowed, int obsoleted) { | |
| 293 | + // If this is an obsoleted suite, then don't let the TLS 1.2 | |
| 294 | + // protocol have a valid PRF value. | |
| 295 | + PRF prf = P_SHA256; | |
| 296 | + if (obsoleted < ProtocolVersion.TLS12.v) { | |
| 297 | + prf = P_NONE; | |
| 298 | + } | |
| 299 | + | |
| 300 | + add(name, id, priority, keyExchange, cipher, allowed, obsoleted, | |
| 301 | + ProtocolVersion.LIMIT_MIN_VALUE, prf); | |
| 302 | + } | |
| 303 | + | |
| 304 | + /* | |
| 305 | + * Use this method when there is no upper protocol limit. That is, | |
| 306 | + * suites which have not been obsoleted. | |
| 307 | + */ | |
| 308 | + private static void add(String name, int id, int priority, | |
| 309 | + KeyExchange keyExchange, BulkCipher cipher, boolean allowed) { | |
| 310 | + add(name, id, priority, keyExchange, | |
| 311 | + cipher, allowed, ProtocolVersion.LIMIT_MAX_VALUE); | |
| 312 | + } | |
| 313 | + | |
| 314 | + /* | |
| 315 | + * Use this method to define an unimplemented suite. This provides | |
| 316 | + * a number<->name mapping that can be used for debugging. | |
| 317 | + */ | |
| 318 | + private static void add(String name, int id) { | |
| 319 | + CipherSuite c = new CipherSuite(name, id); | |
| 320 | + if (idMap.put(id, c) != null) { | |
| 321 | + throw new RuntimeException("Duplicate ciphersuite definition: " | |
| 322 | + + id + ", " + name); | |
| 323 | + } | |
| 324 | + } | |
| 325 | + | |
| 326 | + /** | |
| 327 | + * An SSL/TLS key exchange algorithm. | |
| 328 | + */ | |
| 329 | + static enum KeyExchange { | |
| 330 | + | |
| 331 | + // key exchange algorithms | |
| 332 | + K_NULL ("NULL", false), | |
| 333 | + K_RSA ("RSA", true), | |
| 334 | + K_RSA_EXPORT ("RSA_EXPORT", true), | |
| 335 | + K_DH_RSA ("DH_RSA", false), | |
| 336 | + K_DH_DSS ("DH_DSS", false), | |
| 337 | + K_DHE_DSS ("DHE_DSS", true), | |
| 338 | + K_DHE_RSA ("DHE_RSA", true), | |
| 339 | + K_DH_ANON ("DH_anon", true), | |
| 340 | + | |
| 341 | + K_ECDH_ECDSA ("ECDH_ECDSA", ALLOW_ECC), | |
| 342 | + K_ECDH_RSA ("ECDH_RSA", ALLOW_ECC), | |
| 343 | + K_ECDHE_ECDSA("ECDHE_ECDSA", ALLOW_ECC), | |
| 344 | + K_ECDHE_RSA ("ECDHE_RSA", ALLOW_ECC), | |
| 345 | + K_ECDH_ANON ("ECDH_anon", ALLOW_ECC), | |
| 346 | + | |
| 347 | + // Kerberos cipher suites | |
| 348 | + K_KRB5 ("KRB5", true), | |
| 349 | + K_KRB5_EXPORT("KRB5_EXPORT", true), | |
| 350 | + | |
| 351 | + // renegotiation protection request signaling cipher suite | |
| 352 | + K_SCSV ("SCSV", true); | |
| 353 | + | |
| 354 | + // name of the key exchange algorithm, e.g. DHE_DSS | |
| 355 | + final String name; | |
| 356 | + final boolean allowed; | |
| 357 | + private final boolean alwaysAvailable; | |
| 358 | + | |
| 359 | + KeyExchange(String name, boolean allowed) { | |
| 360 | + this.name = name; | |
| 361 | + this.allowed = allowed; | |
| 362 | + this.alwaysAvailable = allowed && | |
| 363 | + (!name.startsWith("EC")) && (!name.startsWith("KRB")); | |
| 364 | + } | |
| 365 | + | |
| 366 | + boolean isAvailable() { | |
| 367 | + if (alwaysAvailable) { | |
| 368 | + return true; | |
| 369 | + } | |
| 370 | + | |
| 371 | + if (name.startsWith("EC")) { | |
| 372 | + return (allowed && JsseJce.isEcAvailable()); | |
| 373 | + } else if (name.startsWith("KRB")) { | |
| 374 | + return (allowed && JsseJce.isKerberosAvailable()); | |
| 375 | + } else { | |
| 376 | + return allowed; | |
| 377 | + } | |
| 378 | + } | |
| 379 | + | |
| 380 | + public String toString() { | |
| 381 | + return name; | |
| 382 | + } | |
| 383 | + } | |
| 384 | + | |
| 385 | + /** | |
| 386 | + * An SSL/TLS bulk cipher algorithm. One instance per combination of | |
| 387 | + * cipher and key length. | |
| 388 | + * | |
| 389 | + * Also contains a factory method to obtain in initialized CipherBox | |
| 390 | + * for this algorithm. | |
| 391 | + */ | |
| 392 | + final static class BulkCipher { | |
| 393 | + | |
| 394 | + // Map BulkCipher -> Boolean(available) | |
| 395 | + private final static Map<BulkCipher,Boolean> availableCache = | |
| 396 | + new HashMap<>(8); | |
| 397 | + | |
| 398 | + // descriptive name including key size, e.g. AES/128 | |
| 399 | + final String description; | |
| 400 | + | |
| 401 | + // JCE cipher transformation string, e.g. AES/CBC/NoPadding | |
| 402 | + final String transformation; | |
| 403 | + | |
| 404 | + // algorithm name, e.g. AES | |
| 405 | + final String algorithm; | |
| 406 | + | |
| 407 | + // supported and compile time enabled. Also see isAvailable() | |
| 408 | + final boolean allowed; | |
| 409 | + | |
| 410 | + // number of bytes of entropy in the key | |
| 411 | + final int keySize; | |
| 412 | + | |
| 413 | + // length of the actual cipher key in bytes. | |
| 414 | + // for non-exportable ciphers, this is the same as keySize | |
| 415 | + final int expandedKeySize; | |
| 416 | + | |
| 417 | + // size of the IV (also block size) | |
| 418 | + final int ivSize; | |
| 419 | + | |
| 420 | + // exportable under 512/40 bit rules | |
| 421 | + final boolean exportable; | |
| 422 | + | |
| 423 | + BulkCipher(String transformation, int keySize, | |
| 424 | + int expandedKeySize, int ivSize, boolean allowed) { | |
| 425 | + this.transformation = transformation; | |
| 426 | + this.algorithm = transformation.split("/")[0]; | |
| 427 | + this.description = this.algorithm + "/" + (keySize << 3); | |
| 428 | + this.keySize = keySize; | |
| 429 | + this.ivSize = ivSize; | |
| 430 | + this.allowed = allowed; | |
| 431 | + | |
| 432 | + this.expandedKeySize = expandedKeySize; | |
| 433 | + this.exportable = true; | |
| 434 | + } | |
| 435 | + | |
| 436 | + BulkCipher(String transformation, int keySize, | |
| 437 | + int ivSize, boolean allowed) { | |
| 438 | + this.transformation = transformation; | |
| 439 | + this.algorithm = transformation.split("/")[0]; | |
| 440 | + this.description = this.algorithm + "/" + (keySize << 3); | |
| 441 | + this.keySize = keySize; | |
| 442 | + this.ivSize = ivSize; | |
| 443 | + this.allowed = allowed; | |
| 444 | + | |
| 445 | + this.expandedKeySize = keySize; | |
| 446 | + this.exportable = false; | |
| 447 | + } | |
| 448 | + | |
| 449 | + /** | |
| 450 | + * Return an initialized CipherBox for this BulkCipher. | |
| 451 | + * IV must be null for stream ciphers. | |
| 452 | + * | |
| 453 | + * @exception NoSuchAlgorithmException if anything goes wrong | |
| 454 | + */ | |
| 455 | + CipherBox newCipher(ProtocolVersion version, SecretKey key, | |
| 456 | + IvParameterSpec iv, SecureRandom random, | |
| 457 | + boolean encrypt) throws NoSuchAlgorithmException { | |
| 458 | + return CipherBox.newCipherBox(version, this, | |
| 459 | + key, iv, random, encrypt); | |
| 460 | + } | |
| 461 | + | |
| 462 | + /** | |
| 463 | + * Test if this bulk cipher is available. For use by CipherSuite. | |
| 464 | + * | |
| 465 | + * Currently all supported ciphers except AES are always available | |
| 466 | + * via the JSSE internal implementations. We also assume AES/128 | |
| 467 | + * is always available since it is shipped with the SunJCE provider. | |
| 468 | + * However, AES/256 is unavailable when the default JCE policy | |
| 469 | + * jurisdiction files are installed because of key length restrictions. | |
| 470 | + */ | |
| 471 | + boolean isAvailable() { | |
| 472 | + if (allowed == false) { | |
| 473 | + return false; | |
| 474 | + } | |
| 475 | + if (this == B_AES_256) { | |
| 476 | + return isAvailable(this); | |
| 477 | + } | |
| 478 | + | |
| 479 | + // always available | |
| 480 | + return true; | |
| 481 | + } | |
| 482 | + | |
| 483 | + // for use by CipherSuiteList.clearAvailableCache(); | |
| 484 | + static synchronized void clearAvailableCache() { | |
| 485 | + if (DYNAMIC_AVAILABILITY) { | |
| 486 | + availableCache.clear(); | |
| 487 | + } | |
| 488 | + } | |
| 489 | + | |
| 490 | + private static synchronized boolean isAvailable(BulkCipher cipher) { | |
| 491 | + Boolean b = availableCache.get(cipher); | |
| 492 | + if (b == null) { | |
| 493 | + try { | |
| 494 | + SecretKey key = new SecretKeySpec | |
| 495 | + (new byte[cipher.expandedKeySize], cipher.algorithm); | |
| 496 | + IvParameterSpec iv = | |
| 497 | + new IvParameterSpec(new byte[cipher.ivSize]); | |
| 498 | + cipher.newCipher(ProtocolVersion.DEFAULT, | |
| 499 | + key, iv, null, true); | |
| 500 | + b = Boolean.TRUE; | |
| 501 | + } catch (NoSuchAlgorithmException e) { | |
| 502 | + b = Boolean.FALSE; | |
| 503 | + } | |
| 504 | + availableCache.put(cipher, b); | |
| 505 | + } | |
| 506 | + return b.booleanValue(); | |
| 507 | + } | |
| 508 | + | |
| 509 | + public String toString() { | |
| 510 | + return description; | |
| 511 | + } | |
| 512 | + } | |
| 513 | + | |
| 514 | + /** | |
| 515 | + * An SSL/TLS key MAC algorithm. | |
| 516 | + * | |
| 517 | + * Also contains a factory method to obtain an initialized MAC | |
| 518 | + * for this algorithm. | |
| 519 | + */ | |
| 520 | + final static class MacAlg { | |
| 521 | + | |
| 522 | + // descriptive name, e.g. MD5 | |
| 523 | + final String name; | |
| 524 | + | |
| 525 | + // size of the MAC value (and MAC key) in bytes | |
| 526 | + final int size; | |
| 527 | + | |
| 528 | + MacAlg(String name, int size) { | |
| 529 | + this.name = name; | |
| 530 | + this.size = size; | |
| 531 | + } | |
| 532 | + | |
| 533 | + /** | |
| 534 | + * Return an initialized MAC for this MacAlg. ProtocolVersion | |
| 535 | + * must either be SSL30 (SSLv3 custom MAC) or TLS10 (std. HMAC). | |
| 536 | + * | |
| 537 | + * @exception NoSuchAlgorithmException if anything goes wrong | |
| 538 | + */ | |
| 539 | + MAC newMac(ProtocolVersion protocolVersion, SecretKey secret) | |
| 540 | + throws NoSuchAlgorithmException, InvalidKeyException { | |
| 541 | + return new MAC(this, protocolVersion, secret); | |
| 542 | + } | |
| 543 | + | |
| 544 | + public String toString() { | |
| 545 | + return name; | |
| 546 | + } | |
| 547 | + } | |
| 548 | + | |
| 549 | + // export strength ciphers | |
| 550 | + final static BulkCipher B_NULL = | |
| 551 | + new BulkCipher("NULL", 0, 0, 0, true); | |
| 552 | + final static BulkCipher B_RC4_40 = | |
| 553 | + new BulkCipher(CIPHER_RC4, 5, 16, 0, true); | |
| 554 | + final static BulkCipher B_RC2_40 = | |
| 555 | + new BulkCipher("RC2", 5, 16, 8, false); | |
| 556 | + final static BulkCipher B_DES_40 = | |
| 557 | + new BulkCipher(CIPHER_DES, 5, 8, 8, true); | |
| 558 | + | |
| 559 | + // domestic strength ciphers | |
| 560 | + final static BulkCipher B_RC4_128 = | |
| 561 | + new BulkCipher(CIPHER_RC4, 16, 0, true); | |
| 562 | + final static BulkCipher B_DES = | |
| 563 | + new BulkCipher(CIPHER_DES, 8, 8, true); | |
| 564 | + final static BulkCipher B_3DES = | |
| 565 | + new BulkCipher(CIPHER_3DES, 24, 8, true); | |
| 566 | + final static BulkCipher B_IDEA = | |
| 567 | + new BulkCipher("IDEA", 16, 8, false); | |
| 568 | + final static BulkCipher B_AES_128 = | |
| 569 | + new BulkCipher(CIPHER_AES, 16, 16, true); | |
| 570 | + final static BulkCipher B_AES_256 = | |
| 571 | + new BulkCipher(CIPHER_AES, 32, 16, true); | |
| 572 | + | |
| 573 | + // MACs | |
| 574 | + final static MacAlg M_NULL = new MacAlg("NULL", 0); | |
| 575 | + final static MacAlg M_MD5 = new MacAlg("MD5", 16); | |
| 576 | + final static MacAlg M_SHA = new MacAlg("SHA", 20); | |
| 577 | + final static MacAlg M_SHA256 = new MacAlg("SHA256", 32); | |
| 578 | + final static MacAlg M_SHA384 = new MacAlg("SHA384", 48); | |
| 579 | + | |
| 580 | + /** | |
| 581 | + * PRFs (PseudoRandom Function) from TLS specifications. | |
| 582 | + * | |
| 583 | + * TLS 1.1- uses a single MD5/SHA1-based PRF algorithm for generating | |
| 584 | + * the necessary material. | |
| 585 | + * | |
| 586 | + * In TLS 1.2+, all existing/known CipherSuites use SHA256, however | |
| 587 | + * new Ciphersuites (e.g. RFC 5288) can define specific PRF hash | |
| 588 | + * algorithms. | |
| 589 | + */ | |
| 590 | + static enum PRF { | |
| 591 | + | |
| 592 | + // PRF algorithms | |
| 593 | + P_NONE( "NONE", 0, 0), | |
| 594 | + P_SHA256("SHA-256", 32, 64), | |
| 595 | + P_SHA384("SHA-384", 48, 128), | |
| 596 | + P_SHA512("SHA-512", 64, 128); // not currently used. | |
| 597 | + | |
| 598 | + // PRF characteristics | |
| 599 | + private final String prfHashAlg; | |
| 600 | + private final int prfHashLength; | |
| 601 | + private final int prfBlockSize; | |
| 602 | + | |
| 603 | + PRF(String prfHashAlg, int prfHashLength, int prfBlockSize) { | |
| 604 | + this.prfHashAlg = prfHashAlg; | |
| 605 | + this.prfHashLength = prfHashLength; | |
| 606 | + this.prfBlockSize = prfBlockSize; | |
| 607 | + } | |
| 608 | + | |
| 609 | + String getPRFHashAlg() { | |
| 610 | + return prfHashAlg; | |
| 611 | + } | |
| 612 | + | |
| 613 | + int getPRFHashLength() { | |
| 614 | + return prfHashLength; | |
| 615 | + } | |
| 616 | + | |
| 617 | + int getPRFBlockSize() { | |
| 618 | + return prfBlockSize; | |
| 619 | + } | |
| 620 | + } | |
| 621 | + | |
| 622 | + static { | |
| 623 | + idMap = new HashMap<Integer,CipherSuite>(); | |
| 624 | + nameMap = new HashMap<String,CipherSuite>(); | |
| 625 | + | |
| 626 | + final boolean F = false; | |
| 627 | + final boolean T = true; | |
| 628 | + // N: ciphersuites only allowed if we are not in FIPS mode | |
| 629 | + final boolean N = (SunJSSE.isFIPS() == false); | |
| 630 | + | |
| 631 | + /* | |
| 632 | + * TLS Cipher Suite Registry, as of August 2010. | |
| 633 | + * | |
| 634 | + * http://www.iana.org/assignments/tls-parameters/tls-parameters.xml | |
| 635 | + * | |
| 636 | + * Range Registration Procedures Notes | |
| 637 | + * 000-191 Standards Action Refers to value of first byte | |
| 638 | + * 192-254 Specification Required Refers to value of first byte | |
| 639 | + * 255 Reserved for Private Use Refers to value of first byte | |
| 640 | + * | |
| 641 | + * Value Description Reference | |
| 642 | + * 0x00,0x00 TLS_NULL_WITH_NULL_NULL [RFC5246] | |
| 643 | + * 0x00,0x01 TLS_RSA_WITH_NULL_MD5 [RFC5246] | |
| 644 | + * 0x00,0x02 TLS_RSA_WITH_NULL_SHA [RFC5246] | |
| 645 | + * 0x00,0x03 TLS_RSA_EXPORT_WITH_RC4_40_MD5 [RFC4346] | |
| 646 | + * 0x00,0x04 TLS_RSA_WITH_RC4_128_MD5 [RFC5246] | |
| 647 | + * 0x00,0x05 TLS_RSA_WITH_RC4_128_SHA [RFC5246] | |
| 648 | + * 0x00,0x06 TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 [RFC4346] | |
| 649 | + * 0x00,0x07 TLS_RSA_WITH_IDEA_CBC_SHA [RFC5469] | |
| 650 | + * 0x00,0x08 TLS_RSA_EXPORT_WITH_DES40_CBC_SHA [RFC4346] | |
| 651 | + * 0x00,0x09 TLS_RSA_WITH_DES_CBC_SHA [RFC5469] | |
| 652 | + * 0x00,0x0A TLS_RSA_WITH_3DES_EDE_CBC_SHA [RFC5246] | |
| 653 | + * 0x00,0x0B TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA [RFC4346] | |
| 654 | + * 0x00,0x0C TLS_DH_DSS_WITH_DES_CBC_SHA [RFC5469] | |
| 655 | + * 0x00,0x0D TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA [RFC5246] | |
| 656 | + * 0x00,0x0E TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA [RFC4346] | |
| 657 | + * 0x00,0x0F TLS_DH_RSA_WITH_DES_CBC_SHA [RFC5469] | |
| 658 | + * 0x00,0x10 TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA [RFC5246] | |
| 659 | + * 0x00,0x11 TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA [RFC4346] | |
| 660 | + * 0x00,0x12 TLS_DHE_DSS_WITH_DES_CBC_SHA [RFC5469] | |
| 661 | + * 0x00,0x13 TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA [RFC5246] | |
| 662 | + * 0x00,0x14 TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA [RFC4346] | |
| 663 | + * 0x00,0x15 TLS_DHE_RSA_WITH_DES_CBC_SHA [RFC5469] | |
| 664 | + * 0x00,0x16 TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA [RFC5246] | |
| 665 | + * 0x00,0x17 TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 [RFC4346] | |
| 666 | + * 0x00,0x18 TLS_DH_anon_WITH_RC4_128_MD5 [RFC5246] | |
| 667 | + * 0x00,0x19 TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA [RFC4346] | |
| 668 | + * 0x00,0x1A TLS_DH_anon_WITH_DES_CBC_SHA [RFC5469] | |
| 669 | + * 0x00,0x1B TLS_DH_anon_WITH_3DES_EDE_CBC_SHA [RFC5246] | |
| 670 | + * 0x00,0x1C-1D Reserved to avoid conflicts with SSLv3 [RFC5246] | |
| 671 | + * 0x00,0x1E TLS_KRB5_WITH_DES_CBC_SHA [RFC2712] | |
| 672 | + * 0x00,0x1F TLS_KRB5_WITH_3DES_EDE_CBC_SHA [RFC2712] | |
| 673 | + * 0x00,0x20 TLS_KRB5_WITH_RC4_128_SHA [RFC2712] | |
| 674 | + * 0x00,0x21 TLS_KRB5_WITH_IDEA_CBC_SHA [RFC2712] | |
| 675 | + * 0x00,0x22 TLS_KRB5_WITH_DES_CBC_MD5 [RFC2712] | |
| 676 | + * 0x00,0x23 TLS_KRB5_WITH_3DES_EDE_CBC_MD5 [RFC2712] | |
| 677 | + * 0x00,0x24 TLS_KRB5_WITH_RC4_128_MD5 [RFC2712] | |
| 678 | + * 0x00,0x25 TLS_KRB5_WITH_IDEA_CBC_MD5 [RFC2712] | |
| 679 | + * 0x00,0x26 TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA [RFC2712] | |
| 680 | + * 0x00,0x27 TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA [RFC2712] | |
| 681 | + * 0x00,0x28 TLS_KRB5_EXPORT_WITH_RC4_40_SHA [RFC2712] | |
| 682 | + * 0x00,0x29 TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5 [RFC2712] | |
| 683 | + * 0x00,0x2A TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5 [RFC2712] | |
| 684 | + * 0x00,0x2B TLS_KRB5_EXPORT_WITH_RC4_40_MD5 [RFC2712] | |
| 685 | + * 0x00,0x2C TLS_PSK_WITH_NULL_SHA [RFC4785] | |
| 686 | + * 0x00,0x2D TLS_DHE_PSK_WITH_NULL_SHA [RFC4785] | |
| 687 | + * 0x00,0x2E TLS_RSA_PSK_WITH_NULL_SHA [RFC4785] | |
| 688 | + * 0x00,0x2F TLS_RSA_WITH_AES_128_CBC_SHA [RFC5246] | |
| 689 | + * 0x00,0x30 TLS_DH_DSS_WITH_AES_128_CBC_SHA [RFC5246] | |
| 690 | + * 0x00,0x31 TLS_DH_RSA_WITH_AES_128_CBC_SHA [RFC5246] | |
| 691 | + * 0x00,0x32 TLS_DHE_DSS_WITH_AES_128_CBC_SHA [RFC5246] | |
| 692 | + * 0x00,0x33 TLS_DHE_RSA_WITH_AES_128_CBC_SHA [RFC5246] | |
| 693 | + * 0x00,0x34 TLS_DH_anon_WITH_AES_128_CBC_SHA [RFC5246] | |
| 694 | + * 0x00,0x35 TLS_RSA_WITH_AES_256_CBC_SHA [RFC5246] | |
| 695 | + * 0x00,0x36 TLS_DH_DSS_WITH_AES_256_CBC_SHA [RFC5246] | |
| 696 | + * 0x00,0x37 TLS_DH_RSA_WITH_AES_256_CBC_SHA [RFC5246] | |
| 697 | + * 0x00,0x38 TLS_DHE_DSS_WITH_AES_256_CBC_SHA [RFC5246] | |
| 698 | + * 0x00,0x39 TLS_DHE_RSA_WITH_AES_256_CBC_SHA [RFC5246] | |
| 699 | + * 0x00,0x3A TLS_DH_anon_WITH_AES_256_CBC_SHA [RFC5246] | |
| 700 | + * 0x00,0x3B TLS_RSA_WITH_NULL_SHA256 [RFC5246] | |
| 701 | + * 0x00,0x3C TLS_RSA_WITH_AES_128_CBC_SHA256 [RFC5246] | |
| 702 | + * 0x00,0x3D TLS_RSA_WITH_AES_256_CBC_SHA256 [RFC5246] | |
| 703 | + * 0x00,0x3E TLS_DH_DSS_WITH_AES_128_CBC_SHA256 [RFC5246] | |
| 704 | + * 0x00,0x3F TLS_DH_RSA_WITH_AES_128_CBC_SHA256 [RFC5246] | |
| 705 | + * 0x00,0x40 TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 [RFC5246] | |
| 706 | + * 0x00,0x41 TLS_RSA_WITH_CAMELLIA_128_CBC_SHA [RFC5932] | |
| 707 | + * 0x00,0x42 TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA [RFC5932] | |
| 708 | + * 0x00,0x43 TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA [RFC5932] | |
| 709 | + * 0x00,0x44 TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA [RFC5932] | |
| 710 | + * 0x00,0x45 TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA [RFC5932] | |
| 711 | + * 0x00,0x46 TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA [RFC5932] | |
| 712 | + * 0x00,0x47-4F Reserved to avoid conflicts with | |
| 713 | + * deployed implementations [Pasi_Eronen] | |
| 714 | + * 0x00,0x50-58 Reserved to avoid conflicts [Pasi Eronen] | |
| 715 | + * 0x00,0x59-5C Reserved to avoid conflicts with | |
| 716 | + * deployed implementations [Pasi_Eronen] | |
| 717 | + * 0x00,0x5D-5F Unassigned | |
| 718 | + * 0x00,0x60-66 Reserved to avoid conflicts with widely | |
| 719 | + * deployed implementations [Pasi_Eronen] | |
| 720 | + * 0x00,0x67 TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 [RFC5246] | |
| 721 | + * 0x00,0x68 TLS_DH_DSS_WITH_AES_256_CBC_SHA256 [RFC5246] | |
| 722 | + * 0x00,0x69 TLS_DH_RSA_WITH_AES_256_CBC_SHA256 [RFC5246] | |
| 723 | + * 0x00,0x6A TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 [RFC5246] | |
| 724 | + * 0x00,0x6B TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 [RFC5246] | |
| 725 | + * 0x00,0x6C TLS_DH_anon_WITH_AES_128_CBC_SHA256 [RFC5246] | |
| 726 | + * 0x00,0x6D TLS_DH_anon_WITH_AES_256_CBC_SHA256 [RFC5246] | |
| 727 | + * 0x00,0x6E-83 Unassigned | |
| 728 | + * 0x00,0x84 TLS_RSA_WITH_CAMELLIA_256_CBC_SHA [RFC5932] | |
| 729 | + * 0x00,0x85 TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA [RFC5932] | |
| 730 | + * 0x00,0x86 TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA [RFC5932] | |
| 731 | + * 0x00,0x87 TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA [RFC5932] | |
| 732 | + * 0x00,0x88 TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA [RFC5932] | |
| 733 | + * 0x00,0x89 TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA [RFC5932] | |
| 734 | + * 0x00,0x8A TLS_PSK_WITH_RC4_128_SHA [RFC4279] | |
| 735 | + * 0x00,0x8B TLS_PSK_WITH_3DES_EDE_CBC_SHA [RFC4279] | |
| 736 | + * 0x00,0x8C TLS_PSK_WITH_AES_128_CBC_SHA [RFC4279] | |
| 737 | + * 0x00,0x8D TLS_PSK_WITH_AES_256_CBC_SHA [RFC4279] | |
| 738 | + * 0x00,0x8E TLS_DHE_PSK_WITH_RC4_128_SHA [RFC4279] | |
| 739 | + * 0x00,0x8F TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA [RFC4279] | |
| 740 | + * 0x00,0x90 TLS_DHE_PSK_WITH_AES_128_CBC_SHA [RFC4279] | |
| 741 | + * 0x00,0x91 TLS_DHE_PSK_WITH_AES_256_CBC_SHA [RFC4279] | |
| 742 | + * 0x00,0x92 TLS_RSA_PSK_WITH_RC4_128_SHA [RFC4279] | |
| 743 | + * 0x00,0x93 TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA [RFC4279] | |
| 744 | + * 0x00,0x94 TLS_RSA_PSK_WITH_AES_128_CBC_SHA [RFC4279] | |
| 745 | + * 0x00,0x95 TLS_RSA_PSK_WITH_AES_256_CBC_SHA [RFC4279] | |
| 746 | + * 0x00,0x96 TLS_RSA_WITH_SEED_CBC_SHA [RFC4162] | |
| 747 | + * 0x00,0x97 TLS_DH_DSS_WITH_SEED_CBC_SHA [RFC4162] | |
| 748 | + * 0x00,0x98 TLS_DH_RSA_WITH_SEED_CBC_SHA [RFC4162] | |
| 749 | + * 0x00,0x99 TLS_DHE_DSS_WITH_SEED_CBC_SHA [RFC4162] | |
| 750 | + * 0x00,0x9A TLS_DHE_RSA_WITH_SEED_CBC_SHA [RFC4162] | |
| 751 | + * 0x00,0x9B TLS_DH_anon_WITH_SEED_CBC_SHA [RFC4162] | |
| 752 | + * 0x00,0x9C TLS_RSA_WITH_AES_128_GCM_SHA256 [RFC5288] | |
| 753 | + * 0x00,0x9D TLS_RSA_WITH_AES_256_GCM_SHA384 [RFC5288] | |
| 754 | + * 0x00,0x9E TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 [RFC5288] | |
| 755 | + * 0x00,0x9F TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 [RFC5288] | |
| 756 | + * 0x00,0xA0 TLS_DH_RSA_WITH_AES_128_GCM_SHA256 [RFC5288] | |
| 757 | + * 0x00,0xA1 TLS_DH_RSA_WITH_AES_256_GCM_SHA384 [RFC5288] | |
| 758 | + * 0x00,0xA2 TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 [RFC5288] | |
| 759 | + * 0x00,0xA3 TLS_DHE_DSS_WITH_AES_256_GCM_SHA384 [RFC5288] | |
| 760 | + * 0x00,0xA4 TLS_DH_DSS_WITH_AES_128_GCM_SHA256 [RFC5288] | |
| 761 | + * 0x00,0xA5 TLS_DH_DSS_WITH_AES_256_GCM_SHA384 [RFC5288] | |
| 762 | + * 0x00,0xA6 TLS_DH_anon_WITH_AES_128_GCM_SHA256 [RFC5288] | |
| 763 | + * 0x00,0xA7 TLS_DH_anon_WITH_AES_256_GCM_SHA384 [RFC5288] | |
| 764 | + * 0x00,0xA8 TLS_PSK_WITH_AES_128_GCM_SHA256 [RFC5487] | |
| 765 | + * 0x00,0xA9 TLS_PSK_WITH_AES_256_GCM_SHA384 [RFC5487] | |
| 766 | + * 0x00,0xAA TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 [RFC5487] | |
| 767 | + * 0x00,0xAB TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 [RFC5487] | |
| 768 | + * 0x00,0xAC TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 [RFC5487] | |
| 769 | + * 0x00,0xAD TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 [RFC5487] | |
| 770 | + * 0x00,0xAE TLS_PSK_WITH_AES_128_CBC_SHA256 [RFC5487] | |
| 771 | + * 0x00,0xAF TLS_PSK_WITH_AES_256_CBC_SHA384 [RFC5487] | |
| 772 | + * 0x00,0xB0 TLS_PSK_WITH_NULL_SHA256 [RFC5487] | |
| 773 | + * 0x00,0xB1 TLS_PSK_WITH_NULL_SHA384 [RFC5487] | |
| 774 | + * 0x00,0xB2 TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 [RFC5487] | |
| 775 | + * 0x00,0xB3 TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 [RFC5487] | |
| 776 | + * 0x00,0xB4 TLS_DHE_PSK_WITH_NULL_SHA256 [RFC5487] | |
| 777 | + * 0x00,0xB5 TLS_DHE_PSK_WITH_NULL_SHA384 [RFC5487] | |
| 778 | + * 0x00,0xB6 TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 [RFC5487] | |
| 779 | + * 0x00,0xB7 TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 [RFC5487] | |
| 780 | + * 0x00,0xB8 TLS_RSA_PSK_WITH_NULL_SHA256 [RFC5487] | |
| 781 | + * 0x00,0xB9 TLS_RSA_PSK_WITH_NULL_SHA384 [RFC5487] | |
| 782 | + * 0x00,0xBA TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 [RFC5932] | |
| 783 | + * 0x00,0xBB TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256 [RFC5932] | |
| 784 | + * 0x00,0xBC TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256 [RFC5932] | |
| 785 | + * 0x00,0xBD TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 [RFC5932] | |
| 786 | + * 0x00,0xBE TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 [RFC5932] | |
| 787 | + * 0x00,0xBF TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256 [RFC5932] | |
| 788 | + * 0x00,0xC0 TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 [RFC5932] | |
| 789 | + * 0x00,0xC1 TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256 [RFC5932] | |
| 790 | + * 0x00,0xC2 TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256 [RFC5932] | |
| 791 | + * 0x00,0xC3 TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 [RFC5932] | |
| 792 | + * 0x00,0xC4 TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 [RFC5932] | |
| 793 | + * 0x00,0xC5 TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256 [RFC5932] | |
| 794 | + * 0x00,0xC6-FE Unassigned | |
| 795 | + * 0x00,0xFF TLS_EMPTY_RENEGOTIATION_INFO_SCSV [RFC5746] | |
| 796 | + * 0x01-BF,* Unassigned | |
| 797 | + * 0xC0,0x01 TLS_ECDH_ECDSA_WITH_NULL_SHA [RFC4492] | |
| 798 | + * 0xC0,0x02 TLS_ECDH_ECDSA_WITH_RC4_128_SHA [RFC4492] | |
| 799 | + * 0xC0,0x03 TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA [RFC4492] | |
| 800 | + * 0xC0,0x04 TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA [RFC4492] | |
| 801 | + * 0xC0,0x05 TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA [RFC4492] | |
| 802 | + * 0xC0,0x06 TLS_ECDHE_ECDSA_WITH_NULL_SHA [RFC4492] | |
| 803 | + * 0xC0,0x07 TLS_ECDHE_ECDSA_WITH_RC4_128_SHA [RFC4492] | |
| 804 | + * 0xC0,0x08 TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA [RFC4492] | |
| 805 | + * 0xC0,0x09 TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA [RFC4492] | |
| 806 | + * 0xC0,0x0A TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA [RFC4492] | |
| 807 | + * 0xC0,0x0B TLS_ECDH_RSA_WITH_NULL_SHA [RFC4492] | |
| 808 | + * 0xC0,0x0C TLS_ECDH_RSA_WITH_RC4_128_SHA [RFC4492] | |
| 809 | + * 0xC0,0x0D TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA [RFC4492] | |
| 810 | + * 0xC0,0x0E TLS_ECDH_RSA_WITH_AES_128_CBC_SHA [RFC4492] | |
| 811 | + * 0xC0,0x0F TLS_ECDH_RSA_WITH_AES_256_CBC_SHA [RFC4492] | |
| 812 | + * 0xC0,0x10 TLS_ECDHE_RSA_WITH_NULL_SHA [RFC4492] | |
| 813 | + * 0xC0,0x11 TLS_ECDHE_RSA_WITH_RC4_128_SHA [RFC4492] | |
| 814 | + * 0xC0,0x12 TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA [RFC4492] | |
| 815 | + * 0xC0,0x13 TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA [RFC4492] | |
| 816 | + * 0xC0,0x14 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA [RFC4492] | |
| 817 | + * 0xC0,0x15 TLS_ECDH_anon_WITH_NULL_SHA [RFC4492] | |
| 818 | + * 0xC0,0x16 TLS_ECDH_anon_WITH_RC4_128_SHA [RFC4492] | |
| 819 | + * 0xC0,0x17 TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA [RFC4492] | |
| 820 | + * 0xC0,0x18 TLS_ECDH_anon_WITH_AES_128_CBC_SHA [RFC4492] | |
| 821 | + * 0xC0,0x19 TLS_ECDH_anon_WITH_AES_256_CBC_SHA [RFC4492] | |
| 822 | + * 0xC0,0x1A TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA [RFC5054] | |
| 823 | + * 0xC0,0x1B TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA [RFC5054] | |
| 824 | + * 0xC0,0x1C TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA [RFC5054] | |
| 825 | + * 0xC0,0x1D TLS_SRP_SHA_WITH_AES_128_CBC_SHA [RFC5054] | |
| 826 | + * 0xC0,0x1E TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA [RFC5054] | |
| 827 | + * 0xC0,0x1F TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA [RFC5054] | |
| 828 | + * 0xC0,0x20 TLS_SRP_SHA_WITH_AES_256_CBC_SHA [RFC5054] | |
| 829 | + * 0xC0,0x21 TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA [RFC5054] | |
| 830 | + * 0xC0,0x22 TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA [RFC5054] | |
| 831 | + * 0xC0,0x23 TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 [RFC5289] | |
| 832 | + * 0xC0,0x24 TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 [RFC5289] | |
| 833 | + * 0xC0,0x25 TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 [RFC5289] | |
| 834 | + * 0xC0,0x26 TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 [RFC5289] | |
| 835 | + * 0xC0,0x27 TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 [RFC5289] | |
| 836 | + * 0xC0,0x28 TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 [RFC5289] | |
| 837 | + * 0xC0,0x29 TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 [RFC5289] | |
| 838 | + * 0xC0,0x2A TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 [RFC5289] | |
| 839 | + * 0xC0,0x2B TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 [RFC5289] | |
| 840 | + * 0xC0,0x2C TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 [RFC5289] | |
| 841 | + * 0xC0,0x2D TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 [RFC5289] | |
| 842 | + * 0xC0,0x2E TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 [RFC5289] | |
| 843 | + * 0xC0,0x2F TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 [RFC5289] | |
| 844 | + * 0xC0,0x30 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 [RFC5289] | |
| 845 | + * 0xC0,0x31 TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 [RFC5289] | |
| 846 | + * 0xC0,0x32 TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 [RFC5289] | |
| 847 | + * 0xC0,0x33 TLS_ECDHE_PSK_WITH_RC4_128_SHA [RFC5489] | |
| 848 | + * 0xC0,0x34 TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA [RFC5489] | |
| 849 | + * 0xC0,0x35 TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA [RFC5489] | |
| 850 | + * 0xC0,0x36 TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA [RFC5489] | |
| 851 | + * 0xC0,0x37 TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 [RFC5489] | |
| 852 | + * 0xC0,0x38 TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 [RFC5489] | |
| 853 | + * 0xC0,0x39 TLS_ECDHE_PSK_WITH_NULL_SHA [RFC5489] | |
| 854 | + * 0xC0,0x3A TLS_ECDHE_PSK_WITH_NULL_SHA256 [RFC5489] | |
| 855 | + * 0xC0,0x3B TLS_ECDHE_PSK_WITH_NULL_SHA384 [RFC5489] | |
| 856 | + * 0xC0,0x3C-FF Unassigned | |
| 857 | + * 0xC1-FD,* Unassigned | |
| 858 | + * 0xFE,0x00-FD Unassigned | |
| 859 | + * 0xFE,0xFE-FF Reserved to avoid conflicts with widely | |
| 860 | + * deployed implementations [Pasi_Eronen] | |
| 861 | + * 0xFF,0x00-FF Reserved for Private Use [RFC5246] | |
| 862 | + */ | |
| 863 | + | |
| 864 | + add("SSL_NULL_WITH_NULL_NULL", | |
| 865 | + 0x0000, 1, K_NULL, B_NULL, F); | |
| 866 | + | |
| 867 | + /* | |
| 868 | + * Definition of the CipherSuites that are enabled by default. | |
| 869 | + * They are listed in preference order, most preferred first, using | |
| 870 | + * the following criteria: | |
| 871 | + * 1. Prefer the stronger buld cipher, in the order of AES_256, | |
| 872 | + * AES_128, RC-4, 3DES-EDE. | |
| 873 | + * 2. Prefer the stronger MAC algorithm, in the order of SHA384, | |
| 874 | + * SHA256, SHA, MD5. | |
| 875 | + * 3. Prefer the better performance of key exchange and digital | |
| 876 | + * signature algorithm, in the order of ECDHE-ECDSA, ECDHE-RSA, | |
| 877 | + * RSA, ECDH-ECDSA, ECDH-RSA, DHE-RSA, DHE-DSS. | |
| 878 | + */ | |
| 879 | + int p = DEFAULT_SUITES_PRIORITY * 2; | |
| 880 | + | |
| 881 | + // shorten names to fit the following table cleanly. | |
| 882 | + int max = ProtocolVersion.LIMIT_MAX_VALUE; | |
| 883 | + int tls11 = ProtocolVersion.TLS11.v; | |
| 884 | + int tls12 = ProtocolVersion.TLS12.v; | |
| 885 | + | |
| 886 | + // ID Key Exchange Cipher A obs suprt PRF | |
| 887 | + // ====== ============ ========= = === ===== ======== | |
| 888 | + add("TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", | |
| 889 | + 0xc024, --p, K_ECDHE_ECDSA, B_AES_256, T, max, tls12, P_SHA384); | |
| 890 | + add("TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", | |
| 891 | + 0xc028, --p, K_ECDHE_RSA, B_AES_256, T, max, tls12, P_SHA384); | |
| 892 | + add("TLS_RSA_WITH_AES_256_CBC_SHA256", | |
| 893 | + 0x003d, --p, K_RSA, B_AES_256, T, max, tls12, P_SHA256); | |
| 894 | + add("TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384", | |
| 895 | + 0xc026, --p, K_ECDH_ECDSA, B_AES_256, T, max, tls12, P_SHA384); | |
| 896 | + add("TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384", | |
| 897 | + 0xc02a, --p, K_ECDH_RSA, B_AES_256, T, max, tls12, P_SHA384); | |
| 898 | + add("TLS_DHE_RSA_WITH_AES_256_CBC_SHA256", | |
| 899 | + 0x006b, --p, K_DHE_RSA, B_AES_256, T, max, tls12, P_SHA256); | |
| 900 | + add("TLS_DHE_DSS_WITH_AES_256_CBC_SHA256", | |
| 901 | + 0x006a, --p, K_DHE_DSS, B_AES_256, T, max, tls12, P_SHA256); | |
| 902 | + | |
| 903 | + add("TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", | |
| 904 | + 0xC00A, --p, K_ECDHE_ECDSA, B_AES_256, T); | |
| 905 | + add("TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", | |
| 906 | + 0xC014, --p, K_ECDHE_RSA, B_AES_256, T); | |
| 907 | + add("TLS_RSA_WITH_AES_256_CBC_SHA", | |
| 908 | + 0x0035, --p, K_RSA, B_AES_256, T); | |
| 909 | + add("TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA", | |
| 910 | + 0xC005, --p, K_ECDH_ECDSA, B_AES_256, T); | |
| 911 | + add("TLS_ECDH_RSA_WITH_AES_256_CBC_SHA", | |
| 912 | + 0xC00F, --p, K_ECDH_RSA, B_AES_256, T); | |
| 913 | + add("TLS_DHE_RSA_WITH_AES_256_CBC_SHA", | |
| 914 | + 0x0039, --p, K_DHE_RSA, B_AES_256, T); | |
| 915 | + add("TLS_DHE_DSS_WITH_AES_256_CBC_SHA", | |
| 916 | + 0x0038, --p, K_DHE_DSS, B_AES_256, T); | |
| 917 | + | |
| 918 | + add("TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", | |
| 919 | + 0xc023, --p, K_ECDHE_ECDSA, B_AES_128, T, max, tls12, P_SHA256); | |
| 920 | + add("TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", | |
| 921 | + 0xc027, --p, K_ECDHE_RSA, B_AES_128, T, max, tls12, P_SHA256); | |
| 922 | + add("TLS_RSA_WITH_AES_128_CBC_SHA256", | |
| 923 | + 0x003c, --p, K_RSA, B_AES_128, T, max, tls12, P_SHA256); | |
| 924 | + add("TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256", | |
| 925 | + 0xc025, --p, K_ECDH_ECDSA, B_AES_128, T, max, tls12, P_SHA256); | |
| 926 | + add("TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256", | |
| 927 | + 0xc029, --p, K_ECDH_RSA, B_AES_128, T, max, tls12, P_SHA256); | |
| 928 | + add("TLS_DHE_RSA_WITH_AES_128_CBC_SHA256", | |
| 929 | + 0x0067, --p, K_DHE_RSA, B_AES_128, T, max, tls12, P_SHA256); | |
| 930 | + add("TLS_DHE_DSS_WITH_AES_128_CBC_SHA256", | |
| 931 | + 0x0040, --p, K_DHE_DSS, B_AES_128, T, max, tls12, P_SHA256); | |
| 932 | + | |
| 933 | + add("TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", | |
| 934 | + 0xC009, --p, K_ECDHE_ECDSA, B_AES_128, T); | |
| 935 | + add("TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", | |
| 936 | + 0xC013, --p, K_ECDHE_RSA, B_AES_128, T); | |
| 937 | + add("TLS_RSA_WITH_AES_128_CBC_SHA", | |
| 938 | + 0x002f, --p, K_RSA, B_AES_128, T); | |
| 939 | + add("TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA", | |
| 940 | + 0xC004, --p, K_ECDH_ECDSA, B_AES_128, T); | |
| 941 | + add("TLS_ECDH_RSA_WITH_AES_128_CBC_SHA", | |
| 942 | + 0xC00E, --p, K_ECDH_RSA, B_AES_128, T); | |
| 943 | + add("TLS_DHE_RSA_WITH_AES_128_CBC_SHA", | |
| 944 | + 0x0033, --p, K_DHE_RSA, B_AES_128, T); | |
| 945 | + add("TLS_DHE_DSS_WITH_AES_128_CBC_SHA", | |
| 946 | + 0x0032, --p, K_DHE_DSS, B_AES_128, T); | |
| 947 | + | |
| 948 | + add("TLS_ECDHE_ECDSA_WITH_RC4_128_SHA", | |
| 949 | + 0xC007, --p, K_ECDHE_ECDSA, B_RC4_128, N); | |
| 950 | + add("TLS_ECDHE_RSA_WITH_RC4_128_SHA", | |
| 951 | + 0xC011, --p, K_ECDHE_RSA, B_RC4_128, N); | |
| 952 | + add("SSL_RSA_WITH_RC4_128_SHA", | |
| 953 | + 0x0005, --p, K_RSA, B_RC4_128, N); | |
| 954 | + add("TLS_ECDH_ECDSA_WITH_RC4_128_SHA", | |
| 955 | + 0xC002, --p, K_ECDH_ECDSA, B_RC4_128, N); | |
| 956 | + add("TLS_ECDH_RSA_WITH_RC4_128_SHA", | |
| 957 | + 0xC00C, --p, K_ECDH_RSA, B_RC4_128, N); | |
| 958 | + | |
| 959 | + add("TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA", | |
| 960 | + 0xC008, --p, K_ECDHE_ECDSA, B_3DES, T); | |
| 961 | + add("TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA", | |
| 962 | + 0xC012, --p, K_ECDHE_RSA, B_3DES, T); | |
| 963 | + add("SSL_RSA_WITH_3DES_EDE_CBC_SHA", | |
| 964 | + 0x000a, --p, K_RSA, B_3DES, T); | |
| 965 | + add("TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA", | |
| 966 | + 0xC003, --p, K_ECDH_ECDSA, B_3DES, T); | |
| 967 | + add("TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA", | |
| 968 | + 0xC00D, --p, K_ECDH_RSA, B_3DES, T); | |
| 969 | + add("SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA", | |
| 970 | + 0x0016, --p, K_DHE_RSA, B_3DES, T); | |
| 971 | + add("SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA", | |
| 972 | + 0x0013, --p, K_DHE_DSS, B_3DES, N); | |
| 973 | + | |
| 974 | + add("SSL_RSA_WITH_RC4_128_MD5", | |
| 975 | + 0x0004, --p, K_RSA, B_RC4_128, N); | |
| 976 | + | |
| 977 | + // Renegotiation protection request Signalling Cipher Suite Value (SCSV) | |
| 978 | + add("TLS_EMPTY_RENEGOTIATION_INFO_SCSV", | |
| 979 | + 0x00ff, --p, K_SCSV, B_NULL, T); | |
| 980 | + | |
| 981 | + /* | |
| 982 | + * Definition of the CipherSuites that are supported but not enabled | |
| 983 | + * by default. | |
| 984 | + * They are listed in preference order, preferred first, using the | |
| 985 | + * following criteria: | |
| 986 | + * 1. CipherSuites for KRB5 need additional KRB5 service | |
| 987 | + * configuration, and these suites are not common in practice, | |
| 988 | + * so we put KRB5 based cipher suites at the end of the supported | |
| 989 | + * list. | |
| 990 | + * 2. If a cipher suite has been obsoleted, we put it at the end of | |
| 991 | + * the list. | |
| 992 | + * 3. Prefer the stronger bulk cipher, in the order of AES_256, | |
| 993 | + * AES_128, RC-4, 3DES-EDE, DES, RC4_40, DES40, NULL. | |
| 994 | + * 4. Prefer the stronger MAC algorithm, in the order of SHA384, | |
| 995 | + * SHA256, SHA, MD5. | |
| 996 | + * 5. Prefer the better performance of key exchange and digital | |
| 997 | + * signature algorithm, in the order of ECDHE-ECDSA, ECDHE-RSA, | |
| 998 | + * RSA, ECDH-ECDSA, ECDH-RSA, DHE-RSA, DHE-DSS, anonymous. | |
| 999 | + */ | |
| 1000 | + p = DEFAULT_SUITES_PRIORITY; | |
| 1001 | + | |
| 1002 | + add("TLS_DH_anon_WITH_AES_256_CBC_SHA256", | |
| 1003 | + 0x006d, --p, K_DH_ANON, B_AES_256, N, max, tls12, P_SHA256); | |
| 1004 | + add("TLS_ECDH_anon_WITH_AES_256_CBC_SHA", | |
| 1005 | + 0xC019, --p, K_ECDH_ANON, B_AES_256, T); | |
| 1006 | + add("TLS_DH_anon_WITH_AES_256_CBC_SHA", | |
| 1007 | + 0x003a, --p, K_DH_ANON, B_AES_256, N); | |
| 1008 | + | |
| 1009 | + add("TLS_DH_anon_WITH_AES_128_CBC_SHA256", | |
| 1010 | + 0x006c, --p, K_DH_ANON, B_AES_128, N, max, tls12, P_SHA256); | |
| 1011 | + add("TLS_ECDH_anon_WITH_AES_128_CBC_SHA", | |
| 1012 | + 0xC018, --p, K_ECDH_ANON, B_AES_128, T); | |
| 1013 | + add("TLS_DH_anon_WITH_AES_128_CBC_SHA", | |
| 1014 | + 0x0034, --p, K_DH_ANON, B_AES_128, N); | |
| 1015 | + | |
| 1016 | + add("TLS_ECDH_anon_WITH_RC4_128_SHA", | |
| 1017 | + 0xC016, --p, K_ECDH_ANON, B_RC4_128, N); | |
| 1018 | + add("SSL_DH_anon_WITH_RC4_128_MD5", | |
| 1019 | + 0x0018, --p, K_DH_ANON, B_RC4_128, N); | |
| 1020 | + | |
| 1021 | + add("TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA", | |
| 1022 | + 0xC017, --p, K_ECDH_ANON, B_3DES, T); | |
| 1023 | + add("SSL_DH_anon_WITH_3DES_EDE_CBC_SHA", | |
| 1024 | + 0x001b, --p, K_DH_ANON, B_3DES, N); | |
| 1025 | + | |
| 1026 | + add("TLS_RSA_WITH_NULL_SHA256", | |
| 1027 | + 0x003b, --p, K_RSA, B_NULL, N, max, tls12, P_SHA256); | |
| 1028 | + add("TLS_ECDHE_ECDSA_WITH_NULL_SHA", | |
| 1029 | + 0xC006, --p, K_ECDHE_ECDSA, B_NULL, N); | |
| 1030 | + add("TLS_ECDHE_RSA_WITH_NULL_SHA", | |
| 1031 | + 0xC010, --p, K_ECDHE_RSA, B_NULL, N); | |
| 1032 | + add("SSL_RSA_WITH_NULL_SHA", | |
| 1033 | + 0x0002, --p, K_RSA, B_NULL, N); | |
| 1034 | + add("TLS_ECDH_ECDSA_WITH_NULL_SHA", | |
| 1035 | + 0xC001, --p, K_ECDH_ECDSA, B_NULL, N); | |
| 1036 | + add("TLS_ECDH_RSA_WITH_NULL_SHA", | |
| 1037 | + 0xC00B, --p, K_ECDH_RSA, B_NULL, N); | |
| 1038 | + add("TLS_ECDH_anon_WITH_NULL_SHA", | |
| 1039 | + 0xC015, --p, K_ECDH_ANON, B_NULL, N); | |
| 1040 | + add("SSL_RSA_WITH_NULL_MD5", | |
| 1041 | + 0x0001, --p, K_RSA, B_NULL, N); | |
| 1042 | + | |
| 1043 | + // weak cipher suites obsoleted in TLS 1.2 | |
| 1044 | + add("SSL_RSA_WITH_DES_CBC_SHA", | |
| 1045 | + 0x0009, --p, K_RSA, B_DES, N, tls12); | |
| 1046 | + add("SSL_DHE_RSA_WITH_DES_CBC_SHA", | |
| 1047 | + 0x0015, --p, K_DHE_RSA, B_DES, N, tls12); | |
| 1048 | + add("SSL_DHE_DSS_WITH_DES_CBC_SHA", | |
| 1049 | + 0x0012, --p, K_DHE_DSS, B_DES, N, tls12); | |
| 1050 | + add("SSL_DH_anon_WITH_DES_CBC_SHA", | |
| 1051 | + 0x001a, --p, K_DH_ANON, B_DES, N, tls12); | |
| 1052 | + | |
| 1053 | + // weak cipher suites obsoleted in TLS 1.1 | |
| 1054 | + add("SSL_RSA_EXPORT_WITH_RC4_40_MD5", | |
| 1055 | + 0x0003, --p, K_RSA_EXPORT, B_RC4_40, N, tls11); | |
| 1056 | + add("SSL_DH_anon_EXPORT_WITH_RC4_40_MD5", | |
| 1057 | + 0x0017, --p, K_DH_ANON, B_RC4_40, N, tls11); | |
| 1058 | + | |
| 1059 | + add("SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", | |
| 1060 | + 0x0008, --p, K_RSA_EXPORT, B_DES_40, N, tls11); | |
| 1061 | + add("SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", | |
| 1062 | + 0x0014, --p, K_DHE_RSA, B_DES_40, N, tls11); | |
| 1063 | + add("SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", | |
| 1064 | + 0x0011, --p, K_DHE_DSS, B_DES_40, N, tls11); | |
| 1065 | + add("SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", | |
| 1066 | + 0x0019, --p, K_DH_ANON, B_DES_40, N, tls11); | |
| 1067 | + | |
| 1068 | + // Supported Kerberos ciphersuites from RFC2712 | |
| 1069 | + add("TLS_KRB5_WITH_RC4_128_SHA", | |
| 1070 | + 0x0020, --p, K_KRB5, B_RC4_128, N); | |
| 1071 | + add("TLS_KRB5_WITH_RC4_128_MD5", | |
| 1072 | + 0x0024, --p, K_KRB5, B_RC4_128, N); | |
| 1073 | + add("TLS_KRB5_WITH_3DES_EDE_CBC_SHA", | |
| 1074 | + 0x001f, --p, K_KRB5, B_3DES, N); | |
| 1075 | + add("TLS_KRB5_WITH_3DES_EDE_CBC_MD5", | |
| 1076 | + 0x0023, --p, K_KRB5, B_3DES, N); | |
| 1077 | + add("TLS_KRB5_WITH_DES_CBC_SHA", | |
| 1078 | + 0x001e, --p, K_KRB5, B_DES, N, tls12); | |
| 1079 | + add("TLS_KRB5_WITH_DES_CBC_MD5", | |
| 1080 | + 0x0022, --p, K_KRB5, B_DES, N, tls12); | |
| 1081 | + add("TLS_KRB5_EXPORT_WITH_RC4_40_SHA", | |
| 1082 | + 0x0028, --p, K_KRB5_EXPORT, B_RC4_40, N, tls11); | |
| 1083 | + add("TLS_KRB5_EXPORT_WITH_RC4_40_MD5", | |
| 1084 | + 0x002b, --p, K_KRB5_EXPORT, B_RC4_40, N, tls11); | |
| 1085 | + add("TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA", | |
| 1086 | + 0x0026, --p, K_KRB5_EXPORT, B_DES_40, N, tls11); | |
| 1087 | + add("TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5", | |
| 1088 | + 0x0029, --p, K_KRB5_EXPORT, B_DES_40, N, tls11); | |
| 1089 | + | |
| 1090 | + /* | |
| 1091 | + * Other values from the TLS Cipher Suite Registry, as of August 2010. | |
| 1092 | + * | |
| 1093 | + * http://www.iana.org/assignments/tls-parameters/tls-parameters.xml | |
| 1094 | + * | |
| 1095 | + * Range Registration Procedures Notes | |
| 1096 | + * 000-191 Standards Action Refers to value of first byte | |
| 1097 | + * 192-254 Specification Required Refers to value of first byte | |
| 1098 | + * 255 Reserved for Private Use Refers to value of first byte | |
| 1099 | + */ | |
| 1100 | + | |
| 1101 | + // Register the names of a few additional CipherSuites. | |
| 1102 | + // Makes them show up as names instead of numbers in | |
| 1103 | + // the debug output. | |
| 1104 | + | |
| 1105 | + // remaining unsupported ciphersuites defined in RFC2246. | |
| 1106 | + add("SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5", 0x0006); | |
| 1107 | + add("SSL_RSA_WITH_IDEA_CBC_SHA", 0x0007); | |
| 1108 | + add("SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA", 0x000b); | |
| 1109 | + add("SSL_DH_DSS_WITH_DES_CBC_SHA", 0x000c); | |
| 1110 | + add("SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA", 0x000d); | |
| 1111 | + add("SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA", 0x000e); | |
| 1112 | + add("SSL_DH_RSA_WITH_DES_CBC_SHA", 0x000f); | |
| 1113 | + add("SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA", 0x0010); | |
| 1114 | + | |
| 1115 | + // SSL 3.0 Fortezza ciphersuites | |
| 1116 | + add("SSL_FORTEZZA_DMS_WITH_NULL_SHA", 0x001c); | |
| 1117 | + add("SSL_FORTEZZA_DMS_WITH_FORTEZZA_CBC_SHA", 0x001d); | |
| 1118 | + | |
| 1119 | + // 1024/56 bit exportable ciphersuites from expired internet draft | |
| 1120 | + add("SSL_RSA_EXPORT1024_WITH_DES_CBC_SHA", 0x0062); | |
| 1121 | + add("SSL_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA", 0x0063); | |
| 1122 | + add("SSL_RSA_EXPORT1024_WITH_RC4_56_SHA", 0x0064); | |
| 1123 | + add("SSL_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA", 0x0065); | |
| 1124 | + add("SSL_DHE_DSS_WITH_RC4_128_SHA", 0x0066); | |
| 1125 | + | |
| 1126 | + // Netscape old and new SSL 3.0 FIPS ciphersuites | |
| 1127 | + // see http://www.mozilla.org/projects/security/pki/nss/ssl/fips-ssl-ciphersuites.html | |
| 1128 | + add("NETSCAPE_RSA_FIPS_WITH_3DES_EDE_CBC_SHA", 0xffe0); | |
| 1129 | + add("NETSCAPE_RSA_FIPS_WITH_DES_CBC_SHA", 0xffe1); | |
| 1130 | + add("SSL_RSA_FIPS_WITH_DES_CBC_SHA", 0xfefe); | |
| 1131 | + add("SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA", 0xfeff); | |
| 1132 | + | |
| 1133 | + // Unsupported Kerberos cipher suites from RFC 2712 | |
| 1134 | + add("TLS_KRB5_WITH_IDEA_CBC_SHA", 0x0021); | |
| 1135 | + add("TLS_KRB5_WITH_IDEA_CBC_MD5", 0x0025); | |
| 1136 | + add("TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA", 0x0027); | |
| 1137 | + add("TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5", 0x002a); | |
| 1138 | + | |
| 1139 | + // Unsupported cipher suites from RFC 4162 | |
| 1140 | + add("TLS_RSA_WITH_SEED_CBC_SHA", 0x0096); | |
| 1141 | + add("TLS_DH_DSS_WITH_SEED_CBC_SHA", 0x0097); | |
| 1142 | + add("TLS_DH_RSA_WITH_SEED_CBC_SHA", 0x0098); | |
| 1143 | + add("TLS_DHE_DSS_WITH_SEED_CBC_SHA", 0x0099); | |
| 1144 | + add("TLS_DHE_RSA_WITH_SEED_CBC_SHA", 0x009a); | |
| 1145 | + add("TLS_DH_anon_WITH_SEED_CBC_SHA", 0x009b); | |
| 1146 | + | |
| 1147 | + // Unsupported cipher suites from RFC 4279 | |
| 1148 | + add("TLS_PSK_WITH_RC4_128_SHA", 0x008a); | |
| 1149 | + add("TLS_PSK_WITH_3DES_EDE_CBC_SHA", 0x008b); | |
| 1150 | + add("TLS_PSK_WITH_AES_128_CBC_SHA", 0x008c); | |
| 1151 | + add("TLS_PSK_WITH_AES_256_CBC_SHA", 0x008d); | |
| 1152 | + add("TLS_DHE_PSK_WITH_RC4_128_SHA", 0x008e); | |
| 1153 | + add("TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA", 0x008f); | |
| 1154 | + add("TLS_DHE_PSK_WITH_AES_128_CBC_SHA", 0x0090); | |
| 1155 | + add("TLS_DHE_PSK_WITH_AES_256_CBC_SHA", 0x0091); | |
| 1156 | + add("TLS_RSA_PSK_WITH_RC4_128_SHA", 0x0092); | |
| 1157 | + add("TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA", 0x0093); | |
| 1158 | + add("TLS_RSA_PSK_WITH_AES_128_CBC_SHA", 0x0094); | |
| 1159 | + add("TLS_RSA_PSK_WITH_AES_256_CBC_SHA", 0x0095); | |
| 1160 | + | |
| 1161 | + // Unsupported cipher suites from RFC 4785 | |
| 1162 | + add("TLS_PSK_WITH_NULL_SHA", 0x002c); | |
| 1163 | + add("TLS_DHE_PSK_WITH_NULL_SHA", 0x002d); | |
| 1164 | + add("TLS_RSA_PSK_WITH_NULL_SHA", 0x002e); | |
| 1165 | + | |
| 1166 | + // Unsupported cipher suites from RFC 5246 | |
| 1167 | + add("TLS_DH_DSS_WITH_AES_128_CBC_SHA", 0x0030); | |
| 1168 | + add("TLS_DH_RSA_WITH_AES_128_CBC_SHA", 0x0031); | |
| 1169 | + add("TLS_DH_DSS_WITH_AES_256_CBC_SHA", 0x0036); | |
| 1170 | + add("TLS_DH_RSA_WITH_AES_256_CBC_SHA", 0x0037); | |
| 1171 | + add("TLS_DH_DSS_WITH_AES_128_CBC_SHA256", 0x003e); | |
| 1172 | + add("TLS_DH_RSA_WITH_AES_128_CBC_SHA256", 0x003f); | |
| 1173 | + add("TLS_DH_DSS_WITH_AES_256_CBC_SHA256", 0x0068); | |
| 1174 | + add("TLS_DH_RSA_WITH_AES_256_CBC_SHA256", 0x0069); | |
| 1175 | + | |
| 1176 | + // Unsupported cipher suites from RFC 5288 | |
| 1177 | + add("TLS_RSA_WITH_AES_128_GCM_SHA256", 0x009c); | |
| 1178 | + add("TLS_RSA_WITH_AES_256_GCM_SHA384", 0x009d); | |
| 1179 | + add("TLS_DHE_RSA_WITH_AES_128_GCM_SHA256", 0x009e); | |
| 1180 | + add("TLS_DHE_RSA_WITH_AES_256_GCM_SHA384", 0x009f); | |
| 1181 | + add("TLS_DH_RSA_WITH_AES_128_GCM_SHA256", 0x00a0); | |
| 1182 | + add("TLS_DH_RSA_WITH_AES_256_GCM_SHA384", 0x00a1); | |
| 1183 | + add("TLS_DHE_DSS_WITH_AES_128_GCM_SHA256", 0x00a2); | |
| 1184 | + add("TLS_DHE_DSS_WITH_AES_256_GCM_SHA384", 0x00a3); | |
| 1185 | + add("TLS_DH_DSS_WITH_AES_128_GCM_SHA256", 0x00a4); | |
| 1186 | + add("TLS_DH_DSS_WITH_AES_256_GCM_SHA384", 0x00a5); | |
| 1187 | + add("TLS_DH_anon_WITH_AES_128_GCM_SHA256", 0x00a6); | |
| 1188 | + add("TLS_DH_anon_WITH_AES_256_GCM_SHA384", 0x00a7); | |
| 1189 | + | |
| 1190 | + // Unsupported cipher suites from RFC 5487 | |
| 1191 | + add("TLS_PSK_WITH_AES_128_GCM_SHA256", 0x00a8); | |
| 1192 | + add("TLS_PSK_WITH_AES_256_GCM_SHA384", 0x00a9); | |
| 1193 | + add("TLS_DHE_PSK_WITH_AES_128_GCM_SHA256", 0x00aa); | |
| 1194 | + add("TLS_DHE_PSK_WITH_AES_256_GCM_SHA384", 0x00ab); | |
| 1195 | + add("TLS_RSA_PSK_WITH_AES_128_GCM_SHA256", 0x00ac); | |
| 1196 | + add("TLS_RSA_PSK_WITH_AES_256_GCM_SHA384", 0x00ad); | |
| 1197 | + add("TLS_PSK_WITH_AES_128_CBC_SHA256", 0x00ae); | |
| 1198 | + add("TLS_PSK_WITH_AES_256_CBC_SHA384", 0x00af); | |
| 1199 | + add("TLS_PSK_WITH_NULL_SHA256", 0x00b0); | |
| 1200 | + add("TLS_PSK_WITH_NULL_SHA384", 0x00b1); | |
| 1201 | + add("TLS_DHE_PSK_WITH_AES_128_CBC_SHA256", 0x00b2); | |
| 1202 | + add("TLS_DHE_PSK_WITH_AES_256_CBC_SHA384", 0x00b3); | |
| 1203 | + add("TLS_DHE_PSK_WITH_NULL_SHA256", 0x00b4); | |
| 1204 | + add("TLS_DHE_PSK_WITH_NULL_SHA384", 0x00b5); | |
| 1205 | + add("TLS_RSA_PSK_WITH_AES_128_CBC_SHA256", 0x00b6); | |
| 1206 | + add("TLS_RSA_PSK_WITH_AES_256_CBC_SHA384", 0x00b7); | |
| 1207 | + add("TLS_RSA_PSK_WITH_NULL_SHA256", 0x00b8); | |
| 1208 | + add("TLS_RSA_PSK_WITH_NULL_SHA384", 0x00b9); | |
| 1209 | + | |
| 1210 | + // Unsupported cipher suites from RFC 5932 | |
| 1211 | + add("TLS_RSA_WITH_CAMELLIA_128_CBC_SHA", 0x0041); | |
| 1212 | + add("TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA", 0x0042); | |
| 1213 | + add("TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA", 0x0043); | |
| 1214 | + add("TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA", 0x0044); | |
| 1215 | + add("TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA", 0x0045); | |
| 1216 | + add("TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA", 0x0046); | |
| 1217 | + add("TLS_RSA_WITH_CAMELLIA_256_CBC_SHA", 0x0084); | |
| 1218 | + add("TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA", 0x0085); | |
| 1219 | + add("TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA", 0x0086); | |
| 1220 | + add("TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA", 0x0087); | |
| 1221 | + add("TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA", 0x0088); | |
| 1222 | + add("TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA", 0x0089); | |
| 1223 | + add("TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256", 0x00ba); | |
| 1224 | + add("TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256", 0x00bb); | |
| 1225 | + add("TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256", 0x00bc); | |
| 1226 | + add("TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256", 0x00bd); | |
| 1227 | + add("TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256", 0x00be); | |
| 1228 | + add("TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256", 0x00bf); | |
| 1229 | + add("TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256", 0x00c0); | |
| 1230 | + add("TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256", 0x00c1); | |
| 1231 | + add("TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256", 0x00c2); | |
| 1232 | + add("TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256", 0x00c3); | |
| 1233 | + add("TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256", 0x00c4); | |
| 1234 | + add("TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256", 0x00c5); | |
| 1235 | + | |
| 1236 | + // Unsupported cipher suites from RFC 5054 | |
| 1237 | + add("TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA", 0xc01a); | |
| 1238 | + add("TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA", 0xc01b); | |
| 1239 | + add("TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA", 0xc01c); | |
| 1240 | + add("TLS_SRP_SHA_WITH_AES_128_CBC_SHA", 0xc01d); | |
| 1241 | + add("TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA", 0xc01e); | |
| 1242 | + add("TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA", 0xc01f); | |
| 1243 | + add("TLS_SRP_SHA_WITH_AES_256_CBC_SHA", 0xc020); | |
| 1244 | + add("TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA", 0xc021); | |
| 1245 | + add("TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA", 0xc022); | |
| 1246 | + | |
| 1247 | + // Unsupported cipher suites from RFC 5289 | |
| 1248 | + add("TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", 0xc02b); | |
| 1249 | + add("TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", 0xc02c); | |
| 1250 | + add("TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256", 0xc02d); | |
| 1251 | + add("TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384", 0xc02e); | |
| 1252 | + add("TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", 0xc02f); | |
| 1253 | + add("TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", 0xc030); | |
| 1254 | + add("TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256", 0xc031); | |
| 1255 | + add("TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384", 0xc032); | |
| 1256 | + | |
| 1257 | + // Unsupported cipher suites from RFC 5489 | |
| 1258 | + add("TLS_ECDHE_PSK_WITH_RC4_128_SHA", 0xc033); | |
| 1259 | + add("TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA", 0xc034); | |
| 1260 | + add("TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA", 0xc035); | |
| 1261 | + add("TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA", 0xc036); | |
| 1262 | + add("TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256", 0xc037); | |
| 1263 | + add("TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384", 0xc038); | |
| 1264 | + add("TLS_ECDHE_PSK_WITH_NULL_SHA", 0xc039); | |
| 1265 | + add("TLS_ECDHE_PSK_WITH_NULL_SHA256", 0xc03a); | |
| 1266 | + add("TLS_ECDHE_PSK_WITH_NULL_SHA384", 0xc03b); | |
| 1267 | + } | |
| 1268 | + | |
| 1269 | + // ciphersuite SSL_NULL_WITH_NULL_NULL | |
| 1270 | + final static CipherSuite C_NULL = CipherSuite.valueOf(0, 0); | |
| 1271 | + | |
| 1272 | + // ciphersuite TLS_EMPTY_RENEGOTIATION_INFO_SCSV | |
| 1273 | + final static CipherSuite C_SCSV = CipherSuite.valueOf(0x00, 0xff); | |
| 1274 | +} | |