Use platform layer in programs for consistency.
diff --git a/programs/pkey/pk_verify.c b/programs/pkey/pk_verify.c
index f2e5eb3..89e9cc1 100644
--- a/programs/pkey/pk_verify.c
+++ b/programs/pkey/pk_verify.c
@@ -26,6 +26,15 @@
#include POLARSSL_CONFIG_FILE
#endif
+#if defined(POLARSSL_PLATFORM_C)
+#include "polarssl/platform.h"
+#else
+#define polarssl_printf printf
+#define polarssl_fprintf fprintf
+#define polarssl_malloc malloc
+#define polarssl_free free
+#endif
+
#include <string.h>
#include <stdio.h>
@@ -46,7 +55,7 @@
((void) argc);
((void) argv);
- printf("POLARSSL_BIGNUM_C and/or "
+ polarssl_printf("POLARSSL_BIGNUM_C and/or "
"POLARSSL_SHA1_C and/or POLARSSL_PK_PARSE_C and/or "
"POLARSSL_FS_IO not defined.\n");
return( 0 );
@@ -66,21 +75,21 @@
if( argc != 3 )
{
- printf( "usage: pk_verify <key_file> <filename>\n" );
+ polarssl_printf( "usage: pk_verify <key_file> <filename>\n" );
#if defined(_WIN32)
- printf( "\n" );
+ polarssl_printf( "\n" );
#endif
goto exit;
}
- printf( "\n . Reading public key from '%s'", argv[1] );
+ polarssl_printf( "\n . Reading public key from '%s'", argv[1] );
fflush( stdout );
if( ( ret = pk_parse_public_keyfile( &pk, argv[1] ) ) != 0 )
{
- printf( " failed\n ! pk_parse_public_keyfile returned -0x%04x\n", -ret );
+ polarssl_printf( " failed\n ! pk_parse_public_keyfile returned -0x%04x\n", -ret );
goto exit;
}
@@ -92,7 +101,7 @@
if( ( f = fopen( filename, "rb" ) ) == NULL )
{
- printf( "\n ! Could not open %s\n\n", filename );
+ polarssl_printf( "\n ! Could not open %s\n\n", filename );
goto exit;
}
@@ -105,23 +114,23 @@
* Compute the SHA-1 hash of the input file and compare
* it with the hash decrypted from the signature.
*/
- printf( "\n . Verifying the SHA-1 signature" );
+ polarssl_printf( "\n . Verifying the SHA-1 signature" );
fflush( stdout );
if( ( ret = sha1_file( argv[2], hash ) ) != 0 )
{
- printf( " failed\n ! Could not open or read %s\n\n", argv[2] );
+ polarssl_printf( " failed\n ! Could not open or read %s\n\n", argv[2] );
goto exit;
}
if( ( ret = pk_verify( &pk, POLARSSL_MD_SHA1, hash, 0,
buf, i ) ) != 0 )
{
- printf( " failed\n ! pk_verify returned -0x%04x\n", -ret );
+ polarssl_printf( " failed\n ! pk_verify returned -0x%04x\n", -ret );
goto exit;
}
- printf( "\n . OK (the decrypted SHA-1 hash matches)\n\n" );
+ polarssl_printf( "\n . OK (the decrypted SHA-1 hash matches)\n\n" );
ret = 0;
@@ -130,11 +139,11 @@
#if defined(POLARSSL_ERROR_C)
polarssl_strerror( ret, (char *) buf, sizeof(buf) );
- printf( " ! Last error was: %s\n", buf );
+ polarssl_printf( " ! Last error was: %s\n", buf );
#endif
#if defined(_WIN32)
- printf( " + Press Enter to exit this program.\n" );
+ polarssl_printf( " + Press Enter to exit this program.\n" );
fflush( stdout ); getchar();
#endif