1c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Copyright (c) 2010 The Chromium Authors. All rights reserved. 2c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Use of this source code is governed by a BSD-style license that can be 3c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// found in the LICENSE file. 4c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 5c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "net/base/ssl_cipher_suite_names.h" 6c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 7c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include <stdlib.h> 8c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 9513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch#include "base/logging.h" 10513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch#include "net/base/ssl_connection_status_flags.h" 11c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 12c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Rather than storing the names of all the ciphersuites we eliminate the 13c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// redundancy and break each cipher suite into a key exchange method, cipher 14c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// and mac. For all the ciphersuites in the IANA registry, we extract each of 15c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// those components from the name, number them and pack the result into a 16c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// 16-bit number thus: 17c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// (MSB to LSB) 18c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// <4 bits> unused 19c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// <5 bits> key exchange 20c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// <4 bits> cipher 21c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// <3 bits> mac 22c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 23c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// The following tables were generated by ssl_cipher_suite_names_generate.go, 24c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// found in the same directory as this file. 25c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 26c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochstruct CipherSuite { 27c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch uint16 cipher_suite, encoded; 28c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}; 29c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 30c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochstatic const struct CipherSuite kCipherSuites[] = { 31c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x0, 0x0}, // TLS_NULL_WITH_NULL_NULL 32c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x1, 0x81}, // TLS_RSA_WITH_NULL_MD5 33c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x2, 0x82}, // TLS_RSA_WITH_NULL_SHA 34c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x3, 0x109}, // TLS_RSA_EXPORT_WITH_RC4_40_MD5 35c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x4, 0x91}, // TLS_RSA_WITH_RC4_128_MD5 36c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x5, 0x92}, // TLS_RSA_WITH_RC4_128_SHA 37c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x6, 0x119}, // TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 38c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x7, 0xa2}, // TLS_RSA_WITH_IDEA_CBC_SHA 39c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x8, 0x12a}, // TLS_RSA_EXPORT_WITH_DES40_CBC_SHA 40c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x9, 0xb2}, // TLS_RSA_WITH_DES_CBC_SHA 41c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xa, 0xba}, // TLS_RSA_WITH_3DES_EDE_CBC_SHA 42c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xb, 0x1aa}, // TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA 43c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc, 0x232}, // TLS_DH_DSS_WITH_DES_CBC_SHA 44c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xd, 0x23a}, // TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA 45c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xe, 0x2aa}, // TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA 46c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xf, 0x332}, // TLS_DH_RSA_WITH_DES_CBC_SHA 47c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x10, 0x33a}, // TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA 48c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x11, 0x3aa}, // TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA 49c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x12, 0x432}, // TLS_DHE_DSS_WITH_DES_CBC_SHA 50c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x13, 0x43a}, // TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA 51c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x14, 0x4aa}, // TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA 52c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x15, 0x532}, // TLS_DHE_RSA_WITH_DES_CBC_SHA 53c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x16, 0x53a}, // TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA 54c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x17, 0x589}, // TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 55c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x18, 0x611}, // TLS_DH_anon_WITH_RC4_128_MD5 56c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x19, 0x5aa}, // TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA 57c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x1a, 0x632}, // TLS_DH_anon_WITH_DES_CBC_SHA 58c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x1b, 0x63a}, // TLS_DH_anon_WITH_3DES_EDE_CBC_SHA 59c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x1e, 0x6b2}, // TLS_KRB5_WITH_DES_CBC_SHA 60c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x1f, 0x6ba}, // TLS_KRB5_WITH_3DES_EDE_CBC_SHA 61c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x20, 0x692}, // TLS_KRB5_WITH_RC4_128_SHA 62c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x21, 0x6a2}, // TLS_KRB5_WITH_IDEA_CBC_SHA 63c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x22, 0x6b1}, // TLS_KRB5_WITH_DES_CBC_MD5 64c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x23, 0x6b9}, // TLS_KRB5_WITH_3DES_EDE_CBC_MD5 65c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x24, 0x691}, // TLS_KRB5_WITH_RC4_128_MD5 66c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x25, 0x6a1}, // TLS_KRB5_WITH_IDEA_CBC_MD5 67c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x26, 0x742}, // TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA 68c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x27, 0x71a}, // TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA 69c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x28, 0x70a}, // TLS_KRB5_EXPORT_WITH_RC4_40_SHA 70c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x29, 0x741}, // TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5 71c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x2a, 0x719}, // TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5 72c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x2b, 0x709}, // TLS_KRB5_EXPORT_WITH_RC4_40_MD5 73c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x2c, 0x782}, // TLS_PSK_WITH_NULL_SHA 74c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x2d, 0x802}, // TLS_DHE_PSK_WITH_NULL_SHA 75c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x2e, 0x882}, // TLS_RSA_PSK_WITH_NULL_SHA 76c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x2f, 0xca}, // TLS_RSA_WITH_AES_128_CBC_SHA 77c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x30, 0x24a}, // TLS_DH_DSS_WITH_AES_128_CBC_SHA 78c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x31, 0x34a}, // TLS_DH_RSA_WITH_AES_128_CBC_SHA 79c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x32, 0x44a}, // TLS_DHE_DSS_WITH_AES_128_CBC_SHA 80c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x33, 0x54a}, // TLS_DHE_RSA_WITH_AES_128_CBC_SHA 81c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x34, 0x64a}, // TLS_DH_anon_WITH_AES_128_CBC_SHA 82c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x35, 0xd2}, // TLS_RSA_WITH_AES_256_CBC_SHA 83c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x36, 0x252}, // TLS_DH_DSS_WITH_AES_256_CBC_SHA 84c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x37, 0x352}, // TLS_DH_RSA_WITH_AES_256_CBC_SHA 85c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x38, 0x452}, // TLS_DHE_DSS_WITH_AES_256_CBC_SHA 86c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x39, 0x552}, // TLS_DHE_RSA_WITH_AES_256_CBC_SHA 87c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x3a, 0x652}, // TLS_DH_anon_WITH_AES_256_CBC_SHA 88c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x3b, 0x83}, // TLS_RSA_WITH_NULL_SHA256 89c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x3c, 0xcb}, // TLS_RSA_WITH_AES_128_CBC_SHA256 90c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x3d, 0xd3}, // TLS_RSA_WITH_AES_256_CBC_SHA256 91c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x3e, 0x24b}, // TLS_DH_DSS_WITH_AES_128_CBC_SHA256 92c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x3f, 0x34b}, // TLS_DH_RSA_WITH_AES_128_CBC_SHA256 93c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x40, 0x44b}, // TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 94c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x41, 0xda}, // TLS_RSA_WITH_CAMELLIA_128_CBC_SHA 95c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x42, 0x25a}, // TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA 96c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x43, 0x35a}, // TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA 97c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x44, 0x45a}, // TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA 98c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x45, 0x55a}, // TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA 99c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x46, 0x65a}, // TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA 100c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x67, 0x54b}, // TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 101c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x68, 0x253}, // TLS_DH_DSS_WITH_AES_256_CBC_SHA256 102c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x69, 0x353}, // TLS_DH_RSA_WITH_AES_256_CBC_SHA256 103c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x6a, 0x453}, // TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 104c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x6b, 0x553}, // TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 105c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x6c, 0x64b}, // TLS_DH_anon_WITH_AES_128_CBC_SHA256 106c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x6d, 0x653}, // TLS_DH_anon_WITH_AES_256_CBC_SHA256 107c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x84, 0xe2}, // TLS_RSA_WITH_CAMELLIA_256_CBC_SHA 108c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x85, 0x262}, // TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA 109c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x86, 0x362}, // TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA 110c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x87, 0x462}, // TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA 111c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x88, 0x562}, // TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA 112c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x89, 0x662}, // TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA 113c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x8a, 0x792}, // TLS_PSK_WITH_RC4_128_SHA 114c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x8b, 0x7ba}, // TLS_PSK_WITH_3DES_EDE_CBC_SHA 115c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x8c, 0x7ca}, // TLS_PSK_WITH_AES_128_CBC_SHA 116c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x8d, 0x7d2}, // TLS_PSK_WITH_AES_256_CBC_SHA 117c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x8e, 0x812}, // TLS_DHE_PSK_WITH_RC4_128_SHA 118c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x8f, 0x83a}, // TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA 119c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x90, 0x84a}, // TLS_DHE_PSK_WITH_AES_128_CBC_SHA 120c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x91, 0x852}, // TLS_DHE_PSK_WITH_AES_256_CBC_SHA 121c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x92, 0x892}, // TLS_RSA_PSK_WITH_RC4_128_SHA 122c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x93, 0x8ba}, // TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA 123c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x94, 0x8ca}, // TLS_RSA_PSK_WITH_AES_128_CBC_SHA 124c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x95, 0x8d2}, // TLS_RSA_PSK_WITH_AES_256_CBC_SHA 125c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x96, 0xea}, // TLS_RSA_WITH_SEED_CBC_SHA 126c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x97, 0x26a}, // TLS_DH_DSS_WITH_SEED_CBC_SHA 127c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x98, 0x36a}, // TLS_DH_RSA_WITH_SEED_CBC_SHA 128c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x99, 0x46a}, // TLS_DHE_DSS_WITH_SEED_CBC_SHA 129c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x9a, 0x56a}, // TLS_DHE_RSA_WITH_SEED_CBC_SHA 130c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x9b, 0x66a}, // TLS_DH_anon_WITH_SEED_CBC_SHA 131c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x9c, 0xf3}, // TLS_RSA_WITH_AES_128_GCM_SHA256 132c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x9d, 0xfc}, // TLS_RSA_WITH_AES_256_GCM_SHA384 133c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x9e, 0x573}, // TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 134c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0x9f, 0x57c}, // TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 135c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xa0, 0x373}, // TLS_DH_RSA_WITH_AES_128_GCM_SHA256 136c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xa1, 0x37c}, // TLS_DH_RSA_WITH_AES_256_GCM_SHA384 137c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xa2, 0x473}, // TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 138c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xa3, 0x47c}, // TLS_DHE_DSS_WITH_AES_256_GCM_SHA384 139c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xa4, 0x273}, // TLS_DH_DSS_WITH_AES_128_GCM_SHA256 140c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xa5, 0x27c}, // TLS_DH_DSS_WITH_AES_256_GCM_SHA384 141c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xa6, 0x673}, // TLS_DH_anon_WITH_AES_128_GCM_SHA256 142c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xa7, 0x67c}, // TLS_DH_anon_WITH_AES_256_GCM_SHA384 143c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xa8, 0x7f3}, // TLS_PSK_WITH_AES_128_GCM_SHA256 144c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xa9, 0x7fc}, // TLS_PSK_WITH_AES_256_GCM_SHA384 145c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xaa, 0x873}, // TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 146c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xab, 0x87c}, // TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 147c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xac, 0x8f3}, // TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 148c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xad, 0x8fc}, // TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 149c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xae, 0x7cb}, // TLS_PSK_WITH_AES_128_CBC_SHA256 150c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xaf, 0x7d4}, // TLS_PSK_WITH_AES_256_CBC_SHA384 151c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xb0, 0x783}, // TLS_PSK_WITH_NULL_SHA256 152c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xb1, 0x784}, // TLS_PSK_WITH_NULL_SHA384 153c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xb2, 0x84b}, // TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 154c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xb3, 0x854}, // TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 155c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xb4, 0x803}, // TLS_DHE_PSK_WITH_NULL_SHA256 156c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xb5, 0x804}, // TLS_DHE_PSK_WITH_NULL_SHA384 157c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xb6, 0x8cb}, // TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 158c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xb7, 0x8d4}, // TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 159c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xb8, 0x883}, // TLS_RSA_PSK_WITH_NULL_SHA256 160c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xb9, 0x884}, // TLS_RSA_PSK_WITH_NULL_SHA384 161c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xba, 0xdb}, // TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 162c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xbb, 0x25b}, // TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256 163c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xbc, 0x35b}, // TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256 164c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xbd, 0x45b}, // TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 165c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xbe, 0x55b}, // TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 166c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xbf, 0x65b}, // TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256 167c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc0, 0xe3}, // TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 168c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc1, 0x263}, // TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256 169c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc2, 0x363}, // TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256 170c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc3, 0x463}, // TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 171c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc4, 0x563}, // TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 172c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc5, 0x663}, // TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256 173c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc001, 0x902}, // TLS_ECDH_ECDSA_WITH_NULL_SHA 174c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc002, 0x912}, // TLS_ECDH_ECDSA_WITH_RC4_128_SHA 175c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc003, 0x93a}, // TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA 176c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc004, 0x94a}, // TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA 177c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc005, 0x952}, // TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA 178c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc006, 0x982}, // TLS_ECDHE_ECDSA_WITH_NULL_SHA 179c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc007, 0x992}, // TLS_ECDHE_ECDSA_WITH_RC4_128_SHA 180c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc008, 0x9ba}, // TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA 181c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc009, 0x9ca}, // TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA 182c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc00a, 0x9d2}, // TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA 183c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc00b, 0xa02}, // TLS_ECDH_RSA_WITH_NULL_SHA 184c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc00c, 0xa12}, // TLS_ECDH_RSA_WITH_RC4_128_SHA 185c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc00d, 0xa3a}, // TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA 186c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc00e, 0xa4a}, // TLS_ECDH_RSA_WITH_AES_128_CBC_SHA 187c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc00f, 0xa52}, // TLS_ECDH_RSA_WITH_AES_256_CBC_SHA 188c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc010, 0xa82}, // TLS_ECDHE_RSA_WITH_NULL_SHA 189c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc011, 0xa92}, // TLS_ECDHE_RSA_WITH_RC4_128_SHA 190c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc012, 0xaba}, // TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA 191c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc013, 0xaca}, // TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA 192c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc014, 0xad2}, // TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA 193c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc015, 0xb02}, // TLS_ECDH_anon_WITH_NULL_SHA 194c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc016, 0xb12}, // TLS_ECDH_anon_WITH_RC4_128_SHA 195c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc017, 0xb3a}, // TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA 196c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc018, 0xb4a}, // TLS_ECDH_anon_WITH_AES_128_CBC_SHA 197c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc019, 0xb52}, // TLS_ECDH_anon_WITH_AES_256_CBC_SHA 198c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc01a, 0xbba}, // TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA 199c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc01b, 0xc3a}, // TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA 200c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc01c, 0xcba}, // TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA 201c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc01d, 0xbca}, // TLS_SRP_SHA_WITH_AES_128_CBC_SHA 202c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc01e, 0xc4a}, // TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA 203c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc01f, 0xcca}, // TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA 204c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc020, 0xbd2}, // TLS_SRP_SHA_WITH_AES_256_CBC_SHA 205c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc021, 0xc52}, // TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA 206c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc022, 0xcd2}, // TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA 207c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc023, 0x9cb}, // TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 208c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc024, 0x9d4}, // TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 209c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc025, 0x94b}, // TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 210c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc026, 0x954}, // TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 211c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc027, 0xacb}, // TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 212c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc028, 0xad4}, // TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 213c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc029, 0xa4b}, // TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 214c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc02a, 0xa54}, // TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 215c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc02b, 0x9f3}, // TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 216c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc02c, 0x9fc}, // TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 217c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc02d, 0x973}, // TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 218c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc02e, 0x97c}, // TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 219c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc02f, 0xaf3}, // TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 220c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc030, 0xafc}, // TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 221c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc031, 0xa73}, // TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 222c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc032, 0xa7c}, // TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 223c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc033, 0xd12}, // TLS_ECDHE_PSK_WITH_RC4_128_SHA 224c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc034, 0xd3a}, // TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA 225c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc035, 0xd4a}, // TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA 226c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc036, 0xd52}, // TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA 227c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc037, 0xd4b}, // TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 228c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc038, 0xd54}, // TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 229c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc039, 0xd02}, // TLS_ECDHE_PSK_WITH_NULL_SHA 230c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc03a, 0xd03}, // TLS_ECDHE_PSK_WITH_NULL_SHA256 231c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {0xc03b, 0xd04}, // TLS_ECDHE_PSK_WITH_NULL_SHA384 232c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}; 233c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 234c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochstatic const struct { 235c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch char name[15]; 236c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} kKeyExchangeNames[27] = { 237c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"NULL"}, // 0 238c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"RSA"}, // 1 239c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"RSA_EXPORT"}, // 2 240c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"DH_DSS_EXPORT"}, // 3 241c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"DH_DSS"}, // 4 242c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"DH_RSA_EXPORT"}, // 5 243c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"DH_RSA"}, // 6 244c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"DHE_DSS_EXPORT"}, // 7 245c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"DHE_DSS"}, // 8 246c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"DHE_RSA_EXPORT"}, // 9 247c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"DHE_RSA"}, // 10 248c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"DH_anon_EXPORT"}, // 11 249c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"DH_anon"}, // 12 250c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"KRB5"}, // 13 251c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"KRB5_EXPORT"}, // 14 252c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"PSK"}, // 15 253c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"DHE_PSK"}, // 16 254c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"RSA_PSK"}, // 17 255c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"ECDH_ECDSA"}, // 18 256c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"ECDHE_ECDSA"}, // 19 257c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"ECDH_RSA"}, // 20 258c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"ECDHE_RSA"}, // 21 259c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"ECDH_anon"}, // 22 260c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"SRP_SHA"}, // 23 261c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"SRP_SHA_RSA"}, // 24 262c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"SRP_SHA_DSS"}, // 25 263c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"ECDHE_PSK"}, // 26 264c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}; 265c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 266c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochstatic const struct { 267c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch char name[17]; 268c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} kCipherNames[16] = { 269c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"NULL"}, // 0 270c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"RC4_40"}, // 1 271c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"RC4_128"}, // 2 272c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"RC2_CBC_40"}, // 3 273c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"IDEA_CBC"}, // 4 274c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"DES40_CBC"}, // 5 275c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"DES_CBC"}, // 6 276c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"3DES_EDE_CBC"}, // 7 277c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"DES_CBC_40"}, // 8 278c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"AES_128_CBC"}, // 9 279c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"AES_256_CBC"}, // 10 280c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"CAMELLIA_128_CBC"}, // 11 281c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"CAMELLIA_256_CBC"}, // 12 282c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"SEED_CBC"}, // 13 283c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"AES_128_GCM"}, // 14 284c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"AES_256_GCM"}, // 15 285c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}; 286c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 287c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochstatic const struct { 288c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch char name[7]; 289c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} kMacNames[5] = { 290c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"NULL"}, // 0 291c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"MD5"}, // 1 292c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"SHA1"}, // 2 293c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"SHA256"}, // 3 294c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch {"SHA384"}, // 4 295c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}; 296c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 297c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 298c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochnamespace net { 299c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 300c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochstatic int CipherSuiteCmp(const void* ia, const void* ib) { 301c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch const CipherSuite* a = static_cast<const CipherSuite*>(ia); 302c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch const CipherSuite* b = static_cast<const CipherSuite*>(ib); 303c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 304c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch if (a->cipher_suite < b->cipher_suite) { 305c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch return -1; 306c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } else if (a->cipher_suite == b->cipher_suite) { 307c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch return 0; 308c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } else { 309c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch return 1; 310c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 311c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 312c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 313c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid SSLCipherSuiteToStrings(const char** key_exchange_str, 314c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch const char** cipher_str, 315c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch const char** mac_str, uint16 cipher_suite) { 316c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch *key_exchange_str = *cipher_str = *mac_str = "???"; 317c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 3183345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick struct CipherSuite desired = {0}; 319c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch desired.cipher_suite = cipher_suite; 320c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 321c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch void* r = bsearch(&desired, kCipherSuites, 322c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch arraysize(kCipherSuites), sizeof(kCipherSuites[0]), 323c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch CipherSuiteCmp); 324c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 325c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch if (!r) 326c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch return; 327c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 328c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch const CipherSuite* cs = static_cast<CipherSuite*>(r); 329c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 330c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch const int key_exchange = cs->encoded >> 7; 331c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch const int cipher = (cs->encoded >> 3) & 0xf; 332c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch const int mac = cs->encoded & 0x7; 333c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 334c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch *key_exchange_str = kKeyExchangeNames[key_exchange].name; 335c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch *cipher_str = kCipherNames[cipher].name; 336c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch *mac_str = kMacNames[mac].name; 337c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 338c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 339c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochvoid SSLCompressionToString(const char** name, uint8 compresssion) { 340c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch if (compresssion == 0) { 341c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch *name = "NONE"; 342c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } else if (compresssion == 1) { 343c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch *name = "DEFLATE"; 344c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } else if (compresssion == 64) { 345c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch *name = "LZS"; 346c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } else { 347c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch *name = "???"; 348c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 349c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 350c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 351513209b27ff55e2841eac0e4120199c23acce758Ben Murdochvoid SSLVersionToString(const char** name, int ssl_version) { 352513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch switch (ssl_version) { 353513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch case SSL_CONNECTION_VERSION_SSL2: 354513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch *name = "SSL 2.0"; 355513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch break; 356513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch case SSL_CONNECTION_VERSION_SSL3: 357513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch *name = "SSL 3.0"; 358513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch break; 359513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch case SSL_CONNECTION_VERSION_TLS1: 360513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch *name = "TLS 1.0"; 361513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch break; 362513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch case SSL_CONNECTION_VERSION_TLS1_1: 363513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch *name = "TLS 1.1"; 364513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch break; 365513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch case SSL_CONNECTION_VERSION_TLS1_2: 366513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch *name = "TLS 1.2"; 367513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch break; 368513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch default: 36921d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen NOTREACHED() << ssl_version; 370513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch *name = "???"; 371513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch break; 372513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch } 373513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch} 374513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch 375c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} // namespace net 376