- Merged changes from trunk to PolarSSL 1.1 branch

diff --git a/include/polarssl/asn1.h b/include/polarssl/asn1.h
index 8daef5a..bc7b6bb 100644
--- a/include/polarssl/asn1.h
+++ b/include/polarssl/asn1.h
@@ -212,6 +212,7 @@
  * \param p     The position in the ASN.1 data
  * \param end   End of data
  * \param cur   First variable in the chain to fill
+ * \param tag   Type of sequence
  *
  * \return      0 if successful or a specific ASN.1 error code.
  */
diff --git a/include/polarssl/bignum.h b/include/polarssl/bignum.h
index f830c08..ad03308 100644
--- a/include/polarssl/bignum.h
+++ b/include/polarssl/bignum.h
@@ -30,6 +30,8 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "config.h"
+
 #define POLARSSL_ERR_MPI_FILE_IO_ERROR                     -0x0002  /**< An error occurred while reading from or writing to a file. */
 #define POLARSSL_ERR_MPI_BAD_INPUT_DATA                    -0x0004  /**< Bad input parameters to function. */
 #define POLARSSL_ERR_MPI_INVALID_CHARACTER                 -0x0006  /**< There is an invalid character in the digit string. */
@@ -95,12 +97,14 @@
   #if defined(_MSC_VER) && defined(_M_IX86)
   typedef unsigned __int64 t_udbl;
   #else
-    #if defined(__amd64__) || defined(__x86_64__)    || \
+    #if defined(__GNUC__) && (                          \
+        defined(__amd64__) || defined(__x86_64__)    || \
         defined(__ppc64__) || defined(__powerpc64__) || \
         defined(__ia64__)  || defined(__alpha__)     || \
         (defined(__sparc__) && defined(__arch64__))  || \
-        defined(__s390x__)
+        defined(__s390x__) )
     typedef unsigned int t_udbl __attribute__((mode(TI)));
+    #define POLARSSL_HAVE_LONGLONG
     #else
       #if defined(POLARSSL_HAVE_LONGLONG)
       typedef unsigned long long t_udbl;
diff --git a/include/polarssl/bn_mul.h b/include/polarssl/bn_mul.h
index f278dd0..a6a2c65 100644
--- a/include/polarssl/bn_mul.h
+++ b/include/polarssl/bn_mul.h
@@ -41,7 +41,7 @@
 #ifndef POLARSSL_BN_MUL_H
 #define POLARSSL_BN_MUL_H
 
-#include "config.h"
+#include "bignum.h"
 
 #if defined(POLARSSL_HAVE_ASM)
 
diff --git a/include/polarssl/error.h b/include/polarssl/error.h
index 78ad362..9c17071 100644
--- a/include/polarssl/error.h
+++ b/include/polarssl/error.h
@@ -72,8 +72,8 @@
  * X509     2   21
  * DHM      3   6
  * RSA      4   9
- * MD       5   1
- * CIPER    6   1
+ * MD       5   4
+ * CIPHER   6   5
  * SSL      7   30
  *
  * Module dependent error code (5 bits 0x.08.-0x.F8.)
diff --git a/include/polarssl/md.h b/include/polarssl/md.h
index f62ef20..88596cb 100644
--- a/include/polarssl/md.h
+++ b/include/polarssl/md.h
@@ -42,8 +42,7 @@
 #define POLARSSL_ERR_MD_FEATURE_UNAVAILABLE                -0x5080  /**< The selected feature is not available. */
 #define POLARSSL_ERR_MD_BAD_INPUT_DATA                     -0x5100  /**< Bad input parameters to function. */
 #define POLARSSL_ERR_MD_ALLOC_FAILED                       -0x5180  /**< Failed to allocate memory. */
-#define POLARSSL_ERR_MD_FILE_OPEN_FAILED                   -0x5200  /**< Opening of file failed. */
-#define POLARSSL_ERR_MD_FILE_READ_FAILED                   -0x5280  /**< Failure when reading from file. */
+#define POLARSSL_ERR_MD_FILE_IO_ERROR                      -0x5200  /**< Opening or reading of file failed. */
 
 typedef enum {
     POLARSSL_MD_NONE=0,
diff --git a/include/polarssl/ssl.h b/include/polarssl/ssl.h
index c897a1e..74c5d2d 100644
--- a/include/polarssl/ssl.h
+++ b/include/polarssl/ssl.h
@@ -562,7 +562,7 @@
  * \param ssl      SSL context
  * \param hostname the server hostname
  *
- * \return         0 if successful
+ * \return         0 if successful or POLARSSL_ERR_SSL_MALLOC_FAILED
  */
 int ssl_set_hostname( ssl_context *ssl, const char *hostname );
 
diff --git a/include/polarssl/version.h b/include/polarssl/version.h
index 13f1420..98eb0b3 100644
--- a/include/polarssl/version.h
+++ b/include/polarssl/version.h
@@ -39,16 +39,16 @@
  */
 #define POLARSSL_VERSION_MAJOR  1
 #define POLARSSL_VERSION_MINOR  1
-#define POLARSSL_VERSION_PATCH  0
+#define POLARSSL_VERSION_PATCH  1
 
 /**
  * The single version number has the following structure:
  *    MMNNPP00
  *    Major version | Minor version | Patch version
  */
-#define POLARSSL_VERSION_NUMBER         0x01010000
-#define POLARSSL_VERSION_STRING         "1.1.0"
-#define POLARSSL_VERSION_STRING_FULL    "PolarSSL 1.1.0"
+#define POLARSSL_VERSION_NUMBER         0x01010100
+#define POLARSSL_VERSION_STRING         "1.1.1"
+#define POLARSSL_VERSION_STRING_FULL    "PolarSSL 1.1.1"
 
 #if defined(POLARSSL_VERSION_C)