mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Don't send back EtM extension if not using CBC
This commit is contained in:
@ -1721,6 +1721,8 @@ static void ssl_write_encrypt_then_mac_ext( ssl_context *ssl,
|
||||
size_t *olen )
|
||||
{
|
||||
unsigned char *p = buf;
|
||||
const ssl_ciphersuite_t *suite = NULL;
|
||||
const cipher_info_t *cipher = NULL;
|
||||
|
||||
if( ssl->session_negotiate->encrypt_then_mac == SSL_EXTENDED_MS_DISABLED ||
|
||||
ssl->minor_ver == SSL_MINOR_VERSION_0 )
|
||||
@ -1729,6 +1731,21 @@ static void ssl_write_encrypt_then_mac_ext( ssl_context *ssl,
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* RFC 7366: "If a server receives an encrypt-then-MAC request extension
|
||||
* from a client and then selects a stream or Authenticated Encryption
|
||||
* with Associated Data (AEAD) ciphersuite, it MUST NOT send an
|
||||
* encrypt-then-MAC response extension back to the client."
|
||||
*/
|
||||
if( ( suite = ssl_ciphersuite_from_id(
|
||||
ssl->session_negotiate->ciphersuite ) ) == NULL ||
|
||||
( cipher = cipher_info_from_type( suite->cipher ) ) == NULL ||
|
||||
cipher->mode != POLARSSL_MODE_CBC )
|
||||
{
|
||||
*olen = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
SSL_DEBUG_MSG( 3, ( "server hello, adding encrypt then mac extension" ) );
|
||||
|
||||
*p++ = (unsigned char)( ( TLS_EXT_ENCRYPT_THEN_MAC >> 8 ) & 0xFF );
|
||||
|
Reference in New Issue
Block a user