-// testi2.cpp : Defines the entry point for the application.\r
-//\r
-\r
-#define FD_SETSIZE 5000\r
-#include "stdafx.h"\r
-#include "resource.h"\r
-#include <winsock2.h>\r
-#include <mswsock.h>\r
-extern "C"\r
-{\r
-#define FD_SETSIZE 5000\r
-#include "silcincludes.h"\r
-#include "clientlibincludes.h"\r
-}\r
-\r
-#define MAX_LOADSTRING 100\r
-\r
-// Global Variables:\r
-HINSTANCE hInst; // current instance\r
-TCHAR szTitle[MAX_LOADSTRING]; // The title bar text\r
-TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text\r
-\r
-// Foward declarations of functions included in this code module:\r
-ATOM MyRegisterClass(HINSTANCE hInstance);\r
-BOOL InitInstance(HINSTANCE, int);\r
-LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);\r
-LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);\r
-\r
-void silc_op_say(SilcClient client, SilcClientConnection conn, \r
- SilcClientMessageType type, char *msg, ...)\r
-{\r
- va_list vp;\r
- char message[2048];\r
-\r
- memset(message, 0, sizeof(message));\r
- strncat(message, "\n*** ", 5);\r
-\r
- va_start(vp, msg);\r
- vsprintf(message + 5, msg, vp);\r
- va_end(vp);\r
-\r
- MessageBox( NULL, (char *)message, "say", MB_OK | MB_ICONINFORMATION );\r
-}\r
-\r
-void silc_notify(SilcClient client, SilcClientConnection conn, \r
- SilcNotifyType type, ...)\r
-{\r
-\r
-}\r
-\r
-void silc_connect(SilcClient client, SilcClientConnection conn, int success)\r
-{\r
-\r
-}\r
-\r
-int silc_auth_meth(SilcClient client, SilcClientConnection conn,\r
- char *hostname, uint16 port,\r
- SilcProtocolAuthMeth *auth_meth,\r
- unsigned char **auth_data,\r
- uint32 *auth_data_len)\r
-{\r
- *auth_meth = SILC_AUTH_NONE;\r
- return TRUE;\r
-}\r
-void silc_verify_public_key(SilcClient client, SilcClientConnection conn,\r
- SilcSocketType conn_type, unsigned char *pk, \r
- uint32 pk_len, SilcSKEPKType pk_type,\r
- SilcVerifyPublicKey completion, void *context)\r
-{\r
- completion(TRUE, context);\r
-}\r
-\r
-void silc_command_reply(SilcClient client, SilcClientConnection conn,\r
- SilcCommandPayload cmd_payload, int success,\r
- SilcCommand command, SilcCommandStatus status, ...)\r
-{\r
-\r
-}\r
-\r
-/* SILC client operations */\r
-SilcClientOperations ops = {\r
- silc_op_say,\r
- NULL,\r
- NULL,\r
- silc_notify,\r
- NULL,\r
- silc_command_reply,\r
- silc_connect,\r
- NULL,\r
- silc_auth_meth,\r
- silc_verify_public_key,\r
-};\r
-\r
-SILC_TASK_CALLBACK(connect_client)\r
-{\r
- SilcClient client = (SilcClient)context;\r
- silc_client_connect_to_server(client, 1334, "leevi.kuo.fi.ssh.com", NULL);\r
-}\r
-\r
-void silc_log(char *message)\r
-{\r
-}\r
-\r
-void silc_debugl(char *file, char *function, \r
- int line, char *message)\r
-{\r
- char m[5000];\r
- memcpy(m, message, strlen(message));\r
- m[strlen(message)] = '\n';\r
- m[strlen(message) + 1] = 0;\r
- OutputDebugString(m);\r
-}\r
-\r
-void silc_hexdumpl(char *file, char *function, \r
- int line, unsigned char *data_in,\r
- uint32 data_len, char *message)\r
-{\r
- int i, k;\r
- int off, pos, count;\r
- unsigned char *data = (unsigned char *)data_in;\r
- char m[10000], *cp;\r
- int len = data_len;\r
- \r
-// memset(m, 0, sizeof(m));\r
-\r
- cp = m;\r
- snprintf(cp, 10000, "%s:%d: %s\n", function, line, message);\r
- cp += strlen(cp);\r
-\r
- k = 0;\r
- off = len % 16;\r
- pos = 0;\r
- count = 16;\r
- while (1) {\r
-\r
- if (off) {\r
- if ((len - pos) < 16 && (len - pos <= len - off))\r
- count = off;\r
- } else {\r
- if (pos == len)\r
- count = 0;\r
- }\r
- if (off == len)\r
- count = len;\r
-\r
- if (count) {\r
- snprintf(cp, sizeof(m), "%08X ", k++ * 16);\r
- cp += strlen(cp);\r
- }\r
-\r
- for (i = 0; i < count; i++) {\r
- snprintf(cp, sizeof(m), "%02X ", data[pos + i]);\r
- cp += strlen(cp);\r
- \r
- if ((i + 1) % 4 == 0) {\r
- snprintf(cp, sizeof(m), " ");\r
- cp += strlen(cp);\r
- }\r
- }\r
-\r
- if (count && count < 16) {\r
- int j;\r
- \r
- for (j = 0; j < 16 - count; j++) {\r
- snprintf(cp, sizeof(m), " ");\r
- cp += strlen(cp);\r
- \r
- if ((j + count + 1) % 4 == 0) {\r
- snprintf(cp, sizeof(m), " ");\r
- cp += strlen(cp);\r
- }\r
- }\r
- }\r
- \r
- for (i = 0; i < count; i++) {\r
- char ch;\r
- \r
- if (data[pos] < 32 || data[pos] >= 127)\r
- ch = '.';\r
- else\r
- ch = data[pos];\r
-\r
- snprintf(cp, sizeof(m), "%c", ch);\r
- cp += strlen(cp);\r
- pos++;\r
- }\r
-\r
- if (count) {\r
- snprintf(cp, sizeof(m), "\n");\r
- cp += strlen(cp);\r
- }\r
-\r
- if (count < 16)\r
- break;\r
- }\r
- \r
- OutputDebugString(m);\r
- MessageBox( NULL, (char *)m, "hexdump", MB_OK | MB_ICONINFORMATION );\r
-}\r
-\r
-static int \r
-silc_create_key_pair(char *pkcs_name, int bits, char *path,\r
- char *identifier, \r
- SilcPublicKey *ret_pub_key,\r
- SilcPrivateKey *ret_prv_key)\r
-{\r
- SilcPKCS pkcs;\r
- SilcPublicKey pub_key;\r
- SilcPrivateKey prv_key;\r
- SilcRng rng;\r
- unsigned char *key;\r
- uint32 key_len;\r
- char pkfile[256], prvfile[256];\r
-\r
- if (!pkcs_name || !path)\r
- return FALSE;\r
-\r
- if (!bits)\r
- bits = 1024;\r
-\r
- rng = silc_rng_alloc();\r
- silc_rng_init(rng);\r
- silc_rng_global_init(rng);\r
-\r
- /* Generate keys */\r
- silc_pkcs_alloc((const unsigned char *)pkcs_name, &pkcs);\r
- pkcs->pkcs->init(pkcs->context, bits, rng);\r
-\r
- /* Save public key into file */\r
- key = silc_pkcs_get_public_key(pkcs, &key_len);\r
- pub_key = silc_pkcs_public_key_alloc(pkcs->pkcs->name, identifier,\r
- key, key_len);\r
- *ret_pub_key = pub_key;\r
-\r
- memset(key, 0, sizeof(key_len));\r
- silc_free(key);\r
-\r
- /* Save private key into file */\r
- key = silc_pkcs_get_private_key(pkcs, &key_len);\r
- prv_key = silc_pkcs_private_key_alloc(pkcs->pkcs->name, key, key_len);\r
- *ret_prv_key = prv_key;\r
-\r
- memset(key, 0, sizeof(key_len));\r
- silc_free(key);\r
-\r
- silc_rng_free(rng);\r
- silc_pkcs_free(pkcs);\r
-\r
- return TRUE;\r
-}\r
-\r
-\r
-int APIENTRY WinMain(HINSTANCE hInstance,\r
- HINSTANCE hPrevInstance,\r
- LPSTR lpCmdLine,\r
- int nCmdShow)\r
-{\r
- // TODO: Place code here.\r
- MSG msg;\r
- HACCEL hAccelTable;\r
- HANDLE h;\r
- HANDLE handles[100];\r
- SOCKET s;\r
- unsigned int k;\r
- WSAEVENT e, e2, e3;\r
- int ret;\r
- DWORD ready;\r
- HMODULE mod;\r
-\r
- // Initialize global strings\r
- LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);\r
- LoadString(hInstance, IDC_TESTI2, szWindowClass, MAX_LOADSTRING);\r
- MyRegisterClass(hInstance);\r
-\r
- // Perform application initialization:\r
- if (!InitInstance (hInstance, nCmdShow)) \r
- {\r
- return FALSE;\r
- }\r
-\r
- hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TESTI2);\r
-\r
- {\r
- SilcSchedule sched; \r
- SilcClient client;\r
-\r
- silc_net_win32_init();\r
- client = silc_client_alloc(&ops, NULL, NULL, "SILC-1.0-0.5.1");\r
- client->realname = "pekka riikonen";\r
- client->username = "priikone";\r
- client->hostname = "leevi.kuo.fi.ssh.com";\r
-\r
- silc_cipher_register_default();\r
- silc_pkcs_register_default();\r
- silc_hash_register_default();\r
- silc_hmac_register_default();\r
-\r
- silc_debug = TRUE;\r
- silc_log_set_debug_callbacks(silc_debugl, silc_hexdumpl);\r
-\r
- silc_create_key_pair("rsa", 1024, "kk", "UN=priikone, HN=pelle.kuo.fi.ssh.com", \r
- &client->public_key, &client->private_key);\r
-\r
- silc_client_init(client);\r
-\r
- silc_schedule_task_add(client->schedule, 0, connect_client, \r
- client, 0, 1, SILC_TASK_TIMEOUT, SILC_TASK_PRI_NORMAL); \r
-\r
- silc_client_run(client); \r
- }\r
- \r
- return msg.wParam;\r
-}\r
-\r
-//\r
-// FUNCTION: MyRegisterClass()\r
-//\r
-// PURPOSE: Registers the window class.\r
-//\r
-// COMMENTS:\r
-//\r
-// This function and its usage is only necessary if you want this code\r
-// to be compatible with Win32 systems prior to the 'RegisterClassEx'\r
-// function that was added to Windows 95. It is important to call this function\r
-// so that the application will get 'well formed' small icons associated\r
-// with it.\r
-//\r
-ATOM MyRegisterClass(HINSTANCE hInstance)\r
-{\r
- WNDCLASSEX wcex;\r
-\r
- wcex.cbSize = sizeof(WNDCLASSEX); \r
-\r
- wcex.style = CS_HREDRAW | CS_VREDRAW;\r
- wcex.lpfnWndProc = (WNDPROC)WndProc;\r
- wcex.cbClsExtra = 0;\r
- wcex.cbWndExtra = 0;\r
- wcex.hInstance = hInstance;\r
- wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_TESTI2);\r
- wcex.hCursor = LoadCursor(NULL, IDC_ARROW);\r
- wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);\r
- wcex.lpszMenuName = (LPCSTR)IDC_TESTI2;\r
- wcex.lpszClassName = szWindowClass;\r
- wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);\r
-\r
- return RegisterClassEx(&wcex);\r
-}\r
-\r
-//\r
-// FUNCTION: InitInstance(HANDLE, int)\r
-//\r
-// PURPOSE: Saves instance handle and creates main window\r
-//\r
-// COMMENTS:\r
-//\r
-// In this function, we save the instance handle in a global variable and\r
-// create and display the main program window.\r
-//\r
-BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)\r
-{\r
- HWND hWnd;\r
-\r
- hInst = hInstance; // Store instance handle in our global variable\r
-\r
- hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,\r
- CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);\r
-\r
- if (!hWnd)\r
- {\r
- LPVOID lpMsgBuf;\r
- FormatMessage( \r
- FORMAT_MESSAGE_ALLOCATE_BUFFER | \r
- FORMAT_MESSAGE_FROM_SYSTEM | \r
- FORMAT_MESSAGE_IGNORE_INSERTS,\r
- NULL,\r
- GetLastError(),\r
- 0, // Default language\r
- (LPTSTR) &lpMsgBuf,\r
- 0,\r
- NULL \r
- );\r
- // Process any inserts in lpMsgBuf.\r
- // ...\r
- // Display the string.\r
- MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );\r
- // Free the buffer.\r
- LocalFree( lpMsgBuf );\r
-\r
- return FALSE;\r
- }\r
-\r
- ShowWindow(hWnd, nCmdShow);\r
- UpdateWindow(hWnd);\r
-\r
- return TRUE;\r
-}\r
-\r
-//\r
-// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)\r
-//\r
-// PURPOSE: Processes messages for the main window.\r
-//\r
-// WM_COMMAND - process the application menu\r
-// WM_PAINT - Paint the main window\r
-// WM_DESTROY - post a quit message and return\r
-//\r
-//\r
-LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)\r
-{\r
- int wmId, wmEvent;\r
- PAINTSTRUCT ps;\r
- HDC hdc;\r
- TCHAR szHello[MAX_LOADSTRING];\r
- LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);\r
-\r
- switch (message) \r
- {\r
- case WM_COMMAND:\r
- wmId = LOWORD(wParam); \r
- wmEvent = HIWORD(wParam); \r
- // Parse the menu selections:\r
- switch (wmId)\r
- {\r
- case IDM_ABOUT:\r
- DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);\r
- break;\r
- case IDM_EXIT:\r
- DestroyWindow(hWnd);\r
- break;\r
- default:\r
- return DefWindowProc(hWnd, message, wParam, lParam);\r
- }\r
- break;\r
- case WM_PAINT:\r
- hdc = BeginPaint(hWnd, &ps);\r
- // TODO: Add any drawing code here...\r
- RECT rt;\r
- GetClientRect(hWnd, &rt);\r
- DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);\r
- EndPaint(hWnd, &ps);\r
- break;\r
- case WM_DESTROY:\r
- PostQuitMessage(0);\r
- break;\r
- default:\r
- return DefWindowProc(hWnd, message, wParam, lParam);\r
- }\r
- return 0;\r
-}\r
-\r
-// Mesage handler for about box.\r
-LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
-{\r
- switch (message)\r
- {\r
- case WM_INITDIALOG:\r
- return TRUE;\r
-\r
- case WM_COMMAND:\r
- if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) \r
- {\r
- EndDialog(hDlg, LOWORD(wParam));\r
- return TRUE;\r
- }\r
- break;\r
- }\r
- return FALSE;\r
-}\r
+// testi2.cpp : Defines the entry point for the application.
+//
+
+#define FD_SETSIZE 5000
+#include "stdafx.h"
+#include "resource.h"
+#include <winsock2.h>
+#include <mswsock.h>
+extern "C"
+{
+#define FD_SETSIZE 5000
+#include "silcincludes.h"
+#include "clientlibincludes.h"
+}
+
+#define MAX_LOADSTRING 100
+
+// Global Variables:
+HINSTANCE hInst; // current instance
+TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
+TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
+
+// Foward declarations of functions included in this code module:
+ATOM MyRegisterClass(HINSTANCE hInstance);
+BOOL InitInstance(HINSTANCE, int);
+LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
+LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
+
+void silc_op_say(SilcClient client, SilcClientConnection conn,
+ SilcClientMessageType type, char *msg, ...)
+{
+ va_list vp;
+ char message[2048];
+
+ memset(message, 0, sizeof(message));
+ strncat(message, "\n*** ", 5);
+
+ va_start(vp, msg);
+ vsprintf(message + 5, msg, vp);
+ va_end(vp);
+
+ MessageBox( NULL, (char *)message, "say", MB_OK | MB_ICONINFORMATION );
+}
+
+void silc_notify(SilcClient client, SilcClientConnection conn,
+ SilcNotifyType type, ...)
+{
+
+}
+
+void silc_connect(SilcClient client, SilcClientConnection conn, int success)
+{
+
+}
+
+int silc_auth_meth(SilcClient client, SilcClientConnection conn,
+ char *hostname, SilcUInt16 port,
+ SilcProtocolAuthMeth *auth_meth,
+ unsigned char **auth_data,
+ SilcUInt32 *auth_data_len)
+{
+ *auth_meth = SILC_AUTH_NONE;
+ return TRUE;
+}
+void silc_verify_public_key(SilcClient client, SilcClientConnection conn,
+ SilcSocketType conn_type, unsigned char *pk,
+ SilcUInt32 pk_len, SilcSKEPKType pk_type,
+ SilcVerifyPublicKey completion, void *context)
+{
+ completion(TRUE, context);
+}
+
+void silc_command_reply(SilcClient client, SilcClientConnection conn,
+ SilcCommandPayload cmd_payload, int success,
+ SilcCommand command, SilcCommandStatus status, ...)
+{
+
+}
+
+/* SILC client operations */
+SilcClientOperations ops = {
+ silc_op_say,
+ NULL,
+ NULL,
+ silc_notify,
+ NULL,
+ silc_command_reply,
+ silc_connect,
+ NULL,
+ silc_auth_meth,
+ silc_verify_public_key,
+};
+
+SILC_TASK_CALLBACK(connect_client)
+{
+ SilcClient client = (SilcClient)context;
+ silc_client_connect_to_server(client, 1334, "leevi.kuo.fi.ssh.com", NULL);
+}
+
+void silc_log(char *message)
+{
+}
+
+void silc_debugl(char *file, char *function,
+ int line, char *message)
+{
+ char m[5000];
+ memcpy(m, message, strlen(message));
+ m[strlen(message)] = '\n';
+ m[strlen(message) + 1] = 0;
+ OutputDebugString(m);
+}
+
+void silc_hexdumpl(char *file, char *function,
+ int line, unsigned char *data_in,
+ SilcUInt32 data_len, char *message)
+{
+ int i, k;
+ int off, pos, count;
+ unsigned char *data = (unsigned char *)data_in;
+ char m[10000], *cp;
+ int len = data_len;
+
+// memset(m, 0, sizeof(m));
+
+ cp = m;
+ snprintf(cp, 10000, "%s:%d: %s\n", function, line, message);
+ cp += strlen(cp);
+
+ k = 0;
+ off = len % 16;
+ pos = 0;
+ count = 16;
+ while (1) {
+
+ if (off) {
+ if ((len - pos) < 16 && (len - pos <= len - off))
+ count = off;
+ } else {
+ if (pos == len)
+ count = 0;
+ }
+ if (off == len)
+ count = len;
+
+ if (count) {
+ snprintf(cp, sizeof(m), "%08X ", k++ * 16);
+ cp += strlen(cp);
+ }
+
+ for (i = 0; i < count; i++) {
+ snprintf(cp, sizeof(m), "%02X ", data[pos + i]);
+ cp += strlen(cp);
+
+ if ((i + 1) % 4 == 0) {
+ snprintf(cp, sizeof(m), " ");
+ cp += strlen(cp);
+ }
+ }
+
+ if (count && count < 16) {
+ int j;
+
+ for (j = 0; j < 16 - count; j++) {
+ snprintf(cp, sizeof(m), " ");
+ cp += strlen(cp);
+
+ if ((j + count + 1) % 4 == 0) {
+ snprintf(cp, sizeof(m), " ");
+ cp += strlen(cp);
+ }
+ }
+ }
+
+ for (i = 0; i < count; i++) {
+ char ch;
+
+ if (data[pos] < 32 || data[pos] >= 127)
+ ch = '.';
+ else
+ ch = data[pos];
+
+ snprintf(cp, sizeof(m), "%c", ch);
+ cp += strlen(cp);
+ pos++;
+ }
+
+ if (count) {
+ snprintf(cp, sizeof(m), "\n");
+ cp += strlen(cp);
+ }
+
+ if (count < 16)
+ break;
+ }
+
+ OutputDebugString(m);
+ MessageBox( NULL, (char *)m, "hexdump", MB_OK | MB_ICONINFORMATION );
+}
+
+static int
+silc_create_key_pair(char *pkcs_name, int bits, char *path,
+ char *identifier,
+ SilcPublicKey *ret_pub_key,
+ SilcPrivateKey *ret_prv_key)
+{
+ SilcPKCS pkcs;
+ SilcPublicKey pub_key;
+ SilcPrivateKey prv_key;
+ SilcRng rng;
+ unsigned char *key;
+ SilcUInt32 key_len;
+ char pkfile[256], prvfile[256];
+
+ if (!pkcs_name || !path)
+ return FALSE;
+
+ if (!bits)
+ bits = 1024;
+
+ rng = silc_rng_alloc();
+ silc_rng_init(rng);
+ silc_rng_global_init(rng);
+
+ /* Generate keys */
+ silc_pkcs_alloc((const unsigned char *)pkcs_name, &pkcs);
+ pkcs->pkcs->init(pkcs->context, bits, rng);
+
+ /* Save public key into file */
+ key = silc_pkcs_get_public_key(pkcs, &key_len);
+ pub_key = silc_pkcs_public_key_alloc(pkcs->pkcs->name, identifier,
+ key, key_len);
+ *ret_pub_key = pub_key;
+
+ memset(key, 0, sizeof(key_len));
+ silc_free(key);
+
+ /* Save private key into file */
+ key = silc_pkcs_get_private_key(pkcs, &key_len);
+ prv_key = silc_pkcs_private_key_alloc(pkcs->pkcs->name, key, key_len);
+ *ret_prv_key = prv_key;
+
+ memset(key, 0, sizeof(key_len));
+ silc_free(key);
+
+ silc_rng_free(rng);
+ silc_pkcs_free(pkcs);
+
+ return TRUE;
+}
+
+
+int APIENTRY WinMain(HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPSTR lpCmdLine,
+ int nCmdShow)
+{
+ // TODO: Place code here.
+ MSG msg;
+ HACCEL hAccelTable;
+ HANDLE h;
+ HANDLE handles[100];
+ SOCKET s;
+ unsigned int k;
+ WSAEVENT e, e2, e3;
+ int ret;
+ DWORD ready;
+ HMODULE mod;
+
+ // Initialize global strings
+ LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
+ LoadString(hInstance, IDC_TESTI2, szWindowClass, MAX_LOADSTRING);
+ MyRegisterClass(hInstance);
+
+ // Perform application initialization:
+ if (!InitInstance (hInstance, nCmdShow))
+ {
+ return FALSE;
+ }
+
+ hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TESTI2);
+
+ {
+ SilcSchedule sched;
+ SilcClient client;
+
+ silc_net_win32_init();
+ client = silc_client_alloc(&ops, NULL, NULL, "SILC-1.0-0.5.1");
+ client->realname = "pekka riikonen";
+ client->username = "priikone";
+ client->hostname = "leevi.kuo.fi.ssh.com";
+
+ silc_cipher_register_default();
+ silc_pkcs_register_default();
+ silc_hash_register_default();
+ silc_hmac_register_default();
+
+ silc_debug = TRUE;
+ silc_log_set_debug_callbacks(silc_debugl, silc_hexdumpl);
+
+ silc_create_key_pair("rsa", 1024, "kk", "UN=priikone, HN=pelle.kuo.fi.ssh.com",
+ &client->public_key, &client->private_key);
+
+ silc_client_init(client);
+
+ silc_schedule_task_add(client->schedule, 0, connect_client,
+ client, 0, 1, SILC_TASK_TIMEOUT, SILC_TASK_PRI_NORMAL);
+
+ silc_client_run(client);
+ }
+
+ return msg.wParam;
+}
+
+//
+// FUNCTION: MyRegisterClass()
+//
+// PURPOSE: Registers the window class.
+//
+// COMMENTS:
+//
+// This function and its usage is only necessary if you want this code
+// to be compatible with Win32 systems prior to the 'RegisterClassEx'
+// function that was added to Windows 95. It is important to call this function
+// so that the application will get 'well formed' small icons associated
+// with it.
+//
+ATOM MyRegisterClass(HINSTANCE hInstance)
+{
+ WNDCLASSEX wcex;
+
+ wcex.cbSize = sizeof(WNDCLASSEX);
+
+ wcex.style = CS_HREDRAW | CS_VREDRAW;
+ wcex.lpfnWndProc = (WNDPROC)WndProc;
+ wcex.cbClsExtra = 0;
+ wcex.cbWndExtra = 0;
+ wcex.hInstance = hInstance;
+ wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_TESTI2);
+ wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
+ wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
+ wcex.lpszMenuName = (LPCSTR)IDC_TESTI2;
+ wcex.lpszClassName = szWindowClass;
+ wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
+
+ return RegisterClassEx(&wcex);
+}
+
+//
+// FUNCTION: InitInstance(HANDLE, int)
+//
+// PURPOSE: Saves instance handle and creates main window
+//
+// COMMENTS:
+//
+// In this function, we save the instance handle in a global variable and
+// create and display the main program window.
+//
+BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
+{
+ HWND hWnd;
+
+ hInst = hInstance; // Store instance handle in our global variable
+
+ hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
+ CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
+
+ if (!hWnd)
+ {
+ LPVOID lpMsgBuf;
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError(),
+ 0, // Default language
+ (LPTSTR) &lpMsgBuf,
+ 0,
+ NULL
+ );
+ // Process any inserts in lpMsgBuf.
+ // ...
+ // Display the string.
+ MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
+ // Free the buffer.
+ LocalFree( lpMsgBuf );
+
+ return FALSE;
+ }
+
+ ShowWindow(hWnd, nCmdShow);
+ UpdateWindow(hWnd);
+
+ return TRUE;
+}
+
+//
+// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
+//
+// PURPOSE: Processes messages for the main window.
+//
+// WM_COMMAND - process the application menu
+// WM_PAINT - Paint the main window
+// WM_DESTROY - post a quit message and return
+//
+//
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ int wmId, wmEvent;
+ PAINTSTRUCT ps;
+ HDC hdc;
+ TCHAR szHello[MAX_LOADSTRING];
+ LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
+
+ switch (message)
+ {
+ case WM_COMMAND:
+ wmId = LOWORD(wParam);
+ wmEvent = HIWORD(wParam);
+ // Parse the menu selections:
+ switch (wmId)
+ {
+ case IDM_ABOUT:
+ DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
+ break;
+ case IDM_EXIT:
+ DestroyWindow(hWnd);
+ break;
+ default:
+ return DefWindowProc(hWnd, message, wParam, lParam);
+ }
+ break;
+ case WM_PAINT:
+ hdc = BeginPaint(hWnd, &ps);
+ // TODO: Add any drawing code here...
+ RECT rt;
+ GetClientRect(hWnd, &rt);
+ DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
+ EndPaint(hWnd, &ps);
+ break;
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
+ default:
+ return DefWindowProc(hWnd, message, wParam, lParam);
+ }
+ return 0;
+}
+
+// Mesage handler for about box.
+LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch (message)
+ {
+ case WM_INITDIALOG:
+ return TRUE;
+
+ case WM_COMMAND:
+ if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
+ {
+ EndDialog(hDlg, LOWORD(wParam));
+ return TRUE;
+ }
+ break;
+ }
+ return FALSE;
+}