Migrated from x509_req_name to asn1_named_data structure
diff --git a/include/polarssl/asn1write.h b/include/polarssl/asn1write.h
index d65ff79..6116502 100644
--- a/include/polarssl/asn1write.h
+++ b/include/polarssl/asn1write.h
@@ -105,10 +105,12 @@
  * \param p         reference to current position pointer
  * \param start     start of the buffer (for bounds-checking)
  * \param oid       the OID to write
+ * \param oid_len   length of the OID
  *
  * \return          the length written or a negative error code
  */
-int asn1_write_oid( unsigned char **p, unsigned char *start, const char *oid );
+int asn1_write_oid( unsigned char **p, unsigned char *start,
+                    const char *oid, size_t oid_len );
 
 /**
  * \brief           Write an AlgorithmIdentifier sequence in ASN.1 format
@@ -118,11 +120,12 @@
  * \param p         reference to current position pointer
  * \param start     start of the buffer (for bounds-checking)
  * \param oid       the OID of the algorithm
+ * \param oid_len   length of the OID
  *
  * \return          the length written or a negative error code
  */
 int asn1_write_algorithm_identifier( unsigned char **p, unsigned char *start,
-                                     const char *oid );
+                                     const char *oid, size_t oid_len );
 
 /**
  * \brief           Write a boolean tag (ASN1_BOOLEAN) and value in ASN.1 format
@@ -156,11 +159,12 @@
  * \param p         reference to current position pointer
  * \param start     start of the buffer (for bounds-checking)
  * \param text      the text to write
+ * \param text_len  length of the text
  *
  * \return          the length written or a negative error code
  */
 int asn1_write_printable_string( unsigned char **p, unsigned char *start,
-                                 char *text );
+                                 const char *text, size_t text_len );
 
 /**
  * \brief           Write an IA5 string tag (ASN1_IA5_STRING) and
@@ -170,11 +174,12 @@
  * \param p         reference to current position pointer
  * \param start     start of the buffer (for bounds-checking)
  * \param text      the text to write
+ * \param text_len  length of the text
  *
  * \return          the length written or a negative error code
  */
 int asn1_write_ia5_string( unsigned char **p, unsigned char *start,
-                                 char *text );
+                           const char *text, size_t text_len );
 
 /**
  * \brief           Write a bitstring tag (ASN1_BIT_STRING) and
diff --git a/include/polarssl/x509write.h b/include/polarssl/x509write.h
index af4d2a1..2e6fa0c 100644
--- a/include/polarssl/x509write.h
+++ b/include/polarssl/x509write.h
@@ -61,24 +61,12 @@
  */
 
 /**
- * Container for CSR named objects
- */
-typedef struct _x509_req_name
-{
-    char oid[128];
-    char name[128];
-
-    struct _x509_req_name *next;
-}
-x509_req_name;
-
-/**
  * Container for a CSR
  */
 typedef struct _x509_csr
 {
     rsa_context *rsa;
-    x509_req_name *subject;
+    asn1_named_data *subject;
     md_type_t md_alg;
     asn1_named_data *extensions;
 }
@@ -100,8 +88,8 @@
     mpi serial;
     rsa_context *subject_key;
     rsa_context *issuer_key;
-    x509_req_name *subject;
-    x509_req_name *issuer;
+    asn1_named_data *subject;
+    asn1_named_data *issuer;
     md_type_t md_alg;
     char not_before[X509_RFC5280_UTC_TIME_LEN + 1];
     char not_after[X509_RFC5280_UTC_TIME_LEN + 1];