mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-08 17:42:09 +03:00
Merge pull request #3315 from hanno-arm/tls13-experimental-macro
Add support for TLS 1.3 record protection routines
This commit is contained in:
@@ -1308,8 +1308,18 @@ static int build_transforms( mbedtls_ssl_transform *t_in,
|
||||
{
|
||||
case MBEDTLS_MODE_GCM:
|
||||
case MBEDTLS_MODE_CCM:
|
||||
t_out->fixed_ivlen = 4;
|
||||
t_in->fixed_ivlen = 4;
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)
|
||||
if( ver == MBEDTLS_SSL_MINOR_VERSION_4 )
|
||||
{
|
||||
t_out->fixed_ivlen = 12;
|
||||
t_in->fixed_ivlen = 12;
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */
|
||||
{
|
||||
t_out->fixed_ivlen = 4;
|
||||
t_in->fixed_ivlen = 4;
|
||||
}
|
||||
t_out->maclen = 0;
|
||||
t_in->maclen = 0;
|
||||
switch( tag_mode )
|
||||
@@ -3182,6 +3192,26 @@ void ssl_crypt_record( int cipher_type, int hash_id,
|
||||
continue;
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
|
||||
if( rec.cid_len != 0 )
|
||||
{
|
||||
/* DTLS 1.2 + CID hides the real content type and
|
||||
* uses a special CID content type in the protected
|
||||
* record. Double-check this. */
|
||||
TEST_ASSERT( rec.type == MBEDTLS_SSL_MSG_CID );
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)
|
||||
if( t_enc->minor_ver == MBEDTLS_SSL_MINOR_VERSION_4 )
|
||||
{
|
||||
/* TLS 1.3 hides the real content type and
|
||||
* always uses Application Data as the content type
|
||||
* for protected records. Double-check this. */
|
||||
TEST_ASSERT( rec.type == MBEDTLS_SSL_MSG_APPLICATION_DATA );
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */
|
||||
|
||||
/* Decrypt record with t_dec */
|
||||
ret = mbedtls_ssl_decrypt_buf( &ssl, t_dec, &rec );
|
||||
TEST_ASSERT( ret == 0 );
|
||||
@@ -3325,6 +3355,26 @@ void ssl_crypt_record_small( int cipher_type, int hash_id,
|
||||
if( ret != 0 )
|
||||
continue;
|
||||
|
||||
#if defined(MBEDTLS_SSL_DTLS_CONNECTION_ID)
|
||||
if( rec.cid_len != 0 )
|
||||
{
|
||||
/* DTLS 1.2 + CID hides the real content type and
|
||||
* uses a special CID content type in the protected
|
||||
* record. Double-check this. */
|
||||
TEST_ASSERT( rec.type == MBEDTLS_SSL_MSG_CID );
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
|
||||
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL)
|
||||
if( t_enc->minor_ver == MBEDTLS_SSL_MINOR_VERSION_4 )
|
||||
{
|
||||
/* TLS 1.3 hides the real content type and
|
||||
* always uses Application Data as the content type
|
||||
* for protected records. Double-check this. */
|
||||
TEST_ASSERT( rec.type == MBEDTLS_SSL_MSG_APPLICATION_DATA );
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL */
|
||||
|
||||
/* Decrypt record with t_dec */
|
||||
TEST_ASSERT( mbedtls_ssl_decrypt_buf( &ssl, t_dec, &rec ) == 0 );
|
||||
|
||||
|
Reference in New Issue
Block a user