mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2026-01-03 21:25:31 +01:00
Change examples to use the new MD API and check ret code
This commit is contained in:
parent
d21d625e1f
commit
1ff60f437f
5 changed files with 28 additions and 18 deletions
|
|
@ -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 @@ int main( void )
|
|||
#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 @@ int main( void )
|
|||
fflush( stdout ); getchar();
|
||||
#endif
|
||||
|
||||
return( 0 );
|
||||
return( MBEDTLS_EXIT_SUCCESS );
|
||||
}
|
||||
#endif /* MBEDTLS_MD5_C */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue