Fixed warnings in case POLARSSL_X509_PARSE_C is not defined

This commit is contained in:
Paul Bakker 2013-09-15 17:06:49 +02:00
parent de56ca1097
commit 2292d1fad0
5 changed files with 21 additions and 10 deletions

View file

@ -29,7 +29,6 @@
#include "config.h" #include "config.h"
#if defined(POLARSSL_X509_PARSE_C) || defined(POLARSSL_X509_WRITE_C)
#include "asn1.h" #include "asn1.h"
#include "dhm.h" #include "dhm.h"
#include "md.h" #include "md.h"
@ -709,5 +708,4 @@ int x509_self_test( int verbose );
} }
#endif #endif
#endif /* POLARSSL_X509_PARSE_C || POLARSSL_X509_WRITE_C */
#endif /* x509.h */ #endif /* x509.h */

View file

@ -32,6 +32,10 @@
#include "polarssl/oid.h" #include "polarssl/oid.h"
#include "polarssl/rsa.h" #include "polarssl/rsa.h"
#if defined(POLARSSL_X509_PARSE_C) || defined(POLARSSL_X509_WRITE_C)
#include "polarssl/x509.h"
#endif
#include <stdio.h> #include <stdio.h>
/* /*

View file

@ -105,7 +105,6 @@ static int ssl_save_session( const ssl_session *session,
static int ssl_load_session( ssl_session *session, static int ssl_load_session( ssl_session *session,
const unsigned char *buf, size_t len ) const unsigned char *buf, size_t len )
{ {
int ret;
const unsigned char *p = buf; const unsigned char *p = buf;
const unsigned char * const end = buf + len; const unsigned char * const end = buf + len;
#if defined(POLARSSL_X509_PARSE_C) #if defined(POLARSSL_X509_PARSE_C)
@ -131,6 +130,8 @@ static int ssl_load_session( ssl_session *session,
} }
else else
{ {
int ret;
if( p + cert_len > end ) if( p + cert_len > end )
return( POLARSSL_ERR_SSL_BAD_INPUT_DATA ); return( POLARSSL_ERR_SSL_BAD_INPUT_DATA );
@ -1834,14 +1835,19 @@ static int ssl_write_server_key_exchange( ssl_context *ssl )
{ {
int ret; int ret;
size_t n = 0, len; size_t n = 0, len;
unsigned char hash[64];
md_type_t md_alg = POLARSSL_MD_NONE;
unsigned int hashlen = 0;
unsigned char *p = ssl->out_msg + 4; unsigned char *p = ssl->out_msg + 4;
const ssl_ciphersuite_t *ciphersuite_info;
#if defined(POLARSSL_KEY_EXCHANGE_DHE_RSA_ENABLED) || \
defined(POLARSSL_KEY_EXCHANGE_DHE_PSK_ENABLED) || \
defined(POLARSSL_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \
defined(POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
unsigned char *dig_signed = p; unsigned char *dig_signed = p;
size_t dig_signed_len = 0; size_t dig_signed_len = 0;
((void) dig_signed);
((void) dig_signed_len);
#endif
const ssl_ciphersuite_t *ciphersuite_info;
ciphersuite_info = ssl->transform_negotiate->ciphersuite_info; ciphersuite_info = ssl->transform_negotiate->ciphersuite_info;
SSL_DEBUG_MSG( 2, ( "=> write server key exchange" ) ); SSL_DEBUG_MSG( 2, ( "=> write server key exchange" ) );
@ -1959,6 +1965,9 @@ static int ssl_write_server_key_exchange( ssl_context *ssl )
ciphersuite_info->key_exchange == POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA ) ciphersuite_info->key_exchange == POLARSSL_KEY_EXCHANGE_ECDHE_ECDSA )
{ {
size_t signature_len = 0; size_t signature_len = 0;
unsigned int hashlen = 0;
unsigned char hash[64];
md_type_t md_alg = POLARSSL_MD_NONE;
/* /*
* Choose hash algorithm. NONE means MD5 + SHA1 here. * Choose hash algorithm. NONE means MD5 + SHA1 here.

View file

@ -72,14 +72,14 @@ static unsigned int mfl_code_to_length[SSL_MAX_FRAG_LEN_INVALID] =
static int ssl_session_copy( ssl_session *dst, const ssl_session *src ) static int ssl_session_copy( ssl_session *dst, const ssl_session *src )
{ {
int ret;
ssl_session_free( dst ); ssl_session_free( dst );
memcpy( dst, src, sizeof( ssl_session ) ); memcpy( dst, src, sizeof( ssl_session ) );
#if defined(POLARSSL_X509_PARSE_C) #if defined(POLARSSL_X509_PARSE_C)
if( src->peer_cert != NULL ) if( src->peer_cert != NULL )
{ {
int ret;
if( ( dst->peer_cert = polarssl_malloc( sizeof(x509_cert) ) ) == NULL ) if( ( dst->peer_cert = polarssl_malloc( sizeof(x509_cert) ) ) == NULL )
return( POLARSSL_ERR_SSL_MALLOC_FAILED ); return( POLARSSL_ERR_SSL_MALLOC_FAILED );

View file

@ -22,7 +22,7 @@ void string_debug(void *data, int level, const char *str)
* END_DEPENDENCIES * END_DEPENDENCIES
*/ */
/* BEGIN_CASE depends_on:POLARSSL_FS_IO */ /* BEGIN_CASE depends_on:POLARSSL_FS_IO:POLARSSL_X509_PARSE_C */
void debug_print_crt( char *crt_file, char *file, int line, char *prefix, void debug_print_crt( char *crt_file, char *file, int line, char *prefix,
char *result_str ) char *result_str )
{ {