summaryrefslogtreecommitdiff
path: root/extra/yassl/testsuite
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2019-02-13 10:57:54 +0100
committerVladislav Vaintroub <wlad@mariadb.com>2019-05-22 13:48:26 +0200
commit592fe954ef82be1bc08b29a8e54f7729eb1e1343 (patch)
treedd153e47c6f594b496b8ca124ddc21bccdc1aba2 /extra/yassl/testsuite
parent5e4b657dd44dce601c91bc77a41f6e382bc32000 (diff)
downloadmariadb-git-592fe954ef82be1bc08b29a8e54f7729eb1e1343.tar.gz
MDEV-18531 : remove yassl
Diffstat (limited to 'extra/yassl/testsuite')
-rw-r--r--extra/yassl/testsuite/cipher-test.sh131
-rw-r--r--extra/yassl/testsuite/input107
-rwxr-xr-xextra/yassl/testsuite/make.bat29
-rw-r--r--extra/yassl/testsuite/quit2
-rw-r--r--extra/yassl/testsuite/test.hpp553
-rw-r--r--extra/yassl/testsuite/testsuite.cpp174
-rw-r--r--extra/yassl/testsuite/testsuite.dsp127
7 files changed, 0 insertions, 1123 deletions
diff --git a/extra/yassl/testsuite/cipher-test.sh b/extra/yassl/testsuite/cipher-test.sh
deleted file mode 100644
index d3e69146097..00000000000
--- a/extra/yassl/testsuite/cipher-test.sh
+++ /dev/null
@@ -1,131 +0,0 @@
-#!/bin/bash
-
-# test all yassl cipher suties
-#
-
-
-no_pid=-1
-server_pid=$no_pid
-
-
-do_cleanup() {
- echo "in cleanup"
-
- if [[ $server_pid != $no_pid ]]
- then
- echo "killing server"
- kill -9 $server_pid
- fi
-}
-
-do_trap() {
- echo "got trap"
- do_cleanup
- exit -1
-}
-
-trap do_trap INT TERM
-
-
-# make sure example server and client are built
-if test ! -s ../examples/server/server; then
- echo "Please build yaSSL first, example server missing"
- exit -1
-fi
-
-if test ! -s ../examples/client/client; then
- echo "Please build yaSSL first, example client missing"
- exit -1
-fi
-
-
-# non DSA suites
-for suite in {"DHE-RSA-AES256-SHA","AES256-SHA","DHE-RSA-AES128-SHA","AES128-SHA","AES256-RMD","AES128-RMD","DES-CBC3-RMD","DHE-RSA-AES256-RMD","DHE-RSA-AES128-RMD","DHE-RSA-DES-CBC3-RMD","RC4-SHA","RC4-MD5","DES-CBC3-SHA","DES-CBC-SHA","EDH-RSA-DES-CBC3-SHA","EDH-RSA-DES-CBC-SHA"}
-do
- for client_auth in {y,n}
- do
- echo "Trying $suite client auth = $client_auth ..."
-
- if test -e server_ready; then
- echo -e "removing exisitng server_ready file"
- rm server_ready
- fi
- ../examples/server/server $client_auth &
- server_pid=$!
-
- while [ ! -s server_ready ]; do
- echo -e "waiting for server_ready file..."
- sleep 0.1
- done
-
- ../examples/client/client $suite
- client_result=$?
-
- wait $server_pid
- server_result=$?
-
- server_pid=$no_pid
-
- if [[ $client_result != 0 ]]
- then
- echo "Client Error"
- exit $client_result
- fi
-
- if [[ $server_result != 0 ]]
- then
- echo "Server Error"
- exit $server_result
- fi
-
- done # end client auth loop
-done # end non dsa suite list
-echo -e "Non DSA Loop SUCCESS"
-
-
-
-# DSA suites
-for suite in {"DHE-DSS-AES256-SHA","DHE-DSS-AES128-SHA","DHE-DSS-AES256-RMD","DHE-DSS-AES128-RMD","DHE-DSS-DES-CBC3-RMD","EDH-DSS-DES-CBC3-SHA","EDH-DSS-DES-CBC-SHA"}
-do
- for client_auth in {y,n}
- do
- echo "Trying $suite client auth = $client_auth ..."
-
- if test -e server_ready; then
- echo -e "removing exisitng server_ready file"
- rm server_ready
- fi
- # d signifies DSA
- ../examples/server/server $client_auth d &
- server_pid=$!
-
- while [ ! -s server_ready ]; do
- echo -e "waiting for server_ready file..."
- sleep 0.1
- done
-
- ../examples/client/client $suite
- client_result=$?
-
- wait $server_pid
- server_result=$?
-
- server_pid=$no_pid
-
- if [[ $client_result != 0 ]]
- then
- echo "Client Error"
- exit $client_result
- fi
-
- if [[ $server_result != 0 ]]
- then
- echo "Server Error"
- exit $server_result
- fi
-
- done # end client auth loop
-done # end dsa suite list
-echo -e "DSA Loop SUCCESS"
-
-exit 0
diff --git a/extra/yassl/testsuite/input b/extra/yassl/testsuite/input
deleted file mode 100644
index d16cbc40750..00000000000
--- a/extra/yassl/testsuite/input
+++ /dev/null
@@ -1,107 +0,0 @@
-// testsuite.cpp
-
-#include "test.hpp"
-#include "md5.hpp"
-
-typedef unsigned char byte;
-
-void taocrypt_test(void*);
-void file_test(char*, byte*);
-
-void client_test(void*);
-void echoclient_test(void*);
-
-THREAD_RETURN YASSL_API server_test(void*);
-THREAD_RETURN YASSL_API echoserver_test(void*);
-
-int main(int argc, char** argv)
-{
- func_args args(argc, argv);
- func_args server_args(args);
-
- // *** Crypto Test ***
- taocrypt_test(&args);
- assert(args.return_code == 0);
-
-
- // *** Simple yaSSL client server test ***
- THREAD_TYPE thread;
-
- start_thread(server_test, &server_args, &thread);
- client_test(&args);
-
- assert(args.return_code == 0);
- join_thread(thread);
- assert(server_args.return_code == 0);
-
-
- // *** Echo input yaSSL client server test ***
- start_thread(echoserver_test, &server_args, &thread);
- func_args echo_args;
-
- // setup args
- echo_args.argc = 3;
- echo_args.argv = new char*[echo_args.argc];
- for (int i = 0; i < echo_args.argc; i++)
- echo_args.argv[i] = new char[32];
-
- strcpy(echo_args.argv[0], "echoclient");
- strcpy(echo_args.argv[1], "input");
- strcpy(echo_args.argv[2], "output");
- remove("output");
-
- // make sure OK
- echoclient_test(&echo_args);
- assert(echo_args.return_code == 0);
-
-
- // *** Echo quit yaSSL client server test ***
- echo_args.argc = 2;
- strcpy(echo_args.argv[1], "quit");
-
- echoclient_test(&echo_args);
- assert(echo_args.return_code == 0);
- join_thread(thread);
- assert(server_args.return_code == 0);
-
-
- // input output compare
- byte input[TaoCrypt::MD5::DIGEST_SIZE];
- byte output[TaoCrypt::MD5::DIGEST_SIZE];
- file_test("input", input);
- file_test("output", output);
- assert(memcmp(input, output, sizeof(input)) == 0);
-
- printf("\nAll tests passed!\n");
-
- // cleanup
- for (int j = echo_args.argc; j >= 0; j--)
- delete[] echo_args.argv[j];
- delete[] echo_args.argv;
-
- return 0;
-}
-
-
-
-void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)
-{
-#ifdef _WIN32
- *thread = _beginthreadex(0, 0, fun, args, 0, 0);
-#else
- pthread_create(thread, 0, fun, args);
-#endif
-}
-
-
-void join_thread(THREAD_TYPE thread)
-{
-#ifdef _WIN32
- int res = WaitForSingleObject(reinterpret_cast<HANDLE>(thread), INFINITE);
- assert(res == WAIT_OBJECT_0);
- res = CloseHandle(reinterpret_cast<HANDLE>(thread));
- assert(res);
-#else
- pthread_join(thread, 0);
-#endif
-}
diff --git a/extra/yassl/testsuite/make.bat b/extra/yassl/testsuite/make.bat
deleted file mode 100755
index eddbe90c400..00000000000
--- a/extra/yassl/testsuite/make.bat
+++ /dev/null
@@ -1,29 +0,0 @@
-REM Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
-REM
-REM This program is free software; you can redistribute it and/or modify
-REM it under the terms of the GNU General Public License as published by
-REM the Free Software Foundation; version 2 of the License.
-REM
-REM This program is distributed in the hope that it will be useful,
-REM but WITHOUT ANY WARRANTY; without even the implied warranty of
-REM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-REM GNU General Public License for more details.
-REM
-REM You should have received a copy of the GNU General Public License
-REM along with this program; if not, write to the Free Software
-REM Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
-
-REM quick and dirty build file for testing different MSDEVs
-setlocal
-
-set myFLAGS= /I../include /I../taocrypt/include /I../taocrypt/mySTL /c /W3 /G6 /O2 /MT /D"WIN32" /D"NO_MAIN_DRIVER"
-
-cl %myFLAGS% testsuite.cpp
-cl %myFLAGS% ../examples/client/client.cpp
-cl %myFLAGS% ../examples/echoclient/echoclient.cpp
-cl %myFLAGS% ../examples/server/server.cpp
-cl %myFLAGS% ../examples/echoserver/echoserver.cpp
-cl %myFLAGS% ../taocrypt/test/test.cpp
-
-link.exe /out:testsuite.exe ../src/yassl.lib ../taocrypt/src/taocrypt.lib testsuite.obj client.obj server.obj echoclient.obj echoserver.obj test.obj advapi32.lib Ws2_32.lib
-
diff --git a/extra/yassl/testsuite/quit b/extra/yassl/testsuite/quit
deleted file mode 100644
index 3db49b3ad12..00000000000
--- a/extra/yassl/testsuite/quit
+++ /dev/null
@@ -1,2 +0,0 @@
-quit
-
diff --git a/extra/yassl/testsuite/test.hpp b/extra/yassl/testsuite/test.hpp
deleted file mode 100644
index 12da450fffe..00000000000
--- a/extra/yassl/testsuite/test.hpp
+++ /dev/null
@@ -1,553 +0,0 @@
-/*
- Copyright (c) 2006, 2012, Oracle and/or its affiliates.
-
- This program 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; version 2 of the License.
-
- This program 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 this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1335 USA.
-*/
-
-// test.hpp
-
-#ifndef yaSSL_TEST_HPP
-#define yaSSL_TEST_HPP
-
-#include "runtime.hpp"
-#include "error.hpp"
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-//#define NON_BLOCKING // test server and client example (not echos)
-
-#ifdef _WIN32
- #include <winsock2.h>
- #include <process.h>
- #ifdef TEST_IPV6 // don't require newer SDK for IPV4
- #include <ws2tcpip.h>
- #include <wspiapi.h>
- #endif
- #define SOCKET_T unsigned int
-#else
- #include <string.h>
- #include <unistd.h>
- #include <netinet/in.h>
- #include <arpa/inet.h>
- #include <sys/ioctl.h>
- #include <sys/time.h>
- #include <sys/types.h>
- #include <sys/socket.h>
- #ifdef TEST_IPV6
- #include <netdb.h>
- #endif
- #include <pthread.h>
-#ifdef NON_BLOCKING
- #include <fcntl.h>
-#endif
- #define SOCKET_T int
-#endif /* _WIN32 */
-#include "openssl/ssl.h" /* openssl compatibility test */
-
-
-#ifdef _MSC_VER
- // disable conversion warning
- // 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy
- #pragma warning(disable:4244 4996)
-#endif
-
-
-#if !defined(_SOCKLEN_T) && (defined(_WIN32) || defined(__APPLE__))
- typedef int socklen_t;
-#endif
-
-
-// Check type of third arg to accept
-#if defined(__hpux)
-// HPUX uses int* for third parameter to accept
- typedef int* ACCEPT_THIRD_T;
-#else
- typedef socklen_t* ACCEPT_THIRD_T;
-#endif
-
-
-#ifdef TEST_IPV6
- typedef sockaddr_in6 SOCKADDR_IN_T;
- #define AF_INET_V AF_INET6
-#else
- typedef sockaddr_in SOCKADDR_IN_T;
- #define AF_INET_V AF_INET
-#endif
-
-
-// Check if _POSIX_THREADS should be forced
-#if !defined(_POSIX_THREADS) && defined(__hpux)
-// HPUX does not define _POSIX_THREADS as it's not _fully_ implemented
-#define _POSIX_THREADS
-#endif
-
-
-#ifndef _POSIX_THREADS
- typedef unsigned int THREAD_RETURN;
- typedef HANDLE THREAD_TYPE;
- #define YASSL_API __stdcall
-#else
- typedef void* THREAD_RETURN;
- typedef pthread_t THREAD_TYPE;
- #define YASSL_API
-#endif
-
-
-struct tcp_ready {
-#ifdef _POSIX_THREADS
- pthread_mutex_t mutex_;
- pthread_cond_t cond_;
- bool ready_; // predicate
-
- tcp_ready() : ready_(false)
- {
- pthread_mutex_init(&mutex_, 0);
- pthread_cond_init(&cond_, 0);
- }
-
- ~tcp_ready()
- {
- pthread_mutex_destroy(&mutex_);
- pthread_cond_destroy(&cond_);
- }
-#endif
-};
-
-
-struct func_args {
- int argc;
- char** argv;
- int return_code;
- const char* file_ready;
- tcp_ready* signal_;
-
- func_args(int c = 0, char** v = 0) : argc(c), argv(v), file_ready(0) {}
-
- void SetSignal(tcp_ready* p) { signal_ = p; }
-};
-
-typedef THREAD_RETURN YASSL_API THREAD_FUNC(void*);
-
-void start_thread(THREAD_FUNC, func_args*, THREAD_TYPE*);
-void join_thread(THREAD_TYPE);
-
-// yaSSL
-const char* const yasslIP = "127.0.0.1";
-const unsigned short yasslPort = 11111;
-const unsigned short proxyPort = 12345;
-
-
-// client
-const char* const cert = "../certs/client-cert.pem";
-const char* const key = "../certs/client-key.pem";
-
-const char* const certSuite = "../../certs/client-cert.pem";
-const char* const keySuite = "../../certs/client-key.pem";
-
-const char* const certDebug = "../../../certs/client-cert.pem";
-const char* const keyDebug = "../../../certs/client-key.pem";
-
-
-// server
-const char* const svrCert = "../certs/server-cert.pem";
-const char* const svrKey = "../certs/server-key.pem";
-
-const char* const svrCert2 = "../../certs/server-cert.pem";
-const char* const svrKey2 = "../../certs/server-key.pem";
-
-const char* const svrCert3 = "../../../certs/server-cert.pem";
-const char* const svrKey3 = "../../../certs/server-key.pem";
-
-
-// server dsa
-const char* const dsaCert = "../certs/dsa-cert.pem";
-const char* const dsaKey = "../certs/dsa1024.der";
-
-const char* const dsaCert2 = "../../certs/dsa-cert.pem";
-const char* const dsaKey2 = "../../certs/dsa1024.der";
-
-const char* const dsaCert3 = "../../../certs/dsa-cert.pem";
-const char* const dsaKey3 = "../../../certs/dsa1024.der";
-
-
-// CA
-const char* const caCert = "../certs/ca-cert.pem";
-const char* const caCert2 = "../../certs/ca-cert.pem";
-const char* const caCert3 = "../../../certs/ca-cert.pem";
-
-
-using namespace yaSSL;
-
-
-inline void err_sys(const char* msg)
-{
- printf("yassl error: %s\n", msg);
- exit(EXIT_FAILURE);
-}
-
-
-extern "C" {
- static int PasswordCallBack(char*, int, int, void*);
-}
-
-
-static int PasswordCallBack(char* passwd, int sz, int rw, void* userdata)
-{
- strncpy(passwd, "yassl123", sz);
- return 8;
-}
-
-
-inline void store_ca(SSL_CTX* ctx)
-{
- // To allow testing from serveral dirs
- if (SSL_CTX_load_verify_locations(ctx, caCert, 0) != SSL_SUCCESS)
- if (SSL_CTX_load_verify_locations(ctx, caCert2, 0) != SSL_SUCCESS)
- if (SSL_CTX_load_verify_locations(ctx, caCert3, 0) != SSL_SUCCESS)
- err_sys("failed to use certificate: certs/cacert.pem");
-
- // load client CA for server verify
- if (SSL_CTX_load_verify_locations(ctx, cert, 0) != SSL_SUCCESS)
- if (SSL_CTX_load_verify_locations(ctx, certSuite, 0) != SSL_SUCCESS)
- if (SSL_CTX_load_verify_locations(ctx, certDebug,0) != SSL_SUCCESS)
- err_sys("failed to use certificate: certs/client-cert.pem");
-
- // DSA cert
- if (SSL_CTX_load_verify_locations(ctx, dsaCert, 0) != SSL_SUCCESS)
- if (SSL_CTX_load_verify_locations(ctx, dsaCert2, 0) != SSL_SUCCESS)
- if (SSL_CTX_load_verify_locations(ctx, dsaCert3, 0) != SSL_SUCCESS)
- err_sys("failed to use certificate: certs/dsa-cert.pem");
-
-}
-
-
-// client
-inline void set_certs(SSL_CTX* ctx)
-{
- store_ca(ctx);
- SSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);
-
- // To allow testing from serveral dirs
- if (SSL_CTX_use_certificate_file(ctx, cert, SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- if (SSL_CTX_use_certificate_file(ctx, certSuite, SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- if (SSL_CTX_use_certificate_file(ctx, certDebug, SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- err_sys("failed to use certificate: certs/client-cert.pem");
-
- // To allow testing from several dirs
- if (SSL_CTX_use_PrivateKey_file(ctx, key, SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- if (SSL_CTX_use_PrivateKey_file(ctx, keySuite, SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- if (SSL_CTX_use_PrivateKey_file(ctx,keyDebug,SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- err_sys("failed to use key file: certs/client-key.pem");
-}
-
-
-// server
-inline void set_serverCerts(SSL_CTX* ctx)
-{
- store_ca(ctx);
- SSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);
-
- // To allow testing from serveral dirs
- if (SSL_CTX_use_certificate_file(ctx, svrCert, SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- if (SSL_CTX_use_certificate_file(ctx, svrCert2, SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- if (SSL_CTX_use_certificate_file(ctx, svrCert3, SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- err_sys("failed to use certificate: certs/server-cert.pem");
-
- // To allow testing from several dirs
- if (SSL_CTX_use_PrivateKey_file(ctx, svrKey, SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- if (SSL_CTX_use_PrivateKey_file(ctx, svrKey2, SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- if (SSL_CTX_use_PrivateKey_file(ctx, svrKey3,SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- err_sys("failed to use key file: certs/server-key.pem");
-}
-
-
-// dsa server
-inline void set_dsaServerCerts(SSL_CTX* ctx)
-{
- store_ca(ctx);
-
- // To allow testing from serveral dirs
- if (SSL_CTX_use_certificate_file(ctx, dsaCert, SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- if (SSL_CTX_use_certificate_file(ctx, dsaCert2, SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- if (SSL_CTX_use_certificate_file(ctx, dsaCert3, SSL_FILETYPE_PEM)
- != SSL_SUCCESS)
- err_sys("failed to use certificate: certs/dsa-cert.pem");
-
- // To allow testing from several dirs
- if (SSL_CTX_use_PrivateKey_file(ctx, dsaKey, SSL_FILETYPE_ASN1)
- != SSL_SUCCESS)
- if (SSL_CTX_use_PrivateKey_file(ctx, dsaKey2, SSL_FILETYPE_ASN1)
- != SSL_SUCCESS)
- if (SSL_CTX_use_PrivateKey_file(ctx, dsaKey3,SSL_FILETYPE_ASN1)
- != SSL_SUCCESS)
- err_sys("failed to use key file: certs/dsa1024.der");
-}
-
-
-inline void set_args(int& argc, char**& argv, func_args& args)
-{
- argc = args.argc;
- argv = args.argv;
- args.return_code = -1; // error state
-}
-
-
-inline void set_file_ready(const char* name, func_args& args)
-{
- args.file_ready = name;
-}
-
-
-inline void tcp_set_nonblocking(SOCKET_T& sockfd)
-{
-#ifdef NON_BLOCKING
- #ifdef _WIN32
- unsigned long blocking = 1;
- int ret = ioctlsocket(sockfd, FIONBIO, &blocking);
- #else
- int flags = fcntl(sockfd, F_GETFL, 0);
- int ret = fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
- #endif
-#endif
-}
-
-
-inline void tcp_socket(SOCKET_T& sockfd, SOCKADDR_IN_T& addr)
-{
- sockfd = socket(AF_INET_V, SOCK_STREAM, 0);
- memset(&addr, 0, sizeof(addr));
-
-#ifdef TEST_IPV6
- addr.sin6_family = AF_INET_V;
- addr.sin6_port = htons(yasslPort);
- addr.sin6_addr = in6addr_loopback;
-
- /* // for external testing later
- addrinfo hints;
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = AF_INET_V;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_flags = AI_PASSIVE;
-
- getaddrinfo(yasslIP6, yasslPortStr, &hints, info);
- // then use info connect(sockfd, info->ai_addr, info->ai_addrlen)
-
- if (*info == 0)
- err_sys("getaddrinfo failed");
- */ // end external testing later
-#else
- addr.sin_family = AF_INET_V;
-#ifdef YASSL_PROXY_PORT
- addr.sin_port = htons(proxyPort);
-#else
- addr.sin_port = htons(yasslPort);
-#endif
- addr.sin_addr.s_addr = inet_addr(yasslIP);
-#endif
-
-}
-
-
-inline void tcp_close(SOCKET_T& sockfd)
-{
-#ifdef _WIN32
- closesocket(sockfd);
-#else
- close(sockfd);
-#endif
- sockfd = (SOCKET_T) -1;
-}
-
-
-inline void tcp_connect(SOCKET_T& sockfd)
-{
- SOCKADDR_IN_T addr;
- tcp_socket(sockfd, addr);
-
- if (connect(sockfd, (const sockaddr*)&addr, sizeof(addr)) != 0) {
- tcp_close(sockfd);
- err_sys("tcp connect failed");
- }
-}
-
-
-inline void tcp_listen(SOCKET_T& sockfd)
-{
- SOCKADDR_IN_T addr;
- tcp_socket(sockfd, addr);
-
-#ifndef _WIN32
- int on = 1;
- socklen_t len = sizeof(on);
- setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &on, len);
-#endif
-
- if (bind(sockfd, (const sockaddr*)&addr, sizeof(addr)) != 0) {
- tcp_close(sockfd);
- err_sys("tcp bind failed");
- }
- if (listen(sockfd, 3) != 0) {
- tcp_close(sockfd);
- err_sys("tcp listen failed");
- }
-}
-
-
-inline void create_ready_file(func_args& args)
-{
- FILE* f = fopen(args.file_ready, "w+");
-
- if (f) {
- fputs("ready", f);
- fclose(f);
- }
-}
-
-
-inline void tcp_accept(SOCKET_T& sockfd, SOCKET_T& clientfd, func_args& args)
-{
- tcp_listen(sockfd);
-
- SOCKADDR_IN_T client;
- socklen_t client_len = sizeof(client);
-
-#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER)
- // signal ready to tcp_accept
- tcp_ready& ready = *args.signal_;
- pthread_mutex_lock(&ready.mutex_);
- ready.ready_ = true;
- pthread_cond_signal(&ready.cond_);
- pthread_mutex_unlock(&ready.mutex_);
-#endif
-
- if (args.file_ready)
- create_ready_file(args);
-
- clientfd = accept(sockfd, (sockaddr*)&client, (ACCEPT_THIRD_T)&client_len);
-
- if (clientfd == (SOCKET_T) -1) {
- tcp_close(sockfd);
- err_sys("tcp accept failed");
- }
-
-#ifdef NON_BLOCKING
- tcp_set_nonblocking(clientfd);
-#endif
-}
-
-
-inline void showPeer(SSL* ssl)
-{
- X509* peer = SSL_get_peer_certificate(ssl);
- if (peer) {
- char* issuer = X509_NAME_oneline(X509_get_issuer_name(peer), 0, 0);
- char* subject = X509_NAME_oneline(X509_get_subject_name(peer), 0, 0);
-
- X509_NAME_ENTRY* se = NULL;
- ASN1_STRING* sd = NULL;
- char* subCN = NULL;
-
- X509_NAME* sub = X509_get_subject_name(peer);
- int lastpos = -1;
- if (sub)
- lastpos = X509_NAME_get_index_by_NID(sub, NID_commonName, lastpos);
- if (lastpos >= 0) {
- se = X509_NAME_get_entry(sub, lastpos);
- if (se)
- sd = X509_NAME_ENTRY_get_data(se);
- if (sd)
- subCN = (char*)ASN1_STRING_data(sd);
- }
-
- printf("peer's cert info:\n issuer : %s\n subject: %s\n"
- " subject cn: %s\n", issuer, subject, subCN);
-
- free(subject);
- free(issuer);
-
- }
- else
- printf("peer has no cert!\n");
-}
-
-
-
-inline DH* set_tmpDH(SSL_CTX* ctx)
-{
- static unsigned char dh1024_p[] =
- {
- 0xE6, 0x96, 0x9D, 0x3D, 0x49, 0x5B, 0xE3, 0x2C, 0x7C, 0xF1, 0x80, 0xC3,
- 0xBD, 0xD4, 0x79, 0x8E, 0x91, 0xB7, 0x81, 0x82, 0x51, 0xBB, 0x05, 0x5E,
- 0x2A, 0x20, 0x64, 0x90, 0x4A, 0x79, 0xA7, 0x70, 0xFA, 0x15, 0xA2, 0x59,
- 0xCB, 0xD5, 0x23, 0xA6, 0xA6, 0xEF, 0x09, 0xC4, 0x30, 0x48, 0xD5, 0xA2,
- 0x2F, 0x97, 0x1F, 0x3C, 0x20, 0x12, 0x9B, 0x48, 0x00, 0x0E, 0x6E, 0xDD,
- 0x06, 0x1C, 0xBC, 0x05, 0x3E, 0x37, 0x1D, 0x79, 0x4E, 0x53, 0x27, 0xDF,
- 0x61, 0x1E, 0xBB, 0xBE, 0x1B, 0xAC, 0x9B, 0x5C, 0x60, 0x44, 0xCF, 0x02,
- 0x3D, 0x76, 0xE0, 0x5E, 0xEA, 0x9B, 0xAD, 0x99, 0x1B, 0x13, 0xA6, 0x3C,
- 0x97, 0x4E, 0x9E, 0xF1, 0x83, 0x9E, 0xB5, 0xDB, 0x12, 0x51, 0x36, 0xF7,
- 0x26, 0x2E, 0x56, 0xA8, 0x87, 0x15, 0x38, 0xDF, 0xD8, 0x23, 0xC6, 0x50,
- 0x50, 0x85, 0xE2, 0x1F, 0x0D, 0xD5, 0xC8, 0x6B,
- };
-
- static unsigned char dh1024_g[] =
- {
- 0x02,
- };
-
- DH* dh;
- if ( (dh = DH_new()) ) {
- dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), 0);
- dh->g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), 0);
- }
- if (!dh->p || !dh->g) {
- DH_free(dh);
- dh = 0;
- }
- SSL_CTX_set_tmp_dh(ctx, dh);
- return dh;
-}
-
-
-inline int verify_callback(int preverify_ok, X509_STORE_CTX* ctx)
-{
- X509* err_cert = X509_STORE_CTX_get_current_cert(ctx);
- int err = X509_STORE_CTX_get_error(ctx);
- int depth = X509_STORE_CTX_get_error_depth(ctx);
-
- // test allow self signed
- if (err_cert && depth == 0 && err == TaoCrypt::SIG_OTHER_E)
- return 1;
-
- return 0;
-}
-
-
-#endif // yaSSL_TEST_HPP
-
diff --git a/extra/yassl/testsuite/testsuite.cpp b/extra/yassl/testsuite/testsuite.cpp
deleted file mode 100644
index 1792a2a3d9a..00000000000
--- a/extra/yassl/testsuite/testsuite.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
-
- This program 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; version 2 of the License.
-
- This program 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 this program; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- MA 02110-1335 USA.
-*/
-
-// testsuite.cpp
-
-#include "test.hpp"
-#include "md5.hpp"
-
-
-typedef unsigned char byte;
-
-void taocrypt_test(void*);
-void file_test(const char*, byte*);
-
-void client_test(void*);
-void echoclient_test(void*);
-
-THREAD_RETURN YASSL_API server_test(void*);
-THREAD_RETURN YASSL_API echoserver_test(void*);
-
-void wait_tcp_ready(func_args&);
-
-
-
-int main(int argc, char** argv)
-{
- func_args args(argc, argv);
- func_args server_args(argc, argv);
-
- // *** Crypto Test ***
- taocrypt_test(&args);
- assert(args.return_code == 0);
-
-
- // *** Simple yaSSL client server test ***
- tcp_ready ready;
- server_args.SetSignal(&ready);
-
- THREAD_TYPE serverThread;
- start_thread(server_test, &server_args, &serverThread);
- wait_tcp_ready(server_args);
-
- client_test(&args);
- assert(args.return_code == 0);
- join_thread(serverThread);
- assert(server_args.return_code == 0);
-
-
- // *** Echo input yaSSL client server test ***
- start_thread(echoserver_test, &server_args, &serverThread);
- wait_tcp_ready(server_args);
- func_args echo_args;
-
- // setup args
- const int numArgs = 3;
- echo_args.argc = numArgs;
- char* myArgv[numArgs];
-
- char argc0[32];
- char argc1[32];
- char argc2[32];
-
- myArgv[0] = argc0;
- myArgv[1] = argc1;
- myArgv[2] = argc2;
-
- echo_args.argv = myArgv;
-
- strcpy(echo_args.argv[0], "echoclient");
- strcpy(echo_args.argv[1], "input");
- strcpy(echo_args.argv[2], "output");
- remove("output");
-
- // make sure OK
- echoclient_test(&echo_args);
- assert(echo_args.return_code == 0);
-
-
- // *** Echo quit yaSSL client server test ***
- echo_args.argc = 2;
- strcpy(echo_args.argv[1], "quit");
-
- echoclient_test(&echo_args);
- assert(echo_args.return_code == 0);
- join_thread(serverThread);
- assert(server_args.return_code == 0);
-
-
- // input output compare
- byte input[TaoCrypt::MD5::DIGEST_SIZE];
- byte output[TaoCrypt::MD5::DIGEST_SIZE];
- file_test("input", input);
- file_test("output", output);
- assert(memcmp(input, output, sizeof(input)) == 0);
-
- printf("\nAll tests passed!\n");
- yaSSL_CleanUp();
-
- return 0;
-}
-
-
-
-void start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)
-{
-#ifndef _POSIX_THREADS
- *thread = (HANDLE)_beginthreadex(0, 0, fun, args, 0, 0);
-#else
- pthread_create(thread, 0, fun, args);
-#endif
-}
-
-
-void join_thread(THREAD_TYPE thread)
-{
-#ifndef _POSIX_THREADS
- int res = WaitForSingleObject(thread, INFINITE);
- assert(res == WAIT_OBJECT_0);
- res = CloseHandle(thread);
- assert(res);
-#else
- pthread_join(thread, 0);
-#endif
-}
-
-
-
-void wait_tcp_ready(func_args& args)
-{
-#ifdef _POSIX_THREADS
- pthread_mutex_lock(&args.signal_->mutex_);
-
- if (!args.signal_->ready_)
- pthread_cond_wait(&args.signal_->cond_, &args.signal_->mutex_);
- args.signal_->ready_ = false; // reset
-
- pthread_mutex_unlock(&args.signal_->mutex_);
-#endif
-}
-
-
-int test_openSSL_des()
-{
- /* test des encrypt/decrypt */
- char data[] = "this is my data ";
- int dataSz = (int)strlen(data);
- DES_key_schedule key[3];
- byte iv[8];
- EVP_BytesToKey(EVP_des_ede3_cbc(), EVP_md5(), NULL, (byte*)data, dataSz, 1,
- (byte*)key, iv);
-
- byte cipher[16];
- DES_ede3_cbc_encrypt((byte*)data, cipher, dataSz, &key[0], &key[1],
- &key[2], &iv, true);
- byte plain[16];
- DES_ede3_cbc_encrypt(cipher, plain, 16, &key[0], &key[1], &key[2],
- &iv, false);
- return 0;
-}
diff --git a/extra/yassl/testsuite/testsuite.dsp b/extra/yassl/testsuite/testsuite.dsp
deleted file mode 100644
index 2a7f5a77433..00000000000
--- a/extra/yassl/testsuite/testsuite.dsp
+++ /dev/null
@@ -1,127 +0,0 @@
-# Microsoft Developer Studio Project File - Name="testsuite" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=testsuite - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "testsuite.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "testsuite.mak" CFG="testsuite - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "testsuite - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "testsuite - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "testsuite - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MT /W3 /O2 /I "../taocrypt/include" /I "../include" /I "../taocrypt/mySTL" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "NO_MAIN_DRIVER" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.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 /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"LIBC"
-# SUBTRACT LINK32 /nodefaultlib
-
-!ELSEIF "$(CFG)" == "testsuite - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I "../taocrypt/include" /I "../include" /I "../taocrypt/mySTL" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "NO_MAIN_DRIVER" /FR /YX /FD /GZ /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.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 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"LIBCD" /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "testsuite - Win32 Release"
-# Name "testsuite - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=..\examples\client\client.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\examples\echoclient\echoclient.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\examples\echoserver\echoserver.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\examples\server\server.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=..\taocrypt\test\test.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\testsuite.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\test.hpp
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project