mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-28 08:37:25 +00:00
Merge pull request #5295 from paul-elliott-arm/crypt_and_hash_prog
Add checks for return values to md functions in crypt and hash
This commit is contained in:
commit
1dc3c4553d
@ -277,10 +277,27 @@ int main( int argc, char *argv[] )
|
||||
|
||||
p = argv[2];
|
||||
|
||||
mbedtls_md_starts( &md_ctx );
|
||||
mbedtls_md_update( &md_ctx, buffer, 8 );
|
||||
mbedtls_md_update( &md_ctx, (unsigned char *) p, strlen( p ) );
|
||||
mbedtls_md_finish( &md_ctx, digest );
|
||||
if( mbedtls_md_starts( &md_ctx ) != 0 )
|
||||
{
|
||||
mbedtls_fprintf( stderr, "mbedtls_md_starts() returned error\n" );
|
||||
goto exit;
|
||||
}
|
||||
if( mbedtls_md_update( &md_ctx, buffer, 8 ) != 0 )
|
||||
{
|
||||
mbedtls_fprintf( stderr, "mbedtls_md_update() returned error\n" );
|
||||
goto exit;
|
||||
}
|
||||
if( mbedtls_md_update( &md_ctx, ( unsigned char * ) p, strlen( p ) )
|
||||
!= 0 )
|
||||
{
|
||||
mbedtls_fprintf( stderr, "mbedtls_md_update() returned error\n" );
|
||||
goto exit;
|
||||
}
|
||||
if( mbedtls_md_finish( &md_ctx, digest ) != 0 )
|
||||
{
|
||||
mbedtls_fprintf( stderr, "mbedtls_md_finish() returned error\n" );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
memcpy( IV, digest, 16 );
|
||||
|
||||
@ -302,10 +319,30 @@ int main( int argc, char *argv[] )
|
||||
|
||||
for( i = 0; i < 8192; i++ )
|
||||
{
|
||||
mbedtls_md_starts( &md_ctx );
|
||||
mbedtls_md_update( &md_ctx, digest, 32 );
|
||||
mbedtls_md_update( &md_ctx, key, keylen );
|
||||
mbedtls_md_finish( &md_ctx, digest );
|
||||
if( mbedtls_md_starts( &md_ctx ) != 0 )
|
||||
{
|
||||
mbedtls_fprintf( stderr,
|
||||
"mbedtls_md_starts() returned error\n" );
|
||||
goto exit;
|
||||
}
|
||||
if( mbedtls_md_update( &md_ctx, digest, 32 ) != 0 )
|
||||
{
|
||||
mbedtls_fprintf( stderr,
|
||||
"mbedtls_md_update() returned error\n" );
|
||||
goto exit;
|
||||
}
|
||||
if( mbedtls_md_update( &md_ctx, key, keylen ) != 0 )
|
||||
{
|
||||
mbedtls_fprintf( stderr,
|
||||
"mbedtls_md_update() returned error\n" );
|
||||
goto exit;
|
||||
}
|
||||
if( mbedtls_md_finish( &md_ctx, digest ) != 0 )
|
||||
{
|
||||
mbedtls_fprintf( stderr,
|
||||
"mbedtls_md_finish() returned error\n" );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user