mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-24 18:41:13 +00:00
Add tests for overreads in pem_read_buffer()
This commit is contained in:
parent
de6079af8e
commit
480f7e7d5e
|
@ -14,7 +14,7 @@ Bugfix
|
||||||
that are reported when building mbed TLS with a config.h that does not
|
that are reported when building mbed TLS with a config.h that does not
|
||||||
define POLARSSL_PEM_PARSE_C. Found by omnium21. #562
|
define POLARSSL_PEM_PARSE_C. Found by omnium21. #562
|
||||||
* Fixed multiple buffer overreads in mbedtls_pem_read_buffer() when parsing
|
* Fixed multiple buffer overreads in mbedtls_pem_read_buffer() when parsing
|
||||||
the input string in pem format to extract the different components. Found
|
the input string in PEM format to extract the different components. Found
|
||||||
by Eyal Itkin.
|
by Eyal Itkin.
|
||||||
|
|
||||||
= mbed TLS 1.3.18 branch 2016-10-17
|
= mbed TLS 1.3.18 branch 2016-10-17
|
||||||
|
|
|
@ -15,3 +15,12 @@ pem_write_buffer:"-----START TEST-----\n":"-----END TEST-----\n":"00010203040506
|
||||||
|
|
||||||
PEM write (exactly two lines + 1)
|
PEM write (exactly two lines + 1)
|
||||||
pem_write_buffer:"-----START TEST-----\n":"-----END TEST-----\n":"000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F000102030405060708090A0B0C0D0E0F00":"-----START TEST-----\nAAECAwQFBgcICQoLDA0ODwABAgMEBQYHCAkKCwwNDg8AAQIDBAUGBwgJCgsMDQ4P\nAAECAwQFBgcICQoLDA0ODwABAgMEBQYHCAkKCwwNDg8AAQIDBAUGBwgJCgsMDQ4P\nAA==\n-----END TEST-----\n"
|
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)
|
||||||
|
pem_read_buffer:"^":"$":"^\nProc-Type\: 4,ENCRYPTED\nDEK-Info\: DES-EDE3-CBC,00$":-4608
|
||||||
|
|
||||||
|
PEM read (DES-CBC + invalid iv)
|
||||||
|
pem_read_buffer:"^":"$":"^\nProc-Type\: 4,ENCRYPTED\nDEK-Info\: DES-CBC,00$":-4608
|
||||||
|
|
||||||
|
PEM read (unknown encryption algorithm)
|
||||||
|
pem_read_buffer:"^":"$":"^\nProc-Type\: 4,ENCRYPTED\nDEK-Info\: AES-,00$":-4736
|
||||||
|
|
|
@ -3,12 +3,7 @@
|
||||||
#include "polarssl/pem.h"
|
#include "polarssl/pem.h"
|
||||||
/* END_HEADER */
|
/* END_HEADER */
|
||||||
|
|
||||||
/* BEGIN_DEPENDENCIES
|
/* BEGIN_CASE depends_on:POLARSSL_PEM_WRITE_C */
|
||||||
* depends_on:POLARSSL_PEM_WRITE_C
|
|
||||||
* END_DEPENDENCIES
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* BEGIN_CASE */
|
|
||||||
void pem_write_buffer( char *start, char *end, char *buf_str, char *result_str )
|
void 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:
|
||||||
polarssl_free( check_buf );
|
polarssl_free( check_buf );
|
||||||
}
|
}
|
||||||
/* END_CASE */
|
/* END_CASE */
|
||||||
|
|
||||||
|
/* BEGIN_CASE depends_on:POLARSSL_PEM_PARSE_C:POLARSSL_AES_C:POLARSSL_DES_C:POLARSSL_MD5_C:POLARSSL_CIPHER_MODE_CBC */
|
||||||
|
void pem_read_buffer( char *header, char *footer, char *data, int ret )
|
||||||
|
{
|
||||||
|
pem_context ctx;
|
||||||
|
size_t use_len = 0;
|
||||||
|
|
||||||
|
pem_init( &ctx );
|
||||||
|
|
||||||
|
TEST_ASSERT( pem_read_buffer( &ctx, header, footer,
|
||||||
|
(const unsigned char *)data, NULL, 0,
|
||||||
|
&use_len ) == ret );
|
||||||
|
|
||||||
|
exit:
|
||||||
|
pem_free( &ctx );
|
||||||
|
}
|
||||||
|
/* END_CASE */
|
||||||
|
|
Loading…
Reference in a new issue