Fix dependencies on PEM in tests and programs
diff --git a/configs/config-picocoin.h b/configs/config-picocoin.h
index 7bd1cab..1a1cd28 100644
--- a/configs/config-picocoin.h
+++ b/configs/config-picocoin.h
@@ -43,8 +43,6 @@
 #define POLARSSL_MD5_C // ???
 #define POLARSSL_OID_C
 #define POLARSSL_PADLOCK_C
-#define POLARSSL_PEM_PARSE_C // ???
-#define POLARSSL_PEM_WRITE_C // ???
 #define POLARSSL_PK_C
 #define POLARSSL_PK_PARSE_C
 #define POLARSSL_PK_WRITE_C
diff --git a/programs/pkey/key_app_writer.c b/programs/pkey/key_app_writer.c
index c35736f..983b64e 100644
--- a/programs/pkey/key_app_writer.c
+++ b/programs/pkey/key_app_writer.c
@@ -63,8 +63,13 @@
 #define DFL_FILENAME            "keyfile.key"
 #define DFL_DEBUG_LEVEL         0
 #define DFL_OUTPUT_MODE         OUTPUT_MODE_NONE
+#if defined(POLARSSL_PEM_WRITE_C)
 #define DFL_OUTPUT_FILENAME     "keyfile.pem"
 #define DFL_OUTPUT_FORMAT       OUTPUT_FORMAT_PEM
+#else
+#define DFL_OUTPUT_FILENAME     "keyfile.der"
+#define DFL_OUTPUT_FORMAT       OUTPUT_FORMAT_DER
+#endif
 
 /*
  * global options
@@ -88,6 +93,7 @@
 
     memset(output_buf, 0, 16000);
 
+#if defined(POLARSSL_PEM_WRITE_C)
     if( opt.output_format == OUTPUT_FORMAT_PEM )
     {
         if( ( ret = pk_write_pubkey_pem( key, output_buf, 16000 ) ) != 0 )
@@ -96,6 +102,7 @@
         len = strlen( (char *) output_buf );
     }
     else
+#endif
     {
         if( ( ret = pk_write_pubkey_der( key, output_buf, 16000 ) ) < 0 )
             return( ret );
@@ -127,6 +134,8 @@
     size_t len = 0;
 
     memset(output_buf, 0, 16000);
+
+#if defined(POLARSSL_PEM_WRITE_C)
     if( opt.output_format == OUTPUT_FORMAT_PEM )
     {
         if( ( ret = pk_write_key_pem( key, output_buf, 16000 ) ) != 0 )
@@ -135,6 +144,7 @@
         len = strlen( (char *) output_buf );
     }
     else
+#endif
     {
         if( ( ret = pk_write_key_der( key, output_buf, 16000 ) ) < 0 )
             return( ret );
@@ -157,14 +167,23 @@
     return( 0 );
 }
 
+#if defined(POLARSSL_PEM_WRITE_C)
+#define USAGE_OUT \
+    "    output_file=%%s      default: keyfile.pem\n"   \
+    "    output_format=pem|der default: pem\n"
+#else
+#define USAGE_OUT \
+    "    output_file=%%s      default: keyfile.der\n"   \
+    "    output_format=der     default: der\n"
+#endif
+
 #define USAGE \
     "\n usage: key_app param=<>...\n"                   \
     "\n acceptable parameters:\n"                       \
     "    mode=private|public default: none\n"           \
     "    filename=%%s         default: keyfile.key\n"   \
     "    output_mode=private|public default: none\n"    \
-    "    output_file=%%s      default: keyfile.pem\n"   \
-    "    output_format=pem|der default: pem\n"          \
+    USAGE_OUT                                           \
     "\n"
 
 int main( int argc, char *argv[] )
@@ -222,9 +241,12 @@
         }
         else if( strcmp( p, "output_format" ) == 0 )
         {
+#if defined(POLARSSL_PEM_WRITE_C)
             if( strcmp( q, "pem" ) == 0 )
                 opt.output_format = OUTPUT_FORMAT_PEM;
-            else if( strcmp( q, "der" ) == 0 )
+            else
+#endif
+            if( strcmp( q, "der" ) == 0 )
                 opt.output_format = OUTPUT_FORMAT_DER;
             else
                 goto usage;
diff --git a/tests/suites/test_suite_pkwrite.function b/tests/suites/test_suite_pkwrite.function
index 2ea9409..e172315 100644
--- a/tests/suites/test_suite_pkwrite.function
+++ b/tests/suites/test_suite_pkwrite.function
@@ -9,7 +9,7 @@
  * END_DEPENDENCIES
  */
 
-/* BEGIN_CASE */
+/* BEGIN_CASE depends_on:POLARSSL_PEM_WRITE_C */
 void pk_write_pubkey_check( char *key_file )
 {
     pk_context key;
@@ -40,7 +40,7 @@
 }
 /* END_CASE */
 
-/* BEGIN_CASE */
+/* BEGIN_CASE depends_on:POLARSSL_PEM_WRITE_C */
 void pk_write_key_check( char *key_file )
 {
     pk_context key;