|
@@ -270,16 +270,16 @@ static void tls_generate_master_secret ( struct tls_session *tls ) {
|
270
|
270
|
DBGC_HD ( tls, &tls->pre_master_secret,
|
271
|
271
|
sizeof ( tls->pre_master_secret ) );
|
272
|
272
|
DBGC ( tls, "TLS %p client random bytes:\n", tls );
|
273
|
|
- DBGC_HD ( tls, &tls->client_random, sizeof ( tls->server_random ) );
|
|
273
|
+ DBGC_HD ( tls, &tls->client_random, sizeof ( tls->client_random ) );
|
274
|
274
|
DBGC ( tls, "TLS %p server random bytes:\n", tls );
|
275
|
275
|
DBGC_HD ( tls, &tls->server_random, sizeof ( tls->server_random ) );
|
276
|
276
|
|
277
|
|
- tls_prf_label ( tls, tls->pre_master_secret,
|
|
277
|
+ tls_prf_label ( tls, &tls->pre_master_secret,
|
278
|
278
|
sizeof ( tls->pre_master_secret ),
|
279
|
|
- tls->master_secret, sizeof ( tls->master_secret ),
|
|
279
|
+ &tls->master_secret, sizeof ( tls->master_secret ),
|
280
|
280
|
"master secret",
|
281
|
|
- tls->client_random, sizeof ( tls->client_random ),
|
282
|
|
- tls->server_random, sizeof ( tls->server_random ) );
|
|
281
|
+ &tls->client_random, sizeof ( tls->client_random ),
|
|
282
|
+ &tls->server_random, sizeof ( tls->server_random ) );
|
283
|
283
|
|
284
|
284
|
DBGC ( tls, "TLS %p generated master secret:\n", tls );
|
285
|
285
|
DBGC_HD ( tls, &tls->master_secret, sizeof ( tls->master_secret ) );
|
|
@@ -304,10 +304,10 @@ static int tls_generate_keys ( struct tls_session *tls ) {
|
304
|
304
|
int rc;
|
305
|
305
|
|
306
|
306
|
|
307
|
|
- tls_prf_label ( tls, tls->master_secret, sizeof ( tls->master_secret ),
|
|
307
|
+ tls_prf_label ( tls, &tls->master_secret, sizeof ( tls->master_secret ),
|
308
|
308
|
key_block, sizeof ( key_block ), "key expansion",
|
309
|
|
- tls->server_random, sizeof ( tls->server_random ),
|
310
|
|
- tls->client_random, sizeof ( tls->client_random ) );
|
|
309
|
+ &tls->server_random, sizeof ( tls->server_random ),
|
|
310
|
+ &tls->client_random, sizeof ( tls->client_random ) );
|
311
|
311
|
|
312
|
312
|
|
313
|
313
|
key = key_block;
|
|
@@ -604,7 +604,7 @@ static int tls_send_client_hello ( struct tls_session *tls ) {
|
604
|
604
|
htonl ( sizeof ( hello ) -
|
605
|
605
|
sizeof ( hello.type_length ) ) );
|
606
|
606
|
hello.version = htons ( TLS_VERSION_TLS_1_0 );
|
607
|
|
- memcpy ( &hello.random, tls->client_random, sizeof ( hello.random ) );
|
|
607
|
+ memcpy ( &hello.random, &tls->client_random, sizeof ( hello.random ) );
|
608
|
608
|
hello.cipher_suite_len = htons ( sizeof ( hello.cipher_suites ) );
|
609
|
609
|
hello.cipher_suites[0] = htons ( TLS_RSA_WITH_AES_128_CBC_SHA );
|
610
|
610
|
hello.cipher_suites[1] = htons ( TLS_RSA_WITH_AES_256_CBC_SHA );
|
|
@@ -643,7 +643,7 @@ static int tls_send_client_key_exchange ( struct tls_session *tls ) {
|
643
|
643
|
sizeof ( tls->pre_master_secret ) );
|
644
|
644
|
DBGC_HD ( tls, tls->rsa_mod, tls->rsa_mod_len );
|
645
|
645
|
DBGC_HD ( tls, tls->rsa_pub_exp, tls->rsa_pub_exp_len );
|
646
|
|
- RSA_encrypt ( rsa_ctx, tls->pre_master_secret,
|
|
646
|
+ RSA_encrypt ( rsa_ctx, ( const uint8_t * ) &tls->pre_master_secret,
|
647
|
647
|
sizeof ( tls->pre_master_secret ),
|
648
|
648
|
key_xchg.encrypted_pre_master_secret, 0 );
|
649
|
649
|
DBGC ( tls, "RSA encrypt done. Ciphertext:\n" );
|
|
@@ -685,7 +685,7 @@ static int tls_send_finished ( struct tls_session *tls ) {
|
685
|
685
|
htonl ( sizeof ( finished ) -
|
686
|
686
|
sizeof ( finished.type_length ) ) );
|
687
|
687
|
tls_verify_handshake ( tls, digest );
|
688
|
|
- tls_prf_label ( tls, tls->master_secret, sizeof ( tls->master_secret ),
|
|
688
|
+ tls_prf_label ( tls, &tls->master_secret, sizeof ( tls->master_secret ),
|
689
|
689
|
finished.verify_data, sizeof ( finished.verify_data ),
|
690
|
690
|
"client finished", digest, sizeof ( digest ) );
|
691
|
691
|
|
|
@@ -802,7 +802,7 @@ static int tls_new_server_hello ( struct tls_session *tls,
|
802
|
802
|
}
|
803
|
803
|
|
804
|
804
|
|
805
|
|
- memcpy ( tls->server_random, hello_a->random,
|
|
805
|
+ memcpy ( &tls->server_random, &hello_a->random,
|
806
|
806
|
sizeof ( tls->server_random ) );
|
807
|
807
|
|
808
|
808
|
|
|
@@ -1710,13 +1710,12 @@ int add_tls ( struct xfer_interface *xfer, struct xfer_interface **next ) {
|
1710
|
1710
|
tls_clear_cipher ( tls, &tls->tx_cipherspec_pending );
|
1711
|
1711
|
tls_clear_cipher ( tls, &tls->rx_cipherspec );
|
1712
|
1712
|
tls_clear_cipher ( tls, &tls->rx_cipherspec_pending );
|
1713
|
|
- *( ( uint32_t * ) tls->client_random ) = 0;
|
1714
|
|
- tls_generate_random ( ( tls->client_random + 4 ),
|
1715
|
|
- ( sizeof ( tls->client_random ) - 4 ) );
|
1716
|
|
- *( ( uint16_t * ) tls->pre_master_secret )
|
1717
|
|
- = htons ( TLS_VERSION_TLS_1_0 );
|
1718
|
|
- tls_generate_random ( ( tls->pre_master_secret + 2 ),
|
1719
|
|
- ( sizeof ( tls->pre_master_secret ) - 2 ) );
|
|
1713
|
+ tls->client_random.gmt_unix_time = 0;
|
|
1714
|
+ tls_generate_random ( &tls->client_random.random,
|
|
1715
|
+ ( sizeof ( tls->client_random.random ) ) );
|
|
1716
|
+ tls->pre_master_secret.version = htons ( TLS_VERSION_TLS_1_0 );
|
|
1717
|
+ tls_generate_random ( &tls->pre_master_secret.random,
|
|
1718
|
+ ( sizeof ( tls->pre_master_secret.random ) ) );
|
1720
|
1719
|
digest_init ( &md5_algorithm, tls->handshake_md5_ctx );
|
1721
|
1720
|
digest_init ( &sha1_algorithm, tls->handshake_sha1_ctx );
|
1722
|
1721
|
tls->tx_state = TLS_TX_CLIENT_HELLO;
|