POLARSSL_PEM_C split into POLARSSL_PEM_PARSE_C and POLARSSL_PEM_WRITE_C
diff --git a/include/polarssl/config.h b/include/polarssl/config.h
index 23bbae0..36697bd 100644
--- a/include/polarssl/config.h
+++ b/include/polarssl/config.h
@@ -719,7 +719,7 @@
* TLS_PSK_WITH_AES_128_CBC_SHA
* TLS_PSK_WITH_AES_256_CBC_SHA
*
- * PEM uses AES for decrypting encrypted keys.
+ * PEM_PARSE uses AES for decrypting encrypted keys.
*/
#define POLARSSL_AES_C
@@ -884,7 +884,7 @@
* TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
* TLS_PSK_WITH_3DES_EDE_CBC_SHA
*
- * PEM uses DES/3DES for decrypting encrypted keys.
+ * PEM_PARSE uses DES/3DES for decrypting encrypted keys.
*/
#define POLARSSL_DES_C
@@ -1074,7 +1074,7 @@
* library/x509parse.c
*
* This module is required for SSL/TLS and X.509.
- * PEM uses MD5 for decrypting encrypted keys.
+ * PEM_PARSE uses MD5 for decrypting encrypted keys.
*/
#define POLARSSL_MD5_C
@@ -1156,18 +1156,34 @@
#define POLARSSL_PBKDF2_C
/**
- * \def POLARSSL_PEM_C
+ * \def POLARSSL_PEM_PARSE_C
*
- * Enable PEM decoding
+ * Enable PEM decoding / parsing
*
* Module: library/pem.c
* Caller: library/x509parse.c
+ * library/pkparse.c
*
* Requires: POLARSSL_BASE64_C
*
- * This modules adds support for decoding PEM files.
+ * This modules adds support for decoding / parsing PEM files.
*/
-#define POLARSSL_PEM_C
+#define POLARSSL_PEM_PARSE_C
+
+/**
+ * \def POLARSSL_PEM_WRITE_C
+ *
+ * Enable PEM encoding / writing
+ *
+ * Module: library/pem.c
+ * Caller: library/x509write.c
+ * library/pkwrite.c
+ *
+ * Requires: POLARSSL_BASE64_C
+ *
+ * This modules adds support for encoding / writing PEM files.
+ */
+#define POLARSSL_PEM_WRITE_C
/**
* \def POLARSSL_PK_C
@@ -1586,8 +1602,12 @@
#error "POLARSSL_PBKDF2_C defined, but not all prerequisites"
#endif
-#if defined(POLARSSL_PEM_C) && !defined(POLARSSL_PEM_C)
-#error "POLARSSL_PEM_C defined, but not all prerequisites"
+#if defined(POLARSSL_PEM_PARSE_C) && !defined(POLARSSL_BASE64_C)
+#error "POLARSSL_PEM_PARSE_C defined, but not all prerequisites"
+#endif
+
+#if defined(POLARSSL_PEM_WRITE_C) && !defined(POLARSSL_BASE64_C)
+#error "POLARSSL_PEM_WRITE_C defined, but not all prerequisites"
#endif
#if defined(POLARSSL_PK_PARSE_C) && !defined(POLARSSL_PK_C)
diff --git a/include/polarssl/pem.h b/include/polarssl/pem.h
index 46d89b0..e606cf0 100644
--- a/include/polarssl/pem.h
+++ b/include/polarssl/pem.h
@@ -50,6 +50,7 @@
extern "C" {
#endif
+#if defined(POLARSSL_PEM_PARSE_C)
/**
* \brief PEM context structure
*/
@@ -96,6 +97,15 @@
size_t pwdlen, size_t *use_len );
/**
+ * \brief PEM context memory freeing
+ *
+ * \param ctx context to be freed
+ */
+void pem_free( pem_context *ctx );
+#endif /* POLARSSL_PEM_PARSE_C */
+
+#if defined(POLARSSL_PEM_WRITE_C)
+/**
* \brief Write a buffer of PEM information from a DER encoded
* buffer.
*
@@ -114,13 +124,7 @@
int pem_write_buffer( const char *header, const char *footer,
const unsigned char *der_data, size_t der_len,
unsigned char *buf, size_t buf_len, size_t *olen );
-
-/**
- * \brief PEM context memory freeing
- *
- * \param ctx context to be freed
- */
-void pem_free( pem_context *ctx );
+#endif /* POLARSSL_PEM_WRITE_C */
#ifdef __cplusplus
}
diff --git a/include/polarssl/pk.h b/include/polarssl/pk.h
index 58b6b7c..451a4e3 100644
--- a/include/polarssl/pk.h
+++ b/include/polarssl/pk.h
@@ -477,7 +477,7 @@
*/
int pk_write_pubkey_der( pk_context *key, unsigned char *buf, size_t size );
-#if defined(POLARSSL_PEM_C)
+#if defined(POLARSSL_PEM_WRITE_C)
/**
* \brief Write a public key to a PEM string
*
@@ -499,7 +499,7 @@
* \return 0 successful, or a specific error code
*/
int pk_write_key_pem( pk_context *key, unsigned char *buf, size_t size );
-#endif /* POLARSSL_PEM_C */
+#endif /* POLARSSL_PEM_WRITE_C */
#endif /* POLARSSL_PK_WRITE_C */
/*
diff --git a/include/polarssl/x509write.h b/include/polarssl/x509write.h
index e90b582..72014a6 100644
--- a/include/polarssl/x509write.h
+++ b/include/polarssl/x509write.h
@@ -414,7 +414,7 @@
int (*f_rng)(void *, unsigned char *, size_t),
void *p_rng );
-#if defined(POLARSSL_PEM_C)
+#if defined(POLARSSL_PEM_WRITE_C)
/**
* \brief Write a built up certificate to a X509 PEM string
*
@@ -455,7 +455,7 @@
int x509write_csr_pem( x509write_csr *ctx, unsigned char *buf, size_t size,
int (*f_rng)(void *, unsigned char *, size_t),
void *p_rng );
-#endif /* POLARSSL_PEM_C */
+#endif /* POLARSSL_PEM_WRITE_C */
#ifdef __cplusplus
}