- Merged changes from trunk to PolarSSL 1.1 branch
diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
index bd676d2..de72735 100644
--- a/library/CMakeLists.txt
+++ b/library/CMakeLists.txt
@@ -47,7 +47,7 @@
else(NOT USE_SHARED_POLARSSL_LIBRARY)
add_library(polarssl SHARED ${src})
-set_target_properties(polarssl PROPERTIES VERSION 1.1.0 SOVERSION 1)
+set_target_properties(polarssl PROPERTIES VERSION 1.1.1 SOVERSION 1)
endif(NOT USE_SHARED_POLARSSL_LIBRARY)
diff --git a/library/cipher.c b/library/cipher.c
index 2a9da25..485a09b 100644
--- a/library/cipher.c
+++ b/library/cipher.c
@@ -94,7 +94,7 @@
return supported_ciphers;
}
-const cipher_info_t *cipher_info_from_type( cipher_type_t cipher_type )
+const cipher_info_t *cipher_info_from_type( const cipher_type_t cipher_type )
{
/* Find static cipher information */
switch ( cipher_type )
@@ -433,11 +433,10 @@
output[data_len + i] = (unsigned char) padding_len;
}
-static int get_pkcs_padding( unsigned char *input, unsigned char input_len,
+static int get_pkcs_padding( unsigned char *input, unsigned int input_len,
size_t *data_len)
{
- int i = 0;
- unsigned char padding_len = 0;
+ unsigned int i, padding_len = 0;
if( NULL == input || NULL == data_len )
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
diff --git a/library/ctr_drbg.c b/library/ctr_drbg.c
index 5b610a2..882d686 100644
--- a/library/ctr_drbg.c
+++ b/library/ctr_drbg.c
@@ -470,7 +470,7 @@
printf( " CTR_DRBG (PR = TRUE) : " );
test_offset = 0;
- if( ctr_drbg_init( &ctx, ctr_drbg_self_test_entropy, entropy_source_pr, nonce_pers_pr, 16 ) != 0 )
+ if( ctr_drbg_init_entropy_len( &ctx, ctr_drbg_self_test_entropy, entropy_source_pr, nonce_pers_pr, 16, 32 ) != 0 )
{
if( verbose != 0 )
printf( "failed\n" );
@@ -513,7 +513,7 @@
printf( " CTR_DRBG (PR = FALSE): " );
test_offset = 0;
- if( ctr_drbg_init( &ctx, ctr_drbg_self_test_entropy, entropy_source_nopr, nonce_pers_nopr, 16 ) != 0 )
+ if( ctr_drbg_init_entropy_len( &ctx, ctr_drbg_self_test_entropy, entropy_source_nopr, nonce_pers_nopr, 16, 32 ) != 0 )
{
if( verbose != 0 )
printf( "failed\n" );
diff --git a/library/error.c b/library/error.c
index 5dcd175..9bc5034 100644
--- a/library/error.c
+++ b/library/error.c
@@ -177,10 +177,8 @@
snprintf( buf, buflen, "MD - Bad input parameters to function" );
if( use_ret == -(POLARSSL_ERR_MD_ALLOC_FAILED) )
snprintf( buf, buflen, "MD - Failed to allocate memory" );
- if( use_ret == -(POLARSSL_ERR_MD_FILE_OPEN_FAILED) )
- snprintf( buf, buflen, "MD - Opening of file failed" );
- if( use_ret == -(POLARSSL_ERR_MD_FILE_READ_FAILED) )
- snprintf( buf, buflen, "MD - Failure when reading from file" );
+ if( use_ret == -(POLARSSL_ERR_MD_FILE_IO_ERROR) )
+ snprintf( buf, buflen, "MD - Opening or reading of file failed" );
#endif /* POLARSSL_MD_C */
#if defined(POLARSSL_PEM_C)
diff --git a/library/md.c b/library/md.c
index 51fb82e..d15bf1d 100644
--- a/library/md.c
+++ b/library/md.c
@@ -222,19 +222,19 @@
int md_file( const md_info_t *md_info, const char *path, unsigned char *output )
{
+#if defined(POLARSSL_FS_IO)
int ret;
+#endif
if( md_info == NULL )
return POLARSSL_ERR_MD_BAD_INPUT_DATA;
#if defined(POLARSSL_FS_IO)
ret = md_info->file_func( path, output );
- if( ret == 2 )
- return POLARSSL_ERR_MD_FILE_OPEN_FAILED;
- if( ret == 3 )
- return POLARSSL_ERR_MD_FILE_READ_FAILED;
+ if( ret != 0 )
+ return( POLARSSL_ERR_MD_FILE_IO_ERROR + ret );
- return ret;
+ return( ret );
#else
((void) path);
((void) output);
diff --git a/library/rsa.c b/library/rsa.c
index 3133b2f..ed1f45b 100644
--- a/library/rsa.c
+++ b/library/rsa.c
@@ -362,7 +362,8 @@
const unsigned char *input,
unsigned char *output )
{
- size_t nb_pad, olen, ret;
+ size_t nb_pad, olen;
+ int ret;
unsigned char *p = output;
#if defined(POLARSSL_PKCS1_V21)
unsigned int hlen;
@@ -592,7 +593,8 @@
unsigned char *p = sig;
#if defined(POLARSSL_PKCS1_V21)
unsigned char salt[POLARSSL_MD_MAX_SIZE];
- unsigned int slen, hlen, offset = 0, ret;
+ unsigned int slen, hlen, offset = 0;
+ int ret;
size_t msb;
const md_info_t *md_info;
md_context_t md_ctx;
diff --git a/library/ssl_cli.c b/library/ssl_cli.c
index 08aaf80..95ceea6 100644
--- a/library/ssl_cli.c
+++ b/library/ssl_cli.c
@@ -178,7 +178,9 @@
static int ssl_parse_server_hello( ssl_context *ssl )
{
+#if defined(POLARSSL_DEBUG_MSG) && defined(POLARSSL_DEBUG_C)
time_t t;
+#endif
int ret, i;
size_t n;
int ext_len;
@@ -226,10 +228,12 @@
ssl->minor_ver = buf[5];
+#if defined(POLARSSL_DEBUG_MSG) && defined(POLARSSL_DEBUG_C)
t = ( (time_t) buf[6] << 24 )
| ( (time_t) buf[7] << 16 )
| ( (time_t) buf[8] << 8 )
| ( (time_t) buf[9] );
+#endif
memcpy( ssl->randbytes + 32, buf + 6, 32 );
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index 545317a..44e972c 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -1913,6 +1913,9 @@
ssl->hostname_len = strlen( hostname );
ssl->hostname = (unsigned char *) malloc( ssl->hostname_len + 1 );
+ if( ssl->hostname == NULL )
+ return( POLARSSL_ERR_SSL_MALLOC_FAILED );
+
memcpy( ssl->hostname, (unsigned char *) hostname,
ssl->hostname_len );
diff --git a/library/x509parse.c b/library/x509parse.c
index f561754..ec4fffc 100644
--- a/library/x509parse.c
+++ b/library/x509parse.c
@@ -968,6 +968,10 @@
if ( *p < end )
{
cur_entry->next = malloc( sizeof( x509_crl_entry ) );
+
+ if( cur_entry->next == NULL )
+ return( POLARSSL_ERR_X509_MALLOC_FAILED );
+
cur_entry = cur_entry->next;
memset( cur_entry, 0, sizeof( x509_crl_entry ) );
}