| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/ssl/ssl_cipher_suite_names.h" | 5 #include "net/ssl/ssl_cipher_suite_names.h" |
| 6 | 6 |
| 7 #if defined(USE_OPENSSL) | 7 #include <stdlib.h> |
| 8 |
| 8 #include <openssl/ssl.h> | 9 #include <openssl/ssl.h> |
| 9 #endif | |
| 10 #include <stdlib.h> | |
| 11 | 10 |
| 12 #include "base/logging.h" | 11 #include "base/logging.h" |
| 13 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 15 #include "net/ssl/ssl_connection_status_flags.h" | 14 #include "net/ssl/ssl_connection_status_flags.h" |
| 16 | 15 |
| 17 // Rather than storing the names of all the ciphersuites we eliminate the | 16 // Rather than storing the names of all the ciphersuites we eliminate the |
| 18 // redundancy and break each cipher suite into a key exchange method, cipher | 17 // redundancy and break each cipher suite into a key exchange method, cipher |
| 19 // and mac. For all the ciphersuites in the IANA registry, we extract each of | 18 // and mac. For all the ciphersuites in the IANA registry, we extract each of |
| 20 // those components from the name, number them and pack the result into a | 19 // those components from the name, number them and pack the result into a |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 } | 416 } |
| 418 | 417 |
| 419 // Only AEADs allowed. | 418 // Only AEADs allowed. |
| 420 if (mac != kAEADMACValue) | 419 if (mac != kAEADMACValue) |
| 421 return false; | 420 return false; |
| 422 | 421 |
| 423 return true; | 422 return true; |
| 424 } | 423 } |
| 425 | 424 |
| 426 const char* ECCurveName(uint16_t cipher_suite, int key_exchange_info) { | 425 const char* ECCurveName(uint16_t cipher_suite, int key_exchange_info) { |
| 427 #if defined(USE_OPENSSL) | |
| 428 int key_exchange, cipher, mac; | 426 int key_exchange, cipher, mac; |
| 429 if (!GetCipherProperties(cipher_suite, &key_exchange, &cipher, &mac)) | 427 if (!GetCipherProperties(cipher_suite, &key_exchange, &cipher, &mac)) |
| 430 return nullptr; | 428 return nullptr; |
| 431 switch (key_exchange) { | 429 switch (key_exchange) { |
| 432 case 14: // ECDHE_ECDSA | 430 case 14: // ECDHE_ECDSA |
| 433 case 16: // ECDHE_RSA | 431 case 16: // ECDHE_RSA |
| 434 break; | 432 break; |
| 435 default: | 433 default: |
| 436 return nullptr; | 434 return nullptr; |
| 437 } | 435 } |
| 438 return SSL_get_curve_name(key_exchange_info); | 436 return SSL_get_curve_name(key_exchange_info); |
| 439 #else | |
| 440 return nullptr; | |
| 441 #endif | |
| 442 } | 437 } |
| 443 | 438 |
| 444 } // namespace net | 439 } // namespace net |
| OLD | NEW |