Change examples to use the new MD API and check ret code
diff --git a/programs/hash/hello.c b/programs/hash/hello.c
index df420f2..a69154f 100644
--- a/programs/hash/hello.c
+++ b/programs/hash/hello.c
@@ -29,7 +29,9 @@
#include "mbedtls/platform.h"
#else
#include <stdio.h>
-#define mbedtls_printf printf
+#define mbedtls_printf printf
+#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
+#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif
#if defined(MBEDTLS_MD5_C)
@@ -45,13 +47,14 @@
#else
int main( void )
{
- int i;
+ int i, ret;
unsigned char digest[16];
char str[] = "Hello, world!";
mbedtls_printf( "\n MD5('%s') = ", str );
- mbedtls_md5( (unsigned char *) str, 13, digest );
+ if( ( ret = mbedtls_md5_ext( (unsigned char *) str, 13, digest ) ) != 0 )
+ return( MBEDTLS_EXIT_FAILURE );
for( i = 0; i < 16; i++ )
mbedtls_printf( "%02x", digest[i] );
@@ -63,6 +66,6 @@
fflush( stdout ); getchar();
#endif
- return( 0 );
+ return( MBEDTLS_EXIT_SUCCESS );
}
#endif /* MBEDTLS_MD5_C */