mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-03-21 10:47:36 +00:00
Merge branch 'mbedtls-2.4-restricted'
This commit is contained in:
commit
01e3beb067
|
@ -2,6 +2,11 @@ mbed TLS ChangeLog (Sorted per branch, date)
|
||||||
|
|
||||||
= mbed TLS 2.x.x branch released xxxx-xx-xx
|
= mbed TLS 2.x.x branch released xxxx-xx-xx
|
||||||
|
|
||||||
|
Security
|
||||||
|
* Removed MD5 from the allowed hash algorithms for CertificateRequest and
|
||||||
|
CertificateVerify messages, to prevent SLOTH attacks against TLS 1.2.
|
||||||
|
Introduced by interoperability fix for #513.
|
||||||
|
|
||||||
Bugfix
|
Bugfix
|
||||||
* Fix the redefinition of macro ssl_set_bio to an undefined symbol
|
* Fix the redefinition of macro ssl_set_bio to an undefined symbol
|
||||||
mbedtls_ssl_set_bio_timeout in compat-1.3.h, by removing it.
|
mbedtls_ssl_set_bio_timeout in compat-1.3.h, by removing it.
|
||||||
|
@ -22,6 +27,9 @@ Bugfix
|
||||||
cause buffer bound checks to be bypassed. Found by Eyal Itkin.
|
cause buffer bound checks to be bypassed. Found by Eyal Itkin.
|
||||||
* Fixed potential arithmetic overflow in mbedtls_base64_decode() that could
|
* Fixed potential arithmetic overflow in mbedtls_base64_decode() that could
|
||||||
cause buffer bound checks to be bypassed. Found by Eyal Itkin.
|
cause buffer bound checks to be bypassed. Found by Eyal Itkin.
|
||||||
|
* Fixed multiple buffer overreads in mbedtls_pem_read_buffer() when parsing
|
||||||
|
the input string in PEM format to extract the different components. Found
|
||||||
|
by Eyal Itkin.
|
||||||
|
|
||||||
= mbed TLS 2.4.1 branch released 2016-12-13
|
= mbed TLS 2.4.1 branch released 2016-12-13
|
||||||
|
|
||||||
|
|
|
@ -249,7 +249,7 @@ int mbedtls_pem_read_buffer( mbedtls_pem_context *ctx, const char *header, const
|
||||||
|
|
||||||
enc = 0;
|
enc = 0;
|
||||||
|
|
||||||
if( memcmp( s1, "Proc-Type: 4,ENCRYPTED", 22 ) == 0 )
|
if( s2 - s1 >= 22 && memcmp( s1, "Proc-Type: 4,ENCRYPTED", 22 ) == 0 )
|
||||||
{
|
{
|
||||||
#if defined(MBEDTLS_MD5_C) && defined(MBEDTLS_CIPHER_MODE_CBC) && \
|
#if defined(MBEDTLS_MD5_C) && defined(MBEDTLS_CIPHER_MODE_CBC) && \
|
||||||
( defined(MBEDTLS_DES_C) || defined(MBEDTLS_AES_C) )
|
( defined(MBEDTLS_DES_C) || defined(MBEDTLS_AES_C) )
|
||||||
|
@ -262,22 +262,22 @@ int mbedtls_pem_read_buffer( mbedtls_pem_context *ctx, const char *header, const
|
||||||
|
|
||||||
|
|
||||||
#if defined(MBEDTLS_DES_C)
|
#if defined(MBEDTLS_DES_C)
|
||||||
if( memcmp( s1, "DEK-Info: DES-EDE3-CBC,", 23 ) == 0 )
|
if( s2 - s1 >= 23 && memcmp( s1, "DEK-Info: DES-EDE3-CBC,", 23 ) == 0 )
|
||||||
{
|
{
|
||||||
enc_alg = MBEDTLS_CIPHER_DES_EDE3_CBC;
|
enc_alg = MBEDTLS_CIPHER_DES_EDE3_CBC;
|
||||||
|
|
||||||
s1 += 23;
|
s1 += 23;
|
||||||
if( pem_get_iv( s1, pem_iv, 8 ) != 0 )
|
if( s2 - s1 < 16 || pem_get_iv( s1, pem_iv, 8 ) != 0 )
|
||||||
return( MBEDTLS_ERR_PEM_INVALID_ENC_IV );
|
return( MBEDTLS_ERR_PEM_INVALID_ENC_IV );
|
||||||
|
|
||||||
s1 += 16;
|
s1 += 16;
|
||||||
}
|
}
|
||||||
else if( memcmp( s1, "DEK-Info: DES-CBC,", 18 ) == 0 )
|
else if( s2 - s1 >= 18 && memcmp( s1, "DEK-Info: DES-CBC,", 18 ) == 0 )
|
||||||
{
|
{
|
||||||
enc_alg = MBEDTLS_CIPHER_DES_CBC;
|
enc_alg = MBEDTLS_CIPHER_DES_CBC;
|
||||||
|
|
||||||
s1 += 18;
|
s1 += 18;
|
||||||
if( pem_get_iv( s1, pem_iv, 8) != 0 )
|
if( s2 - s1 < 16 || pem_get_iv( s1, pem_iv, 8) != 0 )
|
||||||
return( MBEDTLS_ERR_PEM_INVALID_ENC_IV );
|
return( MBEDTLS_ERR_PEM_INVALID_ENC_IV );
|
||||||
|
|
||||||
s1 += 16;
|
s1 += 16;
|
||||||
|
@ -285,9 +285,11 @@ int mbedtls_pem_read_buffer( mbedtls_pem_context *ctx, const char *header, const
|
||||||
#endif /* MBEDTLS_DES_C */
|
#endif /* MBEDTLS_DES_C */
|
||||||
|
|
||||||
#if defined(MBEDTLS_AES_C)
|
#if defined(MBEDTLS_AES_C)
|
||||||
if( memcmp( s1, "DEK-Info: AES-", 14 ) == 0 )
|
if( s2 - s1 >= 14 && memcmp( s1, "DEK-Info: AES-", 14 ) == 0 )
|
||||||
{
|
{
|
||||||
if( memcmp( s1, "DEK-Info: AES-128-CBC,", 22 ) == 0 )
|
if( s2 - s1 < 22 )
|
||||||
|
return( MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG );
|
||||||
|
else if( memcmp( s1, "DEK-Info: AES-128-CBC,", 22 ) == 0 )
|
||||||
enc_alg = MBEDTLS_CIPHER_AES_128_CBC;
|
enc_alg = MBEDTLS_CIPHER_AES_128_CBC;
|
||||||
else if( memcmp( s1, "DEK-Info: AES-192-CBC,", 22 ) == 0 )
|
else if( memcmp( s1, "DEK-Info: AES-192-CBC,", 22 ) == 0 )
|
||||||
enc_alg = MBEDTLS_CIPHER_AES_192_CBC;
|
enc_alg = MBEDTLS_CIPHER_AES_192_CBC;
|
||||||
|
@ -297,7 +299,7 @@ int mbedtls_pem_read_buffer( mbedtls_pem_context *ctx, const char *header, const
|
||||||
return( MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG );
|
return( MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG );
|
||||||
|
|
||||||
s1 += 22;
|
s1 += 22;
|
||||||
if( pem_get_iv( s1, pem_iv, 16 ) != 0 )
|
if( s2 - s1 < 32 || pem_get_iv( s1, pem_iv, 16 ) != 0 )
|
||||||
return( MBEDTLS_ERR_PEM_INVALID_ENC_IV );
|
return( MBEDTLS_ERR_PEM_INVALID_ENC_IV );
|
||||||
|
|
||||||
s1 += 32;
|
s1 += 32;
|
||||||
|
@ -316,7 +318,7 @@ int mbedtls_pem_read_buffer( mbedtls_pem_context *ctx, const char *header, const
|
||||||
( MBEDTLS_AES_C || MBEDTLS_DES_C ) */
|
( MBEDTLS_AES_C || MBEDTLS_DES_C ) */
|
||||||
}
|
}
|
||||||
|
|
||||||
if( s1 == s2 )
|
if( s1 >= s2 )
|
||||||
return( MBEDTLS_ERR_PEM_INVALID_DATA );
|
return( MBEDTLS_ERR_PEM_INVALID_DATA );
|
||||||
|
|
||||||
ret = mbedtls_base64_decode( NULL, 0, &len, s1, s2 - s1 );
|
ret = mbedtls_base64_decode( NULL, 0, &len, s1, s2 - s1 );
|
||||||
|
|
|
@ -7653,8 +7653,7 @@ int mbedtls_ssl_set_calc_verify_md( mbedtls_ssl_context *ssl, int md )
|
||||||
#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1)
|
#if defined(MBEDTLS_SSL_PROTO_TLS1) || defined(MBEDTLS_SSL_PROTO_TLS1_1)
|
||||||
#if defined(MBEDTLS_MD5_C)
|
#if defined(MBEDTLS_MD5_C)
|
||||||
case MBEDTLS_SSL_HASH_MD5:
|
case MBEDTLS_SSL_HASH_MD5:
|
||||||
ssl->handshake->calc_verify = ssl_calc_verify_tls;
|
return MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH;
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
#if defined(MBEDTLS_SHA1_C)
|
#if defined(MBEDTLS_SHA1_C)
|
||||||
case MBEDTLS_SSL_HASH_SHA1:
|
case MBEDTLS_SSL_HASH_SHA1:
|
||||||
|
|
|
@ -15,3 +15,12 @@ mbedtls_pem_write_buffer:"-----START TEST-----\n":"-----END TEST-----\n":"000102
|
||||||
|
|
||||||
PEM write (exactly two lines + 1)
|
PEM write (exactly two lines + 1)
|
||||||
mbedtls_pem_write_buffer:"-----START TEST-----\n":"-----END TEST-----\n":"000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F00":"-----START TEST-----\nAAECAwQFBgcICQoLDA0ODwABAgMEBQYHCAkKCwwNDg8AAQIDBAUGBwgJCgsMDQ4P\nAAECAwQFBgcICQoLDA0ODwABAgMEBQYHCAkKCwwNDg8AAQIDBAUGBwgJCgsMDQ4P\nAA==\n-----END TEST-----\n"
|
mbedtls_pem_write_buffer:"-----START TEST-----\n":"-----END TEST-----\n":"000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F00":"-----START TEST-----\nAAECAwQFBgcICQoLDA0ODwABAgMEBQYHCAkKCwwNDg8AAQIDBAUGBwgJCgsMDQ4P\nAAECAwQFBgcICQoLDA0ODwABAgMEBQYHCAkKCwwNDg8AAQIDBAUGBwgJCgsMDQ4P\nAA==\n-----END TEST-----\n"
|
||||||
|
|
||||||
|
PEM read (DES-EDE3-CBC + invalid iv)
|
||||||
|
mbedtls_pem_read_buffer:"^":"$":"^\nProc-Type\: 4,ENCRYPTED\nDEK-Info\: DES-EDE3-CBC,00$":-4608
|
||||||
|
|
||||||
|
PEM read (DES-CBC + invalid iv)
|
||||||
|
mbedtls_pem_read_buffer:"^":"$":"^\nProc-Type\: 4,ENCRYPTED\nDEK-Info\: DES-CBC,00$":-4608
|
||||||
|
|
||||||
|
PEM read (unknown encryption algorithm)
|
||||||
|
mbedtls_pem_read_buffer:"^":"$":"^\nProc-Type\: 4,ENCRYPTED\nDEK-Info\: AES-,00$":-4736
|
||||||
|
|
|
@ -3,12 +3,7 @@
|
||||||
#include "mbedtls/pem.h"
|
#include "mbedtls/pem.h"
|
||||||
/* END_HEADER */
|
/* END_HEADER */
|
||||||
|
|
||||||
/* BEGIN_DEPENDENCIES
|
/* BEGIN_CASE depends_on:MBEDTLS_PEM_WRITE_C */
|
||||||
* depends_on:MBEDTLS_PEM_WRITE_C
|
|
||||||
* END_DEPENDENCIES
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* BEGIN_CASE */
|
|
||||||
void mbedtls_pem_write_buffer( char *start, char *end, char *buf_str, char *result_str )
|
void mbedtls_pem_write_buffer( char *start, char *end, char *buf_str, char *result_str )
|
||||||
{
|
{
|
||||||
unsigned char buf[5000];
|
unsigned char buf[5000];
|
||||||
|
@ -38,3 +33,20 @@ exit:
|
||||||
mbedtls_free( check_buf );
|
mbedtls_free( check_buf );
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
|
/* BEGIN_CASE depends_on:MBEDTLS_PEM_PARSE_C:MBEDTLS_AES_C:MBEDTLS_DES_C:MBEDTLS_MD5_C:MBEDTLS_CIPHER_MODE_CBC */
|
||||||
|
void mbedtls_pem_read_buffer( char *header, char *footer, char *data, int ret )
|
||||||
|
{
|
||||||
|
mbedtls_pem_context ctx;
|
||||||
|
size_t use_len = 0;
|
||||||
|
|
||||||
|
mbedtls_pem_init( &ctx );
|
||||||
|
|
||||||
|
TEST_ASSERT( mbedtls_pem_read_buffer( &ctx, header, footer,
|
||||||
|
(const unsigned char *)data, NULL, 0,
|
||||||
|
&use_len ) == ret );
|
||||||
|
|
||||||
|
exit:
|
||||||
|
mbedtls_pem_free( &ctx );
|
||||||
|
}
|
||||||
|
/* END_CASE */
|
||||||
|
|
Loading…
Reference in a new issue