name change for client.c

This commit is contained in:
lchristina26 2015-01-05 14:48:43 -07:00
parent 37deb65371
commit 3cbed90cb9

View File

@ -2,14 +2,14 @@
* *
* Copyright (C) 2006-2014 wolfSSL Inc. * Copyright (C) 2006-2014 wolfSSL Inc.
* *
* This file is part of CyaSSL. * This file is part of wolfSSL.
* *
* CyaSSL is free software; you can redistribute it and/or modify * wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* CyaSSL is distributed in the hope that it will be useful, * wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
@ -23,13 +23,13 @@
#include <config.h> #include <config.h>
#endif #endif
#include <cyassl/ssl.h> /* name change portability layer */ #include <wolfssl/ssl.h> /* name change portability layer */
#if defined(CYASSL_MDK_ARM) #if defined(WOLFSSL_MDK_ARM)
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#if defined(CYASSL_MDK5) #if defined(WOLFSSL_MDK5)
#include "cmsis_os.h" #include "cmsis_os.h"
#include "rl_fs.h" #include "rl_fs.h"
#include "rl_net.h" #include "rl_net.h"
@ -37,43 +37,43 @@
#include "rtl.h" #include "rtl.h"
#endif #endif
#include "cyassl_MDK_ARM.h" #include "wolfssl_MDK_ARM.h"
#endif #endif
#include <cyassl/ctaocrypt/settings.h> #include <wolfssl/wolfcrypt/settings.h>
#if !defined(CYASSL_TRACK_MEMORY) && !defined(NO_MAIN_DRIVER) #if !defined(WOLFSSL_TRACK_MEMORY) && !defined(NO_MAIN_DRIVER)
/* in case memory tracker wants stats */ /* in case memory tracker wants stats */
#define CYASSL_TRACK_MEMORY #define WOLFSSL_TRACK_MEMORY
#endif #endif
#include <cyassl/ssl.h> #include <wolfssl/ssl.h>
#include <cyassl/test.h> #include <wolfssl/test.h>
#include "examples/client/client.h" #include "examples/client/client.h"
#ifdef CYASSL_CALLBACKS #ifdef WOLFSSL_CALLBACKS
int handShakeCB(HandShakeInfo*); int handShakeCB(HandShakeInfo*);
int timeoutCB(TimeoutInfo*); int timeoutCB(TimeoutInfo*);
Timeval timeout; Timeval timeout;
#endif #endif
#ifdef HAVE_SESSION_TICKET #ifdef HAVE_SESSION_TICKET
int sessionTicketCB(CYASSL*, const unsigned char*, int, void*); int sessionTicketCB(WOLFSSL*, const unsigned char*, int, void*);
#endif #endif
static void NonBlockingSSL_Connect(CYASSL* ssl) static void NonBlockingSSL_Connect(WOLFSSL* ssl)
{ {
#ifndef CYASSL_CALLBACKS #ifndef WOLFSSL_CALLBACKS
int ret = CyaSSL_connect(ssl); int ret = wolfSSL_connect(ssl);
#else #else
int ret = CyaSSL_connect_ex(ssl, handShakeCB, timeoutCB, timeout); int ret = wolfSSL_connect_ex(ssl, handShakeCB, timeoutCB, timeout);
#endif #endif
int error = CyaSSL_get_error(ssl, 0); int error = wolfSSL_get_error(ssl, 0);
SOCKET_T sockfd = (SOCKET_T)CyaSSL_get_fd(ssl); SOCKET_T sockfd = (SOCKET_T)wolfSSL_get_fd(ssl);
int select_ret; int select_ret;
while (ret != SSL_SUCCESS && (error == SSL_ERROR_WANT_READ || while (ret != SSL_SUCCESS && (error == SSL_ERROR_WANT_READ ||
@ -85,26 +85,26 @@ static void NonBlockingSSL_Connect(CYASSL* ssl)
else else
printf("... client would write block\n"); printf("... client would write block\n");
#ifdef CYASSL_DTLS #ifdef WOLFSSL_DTLS
currTimeout = CyaSSL_dtls_get_current_timeout(ssl); currTimeout = wolfSSL_dtls_get_current_timeout(ssl);
#endif #endif
select_ret = tcp_select(sockfd, currTimeout); select_ret = tcp_select(sockfd, currTimeout);
if ((select_ret == TEST_RECV_READY) || if ((select_ret == TEST_RECV_READY) ||
(select_ret == TEST_ERROR_READY)) { (select_ret == TEST_ERROR_READY)) {
#ifndef CYASSL_CALLBACKS #ifndef WOLFSSL_CALLBACKS
ret = CyaSSL_connect(ssl); ret = wolfSSL_connect(ssl);
#else #else
ret = CyaSSL_connect_ex(ssl,handShakeCB,timeoutCB,timeout); ret = wolfSSL_connect_ex(ssl,handShakeCB,timeoutCB,timeout);
#endif #endif
error = CyaSSL_get_error(ssl, 0); error = wolfSSL_get_error(ssl, 0);
} }
else if (select_ret == TEST_TIMEOUT && !CyaSSL_dtls(ssl)) { else if (select_ret == TEST_TIMEOUT && !wolfSSL_dtls(ssl)) {
error = SSL_ERROR_WANT_READ; error = SSL_ERROR_WANT_READ;
} }
#ifdef CYASSL_DTLS #ifdef WOLFSSL_DTLS
else if (select_ret == TEST_TIMEOUT && CyaSSL_dtls(ssl) && else if (select_ret == TEST_TIMEOUT && wolfSSL_dtls(ssl) &&
CyaSSL_dtls_got_timeout(ssl) >= 0) { wolfSSL_dtls_got_timeout(ssl) >= 0) {
error = SSL_ERROR_WANT_READ; error = SSL_ERROR_WANT_READ;
} }
#endif #endif
@ -119,8 +119,8 @@ static void NonBlockingSSL_Connect(CYASSL* ssl)
static void Usage(void) static void Usage(void)
{ {
printf("client " LIBCYASSL_VERSION_STRING printf("client " LIBWOLFSSL_VERSION_STRING
" NOTE: All files relative to CyaSSL home dir\n"); " NOTE: All files relative to wolfSSL home dir\n");
printf("-? Help, print this usage\n"); printf("-? Help, print this usage\n");
printf("-h <host> Host to connect to, default %s\n", yasslIP); printf("-h <host> Host to connect to, default %s\n", yasslIP);
printf("-p <num> Port to connect on, not 0, default %d\n", yasslPort); printf("-p <num> Port to connect on, not 0, default %d\n", yasslPort);
@ -132,7 +132,7 @@ static void Usage(void)
printf("-A <file> Certificate Authority file, default %s\n", caCert); printf("-A <file> Certificate Authority file, default %s\n", caCert);
printf("-b <num> Benchmark <num> connections and print stats\n"); printf("-b <num> Benchmark <num> connections and print stats\n");
printf("-s Use pre Shared keys\n"); printf("-s Use pre Shared keys\n");
printf("-t Track CyaSSL memory use\n"); printf("-t Track wolfSSL memory use\n");
printf("-d Disable peer checks\n"); printf("-d Disable peer checks\n");
printf("-D Override Date Errors example\n"); printf("-D Override Date Errors example\n");
printf("-g Send server HTTP GET\n"); printf("-g Send server HTTP GET\n");
@ -174,20 +174,20 @@ static void Usage(void)
#endif #endif
} }
THREAD_RETURN CYASSL_THREAD client_test(void* args) THREAD_RETURN WOLFSSL_THREAD client_test(void* args)
{ {
SOCKET_T sockfd = 0; SOCKET_T sockfd = 0;
CYASSL_METHOD* method = 0; WOLFSSL_METHOD* method = 0;
CYASSL_CTX* ctx = 0; WOLFSSL_CTX* ctx = 0;
CYASSL* ssl = 0; WOLFSSL* ssl = 0;
CYASSL* sslResume = 0; WOLFSSL* sslResume = 0;
CYASSL_SESSION* session = 0; WOLFSSL_SESSION* session = 0;
char resumeMsg[] = "resuming cyassl!"; char resumeMsg[] = "resuming wolfssl!";
int resumeSz = sizeof(resumeMsg); int resumeSz = sizeof(resumeMsg);
char msg[32] = "hello cyassl!"; /* GET may make bigger */ char msg[32] = "hello wolfssl!"; /* GET may make bigger */
char reply[80]; char reply[80];
int input; int input;
int msgSz = (int)strlen(msg); int msgSz = (int)strlen(msg);
@ -285,7 +285,7 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
break; break;
case 't' : case 't' :
#ifdef USE_CYASSL_MEMORY #ifdef USE_WOLFSSL_MEMORY
trackMemory = 1; trackMemory = 1;
#endif #endif
break; break;
@ -381,8 +381,8 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
break; break;
case 'z' : case 'z' :
#ifndef CYASSL_LEANPSK #ifndef WOLFSSL_LEANPSK
CyaSSL_GetObjectSize(); wolfSSL_GetObjectSize();
#endif #endif
break; break;
@ -395,8 +395,8 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
case 'L' : case 'L' :
#ifdef HAVE_MAX_FRAGMENT #ifdef HAVE_MAX_FRAGMENT
maxFragment = atoi(myoptarg); maxFragment = atoi(myoptarg);
if (maxFragment < CYASSL_MFL_2_9 || if (maxFragment < WOLFSSL_MFL_2_9 ||
maxFragment > CYASSL_MFL_2_13) { maxFragment > WOLFSSL_MFL_2_13) {
Usage(); Usage();
exit(MY_EX_USAGE); exit(MY_EX_USAGE);
} }
@ -452,7 +452,7 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
} }
} }
#ifdef USE_CYASSL_MEMORY #ifdef USE_WOLFSSL_MEMORY
if (trackMemory) if (trackMemory)
InitMemoryTracker(); InitMemoryTracker();
#endif #endif
@ -460,17 +460,17 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
switch (version) { switch (version) {
#ifndef NO_OLD_TLS #ifndef NO_OLD_TLS
case 0: case 0:
method = CyaSSLv3_client_method(); method = wolfSSLv3_client_method();
break; break;
#ifndef NO_TLS #ifndef NO_TLS
case 1: case 1:
method = CyaTLSv1_client_method(); method = wolfTLSv1_client_method();
break; break;
case 2: case 2:
method = CyaTLSv1_1_client_method(); method = wolfTLSv1_1_client_method();
break; break;
#endif /* NO_TLS */ #endif /* NO_TLS */
@ -478,17 +478,17 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
#ifndef NO_TLS #ifndef NO_TLS
case 3: case 3:
method = CyaTLSv1_2_client_method(); method = wolfTLSv1_2_client_method();
break; break;
#endif #endif
#ifdef CYASSL_DTLS #ifdef WOLFSSL_DTLS
case -1: case -1:
method = CyaDTLSv1_client_method(); method = wolfDTLSv1_client_method();
break; break;
case -2: case -2:
method = CyaDTLSv1_2_client_method(); method = wolfDTLSv1_2_client_method();
break; break;
#endif #endif
@ -500,15 +500,15 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
if (method == NULL) if (method == NULL)
err_sys("unable to get method"); err_sys("unable to get method");
ctx = CyaSSL_CTX_new(method); ctx = wolfSSL_CTX_new(method);
if (ctx == NULL) if (ctx == NULL)
err_sys("unable to get ctx"); err_sys("unable to get ctx");
if (cipherList) if (cipherList)
if (CyaSSL_CTX_set_cipher_list(ctx, cipherList) != SSL_SUCCESS) if (wolfSSL_CTX_set_cipher_list(ctx, cipherList) != SSL_SUCCESS)
err_sys("client can't set cipher list 1"); err_sys("client can't set cipher list 1");
#ifdef CYASSL_LEANPSK #ifdef WOLFSSL_LEANPSK
usePsk = 1; usePsk = 1;
#endif #endif
@ -517,11 +517,11 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
#endif #endif
if (fewerPackets) if (fewerPackets)
CyaSSL_CTX_set_group_messages(ctx); wolfSSL_CTX_set_group_messages(ctx);
if (usePsk) { if (usePsk) {
#ifndef NO_PSK #ifndef NO_PSK
CyaSSL_CTX_set_psk_client_callback(ctx, my_psk_client_cb); wolfSSL_CTX_set_psk_client_callback(ctx, my_psk_client_cb);
if (cipherList == NULL) { if (cipherList == NULL) {
const char *defaultCipherList; const char *defaultCipherList;
#ifdef HAVE_NULL_CIPHER #ifdef HAVE_NULL_CIPHER
@ -529,7 +529,7 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
#else #else
defaultCipherList = "PSK-AES128-CBC-SHA256"; defaultCipherList = "PSK-AES128-CBC-SHA256";
#endif #endif
if (CyaSSL_CTX_set_cipher_list(ctx,defaultCipherList) !=SSL_SUCCESS) if (wolfSSL_CTX_set_cipher_list(ctx,defaultCipherList) !=SSL_SUCCESS)
err_sys("client can't set cipher list 2"); err_sys("client can't set cipher list 2");
} }
#endif #endif
@ -539,8 +539,8 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
if (useAnon) { if (useAnon) {
#ifdef HAVE_ANON #ifdef HAVE_ANON
if (cipherList == NULL) { if (cipherList == NULL) {
CyaSSL_CTX_allow_anon_cipher(ctx); wolfSSL_CTX_allow_anon_cipher(ctx);
if (CyaSSL_CTX_set_cipher_list(ctx,"ADH-AES128-SHA") != SSL_SUCCESS) if (wolfSSL_CTX_set_cipher_list(ctx,"ADH-AES128-SHA") != SSL_SUCCESS)
err_sys("client can't set cipher list 4"); err_sys("client can't set cipher list 4");
} }
#endif #endif
@ -548,13 +548,13 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
} }
#if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) #if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)
CyaSSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack); wolfSSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);
#endif #endif
#if defined(CYASSL_SNIFFER) && !defined(HAVE_NTRU) && !defined(HAVE_ECC) #if defined(WOLFSSL_SNIFFER) && !defined(HAVE_NTRU) && !defined(HAVE_ECC)
if (cipherList == NULL) { if (cipherList == NULL) {
/* don't use EDH, can't sniff tmp keys */ /* don't use EDH, can't sniff tmp keys */
if (CyaSSL_CTX_set_cipher_list(ctx, "AES256-SHA256") != SSL_SUCCESS) { if (wolfSSL_CTX_set_cipher_list(ctx, "AES256-SHA256") != SSL_SUCCESS) {
err_sys("client can't set cipher list 3"); err_sys("client can't set cipher list 3");
} }
} }
@ -563,68 +563,68 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
#ifdef HAVE_OCSP #ifdef HAVE_OCSP
if (useOcsp) { if (useOcsp) {
if (ocspUrl != NULL) { if (ocspUrl != NULL) {
CyaSSL_CTX_SetOCSP_OverrideURL(ctx, ocspUrl); wolfSSL_CTX_SetOCSP_OverrideURL(ctx, ocspUrl);
CyaSSL_CTX_EnableOCSP(ctx, CYASSL_OCSP_NO_NONCE wolfSSL_CTX_EnableOCSP(ctx, WOLFSSL_OCSP_NO_NONCE
| CYASSL_OCSP_URL_OVERRIDE); | WOLFSSL_OCSP_URL_OVERRIDE);
} }
else else
CyaSSL_CTX_EnableOCSP(ctx, CYASSL_OCSP_NO_NONCE); wolfSSL_CTX_EnableOCSP(ctx, WOLFSSL_OCSP_NO_NONCE);
} }
#endif #endif
#ifdef USER_CA_CB #ifdef USER_CA_CB
CyaSSL_CTX_SetCACb(ctx, CaCb); wolfSSL_CTX_SetCACb(ctx, CaCb);
#endif #endif
#ifdef VERIFY_CALLBACK #ifdef VERIFY_CALLBACK
CyaSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, myVerify); wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, myVerify);
#endif #endif
#if !defined(NO_FILESYSTEM) && !defined(NO_CERTS) #if !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
if (useClientCert){ if (useClientCert){
if (CyaSSL_CTX_use_certificate_chain_file(ctx, ourCert) != SSL_SUCCESS) if (wolfSSL_CTX_use_certificate_chain_file(ctx, ourCert) != SSL_SUCCESS)
err_sys("can't load client cert file, check file and run from" err_sys("can't load client cert file, check file and run from"
" CyaSSL home dir"); " wolfSSL home dir");
if (CyaSSL_CTX_use_PrivateKey_file(ctx, ourKey, SSL_FILETYPE_PEM) if (wolfSSL_CTX_use_PrivateKey_file(ctx, ourKey, SSL_FILETYPE_PEM)
!= SSL_SUCCESS) != SSL_SUCCESS)
err_sys("can't load client private key file, check file and run " err_sys("can't load client private key file, check file and run "
"from CyaSSL home dir"); "from wolfSSL home dir");
} }
if (!usePsk && !useAnon) { if (!usePsk && !useAnon) {
if (CyaSSL_CTX_load_verify_locations(ctx, verifyCert, 0) != SSL_SUCCESS) if (wolfSSL_CTX_load_verify_locations(ctx, verifyCert, 0) != SSL_SUCCESS)
err_sys("can't load ca file, Please run from CyaSSL home dir"); err_sys("can't load ca file, Please run from wolfSSL home dir");
} }
#endif #endif
#if !defined(NO_CERTS) #if !defined(NO_CERTS)
if (!usePsk && !useAnon && doPeerCheck == 0) if (!usePsk && !useAnon && doPeerCheck == 0)
CyaSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0); wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0);
if (!usePsk && !useAnon && overrideDateErrors == 1) if (!usePsk && !useAnon && overrideDateErrors == 1)
CyaSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, myDateCb); wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, myDateCb);
#endif #endif
#ifdef HAVE_CAVIUM #ifdef HAVE_CAVIUM
CyaSSL_CTX_UseCavium(ctx, CAVIUM_DEV_ID); wolfSSL_CTX_UseCavium(ctx, CAVIUM_DEV_ID);
#endif #endif
#ifdef HAVE_SNI #ifdef HAVE_SNI
if (sniHostName) if (sniHostName)
if (CyaSSL_CTX_UseSNI(ctx, 0, sniHostName, XSTRLEN(sniHostName)) if (wolfSSL_CTX_UseSNI(ctx, 0, sniHostName, XSTRLEN(sniHostName))
!= SSL_SUCCESS) != SSL_SUCCESS)
err_sys("UseSNI failed"); err_sys("UseSNI failed");
#endif #endif
#ifdef HAVE_MAX_FRAGMENT #ifdef HAVE_MAX_FRAGMENT
if (maxFragment) if (maxFragment)
if (CyaSSL_CTX_UseMaxFragment(ctx, maxFragment) != SSL_SUCCESS) if (wolfSSL_CTX_UseMaxFragment(ctx, maxFragment) != SSL_SUCCESS)
err_sys("UseMaxFragment failed"); err_sys("UseMaxFragment failed");
#endif #endif
#ifdef HAVE_TRUNCATED_HMAC #ifdef HAVE_TRUNCATED_HMAC
if (truncatedHMAC) if (truncatedHMAC)
if (CyaSSL_CTX_UseTruncatedHMAC(ctx) != SSL_SUCCESS) if (wolfSSL_CTX_UseTruncatedHMAC(ctx) != SSL_SUCCESS)
err_sys("UseTruncatedHMAC failed"); err_sys("UseTruncatedHMAC failed");
#endif #endif
#ifdef HAVE_SESSION_TICKET #ifdef HAVE_SESSION_TICKET
if (CyaSSL_CTX_UseSessionTicket(ctx) != SSL_SUCCESS) if (wolfSSL_CTX_UseSessionTicket(ctx) != SSL_SUCCESS)
err_sys("UseSessionTicket failed"); err_sys("UseSessionTicket failed");
#endif #endif
@ -638,40 +638,40 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
for (i = 0; i < times; i++) { for (i = 0; i < times; i++) {
tcp_connect(&sockfd, host, port, doDTLS); tcp_connect(&sockfd, host, port, doDTLS);
ssl = CyaSSL_new(ctx); ssl = wolfSSL_new(ctx);
CyaSSL_set_fd(ssl, sockfd); wolfSSL_set_fd(ssl, sockfd);
if (CyaSSL_connect(ssl) != SSL_SUCCESS) if (wolfSSL_connect(ssl) != SSL_SUCCESS)
err_sys("SSL_connect failed"); err_sys("SSL_connect failed");
CyaSSL_shutdown(ssl); wolfSSL_shutdown(ssl);
CyaSSL_free(ssl); wolfSSL_free(ssl);
CloseSocket(sockfd); CloseSocket(sockfd);
} }
avg = current_time() - start; avg = current_time() - start;
avg /= times; avg /= times;
avg *= 1000; /* milliseconds */ avg *= 1000; /* milliseconds */
printf("CyaSSL_connect avg took: %8.3f milliseconds\n", avg); printf("wolfSSL_connect avg took: %8.3f milliseconds\n", avg);
CyaSSL_CTX_free(ctx); wolfSSL_CTX_free(ctx);
((func_args*)args)->return_code = 0; ((func_args*)args)->return_code = 0;
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
#if defined(CYASSL_MDK_ARM) #if defined(WOLFSSL_MDK_ARM)
CyaSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0); wolfSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0);
#endif #endif
ssl = CyaSSL_new(ctx); ssl = wolfSSL_new(ctx);
if (ssl == NULL) if (ssl == NULL)
err_sys("unable to get SSL object"); err_sys("unable to get SSL object");
#ifdef HAVE_SESSION_TICKET #ifdef HAVE_SESSION_TICKET
CyaSSL_set_SessionTicket_cb(ssl, sessionTicketCB, (void*)"initial session"); wolfSSL_set_SessionTicket_cb(ssl, sessionTicketCB, (void*)"initial session");
#endif #endif
if (doDTLS) { if (doDTLS) {
SOCKADDR_IN_T addr; SOCKADDR_IN_T addr;
build_addr(&addr, host, port, 1); build_addr(&addr, host, port, 1);
CyaSSL_dtls_set_peer(ssl, &addr, sizeof(addr)); wolfSSL_dtls_set_peer(ssl, &addr, sizeof(addr));
tcp_socket(&sockfd, 1); tcp_socket(&sockfd, 1);
} }
else { else {
@ -681,23 +681,23 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
#ifdef HAVE_POLY1305 #ifdef HAVE_POLY1305
/* use old poly to connect with google server */ /* use old poly to connect with google server */
if (!XSTRNCMP(domain, "www.google.com", 14)) { if (!XSTRNCMP(domain, "www.google.com", 14)) {
if (CyaSSL_use_old_poly(ssl, 1) != 0) if (wolfSSL_use_old_poly(ssl, 1) != 0)
err_sys("unable to set to old poly"); err_sys("unable to set to old poly");
} }
#endif #endif
CyaSSL_set_fd(ssl, sockfd); wolfSSL_set_fd(ssl, sockfd);
#ifdef HAVE_CRL #ifdef HAVE_CRL
if (CyaSSL_EnableCRL(ssl, CYASSL_CRL_CHECKALL) != SSL_SUCCESS) if (wolfSSL_EnableCRL(ssl, WOLFSSL_CRL_CHECKALL) != SSL_SUCCESS)
err_sys("can't enable crl check"); err_sys("can't enable crl check");
if (CyaSSL_LoadCRL(ssl, crlPemDir, SSL_FILETYPE_PEM, 0) != SSL_SUCCESS) if (wolfSSL_LoadCRL(ssl, crlPemDir, SSL_FILETYPE_PEM, 0) != SSL_SUCCESS)
err_sys("can't load crl, check crlfile and date validity"); err_sys("can't load crl, check crlfile and date validity");
if (CyaSSL_SetCRL_Cb(ssl, CRL_CallBack) != SSL_SUCCESS) if (wolfSSL_SetCRL_Cb(ssl, CRL_CallBack) != SSL_SUCCESS)
err_sys("can't set crl callback"); err_sys("can't set crl callback");
#endif #endif
#ifdef HAVE_SECURE_RENEGOTIATION #ifdef HAVE_SECURE_RENEGOTIATION
if (scr) { if (scr) {
if (CyaSSL_UseSecureRenegotiation(ssl) != SSL_SUCCESS) if (wolfSSL_UseSecureRenegotiation(ssl) != SSL_SUCCESS)
err_sys("can't enable secure renegotiation"); err_sys("can't enable secure renegotiation");
} }
#endif #endif
@ -710,19 +710,19 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
SetupPkCallbacks(ctx, ssl); SetupPkCallbacks(ctx, ssl);
#endif #endif
if (matchName && doPeerCheck) if (matchName && doPeerCheck)
CyaSSL_check_domain_name(ssl, domain); wolfSSL_check_domain_name(ssl, domain);
#ifndef CYASSL_CALLBACKS #ifndef WOLFSSL_CALLBACKS
if (nonBlocking) { if (nonBlocking) {
CyaSSL_set_using_nonblock(ssl, 1); wolfSSL_set_using_nonblock(ssl, 1);
tcp_set_nonblocking(&sockfd); tcp_set_nonblocking(&sockfd);
NonBlockingSSL_Connect(ssl); NonBlockingSSL_Connect(ssl);
} }
else if (CyaSSL_connect(ssl) != SSL_SUCCESS) { else if (wolfSSL_connect(ssl) != SSL_SUCCESS) {
/* see note at top of README */ /* see note at top of README */
int err = CyaSSL_get_error(ssl, 0); int err = wolfSSL_get_error(ssl, 0);
char buffer[CYASSL_MAX_ERROR_SZ]; char buffer[WOLFSSL_MAX_ERROR_SZ];
printf("err = %d, %s\n", err, printf("err = %d, %s\n", err,
CyaSSL_ERR_error_string(err, buffer)); wolfSSL_ERR_error_string(err, buffer));
err_sys("SSL_connect failed"); err_sys("SSL_connect failed");
/* if you're getting an error here */ /* if you're getting an error here */
} }
@ -741,17 +741,17 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
} else { } else {
#ifndef NO_SESSION_CACHE #ifndef NO_SESSION_CACHE
if (resumeSession) { if (resumeSession) {
session = CyaSSL_get_session(ssl); session = wolfSSL_get_session(ssl);
CyaSSL_set_session(ssl, session); wolfSSL_set_session(ssl, session);
resumeSession = 0; /* only resume once */ resumeSession = 0; /* only resume once */
} }
#endif #endif
if (CyaSSL_Rehandshake(ssl) != SSL_SUCCESS) { if (wolfSSL_Rehandshake(ssl) != SSL_SUCCESS) {
int err = CyaSSL_get_error(ssl, 0); int err = wolfSSL_get_error(ssl, 0);
char buffer[CYASSL_MAX_ERROR_SZ]; char buffer[WOLFSSL_MAX_ERROR_SZ];
printf("err = %d, %s\n", err, printf("err = %d, %s\n", err,
CyaSSL_ERR_error_string(err, buffer)); wolfSSL_ERR_error_string(err, buffer));
err_sys("CyaSSL_Rehandshake failed"); err_sys("wolfSSL_Rehandshake failed");
} }
} }
} }
@ -763,17 +763,17 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
strncpy(msg, "GET /index.html HTTP/1.0\r\n\r\n", msgSz); strncpy(msg, "GET /index.html HTTP/1.0\r\n\r\n", msgSz);
msg[msgSz] = '\0'; msg[msgSz] = '\0';
} }
if (CyaSSL_write(ssl, msg, msgSz) != msgSz) if (wolfSSL_write(ssl, msg, msgSz) != msgSz)
err_sys("SSL_write failed"); err_sys("SSL_write failed");
input = CyaSSL_read(ssl, reply, sizeof(reply)-1); input = wolfSSL_read(ssl, reply, sizeof(reply)-1);
if (input > 0) { if (input > 0) {
reply[input] = 0; reply[input] = 0;
printf("Server response: %s\n", reply); printf("Server response: %s\n", reply);
if (sendGET) { /* get html */ if (sendGET) { /* get html */
while (1) { while (1) {
input = CyaSSL_read(ssl, reply, sizeof(reply)-1); input = wolfSSL_read(ssl, reply, sizeof(reply)-1);
if (input > 0) { if (input > 0) {
reply[input] = 0; reply[input] = 0;
printf("%s\n", reply); printf("%s\n", reply);
@ -784,9 +784,9 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
} }
} }
else if (input < 0) { else if (input < 0) {
int readErr = CyaSSL_get_error(ssl, 0); int readErr = wolfSSL_get_error(ssl, 0);
if (readErr != SSL_ERROR_WANT_READ) if (readErr != SSL_ERROR_WANT_READ)
err_sys("CyaSSL_read failed"); err_sys("wolfSSL_read failed");
} }
#ifndef NO_SESSION_CACHE #ifndef NO_SESSION_CACHE
@ -795,20 +795,20 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
strncpy(msg, "break", 6); strncpy(msg, "break", 6);
msgSz = (int)strlen(msg); msgSz = (int)strlen(msg);
/* try to send session close */ /* try to send session close */
CyaSSL_write(ssl, msg, msgSz); wolfSSL_write(ssl, msg, msgSz);
} }
session = CyaSSL_get_session(ssl); session = wolfSSL_get_session(ssl);
sslResume = CyaSSL_new(ctx); sslResume = wolfSSL_new(ctx);
} }
#endif #endif
if (doDTLS == 0) /* don't send alert after "break" command */ if (doDTLS == 0) /* don't send alert after "break" command */
CyaSSL_shutdown(ssl); /* echoserver will interpret as new conn */ wolfSSL_shutdown(ssl); /* echoserver will interpret as new conn */
#ifdef ATOMIC_USER #ifdef ATOMIC_USER
if (atomicUser) if (atomicUser)
FreeAtomicUser(ssl); FreeAtomicUser(ssl);
#endif #endif
CyaSSL_free(ssl); wolfSSL_free(ssl);
CloseSocket(sockfd); CloseSocket(sockfd);
#ifndef NO_SESSION_CACHE #ifndef NO_SESSION_CACHE
@ -817,33 +817,33 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
SOCKADDR_IN_T addr; SOCKADDR_IN_T addr;
#ifdef USE_WINDOWS_API #ifdef USE_WINDOWS_API
Sleep(500); Sleep(500);
#elif defined(CYASSL_TIRTOS) #elif defined(WOLFSSL_TIRTOS)
Task_sleep(1); Task_sleep(1);
#else #else
sleep(1); sleep(1);
#endif #endif
build_addr(&addr, host, port, 1); build_addr(&addr, host, port, 1);
CyaSSL_dtls_set_peer(sslResume, &addr, sizeof(addr)); wolfSSL_dtls_set_peer(sslResume, &addr, sizeof(addr));
tcp_socket(&sockfd, 1); tcp_socket(&sockfd, 1);
} }
else { else {
tcp_connect(&sockfd, host, port, 0); tcp_connect(&sockfd, host, port, 0);
} }
CyaSSL_set_fd(sslResume, sockfd); wolfSSL_set_fd(sslResume, sockfd);
CyaSSL_set_session(sslResume, session); wolfSSL_set_session(sslResume, session);
#ifdef HAVE_SESSION_TICKET #ifdef HAVE_SESSION_TICKET
CyaSSL_set_SessionTicket_cb(sslResume, sessionTicketCB, wolfSSL_set_SessionTicket_cb(sslResume, sessionTicketCB,
(void*)"resumed session"); (void*)"resumed session");
#endif #endif
showPeer(sslResume); showPeer(sslResume);
#ifndef CYASSL_CALLBACKS #ifndef WOLFSSL_CALLBACKS
if (nonBlocking) { if (nonBlocking) {
CyaSSL_set_using_nonblock(sslResume, 1); wolfSSL_set_using_nonblock(sslResume, 1);
tcp_set_nonblocking(&sockfd); tcp_set_nonblocking(&sockfd);
NonBlockingSSL_Connect(sslResume); NonBlockingSSL_Connect(sslResume);
} }
else if (CyaSSL_connect(sslResume) != SSL_SUCCESS) else if (wolfSSL_connect(sslResume) != SSL_SUCCESS)
err_sys("SSL resume failed"); err_sys("SSL resume failed");
#else #else
timeout.tv_sec = 2; timeout.tv_sec = 2;
@ -851,50 +851,50 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
NonBlockingSSL_Connect(ssl); /* will keep retrying on timeout */ NonBlockingSSL_Connect(ssl); /* will keep retrying on timeout */
#endif #endif
if (CyaSSL_session_reused(sslResume)) if (wolfSSL_session_reused(sslResume))
printf("reused session id\n"); printf("reused session id\n");
else else
printf("didn't reuse session id!!!\n"); printf("didn't reuse session id!!!\n");
if (CyaSSL_write(sslResume, resumeMsg, resumeSz) != resumeSz) if (wolfSSL_write(sslResume, resumeMsg, resumeSz) != resumeSz)
err_sys("SSL_write failed"); err_sys("SSL_write failed");
if (nonBlocking) { if (nonBlocking) {
/* give server a chance to bounce a message back to client */ /* give server a chance to bounce a message back to client */
#ifdef USE_WINDOWS_API #ifdef USE_WINDOWS_API
Sleep(500); Sleep(500);
#elif defined(CYASSL_TIRTOS) #elif defined(WOLFSSL_TIRTOS)
Task_sleep(1); Task_sleep(1);
#else #else
sleep(1); sleep(1);
#endif #endif
} }
input = CyaSSL_read(sslResume, reply, sizeof(reply)-1); input = wolfSSL_read(sslResume, reply, sizeof(reply)-1);
if (input > 0) { if (input > 0) {
reply[input] = 0; reply[input] = 0;
printf("Server resume response: %s\n", reply); printf("Server resume response: %s\n", reply);
} }
/* try to send session break */ /* try to send session break */
CyaSSL_write(sslResume, msg, msgSz); wolfSSL_write(sslResume, msg, msgSz);
CyaSSL_shutdown(sslResume); wolfSSL_shutdown(sslResume);
CyaSSL_free(sslResume); wolfSSL_free(sslResume);
CloseSocket(sockfd); CloseSocket(sockfd);
} }
#endif /* NO_SESSION_CACHE */ #endif /* NO_SESSION_CACHE */
CyaSSL_CTX_free(ctx); wolfSSL_CTX_free(ctx);
((func_args*)args)->return_code = 0; ((func_args*)args)->return_code = 0;
#ifdef USE_CYASSL_MEMORY #ifdef USE_WOLFSSL_MEMORY
if (trackMemory) if (trackMemory)
ShowMemoryTracker(); ShowMemoryTracker();
#endif /* USE_CYASSL_MEMORY */ #endif /* USE_WOLFSSL_MEMORY */
#if !defined(CYASSL_TIRTOS) #if !defined(WOLFSSL_TIRTOS)
return 0; return 0;
#endif #endif
} }
@ -918,9 +918,9 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
args.argc = argc; args.argc = argc;
args.argv = argv; args.argv = argv;
CyaSSL_Init(); wolfSSL_Init();
#if defined(DEBUG_CYASSL) && !defined(CYASSL_MDK_SHELL) && !defined(STACK_TRAP) #if defined(DEBUG_WOLFSSL) && !defined(WOLFSSL_MDK_SHELL) && !defined(STACK_TRAP)
CyaSSL_Debugging_ON(); wolfSSL_Debugging_ON();
#endif #endif
if (CurrentDir("client")) if (CurrentDir("client"))
ChangeDirBack(2); ChangeDirBack(2);
@ -932,7 +932,7 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
#else #else
client_test(&args); client_test(&args);
#endif #endif
CyaSSL_Cleanup(); wolfSSL_Cleanup();
#ifdef HAVE_CAVIUM #ifdef HAVE_CAVIUM
CspShutdown(CAVIUM_DEV_ID); CspShutdown(CAVIUM_DEV_ID);
@ -947,7 +947,7 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
#ifdef CYASSL_CALLBACKS #ifdef WOLFSSL_CALLBACKS
int handShakeCB(HandShakeInfo* info) int handShakeCB(HandShakeInfo* info)
{ {
@ -967,7 +967,7 @@ THREAD_RETURN CYASSL_THREAD client_test(void* args)
#ifdef HAVE_SESSION_TICKET #ifdef HAVE_SESSION_TICKET
int sessionTicketCB(CYASSL* ssl, int sessionTicketCB(WOLFSSL* ssl,
const unsigned char* ticket, int ticketSz, const unsigned char* ticket, int ticketSz,
void* ctx) void* ctx)
{ {