mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 22:45:48 +01:00
Add tests for th init_buf() variant of HMAC_DRBG
This commit is contained in:
parent
cf38367f45
commit
e6cdbbd40b
@ -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 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user