Introduced x509_crt_init(), x509_crl_init() and x509_csr_init()
diff --git a/include/polarssl/x509_crl.h b/include/polarssl/x509_crl.h
index bae8182..2bc7cd8 100644
--- a/include/polarssl/x509_crl.h
+++ b/include/polarssl/x509_crl.h
@@ -135,6 +135,13 @@
                         const x509_crl *crl );
 
 /**
+ * \brief          Initialize a CRL (chain)
+ *
+ * \param crl      CRL chain to initialize
+ */
+void x509_crl_init( x509_crl *crl );
+
+/**
  * \brief          Unallocate all CRL data
  *
  * \param crl      CRL chain to free
diff --git a/include/polarssl/x509_crt.h b/include/polarssl/x509_crt.h
index 55042ec..6378191 100644
--- a/include/polarssl/x509_crt.h
+++ b/include/polarssl/x509_crt.h
@@ -255,6 +255,13 @@
 #endif /* POLARSSL_X509_CRL_PARSE_C */
 
 /**
+ * \brief          Initialize a certificate (chain)
+ *
+ * \param crt      Certificate chain to initialize
+ */
+void x509_crt_init( x509_cert *crt );
+
+/**
  * \brief          Unallocate all certificate data
  *
  * \param crt      Certificate chain to free
diff --git a/include/polarssl/x509_csr.h b/include/polarssl/x509_csr.h
index 32befdb..5b4b1ba 100644
--- a/include/polarssl/x509_csr.h
+++ b/include/polarssl/x509_csr.h
@@ -118,6 +118,13 @@
                         const x509_csr *csr );
 
 /**
+ * \brief          Initialize a CSR
+ *
+ * \param csr      CSR to initialize
+ */
+void x509_csr_init( x509_csr *csr );
+
+/**
  * \brief          Unallocate all CSR data
  *
  * \param csr      CSR to free
diff --git a/library/x509_crl.c b/library/x509_crl.c
index 1a10bc4..e327726 100644
--- a/library/x509_crl.c
+++ b/library/x509_crl.c
@@ -279,7 +279,7 @@
         }
 
         crl = crl->next;
-        memset( crl, 0, sizeof( x509_crl ) );
+        x509_crl_init( crl );
     }
 
 #if defined(POLARSSL_PEM_PARSE_C)
@@ -514,7 +514,7 @@
         }
 
         crl = crl->next;
-        memset( crl, 0, sizeof( x509_crl ) );
+        x509_crl_init( crl );
 
         return( x509parse_crl( crl, buf, buflen ) );
     }
@@ -680,6 +680,14 @@
 }
 
 /*
+ * Initialize a CRL chain
+ */
+void x509_crl_init( x509_crl *crl )
+{
+    memset( crl, 0, sizeof(x509_crl) );
+}
+
+/*
  * Unallocate all CRL data
  */
 void x509_crl_free( x509_crl *crl )
diff --git a/library/x509_crt.c b/library/x509_crt.c
index f57fddc..f73724e 100644
--- a/library/x509_crt.c
+++ b/library/x509_crt.c
@@ -785,7 +785,7 @@
 
         prev = crt;
         crt = crt->next;
-        memset( crt, 0, sizeof( x509_cert ) );
+        x509_crt_init( crt );
     }
 
     if( ( ret = x509parse_crt_der_core( crt, buf, buflen ) ) != 0 )
@@ -1603,6 +1603,14 @@
 }
 
 /*
+ * Initialize a certificate chain
+ */
+void x509_crt_init( x509_cert *crt )
+{
+    memset( crt, 0, sizeof(x509_cert) );
+}
+
+/*
  * Unallocate all certificate data
  */
 void x509_crt_free( x509_cert *crt )
diff --git a/library/x509_csr.c b/library/x509_csr.c
index 30cd1c1..65bc63c 100644
--- a/library/x509_csr.c
+++ b/library/x509_csr.c
@@ -103,7 +103,7 @@
     if( csr == NULL || buf == NULL )
         return( POLARSSL_ERR_X509_BAD_INPUT_DATA );
 
-    memset( csr, 0, sizeof( x509_csr ) );
+    x509_csr_init( csr );
 
 #if defined(POLARSSL_PEM_PARSE_C)
     pem_init( &pem );
@@ -406,6 +406,14 @@
 }
 
 /*
+ * Initialize a CSR
+ */
+void x509_csr_init( x509_csr *csr )
+{
+    memset( csr, 0, sizeof(x509_csr) );
+}
+
+/*
  * Unallocate all CSR data
  */
 void x509_csr_free( x509_csr *csr )
diff --git a/programs/ssl/ssl_client1.c b/programs/ssl/ssl_client1.c
index b7a1e9a..da4fe82 100644
--- a/programs/ssl/ssl_client1.c
+++ b/programs/ssl/ssl_client1.c
@@ -90,7 +90,7 @@
      * 0. Initialize the RNG and the session data
      */
     memset( &ssl, 0, sizeof( ssl_context ) );
-    memset( &cacert, 0, sizeof( x509_cert ) );
+    x509_crt_init( &cacert );
 
     printf( "\n  . Seeding the random number generator..." );
     fflush( stdout );
diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c
index 5ee97b7..d5e43f6 100644
--- a/programs/ssl/ssl_client2.c
+++ b/programs/ssl/ssl_client2.c
@@ -269,8 +269,8 @@
     memset( &ssl, 0, sizeof( ssl_context ) );
     memset( &saved_session, 0, sizeof( ssl_session ) );
 #if defined(POLARSSL_X509_CRT_PARSE_C)
-    memset( &cacert, 0, sizeof( x509_cert ) );
-    memset( &clicert, 0, sizeof( x509_cert ) );
+    x509_crt_init( &cacert );
+    x509_crt_init( &clicert );
     pk_init( &pkey );
 #endif
 
diff --git a/programs/ssl/ssl_fork_server.c b/programs/ssl/ssl_fork_server.c
index af9cef6..df75d92 100644
--- a/programs/ssl/ssl_fork_server.c
+++ b/programs/ssl/ssl_fork_server.c
@@ -134,7 +134,7 @@
     printf( "  . Loading the server cert. and key..." );
     fflush( stdout );
 
-    memset( &srvcert, 0, sizeof( x509_cert ) );
+    x509_crt_init( &srvcert );
 
     /*
      * This demonstration program uses embedded test certificates.
diff --git a/programs/ssl/ssl_mail_client.c b/programs/ssl/ssl_mail_client.c
index f9465ca..a95e2da 100644
--- a/programs/ssl/ssl_mail_client.c
+++ b/programs/ssl/ssl_mail_client.c
@@ -363,8 +363,8 @@
      * Make sure memory references are valid.
      */
     server_fd = 0;
-    memset( &cacert, 0, sizeof( x509_cert ) );
-    memset( &clicert, 0, sizeof( x509_cert ) );
+    x509_crt_init( &cacert );
+    x509_crt_init( &clicert );
     pk_init( &pkey );
 
     if( argc == 0 )
diff --git a/programs/ssl/ssl_server.c b/programs/ssl/ssl_server.c
index 38fa2f2..1929c9e 100644
--- a/programs/ssl/ssl_server.c
+++ b/programs/ssl/ssl_server.c
@@ -114,7 +114,7 @@
     printf( "\n  . Loading the server cert. and key..." );
     fflush( stdout );
 
-    memset( &srvcert, 0, sizeof( x509_cert ) );
+    x509_crt_init( &srvcert );
 
     /*
      * This demonstration program uses embedded test certificates.
diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c
index a7dfa5f..b024e4b 100644
--- a/programs/ssl/ssl_server2.c
+++ b/programs/ssl/ssl_server2.c
@@ -237,8 +237,8 @@
      */
     listen_fd = 0;
 #if defined(POLARSSL_X509_CRT_PARSE_C)
-    memset( &cacert, 0, sizeof( x509_cert ) );
-    memset( &srvcert, 0, sizeof( x509_cert ) );
+    x509_crt_init( &cacert );
+    x509_crt_init( &srvcert );
     pk_init( &pkey );
 #endif
 #if defined(POLARSSL_SSL_CACHE_C)
diff --git a/programs/test/ssl_cert_test.c b/programs/test/ssl_cert_test.c
index f1044cf..9b58a6d 100644
--- a/programs/test/ssl_cert_test.c
+++ b/programs/test/ssl_cert_test.c
@@ -89,8 +89,8 @@
     ((void) argc);
     ((void) argv);
 
-    memset( &cacert, 0, sizeof( x509_cert ) );
-    memset( &crl, 0, sizeof( x509_crl ) );
+    x509_crt_init( &cacert );
+    x509_crl_init( &crl );
 
     /*
      * 1.1. Load the trusted CA
@@ -142,7 +142,7 @@
         x509_cert clicert;
         pk_context pk;
 
-        memset( &clicert, 0, sizeof( x509_cert ) );
+        x509_crt_init( &clicert );
         pk_init( &pk );
 
         snprintf(name, 512, "ssl/test-ca/%s", client_certificates[i]);
diff --git a/programs/test/ssl_test.c b/programs/test/ssl_test.c
index 9d6391d..1677aa9 100644
--- a/programs/test/ssl_test.c
+++ b/programs/test/ssl_test.c
@@ -187,7 +187,7 @@
     memset( read_state, 0, sizeof( read_state ) );
     memset( write_state, 0, sizeof( write_state ) );
 
-    memset( &srvcert, 0, sizeof( x509_cert ) );
+    x509_crt_init( &srvcert );
     pk_init( &pkey );
 
     if( opt->opmode == OPMODE_CLIENT )
diff --git a/programs/x509/cert_app.c b/programs/x509/cert_app.c
index add75a0..160e65d 100644
--- a/programs/x509/cert_app.c
+++ b/programs/x509/cert_app.c
@@ -168,8 +168,8 @@
      * Set to sane values
      */
     server_fd = 0;
-    memset( &cacert, 0, sizeof( x509_cert ) );
-    memset( &clicert, 0, sizeof( x509_cert ) );
+    x509_crt_init( &cacert );
+    x509_crt_init( &clicert );
     pk_init( &pkey );
 
     if( argc == 0 )
@@ -269,7 +269,7 @@
     {
         x509_cert crt;
         x509_cert *cur = &crt;
-        memset( &crt, 0, sizeof( x509_cert ) );
+        x509_crt_init( &crt );
 
         /*
          * 1.1. Load the certificate(s)
diff --git a/programs/x509/cert_write.c b/programs/x509/cert_write.c
index 84b12f6..c50cf81 100644
--- a/programs/x509/cert_write.c
+++ b/programs/x509/cert_write.c
@@ -208,9 +208,9 @@
     pk_init( &loaded_subject_key );
     mpi_init( &serial );
 #if defined(POLARSSL_X509_CSR_PARSE_C)
-    memset( &csr, 0, sizeof(x509_csr) );
+    x509_csr_init( &csr );
 #endif
-    memset( &issuer_crt, 0, sizeof(x509_cert) );
+    x509_crt_init( &issuer_crt );
     memset( buf, 0, 1024 );
 
     if( argc == 0 )
diff --git a/programs/x509/crl_app.c b/programs/x509/crl_app.c
index 1cb9828..2213f81 100644
--- a/programs/x509/crl_app.c
+++ b/programs/x509/crl_app.c
@@ -76,7 +76,7 @@
     /*
      * Set to sane values
      */
-    memset( &crl, 0, sizeof( x509_crl ) );
+    x509_crl_init( &crl );
 
     if( argc == 0 )
     {
diff --git a/programs/x509/req_app.c b/programs/x509/req_app.c
index 5e05d60..3d35524 100644
--- a/programs/x509/req_app.c
+++ b/programs/x509/req_app.c
@@ -76,7 +76,7 @@
     /*
      * Set to sane values
      */
-    memset( &csr, 0, sizeof( x509_csr ) );
+    x509_csr_init( &csr );
 
     if( argc == 0 )
     {
diff --git a/tests/suites/test_suite_debug.function b/tests/suites/test_suite_debug.function
index eb916ba..6bc524b 100644
--- a/tests/suites/test_suite_debug.function
+++ b/tests/suites/test_suite_debug.function
@@ -30,7 +30,7 @@
     ssl_context ssl;
     struct buffer_data buffer;
 
-    memset( &crt, 0, sizeof( x509_cert ) );
+    x509_crt_init( &crt );
     memset( &ssl, 0, sizeof( ssl_context ) );
     memset( buffer.buf, 0, 2000 );
     buffer.ptr = buffer.buf; 
diff --git a/tests/suites/test_suite_x509parse.function b/tests/suites/test_suite_x509parse.function
index 62a6fd5..082dd33 100644
--- a/tests/suites/test_suite_x509parse.function
+++ b/tests/suites/test_suite_x509parse.function
@@ -38,7 +38,7 @@
     char buf[2000];
     int res;
 
-    memset( &crt, 0, sizeof( x509_cert ) );
+    x509_crt_init( &crt );
     memset( buf, 0, 2000 );
 
     TEST_ASSERT( x509parse_crtfile( &crt, crt_file ) == 0 );
@@ -60,7 +60,7 @@
     char buf[2000];
     int res;
 
-    memset( &crl, 0, sizeof( x509_crl ) );
+    x509_crl_init( &crl );
     memset( buf, 0, 2000 );
 
     TEST_ASSERT( x509parse_crlfile( &crl, crl_file ) == 0 );
@@ -88,9 +88,9 @@
     int (*f_vrfy)(void *, x509_cert *, int, int *) = NULL;
     char *      cn_name = NULL;
 
-    memset( &crt, 0, sizeof( x509_cert ) );
-    memset( &ca, 0, sizeof( x509_cert ) );
-    memset( &crl, 0, sizeof( x509_crl ) );
+    x509_crt_init( &crt );
+    x509_crt_init( &ca );
+    x509_crl_init( &crl );
 
     if( strcmp( cn_name_str, "NULL" ) != 0 )
         cn_name = cn_name_str;
@@ -126,7 +126,7 @@
     char buf[2000];
     int res = 0;
 
-    memset( &crt, 0, sizeof( x509_cert ) );
+    x509_crt_init( &crt );
     memset( buf, 0, 2000 );
 
     TEST_ASSERT( x509parse_crtfile( &crt, crt_file ) == 0 );
@@ -151,7 +151,7 @@
 {
     x509_cert   crt;
 
-    memset( &crt, 0, sizeof( x509_cert ) );
+    x509_crt_init( &crt );
 
     TEST_ASSERT( x509parse_crtfile( &crt, crt_file ) == 0 );
 
@@ -174,7 +174,7 @@
     unsigned char output[2000];
     int data_len, res;
 
-    memset( &crt, 0, sizeof( x509_cert ) );
+    x509_crt_init( &crt );
     memset( buf, 0, 2000 );
     memset( output, 0, 2000 );
 
@@ -203,7 +203,7 @@
     unsigned char output[2000];
     int data_len, res;
 
-    memset( &crl, 0, sizeof( x509_crl ) );
+    x509_crl_init( &crl );
     memset( buf, 0, 2000 );
     memset( output, 0, 2000 );