Use platform layer in programs for consistency.
diff --git a/programs/pkey/rsa_verify.c b/programs/pkey/rsa_verify.c
index 7405df7..43b742e 100644
--- a/programs/pkey/rsa_verify.c
+++ b/programs/pkey/rsa_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>
@@ -39,7 +48,7 @@
((void) argc);
((void) argv);
- printf("POLARSSL_BIGNUM_C and/or POLARSSL_RSA_C and/or "
+ polarssl_printf("POLARSSL_BIGNUM_C and/or POLARSSL_RSA_C and/or "
"POLARSSL_SHA1_C and/or POLARSSL_FS_IO not defined.\n");
return( 0 );
}
@@ -56,21 +65,21 @@
ret = 1;
if( argc != 2 )
{
- printf( "usage: rsa_verify <filename>\n" );
+ polarssl_printf( "usage: rsa_verify <filename>\n" );
#if defined(_WIN32)
- printf( "\n" );
+ polarssl_printf( "\n" );
#endif
goto exit;
}
- printf( "\n . Reading public key from rsa_pub.txt" );
+ polarssl_printf( "\n . Reading public key from rsa_pub.txt" );
fflush( stdout );
if( ( f = fopen( "rsa_pub.txt", "rb" ) ) == NULL )
{
- printf( " failed\n ! Could not open rsa_pub.txt\n" \
+ polarssl_printf( " failed\n ! Could not open rsa_pub.txt\n" \
" ! Please run rsa_genkey first\n\n" );
goto exit;
}
@@ -80,7 +89,7 @@
if( ( ret = mpi_read_file( &rsa.N, 16, f ) ) != 0 ||
( ret = mpi_read_file( &rsa.E, 16, f ) ) != 0 )
{
- printf( " failed\n ! mpi_read_file returned %d\n\n", ret );
+ polarssl_printf( " failed\n ! mpi_read_file returned %d\n\n", ret );
goto exit;
}
@@ -97,7 +106,7 @@
if( ( f = fopen( argv[1], "rb" ) ) == NULL )
{
- printf( "\n ! Could not open %s\n\n", argv[1] );
+ polarssl_printf( "\n ! Could not open %s\n\n", argv[1] );
goto exit;
}
@@ -111,7 +120,7 @@
if( i != rsa.len )
{
- printf( "\n ! Invalid RSA signature format\n\n" );
+ polarssl_printf( "\n ! Invalid RSA signature format\n\n" );
goto exit;
}
@@ -119,30 +128,30 @@
* Compute the SHA-1 hash of the input file and compare
* it with the hash decrypted from the RSA signature.
*/
- printf( "\n . Verifying the RSA/SHA-1 signature" );
+ polarssl_printf( "\n . Verifying the RSA/SHA-1 signature" );
fflush( stdout );
if( ( ret = sha1_file( argv[1], hash ) ) != 0 )
{
- printf( " failed\n ! Could not open or read %s\n\n", argv[1] );
+ polarssl_printf( " failed\n ! Could not open or read %s\n\n", argv[1] );
goto exit;
}
if( ( ret = rsa_pkcs1_verify( &rsa, NULL, NULL, RSA_PUBLIC,
POLARSSL_MD_SHA1, 20, hash, buf ) ) != 0 )
{
- printf( " failed\n ! rsa_pkcs1_verify returned -0x%0x\n\n", -ret );
+ polarssl_printf( " failed\n ! rsa_pkcs1_verify returned -0x%0x\n\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;
exit:
#if defined(_WIN32)
- printf( " + Press Enter to exit this program.\n" );
+ polarssl_printf( " + Press Enter to exit this program.\n" );
fflush( stdout ); getchar();
#endif