- Functions requiring File System functions can now be disables by undefining POLARSSL_FS_IO
diff --git a/library/x509parse.c b/library/x509parse.c
index c6a9245..3a67539 100644
--- a/library/x509parse.c
+++ b/library/x509parse.c
@@ -51,9 +51,12 @@
#include <string.h>
#include <stdlib.h>
-#include <stdio.h>
#include <time.h>
+#if defined(POLARSSL_FS_IO)
+#include <stdio.h>
+#endif
+
/*
* ASN.1 DER decoding routines
*/
@@ -1739,6 +1742,7 @@
return( 0 );
}
+#if defined(POLARSSL_FS_IO)
/*
* Load all data from a file into a given buffer.
*/
@@ -1811,6 +1815,51 @@
}
/*
+ * Load and parse a private RSA key
+ */
+int x509parse_keyfile( rsa_context *rsa, const char *path, const char *pwd )
+{
+ int ret;
+ size_t n;
+ unsigned char *buf;
+
+ if ( load_file( path, &buf, &n ) )
+ return( 1 );
+
+ if( pwd == NULL )
+ ret = x509parse_key( rsa, buf, (int) n, NULL, 0 );
+ else
+ ret = x509parse_key( rsa, buf, (int) n,
+ (unsigned char *) pwd, strlen( pwd ) );
+
+ memset( buf, 0, n + 1 );
+ free( buf );
+
+ return( ret );
+}
+
+/*
+ * Load and parse a public RSA key
+ */
+int x509parse_public_keyfile( rsa_context *rsa, const char *path )
+{
+ int ret;
+ size_t n;
+ unsigned char *buf;
+
+ if ( load_file( path, &buf, &n ) )
+ return( 1 );
+
+ ret = x509parse_public_key( rsa, buf, (int) n );
+
+ memset( buf, 0, n + 1 );
+ free( buf );
+
+ return( ret );
+}
+#endif /* POLARSSL_FS_IO */
+
+/*
* Parse a private RSA key
*/
int x509parse_key( rsa_context *rsa, const unsigned char *key, size_t keylen,
@@ -1936,30 +1985,6 @@
}
/*
- * Load and parse a private RSA key
- */
-int x509parse_keyfile( rsa_context *rsa, const char *path, const char *pwd )
-{
- int ret;
- size_t n;
- unsigned char *buf;
-
- if ( load_file( path, &buf, &n ) )
- return( 1 );
-
- if( pwd == NULL )
- ret = x509parse_key( rsa, buf, (int) n, NULL, 0 );
- else
- ret = x509parse_key( rsa, buf, (int) n,
- (unsigned char *) pwd, strlen( pwd ) );
-
- memset( buf, 0, n + 1 );
- free( buf );
-
- return( ret );
-}
-
-/*
* Parse a public RSA key
*/
int x509parse_public_key( rsa_context *rsa, const unsigned char *key, size_t keylen )
@@ -2050,26 +2075,6 @@
return( 0 );
}
-/*
- * Load and parse a public RSA key
- */
-int x509parse_public_keyfile( rsa_context *rsa, const char *path )
-{
- int ret;
- size_t n;
- unsigned char *buf;
-
- if ( load_file( path, &buf, &n ) )
- return( 1 );
-
- ret = x509parse_public_key( rsa, buf, (int) n );
-
- memset( buf, 0, n + 1 );
- free( buf );
-
- return( ret );
-}
-
#if defined(POLARSSL_DHM_C)
/*
* Parse DHM parameters
@@ -2154,6 +2159,7 @@
return( 0 );
}
+#if defined(POLARSSL_FS_IO)
/*
* Load and parse a private RSA key
*/
@@ -2173,6 +2179,7 @@
return( ret );
}
+#endif /* POLARSSL_FS_IO */
#endif /* POLARSSL_DHM_C */
#if defined _MSC_VER && !defined snprintf