Skip to content

Commit 5750435

Browse files
committed
[tls] Refuse to resume sessions with mismatched master secret methods
RFC 7627 section 5.3 states that the client must abort the handshake if the server attempts to resume a session where the master secret calculation method stored in the session does not match the method used for the connection being resumed. Signed-off-by: Michael Brown <[email protected]>
1 parent ab64bc5 commit 5750435

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/include/ipxe/tls.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ struct tls_session {
353353
size_t ticket_len;
354354
/** Master secret */
355355
uint8_t master_secret[48];
356+
/** Extended master secret flag */
357+
int extended_master_secret;
356358

357359
/** List of connections */
358360
struct list_head conn;

src/net/tls.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ FILE_LICENCE ( GPL2_OR_LATER );
183183
#define EINFO_EPERM_KEY_EXCHANGE \
184184
__einfo_uniqify ( EINFO_EPERM, 0x06, \
185185
"ServerKeyExchange verification failed" )
186+
#define EPERM_EMS __einfo_error ( EINFO_EPERM_EMS )
187+
#define EINFO_EPERM_EMS \
188+
__einfo_uniqify ( EINFO_EPERM, 0x07, \
189+
"Extended master secret extension mismatch" )
186190
#define EPROTO_VERSION __einfo_error ( EINFO_EPROTO_VERSION )
187191
#define EINFO_EPROTO_VERSION \
188192
__einfo_uniqify ( EINFO_EPROTO, 0x01, \
@@ -2243,6 +2247,14 @@ static int tls_new_server_hello ( struct tls_connection *tls,
22432247
if ( ( rc = tls_generate_keys ( tls ) ) != 0 )
22442248
return rc;
22452249

2250+
/* Ensure master secret generation method matches */
2251+
if ( tls->extended_master_secret !=
2252+
tls->session->extended_master_secret ) {
2253+
DBGC ( tls, "TLS %p mismatched extended master secret "
2254+
"extension\n", tls );
2255+
return -EPERM_EMS;
2256+
}
2257+
22462258
} else {
22472259

22482260
/* Record new session ID, if present */
@@ -2635,6 +2647,7 @@ static int tls_new_finished ( struct tls_connection *tls,
26352647
if ( tls->session_id_len || tls->new_session_ticket_len ) {
26362648
memcpy ( session->master_secret, tls->master_secret,
26372649
sizeof ( session->master_secret ) );
2650+
session->extended_master_secret = tls->extended_master_secret;
26382651
}
26392652
if ( tls->session_id_len ) {
26402653
session->id_len = tls->session_id_len;

0 commit comments

Comments
 (0)