mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-21 21:36:21 +01:00
Implement FALLBACK_SCSV server-side
This commit is contained in:
parent
1cbd39dbeb
commit
01b2699198
3 changed files with 87 additions and 0 deletions
|
|
@ -1052,6 +1052,30 @@ static int ssl_parse_client_hello_v2( ssl_context *ssl )
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(POLARSSL_SSL_FALLBACK_SCSV)
|
||||
for( i = 0, p = buf + 6; i < ciph_len; i += 3, p += 3 )
|
||||
{
|
||||
if( p[0] == 0 &&
|
||||
p[1] == (unsigned char)( ( SSL_FALLBACK_SCSV >> 8 ) & 0xff ) &&
|
||||
p[2] == (unsigned char)( ( SSL_FALLBACK_SCSV ) & 0xff ) )
|
||||
{
|
||||
SSL_DEBUG_MSG( 3, ( "received FALLBACK_SCSV" ) );
|
||||
|
||||
if( ssl->minor_ver < ssl->max_minor_ver )
|
||||
{
|
||||
SSL_DEBUG_MSG( 1, ( "inapropriate fallback" ) );
|
||||
|
||||
ssl_send_alert_message( ssl, SSL_ALERT_LEVEL_FATAL,
|
||||
SSL_ALERT_MSG_INAPROPRIATE_FALLBACK );
|
||||
|
||||
return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* POLARSSL_SSL_FALLBACK_SCSV */
|
||||
|
||||
ciphersuites = ssl->ciphersuite_list[ssl->minor_ver];
|
||||
ciphersuite_info = NULL;
|
||||
#if defined(POLARSSL_SSL_SRV_RESPECT_CLIENT_PREFERENCE)
|
||||
|
|
@ -1365,6 +1389,29 @@ static int ssl_parse_client_hello( ssl_context *ssl )
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(POLARSSL_SSL_FALLBACK_SCSV)
|
||||
for( i = 0, p = buf + 41 + sess_len; i < ciph_len; i += 2, p += 2 )
|
||||
{
|
||||
if( p[0] == (unsigned char)( ( SSL_FALLBACK_SCSV >> 8 ) & 0xff ) &&
|
||||
p[1] == (unsigned char)( ( SSL_FALLBACK_SCSV ) & 0xff ) )
|
||||
{
|
||||
SSL_DEBUG_MSG( 0, ( "received FALLBACK_SCSV" ) );
|
||||
|
||||
if( ssl->minor_ver < ssl->max_minor_ver )
|
||||
{
|
||||
SSL_DEBUG_MSG( 0, ( "inapropriate fallback" ) );
|
||||
|
||||
ssl_send_alert_message( ssl, SSL_ALERT_LEVEL_FATAL,
|
||||
SSL_ALERT_MSG_INAPROPRIATE_FALLBACK );
|
||||
|
||||
return( POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO );
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* POLARSSL_SSL_FALLBACK_SCSV */
|
||||
|
||||
ext = buf + 44 + sess_len + ciph_len + comp_len;
|
||||
|
||||
while( ext_len )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue