Use platform layer in programs for consistency.
diff --git a/programs/pkey/key_app.c b/programs/pkey/key_app.c
index 3637d6d..a161829 100644
--- a/programs/pkey/key_app.c
+++ b/programs/pkey/key_app.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 <stdlib.h>
 #include <stdio.h>
@@ -41,7 +50,7 @@
     ((void) argc);
     ((void) argv);
 
-    printf("POLARSSL_BIGNUM_C and/or "
+    polarssl_printf("POLARSSL_BIGNUM_C and/or "
            "POLARSSL_PK_PARSE_C and/or POLARSSL_FS_IO not defined.\n");
     return( 0 );
 }
@@ -94,7 +103,7 @@
     if( argc == 0 )
     {
     usage:
-        printf( USAGE );
+        polarssl_printf( USAGE );
         goto exit;
     }
 
@@ -133,7 +142,7 @@
     {
         if( strlen( opt.password ) && strlen( opt.password_file ) )
         {
-            printf( "Error: cannot have both password and password_file\n" );
+            polarssl_printf( "Error: cannot have both password and password_file\n" );
             goto usage;
         }
 
@@ -141,16 +150,16 @@
         {
             FILE *f;
 
-            printf( "\n  . Loading the password file ..." );
+            polarssl_printf( "\n  . Loading the password file ..." );
             if( ( f = fopen( opt.password_file, "rb" ) ) == NULL )
             {
-                printf( " failed\n  !  fopen returned NULL\n" );
+                polarssl_printf( " failed\n  !  fopen returned NULL\n" );
                 goto exit;
             }
             if( fgets( buf, sizeof(buf), f ) == NULL )
             {
                 fclose( f );
-                printf( "Error: fgets() failed to retrieve password\n" );
+                polarssl_printf( "Error: fgets() failed to retrieve password\n" );
                 goto exit;
             }
             fclose( f );
@@ -164,23 +173,23 @@
         /*
          * 1.1. Load the key
          */
-        printf( "\n  . Loading the private key ..." );
+        polarssl_printf( "\n  . Loading the private key ..." );
         fflush( stdout );
 
         ret = pk_parse_keyfile( &pk, opt.filename, opt.password );
 
         if( ret != 0 )
         {
-            printf( " failed\n  !  pk_parse_keyfile returned -0x%04x\n", -ret );
+            polarssl_printf( " failed\n  !  pk_parse_keyfile returned -0x%04x\n", -ret );
             goto exit;
         }
 
-        printf( " ok\n" );
+        polarssl_printf( " ok\n" );
 
         /*
          * 1.2 Print the key
          */
-        printf( "  . Key information    ...\n" );
+        polarssl_printf( "  . Key information    ...\n" );
 #if defined(POLARSSL_RSA_C)
         if( pk_get_type( &pk ) == POLARSSL_PK_RSA )
         {
@@ -208,7 +217,7 @@
         else
 #endif
         {
-            printf("Do not know how to print key information for this type\n" );
+            polarssl_printf("Do not know how to print key information for this type\n" );
             goto exit;
         }
     }
@@ -217,20 +226,20 @@
         /*
          * 1.1. Load the key
          */
-        printf( "\n  . Loading the public key ..." );
+        polarssl_printf( "\n  . Loading the public key ..." );
         fflush( stdout );
 
         ret = pk_parse_public_keyfile( &pk, opt.filename );
 
         if( ret != 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;
         }
 
-        printf( " ok\n" );
+        polarssl_printf( " ok\n" );
 
-        printf( "  . Key information    ...\n" );
+        polarssl_printf( "  . Key information    ...\n" );
 #if defined(POLARSSL_RSA_C)
         if( pk_get_type( &pk ) == POLARSSL_PK_RSA )
         {
@@ -251,7 +260,7 @@
         else
 #endif
         {
-            printf("Do not know how to print key information for this type\n" );
+            polarssl_printf("Do not know how to print key information for this type\n" );
             goto exit;
         }
     }
@@ -262,13 +271,13 @@
 
 #if defined(POLARSSL_ERROR_C)
     polarssl_strerror( ret, buf, sizeof(buf) );
-    printf( "  !  Last error was: %s\n", buf );
+    polarssl_printf( "  !  Last error was: %s\n", buf );
 #endif
 
     pk_free( &pk );
 
 #if defined(_WIN32)
-    printf( "  + Press Enter to exit this program.\n" );
+    polarssl_printf( "  + Press Enter to exit this program.\n" );
     fflush( stdout ); getchar();
 #endif