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 #if defined(USE_OPENSSL) |
8 #include <openssl/ssl.h> | 8 #include <openssl/ssl.h> |
9 #endif | 9 #endif |
10 #include <stdlib.h> | 10 #include <stdlib.h> |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
355 if (cipher_string.size() == 6 && | 355 if (cipher_string.size() == 6 && |
356 base::StartsWith(cipher_string, "0x", | 356 base::StartsWith(cipher_string, "0x", |
357 base::CompareCase::INSENSITIVE_ASCII) && | 357 base::CompareCase::INSENSITIVE_ASCII) && |
358 base::HexStringToInt(cipher_string, &value)) { | 358 base::HexStringToInt(cipher_string, &value)) { |
359 *cipher_suite = static_cast<uint16_t>(value); | 359 *cipher_suite = static_cast<uint16_t>(value); |
360 return true; | 360 return true; |
361 } | 361 } |
362 return false; | 362 return false; |
363 } | 363 } |
364 | 364 |
365 bool IsSecureTLSCipherSuite(uint16_t cipher_suite) { | 365 int ObsoleteSSLStatus(int connection_status) { |
lgarron
2016/04/09 03:22:50
I think that this is the right level of abstractio
lgarron
2016/04/12 02:25:08
ping
davidben
2016/04/19 17:47:01
I'm a little sad about this connection_status thin
| |
366 int key_exchange, cipher, mac; | 366 int key_exchange, cipher, mac; |
367 if (!GetCipherProperties(cipher_suite, &key_exchange, &cipher, &mac)) | 367 int obsolete_ssl = OBSOLETE_SSL_NONE; |
368 return false; | 368 |
369 int ssl_version = SSLConnectionStatusToVersion(connection_status); | |
370 if (ssl_version < SSL_CONNECTION_VERSION_TLS1_2) { | |
371 obsolete_ssl |= OBSOLETE_SSL_MASK_PROTOCOL; | |
372 } | |
373 | |
374 uint16_t cipher_suite = SSLConnectionStatusToCipherSuite(connection_status); | |
375 if (!GetCipherProperties(cipher_suite, &key_exchange, &cipher, &mac)) { | |
376 // Cannot determine/unknown cipher suite. Err on the side of caution. | |
377 obsolete_ssl |= OBSOLETE_SSL_MASK_KEY_EXCHANGE; | |
378 obsolete_ssl |= OBSOLETE_SSL_MASK_CIPHER_SUITE; | |
379 return obsolete_ssl; | |
380 } | |
369 | 381 |
370 // Only allow ECDHE key exchanges. | 382 // Only allow ECDHE key exchanges. |
371 switch (key_exchange) { | 383 switch (key_exchange) { |
372 case 14: // ECDHE_ECDSA | 384 case 14: // ECDHE_ECDSA |
373 case 16: // ECDHE_RSA | 385 case 16: // ECDHE_RSA |
374 break; | 386 break; |
375 default: | 387 default: |
376 return false; | 388 obsolete_ssl |= OBSOLETE_SSL_MASK_KEY_EXCHANGE; |
377 } | 389 } |
378 | 390 |
379 switch (cipher) { | 391 switch (cipher) { |
380 case 13: // AES_128_GCM | 392 case 13: // AES_128_GCM |
381 case 14: // AES_256_GCM | 393 case 14: // AES_256_GCM |
382 case 17: // CHACHA20_POLY1305 | 394 case 17: // CHACHA20_POLY1305 |
383 break; | 395 break; |
384 default: | 396 default: |
385 return false; | 397 obsolete_ssl |= OBSOLETE_SSL_MASK_CIPHER_SUITE; |
386 } | 398 } |
387 | 399 |
388 // Only AEADs allowed. | 400 // Only AEADs allowed. |
389 if (mac != kAEADMACValue) | 401 if (mac != kAEADMACValue) |
390 return false; | 402 obsolete_ssl |= OBSOLETE_SSL_MASK_CIPHER_SUITE; |
391 | 403 |
392 return true; | 404 return obsolete_ssl; |
393 } | 405 } |
394 | 406 |
395 bool IsTLSCipherSuiteAllowedByHTTP2(uint16_t cipher_suite) { | 407 bool IsTLSCipherSuiteAllowedByHTTP2(uint16_t cipher_suite) { |
396 int key_exchange, cipher, mac; | 408 int key_exchange, cipher, mac; |
397 if (!GetCipherProperties(cipher_suite, &key_exchange, &cipher, &mac)) | 409 if (!GetCipherProperties(cipher_suite, &key_exchange, &cipher, &mac)) |
398 return false; | 410 return false; |
399 | 411 |
400 // Only allow forward secure key exchanges. | 412 // Only allow forward secure key exchanges. |
401 switch (key_exchange) { | 413 switch (key_exchange) { |
402 case 10: // DHE_RSA | 414 case 10: // DHE_RSA |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
435 default: | 447 default: |
436 return nullptr; | 448 return nullptr; |
437 } | 449 } |
438 return SSL_get_curve_name(key_exchange_info); | 450 return SSL_get_curve_name(key_exchange_info); |
439 #else | 451 #else |
440 return nullptr; | 452 return nullptr; |
441 #endif | 453 #endif |
442 } | 454 } |
443 | 455 |
444 } // namespace net | 456 } // namespace net |
OLD | NEW |