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,