Add coverage for CTR-DRBG corner case function behaviours

This commit is contained in:
Paul Bakker 2016-07-14 13:21:10 +01:00 committed by Simon Butcher
parent ec5ceb65d6
commit 185ccf7070
2 changed files with 31 additions and 0 deletions

View File

@ -727,6 +727,9 @@ ctr_drbg_seed_file:"data_files/ctr_drbg_seed":0
CTR_DRBG write/update seed file
ctr_drbg_seed_file:"no_such_dir/file":MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR
CTR_DRBG Special Behaviours
ctr_drbg_special_behaviours:
CTR_DRBG self test
ctr_drbg_selftest:

View File

@ -16,6 +16,34 @@ int mbedtls_entropy_func( void *data, unsigned char *buf, size_t len )
* END_DEPENDENCIES
*/
/* BEGIN_CASE */
void ctr_drbg_special_behaviours( )
{
mbedtls_ctr_drbg_context ctx;
unsigned char output[512];
unsigned char additional[512];
mbedtls_ctr_drbg_init( &ctx );
memset( output, 0, sizeof( output ) );
memset( additional, 0, sizeof( additional ) );
TEST_ASSERT( mbedtls_ctr_drbg_random_with_add( &ctx,
output, MBEDTLS_CTR_DRBG_MAX_REQUEST + 1,
additional, 16 ) ==
MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG );
TEST_ASSERT( mbedtls_ctr_drbg_random_with_add( &ctx,
output, 16,
additional, MBEDTLS_CTR_DRBG_MAX_INPUT + 1 ) ==
MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG );
TEST_ASSERT( mbedtls_ctr_drbg_reseed( &ctx, additional,
MBEDTLS_CTR_DRBG_MAX_SEED_INPUT + 1 ) ==
MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG );
exit:
mbedtls_ctr_drbg_free( &ctx );
}
/* END_CASE */
/* BEGIN_CASE */
void ctr_drbg_validate_pr( char *add_init_string, char *entropy_string,
char *add1_string, char *add2_string,