mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2026-01-04 13:45:05 +01:00
Merge commit '8b9bcec' into dtls
* commit '8b9bcec':
Stop assuming chars are signed
Fix len miscalculation in buffer-based allocator
Fix NULL dereference in buffer-based allocator
Add test_suite_memory_buffer_alloc
Add memory_buffer_alloc_self_test()
Fix missing bound check
Add test for ctr_drbg_update() input sanitizing
Refactor for clearer correctness/security
Stop assuming chars are signed
Conflicts:
library/ssl_tls.c
This commit is contained in:
commit
f9c8a606b5
14 changed files with 270 additions and 65 deletions
|
|
@ -77,6 +77,7 @@ add_test_suite(hmac_drbg hmac_drbg.pr)
|
|||
add_test_suite(hmac_shax)
|
||||
add_test_suite(md)
|
||||
add_test_suite(mdx)
|
||||
add_test_suite(memory_buffer_alloc)
|
||||
add_test_suite(mpi)
|
||||
add_test_suite(pbkdf2)
|
||||
add_test_suite(pem)
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ APPS = test_suite_aes.ecb test_suite_aes.cbc \
|
|||
test_suite_hmac_drbg.nopr \
|
||||
test_suite_hmac_drbg.pr \
|
||||
test_suite_md test_suite_mdx \
|
||||
test_suite_memory_buffer_alloc \
|
||||
test_suite_mpi test_suite_pbkdf2 \
|
||||
test_suite_pem \
|
||||
test_suite_pkcs1_v21 test_suite_pkcs5 \
|
||||
|
|
@ -337,6 +338,10 @@ test_suite_mdx: test_suite_mdx.c $(DEP)
|
|||
echo " CC $@.c"
|
||||
$(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
|
||||
|
||||
test_suite_memory_buffer_alloc: test_suite_memory_buffer_alloc.c $(DEP)
|
||||
echo " CC $@.c"
|
||||
$(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
|
||||
|
||||
test_suite_mpi: test_suite_mpi.c $(DEP)
|
||||
echo " CC $@.c"
|
||||
$(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
|
||||
|
|
|
|||
|
|
@ -211,7 +211,8 @@ int main()
|
|||
char buf[5000];
|
||||
char *params[50];
|
||||
|
||||
#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
|
||||
#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C) && \
|
||||
!defined(TEST_SUITE_MEMORY_BUFFER_ALLOC)
|
||||
unsigned char alloc_buf[1000000];
|
||||
memory_buffer_alloc_init( alloc_buf, sizeof(alloc_buf) );
|
||||
#endif
|
||||
|
|
@ -298,7 +299,8 @@ int main()
|
|||
fprintf( stdout, " (%d / %d tests (%d skipped))\n",
|
||||
total_tests - total_errors, total_tests, total_skipped );
|
||||
|
||||
#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
|
||||
#if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C) && \
|
||||
!defined(TEST_SUITE_MEMORY_BUFFER_ALLOC)
|
||||
#if defined(POLARSSL_MEMORY_DEBUG)
|
||||
memory_buffer_alloc_status();
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -141,6 +141,10 @@ void ctr_drbg_entropy_usage( )
|
|||
}
|
||||
TEST_ASSERT( last_idx == test_offset_idx );
|
||||
|
||||
/* Call update with too much data (sizeof entropy > MAX(_SEED)_INPUT)
|
||||
* (just make sure it doesn't cause memory corruption) */
|
||||
ctr_drbg_update( &ctx, entropy, sizeof( entropy ) );
|
||||
|
||||
/* Now enable PR, so the next few calls should all reseed */
|
||||
ctr_drbg_set_prediction_resistance( &ctx, CTR_DRBG_PR_ON );
|
||||
TEST_ASSERT( ctr_drbg_random( &ctx, out, sizeof( out ) ) == 0 );
|
||||
|
|
|
|||
2
tests/suites/test_suite_memory_buffer_alloc.data
Normal file
2
tests/suites/test_suite_memory_buffer_alloc.data
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Memory buffer alloc self test
|
||||
memory_buffer_alloc_self_test:
|
||||
16
tests/suites/test_suite_memory_buffer_alloc.function
Normal file
16
tests/suites/test_suite_memory_buffer_alloc.function
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/* BEGIN_HEADER */
|
||||
#include <polarssl/memory_buffer_alloc.h>
|
||||
#define TEST_SUITE_MEMORY_BUFFER_ALLOC
|
||||
/* END_HEADER */
|
||||
|
||||
/* BEGIN_DEPENDENCIES
|
||||
* depends_on:POLARSSL_MEMORY_BUFFER_ALLOC_C
|
||||
* END_DEPENDENCIES
|
||||
*/
|
||||
|
||||
/* BEGIN_CASE depends_on:POLARSSL_SELF_TEST */
|
||||
void memory_buffer_alloc_self_test( )
|
||||
{
|
||||
TEST_ASSERT( memory_buffer_alloc_self_test( 0 ) == 0 );
|
||||
}
|
||||
/* END_CASE */
|
||||
Loading…
Add table
Add a link
Reference in a new issue