Defines for UEFI environment under MSVC added

This commit is contained in:
Paul Bakker 2013-10-28 18:48:30 +01:00
parent 178d9bac3c
commit fa6a620b75
33 changed files with 94 additions and 54 deletions

View File

@ -17,6 +17,7 @@ Bugfix
* Const correctness * Const correctness
* cert_write with selfsign should use issuer_name as subject_name * cert_write with selfsign should use issuer_name as subject_name
* Fix ECDSA corner case: missing reduction mod N (found by DualTachyon) * Fix ECDSA corner case: missing reduction mod N (found by DualTachyon)
* Defines to handle UEFI environment under MSVC
= PolarSSL 1.3.1 released on 2013-10-15 = PolarSSL 1.3.1 released on 2013-10-15
Features Features

View File

@ -31,7 +31,7 @@
#include <string.h> #include <string.h>
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h> #include <basetsd.h>
typedef UINT32 uint32_t; typedef UINT32 uint32_t;
#else #else

View File

@ -32,7 +32,7 @@
#include "config.h" #include "config.h"
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h> #include <basetsd.h>
#if (_MSC_VER <= 1200) #if (_MSC_VER <= 1200)
typedef signed short int16_t; typedef signed short int16_t;

View File

@ -31,7 +31,7 @@
#include <string.h> #include <string.h>
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h> #include <basetsd.h>
typedef UINT32 uint32_t; typedef UINT32 uint32_t;
#else #else

View File

@ -31,7 +31,7 @@
#include <string.h> #include <string.h>
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h> #include <basetsd.h>
typedef UINT32 uint32_t; typedef UINT32 uint32_t;
#else #else

View File

@ -32,7 +32,14 @@
// Comment out to disable prototype change warnings // Comment out to disable prototype change warnings
#define SHOW_PROTOTYPE_CHANGE_WARNINGS #define SHOW_PROTOTYPE_CHANGE_WARNINGS
#if defined _MSC_VER #if defined(_MSC_VER) && !defined(inline)
#define inline _inline
#else
#if defined(__ARMCC_VERSION) && !defined(inline)
#define inline __inline
#endif /* __ARMCC_VERSION */
#if defined(_MSC_VER)
// MSVC does not support #warning // MSVC does not support #warning
#undef SHOW_PROTOTYPE_CHANGE_WARNINGS #undef SHOW_PROTOTYPE_CHANGE_WARNINGS
#endif #endif

View File

@ -31,7 +31,7 @@
#include <string.h> #include <string.h>
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h> #include <basetsd.h>
typedef UINT32 uint32_t; typedef UINT32 uint32_t;
#else #else

View File

@ -29,7 +29,7 @@
#include "cipher.h" #include "cipher.h"
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h> #include <basetsd.h>
typedef UINT32 uint32_t; typedef UINT32 uint32_t;
typedef UINT64 uint64_t; typedef UINT64 uint64_t;

View File

@ -31,7 +31,7 @@
#include <string.h> #include <string.h>
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h> #include <basetsd.h>
typedef UINT32 uint32_t; typedef UINT32 uint32_t;
#else #else

View File

@ -31,7 +31,7 @@
#include <string.h> #include <string.h>
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h> #include <basetsd.h>
typedef UINT32 uint32_t; typedef UINT32 uint32_t;
#else #else

View File

@ -37,7 +37,7 @@
#define POLARSSL_HAVE_X86 #define POLARSSL_HAVE_X86
#endif #endif
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h> #include <basetsd.h>
typedef INT32 int32_t; typedef INT32 int32_t;
#else #else

View File

@ -34,7 +34,7 @@
#include "md.h" #include "md.h"
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h> #include <basetsd.h>
typedef UINT32 uint32_t; typedef UINT32 uint32_t;
#else #else

View File

@ -34,7 +34,7 @@
#include "asn1.h" #include "asn1.h"
#include "md.h" #include "md.h"
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h> #include <basetsd.h>
typedef UINT32 uint32_t; typedef UINT32 uint32_t;
#else #else

View File

@ -31,7 +31,7 @@
#include <string.h> #include <string.h>
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h> #include <basetsd.h>
typedef UINT32 uint32_t; typedef UINT32 uint32_t;
#else #else

View File

@ -31,7 +31,7 @@
#include <string.h> #include <string.h>
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h> #include <basetsd.h>
typedef UINT32 uint32_t; typedef UINT32 uint32_t;
#else #else

View File

@ -31,7 +31,7 @@
#include <string.h> #include <string.h>
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h> #include <basetsd.h>
typedef UINT32 uint32_t; typedef UINT32 uint32_t;
#else #else

View File

@ -29,7 +29,7 @@
#include "polarssl/base64.h" #include "polarssl/base64.h"
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h> #include <basetsd.h>
typedef UINT32 uint32_t; typedef UINT32 uint32_t;
#else #else

View File

@ -44,7 +44,7 @@
#define POLARSSL_CIPHER_MODE_STREAM #define POLARSSL_CIPHER_MODE_STREAM
#endif #endif
#if defined _MSC_VER && !defined strcasecmp #if defined(_MSC_VER) && !defined strcasecmp
#define strcasecmp _stricmp #define strcasecmp _stricmp
#endif #endif

View File

@ -32,11 +32,15 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#if defined _MSC_VER && !defined snprintf #if defined(EFIX64) || defined(EFI32)
#include <stdio.h>
#endif
#if defined(_MSC_VER) && !defined snprintf
#define snprintf _snprintf #define snprintf _snprintf
#endif #endif
#if defined _MSC_VER && !defined vsnprintf #if defined(_MSC_VER) && !defined vsnprintf
#define vsnprintf _vsnprintf #define vsnprintf _vsnprintf
#endif #endif

View File

@ -38,7 +38,7 @@
#endif #endif
#if !defined(POLARSSL_NO_PLATFORM_ENTROPY) #if !defined(POLARSSL_NO_PLATFORM_ENTROPY)
#if defined(_WIN32) #if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
#if !defined(_WIN32_WINNT) #if !defined(_WIN32_WINNT)
#define _WIN32_WINNT 0x0400 #define _WIN32_WINNT 0x0400

View File

@ -160,7 +160,7 @@
#include <string.h> #include <string.h>
#if defined _MSC_VER && !defined snprintf #if defined(_MSC_VER) && !defined snprintf
#define snprintf _snprintf #define snprintf _snprintf
#endif #endif

View File

@ -36,8 +36,8 @@
#include <stdlib.h> #include <stdlib.h>
#if defined _MSC_VER && !defined strcasecmp #if defined(_MSC_VER) && !defined strcasecmp
#define strcasecmp _stricmp #define snprintf _stricmp
#endif #endif
static const int supported_digests[] = { static const int supported_digests[] = {

View File

@ -29,7 +29,8 @@
#include "polarssl/net.h" #include "polarssl/net.h"
#if defined(_WIN32) || defined(_WIN32_WCE) #if (defined(_WIN32) || defined(_WIN32_WCE)) && !defined(EFIX64) && \
!defined(EFI32)
#include <winsock2.h> #include <winsock2.h>
#include <windows.h> #include <windows.h>
@ -64,7 +65,8 @@ static int wsa_init_done = 0;
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || \ #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || \
defined(__DragonflyBSD__) defined(__DragonflyBSD__)
#include <sys/endian.h> #include <sys/endian.h>
#elif defined(__APPLE__) || defined(HAVE_MACHINE_ENDIAN_H) #elif defined(__APPLE__) || defined(HAVE_MACHINE_ENDIAN_H) || \
defined(EFIX64) || defined(EFI32)
#include <machine/endian.h> #include <machine/endian.h>
#elif defined(sun) #elif defined(sun)
#include <sys/isa_defs.h> #include <sys/isa_defs.h>
@ -83,7 +85,7 @@ static int wsa_init_done = 0;
#include <time.h> #include <time.h>
#endif #endif
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h> #include <basetsd.h>
typedef UINT32 uint32_t; typedef UINT32 uint32_t;
#else #else
@ -120,7 +122,9 @@ int net_connect( int *fd, const char *host, int port )
struct sockaddr_in server_addr; struct sockaddr_in server_addr;
struct hostent *server_host; struct hostent *server_host;
#if defined(_WIN32) || defined(_WIN32_WCE) #if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
!defined(EFI32)
WSADATA wsaData; WSADATA wsaData;
if( wsa_init_done == 0 ) if( wsa_init_done == 0 )
@ -131,7 +135,9 @@ int net_connect( int *fd, const char *host, int port )
wsa_init_done = 1; wsa_init_done = 1;
} }
#else #else
#if !defined(EFIX64) && !defined(EFI32)
signal( SIGPIPE, SIG_IGN ); signal( SIGPIPE, SIG_IGN );
#endif
#endif #endif
if( ( server_host = gethostbyname( host ) ) == NULL ) if( ( server_host = gethostbyname( host ) ) == NULL )
@ -165,7 +171,8 @@ int net_bind( int *fd, const char *bind_ip, int port )
int n, c[4]; int n, c[4];
struct sockaddr_in server_addr; struct sockaddr_in server_addr;
#if defined(_WIN32) || defined(_WIN32_WCE) #if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
!defined(EFI32)
WSADATA wsaData; WSADATA wsaData;
if( wsa_init_done == 0 ) if( wsa_init_done == 0 )
@ -176,7 +183,9 @@ int net_bind( int *fd, const char *bind_ip, int port )
wsa_init_done = 1; wsa_init_done = 1;
} }
#else #else
#if !defined(EFIX64) && !defined(EFI32)
signal( SIGPIPE, SIG_IGN ); signal( SIGPIPE, SIG_IGN );
#endif
#endif #endif
if( ( *fd = (int) socket( AF_INET, SOCK_STREAM, IPPROTO_IP ) ) < 0 ) if( ( *fd = (int) socket( AF_INET, SOCK_STREAM, IPPROTO_IP ) ) < 0 )
@ -228,7 +237,8 @@ int net_bind( int *fd, const char *bind_ip, int port )
*/ */
static int net_is_blocking( void ) static int net_is_blocking( void )
{ {
#if defined(_WIN32) || defined(_WIN32_WCE) #if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
!defined(EFI32)
return( WSAGetLastError() == WSAEWOULDBLOCK ); return( WSAGetLastError() == WSAEWOULDBLOCK );
#else #else
switch( errno ) switch( errno )
@ -282,7 +292,8 @@ int net_accept( int bind_fd, int *client_fd, void *client_ip )
*/ */
int net_set_block( int fd ) int net_set_block( int fd )
{ {
#if defined(_WIN32) || defined(_WIN32_WCE) #if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
!defined(EFI32)
u_long n = 0; u_long n = 0;
return( ioctlsocket( fd, FIONBIO, &n ) ); return( ioctlsocket( fd, FIONBIO, &n ) );
#else #else
@ -292,7 +303,8 @@ int net_set_block( int fd )
int net_set_nonblock( int fd ) int net_set_nonblock( int fd )
{ {
#if defined(_WIN32) || defined(_WIN32_WCE) #if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
!defined(EFI32)
u_long n = 1; u_long n = 1;
return( ioctlsocket( fd, FIONBIO, &n ) ); return( ioctlsocket( fd, FIONBIO, &n ) );
#else #else
@ -317,7 +329,7 @@ void net_usleep( unsigned long usec )
* Read at most 'len' characters * Read at most 'len' characters
*/ */
int net_recv( void *ctx, unsigned char *buf, size_t len ) int net_recv( void *ctx, unsigned char *buf, size_t len )
{ {
int ret = read( *((int *) ctx), buf, len ); int ret = read( *((int *) ctx), buf, len );
if( ret < 0 ) if( ret < 0 )
@ -325,7 +337,8 @@ int net_recv( void *ctx, unsigned char *buf, size_t len )
if( net_is_blocking() != 0 ) if( net_is_blocking() != 0 )
return( POLARSSL_ERR_NET_WANT_READ ); return( POLARSSL_ERR_NET_WANT_READ );
#if defined(_WIN32) || defined(_WIN32_WCE) #if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
!defined(EFI32)
if( WSAGetLastError() == WSAECONNRESET ) if( WSAGetLastError() == WSAECONNRESET )
return( POLARSSL_ERR_NET_CONN_RESET ); return( POLARSSL_ERR_NET_CONN_RESET );
#else #else
@ -354,7 +367,8 @@ int net_send( void *ctx, const unsigned char *buf, size_t len )
if( net_is_blocking() != 0 ) if( net_is_blocking() != 0 )
return( POLARSSL_ERR_NET_WANT_WRITE ); return( POLARSSL_ERR_NET_WANT_WRITE );
#if defined(_WIN32) || defined(_WIN32_WCE) #if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \
!defined(EFI32)
if( WSAGetLastError() == WSAECONNRESET ) if( WSAGetLastError() == WSAECONNRESET )
return( POLARSSL_ERR_NET_CONN_RESET ); return( POLARSSL_ERR_NET_CONN_RESET );
#else #else

View File

@ -530,7 +530,7 @@ FN_OID_TYPED_FROM_ASN1(oid_pkcs12_pbe_alg_t, pkcs12_pbe_alg, oid_pkcs12_pbe_alg)
FN_OID_GET_ATTR2(oid_get_pkcs12_pbe_alg, oid_pkcs12_pbe_alg_t, pkcs12_pbe_alg, md_type_t, md_alg, cipher_type_t, cipher_alg); FN_OID_GET_ATTR2(oid_get_pkcs12_pbe_alg, oid_pkcs12_pbe_alg_t, pkcs12_pbe_alg, md_type_t, md_alg, cipher_type_t, cipher_alg);
#endif /* POLARSSL_PKCS12_C */ #endif /* POLARSSL_PKCS12_C */
#if defined _MSC_VER && !defined snprintf #if defined(_MSC_VER) && !defined snprintf
#include <stdarg.h> #include <stdarg.h>
#if !defined vsnprintf #if !defined vsnprintf

View File

@ -34,7 +34,7 @@
#include <stdlib.h> #include <stdlib.h>
#if defined _MSC_VER && !defined strcasecmp #if defined(_MSC_VER) && !defined strcasecmp
#define strcasecmp _stricmp #define strcasecmp _stricmp
#endif #endif

View File

@ -40,7 +40,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
#include <basetsd.h> #include <basetsd.h>
typedef UINT32 uint32_t; typedef UINT32 uint32_t;
#else #else

View File

@ -47,7 +47,7 @@
#include <stdlib.h> #include <stdlib.h>
#if defined _MSC_VER && !defined strcasecmp #if defined(_MSC_VER) && !defined strcasecmp
#define strcasecmp _stricmp #define strcasecmp _stricmp
#endif #endif

View File

@ -29,7 +29,7 @@
#include "polarssl/timing.h" #include "polarssl/timing.h"
#if defined(_WIN32) #if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
#include <windows.h> #include <windows.h>
#include <winbase.h> #include <winbase.h>
@ -172,14 +172,15 @@ unsigned long hardclock( void )
} }
#endif #endif
#if !defined(POLARSSL_HAVE_HARDCLOCK) && defined(_MSC_VER) #if !defined(POLARSSL_HAVE_HARDCLOCK) && defined(_MSC_VER) && \
!defined(EFIX64) && !defined(EFI32)
#define POLARSSL_HAVE_HARDCLOCK #define POLARSSL_HAVE_HARDCLOCK
unsigned long hardclock( void ) unsigned long hardclock( void )
{ {
LARGE_INTEGER offset; LARGE_INTEGER offset;
QueryPerformanceCounter( &offset ); QueryPerformanceCounter( &offset );
return (unsigned long)( offset.QuadPart ); return (unsigned long)( offset.QuadPart );
@ -211,7 +212,7 @@ unsigned long hardclock( void )
volatile int alarmed = 0; volatile int alarmed = 0;
#if defined(_WIN32) #if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
unsigned long get_timer( struct hr_time *val, int reset ) unsigned long get_timer( struct hr_time *val, int reset )
{ {

View File

@ -54,12 +54,16 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#if defined(_WIN32) #if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
#include <windows.h> #include <windows.h>
#else #else
#include <time.h> #include <time.h>
#endif #endif
#if defined(EFIX64) || defined(EFI32)
#include <stdio.h>
#endif
#if defined(POLARSSL_FS_IO) #if defined(POLARSSL_FS_IO)
#include <stdio.h> #include <stdio.h>
#if !defined(_WIN32) #if !defined(_WIN32)
@ -425,7 +429,7 @@ int x509_load_file( const char *path, unsigned char **buf, size_t *n )
} }
#endif /* POLARSSL_FS_IO */ #endif /* POLARSSL_FS_IO */
#if defined _MSC_VER && !defined snprintf #if defined(_MSC_VER) && !defined snprintf
#include <stdarg.h> #include <stdarg.h>
#if !defined vsnprintf #if !defined vsnprintf
@ -620,7 +624,7 @@ int x509_time_expired( const x509_time *to )
int year, mon, day; int year, mon, day;
int hour, min, sec; int hour, min, sec;
#if defined(_WIN32) #if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
SYSTEMTIME st; SYSTEMTIME st;
GetLocalTime(&st); GetLocalTime(&st);

View File

@ -53,13 +53,14 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#if defined(_WIN32) #if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
#include <windows.h> #include <windows.h>
#else #else
#include <time.h> #include <time.h>
#endif #endif
#if defined(POLARSSL_FS_IO) #if defined(POLARSSL_FS_IO) || defined(EFIX64) || defined(EFI32)
#include <stdio.h> #include <stdio.h>
#endif #endif
@ -544,7 +545,7 @@ int x509_crl_parse_file( x509_crl *chain, const char *path )
} }
#endif /* POLARSSL_FS_IO */ #endif /* POLARSSL_FS_IO */
#if defined _MSC_VER && !defined snprintf #if defined(_MSC_VER) && !defined snprintf
#include <stdarg.h> #include <stdarg.h>
#if !defined vsnprintf #if !defined vsnprintf

View File

@ -53,12 +53,16 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#if defined(_WIN32) #if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
#include <windows.h> #include <windows.h>
#else #else
#include <time.h> #include <time.h>
#endif #endif
#if defined(EFIX64) || defined(EFI32)
#include <stdio.h>
#endif
#if defined(POLARSSL_FS_IO) #if defined(POLARSSL_FS_IO)
#include <stdio.h> #include <stdio.h>
#if !defined(_WIN32) #if !defined(_WIN32)
@ -935,7 +939,7 @@ int x509_crt_parse_file( x509_crt *chain, const char *path )
int x509_crt_parse_path( x509_crt *chain, const char *path ) int x509_crt_parse_path( x509_crt *chain, const char *path )
{ {
int ret = 0; int ret = 0;
#if defined(_WIN32) #if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
int w_ret; int w_ret;
WCHAR szDir[MAX_PATH]; WCHAR szDir[MAX_PATH];
char filename[MAX_PATH]; char filename[MAX_PATH];
@ -1035,7 +1039,7 @@ int x509_crt_parse_path( x509_crt *chain, const char *path )
} }
#endif /* POLARSSL_FS_IO */ #endif /* POLARSSL_FS_IO */
#if defined _MSC_VER && !defined snprintf #if defined(_MSC_VER) && !defined snprintf
#include <stdarg.h> #include <stdarg.h>
#if !defined vsnprintf #if !defined vsnprintf

View File

@ -54,7 +54,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#if defined(POLARSSL_FS_IO) #if defined(POLARSSL_FS_IO) || defined(EFIX64) || defined(EFI32)
#include <stdio.h> #include <stdio.h>
#endif #endif
@ -302,7 +302,7 @@ int x509_csr_parse_file( x509_csr *csr, const char *path )
} }
#endif /* POLARSSL_FS_IO */ #endif /* POLARSSL_FS_IO */
#if defined _MSC_VER && !defined snprintf #if defined(_MSC_VER) && !defined snprintf
#include <stdarg.h> #include <stdarg.h>
#if !defined vsnprintf #if !defined vsnprintf

View File

@ -33,7 +33,11 @@ HEADER_INCLUDED
#include <string.h> #include <string.h>
#if defined _MSC_VER && !defined snprintf #if defined(EFIX64) || defined(EFI32)
#include <stdio.h>
#endif
#if defined(_MSC_VER) && !defined snprintf
#define snprintf _snprintf #define snprintf _snprintf
#endif #endif