mirror of https://github.com/wolfSSL/wolfssh.git
IDE Support
1. Added Windows Visual Studio build solution. Includes projects for: * wolfSSH static library * echoserver * unit-test * api-test * 32- and 64-bit debug and release builds for all 2. Made necessary tweaks including adding some wrapper functions so the code compiles for both Linux/macOS and Windows. 3. Fixed a bug in the KDF test where the output buffer wasn't updated when SHA-256 was added. 4. Added the fallthrough attribute for GCC7. 5. Replaced all uses of `uint8_t`, `uint16_t`, and `uint32_t` with the wolfCrypt provided `byte`, `word16`, and `word32`. 6. Split the new channel function into new and init. 7. Added some ECC keys for authentication testing. 8. Moved some functions and includes around. 9. Removed the keying state machine and replaced with a flag. 10. Added rekey trigger if the client sends *CTRL-F* to echoserver. 11. Moved the sequence number increase outside `CreateMac()`. Incremented if the packet was successfully created. This way the sequence number is incremented when using AES-GCM. 12. Removed the redundant function `SendText()`. 13. Renamed the `clientId` related functions and data members to `protoId` to keep things role agnostic. 14. Changed all references of `clientKey` and `serverKey` to `keys` and `peerKeys`. 15. Updated `GenerateKeys()` to generate `keys` and `peerKeys` appropriately based on the endpoint side. 16. Added the wolfSSL style _test.h_ file to group shared example functions in one place. 17. Changed the echoserver to be similar to wolfSSL's where the code may be included without the main function in another executable. Note: This commit is a squash of more than a dozen commits. IDE support was added to the client branch, but the client branch is on hold. There were many changes in the client branch that are needed going forward. The code at the head of the client branch was copied over to the IDE branch, and the client code either deleted or removed from the build.pull/37/head
parent
60d945699a
commit
1498bc5409
|
@ -64,7 +64,8 @@ testing notes
|
||||||
After cloning the repository, be sure to make the testing private keys read-
|
After cloning the repository, be sure to make the testing private keys read-
|
||||||
only for the user, otherwise ssh_client will tell you to do it.
|
only for the user, otherwise ssh_client will tell you to do it.
|
||||||
|
|
||||||
$ chmod 0600 ./keys/key-gretel.pem ./keys/key-hansel.pem
|
$ chmod 0600 ./keys/gretel-key-rsa.pem ./keys/hansel-key-rsa.pem \
|
||||||
|
./keys/gretel-key-ecc.pem ./keys/hansel-key-ecc.pem
|
||||||
|
|
||||||
Authentication against the example echoserver can be done with a password or
|
Authentication against the example echoserver can be done with a password or
|
||||||
public key. To use a password the command line:
|
public key. To use a password the command line:
|
||||||
|
@ -78,9 +79,9 @@ Where the `USER` and password pairs are:
|
||||||
|
|
||||||
To use public key authentication use the command line:
|
To use public key authentication use the command line:
|
||||||
|
|
||||||
$ ssh_client -i ./keys/key-USER.pem -p 22222 USER@localhost
|
$ ssh_client -i ./keys/USER-key-TYPE.pem -p 22222 USER@localhost
|
||||||
|
|
||||||
Where the user can be `gretel` or `hansel`.
|
Where the user can be `gretel` or `hansel`, and type is `rsa` or `ecc`.
|
||||||
|
|
||||||
|
|
||||||
release notes
|
release notes
|
||||||
|
@ -89,7 +90,7 @@ release notes
|
||||||
### wolfSSH v1.2.0 (07/XX/2017)
|
### wolfSSH v1.2.0 (07/XX/2017)
|
||||||
|
|
||||||
- Added ECDH Group Exchange with SHA2 hashing and curves nistp256,
|
- Added ECDH Group Exchange with SHA2 hashing and curves nistp256,
|
||||||
nistp384, and nistp521.
|
nistp384, and nistp521.
|
||||||
- Added ECDSA with SHA2 hashing and curves nistp256, nistp384, and nistp521.
|
- Added ECDSA with SHA2 hashing and curves nistp256, nistp384, and nistp521.
|
||||||
- Changed the echoserver to allow only one connection, but multiple
|
- Changed the echoserver to allow only one connection, but multiple
|
||||||
connections are allowed with a command line option.
|
connections are allowed with a command line option.
|
||||||
|
|
|
@ -68,6 +68,9 @@ TAO_REQUIRE_LIBWOLFSSL
|
||||||
#REQUIRE_CYASSL([scep])
|
#REQUIRE_CYASSL([scep])
|
||||||
#REQUIRE_WOLFCRYPT([aes rsa dh])
|
#REQUIRE_WOLFCRYPT([aes rsa dh])
|
||||||
|
|
||||||
|
# Disable any client code. For size, as nothing calls it.
|
||||||
|
AM_CPPFLAGS="$AM_CPPFLAGS -DWOLFSSL_NO_CLIENT"
|
||||||
|
|
||||||
# since we have autoconf available, we can use cyassl options header
|
# since we have autoconf available, we can use cyassl options header
|
||||||
AM_CPPFLAGS="$AM_CPPFLAGS -DHAVE_CYASSL_OPTIONS"
|
AM_CPPFLAGS="$AM_CPPFLAGS -DHAVE_CYASSL_OPTIONS"
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* echoserver.c
|
/* echoserver.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014-2016 wolfSSL Inc.
|
* Copyright (C) 2014-2017 wolfSSL Inc.
|
||||||
*
|
*
|
||||||
* This file is part of wolfSSH.
|
* This file is part of wolfSSH.
|
||||||
*
|
*
|
||||||
|
@ -19,80 +19,21 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <netinet/tcp.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <wolfssl/options.h>
|
#include <wolfssl/options.h>
|
||||||
#include <wolfssl/wolfcrypt/sha256.h>
|
#include <wolfssl/wolfcrypt/sha256.h>
|
||||||
#include <wolfssl/wolfcrypt/coding.h>
|
#include <wolfssl/wolfcrypt/coding.h>
|
||||||
#include <wolfssh/ssh.h>
|
#include <wolfssh/ssh.h>
|
||||||
#ifndef SO_NOSIGPIPE
|
#include <wolfssh/test.h>
|
||||||
#include <signal.h>
|
#include "examples/echoserver/echoserver.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static const char echoserverBanner[] = "wolfSSH Example Echo Server\n";
|
static const char echoserverBanner[] = "wolfSSH Example Echo Server\n";
|
||||||
|
|
||||||
typedef int SOCKET_T;
|
|
||||||
#ifdef TEST_IPV6
|
|
||||||
typedef struct sockaddr_in6 SOCKADDR_IN_T;
|
|
||||||
#define AF_INET_V AF_INET6
|
|
||||||
static const char* wolfsshIP = "::1";
|
|
||||||
#else
|
|
||||||
typedef struct sockaddr_in SOCKADDR_IN_T;
|
|
||||||
#define AF_INET_V AF_INET
|
|
||||||
static const char* wolfsshIP = "127.0.0.1";
|
|
||||||
#endif
|
|
||||||
#define SERVER_PORT_NUMBER 22222
|
|
||||||
#define SCRATCH_BUFFER_SIZE 1200
|
|
||||||
|
|
||||||
#if defined(__MACH__) || defined(USE_WINDOWS_API)
|
|
||||||
#ifndef _SOCKLEN_T
|
|
||||||
typedef int socklen_t;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
/* HPUX doesn't use socklent_t for third parameter to accept, unless
|
|
||||||
_XOPEN_SOURCE_EXTENDED is defined */
|
|
||||||
#if !defined(__hpux__) && !defined(CYASSL_MDK_ARM) && !defined(CYASSL_IAR_ARM)
|
|
||||||
typedef socklen_t SOCKLEN_T;
|
|
||||||
#else
|
|
||||||
#if defined _XOPEN_SOURCE_EXTENDED
|
|
||||||
typedef socklen_t SOCKLEN_T;
|
|
||||||
#else
|
|
||||||
typedef int SOCKLEN_T;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
|
||||||
typedef void* THREAD_RETURN;
|
|
||||||
typedef pthread_t THREAD_TYPE;
|
|
||||||
#define CYASSL_THREAD
|
|
||||||
#define INFINITE -1
|
|
||||||
#define WAIT_OBJECT_0 0L
|
|
||||||
#elif defined(CYASSL_MDK_ARM)
|
|
||||||
typedef unsigned int THREAD_RETURN;
|
|
||||||
typedef int THREAD_TYPE;
|
|
||||||
#define CYASSL_THREAD
|
|
||||||
#else
|
|
||||||
typedef unsigned int THREAD_RETURN;
|
|
||||||
typedef intptr_t THREAD_TYPE;
|
|
||||||
#define CYASSL_THREAD __stdcall
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
WOLFSSH* ssh;
|
WOLFSSH* ssh;
|
||||||
SOCKET_T fd;
|
SOCKET_T fd;
|
||||||
uint32_t id;
|
word32 id;
|
||||||
} thread_ctx_t;
|
} thread_ctx_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,247 +43,12 @@ typedef struct {
|
||||||
#ifndef EXAMPLE_BUFFER_SZ
|
#ifndef EXAMPLE_BUFFER_SZ
|
||||||
#define EXAMPLE_BUFFER_SZ 4096
|
#define EXAMPLE_BUFFER_SZ 4096
|
||||||
#endif
|
#endif
|
||||||
|
#define SCRATCH_BUFFER_SZ 1200
|
||||||
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
static byte find_char(const byte* str, const byte* buf, word32 bufSz)
|
||||||
#define WS_NORETURN __attribute__((noreturn))
|
|
||||||
#else
|
|
||||||
#define WS_NORETURN
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#define MY_EX_USAGE 2
|
|
||||||
|
|
||||||
extern int myoptind;
|
|
||||||
extern char* myoptarg;
|
|
||||||
|
|
||||||
static INLINE int mygetopt(int argc, char** argv, const char* optstring)
|
|
||||||
{
|
{
|
||||||
static char* next = NULL;
|
const byte* cur;
|
||||||
|
|
||||||
char c;
|
|
||||||
char* cp;
|
|
||||||
|
|
||||||
if (myoptind == 0)
|
|
||||||
next = NULL; /* we're starting new/over */
|
|
||||||
|
|
||||||
if (next == NULL || *next == '\0') {
|
|
||||||
if (myoptind == 0)
|
|
||||||
myoptind++;
|
|
||||||
|
|
||||||
if (myoptind >= argc || argv[myoptind][0] != '-' ||
|
|
||||||
argv[myoptind][1] == '\0') {
|
|
||||||
myoptarg = NULL;
|
|
||||||
if (myoptind < argc)
|
|
||||||
myoptarg = argv[myoptind];
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp(argv[myoptind], "--") == 0) {
|
|
||||||
myoptind++;
|
|
||||||
myoptarg = NULL;
|
|
||||||
|
|
||||||
if (myoptind < argc)
|
|
||||||
myoptarg = argv[myoptind];
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
next = argv[myoptind];
|
|
||||||
next++; /* skip - */
|
|
||||||
myoptind++;
|
|
||||||
}
|
|
||||||
|
|
||||||
c = *next++;
|
|
||||||
/* The C++ strchr can return a different value */
|
|
||||||
cp = (char*)strchr(optstring, c);
|
|
||||||
|
|
||||||
if (cp == NULL || c == ':')
|
|
||||||
return '?';
|
|
||||||
|
|
||||||
cp++;
|
|
||||||
|
|
||||||
if (*cp == ':') {
|
|
||||||
if (*next != '\0') {
|
|
||||||
myoptarg = next;
|
|
||||||
next = NULL;
|
|
||||||
}
|
|
||||||
else if (myoptind < argc) {
|
|
||||||
myoptarg = argv[myoptind];
|
|
||||||
myoptind++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return '?';
|
|
||||||
}
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static INLINE WS_NORETURN void err_sys(const char* msg)
|
|
||||||
{
|
|
||||||
printf("server error: %s\n", msg);
|
|
||||||
|
|
||||||
#ifndef __GNUC__
|
|
||||||
/* scan-build (which pretends to be gnuc) can get confused and think the
|
|
||||||
* msg pointer can be null even when hardcoded and then it won't exit,
|
|
||||||
* making null pointer checks above the err_sys() call useless.
|
|
||||||
* We could just always exit() but some compilers will complain about no
|
|
||||||
* possible return, with gcc we know the attribute to handle that with
|
|
||||||
* WS_NORETURN. */
|
|
||||||
if (msg)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static INLINE void build_addr(SOCKADDR_IN_T* addr, const char* peer,
|
|
||||||
uint16_t port)
|
|
||||||
{
|
|
||||||
int useLookup = 0;
|
|
||||||
(void)useLookup;
|
|
||||||
|
|
||||||
memset(addr, 0, sizeof(SOCKADDR_IN_T));
|
|
||||||
|
|
||||||
#ifndef TEST_IPV6
|
|
||||||
/* peer could be in human readable form */
|
|
||||||
if ( (peer != INADDR_ANY) && isalpha((int)peer[0])) {
|
|
||||||
#ifdef CYASSL_MDK_ARM
|
|
||||||
int err;
|
|
||||||
struct hostent* entry = gethostbyname(peer, &err);
|
|
||||||
#else
|
|
||||||
struct hostent* entry = gethostbyname(peer);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (entry) {
|
|
||||||
memcpy(&addr->sin_addr.s_addr, entry->h_addr_list[0],
|
|
||||||
entry->h_length);
|
|
||||||
useLookup = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
err_sys("no entry for host");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TEST_IPV6
|
|
||||||
#if defined(CYASSL_MDK_ARM)
|
|
||||||
addr->sin_family = PF_INET;
|
|
||||||
#else
|
|
||||||
addr->sin_family = AF_INET_V;
|
|
||||||
#endif
|
|
||||||
addr->sin_port = htons(port);
|
|
||||||
if (peer == INADDR_ANY)
|
|
||||||
addr->sin_addr.s_addr = INADDR_ANY;
|
|
||||||
else {
|
|
||||||
if (!useLookup)
|
|
||||||
addr->sin_addr.s_addr = inet_addr(peer);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
addr->sin6_family = AF_INET_V;
|
|
||||||
addr->sin6_port = htons(port);
|
|
||||||
if (peer == INADDR_ANY)
|
|
||||||
addr->sin6_addr = in6addr_any;
|
|
||||||
else {
|
|
||||||
#ifdef HAVE_GETADDRINFO
|
|
||||||
struct addrinfo hints;
|
|
||||||
struct addrinfo* answer = NULL;
|
|
||||||
int ret;
|
|
||||||
char strPort[80];
|
|
||||||
|
|
||||||
memset(&hints, 0, sizeof(hints));
|
|
||||||
|
|
||||||
hints.ai_family = AF_INET_V;
|
|
||||||
hints.ai_socktype = udp ? SOCK_DGRAM : SOCK_STREAM;
|
|
||||||
hints.ai_protocol = udp ? IPPROTO_UDP : IPPROTO_TCP;
|
|
||||||
|
|
||||||
SNPRINTF(strPort, sizeof(strPort), "%d", port);
|
|
||||||
strPort[79] = '\0';
|
|
||||||
|
|
||||||
ret = getaddrinfo(peer, strPort, &hints, &answer);
|
|
||||||
if (ret < 0 || answer == NULL)
|
|
||||||
err_sys("getaddrinfo failed");
|
|
||||||
|
|
||||||
memcpy(addr, answer->ai_addr, answer->ai_addrlen);
|
|
||||||
freeaddrinfo(answer);
|
|
||||||
#else
|
|
||||||
printf("no ipv6 getaddrinfo, loopback only tests/examples\n");
|
|
||||||
addr->sin6_addr = in6addr_loopback;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static INLINE void tcp_socket(SOCKET_T* sockFd)
|
|
||||||
{
|
|
||||||
*sockFd = socket(AF_INET_V, SOCK_STREAM, 0);
|
|
||||||
|
|
||||||
#ifdef USE_WINDOWS_API
|
|
||||||
if (*sockFd == INVALID_SOCKET)
|
|
||||||
err_sys("socket failed\n");
|
|
||||||
#else
|
|
||||||
if (*sockFd < 0)
|
|
||||||
err_sys("socket failed\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef USE_WINDOWS_API
|
|
||||||
#ifdef SO_NOSIGPIPE
|
|
||||||
{
|
|
||||||
int on = 1;
|
|
||||||
socklen_t len = sizeof(on);
|
|
||||||
int res = setsockopt(*sockFd, SOL_SOCKET, SO_NOSIGPIPE, &on, len);
|
|
||||||
if (res < 0)
|
|
||||||
err_sys("setsockopt SO_NOSIGPIPE failed\n");
|
|
||||||
}
|
|
||||||
#elif defined(CYASSL_MDK_ARM)
|
|
||||||
/* nothing to define */
|
|
||||||
#else /* no S_NOSIGPIPE */
|
|
||||||
signal(SIGPIPE, SIG_IGN);
|
|
||||||
#endif /* S_NOSIGPIPE */
|
|
||||||
|
|
||||||
#if defined(TCP_NODELAY)
|
|
||||||
{
|
|
||||||
int on = 1;
|
|
||||||
socklen_t len = sizeof(on);
|
|
||||||
int res = setsockopt(*sockFd, IPPROTO_TCP, TCP_NODELAY, &on, len);
|
|
||||||
if (res < 0)
|
|
||||||
err_sys("setsockopt TCP_NODELAY failed\n");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif /* USE_WINDOWS_API */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static INLINE void tcp_bind(SOCKET_T* sockFd, uint16_t port, int useAnyAddr)
|
|
||||||
{
|
|
||||||
SOCKADDR_IN_T addr;
|
|
||||||
|
|
||||||
/* don't use INADDR_ANY by default, firewall may block, make user switch
|
|
||||||
on */
|
|
||||||
build_addr(&addr, (useAnyAddr ? INADDR_ANY : wolfsshIP), port);
|
|
||||||
tcp_socket(sockFd);
|
|
||||||
|
|
||||||
#if !defined(USE_WINDOWS_API) && !defined(CYASSL_MDK_ARM)
|
|
||||||
{
|
|
||||||
int res, on = 1;
|
|
||||||
socklen_t len = sizeof(on);
|
|
||||||
res = setsockopt(*sockFd, SOL_SOCKET, SO_REUSEADDR, &on, len);
|
|
||||||
if (res < 0)
|
|
||||||
err_sys("setsockopt SO_REUSEADDR failed\n");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (bind(*sockFd, (const struct sockaddr*)&addr, sizeof(addr)) != 0)
|
|
||||||
err_sys("tcp bind failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static uint8_t find_char(const uint8_t* str, const uint8_t* buf, uint32_t bufSz)
|
|
||||||
{
|
|
||||||
const uint8_t* cur;
|
|
||||||
|
|
||||||
while (bufSz) {
|
while (bufSz) {
|
||||||
cur = str;
|
cur = str;
|
||||||
|
@ -362,35 +68,36 @@ static uint8_t find_char(const uint8_t* str, const uint8_t* buf, uint32_t bufSz)
|
||||||
static int dump_stats(thread_ctx_t* ctx)
|
static int dump_stats(thread_ctx_t* ctx)
|
||||||
{
|
{
|
||||||
char stats[1024];
|
char stats[1024];
|
||||||
uint32_t statsSz;
|
word32 statsSz;
|
||||||
uint32_t txCount, rxCount, seq, peerSeq;
|
word32 txCount, rxCount, seq, peerSeq;
|
||||||
|
|
||||||
wolfSSH_GetStats(ctx->ssh, &txCount, &rxCount, &seq, &peerSeq);
|
wolfSSH_GetStats(ctx->ssh, &txCount, &rxCount, &seq, &peerSeq);
|
||||||
|
|
||||||
sprintf(stats,
|
WSNPRINTF(stats, sizeof(stats),
|
||||||
"Statistics for Thread #%u:\r\n"
|
"Statistics for Thread #%u:\r\n"
|
||||||
" txCount = %u\r\n rxCount = %u\r\n"
|
" txCount = %u\r\n rxCount = %u\r\n"
|
||||||
" seq = %u\r\n peerSeq = %u\r\n",
|
" seq = %u\r\n peerSeq = %u\r\n",
|
||||||
ctx->id, txCount, rxCount, seq, peerSeq);
|
ctx->id, txCount, rxCount, seq, peerSeq);
|
||||||
statsSz = (uint32_t)strlen(stats);
|
statsSz = (word32)strlen(stats);
|
||||||
|
|
||||||
fprintf(stderr, "%s", stats);
|
fprintf(stderr, "%s", stats);
|
||||||
return wolfSSH_stream_send(ctx->ssh, (uint8_t*)stats, statsSz);
|
return wolfSSH_stream_send(ctx->ssh, (byte*)stats, statsSz);
|
||||||
}
|
}
|
||||||
|
|
||||||
static THREAD_RETURN CYASSL_THREAD server_worker(void* vArgs)
|
|
||||||
|
static THREAD_RETURN WOLFSSH_THREAD server_worker(void* vArgs)
|
||||||
{
|
{
|
||||||
thread_ctx_t* threadCtx = (thread_ctx_t*)vArgs;
|
thread_ctx_t* threadCtx = (thread_ctx_t*)vArgs;
|
||||||
|
|
||||||
if (wolfSSH_accept(threadCtx->ssh) == WS_SUCCESS) {
|
if (wolfSSH_accept(threadCtx->ssh) == WS_SUCCESS) {
|
||||||
uint8_t* buf = NULL;
|
byte* buf = NULL;
|
||||||
uint8_t* tmpBuf;
|
byte* tmpBuf;
|
||||||
int bufSz, backlogSz = 0, rxSz, txSz, stop = 0, txSum;
|
int bufSz, backlogSz = 0, rxSz, txSz, stop = 0, txSum;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
bufSz = EXAMPLE_BUFFER_SZ + backlogSz;
|
bufSz = EXAMPLE_BUFFER_SZ + backlogSz;
|
||||||
|
|
||||||
tmpBuf = realloc(buf, bufSz);
|
tmpBuf = (byte*)realloc(buf, bufSz);
|
||||||
if (tmpBuf == NULL)
|
if (tmpBuf == NULL)
|
||||||
stop = 1;
|
stop = 1;
|
||||||
else
|
else
|
||||||
|
@ -411,20 +118,25 @@ static THREAD_RETURN CYASSL_THREAD server_worker(void* vArgs)
|
||||||
backlogSz - txSum);
|
backlogSz - txSum);
|
||||||
|
|
||||||
if (txSz > 0) {
|
if (txSz > 0) {
|
||||||
uint8_t c;
|
byte c;
|
||||||
const uint8_t matches[] = { 0x03, 0x04, 0x05, 0x00 };
|
const byte matches[] = { 0x03, 0x05, 0x06, 0x00 };
|
||||||
|
|
||||||
c = find_char(matches, buf + txSum, txSz);
|
c = find_char(matches, buf + txSum, txSz);
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 0x03:
|
case 0x03:
|
||||||
stop = 1;
|
stop = 1;
|
||||||
break;
|
break;
|
||||||
|
case 0x06:
|
||||||
|
if (wolfSSH_TriggerKeyExchange(threadCtx->ssh)
|
||||||
|
!= WS_SUCCESS)
|
||||||
|
stop = 1;
|
||||||
|
break;
|
||||||
case 0x05:
|
case 0x05:
|
||||||
if (dump_stats(threadCtx) <= 0)
|
if (dump_stats(threadCtx) <= 0)
|
||||||
stop = 1;
|
stop = 1;
|
||||||
default:
|
break;
|
||||||
txSum += txSz;
|
|
||||||
}
|
}
|
||||||
|
txSum += txSz;
|
||||||
}
|
}
|
||||||
else if (txSz != WS_REKEYING)
|
else if (txSz != WS_REKEYING)
|
||||||
stop = 1;
|
stop = 1;
|
||||||
|
@ -441,7 +153,7 @@ static THREAD_RETURN CYASSL_THREAD server_worker(void* vArgs)
|
||||||
|
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
close(threadCtx->fd);
|
WCLOSESOCKET(threadCtx->fd);
|
||||||
wolfSSH_free(threadCtx->ssh);
|
wolfSSH_free(threadCtx->ssh);
|
||||||
free(threadCtx);
|
free(threadCtx);
|
||||||
|
|
||||||
|
@ -449,18 +161,18 @@ static THREAD_RETURN CYASSL_THREAD server_worker(void* vArgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int load_file(const char* fileName, uint8_t* buf, uint32_t bufSz)
|
static int load_file(const char* fileName, byte* buf, word32 bufSz)
|
||||||
{
|
{
|
||||||
FILE* file;
|
FILE* file;
|
||||||
uint32_t fileSz;
|
word32 fileSz;
|
||||||
uint32_t readSz;
|
word32 readSz;
|
||||||
|
|
||||||
if (fileName == NULL) return 0;
|
if (fileName == NULL) return 0;
|
||||||
|
|
||||||
file = fopen(fileName, "rb");
|
if (WFOPEN(&file, fileName, "rb") != 0)
|
||||||
if (file == NULL) return 0;
|
return 0;
|
||||||
fseek(file, 0, SEEK_END);
|
fseek(file, 0, SEEK_END);
|
||||||
fileSz = (uint32_t)ftell(file);
|
fileSz = (word32)ftell(file);
|
||||||
rewind(file);
|
rewind(file);
|
||||||
|
|
||||||
if (fileSz > bufSz) {
|
if (fileSz > bufSz) {
|
||||||
|
@ -468,7 +180,7 @@ static int load_file(const char* fileName, uint8_t* buf, uint32_t bufSz)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
readSz = (uint32_t)fread(buf, 1, fileSz, file);
|
readSz = (word32)fread(buf, 1, fileSz, file);
|
||||||
if (readSz < fileSz) {
|
if (readSz < fileSz) {
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -480,7 +192,7 @@ static int load_file(const char* fileName, uint8_t* buf, uint32_t bufSz)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline void c32toa(uint32_t u32, uint8_t* c)
|
static INLINE void c32toa(word32 u32, byte* c)
|
||||||
{
|
{
|
||||||
c[0] = (u32 >> 24) & 0xff;
|
c[0] = (u32 >> 24) & 0xff;
|
||||||
c[1] = (u32 >> 16) & 0xff;
|
c[1] = (u32 >> 16) & 0xff;
|
||||||
|
@ -493,10 +205,10 @@ static inline void c32toa(uint32_t u32, uint8_t* c)
|
||||||
/* Use arrays for username and p. The password or public key can
|
/* Use arrays for username and p. The password or public key can
|
||||||
* be hashed and the hash stored here. Then I won't need the type. */
|
* be hashed and the hash stored here. Then I won't need the type. */
|
||||||
typedef struct PwMap {
|
typedef struct PwMap {
|
||||||
uint8_t type;
|
byte type;
|
||||||
uint8_t username[32];
|
byte username[32];
|
||||||
uint32_t usernameSz;
|
word32 usernameSz;
|
||||||
uint8_t p[SHA256_DIGEST_SIZE];
|
byte p[SHA256_DIGEST_SIZE];
|
||||||
struct PwMap* next;
|
struct PwMap* next;
|
||||||
} PwMap;
|
} PwMap;
|
||||||
|
|
||||||
|
@ -506,15 +218,15 @@ typedef struct PwMapList {
|
||||||
} PwMapList;
|
} PwMapList;
|
||||||
|
|
||||||
|
|
||||||
static PwMap* PwMapNew(PwMapList* list, uint8_t type, const uint8_t* username,
|
static PwMap* PwMapNew(PwMapList* list, byte type, const byte* username,
|
||||||
uint32_t usernameSz, const uint8_t* p, uint32_t pSz)
|
word32 usernameSz, const byte* p, word32 pSz)
|
||||||
{
|
{
|
||||||
PwMap* map;
|
PwMap* map;
|
||||||
|
|
||||||
map = (PwMap*)malloc(sizeof(PwMap));
|
map = (PwMap*)malloc(sizeof(PwMap));
|
||||||
if (map != NULL) {
|
if (map != NULL) {
|
||||||
Sha256 sha;
|
Sha256 sha;
|
||||||
uint8_t flatSz[4];
|
byte flatSz[4];
|
||||||
|
|
||||||
map->type = type;
|
map->type = type;
|
||||||
if (usernameSz >= sizeof(map->username))
|
if (usernameSz >= sizeof(map->username))
|
||||||
|
@ -557,7 +269,16 @@ static const char samplePasswordBuffer[] =
|
||||||
"jack:fetchapail\n";
|
"jack:fetchapail\n";
|
||||||
|
|
||||||
|
|
||||||
static const char samplePublicKeyBuffer[] =
|
static const char samplePublicKeyEccBuffer[] =
|
||||||
|
"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAA"
|
||||||
|
"BBBNkI5JTP6D0lF42tbxX19cE87hztUS6FSDoGvPfiU0CgeNSbI+aFdKIzTP5CQEJSvm25"
|
||||||
|
"qUzgDtH7oyaQROUnNvk= hansel\n"
|
||||||
|
"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAA"
|
||||||
|
"BBBKAtH8cqaDbtJFjtviLobHBmjCtG56DMkP6A4M2H9zX2/YCg1h9bYS7WHd9UQDwXO1Hh"
|
||||||
|
"IZzRYecXh7SG9P4GhRY= gretel\n";
|
||||||
|
|
||||||
|
|
||||||
|
static const char samplePublicKeyRsaBuffer[] =
|
||||||
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9P3ZFowOsONXHD5MwWiCciXytBRZGho"
|
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9P3ZFowOsONXHD5MwWiCciXytBRZGho"
|
||||||
"MNiisWSgUs5HdHcACuHYPi2W6Z1PBFmBWT9odOrGRjoZXJfDDoPi+j8SSfDGsc/hsCmc3G"
|
"MNiisWSgUs5HdHcACuHYPi2W6Z1PBFmBWT9odOrGRjoZXJfDDoPi+j8SSfDGsc/hsCmc3G"
|
||||||
"p2yEhUZUEkDhtOXyqjns1ickC9Gh4u80aSVtwHRnJZh9xPhSq5tLOhId4eP61s+a5pwjTj"
|
"p2yEhUZUEkDhtOXyqjns1ickC9Gh4u80aSVtwHRnJZh9xPhSq5tLOhId4eP61s+a5pwjTj"
|
||||||
|
@ -572,7 +293,7 @@ static const char samplePublicKeyBuffer[] =
|
||||||
"RGwkU38D043AR1h0mUoGCPIKuqcFMf gretel\n";
|
"RGwkU38D043AR1h0mUoGCPIKuqcFMf gretel\n";
|
||||||
|
|
||||||
|
|
||||||
static int LoadPasswordBuffer(uint8_t* buf, uint32_t bufSz, PwMapList* list)
|
static int LoadPasswordBuffer(byte* buf, word32 bufSz, PwMapList* list)
|
||||||
{
|
{
|
||||||
char* str = (char*)buf;
|
char* str = (char*)buf;
|
||||||
char* delimiter;
|
char* delimiter;
|
||||||
|
@ -598,8 +319,8 @@ static int LoadPasswordBuffer(uint8_t* buf, uint32_t bufSz, PwMapList* list)
|
||||||
*str = 0;
|
*str = 0;
|
||||||
str++;
|
str++;
|
||||||
if (PwMapNew(list, WOLFSSH_USERAUTH_PASSWORD,
|
if (PwMapNew(list, WOLFSSH_USERAUTH_PASSWORD,
|
||||||
(uint8_t*)username, (uint32_t)strlen(username),
|
(byte*)username, (word32)strlen(username),
|
||||||
(uint8_t*)password, (uint32_t)strlen(password)) == NULL ) {
|
(byte*)password, (word32)strlen(password)) == NULL ) {
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -609,16 +330,16 @@ static int LoadPasswordBuffer(uint8_t* buf, uint32_t bufSz, PwMapList* list)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int LoadPublicKeyBuffer(uint8_t* buf, uint32_t bufSz, PwMapList* list)
|
static int LoadPublicKeyBuffer(byte* buf, word32 bufSz, PwMapList* list)
|
||||||
{
|
{
|
||||||
char* str = (char*)buf;
|
char* str = (char*)buf;
|
||||||
char* delimiter;
|
char* delimiter;
|
||||||
uint8_t* publicKey64;
|
byte* publicKey64;
|
||||||
uint32_t publicKey64Sz;
|
word32 publicKey64Sz;
|
||||||
uint8_t* username;
|
byte* username;
|
||||||
uint32_t usernameSz;
|
word32 usernameSz;
|
||||||
uint8_t publicKey[300];
|
byte publicKey[300];
|
||||||
uint32_t publicKeySz;
|
word32 publicKeySz;
|
||||||
|
|
||||||
/* Each line of passwd.txt is in the format
|
/* Each line of passwd.txt is in the format
|
||||||
* ssh-rsa AAAB3BASE64ENCODEDPUBLICKEYBLOB username\n
|
* ssh-rsa AAAB3BASE64ENCODEDPUBLICKEYBLOB username\n
|
||||||
|
@ -634,14 +355,14 @@ static int LoadPublicKeyBuffer(uint8_t* buf, uint32_t bufSz, PwMapList* list)
|
||||||
delimiter = strchr(str, ' ');
|
delimiter = strchr(str, ' ');
|
||||||
str = delimiter + 1;
|
str = delimiter + 1;
|
||||||
delimiter = strchr(str, ' ');
|
delimiter = strchr(str, ' ');
|
||||||
publicKey64 = (uint8_t*)str;
|
publicKey64 = (byte*)str;
|
||||||
*delimiter = 0;
|
*delimiter = 0;
|
||||||
publicKey64Sz = (uint32_t)(delimiter - str);
|
publicKey64Sz = (word32)(delimiter - str);
|
||||||
str = delimiter + 1;
|
str = delimiter + 1;
|
||||||
delimiter = strchr(str, '\n');
|
delimiter = strchr(str, '\n');
|
||||||
username = (uint8_t*)str;
|
username = (byte*)str;
|
||||||
*delimiter = 0;
|
*delimiter = 0;
|
||||||
usernameSz = (uint32_t)(delimiter - str);
|
usernameSz = (word32)(delimiter - str);
|
||||||
str = delimiter + 1;
|
str = delimiter + 1;
|
||||||
publicKeySz = sizeof(publicKey);
|
publicKeySz = sizeof(publicKey);
|
||||||
|
|
||||||
|
@ -663,13 +384,13 @@ static int LoadPublicKeyBuffer(uint8_t* buf, uint32_t bufSz, PwMapList* list)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int wsUserAuth(uint8_t authType,
|
static int wsUserAuth(byte authType,
|
||||||
const WS_UserAuthData* authData,
|
WS_UserAuthData* authData,
|
||||||
void* ctx)
|
void* ctx)
|
||||||
{
|
{
|
||||||
PwMapList* list;
|
PwMapList* list;
|
||||||
PwMap* map;
|
PwMap* map;
|
||||||
uint8_t authHash[SHA256_DIGEST_SIZE];
|
byte authHash[SHA256_DIGEST_SIZE];
|
||||||
|
|
||||||
if (ctx == NULL) {
|
if (ctx == NULL) {
|
||||||
fprintf(stderr, "wsUserAuth: ctx not set");
|
fprintf(stderr, "wsUserAuth: ctx not set");
|
||||||
|
@ -685,7 +406,7 @@ static int wsUserAuth(uint8_t authType,
|
||||||
/* Hash the password or public key with its length. */
|
/* Hash the password or public key with its length. */
|
||||||
{
|
{
|
||||||
Sha256 sha;
|
Sha256 sha;
|
||||||
uint8_t flatSz[4];
|
byte flatSz[4];
|
||||||
wc_InitSha256(&sha);
|
wc_InitSha256(&sha);
|
||||||
if (authType == WOLFSSH_USERAUTH_PASSWORD) {
|
if (authType == WOLFSSH_USERAUTH_PASSWORD) {
|
||||||
c32toa(authData->sf.password.passwordSz, flatSz);
|
c32toa(authData->sf.password.passwordSz, flatSz);
|
||||||
|
@ -741,20 +462,21 @@ static void ShowUsage(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
|
||||||
{
|
{
|
||||||
WOLFSSH_CTX* ctx = NULL;
|
WOLFSSH_CTX* ctx = NULL;
|
||||||
PwMapList pwMapList;
|
PwMapList pwMapList;
|
||||||
SOCKET_T listenFd = 0;
|
SOCKET_T listenFd = 0;
|
||||||
uint32_t defaultHighwater = EXAMPLE_HIGHWATER_MARK;
|
word32 defaultHighwater = EXAMPLE_HIGHWATER_MARK;
|
||||||
uint32_t threadCount = 0;
|
word32 threadCount = 0;
|
||||||
int multipleConnections = 0;
|
int multipleConnections = 0;
|
||||||
int useEcc = 0;
|
int useEcc = 0;
|
||||||
char ch;
|
char ch;
|
||||||
|
word16 port = wolfSshPort;
|
||||||
|
|
||||||
#ifdef DEBUG_WOLFSSH
|
int argc = ((func_args*)args)->argc;
|
||||||
wolfSSH_Debugging_ON();
|
char** argv = ((func_args*)args)->argv;
|
||||||
#endif
|
((func_args*)args)->return_code = 0;
|
||||||
|
|
||||||
while ((ch = mygetopt(argc, argv, "hme")) != -1) {
|
while ((ch = mygetopt(argc, argv, "hme")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
@ -793,13 +515,13 @@ int main(int argc, char** argv)
|
||||||
wolfSSH_CTX_SetBanner(ctx, echoserverBanner);
|
wolfSSH_CTX_SetBanner(ctx, echoserverBanner);
|
||||||
|
|
||||||
{
|
{
|
||||||
uint8_t buf[SCRATCH_BUFFER_SIZE];
|
const char* bufName;
|
||||||
uint32_t bufSz;
|
byte buf[SCRATCH_BUFFER_SZ];
|
||||||
|
word32 bufSz;
|
||||||
|
|
||||||
bufSz = load_file(useEcc ?
|
bufName = useEcc ? "./keys/server-key-ecc.der" :
|
||||||
"./keys/server-key-ecc.der" :
|
"./keys/server-key-rsa.der" ;
|
||||||
"./keys/server-key-rsa.der",
|
bufSz = load_file(bufName, buf, SCRATCH_BUFFER_SZ);
|
||||||
buf, SCRATCH_BUFFER_SIZE);
|
|
||||||
if (bufSz == 0) {
|
if (bufSz == 0) {
|
||||||
fprintf(stderr, "Couldn't load key file.\n");
|
fprintf(stderr, "Couldn't load key file.\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -810,26 +532,25 @@ int main(int argc, char** argv)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bufSz = (uint32_t)strlen((char*)samplePasswordBuffer);
|
bufSz = (word32)strlen(samplePasswordBuffer);
|
||||||
memcpy(buf, samplePasswordBuffer, bufSz);
|
memcpy(buf, samplePasswordBuffer, bufSz);
|
||||||
buf[bufSz] = 0;
|
buf[bufSz] = 0;
|
||||||
LoadPasswordBuffer(buf, bufSz, &pwMapList);
|
LoadPasswordBuffer(buf, bufSz, &pwMapList);
|
||||||
|
|
||||||
bufSz = (uint32_t)strlen((char*)samplePublicKeyBuffer);
|
bufName = useEcc ? samplePublicKeyEccBuffer :
|
||||||
memcpy(buf, samplePublicKeyBuffer, bufSz);
|
samplePublicKeyRsaBuffer;
|
||||||
|
bufSz = (word32)strlen(bufName);
|
||||||
|
memcpy(buf, bufName, bufSz);
|
||||||
buf[bufSz] = 0;
|
buf[bufSz] = 0;
|
||||||
LoadPublicKeyBuffer(buf, bufSz, &pwMapList);
|
LoadPublicKeyBuffer(buf, bufSz, &pwMapList);
|
||||||
}
|
}
|
||||||
|
|
||||||
tcp_bind(&listenFd, SERVER_PORT_NUMBER, 0);
|
tcp_listen(&listenFd, &port, 0);
|
||||||
|
|
||||||
if (listen(listenFd, 5) != 0)
|
|
||||||
err_sys("tcp listen failed");
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
SOCKET_T clientFd = 0;
|
SOCKET_T clientFd = 0;
|
||||||
SOCKADDR_IN_T clientAddr;
|
SOCKADDR_IN_T clientAddr;
|
||||||
SOCKLEN_T clientAddrSz = sizeof(clientAddr);
|
socklen_t clientAddrSz = sizeof(clientAddr);
|
||||||
THREAD_TYPE thread;
|
THREAD_TYPE thread;
|
||||||
WOLFSSH* ssh;
|
WOLFSSH* ssh;
|
||||||
thread_ctx_t* threadCtx;
|
thread_ctx_t* threadCtx;
|
||||||
|
@ -857,18 +578,18 @@ int main(int argc, char** argv)
|
||||||
if (clientFd == -1)
|
if (clientFd == -1)
|
||||||
err_sys("tcp accept failed");
|
err_sys("tcp accept failed");
|
||||||
|
|
||||||
wolfSSH_set_fd(ssh, clientFd);
|
wolfSSH_set_fd(ssh, (int)clientFd);
|
||||||
|
|
||||||
threadCtx->ssh = ssh;
|
threadCtx->ssh = ssh;
|
||||||
threadCtx->fd = clientFd;
|
threadCtx->fd = clientFd;
|
||||||
threadCtx->id = threadCount++;
|
threadCtx->id = threadCount++;
|
||||||
|
|
||||||
pthread_create(&thread, 0, server_worker, threadCtx);
|
start_thread(server_worker, threadCtx, &thread);
|
||||||
|
|
||||||
if (multipleConnections)
|
if (multipleConnections)
|
||||||
pthread_detach(thread);
|
detach_thread(thread);
|
||||||
else
|
else
|
||||||
pthread_join(thread, NULL);
|
join_thread(thread);
|
||||||
|
|
||||||
} while (multipleConnections);
|
} while (multipleConnections);
|
||||||
|
|
||||||
|
@ -882,5 +603,36 @@ int main(int argc, char** argv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int myoptind = 0;
|
#ifndef NO_MAIN_DRIVER
|
||||||
char* myoptarg = NULL;
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
func_args args;
|
||||||
|
|
||||||
|
args.argc = argc;
|
||||||
|
args.argv = argv;
|
||||||
|
args.return_code = 0;
|
||||||
|
|
||||||
|
WSTARTTCP();
|
||||||
|
|
||||||
|
ChangeToWolfSshRoot();
|
||||||
|
#ifdef DEBUG_WOLFSSH
|
||||||
|
wolfSSH_Debugging_ON();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wolfSSH_Init();
|
||||||
|
|
||||||
|
#ifndef NO_WOLFSSH_CLIENT
|
||||||
|
echoserver_test(&args);
|
||||||
|
#endif /* NO_WOLFSSH_CLIENT */
|
||||||
|
|
||||||
|
wolfSSH_Cleanup();
|
||||||
|
|
||||||
|
return args.return_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int myoptind = 0;
|
||||||
|
char* myoptarg = NULL;
|
||||||
|
|
||||||
|
#endif /* NO_MAIN_DRIVER */
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/* echoserver.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014-2017 wolfSSL Inc.
|
||||||
|
*
|
||||||
|
* This file is part of wolfSSH.
|
||||||
|
*
|
||||||
|
* wolfSSH is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* wolfSSH is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with wolfSSH. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef _WOLFSSH_ECHOSERVER_H_
|
||||||
|
#define _WOLFSSH_ECHOSERVER_H_
|
||||||
|
|
||||||
|
|
||||||
|
THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _WOLFSSH_ECHOSERVER_H_ */
|
|
@ -5,10 +5,18 @@
|
||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
<Configuration>Release</Configuration>
|
<Configuration>Release</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\..\tests\api.c" />
|
<ClCompile Include="..\..\..\tests\api.c" />
|
||||||
|
@ -18,6 +26,9 @@
|
||||||
<Project>{7c2ccf0d-a155-4914-bd1c-9a47c0530e65}</Project>
|
<Project>{7c2ccf0d-a155-4914-bd1c-9a47c0530e65}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Library Include="..\wolfcrypt\wolfssl.lib" />
|
||||||
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{07D36DB5-210E-45A6-8270-2DAD9DCDEFD7}</ProjectGuid>
|
<ProjectGuid>{07D36DB5-210E-45A6-8270-2DAD9DCDEFD7}</ProjectGuid>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
@ -30,6 +41,12 @@
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
@ -37,23 +54,48 @@
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<IntDir>$(Configuration)\$(Platform)\obj\</IntDir>
|
<IntDir>$(Configuration)\$(Platform)\obj\</IntDir>
|
||||||
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
|
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IntDir>$(Configuration)\$(Platform)\obj\</IntDir>
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
|
||||||
|
<IntDir>$(Configuration)\$(Platform)\obj\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
|
||||||
|
<IntDir>$(Configuration)\$(Platform)\obj\</IntDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
|
@ -62,7 +104,25 @@
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..\..;..\wolfcrypt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
<IgnoreSpecificDefaultLibraries>msvcrt.lib</IgnoreSpecificDefaultLibraries>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>..\..\..;..\wolfcrypt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
|
@ -81,11 +141,32 @@
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>..\..\..;..\wolfcrypt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>ws2_32.lib;advapi32.lib</AdditionalDependencies>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>..\..\..;..\wolfcrypt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>ws2_32.lib;advapi32.lib</AdditionalDependencies>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
</Link>
|
</Link>
|
||||||
|
@ -93,4 +174,4 @@
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -5,10 +5,18 @@
|
||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
<Configuration>Release</Configuration>
|
<Configuration>Release</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\..\examples\echoserver\echoserver.c" />
|
<ClCompile Include="..\..\..\examples\echoserver\echoserver.c" />
|
||||||
|
@ -18,6 +26,9 @@
|
||||||
<Project>{7c2ccf0d-a155-4914-bd1c-9a47c0530e65}</Project>
|
<Project>{7c2ccf0d-a155-4914-bd1c-9a47c0530e65}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Library Include="..\wolfcrypt\wolfssl.lib" />
|
||||||
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{B4E163C2-ECA0-4DA2-9FD9-4CD6599C9D4D}</ProjectGuid>
|
<ProjectGuid>{B4E163C2-ECA0-4DA2-9FD9-4CD6599C9D4D}</ProjectGuid>
|
||||||
<Keyword>Win32Proj</Keyword>
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
@ -30,6 +41,12 @@
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
@ -37,23 +54,48 @@
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
<IntDir>$(Configuration)\$(Platform)\obj\</IntDir>
|
<IntDir>$(Configuration)\$(Platform)\obj\</IntDir>
|
||||||
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
|
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IntDir>$(Configuration)\$(Platform)\obj\</IntDir>
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<LinkIncremental>false</LinkIncremental>
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
|
||||||
|
<IntDir>$(Configuration)\$(Platform)\obj\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
|
||||||
|
<IntDir>$(Configuration)\$(Platform)\obj\</IntDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
|
@ -62,7 +104,25 @@
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..\..;..\wolfcrypt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
<IgnoreSpecificDefaultLibraries>msvcrt.lib</IgnoreSpecificDefaultLibraries>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>..\..\..;..\wolfcrypt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
|
@ -81,11 +141,32 @@
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>..\..\..;..\wolfcrypt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>ws2_32.lib;advapi32.lib</AdditionalDependencies>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>..\..\..;..\wolfcrypt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>ws2_32.lib;advapi32.lib</AdditionalDependencies>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
</Link>
|
</Link>
|
||||||
|
@ -93,4 +174,4 @@
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -5,5 +5,7 @@ EXTRA_DIST+= ide/winvs/README.txt
|
||||||
EXTRA_DIST+= ide/winvs/wolfssh.sln
|
EXTRA_DIST+= ide/winvs/wolfssh.sln
|
||||||
EXTRA_DIST+= ide/winvs/wolfssh/wolfssh.vcxproj
|
EXTRA_DIST+= ide/winvs/wolfssh/wolfssh.vcxproj
|
||||||
EXTRA_DIST+= ide/winvs/api-test/api-test.vcxproj
|
EXTRA_DIST+= ide/winvs/api-test/api-test.vcxproj
|
||||||
|
EXTRA_DIST+= ide/winvs/unit-test/unit-test.vcxproj
|
||||||
EXTRA_DIST+= ide/winvs/echoserver/echoserver.vcxproj
|
EXTRA_DIST+= ide/winvs/echoserver/echoserver.vcxproj
|
||||||
EXTRA_DIST+= ide/winvs/user_settings.h
|
EXTRA_DIST+= ide/winvs/user_settings.h
|
||||||
|
EXTRA_DIST+= ide/winvs/wolfcrypt/README.txt
|
||||||
|
|
|
@ -0,0 +1,177 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\..\tests\unit.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\wolfssh\wolfssh.vcxproj">
|
||||||
|
<Project>{7c2ccf0d-a155-4914-bd1c-9a47c0530e65}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Library Include="..\wolfcrypt\wolfssl.lib" />
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{CBF8A91E-C52B-4044-9FDA-B99D5D3CFF02}</ProjectGuid>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<RootNamespace>unittest</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IntDir>$(Configuration)\$(Platform)\obj\</IntDir>
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IntDir>$(Configuration)\$(Platform)\obj\</IntDir>
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
|
||||||
|
<IntDir>$(Configuration)\$(Platform)\obj\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
|
||||||
|
<IntDir>$(Configuration)\$(Platform)\obj\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>..\..\..;..\wolfcrypt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
<IgnoreSpecificDefaultLibraries>msvcrt.lib</IgnoreSpecificDefaultLibraries>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>..\..\..;..\wolfcrypt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>ws2_32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||||
|
<IgnoreSpecificDefaultLibraries>msvcrt.lib</IgnoreSpecificDefaultLibraries>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>..\..\..;..\wolfcrypt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>ws2_32.lib;advapi32.lib</AdditionalDependencies>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>..\..\..;..\wolfcrypt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>ws2_32.lib;advapi32.lib</AdditionalDependencies>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,21 @@
|
||||||
|
WOLFCRYPT
|
||||||
|
|
||||||
|
This directory is provided as a convenience for the test and sample
|
||||||
|
tools to find the wolfSSL library and headers.
|
||||||
|
|
||||||
|
The library should just be copied into this directory with the name
|
||||||
|
`wolfssl.lib`. The headers that come with the library are in the
|
||||||
|
directory `wolfssl` and `wolfssl\wolfcrypt`. That wolfssl directory
|
||||||
|
should be copied here.
|
||||||
|
|
||||||
|
The following is a subset of files and the directories they live in,
|
||||||
|
as an example.
|
||||||
|
|
||||||
|
src\ssh.c
|
||||||
|
src\internal.c
|
||||||
|
wolfcrypt\readme.txt (this file)
|
||||||
|
wolfcrypt\wolfssl.lib
|
||||||
|
wolfcrypt\wolfssl\ssl.h
|
||||||
|
wolfcrypt\wolfssl\options.h
|
||||||
|
wolfcrypt\wolfssl\wolfcrypt\aes.h
|
||||||
|
wolfcrypt\wolfssl\wolfcrypt\user_settings.h
|
|
@ -13,24 +13,48 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "echoserver", "echoserver\ec
|
||||||
{7C2CCF0D-A155-4914-BD1C-9A47C0530E65} = {7C2CCF0D-A155-4914-BD1C-9A47C0530E65}
|
{7C2CCF0D-A155-4914-BD1C-9A47C0530E65} = {7C2CCF0D-A155-4914-BD1C-9A47C0530E65}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unit-test", "unit-test\unit-test.vcxproj", "{CBF8A91E-C52B-4044-9FDA-B99D5D3CFF02}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Win32 = Debug|Win32
|
Debug|Win32 = Debug|Win32
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
Release|Win32 = Release|Win32
|
Release|Win32 = Release|Win32
|
||||||
|
Release|x64 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{7C2CCF0D-A155-4914-BD1C-9A47C0530E65}.Debug|Win32.ActiveCfg = Debug|Win32
|
{7C2CCF0D-A155-4914-BD1C-9A47C0530E65}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{7C2CCF0D-A155-4914-BD1C-9A47C0530E65}.Debug|Win32.Build.0 = Debug|Win32
|
{7C2CCF0D-A155-4914-BD1C-9A47C0530E65}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{7C2CCF0D-A155-4914-BD1C-9A47C0530E65}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{7C2CCF0D-A155-4914-BD1C-9A47C0530E65}.Debug|x64.Build.0 = Debug|x64
|
||||||
{7C2CCF0D-A155-4914-BD1C-9A47C0530E65}.Release|Win32.ActiveCfg = Release|Win32
|
{7C2CCF0D-A155-4914-BD1C-9A47C0530E65}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{7C2CCF0D-A155-4914-BD1C-9A47C0530E65}.Release|Win32.Build.0 = Release|Win32
|
{7C2CCF0D-A155-4914-BD1C-9A47C0530E65}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{7C2CCF0D-A155-4914-BD1C-9A47C0530E65}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{7C2CCF0D-A155-4914-BD1C-9A47C0530E65}.Release|x64.Build.0 = Release|x64
|
||||||
{07D36DB5-210E-45A6-8270-2DAD9DCDEFD7}.Debug|Win32.ActiveCfg = Debug|Win32
|
{07D36DB5-210E-45A6-8270-2DAD9DCDEFD7}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{07D36DB5-210E-45A6-8270-2DAD9DCDEFD7}.Debug|Win32.Build.0 = Debug|Win32
|
{07D36DB5-210E-45A6-8270-2DAD9DCDEFD7}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{07D36DB5-210E-45A6-8270-2DAD9DCDEFD7}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{07D36DB5-210E-45A6-8270-2DAD9DCDEFD7}.Debug|x64.Build.0 = Debug|x64
|
||||||
{07D36DB5-210E-45A6-8270-2DAD9DCDEFD7}.Release|Win32.ActiveCfg = Release|Win32
|
{07D36DB5-210E-45A6-8270-2DAD9DCDEFD7}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{07D36DB5-210E-45A6-8270-2DAD9DCDEFD7}.Release|Win32.Build.0 = Release|Win32
|
{07D36DB5-210E-45A6-8270-2DAD9DCDEFD7}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{07D36DB5-210E-45A6-8270-2DAD9DCDEFD7}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{07D36DB5-210E-45A6-8270-2DAD9DCDEFD7}.Release|x64.Build.0 = Release|x64
|
||||||
{B4E163C2-ECA0-4DA2-9FD9-4CD6599C9D4D}.Debug|Win32.ActiveCfg = Debug|Win32
|
{B4E163C2-ECA0-4DA2-9FD9-4CD6599C9D4D}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{B4E163C2-ECA0-4DA2-9FD9-4CD6599C9D4D}.Debug|Win32.Build.0 = Debug|Win32
|
{B4E163C2-ECA0-4DA2-9FD9-4CD6599C9D4D}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{B4E163C2-ECA0-4DA2-9FD9-4CD6599C9D4D}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{B4E163C2-ECA0-4DA2-9FD9-4CD6599C9D4D}.Debug|x64.Build.0 = Debug|x64
|
||||||
{B4E163C2-ECA0-4DA2-9FD9-4CD6599C9D4D}.Release|Win32.ActiveCfg = Release|Win32
|
{B4E163C2-ECA0-4DA2-9FD9-4CD6599C9D4D}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
{B4E163C2-ECA0-4DA2-9FD9-4CD6599C9D4D}.Release|Win32.Build.0 = Release|Win32
|
{B4E163C2-ECA0-4DA2-9FD9-4CD6599C9D4D}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{B4E163C2-ECA0-4DA2-9FD9-4CD6599C9D4D}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{B4E163C2-ECA0-4DA2-9FD9-4CD6599C9D4D}.Release|x64.Build.0 = Release|x64
|
||||||
|
{CBF8A91E-C52B-4044-9FDA-B99D5D3CFF02}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{CBF8A91E-C52B-4044-9FDA-B99D5D3CFF02}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{CBF8A91E-C52B-4044-9FDA-B99D5D3CFF02}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{CBF8A91E-C52B-4044-9FDA-B99D5D3CFF02}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{CBF8A91E-C52B-4044-9FDA-B99D5D3CFF02}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{CBF8A91E-C52B-4044-9FDA-B99D5D3CFF02}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{CBF8A91E-C52B-4044-9FDA-B99D5D3CFF02}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{CBF8A91E-C52B-4044-9FDA-B99D5D3CFF02}.Release|x64.Build.0 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
|
@ -5,10 +5,18 @@
|
||||||
<Configuration>Debug</Configuration>
|
<Configuration>Debug</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
<Configuration>Release</Configuration>
|
<Configuration>Release</Configuration>
|
||||||
<Platform>Win32</Platform>
|
<Platform>Win32</Platform>
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\..\src\internal.c" />
|
<ClCompile Include="..\..\..\src\internal.c" />
|
||||||
|
@ -31,6 +39,12 @@
|
||||||
<PlatformToolset>v110</PlatformToolset>
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
@ -38,20 +52,45 @@
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v110</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Label="ExtensionSettings">
|
<ImportGroup Label="ExtensionSettings">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
|
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
|
||||||
<IntDir>$(Configuration)\$(Platform)\obj\</IntDir>
|
<IntDir>$(Configuration)\$(Platform)\obj\</IntDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
|
||||||
|
<IntDir>$(Configuration)\$(Platform)\obj\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
|
||||||
|
<IntDir>$(Configuration)\$(Platform)\obj\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\$(Platform)\</OutDir>
|
||||||
|
<IntDir>$(Configuration)\$(Platform)\obj\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<PrecompiledHeader>
|
<PrecompiledHeader>
|
||||||
|
@ -59,7 +98,22 @@
|
||||||
<WarningLevel>Level3</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;DEBUG_WOLFSSH;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;DEBUG_WOLFSSH;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\..\..;..\wolfcrypt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;DEBUG_WOLFSSH;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>..\..\..;..\wolfcrypt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
|
@ -75,7 +129,26 @@
|
||||||
<Optimization>MaxSpeed</Optimization>
|
<Optimization>MaxSpeed</Optimization>
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>..\..\..;..\wolfcrypt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>..\..\..;..\wolfcrypt;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -87,4 +160,4 @@
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
</Project>
|
</Project>
|
2687
src/internal.c
2687
src/internal.c
File diff suppressed because it is too large
Load Diff
4
src/io.c
4
src/io.c
|
@ -268,7 +268,7 @@ static INLINE int LastError(void)
|
||||||
/* The receive embedded callback
|
/* The receive embedded callback
|
||||||
* return : nb bytes read, or error
|
* return : nb bytes read, or error
|
||||||
*/
|
*/
|
||||||
int wsEmbedRecv(WOLFSSH* ssh, void* data, uint32_t sz, void* ctx)
|
int wsEmbedRecv(WOLFSSH* ssh, void* data, word32 sz, void* ctx)
|
||||||
{
|
{
|
||||||
int recvd;
|
int recvd;
|
||||||
int err;
|
int err;
|
||||||
|
@ -320,7 +320,7 @@ int wsEmbedRecv(WOLFSSH* ssh, void* data, uint32_t sz, void* ctx)
|
||||||
/* The send embedded callback
|
/* The send embedded callback
|
||||||
* return : nb bytes sent, or error
|
* return : nb bytes sent, or error
|
||||||
*/
|
*/
|
||||||
int wsEmbedSend(WOLFSSH* ssh, void* data, uint32_t sz, void* ctx)
|
int wsEmbedSend(WOLFSSH* ssh, void* data, word32 sz, void* ctx)
|
||||||
{
|
{
|
||||||
int sd = *(int*)ctx;
|
int sd = *(int*)ctx;
|
||||||
int sent;
|
int sent;
|
||||||
|
|
10
src/keygen.c
10
src/keygen.c
|
@ -29,12 +29,12 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <wolfssh/error.h>
|
|
||||||
#include <wolfssh/keygen.h>
|
|
||||||
#include <wolfssh/log.h>
|
|
||||||
#include <wolfssl/options.h>
|
#include <wolfssl/options.h>
|
||||||
#include <wolfssl/wolfcrypt/random.h>
|
#include <wolfssl/wolfcrypt/random.h>
|
||||||
#include <wolfssl/wolfcrypt/rsa.h>
|
#include <wolfssl/wolfcrypt/rsa.h>
|
||||||
|
#include <wolfssh/error.h>
|
||||||
|
#include <wolfssh/keygen.h>
|
||||||
|
#include <wolfssh/log.h>
|
||||||
|
|
||||||
#ifdef WOLFSSH_KEYGEN
|
#ifdef WOLFSSH_KEYGEN
|
||||||
|
|
||||||
|
@ -46,8 +46,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int wolfSSH_MakeRsaKey(uint8_t* out, uint32_t outSz,
|
int wolfSSH_MakeRsaKey(byte* out, word32 outSz,
|
||||||
uint32_t size, uint32_t e)
|
word32 size, word32 e)
|
||||||
{
|
{
|
||||||
int ret = WS_SUCCESS;
|
int ret = WS_SUCCESS;
|
||||||
WC_RNG rng;
|
WC_RNG rng;
|
||||||
|
|
18
src/misc.c
18
src/misc.c
|
@ -61,7 +61,7 @@
|
||||||
|
|
||||||
|
|
||||||
#ifndef min
|
#ifndef min
|
||||||
STATIC INLINE uint32_t min(uint32_t a, uint32_t b)
|
STATIC INLINE word32 min(word32 a, word32 b)
|
||||||
{
|
{
|
||||||
return a > b ? b : a;
|
return a > b ? b : a;
|
||||||
}
|
}
|
||||||
|
@ -69,14 +69,14 @@ STATIC INLINE uint32_t min(uint32_t a, uint32_t b)
|
||||||
|
|
||||||
|
|
||||||
/* convert opaque to 32 bit integer */
|
/* convert opaque to 32 bit integer */
|
||||||
STATIC INLINE void ato32(const uint8_t* c, uint32_t* u32)
|
STATIC INLINE void ato32(const byte* c, word32* u32)
|
||||||
{
|
{
|
||||||
*u32 = (c[0] << 24) | (c[1] << 16) | (c[2] << 8) | c[3];
|
*u32 = (c[0] << 24) | (c[1] << 16) | (c[2] << 8) | c[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* convert 32 bit integer to opaque */
|
/* convert 32 bit integer to opaque */
|
||||||
STATIC INLINE void c32toa(uint32_t u32, uint8_t* c)
|
STATIC INLINE void c32toa(word32 u32, byte* c)
|
||||||
{
|
{
|
||||||
c[0] = (u32 >> 24) & 0xff;
|
c[0] = (u32 >> 24) & 0xff;
|
||||||
c[1] = (u32 >> 16) & 0xff;
|
c[1] = (u32 >> 16) & 0xff;
|
||||||
|
@ -86,20 +86,20 @@ STATIC INLINE void c32toa(uint32_t u32, uint8_t* c)
|
||||||
|
|
||||||
|
|
||||||
/* Make sure compiler doesn't skip */
|
/* Make sure compiler doesn't skip */
|
||||||
STATIC INLINE void ForceZero(const void* mem, uint32_t length)
|
STATIC INLINE void ForceZero(const void* mem, word32 length)
|
||||||
{
|
{
|
||||||
volatile uint8_t* z = (volatile uint8_t*)mem;
|
volatile byte* z = (volatile byte*)mem;
|
||||||
|
|
||||||
while (length--) *z++ = 0;
|
while (length--) *z++ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* check all length bytes for equality, return 0 on success */
|
/* check all length bytes for equality, return 0 on success */
|
||||||
STATIC INLINE int ConstantCompare(const uint8_t* a, const uint8_t* b,
|
STATIC INLINE int ConstantCompare(const byte* a, const byte* b,
|
||||||
uint32_t length)
|
word32 length)
|
||||||
{
|
{
|
||||||
uint32_t i;
|
word32 i;
|
||||||
uint32_t compareSum = 0;
|
word32 compareSum = 0;
|
||||||
|
|
||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
compareSum |= a[i] ^ b[i];
|
compareSum |= a[i] ^ b[i];
|
||||||
|
|
16
src/port.c
16
src/port.c
|
@ -31,9 +31,24 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <wolfssh/port.h>
|
#include <wolfssh/port.h>
|
||||||
|
|
||||||
|
|
||||||
|
int wfopen(WFILE** f, const char* filename, const char* mode)
|
||||||
|
{
|
||||||
|
#ifdef USE_WINDOWS_API
|
||||||
|
return fopen_s(f, filename, mode) != 0;
|
||||||
|
#else
|
||||||
|
if (f != NULL) {
|
||||||
|
*f = fopen(filename, mode);
|
||||||
|
return *f == NULL;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef WSTRING_USER
|
#ifndef WSTRING_USER
|
||||||
|
|
||||||
char* wstrnstr(const char* s1, const char* s2, unsigned int n)
|
char* wstrnstr(const char* s1, const char* s2, unsigned int n)
|
||||||
|
@ -55,4 +70,3 @@ char* wstrnstr(const char* s1, const char* s2, unsigned int n)
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* WSTRING_USER */
|
#endif /* WSTRING_USER */
|
||||||
|
|
||||||
|
|
114
src/ssh.c
114
src/ssh.c
|
@ -56,13 +56,19 @@ int wolfSSH_Init(void)
|
||||||
|
|
||||||
int wolfSSH_Cleanup(void)
|
int wolfSSH_Cleanup(void)
|
||||||
{
|
{
|
||||||
|
int ret = WS_SUCCESS;
|
||||||
|
|
||||||
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_Cleanup()");
|
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_Cleanup()");
|
||||||
WLOG(WS_LOG_DEBUG, "Leaving wolfSSH_Cleanup(), returning %d", WS_SUCCESS);
|
|
||||||
return WS_SUCCESS;
|
if (wolfCrypt_Cleanup() != 0)
|
||||||
|
ret = WS_CRYPTO_FAILED;
|
||||||
|
|
||||||
|
WLOG(WS_LOG_DEBUG, "Leaving wolfSSH_Cleanup(), returning %d", ret);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WOLFSSH_CTX* wolfSSH_CTX_new(uint8_t side, void* heap)
|
WOLFSSH_CTX* wolfSSH_CTX_new(byte side, void* heap)
|
||||||
{
|
{
|
||||||
WOLFSSH_CTX* ctx;
|
WOLFSSH_CTX* ctx;
|
||||||
|
|
||||||
|
@ -74,7 +80,7 @@ WOLFSSH_CTX* wolfSSH_CTX_new(uint8_t side, void* heap)
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = (WOLFSSH_CTX*)WMALLOC(sizeof(WOLFSSH_CTX), heap, DYNTYPE_CTX);
|
ctx = (WOLFSSH_CTX*)WMALLOC(sizeof(WOLFSSH_CTX), heap, DYNTYPE_CTX);
|
||||||
ctx = CtxInit(ctx, heap);
|
ctx = CtxInit(ctx, side, heap);
|
||||||
|
|
||||||
WLOG(WS_LOG_DEBUG, "Leaving wolfSSH_CTX_new(), ctx = %p", ctx);
|
WLOG(WS_LOG_DEBUG, "Leaving wolfSSH_CTX_new(), ctx = %p", ctx);
|
||||||
|
|
||||||
|
@ -158,7 +164,7 @@ int wolfSSH_get_fd(const WOLFSSH* ssh)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int wolfSSH_SetHighwater(WOLFSSH* ssh, uint32_t highwater)
|
int wolfSSH_SetHighwater(WOLFSSH* ssh, word32 highwater)
|
||||||
{
|
{
|
||||||
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_SetHighwater()");
|
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_SetHighwater()");
|
||||||
|
|
||||||
|
@ -172,7 +178,7 @@ int wolfSSH_SetHighwater(WOLFSSH* ssh, uint32_t highwater)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t wolfSSH_GetHighwater(WOLFSSH* ssh)
|
word32 wolfSSH_GetHighwater(WOLFSSH* ssh)
|
||||||
{
|
{
|
||||||
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_GetHighwater()");
|
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_GetHighwater()");
|
||||||
|
|
||||||
|
@ -183,7 +189,7 @@ uint32_t wolfSSH_GetHighwater(WOLFSSH* ssh)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wolfSSH_SetHighwaterCb(WOLFSSH_CTX* ctx, uint32_t highwater,
|
void wolfSSH_SetHighwaterCb(WOLFSSH_CTX* ctx, word32 highwater,
|
||||||
WS_CallbackHighwater cb)
|
WS_CallbackHighwater cb)
|
||||||
{
|
{
|
||||||
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_SetHighwaterCb()");
|
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_SetHighwaterCb()");
|
||||||
|
@ -245,19 +251,23 @@ int wolfSSH_accept(WOLFSSH* ssh)
|
||||||
{
|
{
|
||||||
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_accept()");
|
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_accept()");
|
||||||
|
|
||||||
|
if (ssh == NULL)
|
||||||
|
return WS_BAD_ARGUMENT;
|
||||||
|
|
||||||
switch (ssh->acceptState) {
|
switch (ssh->acceptState) {
|
||||||
|
|
||||||
case ACCEPT_BEGIN:
|
case ACCEPT_BEGIN:
|
||||||
if ( (ssh->error = SendServerVersion(ssh)) < WS_SUCCESS) {
|
if ( (ssh->error = SendProtoId(ssh)) < WS_SUCCESS) {
|
||||||
WLOG(WS_LOG_DEBUG, acceptError, "BEGIN", ssh->error);
|
WLOG(WS_LOG_DEBUG, acceptError, "BEGIN", ssh->error);
|
||||||
return WS_FATAL_ERROR;
|
return WS_FATAL_ERROR;
|
||||||
}
|
}
|
||||||
ssh->acceptState = ACCEPT_SERVER_VERSION_SENT;
|
ssh->acceptState = ACCEPT_SERVER_VERSION_SENT;
|
||||||
WLOG(WS_LOG_DEBUG, acceptState, "SERVER_VERSION_SENT");
|
WLOG(WS_LOG_DEBUG, acceptState, "SERVER_VERSION_SENT");
|
||||||
|
FALL_THROUGH;
|
||||||
|
|
||||||
case ACCEPT_SERVER_VERSION_SENT:
|
case ACCEPT_SERVER_VERSION_SENT:
|
||||||
while (ssh->clientState < CLIENT_VERSION_DONE) {
|
while (ssh->clientState < CLIENT_VERSION_DONE) {
|
||||||
if ( (ssh->error = ProcessClientVersion(ssh)) < WS_SUCCESS) {
|
if ( (ssh->error = DoProtoId(ssh)) < WS_SUCCESS) {
|
||||||
WLOG(WS_LOG_DEBUG, acceptError,
|
WLOG(WS_LOG_DEBUG, acceptError,
|
||||||
"SERVER_VERSION_SENT", ssh->error);
|
"SERVER_VERSION_SENT", ssh->error);
|
||||||
return WS_FATAL_ERROR;
|
return WS_FATAL_ERROR;
|
||||||
|
@ -265,17 +275,29 @@ int wolfSSH_accept(WOLFSSH* ssh)
|
||||||
}
|
}
|
||||||
ssh->acceptState = ACCEPT_CLIENT_VERSION_DONE;
|
ssh->acceptState = ACCEPT_CLIENT_VERSION_DONE;
|
||||||
WLOG(WS_LOG_DEBUG, acceptState, "CLIENT_VERSION_DONE");
|
WLOG(WS_LOG_DEBUG, acceptState, "CLIENT_VERSION_DONE");
|
||||||
|
FALL_THROUGH;
|
||||||
|
|
||||||
case ACCEPT_CLIENT_VERSION_DONE:
|
case ACCEPT_CLIENT_VERSION_DONE:
|
||||||
while (ssh->keyingState < KEYING_KEYED) {
|
if ( (ssh->error = SendKexInit(ssh)) < WS_SUCCESS) {
|
||||||
|
WLOG(WS_LOG_DEBUG, acceptError,
|
||||||
|
"CLIENT_VERSION_DONE", ssh->error);
|
||||||
|
return WS_FATAL_ERROR;
|
||||||
|
}
|
||||||
|
ssh->acceptState = ACCEPT_SERVER_KEXINIT_SENT;
|
||||||
|
WLOG(WS_LOG_DEBUG, acceptState, "SERVER_KEXINIT_SENT");
|
||||||
|
FALL_THROUGH;
|
||||||
|
|
||||||
|
case ACCEPT_SERVER_KEXINIT_SENT:
|
||||||
|
while (ssh->isKeying) {
|
||||||
if ( (ssh->error = DoReceive(ssh)) < WS_SUCCESS) {
|
if ( (ssh->error = DoReceive(ssh)) < WS_SUCCESS) {
|
||||||
WLOG(WS_LOG_DEBUG, acceptError,
|
WLOG(WS_LOG_DEBUG, acceptError,
|
||||||
"CLIENT_VERSION_DONE", ssh->error);
|
"SERVER_KEXINIT_SENT", ssh->error);
|
||||||
return WS_FATAL_ERROR;
|
return WS_FATAL_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ssh->acceptState = ACCEPT_KEYED;
|
ssh->acceptState = ACCEPT_KEYED;
|
||||||
WLOG(WS_LOG_DEBUG, acceptState, "KEYED");
|
WLOG(WS_LOG_DEBUG, acceptState, "KEYED");
|
||||||
|
FALL_THROUGH;
|
||||||
|
|
||||||
case ACCEPT_KEYED:
|
case ACCEPT_KEYED:
|
||||||
while (ssh->clientState < CLIENT_USERAUTH_REQUEST_DONE) {
|
while (ssh->clientState < CLIENT_USERAUTH_REQUEST_DONE) {
|
||||||
|
@ -287,9 +309,11 @@ int wolfSSH_accept(WOLFSSH* ssh)
|
||||||
}
|
}
|
||||||
ssh->acceptState = ACCEPT_CLIENT_USERAUTH_REQUEST_DONE;
|
ssh->acceptState = ACCEPT_CLIENT_USERAUTH_REQUEST_DONE;
|
||||||
WLOG(WS_LOG_DEBUG, acceptState, "CLIENT_USERAUTH_REQUEST_DONE");
|
WLOG(WS_LOG_DEBUG, acceptState, "CLIENT_USERAUTH_REQUEST_DONE");
|
||||||
|
FALL_THROUGH;
|
||||||
|
|
||||||
case ACCEPT_CLIENT_USERAUTH_REQUEST_DONE:
|
case ACCEPT_CLIENT_USERAUTH_REQUEST_DONE:
|
||||||
if ( (ssh->error = SendServiceAccept(ssh)) < WS_SUCCESS) {
|
if ( (ssh->error = SendServiceAccept(ssh, ID_SERVICE_USERAUTH)) <
|
||||||
|
WS_SUCCESS) {
|
||||||
WLOG(WS_LOG_DEBUG, acceptError,
|
WLOG(WS_LOG_DEBUG, acceptError,
|
||||||
"CLIENT_USERAUTH_REQUEST_DONE", ssh->error);
|
"CLIENT_USERAUTH_REQUEST_DONE", ssh->error);
|
||||||
return WS_FATAL_ERROR;
|
return WS_FATAL_ERROR;
|
||||||
|
@ -297,6 +321,7 @@ int wolfSSH_accept(WOLFSSH* ssh)
|
||||||
ssh->acceptState = ACCEPT_SERVER_USERAUTH_ACCEPT_SENT;
|
ssh->acceptState = ACCEPT_SERVER_USERAUTH_ACCEPT_SENT;
|
||||||
WLOG(WS_LOG_DEBUG, acceptState,
|
WLOG(WS_LOG_DEBUG, acceptState,
|
||||||
"ACCEPT_SERVER_USERAUTH_ACCEPT_SENT");
|
"ACCEPT_SERVER_USERAUTH_ACCEPT_SENT");
|
||||||
|
FALL_THROUGH;
|
||||||
|
|
||||||
case ACCEPT_SERVER_USERAUTH_ACCEPT_SENT:
|
case ACCEPT_SERVER_USERAUTH_ACCEPT_SENT:
|
||||||
while (ssh->clientState < CLIENT_USERAUTH_DONE) {
|
while (ssh->clientState < CLIENT_USERAUTH_DONE) {
|
||||||
|
@ -308,6 +333,7 @@ int wolfSSH_accept(WOLFSSH* ssh)
|
||||||
}
|
}
|
||||||
ssh->acceptState = ACCEPT_CLIENT_USERAUTH_DONE;
|
ssh->acceptState = ACCEPT_CLIENT_USERAUTH_DONE;
|
||||||
WLOG(WS_LOG_DEBUG, acceptState, "CLIENT_USERAUTH_DONE");
|
WLOG(WS_LOG_DEBUG, acceptState, "CLIENT_USERAUTH_DONE");
|
||||||
|
FALL_THROUGH;
|
||||||
|
|
||||||
case ACCEPT_CLIENT_USERAUTH_DONE:
|
case ACCEPT_CLIENT_USERAUTH_DONE:
|
||||||
if ( (ssh->error = SendUserAuthSuccess(ssh)) < WS_SUCCESS) {
|
if ( (ssh->error = SendUserAuthSuccess(ssh)) < WS_SUCCESS) {
|
||||||
|
@ -317,6 +343,7 @@ int wolfSSH_accept(WOLFSSH* ssh)
|
||||||
}
|
}
|
||||||
ssh->acceptState = ACCEPT_SERVER_USERAUTH_SENT;
|
ssh->acceptState = ACCEPT_SERVER_USERAUTH_SENT;
|
||||||
WLOG(WS_LOG_DEBUG, acceptState, "SERVER_USERAUTH_SENT");
|
WLOG(WS_LOG_DEBUG, acceptState, "SERVER_USERAUTH_SENT");
|
||||||
|
FALL_THROUGH;
|
||||||
|
|
||||||
case ACCEPT_SERVER_USERAUTH_SENT:
|
case ACCEPT_SERVER_USERAUTH_SENT:
|
||||||
while (ssh->clientState < CLIENT_DONE) {
|
while (ssh->clientState < CLIENT_DONE) {
|
||||||
|
@ -328,6 +355,7 @@ int wolfSSH_accept(WOLFSSH* ssh)
|
||||||
}
|
}
|
||||||
ssh->acceptState = ACCEPT_CLIENT_CHANNEL_REQUEST_DONE;
|
ssh->acceptState = ACCEPT_CLIENT_CHANNEL_REQUEST_DONE;
|
||||||
WLOG(WS_LOG_DEBUG, acceptState, "CLIENT_CHANNEL_REQUEST_DONE");
|
WLOG(WS_LOG_DEBUG, acceptState, "CLIENT_CHANNEL_REQUEST_DONE");
|
||||||
|
FALL_THROUGH;
|
||||||
|
|
||||||
case ACCEPT_CLIENT_CHANNEL_REQUEST_DONE:
|
case ACCEPT_CLIENT_CHANNEL_REQUEST_DONE:
|
||||||
if ( (ssh->error = SendChannelOpenConf(ssh)) < WS_SUCCESS) {
|
if ( (ssh->error = SendChannelOpenConf(ssh)) < WS_SUCCESS) {
|
||||||
|
@ -343,6 +371,29 @@ int wolfSSH_accept(WOLFSSH* ssh)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int wolfSSH_shutdown(WOLFSSH* ssh)
|
||||||
|
{
|
||||||
|
int ret = WS_SUCCESS;
|
||||||
|
|
||||||
|
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_shutdown()");
|
||||||
|
|
||||||
|
if (ssh == NULL)
|
||||||
|
ret = WS_BAD_ARGUMENT;
|
||||||
|
|
||||||
|
if (ret == WS_SUCCESS)
|
||||||
|
ret = SendChannelEof(ssh, 0);
|
||||||
|
|
||||||
|
if (ret == WS_SUCCESS)
|
||||||
|
ret = SendChannelClose(ssh, 0);
|
||||||
|
|
||||||
|
if (ret == WS_SUCCESS)
|
||||||
|
ret = SendDisconnect(ssh, WOLFSSH_DISCONNECT_BY_APPLICATION);
|
||||||
|
|
||||||
|
WLOG(WS_LOG_DEBUG, "Leaving wolfSSH_shutdown(), ret = %d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int wolfSSH_TriggerKeyExchange(WOLFSSH* ssh)
|
int wolfSSH_TriggerKeyExchange(WOLFSSH* ssh)
|
||||||
{
|
{
|
||||||
int ret = WS_SUCCESS;
|
int ret = WS_SUCCESS;
|
||||||
|
@ -359,7 +410,7 @@ int wolfSSH_TriggerKeyExchange(WOLFSSH* ssh)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int wolfSSH_stream_read(WOLFSSH* ssh, uint8_t* buf, uint32_t bufSz)
|
int wolfSSH_stream_read(WOLFSSH* ssh, byte* buf, word32 bufSz)
|
||||||
{
|
{
|
||||||
Buffer* inputBuffer;
|
Buffer* inputBuffer;
|
||||||
|
|
||||||
|
@ -382,11 +433,10 @@ int wolfSSH_stream_read(WOLFSSH* ssh, uint8_t* buf, uint32_t bufSz)
|
||||||
WMEMCPY(buf, inputBuffer->buffer + inputBuffer->idx, bufSz);
|
WMEMCPY(buf, inputBuffer->buffer + inputBuffer->idx, bufSz);
|
||||||
inputBuffer->idx += bufSz;
|
inputBuffer->idx += bufSz;
|
||||||
|
|
||||||
if (ssh->keyingState == KEYING_KEYED &&
|
if (!ssh->isKeying && (inputBuffer->length > inputBuffer->bufferSz / 2)) {
|
||||||
(inputBuffer->length > inputBuffer->bufferSz / 2)) {
|
|
||||||
|
|
||||||
uint32_t usedSz = inputBuffer->length - inputBuffer->idx;
|
word32 usedSz = inputBuffer->length - inputBuffer->idx;
|
||||||
uint32_t bytesToAdd = inputBuffer->idx;
|
word32 bytesToAdd = inputBuffer->idx;
|
||||||
int sendResult;
|
int sendResult;
|
||||||
|
|
||||||
WLOG(WS_LOG_DEBUG, "Making more room: %u", usedSz);
|
WLOG(WS_LOG_DEBUG, "Making more room: %u", usedSz);
|
||||||
|
@ -416,7 +466,7 @@ int wolfSSH_stream_read(WOLFSSH* ssh, uint8_t* buf, uint32_t bufSz)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int wolfSSH_stream_send(WOLFSSH* ssh, uint8_t* buf, uint32_t bufSz)
|
int wolfSSH_stream_send(WOLFSSH* ssh, byte* buf, word32 bufSz)
|
||||||
{
|
{
|
||||||
int bytesTxd = 0;
|
int bytesTxd = 0;
|
||||||
|
|
||||||
|
@ -460,7 +510,7 @@ void* wolfSSH_GetUserAuthCtx(WOLFSSH* ssh)
|
||||||
int wolfSSH_CTX_SetBanner(WOLFSSH_CTX* ctx,
|
int wolfSSH_CTX_SetBanner(WOLFSSH_CTX* ctx,
|
||||||
const char* newBanner)
|
const char* newBanner)
|
||||||
{
|
{
|
||||||
uint32_t newBannerSz = 0;
|
word32 newBannerSz = 0;
|
||||||
|
|
||||||
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_CTX_SetBanner()");
|
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_CTX_SetBanner()");
|
||||||
|
|
||||||
|
@ -469,7 +519,7 @@ int wolfSSH_CTX_SetBanner(WOLFSSH_CTX* ctx,
|
||||||
|
|
||||||
if (newBanner != NULL) {
|
if (newBanner != NULL) {
|
||||||
WLOG(WS_LOG_INFO, " setting banner to: \"%s\"", newBanner);
|
WLOG(WS_LOG_INFO, " setting banner to: \"%s\"", newBanner);
|
||||||
newBannerSz = (uint32_t)WSTRLEN(newBanner);
|
newBannerSz = (word32)WSTRLEN(newBanner);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->banner = newBanner;
|
ctx->banner = newBanner;
|
||||||
|
@ -480,20 +530,20 @@ int wolfSSH_CTX_SetBanner(WOLFSSH_CTX* ctx,
|
||||||
|
|
||||||
|
|
||||||
int wolfSSH_CTX_UsePrivateKey_buffer(WOLFSSH_CTX* ctx,
|
int wolfSSH_CTX_UsePrivateKey_buffer(WOLFSSH_CTX* ctx,
|
||||||
const uint8_t* in, uint32_t inSz, int format)
|
const byte* in, word32 inSz, int format)
|
||||||
{
|
{
|
||||||
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_CTX_UsePrivateKey_buffer()");
|
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_CTX_UsePrivateKey_buffer()");
|
||||||
return ProcessBuffer(ctx, in, inSz, format, BUFTYPE_PRIVKEY);
|
return ProcessBuffer(ctx, in, inSz, format, BUFTYPE_PRIVKEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wolfSSH_GetStats(WOLFSSH* ssh, uint32_t* txCount, uint32_t* rxCount,
|
void wolfSSH_GetStats(WOLFSSH* ssh, word32* txCount, word32* rxCount,
|
||||||
uint32_t* seq, uint32_t* peerSeq)
|
word32* seq, word32* peerSeq)
|
||||||
{
|
{
|
||||||
uint32_t rTxCount = 0;
|
word32 rTxCount = 0;
|
||||||
uint32_t rRxCount = 0;
|
word32 rRxCount = 0;
|
||||||
uint32_t rSeq = 0;
|
word32 rSeq = 0;
|
||||||
uint32_t rPeerSeq = 0;
|
word32 rPeerSeq = 0;
|
||||||
|
|
||||||
if (ssh != NULL) {
|
if (ssh != NULL) {
|
||||||
rTxCount = ssh->txCount;
|
rTxCount = ssh->txCount;
|
||||||
|
@ -513,11 +563,11 @@ void wolfSSH_GetStats(WOLFSSH* ssh, uint32_t* txCount, uint32_t* rxCount,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int wolfSSH_KDF(uint8_t hashId, uint8_t keyId,
|
int wolfSSH_KDF(byte hashId, byte keyId,
|
||||||
uint8_t* key, uint32_t keySz,
|
byte* key, word32 keySz,
|
||||||
const uint8_t* k, uint32_t kSz,
|
const byte* k, word32 kSz,
|
||||||
const uint8_t* h, uint32_t hSz,
|
const byte* h, word32 hSz,
|
||||||
const uint8_t* sessionId, uint32_t sessionIdSz)
|
const byte* sessionId, word32 sessionIdSz)
|
||||||
{
|
{
|
||||||
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_KDF()");
|
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_KDF()");
|
||||||
return GenerateKey(hashId, keyId, key, keySz, k, kSz, h, hSz,
|
return GenerateKey(hashId, keyId, key, keySz, k, kSz, h, hSz,
|
||||||
|
|
31
tests/api.c
31
tests/api.c
|
@ -124,6 +124,36 @@ static void test_client_wolfSSH_new(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void test_wolfSSH_SetUsername(void)
|
||||||
|
{
|
||||||
|
#ifndef WOLFSSH_NO_CLIENT
|
||||||
|
WOLFSSH_CTX* ctx;
|
||||||
|
WOLFSSH* ssh;
|
||||||
|
const char username[] = "johnny";
|
||||||
|
const char empty[] = "";
|
||||||
|
|
||||||
|
|
||||||
|
AssertIntNE(WS_SUCCESS, wolfSSH_SetUsername(NULL, NULL));
|
||||||
|
|
||||||
|
AssertNotNull(ctx = wolfSSH_CTX_new(WOLFSSH_ENDPOINT_SERVER, NULL));
|
||||||
|
AssertNotNull(ssh = wolfSSH_new(ctx));
|
||||||
|
AssertIntNE(WS_SUCCESS, wolfSSH_SetUsername(ssh, username));
|
||||||
|
wolfSSH_free(ssh);
|
||||||
|
wolfSSH_CTX_free(ctx);
|
||||||
|
|
||||||
|
AssertNotNull(ctx = wolfSSH_CTX_new(WOLFSSH_ENDPOINT_CLIENT, NULL));
|
||||||
|
AssertNotNull(ssh = wolfSSH_new(ctx));
|
||||||
|
AssertIntNE(WS_SUCCESS, wolfSSH_SetUsername(ssh, NULL));
|
||||||
|
AssertIntNE(WS_SUCCESS, wolfSSH_SetUsername(ssh, empty));
|
||||||
|
wolfSSH_free(ssh);
|
||||||
|
AssertNotNull(ssh = wolfSSH_new(ctx));
|
||||||
|
AssertIntEQ(WS_SUCCESS, wolfSSH_SetUsername(ssh, username));
|
||||||
|
wolfSSH_free(ssh);
|
||||||
|
wolfSSH_CTX_free(ctx);
|
||||||
|
#endif /* WOLFSSH_NO_CLIENT */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
AssertIntEQ(wolfSSH_Init(), WS_SUCCESS);
|
AssertIntEQ(wolfSSH_Init(), WS_SUCCESS);
|
||||||
|
@ -131,6 +161,7 @@ int main(void)
|
||||||
test_wolfSSH_CTX_new();
|
test_wolfSSH_CTX_new();
|
||||||
test_server_wolfSSH_new();
|
test_server_wolfSSH_new();
|
||||||
test_client_wolfSSH_new();
|
test_client_wolfSSH_new();
|
||||||
|
test_wolfSSH_SetUsername();
|
||||||
|
|
||||||
AssertIntEQ(wolfSSH_Cleanup(), WS_SUCCESS);
|
AssertIntEQ(wolfSSH_Cleanup(), WS_SUCCESS);
|
||||||
|
|
||||||
|
|
74
tests/unit.c
74
tests/unit.c
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
#define BAD 0xFF
|
#define BAD 0xFF
|
||||||
|
|
||||||
const uint8_t hexDecode[] =
|
const byte hexDecode[] =
|
||||||
{
|
{
|
||||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
||||||
BAD, BAD, BAD, BAD, BAD, BAD, BAD,
|
BAD, BAD, BAD, BAD, BAD, BAD, BAD,
|
||||||
|
@ -42,14 +42,14 @@ const uint8_t hexDecode[] =
|
||||||
}; /* A starts at 0x41 not 0x3A */
|
}; /* A starts at 0x41 not 0x3A */
|
||||||
|
|
||||||
|
|
||||||
static int Base16_Decode(const uint8_t* in, uint32_t inLen,
|
static int Base16_Decode(const byte* in, word32 inLen,
|
||||||
uint8_t* out, uint32_t* outLen)
|
byte* out, word32* outLen)
|
||||||
{
|
{
|
||||||
uint32_t inIdx = 0;
|
word32 inIdx = 0;
|
||||||
uint32_t outIdx = 0;
|
word32 outIdx = 0;
|
||||||
|
|
||||||
if (inLen == 1 && *outLen && in) {
|
if (inLen == 1 && *outLen && in) {
|
||||||
uint8_t b = in[inIdx++] - 0x30; /* 0 starts at 0x30 */
|
byte b = in[inIdx++] - 0x30; /* 0 starts at 0x30 */
|
||||||
|
|
||||||
/* sanity check */
|
/* sanity check */
|
||||||
if (b >= sizeof(hexDecode)/sizeof(hexDecode[0]))
|
if (b >= sizeof(hexDecode)/sizeof(hexDecode[0]))
|
||||||
|
@ -73,8 +73,8 @@ static int Base16_Decode(const uint8_t* in, uint32_t inLen,
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
while (inLen) {
|
while (inLen) {
|
||||||
uint8_t b = in[inIdx++] - 0x30; /* 0 starts at 0x30 */
|
byte b = in[inIdx++] - 0x30; /* 0 starts at 0x30 */
|
||||||
uint8_t b2 = in[inIdx++] - 0x30;
|
byte b2 = in[inIdx++] - 0x30;
|
||||||
|
|
||||||
/* sanity checks */
|
/* sanity checks */
|
||||||
if (b >= sizeof(hexDecode)/sizeof(hexDecode[0]))
|
if (b >= sizeof(hexDecode)/sizeof(hexDecode[0]))
|
||||||
|
@ -88,7 +88,7 @@ static int Base16_Decode(const uint8_t* in, uint32_t inLen,
|
||||||
if (b == BAD || b2 == BAD)
|
if (b == BAD || b2 == BAD)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
out[outIdx++] = (uint8_t)((b << 4) | b2);
|
out[outIdx++] = (byte)((b << 4) | b2);
|
||||||
inLen -= 2;
|
inLen -= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ static int Base16_Decode(const uint8_t* in, uint32_t inLen,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void FreeBins(uint8_t* b1, uint8_t* b2, uint8_t* b3, uint8_t* b4)
|
static void FreeBins(byte* b1, byte* b2, byte* b3, byte* b4)
|
||||||
{
|
{
|
||||||
if (b1 != NULL) free(b1);
|
if (b1 != NULL) free(b1);
|
||||||
if (b2 != NULL) free(b2);
|
if (b2 != NULL) free(b2);
|
||||||
|
@ -107,20 +107,20 @@ static void FreeBins(uint8_t* b1, uint8_t* b2, uint8_t* b3, uint8_t* b4)
|
||||||
|
|
||||||
|
|
||||||
/* convert hex string to binary, store size, 0 success (free mem on failure) */
|
/* convert hex string to binary, store size, 0 success (free mem on failure) */
|
||||||
static int ConvertHexToBin(const char* h1, uint8_t** b1, uint32_t* b1Sz,
|
static int ConvertHexToBin(const char* h1, byte** b1, word32* b1Sz,
|
||||||
const char* h2, uint8_t** b2, uint32_t* b2Sz,
|
const char* h2, byte** b2, word32* b2Sz,
|
||||||
const char* h3, uint8_t** b3, uint32_t* b3Sz,
|
const char* h3, byte** b3, word32* b3Sz,
|
||||||
const char* h4, uint8_t** b4, uint32_t* b4Sz)
|
const char* h4, byte** b4, word32* b4Sz)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* b1 */
|
/* b1 */
|
||||||
if (h1 && b1 && b1Sz) {
|
if (h1 && b1 && b1Sz) {
|
||||||
*b1Sz = (uint32_t)strlen(h1) / 2;
|
*b1Sz = (word32)strlen(h1) / 2;
|
||||||
*b1 = (uint8_t*)malloc(*b1Sz);
|
*b1 = (byte*)malloc(*b1Sz);
|
||||||
if (*b1 == NULL)
|
if (*b1 == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
ret = Base16_Decode((const uint8_t*)h1, (uint32_t)strlen(h1),
|
ret = Base16_Decode((const byte*)h1, (word32)strlen(h1),
|
||||||
*b1, b1Sz);
|
*b1, b1Sz);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
FreeBins(*b1, NULL, NULL, NULL);
|
FreeBins(*b1, NULL, NULL, NULL);
|
||||||
|
@ -130,13 +130,13 @@ static int ConvertHexToBin(const char* h1, uint8_t** b1, uint32_t* b1Sz,
|
||||||
|
|
||||||
/* b2 */
|
/* b2 */
|
||||||
if (h2 && b2 && b2Sz) {
|
if (h2 && b2 && b2Sz) {
|
||||||
*b2Sz = (uint32_t)strlen(h2) / 2;
|
*b2Sz = (word32)strlen(h2) / 2;
|
||||||
*b2 = (uint8_t*)malloc(*b2Sz);
|
*b2 = (byte*)malloc(*b2Sz);
|
||||||
if (*b2 == NULL) {
|
if (*b2 == NULL) {
|
||||||
FreeBins(b1 ? *b1 : NULL, NULL, NULL, NULL);
|
FreeBins(b1 ? *b1 : NULL, NULL, NULL, NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ret = Base16_Decode((const uint8_t*)h2, (uint32_t)strlen(h2),
|
ret = Base16_Decode((const byte*)h2, (word32)strlen(h2),
|
||||||
*b2, b2Sz);
|
*b2, b2Sz);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
FreeBins(b1 ? *b1 : NULL, *b2, NULL, NULL);
|
FreeBins(b1 ? *b1 : NULL, *b2, NULL, NULL);
|
||||||
|
@ -146,13 +146,13 @@ static int ConvertHexToBin(const char* h1, uint8_t** b1, uint32_t* b1Sz,
|
||||||
|
|
||||||
/* b3 */
|
/* b3 */
|
||||||
if (h3 && b3 && b3Sz) {
|
if (h3 && b3 && b3Sz) {
|
||||||
*b3Sz = (uint32_t)strlen(h3) / 2;
|
*b3Sz = (word32)strlen(h3) / 2;
|
||||||
*b3 = (uint8_t*)malloc(*b3Sz);
|
*b3 = (byte*)malloc(*b3Sz);
|
||||||
if (*b3 == NULL) {
|
if (*b3 == NULL) {
|
||||||
FreeBins(b1 ? *b1 : NULL, b2 ? *b2 : NULL, NULL, NULL);
|
FreeBins(b1 ? *b1 : NULL, b2 ? *b2 : NULL, NULL, NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ret = Base16_Decode((const uint8_t*)h3, (uint32_t)strlen(h3),
|
ret = Base16_Decode((const byte*)h3, (word32)strlen(h3),
|
||||||
*b3, b3Sz);
|
*b3, b3Sz);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
FreeBins(b1 ? *b1 : NULL, b2 ? *b2 : NULL, *b3, NULL);
|
FreeBins(b1 ? *b1 : NULL, b2 ? *b2 : NULL, *b3, NULL);
|
||||||
|
@ -162,13 +162,13 @@ static int ConvertHexToBin(const char* h1, uint8_t** b1, uint32_t* b1Sz,
|
||||||
|
|
||||||
/* b4 */
|
/* b4 */
|
||||||
if (h4 && b4 && b4Sz) {
|
if (h4 && b4 && b4Sz) {
|
||||||
*b4Sz = (uint32_t)strlen(h4) / 2;
|
*b4Sz = (word32)strlen(h4) / 2;
|
||||||
*b4 = (uint8_t*)malloc(*b4Sz);
|
*b4 = (byte*)malloc(*b4Sz);
|
||||||
if (*b4 == NULL) {
|
if (*b4 == NULL) {
|
||||||
FreeBins(b1 ? *b1 : NULL, b2 ? *b2 : NULL, b3 ? *b3 : NULL, NULL);
|
FreeBins(b1 ? *b1 : NULL, b2 ? *b2 : NULL, b3 ? *b3 : NULL, NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ret = Base16_Decode((const uint8_t*)h4, (uint32_t)strlen(h4),
|
ret = Base16_Decode((const byte*)h4, (word32)strlen(h4),
|
||||||
*b4, b4Sz);
|
*b4, b4Sz);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
FreeBins(b1 ? *b1 : NULL, b2 ? *b2 : NULL, b3 ? *b3 : NULL, *b4);
|
FreeBins(b1 ? *b1 : NULL, b2 ? *b2 : NULL, b3 ? *b3 : NULL, *b4);
|
||||||
|
@ -183,8 +183,8 @@ static int ConvertHexToBin(const char* h1, uint8_t** b1, uint32_t* b1Sz,
|
||||||
/* Key Derivation Function (KDF) Unit Test */
|
/* Key Derivation Function (KDF) Unit Test */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t hashId;
|
byte hashId;
|
||||||
uint8_t keyId;
|
byte keyId;
|
||||||
const char* k;
|
const char* k;
|
||||||
const char* h;
|
const char* h;
|
||||||
const char* sessionId;
|
const char* sessionId;
|
||||||
|
@ -310,15 +310,15 @@ static const KdfTestVector kdfTestVectors[] = {
|
||||||
static int test_KDF(void)
|
static int test_KDF(void)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
uint32_t i;
|
word32 i;
|
||||||
uint32_t tc = sizeof(kdfTestVectors)/sizeof(KdfTestVector);
|
word32 tc = sizeof(kdfTestVectors)/sizeof(KdfTestVector);
|
||||||
const KdfTestVector* tv = NULL;
|
const KdfTestVector* tv = NULL;
|
||||||
uint8_t* k = NULL;
|
byte* k = NULL;
|
||||||
uint8_t* h = NULL;
|
byte* h = NULL;
|
||||||
uint8_t* sId = NULL;
|
byte* sId = NULL;
|
||||||
uint8_t* eKey = NULL;
|
byte* eKey = NULL;
|
||||||
uint32_t kSz, hSz, sIdSz, eKeySz;
|
word32 kSz, hSz, sIdSz, eKeySz;
|
||||||
uint8_t cKey[20]; /* Greater of SHA_DIGEST_SIZE and AES_BLOCK_SIZE */
|
byte cKey[32]; /* Greater of SHA256_DIGEST_SIZE and AES_BLOCK_SIZE */
|
||||||
/* sId - Session ID, eKey - Expected Key, cKey - Calculated Key */
|
/* sId - Session ID, eKey - Expected Key, cKey - Calculated Key */
|
||||||
|
|
||||||
for (i = 0, tv = kdfTestVectors; i < tc; i++, tv++) {
|
for (i = 0, tv = kdfTestVectors; i < tc; i++, tv++) {
|
||||||
|
@ -362,7 +362,7 @@ static int test_KDF(void)
|
||||||
static int test_RsaKeyGen(void)
|
static int test_RsaKeyGen(void)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
uint8_t der[1200];
|
byte der[1200];
|
||||||
int derSz;
|
int derSz;
|
||||||
|
|
||||||
derSz = wolfSSH_MakeRsaKey(der, sizeof(der),
|
derSz = wolfSSH_MakeRsaKey(der, sizeof(der),
|
||||||
|
|
|
@ -70,7 +70,8 @@ enum WS_ErrorCodes {
|
||||||
WS_INVALID_STATE_E = -30,
|
WS_INVALID_STATE_E = -30,
|
||||||
WS_REKEYING = -31,
|
WS_REKEYING = -31,
|
||||||
WS_INVALID_PRIME_CURVE = -32,
|
WS_INVALID_PRIME_CURVE = -32,
|
||||||
WS_ECC_E = -33
|
WS_ECC_E = -33,
|
||||||
|
WS_CHANOPEN_FAILED = -34
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,11 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <wolfssh/ssh.h>
|
#include <wolfssh/ssh.h>
|
||||||
#include <wolfssl/options.h>
|
|
||||||
#include <wolfssl/wolfcrypt/hash.h>
|
#include <wolfssl/wolfcrypt/hash.h>
|
||||||
#include <wolfssl/wolfcrypt/random.h>
|
#include <wolfssl/wolfcrypt/random.h>
|
||||||
#include <wolfssl/wolfcrypt/aes.h>
|
#include <wolfssl/wolfcrypt/aes.h>
|
||||||
|
#include <wolfssl/wolfcrypt/dh.h>
|
||||||
|
#include <wolfssl/wolfcrypt/ecc.h>
|
||||||
|
|
||||||
|
|
||||||
#if !defined (ALIGN16)
|
#if !defined (ALIGN16)
|
||||||
|
@ -82,6 +83,10 @@ enum {
|
||||||
ID_ECDSA_SHA2_NISTP384,
|
ID_ECDSA_SHA2_NISTP384,
|
||||||
ID_ECDSA_SHA2_NISTP521,
|
ID_ECDSA_SHA2_NISTP521,
|
||||||
|
|
||||||
|
/* Service IDs */
|
||||||
|
ID_SERVICE_USERAUTH,
|
||||||
|
ID_SERVICE_CONNECTION,
|
||||||
|
|
||||||
/* UserAuth IDs */
|
/* UserAuth IDs */
|
||||||
ID_USERAUTH_PASSWORD,
|
ID_USERAUTH_PASSWORD,
|
||||||
ID_USERAUTH_PUBLICKEY,
|
ID_USERAUTH_PUBLICKEY,
|
||||||
|
@ -93,25 +98,25 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define MAX_ENCRYPTION 3
|
#define MAX_ENCRYPTION 3
|
||||||
#define MAX_INTEGRITY 2
|
#define MAX_INTEGRITY 2
|
||||||
#define MAX_KEY_EXCHANGE 2
|
#define MAX_KEY_EXCHANGE 2
|
||||||
#define MAX_PUBLIC_KEY 1
|
#define MAX_PUBLIC_KEY 1
|
||||||
#define MAX_HMAC_SZ SHA256_DIGEST_SIZE
|
#define MAX_HMAC_SZ SHA256_DIGEST_SIZE
|
||||||
#define MIN_BLOCK_SZ 8
|
#define MIN_BLOCK_SZ 8
|
||||||
#define COOKIE_SZ 16
|
#define COOKIE_SZ 16
|
||||||
#define LENGTH_SZ 4
|
#define LENGTH_SZ 4
|
||||||
#define PAD_LENGTH_SZ 1
|
#define PAD_LENGTH_SZ 1
|
||||||
#define MIN_PAD_LENGTH 4
|
#define MIN_PAD_LENGTH 4
|
||||||
#define BOOLEAN_SZ 1
|
#define BOOLEAN_SZ 1
|
||||||
#define MSG_ID_SZ 1
|
#define MSG_ID_SZ 1
|
||||||
#define SHA1_96_SZ 12
|
#define SHA1_96_SZ 12
|
||||||
#define UINT32_SZ 4
|
#define UINT32_SZ 4
|
||||||
#define SSH_PROTO_SZ 7 /* "SSH-2.0" */
|
#define SSH_PROTO_SZ 7 /* "SSH-2.0" */
|
||||||
#define SSH_PROTO_EOL_SZ 2 /* Just the CRLF */
|
#define SSH_PROTO_EOL_SZ 2 /* Just the CRLF */
|
||||||
#define AEAD_IMP_IV_SZ 4
|
#define AEAD_IMP_IV_SZ 4
|
||||||
#define AEAD_EXP_IV_SZ 8
|
#define AEAD_EXP_IV_SZ 8
|
||||||
#define AEAD_NONCE_SZ (AEAD_IMP_IV_SZ+AEAD_EXP_IV_SZ)
|
#define AEAD_NONCE_SZ (AEAD_IMP_IV_SZ+AEAD_EXP_IV_SZ)
|
||||||
#ifndef DEFAULT_HIGHWATER_MARK
|
#ifndef DEFAULT_HIGHWATER_MARK
|
||||||
#define DEFAULT_HIGHWATER_MARK ((1024 * 1024 * 1024) - (32 * 1024))
|
#define DEFAULT_HIGHWATER_MARK ((1024 * 1024 * 1024) - (32 * 1024))
|
||||||
#endif
|
#endif
|
||||||
|
@ -121,11 +126,13 @@ enum {
|
||||||
#ifndef DEFAULT_MAX_PACKET_SZ
|
#ifndef DEFAULT_MAX_PACKET_SZ
|
||||||
#define DEFAULT_MAX_PACKET_SZ (16 * 1024)
|
#define DEFAULT_MAX_PACKET_SZ (16 * 1024)
|
||||||
#endif
|
#endif
|
||||||
#define DEFAULT_NEXT_CHANNEL 13013
|
#ifndef DEFAULT_NEXT_CHANNEL
|
||||||
|
#define DEFAULT_NEXT_CHANNEL 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
WOLFSSH_LOCAL uint8_t NameToId(const char*, uint32_t);
|
WOLFSSH_LOCAL byte NameToId(const char*, word32);
|
||||||
WOLFSSH_LOCAL const char* IdToName(uint8_t);
|
WOLFSSH_LOCAL const char* IdToName(byte);
|
||||||
|
|
||||||
|
|
||||||
#define STATIC_BUFFER_LEN AES_BLOCK_SIZE
|
#define STATIC_BUFFER_LEN AES_BLOCK_SIZE
|
||||||
|
@ -135,35 +142,37 @@ WOLFSSH_LOCAL const char* IdToName(uint8_t);
|
||||||
|
|
||||||
|
|
||||||
typedef struct Buffer {
|
typedef struct Buffer {
|
||||||
void* heap; /* Heap for allocations */
|
void* heap; /* Heap for allocations */
|
||||||
uint32_t length; /* total buffer length used */
|
word32 length; /* total buffer length used */
|
||||||
uint32_t idx; /* idx to part of length already consumed */
|
word32 idx; /* idx to part of length already consumed */
|
||||||
uint8_t* buffer; /* place holder for actual buffer */
|
byte* buffer; /* place holder for actual buffer */
|
||||||
uint32_t bufferSz; /* current buffer size */
|
word32 bufferSz; /* current buffer size */
|
||||||
ALIGN16 uint8_t staticBuffer[STATIC_BUFFER_LEN];
|
ALIGN16 byte staticBuffer[STATIC_BUFFER_LEN];
|
||||||
uint8_t dynamicFlag; /* dynamic memory currently in use */
|
byte dynamicFlag; /* dynamic memory currently in use */
|
||||||
} Buffer;
|
} Buffer;
|
||||||
|
|
||||||
|
|
||||||
WOLFSSH_LOCAL int BufferInit(Buffer*, uint32_t, void*);
|
WOLFSSH_LOCAL int BufferInit(Buffer*, word32, void*);
|
||||||
WOLFSSH_LOCAL int GrowBuffer(Buffer*, uint32_t, uint32_t);
|
WOLFSSH_LOCAL int GrowBuffer(Buffer*, word32, word32);
|
||||||
WOLFSSH_LOCAL void ShrinkBuffer(Buffer* buf, int);
|
WOLFSSH_LOCAL void ShrinkBuffer(Buffer* buf, int);
|
||||||
|
|
||||||
|
|
||||||
/* our wolfSSH Context */
|
/* our wolfSSH Context */
|
||||||
struct WOLFSSH_CTX {
|
struct WOLFSSH_CTX {
|
||||||
void* heap; /* heap hint */
|
void* heap; /* heap hint */
|
||||||
WS_CallbackIORecv ioRecvCb; /* I/O Receive Callback */
|
WS_CallbackIORecv ioRecvCb; /* I/O Receive Callback */
|
||||||
WS_CallbackIOSend ioSendCb; /* I/O Send Callback */
|
WS_CallbackIOSend ioSendCb; /* I/O Send Callback */
|
||||||
WS_CallbackUserAuth userAuthCb; /* User Authentication Callback */
|
WS_CallbackUserAuth userAuthCb; /* User Authentication Callback */
|
||||||
WS_CallbackHighwater highwaterCb; /* Data Highwater Mark Callback */
|
WS_CallbackHighwater highwaterCb; /* Data Highwater Mark Callback */
|
||||||
|
|
||||||
uint8_t* privateKey; /* Owned by CTX */
|
byte* privateKey; /* Owned by CTX */
|
||||||
uint32_t privateKeySz;
|
word32 privateKeySz;
|
||||||
uint8_t useEcc; /* Depends on the private key */
|
byte useEcc; /* Depends on the private key */
|
||||||
uint32_t highwaterMark;
|
word32 highwaterMark;
|
||||||
const char* banner;
|
const char* banner;
|
||||||
uint32_t bannerSz;
|
word32 bannerSz;
|
||||||
|
byte side; /* client or server */
|
||||||
|
byte showBanner;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -173,202 +182,205 @@ typedef struct Ciphers {
|
||||||
|
|
||||||
|
|
||||||
typedef struct Keys {
|
typedef struct Keys {
|
||||||
uint8_t iv[AES_BLOCK_SIZE];
|
byte iv[AES_BLOCK_SIZE];
|
||||||
uint8_t ivSz;
|
byte ivSz;
|
||||||
uint8_t encKey[AES_BLOCK_SIZE];
|
byte encKey[AES_BLOCK_SIZE];
|
||||||
uint8_t encKeySz;
|
byte encKeySz;
|
||||||
uint8_t macKey[MAX_HMAC_SZ];
|
byte macKey[MAX_HMAC_SZ];
|
||||||
uint8_t macKeySz;
|
byte macKeySz;
|
||||||
} Keys;
|
} Keys;
|
||||||
|
|
||||||
|
|
||||||
typedef struct HandshakeInfo {
|
typedef struct HandshakeInfo {
|
||||||
uint8_t kexId;
|
byte kexId;
|
||||||
uint8_t pubKeyId;
|
byte pubKeyId;
|
||||||
uint8_t encryptId;
|
byte encryptId;
|
||||||
uint8_t macId;
|
byte macId;
|
||||||
uint8_t hashId;
|
byte hashId;
|
||||||
uint8_t kexPacketFollows;
|
byte kexPacketFollows;
|
||||||
uint8_t aeadMode;
|
byte aeadMode;
|
||||||
|
|
||||||
uint8_t blockSz;
|
byte blockSz;
|
||||||
uint8_t macSz;
|
byte macSz;
|
||||||
|
|
||||||
Keys clientKeys;
|
Keys keys;
|
||||||
Keys serverKeys;
|
Keys peerKeys;
|
||||||
wc_HashAlg hash;
|
wc_HashAlg hash;
|
||||||
uint8_t e[257]; /* May have a leading zero, for unsigned, or
|
byte e[257]; /* May have a leading zero for unsigned or is a Q_S value. */
|
||||||
* it is a nistp521 Q_S value. */
|
word32 eSz;
|
||||||
uint32_t eSz;
|
byte x[257]; /* May have a leading zero, for unsigned. */
|
||||||
uint8_t* serverKexInit;
|
word32 xSz;
|
||||||
uint32_t serverKexInitSz;
|
byte* kexInit;
|
||||||
|
word32 kexInitSz;
|
||||||
|
|
||||||
uint32_t dhGexMinSz;
|
word32 dhGexMinSz;
|
||||||
uint32_t dhGexPreferredSz;
|
word32 dhGexPreferredSz;
|
||||||
uint32_t dhGexMaxSz;
|
word32 dhGexMaxSz;
|
||||||
|
byte* primeGroup;
|
||||||
|
word32 primeGroupSz;
|
||||||
|
byte* generator;
|
||||||
|
word32 generatorSz;
|
||||||
|
|
||||||
|
byte useEcc;
|
||||||
|
union {
|
||||||
|
DhKey dh;
|
||||||
|
ecc_key ecc;
|
||||||
|
} privKey;
|
||||||
} HandshakeInfo;
|
} HandshakeInfo;
|
||||||
|
|
||||||
|
|
||||||
/* our wolfSSH session */
|
/* our wolfSSH session */
|
||||||
struct WOLFSSH {
|
struct WOLFSSH {
|
||||||
WOLFSSH_CTX* ctx; /* owner context */
|
WOLFSSH_CTX* ctx; /* owner context */
|
||||||
int error;
|
int error;
|
||||||
int rfd;
|
int rfd;
|
||||||
int wfd;
|
int wfd;
|
||||||
void* ioReadCtx; /* I/O Read Context handle */
|
void* ioReadCtx; /* I/O Read Context handle */
|
||||||
void* ioWriteCtx; /* I/O Write Context handle */
|
void* ioWriteCtx; /* I/O Write Context handle */
|
||||||
int rflags; /* optional read flags */
|
int rflags; /* optional read flags */
|
||||||
int wflags; /* optional write flags */
|
int wflags; /* optional write flags */
|
||||||
uint32_t txCount;
|
word32 txCount;
|
||||||
uint32_t rxCount;
|
word32 rxCount;
|
||||||
uint32_t highwaterMark;
|
word32 highwaterMark;
|
||||||
uint8_t highwaterFlag; /* Set when highwater CB called */
|
byte highwaterFlag; /* Set when highwater CB called */
|
||||||
void* highwaterCtx;
|
void* highwaterCtx;
|
||||||
uint32_t curSz;
|
word32 curSz;
|
||||||
uint32_t seq;
|
word32 seq;
|
||||||
uint32_t peerSeq;
|
word32 peerSeq;
|
||||||
uint32_t packetStartIdx; /* Current send packet start index */
|
word32 packetStartIdx; /* Current send packet start index */
|
||||||
uint8_t paddingSz; /* Current send packet padding size */
|
byte paddingSz; /* Current send packet padding size */
|
||||||
uint8_t acceptState;
|
byte acceptState;
|
||||||
uint8_t clientState;
|
byte connectState;
|
||||||
uint8_t processReplyState;
|
byte clientState;
|
||||||
uint8_t keyingState;
|
byte serverState;
|
||||||
|
byte processReplyState;
|
||||||
|
byte isKeying;
|
||||||
|
|
||||||
uint8_t connReset;
|
byte connReset;
|
||||||
uint8_t isClosed;
|
byte isClosed;
|
||||||
|
|
||||||
uint8_t blockSz;
|
byte blockSz;
|
||||||
uint8_t encryptId;
|
byte encryptId;
|
||||||
uint8_t macId;
|
byte macId;
|
||||||
uint8_t macSz;
|
byte macSz;
|
||||||
uint8_t aeadMode;
|
byte aeadMode;
|
||||||
uint8_t peerBlockSz;
|
byte peerBlockSz;
|
||||||
uint8_t peerEncryptId;
|
byte peerEncryptId;
|
||||||
uint8_t peerMacId;
|
byte peerMacId;
|
||||||
uint8_t peerMacSz;
|
byte peerMacSz;
|
||||||
uint8_t peerAeadMode;
|
byte peerAeadMode;
|
||||||
|
|
||||||
Ciphers encryptCipher;
|
Ciphers encryptCipher;
|
||||||
Ciphers decryptCipher;
|
Ciphers decryptCipher;
|
||||||
|
|
||||||
uint32_t nextChannel;
|
word32 nextChannel;
|
||||||
WOLFSSH_CHANNEL* channelList;
|
WOLFSSH_CHANNEL* channelList;
|
||||||
uint32_t channelListSz;
|
word32 channelListSz;
|
||||||
uint32_t defaultPeerChannelId;
|
word32 defaultPeerChannelId;
|
||||||
|
|
||||||
Buffer inputBuffer;
|
Buffer inputBuffer;
|
||||||
Buffer outputBuffer;
|
Buffer outputBuffer;
|
||||||
WC_RNG* rng;
|
WC_RNG* rng;
|
||||||
|
|
||||||
uint8_t h[WC_MAX_DIGEST_SIZE];
|
byte h[WC_MAX_DIGEST_SIZE];
|
||||||
uint32_t hSz;
|
word32 hSz;
|
||||||
uint8_t k[257]; /* May have a leading zero, for unsigned. */
|
byte k[257]; /* May have a leading zero, for unsigned. */
|
||||||
uint32_t kSz;
|
word32 kSz;
|
||||||
uint8_t sessionId[WC_MAX_DIGEST_SIZE];
|
byte sessionId[WC_MAX_DIGEST_SIZE];
|
||||||
uint32_t sessionIdSz;
|
word32 sessionIdSz;
|
||||||
|
|
||||||
Keys clientKeys;
|
Keys keys;
|
||||||
Keys serverKeys;
|
Keys peerKeys;
|
||||||
HandshakeInfo* handshake;
|
HandshakeInfo* handshake;
|
||||||
|
|
||||||
void* userAuthCtx;
|
void* userAuthCtx;
|
||||||
uint8_t* userName;
|
char* userName;
|
||||||
uint32_t userNameSz;
|
word32 userNameSz;
|
||||||
uint8_t* pkBlob;
|
char* password;
|
||||||
uint32_t pkBlobSz;
|
word32 passwordSz;
|
||||||
uint8_t* clientId; /* Save for rekey */
|
byte* pkBlob;
|
||||||
uint32_t clientIdSz;
|
word32 pkBlobSz;
|
||||||
|
byte* peerProtoId; /* Save for rekey */
|
||||||
|
word32 peerProtoIdSz;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct WOLFSSH_CHANNEL {
|
struct WOLFSSH_CHANNEL {
|
||||||
uint8_t channelType;
|
byte channelType;
|
||||||
uint32_t channel;
|
word32 channel;
|
||||||
uint32_t windowSz;
|
word32 windowSz;
|
||||||
uint32_t maxPacketSz;
|
word32 maxPacketSz;
|
||||||
uint32_t peerChannel;
|
word32 peerChannel;
|
||||||
uint32_t peerWindowSz;
|
word32 peerWindowSz;
|
||||||
uint32_t peerMaxPacketSz;
|
word32 peerMaxPacketSz;
|
||||||
Buffer inputBuffer;
|
Buffer inputBuffer;
|
||||||
struct WOLFSSH* ssh;
|
struct WOLFSSH* ssh;
|
||||||
struct WOLFSSH_CHANNEL* next;
|
struct WOLFSSH_CHANNEL* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
WOLFSSH_LOCAL WOLFSSH_CTX* CtxInit(WOLFSSH_CTX*, void*);
|
WOLFSSH_LOCAL WOLFSSH_CTX* CtxInit(WOLFSSH_CTX*, byte, void*);
|
||||||
WOLFSSH_LOCAL void CtxResourceFree(WOLFSSH_CTX*);
|
WOLFSSH_LOCAL void CtxResourceFree(WOLFSSH_CTX*);
|
||||||
WOLFSSH_LOCAL WOLFSSH* SshInit(WOLFSSH*, WOLFSSH_CTX*);
|
WOLFSSH_LOCAL WOLFSSH* SshInit(WOLFSSH*, WOLFSSH_CTX*);
|
||||||
WOLFSSH_LOCAL void SshResourceFree(WOLFSSH*, void*);
|
WOLFSSH_LOCAL void SshResourceFree(WOLFSSH*, void*);
|
||||||
|
|
||||||
WOLFSSH_LOCAL WOLFSSH_CHANNEL* ChannelNew(WOLFSSH*, uint8_t, uint32_t,
|
WOLFSSH_LOCAL WOLFSSH_CHANNEL* ChannelNew(WOLFSSH*, byte, word32, word32);
|
||||||
uint32_t, uint32_t);
|
WOLFSSH_LOCAL int ChannelUpdate(WOLFSSH_CHANNEL*, word32, word32, word32);
|
||||||
WOLFSSH_LOCAL void ChannelDelete(WOLFSSH_CHANNEL*, void*);
|
WOLFSSH_LOCAL void ChannelDelete(WOLFSSH_CHANNEL*, void*);
|
||||||
WOLFSSH_LOCAL WOLFSSH_CHANNEL* ChannelFind(WOLFSSH*, uint32_t, uint8_t);
|
WOLFSSH_LOCAL WOLFSSH_CHANNEL* ChannelFind(WOLFSSH*, word32, byte);
|
||||||
WOLFSSH_LOCAL int ChannelRemove(WOLFSSH*, uint32_t, uint8_t);
|
WOLFSSH_LOCAL int ChannelRemove(WOLFSSH*, word32, byte);
|
||||||
WOLFSSH_LOCAL int ChannelPutData(WOLFSSH_CHANNEL*, uint8_t*, uint32_t);
|
WOLFSSH_LOCAL int ChannelPutData(WOLFSSH_CHANNEL*, byte*, word32);
|
||||||
WOLFSSH_LOCAL int ProcessBuffer(WOLFSSH_CTX*, const uint8_t*, uint32_t,
|
WOLFSSH_LOCAL int ProcessBuffer(WOLFSSH_CTX*, const byte*, word32, int, int);
|
||||||
int, int);
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef WOLFSSH_USER_IO
|
#ifndef WOLFSSH_USER_IO
|
||||||
|
|
||||||
/* default I/O handlers */
|
/* default I/O handlers */
|
||||||
WOLFSSH_LOCAL int wsEmbedRecv(WOLFSSH*, void*, uint32_t, void*);
|
WOLFSSH_LOCAL int wsEmbedRecv(WOLFSSH*, void*, word32, void*);
|
||||||
WOLFSSH_LOCAL int wsEmbedSend(WOLFSSH*, void*, uint32_t, void*);
|
WOLFSSH_LOCAL int wsEmbedSend(WOLFSSH*, void*, word32, void*);
|
||||||
|
|
||||||
#endif /* WOLFSSH_USER_IO */
|
#endif /* WOLFSSH_USER_IO */
|
||||||
|
|
||||||
|
|
||||||
WOLFSSH_LOCAL int DoReceive(WOLFSSH*);
|
WOLFSSH_LOCAL int DoReceive(WOLFSSH*);
|
||||||
WOLFSSH_LOCAL int ProcessClientVersion(WOLFSSH*);
|
WOLFSSH_LOCAL int DoProtoId(WOLFSSH*);
|
||||||
WOLFSSH_LOCAL int SendServerVersion(WOLFSSH*);
|
WOLFSSH_LOCAL int SendProtoId(WOLFSSH*);
|
||||||
WOLFSSH_LOCAL int SendKexInit(WOLFSSH*);
|
WOLFSSH_LOCAL int SendKexInit(WOLFSSH*);
|
||||||
|
WOLFSSH_LOCAL int SendKexDhInit(WOLFSSH*);
|
||||||
WOLFSSH_LOCAL int SendKexDhReply(WOLFSSH*);
|
WOLFSSH_LOCAL int SendKexDhReply(WOLFSSH*);
|
||||||
|
WOLFSSH_LOCAL int SendKexDhGexRequest(WOLFSSH*);
|
||||||
WOLFSSH_LOCAL int SendKexDhGexGroup(WOLFSSH*);
|
WOLFSSH_LOCAL int SendKexDhGexGroup(WOLFSSH*);
|
||||||
WOLFSSH_LOCAL int SendNewKeys(WOLFSSH*);
|
WOLFSSH_LOCAL int SendNewKeys(WOLFSSH*);
|
||||||
WOLFSSH_LOCAL int SendUnimplemented(WOLFSSH*);
|
WOLFSSH_LOCAL int SendUnimplemented(WOLFSSH*);
|
||||||
WOLFSSH_LOCAL int SendDisconnect(WOLFSSH*, uint32_t);
|
WOLFSSH_LOCAL int SendDisconnect(WOLFSSH*, word32);
|
||||||
WOLFSSH_LOCAL int SendIgnore(WOLFSSH*, const unsigned char*, uint32_t);
|
WOLFSSH_LOCAL int SendIgnore(WOLFSSH*, const unsigned char*, word32);
|
||||||
WOLFSSH_LOCAL int SendDebug(WOLFSSH*, byte, const char*);
|
WOLFSSH_LOCAL int SendDebug(WOLFSSH*, byte, const char*);
|
||||||
WOLFSSH_LOCAL int SendServiceAccept(WOLFSSH*);
|
WOLFSSH_LOCAL int SendServiceRequest(WOLFSSH*, byte);
|
||||||
|
WOLFSSH_LOCAL int SendServiceAccept(WOLFSSH*, byte);
|
||||||
|
WOLFSSH_LOCAL int SendUserAuthRequest(WOLFSSH*, byte);
|
||||||
WOLFSSH_LOCAL int SendUserAuthSuccess(WOLFSSH*);
|
WOLFSSH_LOCAL int SendUserAuthSuccess(WOLFSSH*);
|
||||||
WOLFSSH_LOCAL int SendUserAuthFailure(WOLFSSH*, uint8_t);
|
WOLFSSH_LOCAL int SendUserAuthFailure(WOLFSSH*, byte);
|
||||||
WOLFSSH_LOCAL int SendUserAuthBanner(WOLFSSH*);
|
WOLFSSH_LOCAL int SendUserAuthBanner(WOLFSSH*);
|
||||||
WOLFSSH_LOCAL int SendUserAuthPkOk(WOLFSSH*, const uint8_t*, uint32_t,
|
WOLFSSH_LOCAL int SendUserAuthPkOk(WOLFSSH*, const byte*, word32,
|
||||||
const uint8_t*, uint32_t);
|
const byte*, word32);
|
||||||
WOLFSSH_LOCAL int SendRequestSuccess(WOLFSSH*, int);
|
WOLFSSH_LOCAL int SendRequestSuccess(WOLFSSH*, int);
|
||||||
|
WOLFSSH_LOCAL int SendChannelOpenSession(WOLFSSH*, word32, word32);
|
||||||
WOLFSSH_LOCAL int SendChannelOpenConf(WOLFSSH*);
|
WOLFSSH_LOCAL int SendChannelOpenConf(WOLFSSH*);
|
||||||
WOLFSSH_LOCAL int SendChannelEof(WOLFSSH*, uint32_t);
|
WOLFSSH_LOCAL int SendChannelEof(WOLFSSH*, word32);
|
||||||
WOLFSSH_LOCAL int SendChannelClose(WOLFSSH*, uint32_t);
|
WOLFSSH_LOCAL int SendChannelClose(WOLFSSH*, word32);
|
||||||
WOLFSSH_LOCAL int SendChannelData(WOLFSSH*, uint32_t, uint8_t*, uint32_t);
|
WOLFSSH_LOCAL int SendChannelData(WOLFSSH*, word32, byte*, word32);
|
||||||
WOLFSSH_LOCAL int SendChannelWindowAdjust(WOLFSSH*, uint32_t, uint32_t);
|
WOLFSSH_LOCAL int SendChannelWindowAdjust(WOLFSSH*, word32, word32);
|
||||||
WOLFSSH_LOCAL int SendChannelSuccess(WOLFSSH*, uint32_t, int);
|
WOLFSSH_LOCAL int SendChannelRequestShell(WOLFSSH*);
|
||||||
WOLFSSH_LOCAL int GenerateKey(uint8_t, uint8_t, uint8_t*, uint32_t,
|
WOLFSSH_LOCAL int SendChannelSuccess(WOLFSSH*, word32, int);
|
||||||
const uint8_t*, uint32_t,
|
WOLFSSH_LOCAL int GenerateKey(byte, byte, byte*, word32, const byte*, word32,
|
||||||
const uint8_t*, uint32_t,
|
const byte*, word32, const byte*, word32);
|
||||||
const uint8_t*, uint32_t);
|
|
||||||
|
|
||||||
|
|
||||||
enum KeyingStates {
|
|
||||||
KEYING_UNKEYED = 0,
|
|
||||||
|
|
||||||
KEYING_KEXINIT_SENT,
|
|
||||||
KEYING_KEXINIT_RECV,
|
|
||||||
KEYING_KEXINIT_DONE,
|
|
||||||
|
|
||||||
KEYING_KEXDH_INIT_RECV,
|
|
||||||
KEYING_KEXDH_DONE,
|
|
||||||
|
|
||||||
KEYING_USING_KEYS_SENT,
|
|
||||||
KEYING_USING_KEYS_RECV,
|
|
||||||
KEYING_KEYED
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
enum AcceptStates {
|
enum AcceptStates {
|
||||||
ACCEPT_BEGIN = 0,
|
ACCEPT_BEGIN = 0,
|
||||||
ACCEPT_SERVER_VERSION_SENT,
|
ACCEPT_SERVER_VERSION_SENT,
|
||||||
ACCEPT_CLIENT_VERSION_DONE,
|
ACCEPT_CLIENT_VERSION_DONE,
|
||||||
|
ACCEPT_SERVER_KEXINIT_SENT,
|
||||||
ACCEPT_KEYED,
|
ACCEPT_KEYED,
|
||||||
ACCEPT_CLIENT_USERAUTH_REQUEST_DONE,
|
ACCEPT_CLIENT_USERAUTH_REQUEST_DONE,
|
||||||
ACCEPT_SERVER_USERAUTH_ACCEPT_SENT,
|
ACCEPT_SERVER_USERAUTH_ACCEPT_SENT,
|
||||||
|
@ -379,18 +391,47 @@ enum AcceptStates {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum ConnectStates {
|
||||||
|
CONNECT_BEGIN = 0,
|
||||||
|
CONNECT_CLIENT_VERSION_SENT,
|
||||||
|
CONNECT_SERVER_VERSION_DONE,
|
||||||
|
CONNECT_CLIENT_KEXINIT_SENT,
|
||||||
|
CONNECT_SERVER_KEXINIT_DONE,
|
||||||
|
CONNECT_CLIENT_KEXDH_INIT_SENT,
|
||||||
|
CONNECT_KEYED,
|
||||||
|
CONNECT_CLIENT_USERAUTH_REQUEST_SENT,
|
||||||
|
CONNECT_SERVER_USERAUTH_REQUEST_DONE,
|
||||||
|
CONNECT_CLIENT_USERAUTH_SENT,
|
||||||
|
CONNECT_SERVER_USERAUTH_ACCEPT_DONE,
|
||||||
|
CONNECT_CLIENT_CHANNEL_OPEN_SESSION_SENT,
|
||||||
|
CONNECT_SERVER_CHANNEL_OPEN_SESSION_DONE,
|
||||||
|
CONNECT_CLIENT_CHANNEL_REQUEST_SHELL_SENT,
|
||||||
|
CONNECT_SERVER_CHANNEL_REQUEST_SHELL_DONE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
enum ClientStates {
|
enum ClientStates {
|
||||||
CLIENT_BEGIN = 0,
|
CLIENT_BEGIN = 0,
|
||||||
CLIENT_VERSION_DONE,
|
CLIENT_VERSION_DONE,
|
||||||
CLIENT_KEXINIT_DONE,
|
CLIENT_KEXINIT_DONE,
|
||||||
CLIENT_KEXDH_INIT_DONE,
|
CLIENT_KEXDH_INIT_DONE,
|
||||||
CLIENT_USING_KEYS,
|
|
||||||
CLIENT_USERAUTH_REQUEST_DONE,
|
CLIENT_USERAUTH_REQUEST_DONE,
|
||||||
CLIENT_USERAUTH_DONE,
|
CLIENT_USERAUTH_DONE,
|
||||||
CLIENT_DONE
|
CLIENT_DONE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
enum ServerStates {
|
||||||
|
SERVER_BEGIN = 0,
|
||||||
|
SERVER_VERSION_DONE,
|
||||||
|
SERVER_KEXINIT_DONE,
|
||||||
|
SERVER_USERAUTH_REQUEST_DONE,
|
||||||
|
SERVER_USERAUTH_ACCEPT_DONE,
|
||||||
|
SERVER_CHANNEL_OPEN_DONE,
|
||||||
|
SERVER_DONE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
enum ProcessReplyStates {
|
enum ProcessReplyStates {
|
||||||
PROCESS_INIT,
|
PROCESS_INIT,
|
||||||
PROCESS_PACKET_LENGTH,
|
PROCESS_PACKET_LENGTH,
|
||||||
|
@ -400,44 +441,47 @@ enum ProcessReplyStates {
|
||||||
|
|
||||||
|
|
||||||
enum WS_MessageIds {
|
enum WS_MessageIds {
|
||||||
MSGID_DISCONNECT = 1,
|
MSGID_DISCONNECT = 1,
|
||||||
MSGID_IGNORE = 2,
|
MSGID_IGNORE = 2,
|
||||||
MSGID_UNIMPLEMENTED = 3,
|
MSGID_UNIMPLEMENTED = 3,
|
||||||
MSGID_DEBUG = 4,
|
MSGID_DEBUG = 4,
|
||||||
MSGID_SERVICE_REQUEST = 5,
|
MSGID_SERVICE_REQUEST = 5,
|
||||||
MSGID_SERVICE_ACCEPT = 6,
|
MSGID_SERVICE_ACCEPT = 6,
|
||||||
|
|
||||||
MSGID_KEXINIT = 20,
|
MSGID_KEXINIT = 20,
|
||||||
MSGID_NEWKEYS = 21,
|
MSGID_NEWKEYS = 21,
|
||||||
|
|
||||||
MSGID_KEXDH_INIT = 30,
|
MSGID_KEXDH_INIT = 30,
|
||||||
MSGID_KEXDH_REPLY = 31,
|
MSGID_KEXECDH_INIT = 30,
|
||||||
|
|
||||||
MSGID_KEXDH_GEX_REQUEST = 34,
|
MSGID_KEXDH_REPLY = 31,
|
||||||
|
MSGID_KEXECDH_REPLY = 31,
|
||||||
MSGID_KEXDH_GEX_GROUP = 31,
|
MSGID_KEXDH_GEX_GROUP = 31,
|
||||||
MSGID_KEXDH_GEX_INIT = 32,
|
MSGID_KEXDH_GEX_INIT = 32,
|
||||||
MSGID_KEXDH_GEX_REPLY = 33,
|
MSGID_KEXDH_GEX_REPLY = 33,
|
||||||
|
MSGID_KEXDH_GEX_REQUEST = 34,
|
||||||
|
|
||||||
MSGID_USERAUTH_REQUEST = 50,
|
MSGID_USERAUTH_REQUEST = 50,
|
||||||
MSGID_USERAUTH_FAILURE = 51,
|
MSGID_USERAUTH_FAILURE = 51,
|
||||||
MSGID_USERAUTH_SUCCESS = 52,
|
MSGID_USERAUTH_SUCCESS = 52,
|
||||||
MSGID_USERAUTH_BANNER = 53,
|
MSGID_USERAUTH_BANNER = 53,
|
||||||
MSGID_USERAUTH_PK_OK = 60, /* Public Key OK */
|
MSGID_USERAUTH_PK_OK = 60, /* Public Key OK */
|
||||||
MSGID_USERAUTH_PW_CHRQ = 60, /* Password Change Request */
|
MSGID_USERAUTH_PW_CHRQ = 60, /* Password Change Request */
|
||||||
|
|
||||||
MSGID_GLOBAL_REQUEST = 80,
|
MSGID_GLOBAL_REQUEST = 80,
|
||||||
MSGID_REQUEST_SUCCESS = 81,
|
MSGID_REQUEST_SUCCESS = 81,
|
||||||
MSGID_REQUEST_FAILURE = 82,
|
MSGID_REQUEST_FAILURE = 82,
|
||||||
|
|
||||||
MSGID_CHANNEL_OPEN = 90,
|
MSGID_CHANNEL_OPEN = 90,
|
||||||
MSGID_CHANNEL_OPEN_CONF = 91,
|
MSGID_CHANNEL_OPEN_CONF = 91,
|
||||||
|
MSGID_CHANNEL_OPEN_FAIL = 92,
|
||||||
MSGID_CHANNEL_WINDOW_ADJUST = 93,
|
MSGID_CHANNEL_WINDOW_ADJUST = 93,
|
||||||
MSGID_CHANNEL_DATA = 94,
|
MSGID_CHANNEL_DATA = 94,
|
||||||
MSGID_CHANNEL_EOF = 96,
|
MSGID_CHANNEL_EOF = 96,
|
||||||
MSGID_CHANNEL_CLOSE = 97,
|
MSGID_CHANNEL_CLOSE = 97,
|
||||||
MSGID_CHANNEL_REQUEST = 98,
|
MSGID_CHANNEL_REQUEST = 98,
|
||||||
MSGID_CHANNEL_SUCCESS = 99,
|
MSGID_CHANNEL_SUCCESS = 99,
|
||||||
MSGID_CHANNEL_FAILURE = 100
|
MSGID_CHANNEL_FAILURE = 100
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -455,7 +499,8 @@ enum WS_DynamicTypes {
|
||||||
DYNTYPE_PUBKEY,
|
DYNTYPE_PUBKEY,
|
||||||
DYNTYPE_DH,
|
DYNTYPE_DH,
|
||||||
DYNTYPE_RNG,
|
DYNTYPE_RNG,
|
||||||
DYNTYPE_STRING
|
DYNTYPE_STRING,
|
||||||
|
DYNTYPE_MPINT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -467,7 +512,7 @@ enum WS_BufferTypes {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
WOLFSSH_LOCAL void DumpOctetString(const uint8_t*, uint32_t);
|
WOLFSSH_LOCAL void DumpOctetString(const byte*, word32);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -42,7 +42,7 @@ extern "C" {
|
||||||
#define WOLFSSH_RSAKEY_DEFAULT_E 65537
|
#define WOLFSSH_RSAKEY_DEFAULT_E 65537
|
||||||
|
|
||||||
|
|
||||||
WOLFSSH_API int wolfSSH_MakeRsaKey(uint8_t*, uint32_t, uint32_t, uint32_t);
|
WOLFSSH_API int wolfSSH_MakeRsaKey(byte*, word32, word32, word32);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -36,13 +36,13 @@
|
||||||
|
|
||||||
|
|
||||||
#ifndef min
|
#ifndef min
|
||||||
WOLFSSH_LOCAL uint32_t min(uint32_t, uint32_t);
|
WOLFSSH_LOCAL word32 min(word32, word32);
|
||||||
#endif /* min */
|
#endif /* min */
|
||||||
|
|
||||||
WOLFSSH_LOCAL void ato32(const uint8_t*, uint32_t*);
|
WOLFSSH_LOCAL void ato32(const byte*, word32*);
|
||||||
WOLFSSH_LOCAL void c32toa(uint32_t, uint8_t*);
|
WOLFSSH_LOCAL void c32toa(word32, byte*);
|
||||||
WOLFSSH_LOCAL void ForceZero(const void*, uint32_t);
|
WOLFSSH_LOCAL void ForceZero(const void*, word32);
|
||||||
WOLFSSH_LOCAL int ConstantCompare(const uint8_t*, const uint8_t*, uint32_t);
|
WOLFSSH_LOCAL int ConstantCompare(const byte*, const byte*, word32);
|
||||||
|
|
||||||
|
|
||||||
#endif /* NO_INLINE */
|
#endif /* NO_INLINE */
|
||||||
|
|
|
@ -36,12 +36,6 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef WUSER_TYPE
|
|
||||||
#include <stdint.h>
|
|
||||||
/* we need uint8, uint32, stdint provides them */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* setup memory handling */
|
/* setup memory handling */
|
||||||
#ifndef WMALLOC_USER
|
#ifndef WMALLOC_USER
|
||||||
#include <wolfssh/memory.h>
|
#include <wolfssh/memory.h>
|
||||||
|
@ -56,7 +50,10 @@ extern "C" {
|
||||||
#ifndef WSTRING_USER
|
#ifndef WSTRING_USER
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
char* wstrnstr(const char* s1, const char* s2, unsigned int n);
|
#define WFILE FILE
|
||||||
|
|
||||||
|
WOLFSSH_API char* wstrnstr(const char*, const char*, unsigned int);
|
||||||
|
WOLFSSH_API int wfopen(WFILE**, const char*, const char*);
|
||||||
|
|
||||||
#define WMEMCPY(d,s,l) memcpy((d),(s),(l))
|
#define WMEMCPY(d,s,l) memcpy((d),(s),(l))
|
||||||
#define WMEMSET(b,c,l) memset((b),(c),(l))
|
#define WMEMSET(b,c,l) memset((b),(c),(l))
|
||||||
|
@ -64,25 +61,28 @@ extern "C" {
|
||||||
#define WMEMMOVE(d,s,l) memmove((d),(s),(l))
|
#define WMEMMOVE(d,s,l) memmove((d),(s),(l))
|
||||||
|
|
||||||
#define WSTRLEN(s1) strlen((s1))
|
#define WSTRLEN(s1) strlen((s1))
|
||||||
#define WSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
|
|
||||||
#define WSTRSTR(s1,s2) strstr((s1),(s2))
|
#define WSTRSTR(s1,s2) strstr((s1),(s2))
|
||||||
#define WSTRNSTR(s1,s2,n) wstrnstr((s1),(s2),(n))
|
#define WSTRNSTR(s1,s2,n) wstrnstr((s1),(s2),(n))
|
||||||
#define WSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n))
|
#define WSTRNCMP(s1,s2,n) strncmp((s1),(s2),(n))
|
||||||
#define WSTRNCAT(s1,s2,n) strncat((s1),(s2),(n))
|
#define WSTRNCAT(s1,s2,n) strncat((s1),(s2),(n))
|
||||||
#define WSTRSPN(s1,s2) strspn((s1),(s2))
|
#define WSTRSPN(s1,s2) strspn((s1),(s2))
|
||||||
#define WSTRCSPN(s1,s2) strcspn((s1),(s2))
|
#define WSTRCSPN(s1,s2) strcspn((s1),(s2))
|
||||||
|
#define WFOPEN(f,fn,m) wfopen((f),(fn),(m))
|
||||||
|
#define WFCLOSE(f) fclose(f)
|
||||||
|
|
||||||
#ifndef USE_WINDOWS_API
|
#ifndef USE_WINDOWS_API
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#define WSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
|
||||||
#define WSTRNCASECMP(s1,s2,n) strncasecmp((s1),(s2),(n))
|
#define WSTRNCASECMP(s1,s2,n) strncasecmp((s1),(s2),(n))
|
||||||
#define WSNPRINTF snprintf
|
#define WSNPRINTF(s,n,f,...) snprintf((s),(n),(f),##__VA_ARGS__)
|
||||||
#define WVSNPRINTF(a,b,c,d) vsnprintf(a,b,c,d)
|
#define WVSNPRINTF(s,n,f,...) vsnprintf((s),(n),(f),##__VA_ARGS__)
|
||||||
#define WLOCALTIME(a,b) (localtime_r(a,b)!=NULL)
|
#define WLOCALTIME(c,r) (localtime_r((c),(r))!=NULL)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
#define WSTRNCPY(s1,s2,n) strncpy_s((s1),(n),(s2),(n))
|
||||||
#define WSTRNCASECMP(s1,s2,n) _strnicmp((s1),(s2),(n))
|
#define WSTRNCASECMP(s1,s2,n) _strnicmp((s1),(s2),(n))
|
||||||
#define WSNPRINTF _snprintf
|
#define WSNPRINTF(s,n,f,...) _snprintf_s((s),(n),(n),(f),##__VA_ARGS__)
|
||||||
#define WVSNPRINTF(a,b,c,d) vsnprintf_s(a,b,(b-1),c,d)
|
#define WVSNPRINTF(s,n,f,...) vsnprintf_s((s),(n),(n),(f),##__VA_ARGS__)
|
||||||
#define WLOCALTIME(a,b) (localtime_s(b,a)==0)
|
#define WLOCALTIME(c,r) (localtime_s((r),(c))==0)
|
||||||
#endif
|
#endif
|
||||||
#endif /* WSTRING_USER */
|
#endif /* WSTRING_USER */
|
||||||
|
|
||||||
|
@ -107,6 +107,16 @@ extern "C" {
|
||||||
#endif /* INLINE */
|
#endif /* INLINE */
|
||||||
|
|
||||||
|
|
||||||
|
/* GCC 7 has new switch() fall-through detection */
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#if ((__GNUC__ > 7) || ((__GNUC__ == 7) && (__GNUC_MINOR__ >= 1)))
|
||||||
|
#define FALL_THROUGH __attribute__ ((fallthrough));
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifndef FALL_THROUGH
|
||||||
|
#define FALL_THROUGH
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,9 @@ extern "C" {
|
||||||
#define USE_WINDOWS_API
|
#define USE_WINDOWS_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define WOLFSSH_NO_CLIENT
|
||||||
|
/* The client code is incomplete. */
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <wolfssl/options.h>
|
||||||
|
#include <wolfssl/wolfcrypt/types.h>
|
||||||
#include <wolfssh/settings.h>
|
#include <wolfssh/settings.h>
|
||||||
#include <wolfssh/version.h>
|
#include <wolfssh/version.h>
|
||||||
#include <wolfssh/port.h>
|
#include <wolfssh/port.h>
|
||||||
|
@ -41,30 +43,30 @@ typedef struct WOLFSSH WOLFSSH;
|
||||||
typedef struct WOLFSSH_CHANNEL WOLFSSH_CHANNEL;
|
typedef struct WOLFSSH_CHANNEL WOLFSSH_CHANNEL;
|
||||||
|
|
||||||
|
|
||||||
WOLFSSH_API int wolfSSH_Init(void);
|
WOLFSSH_API int wolfSSH_Init(void);
|
||||||
WOLFSSH_API int wolfSSH_Cleanup(void);
|
WOLFSSH_API int wolfSSH_Cleanup(void);
|
||||||
|
|
||||||
/* debugging output functions */
|
/* debugging output functions */
|
||||||
WOLFSSH_API int wolfSSH_Debugging_ON(void);
|
WOLFSSH_API int wolfSSH_Debugging_ON(void);
|
||||||
WOLFSSH_API void wolfSSH_Debugging_OFF(void);
|
WOLFSSH_API void wolfSSH_Debugging_OFF(void);
|
||||||
|
|
||||||
/* context functions */
|
/* context functions */
|
||||||
WOLFSSH_API WOLFSSH_CTX* wolfSSH_CTX_new(uint8_t, void*);
|
WOLFSSH_API WOLFSSH_CTX* wolfSSH_CTX_new(byte, void*);
|
||||||
WOLFSSH_API void wolfSSH_CTX_free(WOLFSSH_CTX*);
|
WOLFSSH_API void wolfSSH_CTX_free(WOLFSSH_CTX*);
|
||||||
|
|
||||||
/* ssh session functions */
|
/* ssh session functions */
|
||||||
WOLFSSH_API WOLFSSH* wolfSSH_new(WOLFSSH_CTX*);
|
WOLFSSH_API WOLFSSH* wolfSSH_new(WOLFSSH_CTX*);
|
||||||
WOLFSSH_API void wolfSSH_free(WOLFSSH*);
|
WOLFSSH_API void wolfSSH_free(WOLFSSH*);
|
||||||
|
|
||||||
WOLFSSH_API int wolfSSH_set_fd(WOLFSSH*, int);
|
WOLFSSH_API int wolfSSH_set_fd(WOLFSSH*, int);
|
||||||
WOLFSSH_API int wolfSSH_get_fd(const WOLFSSH*);
|
WOLFSSH_API int wolfSSH_get_fd(const WOLFSSH*);
|
||||||
|
|
||||||
/* data high water mark functions */
|
/* data high water mark functions */
|
||||||
WOLFSSH_API int wolfSSH_SetHighwater(WOLFSSH*, uint32_t);
|
WOLFSSH_API int wolfSSH_SetHighwater(WOLFSSH*, word32);
|
||||||
WOLFSSH_API uint32_t wolfSSH_GetHighwater(WOLFSSH*);
|
WOLFSSH_API word32 wolfSSH_GetHighwater(WOLFSSH*);
|
||||||
|
|
||||||
typedef int (*WS_CallbackHighwater)(uint8_t, void*);
|
typedef int (*WS_CallbackHighwater)(byte, void*);
|
||||||
WOLFSSH_API void wolfSSH_SetHighwaterCb(WOLFSSH_CTX*, uint32_t,
|
WOLFSSH_API void wolfSSH_SetHighwaterCb(WOLFSSH_CTX*, word32,
|
||||||
WS_CallbackHighwater);
|
WS_CallbackHighwater);
|
||||||
WOLFSSH_API void wolfSSH_SetHighwaterCtx(WOLFSSH*, void*);
|
WOLFSSH_API void wolfSSH_SetHighwaterCtx(WOLFSSH*, void*);
|
||||||
WOLFSSH_API void* wolfSSH_GetHighwaterCtx(WOLFSSH*);
|
WOLFSSH_API void* wolfSSH_GetHighwaterCtx(WOLFSSH*);
|
||||||
|
@ -74,8 +76,8 @@ WOLFSSH_API int wolfSSH_get_error(const WOLFSSH*);
|
||||||
WOLFSSH_API const char* wolfSSH_get_error_name(const WOLFSSH*);
|
WOLFSSH_API const char* wolfSSH_get_error_name(const WOLFSSH*);
|
||||||
|
|
||||||
/* I/O callbacks */
|
/* I/O callbacks */
|
||||||
typedef int (*WS_CallbackIORecv)(WOLFSSH*, void*, uint32_t, void*);
|
typedef int (*WS_CallbackIORecv)(WOLFSSH*, void*, word32, void*);
|
||||||
typedef int (*WS_CallbackIOSend)(WOLFSSH*, void*, uint32_t, void*);
|
typedef int (*WS_CallbackIOSend)(WOLFSSH*, void*, word32, void*);
|
||||||
WOLFSSH_API void wolfSSH_SetIORecv(WOLFSSH_CTX*, WS_CallbackIORecv);
|
WOLFSSH_API void wolfSSH_SetIORecv(WOLFSSH_CTX*, WS_CallbackIORecv);
|
||||||
WOLFSSH_API void wolfSSH_SetIOSend(WOLFSSH_CTX*, WS_CallbackIOSend);
|
WOLFSSH_API void wolfSSH_SetIOSend(WOLFSSH_CTX*, WS_CallbackIOSend);
|
||||||
WOLFSSH_API void wolfSSH_SetIOReadCtx(WOLFSSH*, void*);
|
WOLFSSH_API void wolfSSH_SetIOReadCtx(WOLFSSH*, void*);
|
||||||
|
@ -84,63 +86,60 @@ WOLFSSH_API void* wolfSSH_GetIOReadCtx(WOLFSSH*);
|
||||||
WOLFSSH_API void* wolfSSH_GetIOWriteCtx(WOLFSSH*);
|
WOLFSSH_API void* wolfSSH_GetIOWriteCtx(WOLFSSH*);
|
||||||
|
|
||||||
/* User Authentication callback */
|
/* User Authentication callback */
|
||||||
|
|
||||||
typedef struct WS_UserAuthData_Password {
|
typedef struct WS_UserAuthData_Password {
|
||||||
uint8_t* password;
|
byte* password;
|
||||||
uint32_t passwordSz;
|
word32 passwordSz;
|
||||||
/* The following are present for future use. */
|
/* The following are present for future use. */
|
||||||
uint8_t hasNewPassword;
|
byte hasNewPassword;
|
||||||
uint8_t* newPassword;
|
byte* newPassword;
|
||||||
uint32_t newPasswordSz;
|
word32 newPasswordSz;
|
||||||
} WS_UserAuthData_Password;
|
} WS_UserAuthData_Password;
|
||||||
|
|
||||||
typedef struct WS_UserAuthData_PublicKey {
|
typedef struct WS_UserAuthData_PublicKey {
|
||||||
uint8_t* dataToSign;
|
byte* dataToSign;
|
||||||
uint8_t* publicKeyType;
|
byte* publicKeyType;
|
||||||
uint32_t publicKeyTypeSz;
|
word32 publicKeyTypeSz;
|
||||||
uint8_t* publicKey;
|
byte* publicKey;
|
||||||
uint32_t publicKeySz;
|
word32 publicKeySz;
|
||||||
uint8_t hasSignature;
|
byte hasSignature;
|
||||||
uint8_t* signature;
|
byte* signature;
|
||||||
uint32_t signatureSz;
|
word32 signatureSz;
|
||||||
} WS_UserAuthData_PublicKey;
|
} WS_UserAuthData_PublicKey;
|
||||||
|
|
||||||
typedef struct WS_UserAuthData {
|
typedef struct WS_UserAuthData {
|
||||||
uint8_t type;
|
byte type;
|
||||||
uint8_t* username;
|
byte* username;
|
||||||
uint32_t usernameSz;
|
word32 usernameSz;
|
||||||
uint8_t* serviceName;
|
byte* serviceName;
|
||||||
uint32_t serviceNameSz;
|
word32 serviceNameSz;
|
||||||
uint8_t* authName;
|
byte* authName;
|
||||||
uint32_t authNameSz;
|
word32 authNameSz;
|
||||||
union {
|
union {
|
||||||
WS_UserAuthData_Password password;
|
WS_UserAuthData_Password password;
|
||||||
WS_UserAuthData_PublicKey publicKey;
|
WS_UserAuthData_PublicKey publicKey;
|
||||||
} sf;
|
} sf;
|
||||||
} WS_UserAuthData;
|
} WS_UserAuthData;
|
||||||
|
|
||||||
typedef int (*WS_CallbackUserAuth)(uint8_t, const WS_UserAuthData*, void*);
|
typedef int (*WS_CallbackUserAuth)(byte, WS_UserAuthData*, void*);
|
||||||
WOLFSSH_API void wolfSSH_SetUserAuth(WOLFSSH_CTX*, WS_CallbackUserAuth);
|
WOLFSSH_API void wolfSSH_SetUserAuth(WOLFSSH_CTX*, WS_CallbackUserAuth);
|
||||||
WOLFSSH_API void wolfSSH_SetUserAuthCtx(WOLFSSH*, void*);
|
WOLFSSH_API void wolfSSH_SetUserAuthCtx(WOLFSSH*, void*);
|
||||||
WOLFSSH_API void* wolfSSH_GetUserAuthCtx(WOLFSSH*);
|
WOLFSSH_API void* wolfSSH_GetUserAuthCtx(WOLFSSH*);
|
||||||
|
|
||||||
WOLFSSH_API int wolfSSH_CTX_SetBanner(WOLFSSH_CTX*, const char*);
|
WOLFSSH_API int wolfSSH_CTX_SetBanner(WOLFSSH_CTX*, const char*);
|
||||||
WOLFSSH_API int wolfSSH_CTX_UsePrivateKey_buffer(WOLFSSH_CTX*,
|
WOLFSSH_API int wolfSSH_CTX_UsePrivateKey_buffer(WOLFSSH_CTX*,
|
||||||
const uint8_t*, uint32_t, int);
|
const byte*, word32, int);
|
||||||
|
|
||||||
WOLFSSH_API int wolfSSH_accept(WOLFSSH*);
|
WOLFSSH_API int wolfSSH_accept(WOLFSSH*);
|
||||||
WOLFSSH_API int wolfSSH_stream_read(WOLFSSH*, uint8_t*, uint32_t);
|
WOLFSSH_API int wolfSSH_shutdown(WOLFSSH*);
|
||||||
WOLFSSH_API int wolfSSH_stream_send(WOLFSSH*, uint8_t*, uint32_t);
|
WOLFSSH_API int wolfSSH_stream_read(WOLFSSH*, byte*, word32);
|
||||||
WOLFSSH_API int wolfSSH_channel_read(WOLFSSH_CHANNEL*, uint8_t*, uint32_t);
|
WOLFSSH_API int wolfSSH_stream_send(WOLFSSH*, byte*, word32);
|
||||||
WOLFSSH_API int wolfSSH_channel_send(WOLFSSH_CHANNEL*, uint8_t*, uint32_t);
|
|
||||||
WOLFSSH_API int wolfSSH_TriggerKeyExchange(WOLFSSH*);
|
WOLFSSH_API int wolfSSH_TriggerKeyExchange(WOLFSSH*);
|
||||||
|
|
||||||
WOLFSSH_API void wolfSSH_GetStats(WOLFSSH*,
|
WOLFSSH_API void wolfSSH_GetStats(WOLFSSH*,
|
||||||
uint32_t*, uint32_t*, uint32_t*, uint32_t*);
|
word32*, word32*, word32*, word32*);
|
||||||
|
|
||||||
WOLFSSH_API int wolfSSH_KDF(uint8_t, uint8_t, uint8_t*, uint32_t,
|
WOLFSSH_API int wolfSSH_KDF(byte, byte, byte*, word32, const byte*, word32,
|
||||||
const uint8_t*, uint32_t, const uint8_t*, uint32_t,
|
const byte*, word32, const byte*, word32);
|
||||||
const uint8_t*, uint32_t);
|
|
||||||
|
|
||||||
|
|
||||||
enum WS_HighwaterSide {
|
enum WS_HighwaterSide {
|
||||||
|
|
|
@ -0,0 +1,544 @@
|
||||||
|
/* test.h */
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef _WOLFSSH_TEST_H_
|
||||||
|
#define _WOLFSSH_TEST_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
/*#include <stdlib.h>*/
|
||||||
|
#include <ctype.h>
|
||||||
|
/*#include <wolfssh/error.h>*/
|
||||||
|
|
||||||
|
#ifdef USE_WINDOWS_API
|
||||||
|
#include <winsock2.h>
|
||||||
|
#include <process.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#ifdef TEST_IPV6 /* don't require newer SDK for IPV4 */
|
||||||
|
#include <ws2tcpip.h>
|
||||||
|
#include <wspiapi.h>
|
||||||
|
#endif
|
||||||
|
#define SOCKET_T SOCKET
|
||||||
|
#else /* USE_WINDOWS_API */
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netinet/tcp.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#ifndef SO_NOSIGPIPE
|
||||||
|
#include <signal.h> /* ignore SIGPIPE */
|
||||||
|
#endif
|
||||||
|
#define SOCKET_T int
|
||||||
|
#endif /* USE_WINDOWS_API */
|
||||||
|
|
||||||
|
|
||||||
|
/* Socket Handling */
|
||||||
|
#ifndef WOLFSSH_SOCKET_INVALID
|
||||||
|
#ifdef USE_WINDOWS_API
|
||||||
|
#define WOLFSSH_SOCKET_INVALID ((SOCKET_T)INVALID_SOCKET)
|
||||||
|
#elif defined(WOLFSSH_TIRTOS)
|
||||||
|
#define WOLFSSH_SOCKET_INVALID ((SOCKET_T)-1)
|
||||||
|
#else
|
||||||
|
#define WOLFSSH_SOCKET_INVALID (SOCKET_T)(0)
|
||||||
|
#endif
|
||||||
|
#endif /* WOLFSSH_SOCKET_INVALID */
|
||||||
|
|
||||||
|
#ifndef WOLFSSL_SOCKET_IS_INVALID
|
||||||
|
#if defined(USE_WINDOWS_API) || defined(WOLFSSL_TIRTOS)
|
||||||
|
#define WOLFSSL_SOCKET_IS_INVALID(s) ((SOCKET_T)(s) == WOLFSSL_SOCKET_INVALID)
|
||||||
|
#else
|
||||||
|
#define WOLFSSL_SOCKET_IS_INVALID(s) ((SOCKET_T)(s) < WOLFSSL_SOCKET_INVALID)
|
||||||
|
#endif
|
||||||
|
#endif /* WOLFSSL_SOCKET_IS_INVALID */
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__MACH__) || defined(USE_WINDOWS_API)
|
||||||
|
#ifndef _SOCKLEN_T
|
||||||
|
typedef int socklen_t;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_WINDOWS_API
|
||||||
|
#define WCLOSESOCKET(s) closesocket(s)
|
||||||
|
#define WSTARTTCP() do { WSADATA wsd; WSAStartup(0x0002, &wsd); } while(0)
|
||||||
|
#else
|
||||||
|
#define WCLOSESOCKET(s) close(s)
|
||||||
|
#define WSTARTTCP()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef SINGLE_THREADED
|
||||||
|
typedef unsigned int THREAD_RETURN;
|
||||||
|
typedef void* THREAD_TYPE;
|
||||||
|
#define WOLFSSH_THREAD
|
||||||
|
#else
|
||||||
|
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
||||||
|
typedef void* THREAD_RETURN;
|
||||||
|
typedef pthread_t THREAD_TYPE;
|
||||||
|
#define WOLFSSH_THREAD
|
||||||
|
#define INFINITE -1
|
||||||
|
#define WAIT_OBJECT_0 0L
|
||||||
|
#else
|
||||||
|
typedef unsigned int THREAD_RETURN;
|
||||||
|
typedef intptr_t THREAD_TYPE;
|
||||||
|
#define WOLFSSH_THREAD __stdcall
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TEST_IPV6
|
||||||
|
typedef struct sockaddr_in6 SOCKADDR_IN_T;
|
||||||
|
#define AF_INET_V AF_INET6
|
||||||
|
#else
|
||||||
|
typedef struct sockaddr_in SOCKADDR_IN_T;
|
||||||
|
#define AF_INET_V AF_INET
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define serverKeyRsaPemFile "./keys/server-key-rsa.pem"
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct tcp_ready {
|
||||||
|
word16 ready; /* predicate */
|
||||||
|
word16 port;
|
||||||
|
char* srfName; /* server ready file name */
|
||||||
|
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
||||||
|
pthread_mutex_t mutex;
|
||||||
|
pthread_cond_t cond;
|
||||||
|
#endif
|
||||||
|
} tcp_ready;
|
||||||
|
|
||||||
|
|
||||||
|
static INLINE void InitTcpReady(tcp_ready* ready)
|
||||||
|
{
|
||||||
|
ready->ready = 0;
|
||||||
|
ready->port = 0;
|
||||||
|
ready->srfName = NULL;
|
||||||
|
#ifdef SINGLE_THREADED
|
||||||
|
#elif defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
||||||
|
pthread_mutex_init(&ready->mutex, 0);
|
||||||
|
pthread_cond_init(&ready->cond, 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static INLINE void FreeTcpReady(tcp_ready* ready)
|
||||||
|
{
|
||||||
|
#ifdef SINGLE_THREADED
|
||||||
|
(void)ready;
|
||||||
|
#elif defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
||||||
|
pthread_mutex_destroy(&ready->mutex);
|
||||||
|
pthread_cond_destroy(&ready->cond);
|
||||||
|
#else
|
||||||
|
(void)ready;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
typedef void (*ctx_callback)(WOLFSSH_CTX*);
|
||||||
|
typedef void (*ssh_callback)(WOLFSSH*);
|
||||||
|
|
||||||
|
typedef struct callback_functions {
|
||||||
|
ctx_callback ctx_ready;
|
||||||
|
ssh_callback ssh_ready;
|
||||||
|
ssh_callback on_result;
|
||||||
|
} callback_functions;
|
||||||
|
|
||||||
|
typedef struct func_args {
|
||||||
|
int argc;
|
||||||
|
char** argv;
|
||||||
|
int return_code;
|
||||||
|
tcp_ready* signal;
|
||||||
|
callback_functions *callbacks;
|
||||||
|
} func_args;
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef SINGLE_THREADED
|
||||||
|
|
||||||
|
typedef THREAD_RETURN WOLFSSH_THREAD THREAD_FUNC(void*);
|
||||||
|
|
||||||
|
static void start_thread(THREAD_FUNC fun, void* args, THREAD_TYPE* thread)
|
||||||
|
{
|
||||||
|
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
||||||
|
pthread_create(thread, 0, fun, args);
|
||||||
|
return;
|
||||||
|
#elif defined(WOLFSSL_TIRTOS)
|
||||||
|
/* Initialize the defaults and set the parameters. */
|
||||||
|
Task_Params taskParams;
|
||||||
|
Task_Params_init(&taskParams);
|
||||||
|
taskParams.arg0 = (UArg)args;
|
||||||
|
taskParams.stackSize = 65535;
|
||||||
|
*thread = Task_create((Task_FuncPtr)fun, &taskParams, NULL);
|
||||||
|
if (*thread == NULL) {
|
||||||
|
printf("Failed to create new Task\n");
|
||||||
|
}
|
||||||
|
Task_yield();
|
||||||
|
#else
|
||||||
|
*thread = (THREAD_TYPE)_beginthreadex(0, 0, fun, args, 0, 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void join_thread(THREAD_TYPE thread)
|
||||||
|
{
|
||||||
|
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
||||||
|
pthread_join(thread, 0);
|
||||||
|
#elif defined(WOLFSSL_TIRTOS)
|
||||||
|
while(1) {
|
||||||
|
if (Task_getMode(thread) == Task_Mode_TERMINATED) {
|
||||||
|
Task_sleep(5);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Task_yield();
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
int res = WaitForSingleObject((HANDLE)thread, INFINITE);
|
||||||
|
assert(res == WAIT_OBJECT_0);
|
||||||
|
res = CloseHandle((HANDLE)thread);
|
||||||
|
assert(res);
|
||||||
|
(void)res; /* Suppress un-used variable warning */
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void detach_thread(THREAD_TYPE thread)
|
||||||
|
{
|
||||||
|
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
||||||
|
pthread_detach(thread);
|
||||||
|
#elif defined(WOLFSSL_TIRTOS)
|
||||||
|
#if 0
|
||||||
|
while(1) {
|
||||||
|
if (Task_getMode(thread) == Task_Mode_TERMINATED) {
|
||||||
|
Task_sleep(5);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Task_yield();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
int res = CloseHandle((HANDLE)thread);
|
||||||
|
assert(res);
|
||||||
|
(void)res; /* Suppress un-used variable warning */
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* SINGLE_THREADED */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef TEST_IPV6
|
||||||
|
static const char* const wolfSshIp = "127.0.0.1";
|
||||||
|
#else /* TEST_IPV6 */
|
||||||
|
static const char* const wolfSshIp = "::1";
|
||||||
|
#endif /* TEST_IPV6 */
|
||||||
|
static const word16 wolfSshPort = 22222;
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#define WS_NORETURN __attribute__((noreturn))
|
||||||
|
#else
|
||||||
|
#define WS_NORETURN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static INLINE WS_NORETURN void err_sys(const char* msg)
|
||||||
|
{
|
||||||
|
printf("wolfSSH error: %s\n", msg);
|
||||||
|
|
||||||
|
#ifndef __GNUC__
|
||||||
|
/* scan-build (which pretends to be gnuc) can get confused and think the
|
||||||
|
* msg pointer can be null even when hardcoded and then it won't exit,
|
||||||
|
* making null pointer checks above the err_sys() call useless.
|
||||||
|
* We could just always exit() but some compilers will complain about no
|
||||||
|
* possible return, with gcc we know the attribute to handle that with
|
||||||
|
* WS_NORETURN. */
|
||||||
|
if (msg)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define MY_EX_USAGE 2
|
||||||
|
|
||||||
|
extern int myoptind;
|
||||||
|
extern char* myoptarg;
|
||||||
|
|
||||||
|
static INLINE int mygetopt(int argc, char** argv, const char* optstring)
|
||||||
|
{
|
||||||
|
static char* next = NULL;
|
||||||
|
|
||||||
|
char c;
|
||||||
|
char* cp;
|
||||||
|
|
||||||
|
if (myoptind == 0)
|
||||||
|
next = NULL; /* we're starting new/over */
|
||||||
|
|
||||||
|
if (next == NULL || *next == '\0') {
|
||||||
|
if (myoptind == 0)
|
||||||
|
myoptind++;
|
||||||
|
|
||||||
|
if (myoptind >= argc || argv[myoptind][0] != '-' ||
|
||||||
|
argv[myoptind][1] == '\0') {
|
||||||
|
myoptarg = NULL;
|
||||||
|
if (myoptind < argc)
|
||||||
|
myoptarg = argv[myoptind];
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(argv[myoptind], "--") == 0) {
|
||||||
|
myoptind++;
|
||||||
|
myoptarg = NULL;
|
||||||
|
|
||||||
|
if (myoptind < argc)
|
||||||
|
myoptarg = argv[myoptind];
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
next = argv[myoptind];
|
||||||
|
next++; /* skip - */
|
||||||
|
myoptind++;
|
||||||
|
}
|
||||||
|
|
||||||
|
c = *next++;
|
||||||
|
/* The C++ strchr can return a different value */
|
||||||
|
cp = (char*)strchr(optstring, c);
|
||||||
|
|
||||||
|
if (cp == NULL || c == ':')
|
||||||
|
return '?';
|
||||||
|
|
||||||
|
cp++;
|
||||||
|
|
||||||
|
if (*cp == ':') {
|
||||||
|
if (*next != '\0') {
|
||||||
|
myoptarg = next;
|
||||||
|
next = NULL;
|
||||||
|
}
|
||||||
|
else if (myoptind < argc) {
|
||||||
|
myoptarg = argv[myoptind];
|
||||||
|
myoptind++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return '?';
|
||||||
|
}
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_WINDOWS_API
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable:4996)
|
||||||
|
/* For Windows builds, disable compiler warnings for:
|
||||||
|
* - 4996: deprecated function */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static INLINE void build_addr(SOCKADDR_IN_T* addr, const char* peer,
|
||||||
|
word16 port)
|
||||||
|
{
|
||||||
|
int useLookup = 0;
|
||||||
|
(void)useLookup;
|
||||||
|
|
||||||
|
memset(addr, 0, sizeof(SOCKADDR_IN_T));
|
||||||
|
|
||||||
|
#ifndef TEST_IPV6
|
||||||
|
/* peer could be in human readable form */
|
||||||
|
if ( ((size_t)peer != INADDR_ANY) && isalpha((int)peer[0])) {
|
||||||
|
#ifdef CYASSL_MDK_ARM
|
||||||
|
int err;
|
||||||
|
struct hostent* entry = gethostbyname(peer, &err);
|
||||||
|
#else
|
||||||
|
struct hostent* entry = gethostbyname(peer);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (entry) {
|
||||||
|
memcpy(&addr->sin_addr.s_addr, entry->h_addr_list[0],
|
||||||
|
entry->h_length);
|
||||||
|
useLookup = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
err_sys("no entry for host");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TEST_IPV6
|
||||||
|
#if defined(CYASSL_MDK_ARM)
|
||||||
|
addr->sin_family = PF_INET;
|
||||||
|
#else
|
||||||
|
addr->sin_family = AF_INET_V;
|
||||||
|
#endif
|
||||||
|
addr->sin_port = htons(port);
|
||||||
|
if ((size_t)peer == INADDR_ANY)
|
||||||
|
addr->sin_addr.s_addr = INADDR_ANY;
|
||||||
|
else {
|
||||||
|
if (!useLookup)
|
||||||
|
addr->sin_addr.s_addr = inet_addr(peer);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
addr->sin6_family = AF_INET_V;
|
||||||
|
addr->sin6_port = htons(port);
|
||||||
|
if ((size_t)peer == INADDR_ANY)
|
||||||
|
addr->sin6_addr = in6addr_any;
|
||||||
|
else {
|
||||||
|
#ifdef HAVE_GETADDRINFO
|
||||||
|
struct addrinfo hints;
|
||||||
|
struct addrinfo* answer = NULL;
|
||||||
|
int ret;
|
||||||
|
char strPort[80];
|
||||||
|
|
||||||
|
memset(&hints, 0, sizeof(hints));
|
||||||
|
|
||||||
|
hints.ai_family = AF_INET_V;
|
||||||
|
hints.ai_socktype = udp ? SOCK_DGRAM : SOCK_STREAM;
|
||||||
|
hints.ai_protocol = udp ? IPPROTO_UDP : IPPROTO_TCP;
|
||||||
|
|
||||||
|
WSNPRINTF(strPort, sizeof(strPort), "%d", port);
|
||||||
|
strPort[79] = '\0';
|
||||||
|
|
||||||
|
ret = getaddrinfo(peer, strPort, &hints, &answer);
|
||||||
|
if (ret < 0 || answer == NULL)
|
||||||
|
err_sys("getaddrinfo failed");
|
||||||
|
|
||||||
|
memcpy(addr, answer->ai_addr, answer->ai_addrlen);
|
||||||
|
freeaddrinfo(answer);
|
||||||
|
#else
|
||||||
|
printf("no ipv6 getaddrinfo, loopback only tests/examples\n");
|
||||||
|
addr->sin6_addr = in6addr_loopback;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef USE_WINDOWS_API
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static INLINE void tcp_socket(SOCKET_T* sockFd)
|
||||||
|
{
|
||||||
|
*sockFd = socket(AF_INET_V, SOCK_STREAM, 0);
|
||||||
|
|
||||||
|
#ifdef USE_WINDOWS_API
|
||||||
|
if (*sockFd == INVALID_SOCKET)
|
||||||
|
err_sys("socket failed\n");
|
||||||
|
#else
|
||||||
|
if (*sockFd < 0)
|
||||||
|
err_sys("socket failed\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef USE_WINDOWS_API
|
||||||
|
#ifdef SO_NOSIGPIPE
|
||||||
|
{
|
||||||
|
int on = 1;
|
||||||
|
socklen_t len = sizeof(on);
|
||||||
|
int res = setsockopt(*sockFd, SOL_SOCKET, SO_NOSIGPIPE, &on, len);
|
||||||
|
if (res < 0)
|
||||||
|
err_sys("setsockopt SO_NOSIGPIPE failed\n");
|
||||||
|
}
|
||||||
|
#elif defined(CYASSL_MDK_ARM)
|
||||||
|
/* nothing to define */
|
||||||
|
#else /* no S_NOSIGPIPE */
|
||||||
|
signal(SIGPIPE, SIG_IGN);
|
||||||
|
#endif /* S_NOSIGPIPE */
|
||||||
|
|
||||||
|
#if defined(TCP_NODELAY)
|
||||||
|
{
|
||||||
|
int on = 1;
|
||||||
|
socklen_t len = sizeof(on);
|
||||||
|
int res = setsockopt(*sockFd, IPPROTO_TCP, TCP_NODELAY, &on, len);
|
||||||
|
if (res < 0)
|
||||||
|
err_sys("setsockopt TCP_NODELAY failed\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif /* USE_WINDOWS_API */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef XNTOHS
|
||||||
|
#define XNTOHS(a) ntohs((a))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static INLINE void tcp_listen(SOCKET_T* sockfd, word16* port, int useAnyAddr)
|
||||||
|
{
|
||||||
|
SOCKADDR_IN_T addr;
|
||||||
|
|
||||||
|
/* don't use INADDR_ANY by default, firewall may block, make user switch
|
||||||
|
on */
|
||||||
|
build_addr(&addr, (useAnyAddr ? INADDR_ANY : wolfSshIp), *port);
|
||||||
|
tcp_socket(sockfd);
|
||||||
|
|
||||||
|
#if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_MDK_ARM)\
|
||||||
|
&& !defined(WOLFSSL_KEIL_TCP_NET)
|
||||||
|
{
|
||||||
|
int res, on = 1;
|
||||||
|
socklen_t len = sizeof(on);
|
||||||
|
res = setsockopt(*sockfd, SOL_SOCKET, SO_REUSEADDR, &on, len);
|
||||||
|
if (res < 0)
|
||||||
|
err_sys("setsockopt SO_REUSEADDR failed\n");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (bind(*sockfd, (const struct sockaddr*)&addr, sizeof(addr)) != 0)
|
||||||
|
err_sys("tcp bind failed");
|
||||||
|
if (listen(*sockfd, 5) != 0)
|
||||||
|
err_sys("tcp listen failed");
|
||||||
|
#if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_TIRTOS)
|
||||||
|
if (*port == 0) {
|
||||||
|
socklen_t len = sizeof(addr);
|
||||||
|
if (getsockname(*sockfd, (struct sockaddr*)&addr, &len) == 0) {
|
||||||
|
#ifndef TEST_IPV6
|
||||||
|
*port = XNTOHS(addr.sin_port);
|
||||||
|
#else
|
||||||
|
*port = XNTOHS(addr.sin6_port);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Wolf Root Directory Helper */
|
||||||
|
/* KEIL-RL File System does not support relative directory */
|
||||||
|
#if !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_KEIL_FS) && !defined(WOLFSSL_TIRTOS)
|
||||||
|
/* Maximum depth to search for WolfSSL root */
|
||||||
|
#define MAX_WOLF_ROOT_DEPTH 5
|
||||||
|
|
||||||
|
static INLINE int ChangeToWolfSshRoot(void)
|
||||||
|
{
|
||||||
|
#if !defined(NO_FILESYSTEM)
|
||||||
|
int depth, res;
|
||||||
|
WFILE* file;
|
||||||
|
for(depth = 0; depth <= MAX_WOLF_ROOT_DEPTH; depth++) {
|
||||||
|
if (WFOPEN(&file, serverKeyRsaPemFile, "rb") == 0) {
|
||||||
|
WFCLOSE(file);
|
||||||
|
return depth;
|
||||||
|
}
|
||||||
|
#ifdef USE_WINDOWS_API
|
||||||
|
res = SetCurrentDirectoryA("..\\");
|
||||||
|
#else
|
||||||
|
res = chdir("../");
|
||||||
|
#endif
|
||||||
|
if (res < 0) {
|
||||||
|
printf("chdir to ../ failed!\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err_sys("wolfSSH root not found");
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif /* !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_KEIL_FS) && !defined(WOL
|
||||||
|
FSSL_TIRTOS) */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _WOLFSSH_TEST_H_ */
|
Loading…
Reference in New Issue