Avoid non-standard strcasecmp()

This commit is contained in:
Manuel Pégourié-Gonnard 2015-05-28 17:06:07 +02:00
parent 2a84dfd747
commit cb46fd8216
10 changed files with 317 additions and 346 deletions

View file

@ -124,6 +124,12 @@ Default behavior changes
custom config.h
* Default DHM parameters server-side upgraded from 1024 to 2048 bits.
* Negotiation of truncated HMAC is now disabled by default on server too.
* The following functions are now case-sensitive:
mbedtls_cipher_info_from_string()
mbedtls_ecp_curve_info_from_name()
mbedtls_md_info_from_string()
mbedtls_ssl_ciphersuite_from_string()
mbedtls_version_check_feature()
Requirement changes
* The minimum MSVC version required is now 2010 (better C99 support).

View file

@ -50,11 +50,6 @@
#define MBEDTLS_CIPHER_MODE_STREAM
#endif
#if defined(_MSC_VER) && !defined strcasecmp && !defined(EFIX64) && \
!defined(EFI32)
#define strcasecmp _stricmp
#endif
/* Implementation that should never be optimized out by the compiler */
static void mbedtls_zeroize( void *v, size_t n ) {
volatile unsigned char *p = v; while( n-- ) *p++ = 0;
@ -102,7 +97,7 @@ const mbedtls_cipher_info_t *mbedtls_cipher_info_from_string( const char *cipher
return( NULL );
for( def = mbedtls_cipher_definitions; def->info != NULL; def++ )
if( ! strcasecmp( def->info->name, cipher_name ) )
if( ! strcmp( def->info->name, cipher_name ) )
return( def->info );
return( NULL );

View file

@ -63,11 +63,6 @@
#define mbedtls_free free
#endif
#if defined(_MSC_VER) && !defined strcasecmp && !defined(EFIX64) && \
!defined(EFI32)
#define strcasecmp _stricmp
#endif
#if defined(_MSC_VER) && !defined(inline)
#define inline _inline
#else
@ -254,7 +249,7 @@ const mbedtls_ecp_curve_info *mbedtls_ecp_curve_info_from_name( const char *name
curve_info->grp_id != MBEDTLS_ECP_DP_NONE;
curve_info++ )
{
if( strcasecmp( curve_info->name, name ) == 0 )
if( strcmp( curve_info->name, name ) == 0 )
return( curve_info );
}

View file

@ -101,35 +101,35 @@ const mbedtls_md_info_t *mbedtls_md_info_from_string( const char *md_name )
/* Get the appropriate digest information */
#if defined(MBEDTLS_MD2_C)
if( !strcasecmp( "MD2", md_name ) )
if( !strcmp( "MD2", md_name ) )
return mbedtls_md_info_from_type( MBEDTLS_MD_MD2 );
#endif
#if defined(MBEDTLS_MD4_C)
if( !strcasecmp( "MD4", md_name ) )
if( !strcmp( "MD4", md_name ) )
return mbedtls_md_info_from_type( MBEDTLS_MD_MD4 );
#endif
#if defined(MBEDTLS_MD5_C)
if( !strcasecmp( "MD5", md_name ) )
if( !strcmp( "MD5", md_name ) )
return mbedtls_md_info_from_type( MBEDTLS_MD_MD5 );
#endif
#if defined(MBEDTLS_RIPEMD160_C)
if( !strcasecmp( "RIPEMD160", md_name ) )
if( !strcmp( "RIPEMD160", md_name ) )
return mbedtls_md_info_from_type( MBEDTLS_MD_RIPEMD160 );
#endif
#if defined(MBEDTLS_SHA1_C)
if( !strcasecmp( "SHA1", md_name ) || !strcasecmp( "SHA", md_name ) )
if( !strcmp( "SHA1", md_name ) || !strcmp( "SHA", md_name ) )
return mbedtls_md_info_from_type( MBEDTLS_MD_SHA1 );
#endif
#if defined(MBEDTLS_SHA256_C)
if( !strcasecmp( "SHA224", md_name ) )
if( !strcmp( "SHA224", md_name ) )
return mbedtls_md_info_from_type( MBEDTLS_MD_SHA224 );
if( !strcasecmp( "SHA256", md_name ) )
if( !strcmp( "SHA256", md_name ) )
return mbedtls_md_info_from_type( MBEDTLS_MD_SHA256 );
#endif
#if defined(MBEDTLS_SHA512_C)
if( !strcasecmp( "SHA384", md_name ) )
if( !strcmp( "SHA384", md_name ) )
return mbedtls_md_info_from_type( MBEDTLS_MD_SHA384 );
if( !strcasecmp( "SHA512", md_name ) )
if( !strcmp( "SHA512", md_name ) )
return mbedtls_md_info_from_type( MBEDTLS_MD_SHA512 );
#endif
return( NULL );

View file

@ -36,11 +36,6 @@
// #include <stdlib.h>
#include <string.h>
#if defined(_MSC_VER) && !defined strcasecmp && !defined(EFIX64) && \
!defined(EFI32)
#define strcasecmp _stricmp
#endif
/*
* Ordered from most preferred to least preferred in terms of security.
*
@ -1733,7 +1728,7 @@ const mbedtls_ssl_ciphersuite_t *mbedtls_ssl_ciphersuite_from_string(
while( cur->id != 0 )
{
if( 0 == strcasecmp( cur->name, ciphersuite_name ) )
if( 0 == strcmp( cur->name, ciphersuite_name ) )
return( cur );
cur++;

View file

@ -55,11 +55,6 @@
#define mbedtls_free free
#endif
#if defined(_MSC_VER) && !defined strcasecmp && !defined(EFIX64) && \
!defined(EFI32)
#define strcasecmp _stricmp
#endif
/* Implementation that should never be optimized out by the compiler */
static void mbedtls_zeroize( void *v, size_t n ) {
volatile unsigned char *p = v; while( n-- ) *p++ = 0;

View file

@ -32,11 +32,6 @@
#include <string.h>
#if defined(_MSC_VER) && !defined strcasecmp && !defined(EFIX64) && \
!defined(EFI32)
#define strcasecmp _stricmp
#endif
static const char *features[] = {
#if defined(MBEDTLS_VERSION_FEATURES)
#if defined(MBEDTLS_HAVE_ASM)
@ -625,7 +620,7 @@ int mbedtls_version_check_feature( const char *feature )
while( *idx != NULL )
{
if( !strcasecmp( *idx, feature ) )
if( !strcmp( *idx, feature ) )
return( 0 );
idx++;
}

View file

@ -34,11 +34,6 @@
#include <string.h>
#if defined(_MSC_VER) && !defined strncasecmp && !defined(EFIX64) && \
!defined(EFI32)
#define strncasecmp _strnicmp
#endif
typedef struct {
const char *name;
size_t name_len;
@ -86,7 +81,7 @@ static const char *x509_at_oid_from_name( const char *name, size_t name_len )
for( cur = x509_attrs; cur->name != NULL; cur++ )
if( cur->name_len == name_len &&
strncasecmp( cur->name, name, name_len ) == 0 )
strncmp( cur->name, name, name_len ) == 0 )
break;
return( cur->oid );

View file

@ -32,11 +32,6 @@
#include <string.h>
#if defined(_MSC_VER) && !defined strcasecmp && !defined(EFIX64) && \
!defined(EFI32)
#define strcasecmp _stricmp
#endif
static const char *features[] = {
#if defined(MBEDTLS_VERSION_FEATURES)
FEATURE_DEFINES
@ -56,7 +51,7 @@ int mbedtls_version_check_feature( const char *feature )
while( *idx != NULL )
{
if( !strcasecmp( *idx, feature ) )
if( !strcmp( *idx, feature ) )
return( 0 );
idx++;
}

File diff suppressed because it is too large Load diff