Move *_pemify() function to PEM module
diff --git a/include/polarssl/pem.h b/include/polarssl/pem.h
index cc6cba1..46d89b0 100644
--- a/include/polarssl/pem.h
+++ b/include/polarssl/pem.h
@@ -88,7 +88,7 @@
  *                  the decrypted text starts with an ASN.1 sequence of
  *                  appropriate length
  *
- * \return          0 on success, ior a specific PEM error code
+ * \return          0 on success, or a specific PEM error code
  */
 int pem_read_buffer( pem_context *ctx, const char *header, const char *footer,
                      const unsigned char *data,
@@ -96,6 +96,26 @@
                      size_t pwdlen, size_t *use_len );
 
 /**
+ * \brief           Write a buffer of PEM information from a DER encoded
+ *                  buffer.
+ *
+ * \param header    header string to write
+ * \param footer    footer string to write
+ * \param der_data  DER data to write
+ * \param der_len   length of the DER data
+ * \param buf       buffer to write to
+ * \param buf_len   length of output buffer
+ * \param olen      total length written / required (if buf_len is not enough)
+ *
+ * \return          0 on success, or a specific PEM or BASE64 error code. On
+ *                  POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL olen is the required
+ *                  size.
+ */
+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
diff --git a/include/polarssl/pk.h b/include/polarssl/pk.h
index e1fdf89..58b6b7c 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_BASE64_C)
+#if defined(POLARSSL_PEM_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_BASE64_C */
+#endif /* POLARSSL_PEM_C */
 #endif /* POLARSSL_PK_WRITE_C */
 
 /*
diff --git a/include/polarssl/x509write.h b/include/polarssl/x509write.h
index d41e708..e90b582 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_BASE64_C)
+#if defined(POLARSSL_PEM_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_BASE64_C */
+#endif /* POLARSSL_PEM_C */
 
 #ifdef __cplusplus
 }