Fix typos & Co
diff --git a/include/mbedtls/ecdsa.h b/include/mbedtls/ecdsa.h
index ae6c526..d22e243 100644
--- a/include/mbedtls/ecdsa.h
+++ b/include/mbedtls/ecdsa.h
@@ -138,8 +138,8 @@
  *                  curve is used). POLARSSL_ECDSA_MAX_LEN is always safe.
  *
  * \return          0 if successful,
- *                  or a POLARSSL_ERR_ECP, POLARSSL_ERR_MPI or
- *                  POLARSSL_ERR_ASN1 error code
+ *                  or a POLARSSL_ERR_ECP_XXX, POLARSSL_ERR_MPI_XXX or
+ *                  POLARSSL_ERR_ASN1_XXX error code
  */
 int ecdsa_write_signature( ecdsa_context *ctx, md_type_t md_alg,
                            const unsigned char *hash, size_t hlen,
@@ -174,8 +174,8 @@
  *                  curve is used). POLARSSL_ECDSA_MAX_LEN is always safe.
  *
  * \return          0 if successful,
- *                  or a POLARSSL_ERR_ECP, POLARSSL_ERR_MPI or
- *                  POLARSSL_ERR_ASN1 error code
+ *                  or a POLARSSL_ERR_ECP_XXX, POLARSSL_ERR_MPI_XXX or
+ *                  POLARSSL_ERR_ASN1_XXX error code
  */
 int ecdsa_write_signature_det( ecdsa_context *ctx,
                                const unsigned char *hash, size_t hlen,
@@ -196,9 +196,9 @@
  *
  * \return          0 if successful,
  *                  POLARSSL_ERR_ECP_BAD_INPUT_DATA if signature is invalid,
- *                  POLARSSL_ERR_ECP_SIG_LEN_MISTMATCH if the signature is
+ *                  POLARSSL_ERR_ECP_SIG_LEN_MISMATCH if the signature is
  *                  valid but its actual length is less than siglen,
- *                  or a POLARSSL_ERR_ECP or POLARSSL_ERR_MPI error code
+ *                  or a POLARSSL_ERR_ECP_XXX or POLARSSL_ERR_MPI_XXX error code
  */
 int ecdsa_read_signature( ecdsa_context *ctx,
                           const unsigned char *hash, size_t hlen,
@@ -213,7 +213,7 @@
  * \param f_rng     RNG function
  * \param p_rng     RNG parameter
  *
- * \return          0 on success, or a POLARSSL_ERR_ECP code.
+ * \return          0 on success, or a POLARSSL_ERR_ECP_XXX code.
  */
 int ecdsa_genkey( ecdsa_context *ctx, ecp_group_id gid,
                   int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
@@ -224,7 +224,7 @@
  * \param ctx       ECDSA context to set
  * \param key       EC key to use
  *
- * \return          0 on success, or a POLARSSL_ERR_ECP code.
+ * \return          0 on success, or a POLARSSL_ERR_ECP_XXX code.
  */
 int ecdsa_from_keypair( ecdsa_context *ctx, const ecp_keypair *key );
 
diff --git a/include/mbedtls/md.h b/include/mbedtls/md.h
index 0f1b615..74534f5 100644
--- a/include/mbedtls/md.h
+++ b/include/mbedtls/md.h
@@ -254,8 +254,8 @@
  * \param path     input file name
  * \param output   generic message digest checksum result
  *
- * \return         0 if successful, POLARSSL_ERR_MD_FILE_OPEN_FAILED if fopen
- *                 failed, POLARSSL_ERR_MD_FILE_READ_FAILED if fread failed,
+ * \return         0 if successful,
+ *                 POLARSSL_ERR_MD_FILE_IO_ERROR if file input failed,
  *                 POLARSSL_ERR_MD_BAD_INPUT_DATA if md_info was NULL.
  */
 int md_file( const md_info_t *md_info, const char *path,
diff --git a/include/mbedtls/oid.h b/include/mbedtls/oid.h
index 31a7d2b..11330f2 100644
--- a/include/mbedtls/oid.h
+++ b/include/mbedtls/oid.h
@@ -396,7 +396,7 @@
  * \param oid       OID to translate
  *
  * \return          Length of the string written (excluding final NULL) or
- *                  POLARSSL_ERR_OID_BUF_TO_SMALL in case of error
+ *                  POLARSSL_ERR_OID_BUF_TOO_SMALL in case of error
  */
 int oid_get_numeric_string( char *buf, size_t size, const asn1_buf *oid );
 
diff --git a/include/mbedtls/pkcs12.h b/include/mbedtls/pkcs12.h
index cb53fe2..cc09aa5 100644
--- a/include/mbedtls/pkcs12.h
+++ b/include/mbedtls/pkcs12.h
@@ -58,7 +58,7 @@
  * \param len        data length
  * \param output     the output buffer
  *
- * \return           0 if successful, or a POLARSSL_ERR_xxx code
+ * \return           0 if successful, or a POLARSSL_ERR_XXX code
  */
 int pkcs12_pbe_sha1_rc4_128( asn1_buf *pbe_params, int mode,
                              const unsigned char *pwd,  size_t pwdlen,
@@ -79,7 +79,7 @@
  * \param len        data length
  * \param output     the output buffer
  *
- * \return           0 if successful, or a POLARSSL_ERR_xxx code
+ * \return           0 if successful, or a POLARSSL_ERR_XXX code
  */
 int pkcs12_pbe( asn1_buf *pbe_params, int mode,
                 cipher_type_t cipher_type, md_type_t md_type,
diff --git a/include/mbedtls/pkcs5.h b/include/mbedtls/pkcs5.h
index 5a765e0..f46be12 100644
--- a/include/mbedtls/pkcs5.h
+++ b/include/mbedtls/pkcs5.h
@@ -61,7 +61,7 @@
  * \param datalen    length of data
  * \param output     output buffer
  *
- * \returns        0 on success, or a POLARSSL_ERR_xxx code if verification fails.
+ * \returns        0 on success, or a POLARSSL_ERR_XXX code if verification fails.
  */
 int pkcs5_pbes2( const asn1_buf *pbe_params, int mode,
                  const unsigned char *pwd,  size_t pwdlen,
@@ -80,7 +80,7 @@
  * \param key_length            Length of generated key
  * \param output   Generated key. Must be at least as big as key_length
  *
- * \returns        0 on success, or a POLARSSL_ERR_xxx code if verification fails.
+ * \returns        0 on success, or a POLARSSL_ERR_XXX code if verification fails.
  */
 int pkcs5_pbkdf2_hmac( md_context_t *ctx, const unsigned char *password,
                        size_t plen, const unsigned char *salt, size_t slen,
diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h
index 09aaf37..3fbb25e 100644
--- a/include/mbedtls/ssl.h
+++ b/include/mbedtls/ssl.h
@@ -2037,8 +2037,8 @@
  * \param ssl      SSL context
  *
  * \return         Current maximum record expansion in bytes, or
- *                 POLARSSL_ERR_FEATURE_UNAVAILABLE if compression is enabled,
- *                 which makes expansion much less predictable
+ *                 POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE if compression is
+ *                 enabled, which makes expansion much less predictable
  */
 int ssl_get_record_expansion( const ssl_context *ssl );
 
diff --git a/include/mbedtls/x509_crt.h b/include/mbedtls/x509_crt.h
index 7816801..021031b 100644
--- a/include/mbedtls/x509_crt.h
+++ b/include/mbedtls/x509_crt.h
@@ -227,7 +227,7 @@
  * \param f_vrfy   verification function
  * \param p_vrfy   verification parameter
  *
- * \return         0 if successful or POLARSSL_ERR_X509_SIG_VERIFY_FAILED,
+ * \return         0 if successful or POLARSSL_ERR_X509_CERT_VERIFY_FAILED
  *                 in which case *flags will have one or more of
  *                 the following values set:
  *                      BADCERT_EXPIRED --
@@ -424,7 +424,7 @@
  * \param val       value of the extension OCTET STRING
  * \param val_len   length of the value data
  *
- * \return          0 if successful, or a POLARSSL_ERR_X509WRITE_MALLOC_FAILED
+ * \return          0 if successful, or a POLARSSL_ERR_X509_MALLOC_FAILED
  */
 int x509write_crt_set_extension( x509write_cert *ctx,
                                  const char *oid, size_t oid_len,
@@ -440,7 +440,7 @@
  *                      certificate (only for CA certificates, -1 is
  *                      inlimited)
  *
- * \return          0 if successful, or a POLARSSL_ERR_X509WRITE_MALLOC_FAILED
+ * \return          0 if successful, or a POLARSSL_ERR_X509_MALLOC_FAILED
  */
 int x509write_crt_set_basic_constraints( x509write_cert *ctx,
                                          int is_ca, int max_pathlen );
@@ -453,7 +453,7 @@
  *
  * \param ctx       CRT context to use
  *
- * \return          0 if successful, or a POLARSSL_ERR_X509WRITE_MALLOC_FAILED
+ * \return          0 if successful, or a POLARSSL_ERR_X509_MALLOC_FAILED
  */
 int x509write_crt_set_subject_key_identifier( x509write_cert *ctx );
 
@@ -464,7 +464,7 @@
  *
  * \param ctx       CRT context to use
  *
- * \return          0 if successful, or a POLARSSL_ERR_X509WRITE_MALLOC_FAILED
+ * \return          0 if successful, or a POLARSSL_ERR_X509_MALLOC_FAILED
  */
 int x509write_crt_set_authority_key_identifier( x509write_cert *ctx );
 #endif /* POLARSSL_SHA1_C */
@@ -476,7 +476,7 @@
  * \param ctx       CRT context to use
  * \param key_usage key usage flags to set
  *
- * \return          0 if successful, or POLARSSL_ERR_X509WRITE_MALLOC_FAILED
+ * \return          0 if successful, or POLARSSL_ERR_X509_MALLOC_FAILED
  */
 int x509write_crt_set_key_usage( x509write_cert *ctx, unsigned char key_usage );
 
@@ -487,7 +487,7 @@
  * \param ctx           CRT context to use
  * \param ns_cert_type  Netscape Cert Type flags to set
  *
- * \return          0 if successful, or POLARSSL_ERR_X509WRITE_MALLOC_FAILED
+ * \return          0 if successful, or POLARSSL_ERR_X509_MALLOC_FAILED
  */
 int x509write_crt_set_ns_cert_type( x509write_cert *ctx,
                                     unsigned char ns_cert_type );
diff --git a/include/mbedtls/x509_csr.h b/include/mbedtls/x509_csr.h
index 34f527b..69ff2cc 100644
--- a/include/mbedtls/x509_csr.h
+++ b/include/mbedtls/x509_csr.h
@@ -197,7 +197,7 @@
  * \param ctx       CSR context to use
  * \param key_usage key usage flags to set
  *
- * \return          0 if successful, or POLARSSL_ERR_X509WRITE_MALLOC_FAILED
+ * \return          0 if successful, or POLARSSL_ERR_X509_MALLOC_FAILED
  */
 int x509write_csr_set_key_usage( x509write_csr *ctx, unsigned char key_usage );
 
@@ -208,7 +208,7 @@
  * \param ctx           CSR context to use
  * \param ns_cert_type  Netscape Cert Type flags to set
  *
- * \return          0 if successful, or POLARSSL_ERR_X509WRITE_MALLOC_FAILED
+ * \return          0 if successful, or POLARSSL_ERR_X509_MALLOC_FAILED
  */
 int x509write_csr_set_ns_cert_type( x509write_csr *ctx,
                                     unsigned char ns_cert_type );
@@ -223,7 +223,7 @@
  * \param val       value of the extension OCTET STRING
  * \param val_len   length of the value data
  *
- * \return          0 if successful, or a POLARSSL_ERR_X509WRITE_MALLOC_FAILED
+ * \return          0 if successful, or a POLARSSL_ERR_X509_MALLOC_FAILED
  */
 int x509write_csr_set_extension( x509write_csr *ctx,
                                  const char *oid, size_t oid_len,
diff --git a/library/ctr_drbg.c b/library/ctr_drbg.c
index c3f4b38..aee3833 100644
--- a/library/ctr_drbg.c
+++ b/library/ctr_drbg.c
@@ -170,7 +170,7 @@
     aes_setkey_enc( &aes_ctx, key, CTR_DRBG_KEYBITS );
 
     /*
-     * Reduce data to POLARSSL_CTR_DRBG_SEEDLEN bytes of data
+     * Reduce data to CTR_DRBG_SEEDLEN bytes of data
      */
     for( j = 0; j < CTR_DRBG_SEEDLEN; j += CTR_DRBG_BLOCKSIZE )
     {
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index 73aefc8..db11a80 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -1098,7 +1098,7 @@
         p += 48;
     }
     else
-#endif /* POLARSSL_KEY_EXCHANGE_RSA_PKS_ENABLED */
+#endif /* POLARSSL_KEY_EXCHANGE_RSA_PSK_ENABLED */
 #if defined(POLARSSL_KEY_EXCHANGE_DHE_PSK_ENABLED)
     if( key_ex == POLARSSL_KEY_EXCHANGE_DHE_PSK )
     {
diff --git a/programs/pkey/dh_server.c b/programs/pkey/dh_server.c
index 524e8d6..3d57495 100644
--- a/programs/pkey/dh_server.c
+++ b/programs/pkey/dh_server.c
@@ -61,7 +61,7 @@
     polarssl_printf("POLARSSL_AES_C and/or POLARSSL_DHM_C and/or POLARSSL_ENTROPY_C "
            "and/or POLARSSL_NET_C and/or POLARSSL_RSA_C and/or "
            "POLARSSL_SHA256_C and/or POLARSSL_FS_IO and/or "
-           "POLARSSL_CTR_DBRG_C not defined.\n");
+           "POLARSSL_CTR_DRBG_C not defined.\n");
     return( 0 );
 }
 #else
diff --git a/programs/pkey/key_app_writer.c b/programs/pkey/key_app_writer.c
index 1be0dd3..b0efa08 100644
--- a/programs/pkey/key_app_writer.c
+++ b/programs/pkey/key_app_writer.c
@@ -404,4 +404,4 @@
 
     return( ret );
 }
-#endif /* POLARSSL_X509_WRITE_C && POLARSSL_FS_IO */
+#endif /* POLARSSL_PK_WRITE_C && POLARSSL_FS_IO */
diff --git a/programs/x509/cert_req.c b/programs/x509/cert_req.c
index d1bc976..87e4e12 100644
--- a/programs/x509/cert_req.c
+++ b/programs/x509/cert_req.c
@@ -39,7 +39,7 @@
 int main( void )
 {
     polarssl_printf( "POLARSSL_X509_CSR_WRITE_C and/or POLARSSL_FS_IO and/or "
-            "POLARSSL_PK_PARSE_C and/or POLARSSL_SHA256_c and/or "
+            "POLARSSL_PK_PARSE_C and/or POLARSSL_SHA256_C and/or "
             "POLARSSL_ENTROPY_C and/or POLARSSL_CTR_DRBG_C "
             "not defined.\n");
     return( 0 );
diff --git a/tests/suites/test_suite_x509parse.data b/tests/suites/test_suite_x509parse.data
index 491f14e..8d5d424 100644
--- a/tests/suites/test_suite_x509parse.data
+++ b/tests/suites/test_suite_x509parse.data
@@ -547,11 +547,11 @@
 x509_verify:"data_files/server8_int-ca2.crt":"data_files/test-ca.crt":"data_files/crl-ec-sha256.pem":"NULL":0:0:"NULL"
 
 X509 Certificate verification #50 (Valid, multiple CAs)
-depends_on:POLARSSL_PEM_PARSE_C:POLARSSL_RSA_C:POLARSSL_PKCS1_V15:POLARSSL_ECP_C:POLARSSL_ECP_DP_SECP383R1_ENABLED
+depends_on:POLARSSL_PEM_PARSE_C:POLARSSL_RSA_C:POLARSSL_PKCS1_V15:POLARSSL_ECP_C:POLARSSL_ECP_DP_SECP384R1_ENABLED
 x509_verify:"data_files/server2.crt":"data_files/test-ca_cat12.crt":"data_files/crl.pem":"NULL":0:0:"NULL"
 
 X509 Certificate verification #51 (Valid, multiple CAs, reverse order)
-depends_on:POLARSSL_PEM_PARSE_C:POLARSSL_RSA_C:POLARSSL_PKCS1_V15:POLARSSL_ECP_C:POLARSSL_ECP_DP_SECP383R1_ENABLED
+depends_on:POLARSSL_PEM_PARSE_C:POLARSSL_RSA_C:POLARSSL_PKCS1_V15:POLARSSL_ECP_C:POLARSSL_ECP_DP_SECP384R1_ENABLED
 x509_verify:"data_files/server2.crt":"data_files/test-ca_cat21.crt":"data_files/crl.pem":"NULL":0:0:"NULL"
 
 X509 Certificate verification #52 (CA keyUsage valid)
diff --git a/tests/suites/test_suite_x509parse.function b/tests/suites/test_suite_x509parse.function
index fb5abe5..79b6a0a 100644
--- a/tests/suites/test_suite_x509parse.function
+++ b/tests/suites/test_suite_x509parse.function
@@ -147,7 +147,7 @@
 }
 /* END_CASE */
 
-/* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CRT_C */
+/* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CRT_PARSE_C */
 void x509_dn_gets( char *crt_file, char *entity, char *result_str )
 {
     x509_crt   crt;
@@ -175,7 +175,7 @@
 }
 /* END_CASE */
 
-/* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CRT_C */
+/* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CRT_PARSE_C */
 void x509_time_expired( char *crt_file, char *entity, int result )
 {
     x509_crt   crt;
@@ -196,7 +196,7 @@
 }
 /* END_CASE */
 
-/* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CRT_C */
+/* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_CRT_PARSE_C */
 void x509_time_future( char *crt_file, char *entity, int result )
 {
     x509_crt   crt;