|
@@ -691,6 +691,19 @@ static int tls_send_client_hello ( struct tls_session *tls ) {
|
691
|
691
|
uint16_t cipher_suites[2];
|
692
|
692
|
uint8_t compression_methods_len;
|
693
|
693
|
uint8_t compression_methods[1];
|
|
694
|
+ uint16_t extensions_len;
|
|
695
|
+ struct {
|
|
696
|
+ uint16_t server_name_type;
|
|
697
|
+ uint16_t server_name_len;
|
|
698
|
+ struct {
|
|
699
|
+ uint16_t len;
|
|
700
|
+ struct {
|
|
701
|
+ uint8_t type;
|
|
702
|
+ uint16_t len;
|
|
703
|
+ uint8_t name[ strlen ( tls->name ) ];
|
|
704
|
+ } __attribute__ (( packed )) list[1];
|
|
705
|
+ } __attribute__ (( packed )) server_name;
|
|
706
|
+ } __attribute__ (( packed )) extensions;
|
694
|
707
|
} __attribute__ (( packed )) hello;
|
695
|
708
|
|
696
|
709
|
memset ( &hello, 0, sizeof ( hello ) );
|
|
@@ -703,6 +716,17 @@ static int tls_send_client_hello ( struct tls_session *tls ) {
|
703
|
716
|
hello.cipher_suites[0] = htons ( TLS_RSA_WITH_AES_128_CBC_SHA );
|
704
|
717
|
hello.cipher_suites[1] = htons ( TLS_RSA_WITH_AES_256_CBC_SHA );
|
705
|
718
|
hello.compression_methods_len = sizeof ( hello.compression_methods );
|
|
719
|
+ hello.extensions_len = htons ( sizeof ( hello.extensions ) );
|
|
720
|
+ hello.extensions.server_name_type = htons ( TLS_SERVER_NAME );
|
|
721
|
+ hello.extensions.server_name_len
|
|
722
|
+ = htons ( sizeof ( hello.extensions.server_name ) );
|
|
723
|
+ hello.extensions.server_name.len
|
|
724
|
+ = htons ( sizeof ( hello.extensions.server_name.list ) );
|
|
725
|
+ hello.extensions.server_name.list[0].type = TLS_SERVER_NAME_HOST_NAME;
|
|
726
|
+ hello.extensions.server_name.list[0].len
|
|
727
|
+ = htons ( sizeof ( hello.extensions.server_name.list[0].name ));
|
|
728
|
+ memcpy ( hello.extensions.server_name.list[0].name, tls->name,
|
|
729
|
+ sizeof ( hello.extensions.server_name.list[0].name ) );
|
706
|
730
|
|
707
|
731
|
return tls_send_handshake ( tls, &hello, sizeof ( hello ) );
|
708
|
732
|
}
|
|
@@ -881,8 +905,8 @@ static int tls_new_server_hello ( struct tls_session *tls,
|
881
|
905
|
int rc;
|
882
|
906
|
|
883
|
907
|
/* Sanity check */
|
884
|
|
- if ( end != ( data + len ) ) {
|
885
|
|
- DBGC ( tls, "TLS %p received overlength Server Hello\n", tls );
|
|
908
|
+ if ( end > ( data + len ) ) {
|
|
909
|
+ DBGC ( tls, "TLS %p received underlength Server Hello\n", tls );
|
886
|
910
|
DBGC_HD ( tls, data, len );
|
887
|
911
|
return -EINVAL;
|
888
|
912
|
}
|
|
@@ -1805,7 +1829,8 @@ static struct process_descriptor tls_process_desc =
|
1805
|
1829
|
******************************************************************************
|
1806
|
1830
|
*/
|
1807
|
1831
|
|
1808
|
|
-int add_tls ( struct interface *xfer, struct interface **next ) {
|
|
1832
|
+int add_tls ( struct interface *xfer, const char *name,
|
|
1833
|
+ struct interface **next ) {
|
1809
|
1834
|
struct tls_session *tls;
|
1810
|
1835
|
int rc;
|
1811
|
1836
|
|
|
@@ -1817,6 +1842,7 @@ int add_tls ( struct interface *xfer, struct interface **next ) {
|
1817
|
1842
|
}
|
1818
|
1843
|
memset ( tls, 0, sizeof ( *tls ) );
|
1819
|
1844
|
ref_init ( &tls->refcnt, free_tls );
|
|
1845
|
+ tls->name = name;
|
1820
|
1846
|
intf_init ( &tls->plainstream, &tls_plainstream_desc, &tls->refcnt );
|
1821
|
1847
|
intf_init ( &tls->cipherstream, &tls_cipherstream_desc, &tls->refcnt );
|
1822
|
1848
|
tls->version = TLS_VERSION_TLS_1_1;
|