From 9eb339f9fd32b8e114863628e91407ac25f336a6 Mon Sep 17 00:00:00 2001 From: Andras Fekete Date: Tue, 1 Aug 2023 10:17:38 -0400 Subject: [PATCH] Remove cyassl from example code --- examples/echoclient/echoclient.c | 30 ++++----- examples/echoserver/echoserver.c | 104 +++++++++++++++---------------- 2 files changed, 67 insertions(+), 67 deletions(-) diff --git a/examples/echoclient/echoclient.c b/examples/echoclient/echoclient.c index c36fc45f5..0c6444700 100644 --- a/examples/echoclient/echoclient.c +++ b/examples/echoclient/echoclient.c @@ -24,14 +24,14 @@ #include #endif -#include +#include /* let's use cyassl layer AND cyassl openssl layer */ #undef TEST_OPENSSL_COEXIST /* can't use this option with this example */ -#include +#include /* Force enable the compatibility macros for this example */ #ifdef WOLFSSL_DTLS - #include + #include #endif #if defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET) @@ -43,12 +43,12 @@ #include "wolfssl_MDK_ARM.h" #endif -#include +#include #ifndef OPENSSL_EXTRA_X509_SMALL #define OPENSSL_EXTRA_X509_SMALL #endif -#include +#include #include @@ -134,7 +134,7 @@ void echoclient_test(void* args) #if defined(NO_MAIN_DRIVER) && !defined(USE_WINDOWS_API) && !defined(WOLFSSL_MDK_SHELL) port = ((func_args*)args)->signal->port; #else - port = yasslPort; + port = wolfSSLPort; #endif #if defined(WOLFSSL_DTLS) @@ -145,9 +145,9 @@ void echoclient_test(void* args) #endif #elif !defined(NO_TLS) #if defined(WOLFSSL_TLS13) && defined(WOLFSSL_SNIFFER) - method = CyaTLSv1_2_client_method(); + method = WolfTLSv1_2_client_method(); #else - method = CyaSSLv23_client_method(); + method = wolfSSLv23_client_method(); #endif #elif defined(WOLFSSL_ALLOW_SSLV3) method = SSLv3_client_method(); @@ -189,7 +189,7 @@ void echoclient_test(void* args) if (doPSK) { const char *defaultCipherList; - CyaSSL_CTX_set_psk_client_callback(ctx, my_psk_client_cb); + wolfSSL_CTX_set_psk_client_callback(ctx, my_psk_client_cb); #ifdef HAVE_NULL_CIPHER defaultCipherList = "PSK-NULL-SHA256"; #elif defined(HAVE_AESGCM) && !defined(NO_DH) @@ -211,7 +211,7 @@ void echoclient_test(void* args) #else defaultCipherList = "PSK-AES128-CBC-SHA256"; #endif - if (CyaSSL_CTX_set_cipher_list(ctx,defaultCipherList) !=WOLFSSL_SUCCESS) + if (wolfSSL_CTX_set_cipher_list(ctx,defaultCipherList) !=WOLFSSL_SUCCESS) err_sys("client can't set cipher list 2"); wolfSSL_CTX_set_psk_callback_ctx(ctx, (void*)defaultCipherList); } @@ -222,7 +222,7 @@ void echoclient_test(void* args) #endif #if defined(WOLFSSL_MDK_ARM) - CyaSSL_CTX_set_verify(ctx, WOLFSSL_VERIFY_NONE, 0); + wolfSSL_CTX_set_verify(ctx, WOLFSSL_VERIFY_NONE, 0); #endif #ifdef WOLFSSL_ASYNC_CRYPT @@ -234,7 +234,7 @@ void echoclient_test(void* args) #endif /* WOLFSSL_ASYNC_CRYPT */ ssl = SSL_new(ctx); - tcp_connect(&sockfd, yasslIP, port, doDTLS, 0, ssl); + tcp_connect(&sockfd, wolfSSLIP, port, doDTLS, 0, ssl); SSL_set_fd(ssl, sockfd); #if defined(USE_WINDOWS_API) && defined(WOLFSSL_DTLS) && defined(NO_MAIN_DRIVER) @@ -394,9 +394,9 @@ void echoclient_test(void* args) args.argv = argv; args.return_code = 0; - CyaSSL_Init(); + wolfSSL_Init(); #if defined(DEBUG_WOLFSSL) && !defined(WOLFSSL_MDK_SHELL) - CyaSSL_Debugging_ON(); + wolfSSL_Debugging_ON(); #endif #ifndef WOLFSSL_TIRTOS ChangeToWolfRoot(); @@ -405,7 +405,7 @@ void echoclient_test(void* args) echoclient_test(&args); #endif - CyaSSL_Cleanup(); + wolfSSL_Cleanup(); #ifdef HAVE_WNR if (wc_FreeNetRandom() < 0) diff --git a/examples/echoserver/echoserver.c b/examples/echoserver/echoserver.c index 79ac1d20a..41885557f 100644 --- a/examples/echoserver/echoserver.c +++ b/examples/echoserver/echoserver.c @@ -24,10 +24,10 @@ #include #endif -#include /* name change portability layer */ -#include +#include /* name change portability layer */ +#include #ifdef HAVE_ECC - #include /* ecc_fp_free */ + #include /* ecc_fp_free */ #endif #if defined(WOLFSSL_MDK_ARM) || defined(WOLFSSL_KEIL_TCP_NET) @@ -39,8 +39,8 @@ #include "wolfssl_MDK_ARM.h" #endif -#include -#include +#include +#include #ifndef NO_MAIN_DRIVER #define ECHO_OUT @@ -151,24 +151,24 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args) #ifdef WOLFSSL_DTLS13 method = wolfDTLSv1_3_server_method(); #elif !defined(WOLFSSL_NO_TLS12) - method = CyaDTLSv1_2_server_method(); + method = wolfDTLSv1_2_server_method(); #endif #elif !defined(NO_TLS) #if defined(WOLFSSL_TLS13) && defined(WOLFSSL_SNIFFER) - method = CyaTLSv1_2_server_method(); + method = WolfTLSv1_2_server_method(); #else - method = CyaSSLv23_server_method(); + method = wolfSSLv23_server_method(); #endif #elif defined(WOLFSSL_ALLOW_SSLV3) - method = CyaSSLv3_server_method(); + method = wolfSSLv3_server_method(); #else #error "no valid server method built in" #endif - ctx = CyaSSL_CTX_new(method); - /* CyaSSL_CTX_set_session_cache_mode(ctx, WOLFSSL_SESS_CACHE_OFF); */ + ctx = wolfSSL_CTX_new(method); + /* wolfSSL_CTX_set_session_cache_mode(ctx, WOLFSSL_SESS_CACHE_OFF); */ #ifdef WOLFSSL_ENCRYPTED_KEYS - CyaSSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack); + wolfSSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack); #endif #ifdef HAVE_TEST_SESSION_TICKET @@ -183,34 +183,34 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args) if (doPSK == 0) { #if defined(HAVE_ECC) && !defined(WOLFSSL_SNIFFER) /* ecc */ - if (CyaSSL_CTX_use_certificate_file(ctx, eccCertFile, WOLFSSL_FILETYPE_PEM) + if (wolfSSL_CTX_use_certificate_file(ctx, eccCertFile, WOLFSSL_FILETYPE_PEM) != WOLFSSL_SUCCESS) err_sys("can't load server cert file, " "Please run from wolfSSL home dir"); - if (CyaSSL_CTX_use_PrivateKey_file(ctx, eccKeyFile, WOLFSSL_FILETYPE_PEM) + if (wolfSSL_CTX_use_PrivateKey_file(ctx, eccKeyFile, WOLFSSL_FILETYPE_PEM) != WOLFSSL_SUCCESS) err_sys("can't load server key file, " "Please run from wolfSSL home dir"); #elif defined(HAVE_ED25519) && !defined(WOLFSSL_SNIFFER) /* ed25519 */ - if (CyaSSL_CTX_use_certificate_chain_file(ctx, edCertFile) + if (wolfSSL_CTX_use_certificate_chain_file(ctx, edCertFile) != WOLFSSL_SUCCESS) err_sys("can't load server cert file, " "Please run from wolfSSL home dir"); - if (CyaSSL_CTX_use_PrivateKey_file(ctx, edKeyFile, WOLFSSL_FILETYPE_PEM) + if (wolfSSL_CTX_use_PrivateKey_file(ctx, edKeyFile, WOLFSSL_FILETYPE_PEM) != WOLFSSL_SUCCESS) err_sys("can't load server key file, " "Please run from wolfSSL home dir"); #elif defined(HAVE_ED448) && !defined(WOLFSSL_SNIFFER) /* ed448 */ - if (CyaSSL_CTX_use_certificate_chain_file(ctx, ed448CertFile) + if (wolfSSL_CTX_use_certificate_chain_file(ctx, ed448CertFile) != WOLFSSL_SUCCESS) err_sys("can't load server cert file, " "Please run from wolfSSL home dir"); - if (CyaSSL_CTX_use_PrivateKey_file(ctx, ed448KeyFile, + if (wolfSSL_CTX_use_PrivateKey_file(ctx, ed448KeyFile, WOLFSSL_FILETYPE_PEM) != WOLFSSL_SUCCESS) err_sys("can't load server key file, " "Please run from wolfSSL home dir"); @@ -218,12 +218,12 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args) /* do nothing, just don't load cert files */ #else /* normal */ - if (CyaSSL_CTX_use_certificate_file(ctx, svrCertFile, WOLFSSL_FILETYPE_PEM) + if (wolfSSL_CTX_use_certificate_file(ctx, svrCertFile, WOLFSSL_FILETYPE_PEM) != WOLFSSL_SUCCESS) err_sys("can't load server cert file, " "Please run from wolfSSL home dir"); - if (CyaSSL_CTX_use_PrivateKey_file(ctx, svrKeyFile, WOLFSSL_FILETYPE_PEM) + if (wolfSSL_CTX_use_PrivateKey_file(ctx, svrKeyFile, WOLFSSL_FILETYPE_PEM) != WOLFSSL_SUCCESS) err_sys("can't load server key file, " "Please run from wolfSSL home dir"); @@ -231,12 +231,12 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args) } /* doPSK */ #elif !defined(NO_CERTS) if (!doPSK) { - if (CyaSSL_CTX_use_certificate_buffer(ctx, server_cert_der_2048, + if (wolfSSL_CTX_use_certificate_buffer(ctx, server_cert_der_2048, sizeof_server_cert_der_2048, WOLFSSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS) err_sys("can't load server cert buffer"); - if (CyaSSL_CTX_use_PrivateKey_buffer(ctx, server_key_der_2048, + if (wolfSSL_CTX_use_PrivateKey_buffer(ctx, server_key_der_2048, sizeof_server_key_der_2048, WOLFSSL_FILETYPE_ASN1) != WOLFSSL_SUCCESS) err_sys("can't load server key buffer"); @@ -247,7 +247,7 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args) /* Only set if not running testsuite */ if (XSTRSTR(argv[0], "testsuite") == NULL) { /* don't use EDH, can't sniff tmp keys */ - CyaSSL_CTX_set_cipher_list(ctx, "AES256-SHA"); + wolfSSL_CTX_set_cipher_list(ctx, "AES256-SHA"); } #endif @@ -255,8 +255,8 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args) #ifndef NO_PSK const char *defaultCipherList; - CyaSSL_CTX_set_psk_server_callback(ctx, my_psk_server_cb); - CyaSSL_CTX_use_psk_identity_hint(ctx, "cyassl server"); + wolfSSL_CTX_set_psk_server_callback(ctx, my_psk_server_cb); + wolfSSL_CTX_use_psk_identity_hint(ctx, "cyassl server"); #ifdef HAVE_NULL_CIPHER defaultCipherList = "PSK-NULL-SHA256"; #elif defined(HAVE_AESGCM) && !defined(NO_DH) @@ -278,7 +278,7 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args) #else defaultCipherList = "PSK-AES128-CBC-SHA256"; #endif - if (CyaSSL_CTX_set_cipher_list(ctx, defaultCipherList) != WOLFSSL_SUCCESS) + if (wolfSSL_CTX_set_cipher_list(ctx, defaultCipherList) != WOLFSSL_SUCCESS) err_sys("server can't set cipher list 2"); wolfSSL_CTX_set_psk_callback_ctx(ctx, (void*)defaultCipherList); #endif @@ -323,23 +323,23 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args) #endif if (WOLFSSL_SOCKET_IS_INVALID(clientfd)) err_sys("tcp accept failed"); - ssl = CyaSSL_new(ctx); + ssl = wolfSSL_new(ctx); if (ssl == NULL) err_sys("SSL_new failed"); - CyaSSL_set_fd(ssl, clientfd); + wolfSSL_set_fd(ssl, clientfd); #ifdef WOLFSSL_DTLS wolfSSL_dtls_set_peer(ssl, &client, client_len); #endif #if !defined(NO_FILESYSTEM) && !defined(NO_DH) && !defined(NO_ASN) - CyaSSL_SetTmpDH_file(ssl, dhParamFile, WOLFSSL_FILETYPE_PEM); + wolfSSL_SetTmpDH_file(ssl, dhParamFile, WOLFSSL_FILETYPE_PEM); #elif !defined(NO_DH) SetDH(ssl); /* will repick suites with DHE, higher than PSK */ #endif do { err = 0; /* Reset error */ - ret = CyaSSL_accept(ssl); + ret = wolfSSL_accept(ssl); if (ret != WOLFSSL_SUCCESS) { - err = CyaSSL_get_error(ssl, 0); + err = wolfSSL_get_error(ssl, 0); #ifdef WOLFSSL_ASYNC_CRYPT if (err == WC_PENDING_E) { ret = wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW); @@ -350,9 +350,9 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args) } while (err == WC_PENDING_E); if (ret != WOLFSSL_SUCCESS) { fprintf(stderr, "SSL_accept error = %d, %s\n", err, - CyaSSL_ERR_error_string(err, buffer)); + wolfSSL_ERR_error_string(err, buffer)); fprintf(stderr, "SSL_accept failed\n"); - CyaSSL_free(ssl); + wolfSSL_free(ssl); CloseSocket(clientfd); continue; } @@ -364,7 +364,7 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args) write_ssl = wolfSSL_write_dup(ssl); if (write_ssl == NULL) { fprintf(stderr, "wolfSSL_write_dup failed\n"); - CyaSSL_free(ssl); + wolfSSL_free(ssl); CloseSocket(clientfd); continue; } @@ -377,9 +377,9 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args) do { err = 0; /* reset error */ - ret = CyaSSL_read(ssl, command, sizeof(command)-1); + ret = wolfSSL_read(ssl, command, sizeof(command)-1); if (ret <= 0) { - err = CyaSSL_get_error(ssl, 0); + err = wolfSSL_get_error(ssl, 0); #ifdef WOLFSSL_ASYNC_CRYPT if (err == WC_PENDING_E) { ret = wolfSSL_AsyncPoll(ssl, WOLF_POLL_FLAG_CHECK_HW); @@ -391,7 +391,7 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args) if (ret <= 0) { if (err != WOLFSSL_ERROR_WANT_READ && err != WOLFSSL_ERROR_ZERO_RETURN){ fprintf(stderr, "SSL_read echo error %d, %s!\n", err, - CyaSSL_ERR_error_string(err, buffer)); + wolfSSL_ERR_error_string(err, buffer)); } break; } @@ -421,7 +421,7 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args) } #ifdef PRINT_SESSION_STATS if ( strncmp(command, "printstats", 10) == 0) { - CyaSSL_PrintSessionStats(); + wolfSSL_PrintSessionStats(); break; } #endif @@ -440,9 +440,9 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args) do { err = 0; /* reset error */ - ret = CyaSSL_write(write_ssl, command, echoSz); + ret = wolfSSL_write(write_ssl, command, echoSz); if (ret <= 0) { - err = CyaSSL_get_error(write_ssl, 0); + err = wolfSSL_get_error(write_ssl, 0); #ifdef WOLFSSL_ASYNC_CRYPT if (err == WC_PENDING_E) { ret = wolfSSL_AsyncPoll(write_ssl, WOLF_POLL_FLAG_CHECK_HW); @@ -453,7 +453,7 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args) } while (err == WC_PENDING_E); if (ret != echoSz) { fprintf(stderr, "SSL_write get error = %d, %s\n", err, - CyaSSL_ERR_error_string(err, buffer)); + wolfSSL_ERR_error_string(err, buffer)); err_sys("SSL_write get failed"); } break; @@ -466,9 +466,9 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args) do { err = 0; /* reset error */ - ret = CyaSSL_write(write_ssl, command, echoSz); + ret = wolfSSL_write(write_ssl, command, echoSz); if (ret <= 0) { - err = CyaSSL_get_error(write_ssl, 0); + err = wolfSSL_get_error(write_ssl, 0); #ifdef WOLFSSL_ASYNC_CRYPT if (err == WC_PENDING_E) { ret = wolfSSL_AsyncPoll(write_ssl, WOLF_POLL_FLAG_CHECK_HW); @@ -480,17 +480,17 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args) if (ret != echoSz) { fprintf(stderr, "SSL_write echo error = %d, %s\n", err, - CyaSSL_ERR_error_string(err, buffer)); + wolfSSL_ERR_error_string(err, buffer)); err_sys("SSL_write echo failed"); } } #ifndef WOLFSSL_DTLS - CyaSSL_shutdown(ssl); + wolfSSL_shutdown(ssl); #endif #ifdef HAVE_WRITE_DUP - CyaSSL_free(write_ssl); + wolfSSL_free(write_ssl); #endif - CyaSSL_free(ssl); + wolfSSL_free(ssl); CloseSocket(clientfd); #ifdef WOLFSSL_DTLS tcp_listen(&sockfd, &port, useAnyAddr, doDTLS, 0); @@ -499,7 +499,7 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args) } CloseSocket(sockfd); - CyaSSL_CTX_free(ctx); + wolfSSL_CTX_free(ctx); #ifdef ECHO_OUT if (outCreated) @@ -510,7 +510,7 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args) #if defined(NO_MAIN_DRIVER) && defined(HAVE_ECC) && defined(FP_ECC) \ && defined(HAVE_THREAD_LS) - ecc_fp_free(); /* free per thread cache */ + wc_ecc_fp_free(); /* free per thread cache */ #endif #ifdef WOLFSSL_TIRTOS @@ -551,15 +551,15 @@ THREAD_RETURN WOLFSSL_THREAD echoserver_test(void* args) args.argv = argv; args.return_code = 0; - CyaSSL_Init(); + wolfSSL_Init(); #if defined(DEBUG_WOLFSSL) && !defined(WOLFSSL_MDK_SHELL) - CyaSSL_Debugging_ON(); + wolfSSL_Debugging_ON(); #endif ChangeToWolfRoot(); #ifndef NO_WOLFSSL_SERVER echoserver_test(&args); #endif - CyaSSL_Cleanup(); + wolfSSL_Cleanup(); #ifdef HAVE_WNR if (wc_FreeNetRandom() < 0)