Browse Source

[tls] Support (and prefer) SHA-256 variants of existing cipher suites

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 years ago
parent
commit
6069b09bfc
2 changed files with 17 additions and 3 deletions
  1. 2
    0
      src/include/ipxe/tls.h
  2. 15
    3
      src/net/tls.c

+ 2
- 0
src/include/ipxe/tls.h View File

@@ -77,6 +77,8 @@ struct tls_header {
77 77
 #define TLS_RSA_WITH_NULL_SHA 0x0002
78 78
 #define TLS_RSA_WITH_AES_128_CBC_SHA 0x002f
79 79
 #define TLS_RSA_WITH_AES_256_CBC_SHA 0x0035
80
+#define TLS_RSA_WITH_AES_128_CBC_SHA256 0x003c
81
+#define TLS_RSA_WITH_AES_256_CBC_SHA256 0x003d
80 82
 
81 83
 /* TLS extension types */
82 84
 #define TLS_SERVER_NAME 0

+ 15
- 3
src/net/tls.c View File

@@ -513,6 +513,16 @@ static int tls_select_cipher ( struct tls_session *tls,
513 513
 		cipher = &aes_cbc_algorithm;
514 514
 		digest = &sha1_algorithm;
515 515
 		break;
516
+	case htons ( TLS_RSA_WITH_AES_128_CBC_SHA256 ):
517
+		key_len = ( 128 / 8 );
518
+		cipher = &aes_cbc_algorithm;
519
+		digest = &sha256_algorithm;
520
+		break;
521
+	case htons ( TLS_RSA_WITH_AES_256_CBC_SHA256 ):
522
+		key_len = ( 256 / 8 );
523
+		cipher = &aes_cbc_algorithm;
524
+		digest = &sha256_algorithm;
525
+		break;
516 526
 	default:
517 527
 		DBGC ( tls, "TLS %p does not support cipher %04x\n",
518 528
 		       tls, ntohs ( cipher_suite ) );
@@ -677,7 +687,7 @@ static int tls_send_client_hello ( struct tls_session *tls ) {
677 687
 		uint8_t random[32];
678 688
 		uint8_t session_id_len;
679 689
 		uint16_t cipher_suite_len;
680
-		uint16_t cipher_suites[2];
690
+		uint16_t cipher_suites[4];
681 691
 		uint8_t compression_methods_len;
682 692
 		uint8_t compression_methods[1];
683 693
 		uint16_t extensions_len;
@@ -702,8 +712,10 @@ static int tls_send_client_hello ( struct tls_session *tls ) {
702 712
 	hello.version = htons ( tls->version );
703 713
 	memcpy ( &hello.random, &tls->client_random, sizeof ( hello.random ) );
704 714
 	hello.cipher_suite_len = htons ( sizeof ( hello.cipher_suites ) );
705
-	hello.cipher_suites[0] = htons ( TLS_RSA_WITH_AES_128_CBC_SHA );
706
-	hello.cipher_suites[1] = htons ( TLS_RSA_WITH_AES_256_CBC_SHA );
715
+	hello.cipher_suites[0] = htons ( TLS_RSA_WITH_AES_256_CBC_SHA256 );
716
+	hello.cipher_suites[1] = htons ( TLS_RSA_WITH_AES_128_CBC_SHA256 );
717
+	hello.cipher_suites[2] = htons ( TLS_RSA_WITH_AES_256_CBC_SHA );
718
+	hello.cipher_suites[3] = htons ( TLS_RSA_WITH_AES_128_CBC_SHA );
707 719
 	hello.compression_methods_len = sizeof ( hello.compression_methods );
708 720
 	hello.extensions_len = htons ( sizeof ( hello.extensions ) );
709 721
 	hello.extensions.server_name_type = htons ( TLS_SERVER_NAME );

Loading…
Cancel
Save