Adapt programs to generic md_file()

This commit is contained in:
Manuel Pégourié-Gonnard 2015-05-28 16:23:18 +02:00
parent b327168e22
commit 06d5d61302
6 changed files with 102 additions and 104 deletions

View file

@ -33,24 +33,24 @@
#define mbedtls_printf printf
#endif
#if defined(MBEDTLS_BIGNUM_C) && defined(MBEDTLS_RSA_C) && \
defined(MBEDTLS_SHA256_C) && defined(MBEDTLS_FS_IO)
#include "mbedtls/rsa.h"
#include "mbedtls/sha1.h"
#include <stdio.h>
#include <string.h>
#endif
#if !defined(MBEDTLS_BIGNUM_C) || !defined(MBEDTLS_RSA_C) || \
!defined(MBEDTLS_SHA256_C) || !defined(MBEDTLS_FS_IO)
!defined(MBEDTLS_SHA256_C) || !defined(MBEDTLS_MD_C) || \
!defined(MBEDTLS_FS_IO)
int main( void )
{
mbedtls_printf("MBEDTLS_BIGNUM_C and/or MBEDTLS_RSA_C and/or "
"MBEDTLS_SHA256_C and/or MBEDTLS_FS_IO not defined.\n");
"MBEDLTS_MD_C and/or "
"MBEDTLS_SHA256_C and/or MBEDTLS_FS_IO not defined.\n");
return( 0 );
}
#else
#include "mbedtls/rsa.h"
#include "mbedtls/md.h"
#include <stdio.h>
#include <string.h>
int main( int argc, char *argv[] )
{
FILE *f;
@ -129,7 +129,9 @@ int main( int argc, char *argv[] )
mbedtls_printf( "\n . Verifying the RSA/SHA-256 signature" );
fflush( stdout );
if( ( ret = mbedtls_sha1_file( argv[1], hash ) ) != 0 )
if( ( ret = mbedtls_md_file(
mbedtls_md_info_from_type( MBEDTLS_MD_SHA256 ),
argv[1], hash ) ) != 0 )
{
mbedtls_printf( " failed\n ! Could not open or read %s\n\n", argv[1] );
goto exit;