mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-08-07 06:42:56 +03:00
- Split current md_starts() and md_hmac_starts() functionality into separate md_init_ctx() for allocating the context and the existing starts() functions to initialize the message digest for use.
This commit is contained in:
@@ -85,8 +85,9 @@ md_text_multi:text_md_name:text_src_string:hex_hash_string
|
||||
strncpy( (char *) md_name, {text_md_name}, 100 );
|
||||
md_info = md_info_from_string(md_name);
|
||||
TEST_ASSERT( md_info != NULL );
|
||||
TEST_ASSERT ( 0 == md_init_ctx( &ctx, md_info ) );
|
||||
|
||||
TEST_ASSERT ( 0 == md_starts( md_info, &ctx ) );
|
||||
TEST_ASSERT ( 0 == md_starts( &ctx ) );
|
||||
TEST_ASSERT ( ctx.md_ctx != NULL );
|
||||
TEST_ASSERT ( 0 == md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
|
||||
TEST_ASSERT ( 0 == md_finish( &ctx, output ) );
|
||||
@@ -117,10 +118,11 @@ md_hex_multi:text_md_name:hex_src_string:hex_hash_string
|
||||
strncpy( (char *) md_name, {text_md_name}, 100 );
|
||||
md_info = md_info_from_string(md_name);
|
||||
TEST_ASSERT( md_info != NULL );
|
||||
TEST_ASSERT ( 0 == md_init_ctx( &ctx, md_info ) );
|
||||
|
||||
src_len = unhexify( src_str, {hex_src_string} );
|
||||
|
||||
TEST_ASSERT ( 0 == md_starts( md_info, &ctx ) );
|
||||
TEST_ASSERT ( 0 == md_starts( &ctx ) );
|
||||
TEST_ASSERT ( ctx.md_ctx != NULL );
|
||||
TEST_ASSERT ( 0 == md_update( &ctx, src_str, src_len ) );
|
||||
TEST_ASSERT ( 0 == md_finish( &ctx, output ) );
|
||||
@@ -184,11 +186,12 @@ md_hmac_multi:text_md_name:trunc_size:hex_key_string:hex_src_string:hex_hash_str
|
||||
strncpy( (char *) md_name, {text_md_name}, 100 );
|
||||
md_info = md_info_from_string( md_name );
|
||||
TEST_ASSERT( md_info != NULL );
|
||||
TEST_ASSERT ( 0 == md_init_ctx( &ctx, md_info ) );
|
||||
|
||||
key_len = unhexify( key_str, {hex_key_string} );
|
||||
src_len = unhexify( src_str, {hex_src_string} );
|
||||
|
||||
TEST_ASSERT ( 0 == md_hmac_starts( md_info, &ctx, key_str, key_len ) );
|
||||
TEST_ASSERT ( 0 == md_hmac_starts( &ctx, key_str, key_len ) );
|
||||
TEST_ASSERT ( ctx.md_ctx != NULL );
|
||||
TEST_ASSERT ( 0 == md_hmac_update( &ctx, src_str, src_len ) );
|
||||
TEST_ASSERT ( 0 == md_hmac_finish( &ctx, output ) );
|
||||
|
Reference in New Issue
Block a user