forked from wolfSSL/wolfssl
1
IDE/WIN/user_settings.h
Executable file → Normal file
1
IDE/WIN/user_settings.h
Executable file → Normal file
@@ -25,6 +25,7 @@
|
|||||||
#else
|
#else
|
||||||
/* Enables blinding mode, to prevent timing attacks */
|
/* Enables blinding mode, to prevent timing attacks */
|
||||||
#define WC_RSA_BLINDING
|
#define WC_RSA_BLINDING
|
||||||
|
#define NO_MULTIBYTE_PRINT
|
||||||
|
|
||||||
#if defined(WOLFSSL_LIB)
|
#if defined(WOLFSSL_LIB)
|
||||||
/* The lib */
|
/* The lib */
|
||||||
|
@@ -447,18 +447,18 @@ static int SocketRecv(int sockFd, char* buf, int sz)
|
|||||||
int recvd = (int)recv(sockFd, buf, sz, 0);
|
int recvd = (int)recv(sockFd, buf, sz, 0);
|
||||||
if (recvd == -1) {
|
if (recvd == -1) {
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
#if EAGAIN != EWOULDBLOCK
|
#if EAGAIN != SOCKET_EWOULDBLOCK
|
||||||
case EAGAIN: /* EAGAIN == EWOULDBLOCK on some systems, but not others */
|
case EAGAIN: /* EAGAIN == EWOULDBLOCK on some systems, but not others */
|
||||||
#endif
|
#endif
|
||||||
case EWOULDBLOCK:
|
case SOCKET_EWOULDBLOCK:
|
||||||
return WOLFSSL_CBIO_ERR_WANT_READ;
|
return WOLFSSL_CBIO_ERR_WANT_READ;
|
||||||
case ECONNRESET:
|
case SOCKET_ECONNRESET:
|
||||||
return WOLFSSL_CBIO_ERR_CONN_RST;
|
return WOLFSSL_CBIO_ERR_CONN_RST;
|
||||||
case EINTR:
|
case SOCKET_EINTR:
|
||||||
return WOLFSSL_CBIO_ERR_ISR;
|
return WOLFSSL_CBIO_ERR_ISR;
|
||||||
case ECONNREFUSED: /* DTLS case */
|
case SOCKET_ECONNREFUSED: /* DTLS case */
|
||||||
return WOLFSSL_CBIO_ERR_WANT_READ;
|
return WOLFSSL_CBIO_ERR_WANT_READ;
|
||||||
case ECONNABORTED:
|
case SOCKET_ECONNABORTED:
|
||||||
return WOLFSSL_CBIO_ERR_CONN_CLOSE;
|
return WOLFSSL_CBIO_ERR_CONN_CLOSE;
|
||||||
default:
|
default:
|
||||||
return WOLFSSL_CBIO_ERR_GENERAL;
|
return WOLFSSL_CBIO_ERR_GENERAL;
|
||||||
@@ -475,16 +475,16 @@ static int SocketSend(int sockFd, char* buf, int sz)
|
|||||||
int sent = (int)send(sockFd, buf, sz, 0);
|
int sent = (int)send(sockFd, buf, sz, 0);
|
||||||
if (sent == -1) {
|
if (sent == -1) {
|
||||||
switch (errno) {
|
switch (errno) {
|
||||||
#if EAGAIN != EWOULDBLOCK
|
#if EAGAIN != SOCKET_EWOULDBLOCK
|
||||||
case EAGAIN: /* EAGAIN == EWOULDBLOCK on some systems, but not others */
|
case EAGAIN: /* EAGAIN == EWOULDBLOCK on some systems, but not others */
|
||||||
#endif
|
#endif
|
||||||
case EWOULDBLOCK:
|
case SOCKET_EWOULDBLOCK:
|
||||||
return WOLFSSL_CBIO_ERR_WANT_READ;
|
return WOLFSSL_CBIO_ERR_WANT_READ;
|
||||||
case ECONNRESET:
|
case SOCKET_ECONNRESET:
|
||||||
return WOLFSSL_CBIO_ERR_CONN_RST;
|
return WOLFSSL_CBIO_ERR_CONN_RST;
|
||||||
case EINTR:
|
case SOCKET_EINTR:
|
||||||
return WOLFSSL_CBIO_ERR_ISR;
|
return WOLFSSL_CBIO_ERR_ISR;
|
||||||
case EPIPE:
|
case SOCKET_EPIPE:
|
||||||
return WOLFSSL_CBIO_ERR_CONN_CLOSE;
|
return WOLFSSL_CBIO_ERR_CONN_CLOSE;
|
||||||
default:
|
default:
|
||||||
return WOLFSSL_CBIO_ERR_GENERAL;
|
return WOLFSSL_CBIO_ERR_GENERAL;
|
||||||
@@ -873,7 +873,11 @@ static void* client_thread(void* args)
|
|||||||
static int SetupSocketAndListen(int* listenFd, word32 port)
|
static int SetupSocketAndListen(int* listenFd, word32 port)
|
||||||
{
|
{
|
||||||
struct sockaddr_in servAddr;
|
struct sockaddr_in servAddr;
|
||||||
|
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||||
|
char optval = 1;
|
||||||
|
#else
|
||||||
int optval = 1;
|
int optval = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Setup server address */
|
/* Setup server address */
|
||||||
XMEMSET(&servAddr, 0, sizeof(servAddr));
|
XMEMSET(&servAddr, 0, sizeof(servAddr));
|
||||||
@@ -890,7 +894,8 @@ static int SetupSocketAndListen(int* listenFd, word32 port)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* allow reuse */
|
/* allow reuse */
|
||||||
if (setsockopt(*listenFd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) == -1) {
|
if (setsockopt(*listenFd, SOL_SOCKET, SO_REUSEADDR,
|
||||||
|
&optval, sizeof(optval)) == -1) {
|
||||||
printf("setsockopt SO_REUSEADDR failed\n");
|
printf("setsockopt SO_REUSEADDR failed\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -923,7 +928,7 @@ static int SocketWaitClient(info_t* info)
|
|||||||
socklen_t size = sizeof(clientAddr);
|
socklen_t size = sizeof(clientAddr);
|
||||||
|
|
||||||
if ((connd = accept(info->listenFd, (struct sockaddr*)&clientAddr, &size)) == -1) {
|
if ((connd = accept(info->listenFd, (struct sockaddr*)&clientAddr, &size)) == -1) {
|
||||||
if (errno == EWOULDBLOCK)
|
if (errno == SOCKET_EWOULDBLOCK)
|
||||||
return -2;
|
return -2;
|
||||||
printf("ERROR: failed to accept the connection\n");
|
printf("ERROR: failed to accept the connection\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
@@ -631,7 +631,11 @@ static int ClientBenchmarkThroughput(WOLFSSL_CTX* ctx, char* host, word16 port,
|
|||||||
wolfSSL_free(ssl); ssl = NULL;
|
wolfSSL_free(ssl); ssl = NULL;
|
||||||
CloseSocket(sockfd);
|
CloseSocket(sockfd);
|
||||||
|
|
||||||
|
#if !defined(__MINGW32__)
|
||||||
printf("wolfSSL Client Benchmark %zu bytes\n"
|
printf("wolfSSL Client Benchmark %zu bytes\n"
|
||||||
|
#else
|
||||||
|
printf("wolfSSL Client Benchmark %d bytes\n"
|
||||||
|
#endif
|
||||||
"\tConnect %8.3f ms\n"
|
"\tConnect %8.3f ms\n"
|
||||||
"\tTX %8.3f ms (%8.3f MBps)\n"
|
"\tTX %8.3f ms (%8.3f MBps)\n"
|
||||||
"\tRX %8.3f ms (%8.3f MBps)\n",
|
"\tRX %8.3f ms (%8.3f MBps)\n",
|
||||||
|
@@ -417,7 +417,11 @@ int ServerEchoData(SSL* ssl, int clientfd, int echoData, int block,
|
|||||||
free(buffer);
|
free(buffer);
|
||||||
|
|
||||||
if (throughput) {
|
if (throughput) {
|
||||||
|
#if !defined(__MINGW32__)
|
||||||
printf("wolfSSL Server Benchmark %zu bytes\n"
|
printf("wolfSSL Server Benchmark %zu bytes\n"
|
||||||
|
#else
|
||||||
|
printf("wolfSSL Server Benchmark %d bytes\n"
|
||||||
|
#endif
|
||||||
"\tRX %8.3f ms (%8.3f MBps)\n"
|
"\tRX %8.3f ms (%8.3f MBps)\n"
|
||||||
"\tTX %8.3f ms (%8.3f MBps)\n",
|
"\tTX %8.3f ms (%8.3f MBps)\n",
|
||||||
throughput,
|
throughput,
|
||||||
|
@@ -483,7 +483,9 @@
|
|||||||
#else
|
#else
|
||||||
/* 4996 warning to use MS extensions e.g., _sprintf_s
|
/* 4996 warning to use MS extensions e.g., _sprintf_s
|
||||||
instead of _snprintf */
|
instead of _snprintf */
|
||||||
|
#if !defined(__MINGW32__)
|
||||||
#pragma warning(disable: 4996)
|
#pragma warning(disable: 4996)
|
||||||
|
#endif
|
||||||
static WC_INLINE
|
static WC_INLINE
|
||||||
int xsnprintf(char *buffer, size_t bufsize,
|
int xsnprintf(char *buffer, size_t bufsize,
|
||||||
const char *format, ...) {
|
const char *format, ...) {
|
||||||
@@ -500,7 +502,9 @@
|
|||||||
}
|
}
|
||||||
#define XSNPRINTF xsnprintf
|
#define XSNPRINTF xsnprintf
|
||||||
#endif /* (_MSC_VER >= 1900) */
|
#endif /* (_MSC_VER >= 1900) */
|
||||||
#endif /* _MSC_VER || __CYGWIN__ || __MINGW32__ */
|
#else
|
||||||
|
#define XSNPRINTF snprintf
|
||||||
|
#endif /* _MSC_VER */
|
||||||
#endif /* USE_WINDOWS_API */
|
#endif /* USE_WINDOWS_API */
|
||||||
|
|
||||||
#if defined(WOLFSSL_CERT_EXT) || defined(OPENSSL_EXTRA) \
|
#if defined(WOLFSSL_CERT_EXT) || defined(OPENSSL_EXTRA) \
|
||||||
|
Reference in New Issue
Block a user