Commit e6cdbbd4 authored by Manuel Pégourié-Gonnard's avatar Manuel Pégourié-Gonnard
Browse files

Add tests for th init_buf() variant of HMAC_DRBG

parent cf38367f
......@@ -153,6 +153,7 @@ void hmac_drbg_no_reseed( int md_alg,
char *add1_hex, char *add2_hex,
char *output_hex )
{
unsigned char data[1024];
unsigned char entropy[512];
unsigned char custom[512];
unsigned char add1[512];
......@@ -174,6 +175,21 @@ void hmac_drbg_no_reseed( int md_alg,
p_entropy.p = entropy;
TEST_ASSERT( ( md_info = md_info_from_type( md_alg ) ) != NULL );
/* Test the simplified buffer-based variant */
memcpy( data, entropy, p_entropy.len );
memcpy( data + p_entropy.len, custom, custom_len );
TEST_ASSERT( hmac_drbg_init_buf( &ctx, md_info,
data, p_entropy.len + custom_len ) == 0 );
TEST_ASSERT( hmac_drbg_random_with_add( &ctx, my_output, out_len,
add1, add1_len ) == 0 );
TEST_ASSERT( hmac_drbg_random_with_add( &ctx, my_output, out_len,
add2, add2_len ) == 0 );
hmac_drbg_free( &ctx );
TEST_ASSERT( memcmp( my_output, output, out_len ) == 0 );
/* And now the normal entropy-based variant */
TEST_ASSERT( hmac_drbg_init( &ctx, md_info, entropy_func, &p_entropy,
custom, custom_len ) == 0 );
TEST_ASSERT( hmac_drbg_random_with_add( &ctx, my_output, out_len,
......@@ -183,6 +199,7 @@ void hmac_drbg_no_reseed( int md_alg,
hmac_drbg_free( &ctx );
TEST_ASSERT( memcmp( my_output, output, out_len ) == 0 );
}
/* END_CASE */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment