mirror of https://github.com/wolfSSL/wolfssh.git
commit
83db50f7b6
|
|
@ -19,9 +19,6 @@
|
|||
*/
|
||||
|
||||
|
||||
#define SINGLE_THREADED
|
||||
/* The client doesn't use threading. */
|
||||
|
||||
#include <wolfssh/ssh.h>
|
||||
#include <wolfssh/test.h>
|
||||
#include "examples/client/client.h"
|
||||
|
|
@ -33,26 +30,18 @@
|
|||
const char testString[] = "Hello, wolfSSH!";
|
||||
|
||||
|
||||
#ifndef USE_WINDOWS_API
|
||||
static struct termios originalTerm;
|
||||
#else
|
||||
static DWORD originalTerm;
|
||||
#endif
|
||||
|
||||
static int InitEcho(void)
|
||||
{
|
||||
#ifndef USE_WINDOWS_API
|
||||
return tcgetattr(STDIN_FILENO, &originalTerm);
|
||||
#else
|
||||
HANDLE stdinHandle = GetStdHandle(STD_INPUT_HANDLE);
|
||||
return (GetConsoleMode(stdinHandle, &originalTerm) == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static int SetEcho(int on)
|
||||
{
|
||||
#ifndef USE_WINDOWS_API
|
||||
static int echoInit = 0;
|
||||
static struct termios originalTerm;
|
||||
if (!echoInit) {
|
||||
if (tcgetattr(STDIN_FILENO, &originalTerm) != 0) {
|
||||
printf("Couldn't get the original terminal settings.\n");
|
||||
return -1;
|
||||
}
|
||||
echoInit = 1;
|
||||
}
|
||||
if (on) {
|
||||
if (tcsetattr(STDIN_FILENO, TCSANOW, &originalTerm) != 0) {
|
||||
printf("Couldn't restore the terminal settings.\n");
|
||||
|
|
@ -72,7 +61,16 @@ static int SetEcho(int on)
|
|||
}
|
||||
}
|
||||
#else
|
||||
static int echoInit = 0;
|
||||
static DWORD originalTerm;
|
||||
HANDLE stdinHandle = GetStdHandle(STD_INPUT_HANDLE);
|
||||
if (!echoInit) {
|
||||
if (GetConsoleMode(stdinHandle, &originalTerm) == 0) {
|
||||
printf("Couldn't get the original terminal settings.\n");
|
||||
return -1;
|
||||
}
|
||||
echoInit = 1;
|
||||
}
|
||||
if (on) {
|
||||
if (SetConsoleMode(stdinHandle, originalTerm) == 0) {
|
||||
printf("Couldn't restore the terminal settings.\n");
|
||||
|
|
@ -208,7 +206,10 @@ THREAD_RETURN WOLFSSH_THREAD client_test(void* args)
|
|||
if (ctx == NULL)
|
||||
err_sys("Couldn't create wolfSSH client context.");
|
||||
|
||||
wolfSSH_SetUserAuth(ctx, wsUserAuth);
|
||||
if (((func_args*)args)->user_auth == NULL)
|
||||
wolfSSH_SetUserAuth(ctx, wsUserAuth);
|
||||
else
|
||||
wolfSSH_SetUserAuth(ctx, ((func_args*)args)->user_auth);
|
||||
|
||||
ssh = wolfSSH_new(ctx);
|
||||
if (ssh == NULL)
|
||||
|
|
@ -267,12 +268,10 @@ THREAD_RETURN WOLFSSH_THREAD client_test(void* args)
|
|||
args.argc = argc;
|
||||
args.argv = argv;
|
||||
args.return_code = 0;
|
||||
args.user_auth = NULL;
|
||||
|
||||
WSTARTTCP();
|
||||
|
||||
if (InitEcho() != 0)
|
||||
err_sys("Couldn't initialize terminal.");
|
||||
|
||||
#ifdef DEBUG_WOLFSSH
|
||||
wolfSSH_Debugging_ON();
|
||||
#endif
|
||||
|
|
@ -280,9 +279,7 @@ THREAD_RETURN WOLFSSH_THREAD client_test(void* args)
|
|||
wolfSSH_Init();
|
||||
|
||||
ChangeToWolfSshRoot();
|
||||
#ifndef NO_WOLFSSH_CLIENT
|
||||
client_test(&args);
|
||||
#endif /* NO_WOLFSSH_CLIENT */
|
||||
client_test(&args);
|
||||
|
||||
wolfSSH_Cleanup();
|
||||
|
||||
|
|
|
|||
|
|
@ -461,42 +461,68 @@ static int wsUserAuth(byte authType,
|
|||
static void ShowUsage(void)
|
||||
{
|
||||
printf("echoserver %s\n", LIBWOLFSSH_VERSION_STRING);
|
||||
printf("-h Help, print this usage\n");
|
||||
printf("-m Allow multiple connections\n");
|
||||
printf("-e Use ECC private key\n");
|
||||
printf(" -? display this help and exit\n");
|
||||
printf(" -1 exit after single (one) connection\n");
|
||||
printf(" -e use ECC private key\n");
|
||||
printf(" -p <num> port to connect on, default %d\n", wolfSshPort);
|
||||
}
|
||||
|
||||
|
||||
static void SignalTcpReady(func_args* serverArgs, word16 port)
|
||||
{
|
||||
#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER) && !defined(__MINGW32__)
|
||||
tcp_ready* ready = serverArgs->signal;
|
||||
pthread_mutex_lock(&ready->mutex);
|
||||
ready->ready = 1;
|
||||
ready->port = port;
|
||||
pthread_cond_signal(&ready->cond);
|
||||
pthread_mutex_unlock(&ready->mutex);
|
||||
#else
|
||||
(void)serverArgs;
|
||||
(void)port;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
|
||||
{
|
||||
func_args* serverArgs = (func_args*)args;
|
||||
WOLFSSH_CTX* ctx = NULL;
|
||||
PwMapList pwMapList;
|
||||
SOCKET_T listenFd = 0;
|
||||
word32 defaultHighwater = EXAMPLE_HIGHWATER_MARK;
|
||||
word32 threadCount = 0;
|
||||
int multipleConnections = 0;
|
||||
int multipleConnections = 1;
|
||||
int useEcc = 0;
|
||||
char ch;
|
||||
word16 port = wolfSshPort;
|
||||
|
||||
int argc = ((func_args*)args)->argc;
|
||||
char** argv = ((func_args*)args)->argv;
|
||||
((func_args*)args)->return_code = 0;
|
||||
int argc = serverArgs->argc;
|
||||
char** argv = serverArgs->argv;
|
||||
serverArgs->return_code = 0;
|
||||
|
||||
while ((ch = mygetopt(argc, argv, "hme")) != -1) {
|
||||
while ((ch = mygetopt(argc, argv, "?1ep:")) != -1) {
|
||||
switch (ch) {
|
||||
case 'h' :
|
||||
case '?' :
|
||||
ShowUsage();
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
case 'm' :
|
||||
multipleConnections = 1;
|
||||
case '1':
|
||||
multipleConnections = 0;
|
||||
break;
|
||||
|
||||
case 'e' :
|
||||
useEcc = 1;
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
port = (word16)atoi(myoptarg);
|
||||
#if !defined(NO_MAIN_DRIVER) || defined(USE_WINDOWS_API)
|
||||
if (port == 0)
|
||||
err_sys("port number cannot be 0");
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
ShowUsage();
|
||||
exit(MY_EX_USAGE);
|
||||
|
|
@ -516,7 +542,10 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
|
|||
}
|
||||
|
||||
memset(&pwMapList, 0, sizeof(pwMapList));
|
||||
wolfSSH_SetUserAuth(ctx, wsUserAuth);
|
||||
if (serverArgs->user_auth == NULL)
|
||||
wolfSSH_SetUserAuth(ctx, wsUserAuth);
|
||||
else
|
||||
wolfSSH_SetUserAuth(ctx, ((func_args*)args)->user_auth);
|
||||
wolfSSH_CTX_SetBanner(ctx, echoserverBanner);
|
||||
|
||||
{
|
||||
|
|
@ -556,7 +585,6 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
|
|||
SOCKET_T clientFd = 0;
|
||||
SOCKADDR_IN_T clientAddr;
|
||||
socklen_t clientAddrSz = sizeof(clientAddr);
|
||||
THREAD_TYPE thread;
|
||||
WOLFSSH* ssh;
|
||||
thread_ctx_t* threadCtx;
|
||||
|
||||
|
|
@ -578,6 +606,8 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
|
|||
wolfSSH_SetHighwater(ssh, defaultHighwater);
|
||||
}
|
||||
|
||||
SignalTcpReady(serverArgs, port);
|
||||
|
||||
clientFd = accept(listenFd, (struct sockaddr*)&clientAddr,
|
||||
&clientAddrSz);
|
||||
if (clientFd == -1)
|
||||
|
|
@ -589,12 +619,7 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
|
|||
threadCtx->fd = clientFd;
|
||||
threadCtx->id = threadCount++;
|
||||
|
||||
start_thread(server_worker, threadCtx, &thread);
|
||||
|
||||
if (multipleConnections)
|
||||
detach_thread(thread);
|
||||
else
|
||||
join_thread(thread);
|
||||
server_worker(threadCtx);
|
||||
|
||||
} while (multipleConnections);
|
||||
|
||||
|
|
@ -617,16 +642,17 @@ THREAD_RETURN WOLFSSH_THREAD echoserver_test(void* args)
|
|||
args.argc = argc;
|
||||
args.argv = argv;
|
||||
args.return_code = 0;
|
||||
args.user_auth = NULL;
|
||||
|
||||
WSTARTTCP();
|
||||
|
||||
ChangeToWolfSshRoot();
|
||||
#ifdef DEBUG_WOLFSSH
|
||||
wolfSSH_Debugging_ON();
|
||||
#endif
|
||||
|
||||
wolfSSH_Init();
|
||||
|
||||
ChangeToWolfSshRoot();
|
||||
echoserver_test(&args);
|
||||
|
||||
wolfSSH_Cleanup();
|
||||
|
|
|
|||
|
|
@ -14,3 +14,5 @@ EXTRA_DIST+= ide/winvs/client/client.vcxproj
|
|||
EXTRA_DIST+= ide/winvs/client/client.vcxproj.user
|
||||
EXTRA_DIST+= ide/winvs/echoserver/echoserver.vcxproj
|
||||
EXTRA_DIST+= ide/winvs/echoserver/echoserver.vcxproj.user
|
||||
EXTRA_DIST+= ide/winvs/testsuite/testsuite.vcxproj
|
||||
EXTRA_DIST+= ide/winvs/testsuite/testsuite.vcxproj.user
|
||||
|
|
|
|||
|
|
@ -0,0 +1,336 @@
|
|||
<?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="DLL Debug|Win32">
|
||||
<Configuration>DLL Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="DLL Debug|x64">
|
||||
<Configuration>DLL Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="DLL Release|Win32">
|
||||
<Configuration>DLL Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="DLL Release|x64">
|
||||
<Configuration>DLL Release</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="..\..\..\examples\client\client.c" />
|
||||
<ClCompile Include="..\..\..\examples\echoserver\echoserver.c" />
|
||||
<ClCompile Include="..\..\..\tests\testsuite.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\wolfssh\wolfssh.vcxproj">
|
||||
<Project>{7c2ccf0d-a155-4914-bd1c-9a47c0530e65}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{BD09DA06-6D2E-4FB0-AE39-1BAE9FDAA9DD}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>testsuite</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)'=='DLL 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)'=='DLL 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)'=='DLL 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>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL 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" />
|
||||
<Import Project="..\wolfssh.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DLL Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\wolfssh.props" />
|
||||
</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" />
|
||||
<Import Project="..\wolfssh.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DLL Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\wolfssh.props" />
|
||||
</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" />
|
||||
<Import Project="..\wolfssh.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DLL Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\wolfssh.props" />
|
||||
</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" />
|
||||
<Import Project="..\wolfssh.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='DLL Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\wolfssh.props" />
|
||||
</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)'=='DLL 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)'=='DLL 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)'=='DLL 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>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL 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;NO_MAIN_DRIVER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..;..\..\..;$(wolfCryptDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>wolfssl.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>msvcrt.lib</IgnoreSpecificDefaultLibraries>
|
||||
<AdditionalLibraryDirectories>$(wolfCryptDebug32)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DLL Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;NO_MAIN_DRIVER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..;..\..\..;$(wolfCryptDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>wolfssl.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>msvcrt.lib</IgnoreSpecificDefaultLibraries>
|
||||
<AdditionalLibraryDirectories>$(wolfCryptDllDebug32)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;NO_MAIN_DRIVER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..;..\..\..;$(wolfCryptDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>wolfssl.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>msvcrt.lib</IgnoreSpecificDefaultLibraries>
|
||||
<AdditionalLibraryDirectories>$(wolfCryptDebug64)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DLL Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;NO_MAIN_DRIVER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..;..\..\..;$(wolfCryptDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>wolfssl.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>msvcrt.lib</IgnoreSpecificDefaultLibraries>
|
||||
<AdditionalLibraryDirectories>$(wolfCryptDllDebug64)</AdditionalLibraryDirectories>
|
||||
</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;NO_MAIN_DRIVER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..;..\..\..;$(wolfCryptDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>wolfssl.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(wolfCryptRelease32)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DLL Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;NO_MAIN_DRIVER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..;..\..\..;$(wolfCryptDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>wolfssl.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(wolfCryptDllRelease32)</AdditionalLibraryDirectories>
|
||||
</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;NO_MAIN_DRIVER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..;..\..\..;$(wolfCryptDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>wolfssl.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(wolfCryptRelease64)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='DLL Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;NO_MAIN_DRIVER;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>..;..\..\..;$(wolfCryptDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>wolfssl.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalLibraryDirectories>$(wolfCryptDllRelease64)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Debug|Win32'">
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
<LocalDebuggerEnvironment>PATH=$(wolfCryptDllDebug32);%PATH%</LocalDebuggerEnvironment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Debug|x64'">
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
<LocalDebuggerEnvironment>PATH=$(wolfCryptDllDebug64);%PATH%</LocalDebuggerEnvironment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Release|Win32'">
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
<LocalDebuggerEnvironment>PATH=$(wolfCryptDllRelease32);%PATH%</LocalDebuggerEnvironment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DLL Release|x64'">
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
<LocalDebuggerEnvironment>PATH=$(wolfCryptDllRelease64);%PATH%</LocalDebuggerEnvironment>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
@ -23,5 +23,6 @@
|
|||
#define USE_FAST_MATH
|
||||
#define TFM_TIMING_RESISTANT
|
||||
#define ECC_TIMING_RESISTANT
|
||||
#define WOLFSSL_PUBLIC_MP
|
||||
|
||||
#endif /* _WIN_USER_SETTINGS_H_ */
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unit-test", "unit-test\unit
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client", "client\client.vcxproj", "{663A7133-B13B-4C37-A5EC-97CA4D60CA3A}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testsuite", "testsuite\testsuite.vcxproj", "{BD09DA06-6D2E-4FB0-AE39-1BAE9FDAA9DD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
|
|
@ -109,6 +111,18 @@ Global
|
|||
{663A7133-B13B-4C37-A5EC-97CA4D60CA3A}.Release|Win32.Build.0 = Release|Win32
|
||||
{663A7133-B13B-4C37-A5EC-97CA4D60CA3A}.Release|x64.ActiveCfg = Release|x64
|
||||
{663A7133-B13B-4C37-A5EC-97CA4D60CA3A}.Release|x64.Build.0 = Release|x64
|
||||
{BD09DA06-6D2E-4FB0-AE39-1BAE9FDAA9DD}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{BD09DA06-6D2E-4FB0-AE39-1BAE9FDAA9DD}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{BD09DA06-6D2E-4FB0-AE39-1BAE9FDAA9DD}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{BD09DA06-6D2E-4FB0-AE39-1BAE9FDAA9DD}.DLL Debug|Win32.ActiveCfg = DLL Debug|Win32
|
||||
{BD09DA06-6D2E-4FB0-AE39-1BAE9FDAA9DD}.DLL Debug|Win32.Build.0 = DLL Debug|Win32
|
||||
{BD09DA06-6D2E-4FB0-AE39-1BAE9FDAA9DD}.DLL Debug|x64.ActiveCfg = DLL Debug|x64
|
||||
{BD09DA06-6D2E-4FB0-AE39-1BAE9FDAA9DD}.DLL Release|Win32.ActiveCfg = DLL Release|Win32
|
||||
{BD09DA06-6D2E-4FB0-AE39-1BAE9FDAA9DD}.DLL Release|Win32.Build.0 = DLL Release|Win32
|
||||
{BD09DA06-6D2E-4FB0-AE39-1BAE9FDAA9DD}.DLL Release|x64.ActiveCfg = DLL Release|x64
|
||||
{BD09DA06-6D2E-4FB0-AE39-1BAE9FDAA9DD}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{BD09DA06-6D2E-4FB0-AE39-1BAE9FDAA9DD}.Release|Win32.Build.0 = Release|Win32
|
||||
{BD09DA06-6D2E-4FB0-AE39-1BAE9FDAA9DD}.Release|x64.ActiveCfg = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
|||
|
|
@ -2914,6 +2914,7 @@ static int DoUserAuthRequestEcc(WOLFSSH* ssh, WS_UserAuthData_PublicKey* pk,
|
|||
|
||||
if (ret == WS_SUCCESS) {
|
||||
curveName = pk->publicKey + i;
|
||||
(void)curveName; /* Not used at the moment, hush the compiler. */
|
||||
i += curveNameSz;
|
||||
ret = GetUint32(&qSz, pk->publicKey, pk->publicKeySz, &i);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ int wolfSSH_SetAllocators(wolfSSH_Malloc_cb mf,
|
|||
|
||||
if (mf)
|
||||
malloc_function = mf;
|
||||
else
|
||||
else
|
||||
res = WS_BAD_ARGUMENT;
|
||||
|
||||
if (ff)
|
||||
|
|
|
|||
|
|
@ -2,17 +2,27 @@
|
|||
# included from Top Level Makefile.am
|
||||
# All paths should be given relative to the root
|
||||
|
||||
check_PROGRAMS += tests/unit.test tests/api.test
|
||||
noinst_PROGRAMS += tests/unit.test tests/api.test
|
||||
check_PROGRAMS += tests/unit.test tests/api.test \
|
||||
tests/testsuite.test
|
||||
noinst_PROGRAMS += tests/unit.test tests/api.test \
|
||||
tests/testsuite.test
|
||||
|
||||
tests_unit_test_SOURCES = tests/unit.c
|
||||
tests_unit_test_CFLAGS = -DNO_MAIN_DRIVER $(AM_CFLAGS)
|
||||
tests_unit_test_LDADD = src/libwolfssh.la $(LIB_STATIC_ADD)
|
||||
tests_unit_test_DEPENDENCIES = src/libwolfssh.la
|
||||
|
||||
tests_api_test_SOURCES = tests/api.c
|
||||
tests_api_test_CFLAGS = -DNO_MAIN_DRIVER $(AM_CFLAGS)
|
||||
tests_api_test_LDADD = src/libwolfssh.la $(LIB_STATIC_ADD)
|
||||
tests_api_test_DEPENDENCIES = src/libwolfssh.la
|
||||
tests_api_test_SOURCES = tests/api.c
|
||||
tests_api_test_CFLAGS = -DNO_MAIN_DRIVER $(AM_CFLAGS)
|
||||
tests_api_test_LDADD = src/libwolfssh.la $(LIB_STATIC_ADD)
|
||||
tests_api_test_DEPENDENCIES = src/libwolfssh.la
|
||||
|
||||
DISTCLEANFILES+= tests/.libs/unit.test tests/.libs/api.test
|
||||
tests_testsuite_test_SOURCES = tests/testsuite.c \
|
||||
examples/echoserver/echoserver.c \
|
||||
examples/client/client.c
|
||||
tests_testsuite_test_CFLAGS = -DNO_MAIN_DRIVER $(AM_CFLAGS)
|
||||
tests_testsuite_test_LDADD = src/libwolfssh.la $(LIB_STATIC_ADD)
|
||||
tests_testsuite_test_DEPENDENCIES = src/libwolfssh.la
|
||||
|
||||
DISTCLEANFILES+= tests/.libs/unit.test tests/.libs/api.test \
|
||||
tests/.libs/testsuite.test
|
||||
|
|
|
|||
|
|
@ -0,0 +1,233 @@
|
|||
/* testsuite.c
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef WOLFSSL_USER_SETTINGS
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
#else
|
||||
#include <wolfssl/options.h>
|
||||
#endif
|
||||
|
||||
#include <wolfssh/settings.h>
|
||||
#include <wolfssh/ssh.h>
|
||||
#include <wolfssh/test.h>
|
||||
#include "examples/echoserver/echoserver.h"
|
||||
#include "examples/client/client.h"
|
||||
|
||||
|
||||
#ifndef NO_TESTSUITE_MAIN_DRIVER
|
||||
|
||||
static int TestsuiteTest(int argc, char** argv);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
return TestsuiteTest(argc, argv);
|
||||
}
|
||||
|
||||
|
||||
int myoptind = 0;
|
||||
char* myoptarg = NULL;
|
||||
|
||||
#endif /* NO_TESTSUITE_MAIN_DRIVER */
|
||||
|
||||
|
||||
static int tsClientUserAuth(byte authType, WS_UserAuthData* authData, void* ctx)
|
||||
{
|
||||
static char password[] = "upthehill";
|
||||
|
||||
(void)authType;
|
||||
(void)ctx;
|
||||
|
||||
authData->sf.password.password = (byte*)password;
|
||||
authData->sf.password.passwordSz = (word32)WSTRLEN(password);
|
||||
return WOLFSSH_USERAUTH_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
#if !defined(NO_WOLFSSH_SERVER) && !defined(NO_WOLFSSH_CLIENT)
|
||||
|
||||
#define NUMARGS 5
|
||||
#define ARGLEN 32
|
||||
|
||||
int TestsuiteTest(int argc, char** argv)
|
||||
{
|
||||
tcp_ready ready;
|
||||
THREAD_TYPE serverThread;
|
||||
func_args serverArgs;
|
||||
func_args clientArgs;
|
||||
char sA[NUMARGS][ARGLEN];
|
||||
char *serverArgv[NUMARGS] =
|
||||
{ sA[0], sA[1], sA[2], sA[3], sA[4] };
|
||||
char cA[NUMARGS][ARGLEN];
|
||||
char *clientArgv[NUMARGS] =
|
||||
{ cA[0], cA[1], cA[2], cA[3], cA[4] };
|
||||
int serverArgc = 0;
|
||||
int clientArgc = 0;
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
WSTARTTCP();
|
||||
|
||||
wolfSSH_Init();
|
||||
#if defined(DEBUG_WOLFSSH)
|
||||
wolfSSH_Debugging_ON();
|
||||
#endif
|
||||
#if !defined(WOLFSSL_TIRTOS)
|
||||
ChangeToWolfSshRoot();
|
||||
#endif
|
||||
|
||||
InitTcpReady(&ready);
|
||||
|
||||
WSTRNCPY(serverArgv[serverArgc++], "echoserver", ARGLEN);
|
||||
WSTRNCPY(serverArgv[serverArgc++], "-1", ARGLEN);
|
||||
#ifndef USE_WINDOWS_API
|
||||
WSTRNCPY(serverArgv[serverArgc++], "-p", ARGLEN);
|
||||
WSTRNCPY(serverArgv[serverArgc++], "-0", ARGLEN);
|
||||
#endif
|
||||
|
||||
serverArgs.argc = serverArgc;
|
||||
serverArgs.argv = serverArgv;
|
||||
serverArgs.return_code = EXIT_SUCCESS;
|
||||
serverArgs.signal = &ready;
|
||||
serverArgs.user_auth = NULL;
|
||||
ThreadStart(echoserver_test, &serverArgs, &serverThread);
|
||||
WaitTcpReady(&serverArgs);
|
||||
|
||||
WSTRNCPY(cA[clientArgc++], "client", ARGLEN);
|
||||
WSTRNCPY(cA[clientArgc++], "-u", ARGLEN);
|
||||
WSTRNCPY(cA[clientArgc++], "jill", ARGLEN);
|
||||
#ifndef USE_WINDOWS_API
|
||||
WSTRNCPY(cA[clientArgc++], "-p", ARGLEN);
|
||||
WSNPRINTF(cA[clientArgc++], ARGLEN, "%d", ready.port);
|
||||
#endif
|
||||
|
||||
clientArgs.argc = clientArgc;
|
||||
clientArgs.argv = clientArgv;
|
||||
clientArgs.return_code = EXIT_SUCCESS;
|
||||
clientArgs.signal = &ready;
|
||||
clientArgs.user_auth = tsClientUserAuth;
|
||||
|
||||
client_test(&clientArgs);
|
||||
if (clientArgs.return_code != 0) {
|
||||
return clientArgs.return_code;
|
||||
}
|
||||
|
||||
ThreadJoin(serverThread);
|
||||
|
||||
wolfSSH_Cleanup();
|
||||
FreeTcpReady(&ready);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#else /* !NO_WOLFSSH_SERVER && !NO_WOLFSSH_CLIENT */
|
||||
|
||||
int TestsuiteTest(int argc, char** argv)
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#endif /* !NO_WOLFSSH_SERVER && !NO_WOLFSSH_CLIENT */
|
||||
|
||||
|
||||
void WaitTcpReady(func_args* args)
|
||||
{
|
||||
#if defined(_POSIX_THREADS) && !defined(__MINGW32__)
|
||||
pthread_mutex_lock(&args->signal->mutex);
|
||||
|
||||
if (!args->signal->ready)
|
||||
pthread_cond_wait(&args->signal->cond, &args->signal->mutex);
|
||||
args->signal->ready = 0; /* reset */
|
||||
|
||||
pthread_mutex_unlock(&args->signal->mutex);
|
||||
#else
|
||||
(void)args;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void ThreadStart(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
|
||||
}
|
||||
|
||||
|
||||
void ThreadJoin(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
|
||||
}
|
||||
|
||||
|
||||
void ThreadDetach(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
|
||||
}
|
||||
|
|
@ -140,94 +140,20 @@ static INLINE void FreeTcpReady(tcp_ready* ready)
|
|||
}
|
||||
|
||||
|
||||
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;
|
||||
WS_CallbackUserAuth user_auth;
|
||||
} 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 */
|
||||
void ThreadStart(THREAD_FUNC, void*, THREAD_TYPE*);
|
||||
void ThreadJoin(THREAD_TYPE);
|
||||
void ThreadDetach(THREAD_TYPE);
|
||||
void WaitTcpReady(func_args*);
|
||||
|
||||
|
||||
#ifndef TEST_IPV6
|
||||
|
|
|
|||
Loading…
Reference in New Issue