diff --git a/src/crl.c b/src/crl.c index f0b7c157c..8e17ec08c 100644 --- a/src/crl.c +++ b/src/crl.c @@ -2,14 +2,14 @@ * * Copyright (C) 2006-2014 wolfSSL Inc. * - * This file is part of CyaSSL. + * This file is part of wolfSSL. (formerly known as CyaSSL) * - * 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 * the Free Software Foundation; either version 2 of the License, or * (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 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -20,18 +20,18 @@ */ /* Name change compatibility layer */ -#include +#include #ifdef HAVE_CONFIG_H #include #endif -#include +#include #ifdef HAVE_CRL -#include -#include +#include +#include #include #include @@ -43,9 +43,9 @@ /* Initialze CRL members */ -int InitCRL(CYASSL_CRL* crl, CYASSL_CERT_MANAGER* cm) +int InitCRL(WOLFSSL_CRL* crl, WOLFSSL_CERT_MANAGER* cm) { - CYASSL_ENTER("InitCRL"); + WOLFSSL_ENTER("InitCRL"); crl->cm = cm; crl->crlList = NULL; @@ -65,7 +65,7 @@ int InitCRL(CYASSL_CRL* crl, CYASSL_CERT_MANAGER* cm) /* Initialze CRL Entry */ static int InitCRL_Entry(CRL_Entry* crle, DecodedCRL* dcrl) { - CYASSL_ENTER("InitCRL_Entry"); + WOLFSSL_ENTER("InitCRL_Entry"); XMEMCPY(crle->issuerHash, dcrl->issuerHash, SHA_DIGEST_SIZE); /* XMEMCPY(crle->crlHash, dcrl->crlHash, SHA_DIGEST_SIZE); @@ -88,7 +88,7 @@ static void FreeCRL_Entry(CRL_Entry* crle) { RevokedCert* tmp = crle->certs; - CYASSL_ENTER("FreeCRL_Entry"); + WOLFSSL_ENTER("FreeCRL_Entry"); while(tmp) { RevokedCert* next = tmp->next; @@ -100,11 +100,11 @@ static void FreeCRL_Entry(CRL_Entry* crle) /* Free all CRL resources */ -void FreeCRL(CYASSL_CRL* crl, int dynamic) +void FreeCRL(WOLFSSL_CRL* crl, int dynamic) { CRL_Entry* tmp = crl->crlList; - CYASSL_ENTER("FreeCRL"); + WOLFSSL_ENTER("FreeCRL"); if (crl->monitors[0].path) XFREE(crl->monitors[0].path, NULL, DYNAMIC_TYPE_CRL_MONITOR); @@ -121,11 +121,11 @@ void FreeCRL(CYASSL_CRL* crl, int dynamic) #ifdef HAVE_CRL_MONITOR if (crl->tid != 0) { - CYASSL_MSG("stopping monitor thread"); + WOLFSSL_MSG("stopping monitor thread"); if (StopMonitor(crl->mfd) == 0) pthread_join(crl->tid, NULL); else { - CYASSL_MSG("stop monitor failed, cancel instead"); + WOLFSSL_MSG("stop monitor failed, cancel instead"); pthread_cancel(crl->tid); } } @@ -137,16 +137,16 @@ void FreeCRL(CYASSL_CRL* crl, int dynamic) /* Is the cert ok with CRL, return 0 on success */ -int CheckCertCRL(CYASSL_CRL* crl, DecodedCert* cert) +int CheckCertCRL(WOLFSSL_CRL* crl, DecodedCert* cert) { CRL_Entry* crle; int foundEntry = 0; int ret = 0; - CYASSL_ENTER("CheckCertCRL"); + WOLFSSL_ENTER("CheckCertCRL"); if (LockMutex(&crl->crlLock) != 0) { - CYASSL_MSG("LockMutex failed"); + WOLFSSL_MSG("LockMutex failed"); return BAD_MUTEX_E; } @@ -154,11 +154,11 @@ int CheckCertCRL(CYASSL_CRL* crl, DecodedCert* cert) while (crle) { if (XMEMCMP(crle->issuerHash, cert->issuerHash, SHA_DIGEST_SIZE) == 0) { - CYASSL_MSG("Found CRL Entry on list"); - CYASSL_MSG("Checking next date validity"); + WOLFSSL_MSG("Found CRL Entry on list"); + WOLFSSL_MSG("Checking next date validity"); if (!ValidateDate(crle->nextDate, crle->nextDateFormat, AFTER)) { - CYASSL_MSG("CRL next date is no longer valid"); + WOLFSSL_MSG("CRL next date is no longer valid"); ret = ASN_AFTER_DATE_E; } else @@ -173,7 +173,7 @@ int CheckCertCRL(CYASSL_CRL* crl, DecodedCert* cert) while (rc) { if (XMEMCMP(rc->serialNumber, cert->serial, rc->serialSz) == 0) { - CYASSL_MSG("Cert revoked"); + WOLFSSL_MSG("Cert revoked"); ret = CRL_CERT_REVOKED; break; } @@ -184,19 +184,19 @@ int CheckCertCRL(CYASSL_CRL* crl, DecodedCert* cert) UnLockMutex(&crl->crlLock); if (foundEntry == 0) { - CYASSL_MSG("Couldn't find CRL for status check"); + WOLFSSL_MSG("Couldn't find CRL for status check"); ret = CRL_MISSING; if (crl->cm->cbMissingCRL) { char url[256]; - CYASSL_MSG("Issuing missing CRL callback"); + WOLFSSL_MSG("Issuing missing CRL callback"); url[0] = '\0'; if (cert->extCrlInfoSz < (int)sizeof(url) -1 ) { XMEMCPY(url, cert->extCrlInfo, cert->extCrlInfoSz); url[cert->extCrlInfoSz] = '\0'; } else { - CYASSL_MSG("CRL url too long"); + WOLFSSL_MSG("CRL url too long"); } crl->cm->cbMissingCRL(url); } @@ -208,26 +208,26 @@ int CheckCertCRL(CYASSL_CRL* crl, DecodedCert* cert) /* Add Decoded CRL, 0 on success */ -static int AddCRL(CYASSL_CRL* crl, DecodedCRL* dcrl) +static int AddCRL(WOLFSSL_CRL* crl, DecodedCRL* dcrl) { CRL_Entry* crle; - CYASSL_ENTER("AddCRL"); + WOLFSSL_ENTER("AddCRL"); crle = (CRL_Entry*)XMALLOC(sizeof(CRL_Entry), NULL, DYNAMIC_TYPE_CRL_ENTRY); if (crle == NULL) { - CYASSL_MSG("alloc CRL Entry failed"); + WOLFSSL_MSG("alloc CRL Entry failed"); return -1; } if (InitCRL_Entry(crle, dcrl) < 0) { - CYASSL_MSG("Init CRL Entry failed"); + WOLFSSL_MSG("Init CRL Entry failed"); XFREE(crle, NULL, DYNAMIC_TYPE_CRL_ENTRY); return -1; } if (LockMutex(&crl->crlLock) != 0) { - CYASSL_MSG("LockMutex failed"); + WOLFSSL_MSG("LockMutex failed"); FreeCRL_Entry(crle); XFREE(crle, NULL, DYNAMIC_TYPE_CRL_ENTRY); return BAD_MUTEX_E; @@ -241,12 +241,12 @@ static int AddCRL(CYASSL_CRL* crl, DecodedCRL* dcrl) /* Load CRL File of type, SSL_SUCCESS on ok */ -int BufferLoadCRL(CYASSL_CRL* crl, const byte* buff, long sz, int type) +int BufferLoadCRL(WOLFSSL_CRL* crl, const byte* buff, long sz, int type) { int ret = SSL_SUCCESS; const byte* myBuffer = buff; /* if DER ok, otherwise switch */ buffer der; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK DecodedCRL* dcrl; #else DecodedCRL dcrl[1]; @@ -254,7 +254,7 @@ int BufferLoadCRL(CYASSL_CRL* crl, const byte* buff, long sz, int type) der.buffer = NULL; - CYASSL_ENTER("BufferLoadCRL"); + WOLFSSL_ENTER("BufferLoadCRL"); if (crl == NULL || buff == NULL || sz == 0) return BAD_FUNC_ARG; @@ -270,12 +270,12 @@ int BufferLoadCRL(CYASSL_CRL* crl, const byte* buff, long sz, int type) sz = der.length; } else { - CYASSL_MSG("Pem to Der failed"); + WOLFSSL_MSG("Pem to Der failed"); return -1; } } -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK dcrl = (DecodedCRL*)XMALLOC(sizeof(DecodedCRL), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (dcrl == NULL) { if (der.buffer) @@ -288,18 +288,18 @@ int BufferLoadCRL(CYASSL_CRL* crl, const byte* buff, long sz, int type) InitDecodedCRL(dcrl); ret = ParseCRL(dcrl, myBuffer, (word32)sz, crl->cm); if (ret != 0) { - CYASSL_MSG("ParseCRL error"); + WOLFSSL_MSG("ParseCRL error"); } else { ret = AddCRL(crl, dcrl); if (ret != 0) { - CYASSL_MSG("AddCRL error"); + WOLFSSL_MSG("AddCRL error"); } } FreeDecodedCRL(dcrl); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(dcrl, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -314,25 +314,25 @@ int BufferLoadCRL(CYASSL_CRL* crl, const byte* buff, long sz, int type) /* read in new CRL entries and save new list */ -static int SwapLists(CYASSL_CRL* crl) +static int SwapLists(WOLFSSL_CRL* crl) { int ret; CRL_Entry* newList; -#ifdef CYASSL_SMALL_STACK - CYASSL_CRL* tmp; +#ifdef WOLFSSL_SMALL_STACK + WOLFSSL_CRL* tmp; #else - CYASSL_CRL tmp[1]; + WOLFSSL_CRL tmp[1]; #endif -#ifdef CYASSL_SMALL_STACK - tmp = (CYASSL_CRL*)XMALLOC(sizeof(CYASSL_CRL), NULL, DYNAMIC_TYPE_TMP_BUFFER); +#ifdef WOLFSSL_SMALL_STACK + tmp = (WOLFSSL_CRL*)XMALLOC(sizeof(WOLFSSL_CRL), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (tmp == NULL) return MEMORY_E; #endif if (InitCRL(tmp, crl->cm) < 0) { - CYASSL_MSG("Init tmp CRL failed"); -#ifdef CYASSL_SMALL_STACK + WOLFSSL_MSG("Init tmp CRL failed"); +#ifdef WOLFSSL_SMALL_STACK XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return -1; @@ -341,9 +341,9 @@ static int SwapLists(CYASSL_CRL* crl) if (crl->monitors[0].path) { ret = LoadCRL(tmp, crl->monitors[0].path, SSL_FILETYPE_PEM, 0); if (ret != SSL_SUCCESS) { - CYASSL_MSG("PEM LoadCRL on dir change failed"); + WOLFSSL_MSG("PEM LoadCRL on dir change failed"); FreeCRL(tmp, 0); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return -1; @@ -353,9 +353,9 @@ static int SwapLists(CYASSL_CRL* crl) if (crl->monitors[1].path) { ret = LoadCRL(tmp, crl->monitors[1].path, SSL_FILETYPE_ASN1, 0); if (ret != SSL_SUCCESS) { - CYASSL_MSG("DER LoadCRL on dir change failed"); + WOLFSSL_MSG("DER LoadCRL on dir change failed"); FreeCRL(tmp, 0); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return -1; @@ -363,9 +363,9 @@ static int SwapLists(CYASSL_CRL* crl) } if (LockMutex(&crl->crlLock) != 0) { - CYASSL_MSG("LockMutex failed"); + WOLFSSL_MSG("LockMutex failed"); FreeCRL(tmp, 0); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return -1; @@ -381,7 +381,7 @@ static int SwapLists(CYASSL_CRL* crl) FreeCRL(tmp, 0); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -419,7 +419,7 @@ static int StopMonitor(int mfd) /* trigger custom shutdown */ EV_SET(&change, CRL_CUSTOM_FD, EVFILT_USER, 0, NOTE_TRIGGER, 0, NULL); if (kevent(mfd, &change, 1, NULL, 0, NULL) < 0) { - CYASSL_MSG("kevent trigger customer event failed"); + WOLFSSL_MSG("kevent trigger customer event failed"); return -1; } @@ -433,20 +433,20 @@ static void* DoMonitor(void* arg) int fPEM, fDER; struct kevent change; - CYASSL_CRL* crl = (CYASSL_CRL*)arg; + WOLFSSL_CRL* crl = (WOLFSSL_CRL*)arg; - CYASSL_ENTER("DoMonitor"); + WOLFSSL_ENTER("DoMonitor"); crl->mfd = kqueue(); if (crl->mfd == -1) { - CYASSL_MSG("kqueue failed"); + WOLFSSL_MSG("kqueue failed"); return NULL; } /* listen for custom shutdown event */ EV_SET(&change, CRL_CUSTOM_FD, EVFILT_USER, EV_ADD, 0, 0, NULL); if (kevent(crl->mfd, &change, 1, NULL, 0, NULL) < 0) { - CYASSL_MSG("kevent monitor customer event failed"); + WOLFSSL_MSG("kevent monitor customer event failed"); close(crl->mfd); return NULL; } @@ -457,7 +457,7 @@ static void* DoMonitor(void* arg) if (crl->monitors[0].path) { fPEM = open(crl->monitors[0].path, XEVENT_MODE); if (fPEM == -1) { - CYASSL_MSG("PEM event dir open failed"); + WOLFSSL_MSG("PEM event dir open failed"); close(crl->mfd); return NULL; } @@ -466,7 +466,7 @@ static void* DoMonitor(void* arg) if (crl->monitors[1].path) { fDER = open(crl->monitors[1].path, XEVENT_MODE); if (fDER == -1) { - CYASSL_MSG("DER event dir open failed"); + WOLFSSL_MSG("DER event dir open failed"); close(crl->mfd); return NULL; } @@ -484,20 +484,20 @@ static void* DoMonitor(void* arg) struct kevent event; int numEvents = kevent(crl->mfd, &change, 1, &event, 1, NULL); - CYASSL_MSG("Got kevent"); + WOLFSSL_MSG("Got kevent"); if (numEvents == -1) { - CYASSL_MSG("kevent problem, continue"); + WOLFSSL_MSG("kevent problem, continue"); continue; } if (event.filter == EVFILT_USER) { - CYASSL_MSG("Got user shutdown event, breaking out"); + WOLFSSL_MSG("Got user shutdown event, breaking out"); break; } if (SwapLists(crl) < 0) { - CYASSL_MSG("SwapLists problem, continue"); + WOLFSSL_MSG("SwapLists problem, continue"); } } @@ -535,7 +535,7 @@ static int StopMonitor(int mfd) /* write to our custom event */ if (write(mfd, &w64, sizeof(w64)) < 0) { - CYASSL_MSG("StopMonitor write failed"); + WOLFSSL_MSG("StopMonitor write failed"); return -1; } @@ -548,24 +548,24 @@ static void* DoMonitor(void* arg) { int notifyFd; int wd = -1; - CYASSL_CRL* crl = (CYASSL_CRL*)arg; -#ifdef CYASSL_SMALL_STACK + WOLFSSL_CRL* crl = (WOLFSSL_CRL*)arg; +#ifdef WOLFSSL_SMALL_STACK char* buff; #else char buff[8192]; #endif - CYASSL_ENTER("DoMonitor"); + WOLFSSL_ENTER("DoMonitor"); crl->mfd = eventfd(0, 0); /* our custom shutdown event */ if (crl->mfd < 0) { - CYASSL_MSG("eventfd failed"); + WOLFSSL_MSG("eventfd failed"); return NULL; } notifyFd = inotify_init(); if (notifyFd < 0) { - CYASSL_MSG("inotify failed"); + WOLFSSL_MSG("inotify failed"); close(crl->mfd); return NULL; } @@ -574,7 +574,7 @@ static void* DoMonitor(void* arg) wd = inotify_add_watch(notifyFd, crl->monitors[0].path, IN_CLOSE_WRITE | IN_DELETE); if (wd < 0) { - CYASSL_MSG("PEM notify add watch failed"); + WOLFSSL_MSG("PEM notify add watch failed"); close(crl->mfd); close(notifyFd); return NULL; @@ -585,14 +585,14 @@ static void* DoMonitor(void* arg) wd = inotify_add_watch(notifyFd, crl->monitors[1].path, IN_CLOSE_WRITE | IN_DELETE); if (wd < 0) { - CYASSL_MSG("DER notify add watch failed"); + WOLFSSL_MSG("DER notify add watch failed"); close(crl->mfd); close(notifyFd); return NULL; } } -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK buff = (char*)XMALLOC(8192, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (buff == NULL) return NULL; @@ -609,30 +609,30 @@ static void* DoMonitor(void* arg) result = select(max(notifyFd, crl->mfd) + 1, &readfds, NULL, NULL,NULL); - CYASSL_MSG("Got notify event"); + WOLFSSL_MSG("Got notify event"); if (result < 0) { - CYASSL_MSG("select problem, continue"); + WOLFSSL_MSG("select problem, continue"); continue; } if (FD_ISSET(crl->mfd, &readfds)) { - CYASSL_MSG("got custom shutdown event, breaking out"); + WOLFSSL_MSG("got custom shutdown event, breaking out"); break; } length = read(notifyFd, buff, 8192); if (length < 0) { - CYASSL_MSG("notify read problem, continue"); + WOLFSSL_MSG("notify read problem, continue"); continue; } if (SwapLists(crl) < 0) { - CYASSL_MSG("SwapLists problem, continue"); + WOLFSSL_MSG("SwapLists problem, continue"); } } -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(buff, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -653,24 +653,24 @@ static void* DoMonitor(void* arg) /* Start Monitoring the CRL path(s) in a thread */ -static int StartMonitorCRL(CYASSL_CRL* crl) +static int StartMonitorCRL(WOLFSSL_CRL* crl) { pthread_attr_t attr; - CYASSL_ENTER("StartMonitorCRL"); + WOLFSSL_ENTER("StartMonitorCRL"); if (crl == NULL) return BAD_FUNC_ARG; if (crl->tid != 0) { - CYASSL_MSG("Monitor thread already running"); + WOLFSSL_MSG("Monitor thread already running"); return MONITOR_RUNNING_E; } pthread_attr_init(&attr); if (pthread_create(&crl->tid, &attr, DoMonitor, crl) != 0) { - CYASSL_MSG("Thread creation error"); + WOLFSSL_MSG("Thread creation error"); return THREAD_CREATE_E; } @@ -680,12 +680,12 @@ static int StartMonitorCRL(CYASSL_CRL* crl) #else /* HAVE_CRL_MONITOR */ -static int StartMonitorCRL(CYASSL_CRL* crl) +static int StartMonitorCRL(WOLFSSL_CRL* crl) { (void)crl; - CYASSL_ENTER("StartMonitorCRL"); - CYASSL_MSG("Not compiled in"); + WOLFSSL_ENTER("StartMonitorCRL"); + WOLFSSL_MSG("Not compiled in"); return NOT_COMPILED_IN; } @@ -694,28 +694,28 @@ static int StartMonitorCRL(CYASSL_CRL* crl) /* Load CRL path files of type, SSL_SUCCESS on ok */ -int LoadCRL(CYASSL_CRL* crl, const char* path, int type, int monitor) +int LoadCRL(WOLFSSL_CRL* crl, const char* path, int type, int monitor) { struct dirent* entry; DIR* dir; int ret = SSL_SUCCESS; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK char* name; #else char name[MAX_FILENAME_SZ]; #endif - CYASSL_ENTER("LoadCRL"); + WOLFSSL_ENTER("LoadCRL"); if (crl == NULL) return BAD_FUNC_ARG; dir = opendir(path); if (dir == NULL) { - CYASSL_MSG("opendir path crl load failed"); + WOLFSSL_MSG("opendir path crl load failed"); return BAD_PATH_ERROR; } -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK name = (char*)XMALLOC(MAX_FILENAME_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (name == NULL) return MEMORY_E; @@ -730,14 +730,14 @@ int LoadCRL(CYASSL_CRL* crl, const char* path, int type, int monitor) XSTRNCAT(name, entry->d_name, MAX_FILENAME_SZ/2); if (stat(name, &s) != 0) { - CYASSL_MSG("stat on name failed"); + WOLFSSL_MSG("stat on name failed"); continue; } if (s.st_mode & S_IFREG) { if (type == SSL_FILETYPE_PEM) { if (strstr(entry->d_name, ".pem") == NULL) { - CYASSL_MSG("not .pem file, skipping"); + WOLFSSL_MSG("not .pem file, skipping"); continue; } } @@ -745,24 +745,24 @@ int LoadCRL(CYASSL_CRL* crl, const char* path, int type, int monitor) if (strstr(entry->d_name, ".der") == NULL && strstr(entry->d_name, ".crl") == NULL) { - CYASSL_MSG("not .der or .crl file, skipping"); + WOLFSSL_MSG("not .der or .crl file, skipping"); continue; } } if (ProcessFile(NULL, name, type, CRL_TYPE, NULL, 0, crl) != SSL_SUCCESS) { - CYASSL_MSG("CRL file load failed, continuing"); + WOLFSSL_MSG("CRL file load failed, continuing"); } } } -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(name, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif - if (monitor & CYASSL_CRL_MONITOR) { - CYASSL_MSG("monitor path requested"); + if (monitor & WOLFSSL_CRL_MONITOR) { + WOLFSSL_MSG("monitor path requested"); if (type == SSL_FILETYPE_PEM) { crl->monitors[0].path = strdup(path); @@ -776,8 +776,8 @@ int LoadCRL(CYASSL_CRL* crl, const char* path, int type, int monitor) ret = MEMORY_E; } - if (monitor & CYASSL_CRL_START_MON) { - CYASSL_MSG("start monitoring requested"); + if (monitor & WOLFSSL_CRL_START_MON) { + WOLFSSL_MSG("start monitoring requested"); ret = StartMonitorCRL(crl); } diff --git a/src/internal.c b/src/internal.c index 1c78d15a1..0532b7cd9 100644 --- a/src/internal.c +++ b/src/internal.c @@ -2,14 +2,14 @@ * * Copyright (C) 2006-2014 wolfSSL Inc. * - * This file is part of CyaSSL. + * This file is part of wolfSSL. (formerly known as CyaSSL) * - * 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 * the Free Software Foundation; either version 2 of the License, or * (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 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -20,18 +20,18 @@ */ /* Name change compatibility layer */ -#include +#include #ifdef HAVE_CONFIG_H #include #endif -#include +#include -#include -#include -#include +#include +#include +#include #ifdef HAVE_LIBZ #include "zlib.h" @@ -41,7 +41,7 @@ #include "ntru_crypto.h" #endif -#if defined(DEBUG_CYASSL) || defined(SHOW_SECRETS) || defined(CHACHA_AEAD_TEST) +#if defined(DEBUG_WOLFSSL) || defined(SHOW_SECRETS) || defined(CHACHA_AEAD_TEST) #ifdef FREESCALE_MQX #include #else @@ -61,45 +61,45 @@ #endif -#if defined(CYASSL_CALLBACKS) && !defined(LARGE_STATIC_BUFFERS) +#if defined(WOLFSSL_CALLBACKS) && !defined(LARGE_STATIC_BUFFERS) #error \ -CYASSL_CALLBACKS needs LARGE_STATIC_BUFFERS, please add LARGE_STATIC_BUFFERS +WOLFSSL_CALLBACKS needs LARGE_STATIC_BUFFERS, please add LARGE_STATIC_BUFFERS #endif #if defined(HAVE_SECURE_RENEGOTIATION) && defined(HAVE_RENEGOTIATION_INDICATION) #error Cannot use both secure-renegotiation and renegotiation-indication #endif -static int BuildMessage(CYASSL* ssl, byte* output, int outSz, +static int BuildMessage(WOLFSSL* ssl, byte* output, int outSz, const byte* input, int inSz, int type); -#ifndef NO_CYASSL_CLIENT - static int DoHelloVerifyRequest(CYASSL* ssl, const byte* input, word32*, +#ifndef NO_WOLFSSL_CLIENT + static int DoHelloVerifyRequest(WOLFSSL* ssl, const byte* input, word32*, word32); - static int DoServerHello(CYASSL* ssl, const byte* input, word32*, word32); - static int DoServerKeyExchange(CYASSL* ssl, const byte* input, word32*, + static int DoServerHello(WOLFSSL* ssl, const byte* input, word32*, word32); + static int DoServerKeyExchange(WOLFSSL* ssl, const byte* input, word32*, word32); #ifndef NO_CERTS - static int DoCertificateRequest(CYASSL* ssl, const byte* input, word32*, + static int DoCertificateRequest(WOLFSSL* ssl, const byte* input, word32*, word32); #endif #ifdef HAVE_SESSION_TICKET - static int DoSessionTicket(CYASSL* ssl, const byte* input, word32*, + static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32*, word32); #endif #endif -#ifndef NO_CYASSL_SERVER - static int DoClientHello(CYASSL* ssl, const byte* input, word32*, word32); - static int DoClientKeyExchange(CYASSL* ssl, byte* input, word32*, word32); +#ifndef NO_WOLFSSL_SERVER + static int DoClientHello(WOLFSSL* ssl, const byte* input, word32*, word32); + static int DoClientKeyExchange(WOLFSSL* ssl, byte* input, word32*, word32); #if !defined(NO_RSA) || defined(HAVE_ECC) - static int DoCertificateVerify(CYASSL* ssl, byte*, word32*, word32); + static int DoCertificateVerify(WOLFSSL* ssl, byte*, word32*, word32); #endif #endif -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS static INLINE int DtlsCheckWindow(DtlsState* state); static INLINE int DtlsUpdateWindow(DtlsState* state); #endif @@ -107,7 +107,7 @@ static int BuildMessage(CYASSL* ssl, byte* output, int outSz, typedef enum { doProcessInit = 0, -#ifndef NO_CYASSL_SERVER +#ifndef NO_WOLFSSL_SERVER runProcessOldClientHello, #endif getRecordLayerHeader, @@ -116,16 +116,16 @@ typedef enum { } processReply; #ifndef NO_OLD_TLS -static int SSL_hmac(CYASSL* ssl, byte* digest, const byte* in, word32 sz, +static int SSL_hmac(WOLFSSL* ssl, byte* digest, const byte* in, word32 sz, int content, int verify); #endif #ifndef NO_CERTS -static int BuildCertHashes(CYASSL* ssl, Hashes* hashes); +static int BuildCertHashes(WOLFSSL* ssl, Hashes* hashes); #endif -static void PickHashSigAlgo(CYASSL* ssl, +static void PickHashSigAlgo(WOLFSSL* ssl, const byte* hashSigAlgo, word32 hashSigAlgoSz); #ifndef min @@ -138,7 +138,7 @@ static void PickHashSigAlgo(CYASSL* ssl, #endif /* min */ -int IsTLS(const CYASSL* ssl) +int IsTLS(const WOLFSSL* ssl) { if (ssl->version.major == SSLv3_MAJOR && ssl->version.minor >=TLSv1_MINOR) return 1; @@ -147,7 +147,7 @@ int IsTLS(const CYASSL* ssl) } -int IsAtLeastTLSv1_2(const CYASSL* ssl) +int IsAtLeastTLSv1_2(const WOLFSSL* ssl) { if (ssl->version.major == SSLv3_MAJOR && ssl->version.minor >=TLSv1_2_MINOR) return 1; @@ -193,7 +193,7 @@ void c32to24(word32 in, word24 out) } -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS static INLINE void c32to48(word32 in, byte out[6]) { @@ -205,7 +205,7 @@ static INLINE void c32to48(word32 in, byte out[6]) out[5] = in & 0xff; } -#endif /* CYASSL_DTLS */ +#endif /* WOLFSSL_DTLS */ /* convert 16 bit integer to opaque */ @@ -243,7 +243,7 @@ static INLINE void ato16(const byte* c, word16* u16) } -#if defined(CYASSL_DTLS) || defined(HAVE_SESSION_TICKET) +#if defined(WOLFSSL_DTLS) || defined(HAVE_SESSION_TICKET) /* convert opaque to 32 bit integer */ static INLINE void ato32(const byte* c, word32* u32) @@ -251,7 +251,7 @@ static INLINE void ato32(const byte* c, word32* u32) *u32 = (c[0] << 24) | (c[1] << 16) | (c[2] << 8) | c[3]; } -#endif /* CYASSL_DTLS */ +#endif /* WOLFSSL_DTLS */ #ifdef HAVE_LIBZ @@ -272,7 +272,7 @@ static INLINE void ato32(const byte* c, word32* u32) /* init zlib comp/decomp streams, 0 on success */ - static int InitStreams(CYASSL* ssl) + static int InitStreams(WOLFSSL* ssl) { ssl->c_stream.zalloc = (alloc_func)myAlloc; ssl->c_stream.zfree = (free_func)myFree; @@ -293,7 +293,7 @@ static INLINE void ato32(const byte* c, word32* u32) } - static void FreeStreams(CYASSL* ssl) + static void FreeStreams(WOLFSSL* ssl) { if (ssl->didStreamInit) { deflateEnd(&ssl->c_stream); @@ -303,7 +303,7 @@ static INLINE void ato32(const byte* c, word32* u32) /* compress in to out, return out size or error */ - static int myCompress(CYASSL* ssl, byte* in, int inSz, byte* out, int outSz) + static int myCompress(WOLFSSL* ssl, byte* in, int inSz, byte* out, int outSz) { int err; int currTotal = (int)ssl->c_stream.total_out; @@ -321,7 +321,7 @@ static INLINE void ato32(const byte* c, word32* u32) /* decompress in to out, returnn out size or error */ - static int myDeCompress(CYASSL* ssl, byte* in,int inSz, byte* out,int outSz) + static int myDeCompress(WOLFSSL* ssl, byte* in,int inSz, byte* out,int outSz) { int err; int currTotal = (int)ssl->d_stream.total_out; @@ -340,16 +340,16 @@ static INLINE void ato32(const byte* c, word32* u32) #endif /* HAVE_LIBZ */ -void InitSSL_Method(CYASSL_METHOD* method, ProtocolVersion pv) +void InitSSL_Method(WOLFSSL_METHOD* method, ProtocolVersion pv) { method->version = pv; - method->side = CYASSL_CLIENT_END; + method->side = WOLFSSL_CLIENT_END; method->downgrade = 0; } /* Initialze SSL context, return 0 on success */ -int InitSSL_Ctx(CYASSL_CTX* ctx, CYASSL_METHOD* method) +int InitSSL_Ctx(WOLFSSL_CTX* ctx, WOLFSSL_METHOD* method) { ctx->method = method; ctx->refCount = 1; /* so either CTX_free or SSL_free can release */ @@ -383,12 +383,12 @@ int InitSSL_Ctx(CYASSL_CTX* ctx, CYASSL_METHOD* method) ctx->userdata = 0; #endif /* OPENSSL_EXTRA */ - ctx->timeout = CYASSL_SESSION_TIMEOUT; + ctx->timeout = WOLFSSL_SESSION_TIMEOUT; -#ifndef CYASSL_USER_IO +#ifndef WOLFSSL_USER_IO ctx->CBIORecv = EmbedReceive; ctx->CBIOSend = EmbedSend; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (method->version.major == DTLS_MAJOR) { ctx->CBIORecv = EmbedReceiveFrom; ctx->CBIOSend = EmbedSendTo; @@ -399,10 +399,10 @@ int InitSSL_Ctx(CYASSL_CTX* ctx, CYASSL_METHOD* method) /* user will set */ ctx->CBIORecv = NULL; ctx->CBIOSend = NULL; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS ctx->CBIOCookie = NULL; #endif -#endif /* CYASSL_USER_IO */ +#endif /* WOLFSSL_USER_IO */ #ifdef HAVE_NETX ctx->CBIORecv = NetX_Receive; ctx->CBIOSend = NetX_Send; @@ -411,15 +411,15 @@ int InitSSL_Ctx(CYASSL_CTX* ctx, CYASSL_METHOD* method) ctx->verifyCallback = 0; #ifndef NO_CERTS - ctx->cm = CyaSSL_CertManagerNew(); + ctx->cm = wolfSSL_CertManagerNew(); #endif #ifdef HAVE_NTRU - if (method->side == CYASSL_CLIENT_END) + if (method->side == WOLFSSL_CLIENT_END) ctx->haveNTRU = 1; /* always on cliet side */ /* server can turn on by loading key */ #endif #ifdef HAVE_ECC - if (method->side == CYASSL_CLIENT_END) { + if (method->side == WOLFSSL_CLIENT_END) { ctx->haveECDSAsig = 1; /* always on cliet side */ ctx->haveStaticECC = 1; /* server can turn on by loading key */ } @@ -460,12 +460,12 @@ int InitSSL_Ctx(CYASSL_CTX* ctx, CYASSL_METHOD* method) #endif /* HAVE_PK_CALLBACKS */ if (InitMutex(&ctx->countMutex) < 0) { - CYASSL_MSG("Mutex error on CTX init"); + WOLFSSL_MSG("Mutex error on CTX init"); return BAD_MUTEX_E; } #ifndef NO_CERTS if (ctx->cm == NULL) { - CYASSL_MSG("Bad Cert Manager New"); + WOLFSSL_MSG("Bad Cert Manager New"); return BAD_CERT_MANAGER_ERROR; } #endif @@ -474,7 +474,7 @@ int InitSSL_Ctx(CYASSL_CTX* ctx, CYASSL_METHOD* method) /* In case contexts are held in array and don't want to free actual ctx */ -void SSL_CtxResourceFree(CYASSL_CTX* ctx) +void SSL_CtxResourceFree(WOLFSSL_CTX* ctx) { XFREE(ctx->method, ctx->heap, DYNAMIC_TYPE_METHOD); @@ -484,7 +484,7 @@ void SSL_CtxResourceFree(CYASSL_CTX* ctx) XFREE(ctx->privateKey.buffer, ctx->heap, DYNAMIC_TYPE_KEY); XFREE(ctx->certificate.buffer, ctx->heap, DYNAMIC_TYPE_CERT); XFREE(ctx->certChain.buffer, ctx->heap, DYNAMIC_TYPE_CERT); - CyaSSL_CertManagerFree(ctx->cm); + wolfSSL_CertManagerFree(ctx->cm); #endif #ifdef HAVE_TLS_EXTENSIONS TLSX_FreeAll(ctx->extensions); @@ -492,12 +492,12 @@ void SSL_CtxResourceFree(CYASSL_CTX* ctx) } -void FreeSSL_Ctx(CYASSL_CTX* ctx) +void FreeSSL_Ctx(WOLFSSL_CTX* ctx) { int doFree = 0; if (LockMutex(&ctx->countMutex) != 0) { - CYASSL_MSG("Couldn't lock count mutex"); + WOLFSSL_MSG("Couldn't lock count mutex"); return; } ctx->refCount--; @@ -506,20 +506,20 @@ void FreeSSL_Ctx(CYASSL_CTX* ctx) UnLockMutex(&ctx->countMutex); if (doFree) { - CYASSL_MSG("CTX ref count down to 0, doing full free"); + WOLFSSL_MSG("CTX ref count down to 0, doing full free"); SSL_CtxResourceFree(ctx); FreeMutex(&ctx->countMutex); XFREE(ctx, ctx->heap, DYNAMIC_TYPE_CTX); } else { (void)ctx; - CYASSL_MSG("CTX ref count not 0 yet, no free"); + WOLFSSL_MSG("CTX ref count not 0 yet, no free"); } } /* Set cipher pointers to null */ -void InitCiphers(CYASSL* ssl) +void InitCiphers(WOLFSSL* ssl) { #ifdef BUILD_ARC4 ssl->encrypt.arc4 = NULL; @@ -561,7 +561,7 @@ void InitCiphers(CYASSL* ssl) /* Free ciphers */ -void FreeCiphers(CYASSL* ssl) +void FreeCiphers(WOLFSSL* ssl) { (void)ssl; #ifdef BUILD_ARC4 @@ -637,7 +637,7 @@ static void InitSuitesHashSigAlgo(Suites* suites, int haveECDSAsig, int idx = 0; if (haveECDSAsig) { - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 suites->hashSigAlgo[idx++] = sha384_mac; suites->hashSigAlgo[idx++] = ecc_dsa_sa_algo; #endif @@ -652,7 +652,7 @@ static void InitSuitesHashSigAlgo(Suites* suites, int haveECDSAsig, } if (haveRSAsig) { - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 suites->hashSigAlgo[idx++] = sha384_mac; suites->hashSigAlgo[idx++] = rsa_sa_algo; #endif @@ -693,24 +693,24 @@ void InitSuites(Suites* suites, ProtocolVersion pv, byte haveRSA, byte havePSK, (void)haveStaticECC; if (suites == NULL) { - CYASSL_MSG("InitSuites pointer error"); + WOLFSSL_MSG("InitSuites pointer error"); return; } if (suites->setSuites) return; /* trust user settings, don't override */ - if (side == CYASSL_SERVER_END && haveStaticECC) { + if (side == WOLFSSL_SERVER_END && haveStaticECC) { haveRSA = 0; /* can't do RSA with ECDSA key */ (void)haveRSA; /* some builds won't read */ } - if (side == CYASSL_SERVER_END && haveECDSAsig) { + if (side == WOLFSSL_SERVER_END && haveECDSAsig) { haveRSAsig = 0; /* can't have RSA sig if signed by ECDSA */ (void)haveRSAsig; /* non ecc builds won't read */ } -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (pv.major == DTLS_MAJOR) { tls = 1; tls1_2 = pv.minor <= DTLSv1_2_MINOR; @@ -718,7 +718,7 @@ void InitSuites(Suites* suites, ProtocolVersion pv, byte haveRSA, byte havePSK, #endif #ifdef HAVE_RENEGOTIATION_INDICATION - if (side == CYASSL_CLIENT_END) { + if (side == WOLFSSL_CLIENT_END) { suites->suites[idx++] = 0; suites->suites[idx++] = TLS_EMPTY_RENEGOTIATION_INFO_SCSV; } @@ -1398,7 +1398,7 @@ void InitSuites(Suites* suites, ProtocolVersion pv, byte haveRSA, byte havePSK, #ifndef NO_CERTS -void InitX509Name(CYASSL_X509_NAME* name, int dynamicFlag) +void InitX509Name(WOLFSSL_X509_NAME* name, int dynamicFlag) { (void)dynamicFlag; @@ -1412,7 +1412,7 @@ void InitX509Name(CYASSL_X509_NAME* name, int dynamicFlag) } -void FreeX509Name(CYASSL_X509_NAME* name) +void FreeX509Name(WOLFSSL_X509_NAME* name) { if (name != NULL) { if (name->dynamicName) @@ -1425,8 +1425,8 @@ void FreeX509Name(CYASSL_X509_NAME* name) } -/* Initialize CyaSSL X509 type */ -void InitX509(CYASSL_X509* x509, int dynamicFlag) +/* Initialize wolfSSL X509 type */ +void InitX509(WOLFSSL_X509* x509, int dynamicFlag) { InitX509Name(&x509->issuer, 0); InitX509Name(&x509->subject, 0); @@ -1459,16 +1459,16 @@ void InitX509(CYASSL_X509* x509, int dynamicFlag) x509->keyUsageSet = 0; x509->keyUsageCrit = 0; x509->keyUsage = 0; - #ifdef CYASSL_SEP + #ifdef WOLFSSL_SEP x509->certPolicySet = 0; x509->certPolicyCrit = 0; - #endif /* CYASSL_SEP */ + #endif /* WOLFSSL_SEP */ #endif /* OPENSSL_EXTRA */ } -/* Free CyaSSL X509 type */ -void FreeX509(CYASSL_X509* x509) +/* Free wolfSSL X509 type */ +void FreeX509(WOLFSSL_X509* x509) { if (x509 == NULL) return; @@ -1494,7 +1494,7 @@ void FreeX509(CYASSL_X509* x509) /* init everything to 0, NULL, default values before calling anything that may fail so that desctructor has a "good" state to cleanup */ -int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx) +int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx) { int ret; byte haveRSA = 0; @@ -1586,7 +1586,7 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx) ssl->IOCB_ReadCtx = &ssl->nxCtx; /* default NetX IO ctx, same for read */ ssl->IOCB_WriteCtx = &ssl->nxCtx; /* and write */ #endif -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS ssl->IOCB_CookieCtx = NULL; /* we don't use for default cb */ ssl->dtls_expected_rx = MAX_MTU; ssl->keys.dtls_state.window = 0; @@ -1611,7 +1611,7 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx) ssl->options.closeNotify = 0; ssl->options.sentNotify = 0; ssl->options.usingCompression = 0; - if (ssl->options.side == CYASSL_SERVER_END) + if (ssl->options.side == WOLFSSL_SERVER_END) ssl->options.haveDH = ctx->haveDH; else ssl->options.haveDH = 0; @@ -1642,7 +1642,7 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx) ssl->options.handShakeDone = 0; ssl->options.processReply = doProcessInit; -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS ssl->keys.dtls_sequence_number = 0; ssl->keys.dtls_state.curSeq = 0; ssl->keys.dtls_state.nextSeq = 0; @@ -1695,7 +1695,7 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx) ssl->buffers.certificate = ctx->certificate; ssl->buffers.certChain = ctx->certChain; ssl->buffers.key = ctx->privateKey; - if (ssl->options.side == CYASSL_SERVER_END) { + if (ssl->options.side == WOLFSSL_SERVER_END) { ssl->buffers.serverDH_P = ctx->serverDH_P; ssl->buffers.serverDH_G = ctx->serverDH_G; } @@ -1705,7 +1705,7 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx) ssl->buffers.weOwnKey = 0; ssl->buffers.weOwnDH = 0; -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS ssl->buffers.dtlsCtx.fd = -1; ssl->buffers.dtlsCtx.peer.sa = NULL; ssl->buffers.dtlsCtx.peer.sz = 0; @@ -1736,7 +1736,7 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx) ssl->ex_data[2] = 0; #endif -#ifdef CYASSL_CALLBACKS +#ifdef WOLFSSL_CALLBACKS ssl->hsInfoOn = 0; ssl->toInfoOn = 0; #endif @@ -1756,7 +1756,7 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx) #ifdef HAVE_SECURE_RENEGOTIATION ssl->secure_renegotiation = NULL; #endif -#if !defined(NO_CYASSL_CLIENT) && defined(HAVE_SESSION_TICKET) +#if !defined(NO_WOLFSSL_CLIENT) && defined(HAVE_SESSION_TICKET) ssl->session_ticket_cb = NULL; ssl->session_ticket_ctx = NULL; ssl->expect_session_ticket = 0; @@ -1814,7 +1814,7 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx) return ret; } #endif -#ifdef CYASSL_SHA384 +#ifdef WOLFSSL_SHA384 ret = InitSha384(&ssl->hashSha384); if (ret != 0) { return ret; @@ -1823,7 +1823,7 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx) /* increment CTX reference count */ if (LockMutex(&ctx->countMutex) != 0) { - CYASSL_MSG("Couldn't lock CTX count mutex"); + WOLFSSL_MSG("Couldn't lock CTX count mutex"); return BAD_MUTEX_E; } ctx->refCount++; @@ -1833,7 +1833,7 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx) ssl->arrays = (Arrays*)XMALLOC(sizeof(Arrays), ssl->heap, DYNAMIC_TYPE_ARRAYS); if (ssl->arrays == NULL) { - CYASSL_MSG("Arrays Memory error"); + WOLFSSL_MSG("Arrays Memory error"); return MEMORY_E; } XMEMSET(ssl->arrays, 0, sizeof(Arrays)); @@ -1848,19 +1848,19 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx) ssl->arrays->server_hint[0] = 0; #endif /* NO_PSK */ -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS ssl->arrays->cookieSz = 0; #endif /* RNG */ ssl->rng = (RNG*)XMALLOC(sizeof(RNG), ssl->heap, DYNAMIC_TYPE_RNG); if (ssl->rng == NULL) { - CYASSL_MSG("RNG Memory error"); + WOLFSSL_MSG("RNG Memory error"); return MEMORY_E; } if ( (ret = InitRng(ssl->rng)) != 0) { - CYASSL_MSG("RNG Init error"); + WOLFSSL_MSG("RNG Init error"); return ret; } @@ -1868,7 +1868,7 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx) ssl->suites = (Suites*)XMALLOC(sizeof(Suites), ssl->heap, DYNAMIC_TYPE_SUITES); if (ssl->suites == NULL) { - CYASSL_MSG("Suites Memory error"); + WOLFSSL_MSG("Suites Memory error"); return MEMORY_E; } *ssl->suites = ctx->suites; @@ -1878,7 +1878,7 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx) ssl->peerRsaKey = (RsaKey*)XMALLOC(sizeof(RsaKey), ssl->heap, DYNAMIC_TYPE_RSA); if (ssl->peerRsaKey == NULL) { - CYASSL_MSG("PeerRsaKey Memory error"); + WOLFSSL_MSG("PeerRsaKey Memory error"); return MEMORY_E; } ret = InitRsaKey(ssl->peerRsaKey, ctx->heap); @@ -1886,9 +1886,9 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx) #endif #ifndef NO_CERTS /* make sure server has cert and key unless using PSK or Anon */ - if (ssl->options.side == CYASSL_SERVER_END && !havePSK && !haveAnon) + if (ssl->options.side == WOLFSSL_SERVER_END && !havePSK && !haveAnon) if (!ssl->buffers.certificate.buffer || !ssl->buffers.key.buffer) { - CYASSL_MSG("Server missing certificate and/or private key"); + WOLFSSL_MSG("Server missing certificate and/or private key"); return NO_PRIVATE_KEY; } #endif @@ -1896,25 +1896,25 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx) ssl->peerEccKey = (ecc_key*)XMALLOC(sizeof(ecc_key), ctx->heap, DYNAMIC_TYPE_ECC); if (ssl->peerEccKey == NULL) { - CYASSL_MSG("PeerEccKey Memory error"); + WOLFSSL_MSG("PeerEccKey Memory error"); return MEMORY_E; } ssl->peerEccDsaKey = (ecc_key*)XMALLOC(sizeof(ecc_key), ctx->heap, DYNAMIC_TYPE_ECC); if (ssl->peerEccDsaKey == NULL) { - CYASSL_MSG("PeerEccDsaKey Memory error"); + WOLFSSL_MSG("PeerEccDsaKey Memory error"); return MEMORY_E; } ssl->eccDsaKey = (ecc_key*)XMALLOC(sizeof(ecc_key), ctx->heap, DYNAMIC_TYPE_ECC); if (ssl->eccDsaKey == NULL) { - CYASSL_MSG("EccDsaKey Memory error"); + WOLFSSL_MSG("EccDsaKey Memory error"); return MEMORY_E; } ssl->eccTempKey = (ecc_key*)XMALLOC(sizeof(ecc_key), ctx->heap, DYNAMIC_TYPE_ECC); if (ssl->eccTempKey == NULL) { - CYASSL_MSG("EccTempKey Memory error"); + WOLFSSL_MSG("EccTempKey Memory error"); return MEMORY_E; } ecc_init(ssl->peerEccKey); @@ -1928,7 +1928,7 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx) #endif /* make sure server has DH parms, and add PSK if there, add NTRU too */ - if (ssl->options.side == CYASSL_SERVER_END) + if (ssl->options.side == WOLFSSL_SERVER_END) InitSuites(ssl->suites, ssl->version, haveRSA, havePSK, ssl->options.haveDH, ssl->options.haveNTRU, ssl->options.haveECDSAsig, ssl->options.haveStaticECC, @@ -1943,7 +1943,7 @@ int InitSSL(CYASSL* ssl, CYASSL_CTX* ctx) /* free use of temporary arrays */ -void FreeArrays(CYASSL* ssl, int keep) +void FreeArrays(WOLFSSL* ssl, int keep) { if (ssl->arrays && keep) { /* keeps session id for user retrieval */ @@ -1956,7 +1956,7 @@ void FreeArrays(CYASSL* ssl, int keep) /* In case holding SSL object in array and don't want to free actual ssl */ -void SSL_ResourceFree(CYASSL* ssl) +void SSL_ResourceFree(WOLFSSL* ssl) { /* Note: any resources used during the handshake should be released in the * function FreeHandshakeResources(). Be careful with the special cases @@ -1977,7 +1977,7 @@ void SSL_ResourceFree(CYASSL* ssl) XFREE(ssl->buffers.serverDH_Priv.buffer, ssl->heap, DYNAMIC_TYPE_DH); XFREE(ssl->buffers.serverDH_Pub.buffer, ssl->heap, DYNAMIC_TYPE_DH); /* parameters (p,g) may be owned by ctx */ - if (ssl->buffers.weOwnDH || ssl->options.side == CYASSL_CLIENT_END) { + if (ssl->buffers.weOwnDH || ssl->options.side == WOLFSSL_CLIENT_END) { XFREE(ssl->buffers.serverDH_G.buffer, ssl->heap, DYNAMIC_TYPE_DH); XFREE(ssl->buffers.serverDH_P.buffer, ssl->heap, DYNAMIC_TYPE_DH); } @@ -1999,7 +1999,7 @@ void SSL_ResourceFree(CYASSL* ssl) ShrinkInputBuffer(ssl, FORCED_FREE); if (ssl->buffers.outputBuffer.dynamicFlag) ShrinkOutputBuffer(ssl); -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (ssl->dtls_pool != NULL) { DtlsPoolReset(ssl); XFREE(ssl->dtls_pool, ssl->heap, DYNAMIC_TYPE_NONE); @@ -2015,9 +2015,9 @@ void SSL_ResourceFree(CYASSL* ssl) FreeX509(&ssl->peerCert); #endif #if defined(OPENSSL_EXTRA) || defined(GOAHEAD_WS) - CyaSSL_BIO_free(ssl->biord); + wolfSSL_BIO_free(ssl->biord); if (ssl->biord != ssl->biowr) /* in case same as write */ - CyaSSL_BIO_free(ssl->biowr); + wolfSSL_BIO_free(ssl->biowr); #endif #ifdef HAVE_LIBZ FreeStreams(ssl); @@ -2063,12 +2063,12 @@ void SSL_ResourceFree(CYASSL* ssl) /* Free any handshake resources no longer needed */ -void FreeHandshakeResources(CYASSL* ssl) +void FreeHandshakeResources(WOLFSSL* ssl) { #ifdef HAVE_SECURE_RENEGOTIATION if (ssl->secure_renegotiation && ssl->secure_renegotiation->enabled) { - CYASSL_MSG("Secure Renegotiation needs to retain handshake resources"); + WOLFSSL_MSG("Secure Renegotiation needs to retain handshake resources"); return; } #endif @@ -2090,7 +2090,7 @@ void FreeHandshakeResources(CYASSL* ssl) ssl->rng = NULL; } -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS /* DTLS_POOL */ if (ssl->options.dtls && ssl->dtls_pool != NULL) { DtlsPoolReset(ssl); @@ -2163,7 +2163,7 @@ void FreeHandshakeResources(CYASSL* ssl) } -void FreeSSL(CYASSL* ssl) +void FreeSSL(WOLFSSL* ssl) { FreeSSL_Ctx(ssl->ctx); /* will decrement and free underyling CTX if 0 */ SSL_ResourceFree(ssl); @@ -2171,15 +2171,15 @@ void FreeSSL(CYASSL* ssl) } -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS -int DtlsPoolInit(CYASSL* ssl) +int DtlsPoolInit(WOLFSSL* ssl) { if (ssl->dtls_pool == NULL) { DtlsPool *pool = (DtlsPool*)XMALLOC(sizeof(DtlsPool), ssl->heap, DYNAMIC_TYPE_DTLS_POOL); if (pool == NULL) { - CYASSL_MSG("DTLS Buffer Pool Memory error"); + WOLFSSL_MSG("DTLS Buffer Pool Memory error"); return MEMORY_E; } else { @@ -2197,14 +2197,14 @@ int DtlsPoolInit(CYASSL* ssl) } -int DtlsPoolSave(CYASSL* ssl, const byte *src, int sz) +int DtlsPoolSave(WOLFSSL* ssl, const byte *src, int sz) { DtlsPool *pool = ssl->dtls_pool; if (pool != NULL && pool->used < DTLS_POOL_SZ) { buffer *pBuf = &pool->buf[pool->used]; pBuf->buffer = (byte*)XMALLOC(sz, ssl->heap, DYNAMIC_TYPE_DTLS_POOL); if (pBuf->buffer == NULL) { - CYASSL_MSG("DTLS Buffer Memory error"); + WOLFSSL_MSG("DTLS Buffer Memory error"); return MEMORY_ERROR; } XMEMCPY(pBuf->buffer, src, sz); @@ -2215,7 +2215,7 @@ int DtlsPoolSave(CYASSL* ssl, const byte *src, int sz) } -void DtlsPoolReset(CYASSL* ssl) +void DtlsPoolReset(WOLFSSL* ssl) { DtlsPool *pool = ssl->dtls_pool; if (pool != NULL) { @@ -2234,7 +2234,7 @@ void DtlsPoolReset(CYASSL* ssl) } -int DtlsPoolTimeout(CYASSL* ssl) +int DtlsPoolTimeout(WOLFSSL* ssl) { int result = -1; if (ssl->dtls_timeout < ssl->dtls_timeout_max) { @@ -2245,7 +2245,7 @@ int DtlsPoolTimeout(CYASSL* ssl) } -int DtlsPoolSend(CYASSL* ssl) +int DtlsPoolSend(WOLFSSL* ssl) { int ret; DtlsPool *pool = ssl->dtls_pool; @@ -2451,7 +2451,7 @@ DtlsMsg* DtlsMsgInsert(DtlsMsg* head, DtlsMsg* item) return head; } -#endif /* CYASSL_DTLS */ +#endif /* WOLFSSL_DTLS */ #ifndef NO_OLD_TLS @@ -2467,7 +2467,7 @@ ProtocolVersion MakeSSLv3(void) #endif /* NO_OLD_TLS */ -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS ProtocolVersion MakeDTLSv1(void) { @@ -2487,7 +2487,7 @@ ProtocolVersion MakeDTLSv1_2(void) return pv; } -#endif /* CYASSL_DTLS */ +#endif /* WOLFSSL_DTLS */ @@ -2572,7 +2572,7 @@ ProtocolVersion MakeDTLSv1_2(void) return (word32) mqxTime.SECONDS; } -#elif defined(CYASSL_TIRTOS) +#elif defined(WOLFSSL_TIRTOS) word32 LowResTimer(void) { @@ -2603,7 +2603,7 @@ ProtocolVersion MakeDTLSv1_2(void) /* add output to md5 and sha handshake hashes, exclude record header */ -static int HashOutput(CYASSL* ssl, const byte* output, int sz, int ivSz) +static int HashOutput(WOLFSSL* ssl, const byte* output, int sz, int ivSz) { const byte* adj = output + RECORD_HEADER_SZ + ivSz; sz -= RECORD_HEADER_SZ; @@ -2612,7 +2612,7 @@ static int HashOutput(CYASSL* ssl, const byte* output, int sz, int ivSz) if (ssl->fuzzerCb) ssl->fuzzerCb(ssl, output, sz, FUZZ_HASH, ssl->fuzzerCtx); #endif -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (ssl->options.dtls) { adj += DTLS_RECORD_EXTRA; sz -= DTLS_RECORD_EXTRA; @@ -2635,7 +2635,7 @@ static int HashOutput(CYASSL* ssl, const byte* output, int sz, int ivSz) if (ret != 0) return ret; #endif -#ifdef CYASSL_SHA384 +#ifdef WOLFSSL_SHA384 ret = Sha384Update(&ssl->hashSha384, adj, sz); if (ret != 0) return ret; @@ -2647,12 +2647,12 @@ static int HashOutput(CYASSL* ssl, const byte* output, int sz, int ivSz) /* add input to md5 and sha handshake hashes, include handshake header */ -static int HashInput(CYASSL* ssl, const byte* input, int sz) +static int HashInput(WOLFSSL* ssl, const byte* input, int sz) { const byte* adj = input - HANDSHAKE_HEADER_SZ; sz += HANDSHAKE_HEADER_SZ; -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (ssl->options.dtls) { adj -= DTLS_HANDSHAKE_EXTRA; sz += DTLS_HANDSHAKE_EXTRA; @@ -2676,7 +2676,7 @@ static int HashInput(CYASSL* ssl, const byte* input, int sz) if (ret != 0) return ret; #endif -#ifdef CYASSL_SHA384 +#ifdef WOLFSSL_SHA384 ret = Sha384Update(&ssl->hashSha384, adj, sz); if (ret != 0) return ret; @@ -2688,7 +2688,7 @@ static int HashInput(CYASSL* ssl, const byte* input, int sz) /* add record layer header for message */ -static void AddRecordHeader(byte* output, word32 length, byte type, CYASSL* ssl) +static void AddRecordHeader(byte* output, word32 length, byte type, WOLFSSL* ssl) { RecordLayerHeader* rl; @@ -2701,7 +2701,7 @@ static void AddRecordHeader(byte* output, word32 length, byte type, CYASSL* ssl) if (!ssl->options.dtls) c16toa((word16)length, rl->length); else { -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS DtlsRecordLayerHeader* dtls; /* dtls record layer header extensions */ @@ -2716,7 +2716,7 @@ static void AddRecordHeader(byte* output, word32 length, byte type, CYASSL* ssl) /* add handshake header for message */ static void AddHandShakeHeader(byte* output, word32 length, byte type, - CYASSL* ssl) + WOLFSSL* ssl) { HandShakeHeader* hs; (void)ssl; @@ -2725,7 +2725,7 @@ static void AddHandShakeHeader(byte* output, word32 length, byte type, hs = (HandShakeHeader*)output; hs->type = type; c32to24(length, hs->length); /* type and length same for each */ -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (ssl->options.dtls) { DtlsHandShakeHeader* dtls; @@ -2740,13 +2740,13 @@ static void AddHandShakeHeader(byte* output, word32 length, byte type, /* add both headers for handshake message */ -static void AddHeaders(byte* output, word32 length, byte type, CYASSL* ssl) +static void AddHeaders(byte* output, word32 length, byte type, WOLFSSL* ssl) { if (!ssl->options.dtls) { AddRecordHeader(output, length + HANDSHAKE_HEADER_SZ, handshake, ssl); AddHandShakeHeader(output + RECORD_HEADER_SZ, length, type, ssl); } -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS else { AddRecordHeader(output, length+DTLS_HANDSHAKE_HEADER_SZ, handshake,ssl); AddHandShakeHeader(output + DTLS_RECORD_HEADER_SZ, length, type, ssl); @@ -2756,12 +2756,12 @@ static void AddHeaders(byte* output, word32 length, byte type, CYASSL* ssl) /* return bytes received, -1 on error */ -static int Receive(CYASSL* ssl, byte* buf, word32 sz) +static int Receive(WOLFSSL* ssl, byte* buf, word32 sz) { int recvd; if (ssl->ctx->CBIORecv == NULL) { - CYASSL_MSG("Your IO Recv callback is null, please set"); + WOLFSSL_MSG("Your IO Recv callback is null, please set"); return -1; } @@ -2769,13 +2769,13 @@ retry: recvd = ssl->ctx->CBIORecv(ssl, (char *)buf, (int)sz, ssl->IOCB_ReadCtx); if (recvd < 0) switch (recvd) { - case CYASSL_CBIO_ERR_GENERAL: /* general/unknown error */ + case WOLFSSL_CBIO_ERR_GENERAL: /* general/unknown error */ return -1; - case CYASSL_CBIO_ERR_WANT_READ: /* want read, would block */ + case WOLFSSL_CBIO_ERR_WANT_READ: /* want read, would block */ return WANT_READ; - case CYASSL_CBIO_ERR_CONN_RST: /* connection reset */ + case WOLFSSL_CBIO_ERR_CONN_RST: /* connection reset */ #ifdef USE_WINDOWS_API if (ssl->options.dtls) { goto retry; @@ -2784,9 +2784,9 @@ retry: ssl->options.connReset = 1; return -1; - case CYASSL_CBIO_ERR_ISR: /* interrupt */ + case WOLFSSL_CBIO_ERR_ISR: /* interrupt */ /* see if we got our timeout */ - #ifdef CYASSL_CALLBACKS + #ifdef WOLFSSL_CALLBACKS if (ssl->toInfoOn) { struct itimerval timeout; getitimer(ITIMER_REAL, &timeout); @@ -2794,19 +2794,19 @@ retry: timeout.it_value.tv_usec == 0) { XSTRNCPY(ssl->timeoutInfo.timeoutName, "recv() timeout", MAX_TIMEOUT_NAME_SZ); - CYASSL_MSG("Got our timeout"); + WOLFSSL_MSG("Got our timeout"); return WANT_READ; } } #endif goto retry; - case CYASSL_CBIO_ERR_CONN_CLOSE: /* peer closed connection */ + case WOLFSSL_CBIO_ERR_CONN_CLOSE: /* peer closed connection */ ssl->options.isClosed = 1; return -1; - case CYASSL_CBIO_ERR_TIMEOUT: -#ifdef CYASSL_DTLS + case WOLFSSL_CBIO_ERR_TIMEOUT: +#ifdef WOLFSSL_DTLS if (DtlsPoolTimeout(ssl) == 0 && DtlsPoolSend(ssl) == 0) goto retry; else @@ -2822,9 +2822,9 @@ retry: /* Switch dynamic output buffer back to static, buffer is assumed clear */ -void ShrinkOutputBuffer(CYASSL* ssl) +void ShrinkOutputBuffer(WOLFSSL* ssl) { - CYASSL_MSG("Shrinking output buffer\n"); + WOLFSSL_MSG("Shrinking output buffer\n"); XFREE(ssl->buffers.outputBuffer.buffer - ssl->buffers.outputBuffer.offset, ssl->heap, DYNAMIC_TYPE_OUT_BUFFER); ssl->buffers.outputBuffer.buffer = ssl->buffers.outputBuffer.staticBuffer; @@ -2836,14 +2836,14 @@ void ShrinkOutputBuffer(CYASSL* ssl) /* Switch dynamic input buffer back to static, keep any remaining input */ /* forced free means cleaning up */ -void ShrinkInputBuffer(CYASSL* ssl, int forcedFree) +void ShrinkInputBuffer(WOLFSSL* ssl, int forcedFree) { int usedLength = ssl->buffers.inputBuffer.length - ssl->buffers.inputBuffer.idx; if (!forcedFree && usedLength > STATIC_BUFFER_LEN) return; - CYASSL_MSG("Shrinking input buffer\n"); + WOLFSSL_MSG("Shrinking input buffer\n"); if (!forcedFree && usedLength) XMEMCPY(ssl->buffers.inputBuffer.staticBuffer, @@ -2861,10 +2861,10 @@ void ShrinkInputBuffer(CYASSL* ssl, int forcedFree) } -int SendBuffered(CYASSL* ssl) +int SendBuffered(WOLFSSL* ssl) { if (ssl->ctx->CBIOSend == NULL) { - CYASSL_MSG("Your IO Send callback is null, please set"); + WOLFSSL_MSG("Your IO Send callback is null, please set"); return SOCKET_ERROR_E; } @@ -2877,16 +2877,16 @@ int SendBuffered(CYASSL* ssl) if (sent < 0) { switch (sent) { - case CYASSL_CBIO_ERR_WANT_WRITE: /* would block */ + case WOLFSSL_CBIO_ERR_WANT_WRITE: /* would block */ return WANT_WRITE; - case CYASSL_CBIO_ERR_CONN_RST: /* connection reset */ + case WOLFSSL_CBIO_ERR_CONN_RST: /* connection reset */ ssl->options.connReset = 1; break; - case CYASSL_CBIO_ERR_ISR: /* interrupt */ + case WOLFSSL_CBIO_ERR_ISR: /* interrupt */ /* see if we got our timeout */ - #ifdef CYASSL_CALLBACKS + #ifdef WOLFSSL_CALLBACKS if (ssl->toInfoOn) { struct itimerval timeout; getitimer(ITIMER_REAL, &timeout); @@ -2894,14 +2894,14 @@ int SendBuffered(CYASSL* ssl) timeout.it_value.tv_usec == 0) { XSTRNCPY(ssl->timeoutInfo.timeoutName, "send() timeout", MAX_TIMEOUT_NAME_SZ); - CYASSL_MSG("Got our timeout"); + WOLFSSL_MSG("Got our timeout"); return WANT_WRITE; } } #endif continue; - case CYASSL_CBIO_ERR_CONN_CLOSE: /* epipe / conn closed */ + case WOLFSSL_CBIO_ERR_CONN_CLOSE: /* epipe / conn closed */ ssl->options.connReset = 1; /* treat same as reset */ break; @@ -2913,7 +2913,7 @@ int SendBuffered(CYASSL* ssl) } if (sent > (int)ssl->buffers.outputBuffer.length) { - CYASSL_MSG("SendBuffered() out of bounds read"); + WOLFSSL_MSG("SendBuffered() out of bounds read"); return SEND_OOB_READ_E; } @@ -2931,12 +2931,12 @@ int SendBuffered(CYASSL* ssl) /* Grow the output buffer */ -static INLINE int GrowOutputBuffer(CYASSL* ssl, int size) +static INLINE int GrowOutputBuffer(WOLFSSL* ssl, int size) { byte* tmp; byte hdrSz = ssl->options.dtls ? DTLS_RECORD_HEADER_SZ : RECORD_HEADER_SZ; - byte align = CYASSL_GENERAL_ALIGNMENT; + byte align = WOLFSSL_GENERAL_ALIGNMENT; /* the encrypted data will be offset from the front of the buffer by the header, if the user wants encrypted alignment they need to define their alignment requirement */ @@ -2948,7 +2948,7 @@ static INLINE int GrowOutputBuffer(CYASSL* ssl, int size) tmp = (byte*) XMALLOC(size + ssl->buffers.outputBuffer.length + align, ssl->heap, DYNAMIC_TYPE_OUT_BUFFER); - CYASSL_MSG("growing output buffer\n"); + WOLFSSL_MSG("growing output buffer\n"); if (!tmp) return MEMORY_E; if (align) @@ -2975,11 +2975,11 @@ static INLINE int GrowOutputBuffer(CYASSL* ssl, int size) /* Grow the input buffer, should only be to read cert or big app data */ -int GrowInputBuffer(CYASSL* ssl, int size, int usedLength) +int GrowInputBuffer(WOLFSSL* ssl, int size, int usedLength) { byte* tmp; byte hdrSz = DTLS_RECORD_HEADER_SZ; - byte align = ssl->options.dtls ? CYASSL_GENERAL_ALIGNMENT : 0; + byte align = ssl->options.dtls ? WOLFSSL_GENERAL_ALIGNMENT : 0; /* the encrypted data will be offset from the front of the buffer by the dtls record header, if the user wants encrypted alignment they need to define their alignment requirement. in tls we read record header @@ -2991,7 +2991,7 @@ int GrowInputBuffer(CYASSL* ssl, int size, int usedLength) } tmp = (byte*) XMALLOC(size + usedLength + align, ssl->heap, DYNAMIC_TYPE_IN_BUFFER); - CYASSL_MSG("growing input buffer\n"); + WOLFSSL_MSG("growing input buffer\n"); if (!tmp) return MEMORY_E; if (align) @@ -3020,11 +3020,11 @@ int GrowInputBuffer(CYASSL* ssl, int size, int usedLength) /* check available size into output buffer, make room if needed */ -int CheckAvailableSize(CYASSL *ssl, int size) +int CheckAvailableSize(WOLFSSL *ssl, int size) { if (size < 0) { - CYASSL_MSG("CheckAvailableSize() called with negative number"); + WOLFSSL_MSG("CheckAvailableSize() called with negative number"); return BAD_FUNC_ARG; } @@ -3039,7 +3039,7 @@ int CheckAvailableSize(CYASSL *ssl, int size) /* do all verify and sanity checks on record header */ -static int GetRecordHeader(CYASSL* ssl, const byte* input, word32* inOutIdx, +static int GetRecordHeader(WOLFSSL* ssl, const byte* input, word32* inOutIdx, RecordLayerHeader* rh, word16 *size) { if (!ssl->options.dtls) { @@ -3053,7 +3053,7 @@ static int GetRecordHeader(CYASSL* ssl, const byte* input, word32* inOutIdx, ato16(rh->length, size); } else { -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS /* type and version in same sport */ XMEMCPY(rh, input + *inOutIdx, ENUM_LEN + VERSION_SZ); *inOutIdx += ENUM_LEN + VERSION_SZ; @@ -3074,20 +3074,20 @@ static int GetRecordHeader(CYASSL* ssl, const byte* input, word32* inOutIdx, /* catch version mismatch */ if (rh->pvMajor != ssl->version.major || rh->pvMinor != ssl->version.minor){ - if (ssl->options.side == CYASSL_SERVER_END && + if (ssl->options.side == WOLFSSL_SERVER_END && ssl->options.acceptState == ACCEPT_BEGIN) - CYASSL_MSG("Client attempting to connect with different version"); - else if (ssl->options.side == CYASSL_CLIENT_END && + WOLFSSL_MSG("Client attempting to connect with different version"); + else if (ssl->options.side == WOLFSSL_CLIENT_END && ssl->options.downgrade && ssl->options.connectState < FIRST_REPLY_DONE) - CYASSL_MSG("Server attempting to accept with different version"); + WOLFSSL_MSG("Server attempting to accept with different version"); else { - CYASSL_MSG("SSL version error"); + WOLFSSL_MSG("SSL version error"); return VERSION_ERROR; /* only use requested version */ } } -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (ssl->options.dtls) { if (DtlsCheckWindow(&ssl->keys.dtls_state) != 1) return SEQUENCE_ERROR; @@ -3114,7 +3114,7 @@ static int GetRecordHeader(CYASSL* ssl, const byte* input, word32* inOutIdx, break; case no_type: default: - CYASSL_MSG("Unknown Record Type"); + WOLFSSL_MSG("Unknown Record Type"); return UNKNOWN_RECORD_TYPE; } @@ -3125,7 +3125,7 @@ static int GetRecordHeader(CYASSL* ssl, const byte* input, word32* inOutIdx, } -static int GetHandShakeHeader(CYASSL* ssl, const byte* input, word32* inOutIdx, +static int GetHandShakeHeader(WOLFSSL* ssl, const byte* input, word32* inOutIdx, byte *type, word32 *size, word32 totalSz) { const byte *ptr = input + *inOutIdx; @@ -3142,8 +3142,8 @@ static int GetHandShakeHeader(CYASSL* ssl, const byte* input, word32* inOutIdx, } -#ifdef CYASSL_DTLS -static int GetDtlsHandShakeHeader(CYASSL* ssl, const byte* input, +#ifdef WOLFSSL_DTLS +static int GetDtlsHandShakeHeader(WOLFSSL* ssl, const byte* input, word32* inOutIdx, byte *type, word32 *size, word32 *fragOffset, word32 *fragSz, word32 totalSz) @@ -3190,7 +3190,7 @@ static const byte PAD2[PAD_MD5] = }; /* calculate MD5 hash for finished */ -static void BuildMD5(CYASSL* ssl, Hashes* hashes, const byte* sender) +static void BuildMD5(WOLFSSL* ssl, Hashes* hashes, const byte* sender) { byte md5_result[MD5_DIGEST_SIZE]; @@ -3210,7 +3210,7 @@ static void BuildMD5(CYASSL* ssl, Hashes* hashes, const byte* sender) /* calculate SHA hash for finished */ -static void BuildSHA(CYASSL* ssl, Hashes* hashes, const byte* sender) +static void BuildSHA(WOLFSSL* ssl, Hashes* hashes, const byte* sender) { byte sha_result[SHA_DIGEST_SIZE]; @@ -3230,10 +3230,10 @@ static void BuildSHA(CYASSL* ssl, Hashes* hashes, const byte* sender) #endif -static int BuildFinished(CYASSL* ssl, Hashes* hashes, const byte* sender) +static int BuildFinished(WOLFSSL* ssl, Hashes* hashes, const byte* sender) { int ret = 0; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK #ifndef NO_OLD_TLS #ifndef NO_MD5 Md5* md5 = (Md5*)XMALLOC(sizeof(Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -3246,7 +3246,7 @@ static int BuildFinished(CYASSL* ssl, Hashes* hashes, const byte* sender) Sha256* sha256 = (Sha256*)XMALLOC(sizeof(Sha256), NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 Sha384* sha384 = (Sha384*)XMALLOC(sizeof(Sha384), NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif #else @@ -3261,12 +3261,12 @@ static int BuildFinished(CYASSL* ssl, Hashes* hashes, const byte* sender) #ifndef NO_SHA256 Sha256 sha256[1]; #endif - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 Sha384 sha384[1]; #endif #endif -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK if (ssl == NULL #ifndef NO_OLD_TLS #ifndef NO_MD5 @@ -3279,7 +3279,7 @@ static int BuildFinished(CYASSL* ssl, Hashes* hashes, const byte* sender) #ifndef NO_SHA256 || sha256 == NULL #endif - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 || sha384 == NULL #endif ) { @@ -3294,7 +3294,7 @@ static int BuildFinished(CYASSL* ssl, Hashes* hashes, const byte* sender) #ifndef NO_SHA256 XFREE(sha256, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 XFREE(sha384, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return MEMORY_E; @@ -3313,7 +3313,7 @@ static int BuildFinished(CYASSL* ssl, Hashes* hashes, const byte* sender) #ifndef NO_SHA256 sha256[0] = ssl->hashSha256; #endif -#ifdef CYASSL_SHA384 +#ifdef WOLFSSL_SHA384 sha384[0] = ssl->hashSha384; #endif @@ -3342,12 +3342,12 @@ static int BuildFinished(CYASSL* ssl, Hashes* hashes, const byte* sender) #ifndef NO_SHA256 ssl->hashSha256 = sha256[0]; #endif - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 ssl->hashSha384 = sha384[0]; #endif } -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK #ifndef NO_OLD_TLS #ifndef NO_MD5 XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -3359,7 +3359,7 @@ static int BuildFinished(CYASSL* ssl, Hashes* hashes, const byte* sender) #ifndef NO_SHA256 XFREE(sha256, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif -#ifdef CYASSL_SHA384 +#ifdef WOLFSSL_SHA384 XFREE(sha384, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif #endif @@ -3620,7 +3620,7 @@ static int BuildFinished(CYASSL* ssl, Hashes* hashes, const byte* sender) break; default: - CYASSL_MSG("Unsupported cipher suite, CipherRequires ECC"); + WOLFSSL_MSG("Unsupported cipher suite, CipherRequires ECC"); return 0; } /* switch */ } /* if */ @@ -3812,7 +3812,7 @@ static int BuildFinished(CYASSL* ssl, Hashes* hashes, const byte* sender) #endif default: - CYASSL_MSG("Unsupported cipher suite, CipherRequires"); + WOLFSSL_MSG("Unsupported cipher suite, CipherRequires"); return 0; } /* switch */ } /* if ECC / Normal suites else */ @@ -3879,13 +3879,13 @@ static int CheckAltNames(DecodedCert* dCert, char* domain) int match = 0; DNS_entry* altName = NULL; - CYASSL_MSG("Checking AltNames"); + WOLFSSL_MSG("Checking AltNames"); if (dCert) altName = dCert->altNames; while (altName) { - CYASSL_MSG(" individual AltName check"); + WOLFSSL_MSG(" individual AltName check"); if (MatchDomainName(altName->name,(int)XSTRLEN(altName->name), domain)){ match = 1; @@ -3902,7 +3902,7 @@ static int CheckAltNames(DecodedCert* dCert, char* domain) #if defined(KEEP_PEER_CERT) || defined(SESSION_CERTS) /* Copy parts X509 needs from Decoded cert, 0 on success */ -int CopyDecodedToX509(CYASSL_X509* x509, DecodedCert* dCert) +int CopyDecodedToX509(WOLFSSL_X509* x509, DecodedCert* dCert) { int ret = 0; @@ -3950,7 +3950,7 @@ int CopyDecodedToX509(CYASSL_X509* x509, DecodedCert* dCert) else x509->subjectCN[0] = '\0'; -#ifdef CYASSL_SEP +#ifdef WOLFSSL_SEP { int minSz = min(dCert->deviceTypeSz, EXTERNAL_SERIAL_SIZE); if (minSz > 0) { @@ -3974,7 +3974,7 @@ int CopyDecodedToX509(CYASSL_X509* x509, DecodedCert* dCert) else x509->hwSerialNumSz = 0; } -#endif /* CYASSL_SEP */ +#endif /* WOLFSSL_SEP */ { int minSz = min(dCert->beforeDateLen, MAX_DATE_SZ); if (minSz != 0) { @@ -4068,10 +4068,10 @@ int CopyDecodedToX509(CYASSL_X509* x509, DecodedCert* dCert) } x509->keyUsageSet = dCert->extKeyUsageSet; x509->keyUsageCrit = dCert->extKeyUsageCrit; - #ifdef CYASSL_SEP + #ifdef WOLFSSL_SEP x509->certPolicySet = dCert->extCertPolicySet; x509->certPolicyCrit = dCert->extCertPolicyCrit; - #endif /* CYASSL_SEP */ + #endif /* WOLFSSL_SEP */ #endif /* OPENSSL_EXTRA */ #ifdef HAVE_ECC x509->pkCurveOID = dCert->pkCurveOID; @@ -4083,7 +4083,7 @@ int CopyDecodedToX509(CYASSL_X509* x509, DecodedCert* dCert) #endif /* KEEP_PEER_CERT || SESSION_CERTS */ -static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx, +static int DoCertificate(WOLFSSL* ssl, byte* input, word32* inOutIdx, word32 size) { word32 listSz; @@ -4094,17 +4094,17 @@ static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx, int count; buffer certs[MAX_CHAIN_DEPTH]; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK char* domain = NULL; DecodedCert* dCert = NULL; - CYASSL_X509_STORE_CTX* store = NULL; + WOLFSSL_X509_STORE_CTX* store = NULL; #else char domain[ASN_NAME_MAX]; DecodedCert dCert[1]; - CYASSL_X509_STORE_CTX store[1]; + WOLFSSL_X509_STORE_CTX store[1]; #endif - #ifdef CYASSL_CALLBACKS + #ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("Certificate", &ssl->handShakeInfo); if (ssl->toInfoOn) AddLateName("Certificate", &ssl->timeoutInfo); #endif @@ -4128,7 +4128,7 @@ static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx, if ((*inOutIdx - begin) + listSz != size) return BUFFER_ERROR; - CYASSL_MSG("Loading peer's cert chain"); + WOLFSSL_MSG("Loading peer's cert chain"); /* first put cert chain into buffer so can verify top down we're sent bottom up */ while (listSz) { @@ -4157,7 +4157,7 @@ static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx, input + *inOutIdx, certSz); ssl->session.chain.count++; } else { - CYASSL_MSG("Couldn't store chain cert for session"); + WOLFSSL_MSG("Couldn't store chain cert for session"); } #endif @@ -4165,12 +4165,12 @@ static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx, listSz -= certSz + CERT_HEADER_SZ; totalCerts++; - CYASSL_MSG(" Put another cert into chain"); + WOLFSSL_MSG(" Put another cert into chain"); } count = totalCerts; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK dCert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (dCert == NULL) @@ -4192,40 +4192,40 @@ static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx, #endif if (ret == 0 && dCert->isCA == 0) { - CYASSL_MSG("Chain cert is not a CA, not adding as one"); + WOLFSSL_MSG("Chain cert is not a CA, not adding as one"); } else if (ret == 0 && ssl->options.verifyNone) { - CYASSL_MSG("Chain cert not verified by option, not adding as CA"); + WOLFSSL_MSG("Chain cert not verified by option, not adding as CA"); } else if (ret == 0 && !AlreadySigner(ssl->ctx->cm, subjectHash)) { buffer add; add.length = myCert.length; add.buffer = (byte*)XMALLOC(myCert.length, ssl->heap, DYNAMIC_TYPE_CA); - CYASSL_MSG("Adding CA from chain"); + WOLFSSL_MSG("Adding CA from chain"); if (add.buffer == NULL) return MEMORY_E; XMEMCPY(add.buffer, myCert.buffer, myCert.length); - ret = AddCA(ssl->ctx->cm, add, CYASSL_CHAIN_CA, + ret = AddCA(ssl->ctx->cm, add, WOLFSSL_CHAIN_CA, ssl->ctx->verifyPeer); if (ret == 1) ret = 0; /* SSL_SUCCESS for external */ } else if (ret != 0) { - CYASSL_MSG("Failed to verify CA from chain"); + WOLFSSL_MSG("Failed to verify CA from chain"); } else { - CYASSL_MSG("Verified CA from chain and already had it"); + WOLFSSL_MSG("Verified CA from chain and already had it"); } #ifdef HAVE_CRL if (ret == 0 && ssl->ctx->cm->crlEnabled && ssl->ctx->cm->crlCheckAll) { - CYASSL_MSG("Doing Non Leaf CRL check"); + WOLFSSL_MSG("Doing Non Leaf CRL check"); ret = CheckCertCRL(ssl->ctx->cm->crl, dCert); if (ret != 0) { - CYASSL_MSG("\tCRL check not ok"); + WOLFSSL_MSG("\tCRL check not ok"); } } #endif /* HAVE_CRL */ @@ -4242,27 +4242,27 @@ static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx, buffer myCert = certs[0]; int fatal = 0; - CYASSL_MSG("Verifying Peer's cert"); + WOLFSSL_MSG("Verifying Peer's cert"); InitDecodedCert(dCert, myCert.buffer, myCert.length, ssl->heap); ret = ParseCertRelative(dCert, CERT_TYPE, !ssl->options.verifyNone, ssl->ctx->cm); if (ret == 0) { - CYASSL_MSG("Verified Peer's cert"); + WOLFSSL_MSG("Verified Peer's cert"); fatal = 0; } else if (ret == ASN_PARSE_E) { - CYASSL_MSG("Got Peer cert ASN PARSE ERROR, fatal"); + WOLFSSL_MSG("Got Peer cert ASN PARSE ERROR, fatal"); fatal = 1; } else { - CYASSL_MSG("Failed to verify Peer's cert"); + WOLFSSL_MSG("Failed to verify Peer's cert"); if (ssl->verifyCallback) { - CYASSL_MSG("\tCallback override available, will continue"); + WOLFSSL_MSG("\tCallback override available, will continue"); fatal = 0; } else { - CYASSL_MSG("\tNo callback override available, fatal"); + WOLFSSL_MSG("\tNo callback override available, fatal"); fatal = 1; } } @@ -4276,7 +4276,7 @@ static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx, if (XMEMCMP(dCert->subjectHash, ssl->secure_renegotiation->subject_hash, SHA_DIGEST_SIZE) != 0) { - CYASSL_MSG("Peer sent different cert during scr, fatal"); + WOLFSSL_MSG("Peer sent different cert during scr, fatal"); fatal = 1; ret = SCR_DIFFERENT_CERT_E; } @@ -4294,7 +4294,7 @@ static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx, if (fatal == 0 && ssl->ctx->cm->ocspEnabled) { ret = CheckCertOCSP(ssl->ctx->cm->ocsp, dCert); if (ret != 0) { - CYASSL_MSG("\tOCSP Lookup not ok"); + WOLFSSL_MSG("\tOCSP Lookup not ok"); fatal = 0; } } @@ -4311,11 +4311,11 @@ static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx, #endif /* HAVE_OCSP */ if (doCrlLookup) { - CYASSL_MSG("Doing Leaf CRL check"); + WOLFSSL_MSG("Doing Leaf CRL check"); ret = CheckCertCRL(ssl->ctx->cm->crl, dCert); if (ret != 0) { - CYASSL_MSG("\tCRL check not ok"); + WOLFSSL_MSG("\tCRL check not ok"); fatal = 0; } } @@ -4342,23 +4342,23 @@ static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx, (ssl->specs.sig_algo == ecc_dsa_sa_algo && !ssl->specs.static_ecdh)) && (dCert->extKeyUsage & KEYUSE_DIGITAL_SIG) == 0) { - CYASSL_MSG("KeyUse Digital Sig not set"); + WOLFSSL_MSG("KeyUse Digital Sig not set"); ret = KEYUSE_SIGNATURE_E; } } if (dCert->extExtKeyUsageSet) { - if (ssl->options.side == CYASSL_CLIENT_END) { + if (ssl->options.side == WOLFSSL_CLIENT_END) { if ((dCert->extExtKeyUsage & (EXTKEYUSE_ANY | EXTKEYUSE_SERVER_AUTH)) == 0) { - CYASSL_MSG("ExtKeyUse Server Auth not set"); + WOLFSSL_MSG("ExtKeyUse Server Auth not set"); ret = EXTKEYUSE_AUTH_E; } } else { if ((dCert->extExtKeyUsage & (EXTKEYUSE_ANY | EXTKEYUSE_CLIENT_AUTH)) == 0) { - CYASSL_MSG("ExtKeyUse Client Auth not set"); + WOLFSSL_MSG("ExtKeyUse Client Auth not set"); ret = EXTKEYUSE_AUTH_E; } } @@ -4367,7 +4367,7 @@ static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx, if (fatal) { FreeDecodedCert(dCert); - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(dCert, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif ssl->error = ret; @@ -4375,7 +4375,7 @@ static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx, } ssl->options.havePeerCert = 1; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK domain = (char*)XMALLOC(ASN_NAME_MAX, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (domain == NULL) { FreeDecodedCert(dCert); @@ -4394,10 +4394,10 @@ static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx, if (!ssl->options.verifyNone && ssl->buffers.domainName.buffer) { if (MatchDomainName(dCert->subjectCN, dCert->subjectCNLen, (char*)ssl->buffers.domainName.buffer) == 0) { - CYASSL_MSG("DomainName match on common name failed"); + WOLFSSL_MSG("DomainName match on common name failed"); if (CheckAltNames(dCert, (char*)ssl->buffers.domainName.buffer) == 0 ) { - CYASSL_MSG("DomainName match on alt names failed too"); + WOLFSSL_MSG("DomainName match on alt names failed too"); ret = DOMAIN_NAME_MISMATCH; /* try to get peer key still */ } } @@ -4497,10 +4497,10 @@ static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx, FreeDecodedCert(dCert); } -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(dCert, NULL, DYNAMIC_TYPE_TMP_BUFFER); - store = (CYASSL_X509_STORE_CTX*)XMALLOC(sizeof(CYASSL_X509_STORE_CTX), + store = (WOLFSSL_X509_STORE_CTX*)XMALLOC(sizeof(WOLFSSL_X509_STORE_CTX), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (store == NULL) { XFREE(domain, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -4535,12 +4535,12 @@ static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx, #endif ok = ssl->verifyCallback(0, store); if (ok) { - CYASSL_MSG("Verify callback overriding error!"); + WOLFSSL_MSG("Verify callback overriding error!"); ret = 0; } #ifdef SESSION_CERTS if (store->discardSessionCerts) { - CYASSL_MSG("Verify callback requested discard sess certs"); + WOLFSSL_MSG("Verify callback requested discard sess certs"); ssl->session.chain.count = 0; } #endif @@ -4552,7 +4552,7 @@ static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx, } ssl->error = ret; } -#ifdef CYASSL_ALWAYS_VERIFY_CB +#ifdef WOLFSSL_ALWAYS_VERIFY_CB else { if (ssl->verifyCallback) { int ok; @@ -4569,14 +4569,14 @@ static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx, ok = ssl->verifyCallback(1, store); if (!ok) { - CYASSL_MSG("Verify callback overriding valid certificate!"); + WOLFSSL_MSG("Verify callback overriding valid certificate!"); ret = -1; SendAlert(ssl, alert_fatal, bad_certificate); ssl->options.isClosed = 1; } #ifdef SESSION_CERTS if (store->discardSessionCerts) { - CYASSL_MSG("Verify callback requested discard sess certs"); + WOLFSSL_MSG("Verify callback requested discard sess certs"); ssl->session.chain.count = 0; } #endif @@ -4586,18 +4586,18 @@ static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx, if (ssl->options.verifyNone && (ret == CRL_MISSING || ret == CRL_CERT_REVOKED)) { - CYASSL_MSG("Ignoring CRL problem based on verify setting"); + WOLFSSL_MSG("Ignoring CRL problem based on verify setting"); ret = ssl->error = 0; } - if (ret == 0 && ssl->options.side == CYASSL_CLIENT_END) + if (ret == 0 && ssl->options.side == WOLFSSL_CLIENT_END) ssl->options.serverState = SERVER_CERT_COMPLETE; if (ssl->keys.encryptionOn) { *inOutIdx += ssl->keys.padSz; } -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(store, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(domain, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -4608,7 +4608,7 @@ static int DoCertificate(CYASSL* ssl, byte* input, word32* inOutIdx, #endif /* !NO_CERTS */ -static int DoHelloRequest(CYASSL* ssl, const byte* input, word32* inOutIdx, +static int DoHelloRequest(WOLFSSL* ssl, const byte* input, word32* inOutIdx, word32 size, word32 totalSz) { (void)input; @@ -4624,7 +4624,7 @@ static int DoHelloRequest(CYASSL* ssl, const byte* input, word32* inOutIdx, *inOutIdx += ssl->keys.padSz; } - if (ssl->options.side == CYASSL_SERVER_END) { + if (ssl->options.side == WOLFSSL_SERVER_END) { SendAlert(ssl, alert_fatal, unexpected_message); /* try */ return FATAL_ERROR; } @@ -4640,7 +4640,7 @@ static int DoHelloRequest(CYASSL* ssl, const byte* input, word32* inOutIdx, } -int DoFinished(CYASSL* ssl, const byte* input, word32* inOutIdx, word32 size, +int DoFinished(WOLFSSL* ssl, const byte* input, word32* inOutIdx, word32 size, word32 totalSz, int sniff) { word32 finishedSz = (ssl->options.tls ? TLS_FINISHED_SZ : FINISHED_SZ); @@ -4652,14 +4652,14 @@ int DoFinished(CYASSL* ssl, const byte* input, word32* inOutIdx, word32 size, if (*inOutIdx + size + ssl->keys.padSz > totalSz) return BUFFER_E; - #ifdef CYASSL_CALLBACKS + #ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("Finished", &ssl->handShakeInfo); if (ssl->toInfoOn) AddLateName("Finished", &ssl->timeoutInfo); #endif if (sniff == NO_SNIFF) { if (XMEMCMP(input + *inOutIdx, &ssl->verifyHashes, size) != 0) { - CYASSL_MSG("Verify finished error on hashes"); + WOLFSSL_MSG("Verify finished error on hashes"); return VERIFY_FINISHED_ERROR; } } @@ -4667,7 +4667,7 @@ int DoFinished(CYASSL* ssl, const byte* input, word32* inOutIdx, word32 size, #ifdef HAVE_SECURE_RENEGOTIATION if (ssl->secure_renegotiation) { /* save peer's state */ - if (ssl->options.side == CYASSL_CLIENT_END) + if (ssl->options.side == WOLFSSL_CLIENT_END) XMEMCPY(ssl->secure_renegotiation->server_verify_data, input + *inOutIdx, TLS_FINISHED_SZ); else @@ -4679,13 +4679,13 @@ int DoFinished(CYASSL* ssl, const byte* input, word32* inOutIdx, word32 size, /* force input exhaustion at ProcessReply consuming padSz */ *inOutIdx += size + ssl->keys.padSz; - if (ssl->options.side == CYASSL_CLIENT_END) { + if (ssl->options.side == WOLFSSL_CLIENT_END) { ssl->options.serverState = SERVER_FINISHED_COMPLETE; if (!ssl->options.resuming) { ssl->options.handShakeState = HANDSHAKE_DONE; ssl->options.handShakeDone = 1; -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (ssl->options.dtls) { /* Other side has received our Finished, go to next epoch */ ssl->keys.dtls_epoch++; @@ -4700,7 +4700,7 @@ int DoFinished(CYASSL* ssl, const byte* input, word32* inOutIdx, word32 size, ssl->options.handShakeState = HANDSHAKE_DONE; ssl->options.handShakeDone = 1; -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (ssl->options.dtls) { /* Other side has received our Finished, go to next epoch */ ssl->keys.dtls_epoch++; @@ -4715,15 +4715,15 @@ int DoFinished(CYASSL* ssl, const byte* input, word32* inOutIdx, word32 size, /* Make sure no duplicates, no fast forward, or other problems; 0 on success */ -static int SanityCheckMsgReceived(CYASSL* ssl, byte type) +static int SanityCheckMsgReceived(WOLFSSL* ssl, byte type) { /* verify not a duplicate, mark received, check state */ switch (type) { -#ifndef NO_CYASSL_CLIENT +#ifndef NO_WOLFSSL_CLIENT case hello_request: if (ssl->msgsReceived.got_hello_request) { - CYASSL_MSG("Duplicate HelloRequest received"); + WOLFSSL_MSG("Duplicate HelloRequest received"); return DUPLICATE_MSG_E; } ssl->msgsReceived.got_hello_request = 1; @@ -4731,10 +4731,10 @@ static int SanityCheckMsgReceived(CYASSL* ssl, byte type) break; #endif -#ifndef NO_CYASSL_SERVER +#ifndef NO_WOLFSSL_SERVER case client_hello: if (ssl->msgsReceived.got_client_hello) { - CYASSL_MSG("Duplicate ClientHello received"); + WOLFSSL_MSG("Duplicate ClientHello received"); return DUPLICATE_MSG_E; } ssl->msgsReceived.got_client_hello = 1; @@ -4742,10 +4742,10 @@ static int SanityCheckMsgReceived(CYASSL* ssl, byte type) break; #endif -#ifndef NO_CYASSL_CLIENT +#ifndef NO_WOLFSSL_CLIENT case server_hello: if (ssl->msgsReceived.got_server_hello) { - CYASSL_MSG("Duplicate ServerHello received"); + WOLFSSL_MSG("Duplicate ServerHello received"); return DUPLICATE_MSG_E; } ssl->msgsReceived.got_server_hello = 1; @@ -4753,10 +4753,10 @@ static int SanityCheckMsgReceived(CYASSL* ssl, byte type) break; #endif -#ifndef NO_CYASSL_CLIENT +#ifndef NO_WOLFSSL_CLIENT case hello_verify_request: if (ssl->msgsReceived.got_hello_verify_request) { - CYASSL_MSG("Duplicate HelloVerifyRequest received"); + WOLFSSL_MSG("Duplicate HelloVerifyRequest received"); return DUPLICATE_MSG_E; } ssl->msgsReceived.got_hello_verify_request = 1; @@ -4764,10 +4764,10 @@ static int SanityCheckMsgReceived(CYASSL* ssl, byte type) break; #endif -#ifndef NO_CYASSL_CLIENT +#ifndef NO_WOLFSSL_CLIENT case session_ticket: if (ssl->msgsReceived.got_session_ticket) { - CYASSL_MSG("Duplicate SessionTicket received"); + WOLFSSL_MSG("Duplicate SessionTicket received"); return DUPLICATE_MSG_E; } ssl->msgsReceived.got_session_ticket = 1; @@ -4777,49 +4777,49 @@ static int SanityCheckMsgReceived(CYASSL* ssl, byte type) case certificate: if (ssl->msgsReceived.got_certificate) { - CYASSL_MSG("Duplicate Certificate received"); + WOLFSSL_MSG("Duplicate Certificate received"); return DUPLICATE_MSG_E; } ssl->msgsReceived.got_certificate = 1; -#ifndef NO_CYASSL_CLIENT - if (ssl->options.side == CYASSL_CLIENT_END) { +#ifndef NO_WOLFSSL_CLIENT + if (ssl->options.side == WOLFSSL_CLIENT_END) { if ( ssl->msgsReceived.got_server_hello == 0) { - CYASSL_MSG("No ServerHello before Cert"); + WOLFSSL_MSG("No ServerHello before Cert"); return OUT_OF_ORDER_E; } } #endif -#ifndef NO_CYASSL_SERVER - if (ssl->options.side == CYASSL_SERVER_END) { +#ifndef NO_WOLFSSL_SERVER + if (ssl->options.side == WOLFSSL_SERVER_END) { if ( ssl->msgsReceived.got_client_hello == 0) { - CYASSL_MSG("No ClientHello before Cert"); + WOLFSSL_MSG("No ClientHello before Cert"); return OUT_OF_ORDER_E; } } #endif break; -#ifndef NO_CYASSL_CLIENT +#ifndef NO_WOLFSSL_CLIENT case server_key_exchange: if (ssl->msgsReceived.got_server_key_exchange) { - CYASSL_MSG("Duplicate ServerKeyExchange received"); + WOLFSSL_MSG("Duplicate ServerKeyExchange received"); return DUPLICATE_MSG_E; } ssl->msgsReceived.got_server_key_exchange = 1; if ( ssl->msgsReceived.got_server_hello == 0) { - CYASSL_MSG("No ServerHello before Cert"); + WOLFSSL_MSG("No ServerHello before Cert"); return OUT_OF_ORDER_E; } break; #endif -#ifndef NO_CYASSL_CLIENT +#ifndef NO_WOLFSSL_CLIENT case certificate_request: if (ssl->msgsReceived.got_certificate_request) { - CYASSL_MSG("Duplicate CertificateRequest received"); + WOLFSSL_MSG("Duplicate CertificateRequest received"); return DUPLICATE_MSG_E; } ssl->msgsReceived.got_certificate_request = 1; @@ -4827,10 +4827,10 @@ static int SanityCheckMsgReceived(CYASSL* ssl, byte type) break; #endif -#ifndef NO_CYASSL_CLIENT +#ifndef NO_WOLFSSL_CLIENT case server_hello_done: if (ssl->msgsReceived.got_server_hello_done) { - CYASSL_MSG("Duplicate ServerHelloDone received"); + WOLFSSL_MSG("Duplicate ServerHelloDone received"); return DUPLICATE_MSG_E; } ssl->msgsReceived.got_server_hello_done = 1; @@ -4839,9 +4839,9 @@ static int SanityCheckMsgReceived(CYASSL* ssl, byte type) if (ssl->specs.kea == psk_kea || ssl->specs.kea == dhe_psk_kea || ssl->options.usingAnon_cipher) { - CYASSL_MSG("No Cert required"); + WOLFSSL_MSG("No Cert required"); } else { - CYASSL_MSG("No Certificate before ServerHelloDone"); + WOLFSSL_MSG("No Certificate before ServerHelloDone"); return OUT_OF_ORDER_E; } } @@ -4849,40 +4849,40 @@ static int SanityCheckMsgReceived(CYASSL* ssl, byte type) if (ssl->specs.static_ecdh == 1 || ssl->specs.kea == rsa_kea || ssl->specs.kea == ntru_kea) { - CYASSL_MSG("No KeyExchange required"); + WOLFSSL_MSG("No KeyExchange required"); } else { - CYASSL_MSG("No ServerKeyExchange before ServerDone"); + WOLFSSL_MSG("No ServerKeyExchange before ServerDone"); return OUT_OF_ORDER_E; } } break; #endif -#ifndef NO_CYASSL_SERVER +#ifndef NO_WOLFSSL_SERVER case certificate_verify: if (ssl->msgsReceived.got_certificate_verify) { - CYASSL_MSG("Duplicate CertificateVerify received"); + WOLFSSL_MSG("Duplicate CertificateVerify received"); return DUPLICATE_MSG_E; } ssl->msgsReceived.got_certificate_verify = 1; if ( ssl->msgsReceived.got_certificate == 0) { - CYASSL_MSG("No Cert before CertVerify"); + WOLFSSL_MSG("No Cert before CertVerify"); return OUT_OF_ORDER_E; } break; #endif -#ifndef NO_CYASSL_SERVER +#ifndef NO_WOLFSSL_SERVER case client_key_exchange: if (ssl->msgsReceived.got_client_key_exchange) { - CYASSL_MSG("Duplicate ClientKeyExchange received"); + WOLFSSL_MSG("Duplicate ClientKeyExchange received"); return DUPLICATE_MSG_E; } ssl->msgsReceived.got_client_key_exchange = 1; if (ssl->msgsReceived.got_client_hello == 0) { - CYASSL_MSG("No ClientHello before ClientKeyExchange"); + WOLFSSL_MSG("No ClientHello before ClientKeyExchange"); return OUT_OF_ORDER_E; } break; @@ -4890,13 +4890,13 @@ static int SanityCheckMsgReceived(CYASSL* ssl, byte type) case finished: if (ssl->msgsReceived.got_finished) { - CYASSL_MSG("Duplicate Finished received"); + WOLFSSL_MSG("Duplicate Finished received"); return DUPLICATE_MSG_E; } ssl->msgsReceived.got_finished = 1; if (ssl->msgsReceived.got_change_cipher == 0) { - CYASSL_MSG("Finished received before ChangeCipher"); + WOLFSSL_MSG("Finished received before ChangeCipher"); return NO_CHANGE_CIPHER_E; } @@ -4904,25 +4904,25 @@ static int SanityCheckMsgReceived(CYASSL* ssl, byte type) case change_cipher_hs: if (ssl->msgsReceived.got_change_cipher) { - CYASSL_MSG("Duplicate ChangeCipher received"); + WOLFSSL_MSG("Duplicate ChangeCipher received"); return DUPLICATE_MSG_E; } ssl->msgsReceived.got_change_cipher = 1; -#ifndef NO_CYASSL_CLIENT - if (ssl->options.side == CYASSL_CLIENT_END) { +#ifndef NO_WOLFSSL_CLIENT + if (ssl->options.side == WOLFSSL_CLIENT_END) { if (!ssl->options.resuming && ssl->msgsReceived.got_server_hello_done == 0) { - CYASSL_MSG("No ServerHelloDone before ChangeCipher"); + WOLFSSL_MSG("No ServerHelloDone before ChangeCipher"); return OUT_OF_ORDER_E; } } #endif -#ifndef NO_CYASSL_SERVER - if (ssl->options.side == CYASSL_SERVER_END) { +#ifndef NO_WOLFSSL_SERVER + if (ssl->options.side == WOLFSSL_SERVER_END) { if (!ssl->options.resuming && ssl->msgsReceived.got_client_key_exchange == 0) { - CYASSL_MSG("No ClientKeyExchange before ChangeCipher"); + WOLFSSL_MSG("No ClientKeyExchange before ChangeCipher"); return OUT_OF_ORDER_E; } } @@ -4931,7 +4931,7 @@ static int SanityCheckMsgReceived(CYASSL* ssl, byte type) break; default: - CYASSL_MSG("Unknown message type"); + WOLFSSL_MSG("Unknown message type"); return SANITY_MSG_E; } @@ -4939,13 +4939,13 @@ static int SanityCheckMsgReceived(CYASSL* ssl, byte type) } -static int DoHandShakeMsgType(CYASSL* ssl, byte* input, word32* inOutIdx, +static int DoHandShakeMsgType(WOLFSSL* ssl, byte* input, word32* inOutIdx, byte type, word32 size, word32 totalSz) { int ret = 0; (void)totalSz; - CYASSL_ENTER("DoHandShakeMsgType"); + WOLFSSL_ENTER("DoHandShakeMsgType"); /* make sure can read the message */ if (*inOutIdx + size > totalSz) @@ -4953,7 +4953,7 @@ static int DoHandShakeMsgType(CYASSL* ssl, byte* input, word32* inOutIdx, /* sanity check msg received */ if ( (ret = SanityCheckMsgReceived(ssl, type)) != 0) { - CYASSL_MSG("Sanity Check on handshake message type received failed"); + WOLFSSL_MSG("Sanity Check on handshake message type received failed"); return ret; } @@ -4963,7 +4963,7 @@ static int DoHandShakeMsgType(CYASSL* ssl, byte* input, word32* inOutIdx, if (ret != 0) return ret; } -#ifdef CYASSL_CALLBACKS +#ifdef WOLFSSL_CALLBACKS /* add name later, add on record and handshake header part back on */ if (ssl->toInfoOn) { int add = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ; @@ -4974,29 +4974,29 @@ static int DoHandShakeMsgType(CYASSL* ssl, byte* input, word32* inOutIdx, #endif if (ssl->options.handShakeState == HANDSHAKE_DONE && type != hello_request){ - CYASSL_MSG("HandShake message after handshake complete"); + WOLFSSL_MSG("HandShake message after handshake complete"); SendAlert(ssl, alert_fatal, unexpected_message); return OUT_OF_ORDER_E; } - if (ssl->options.side == CYASSL_CLIENT_END && ssl->options.dtls == 0 && + if (ssl->options.side == WOLFSSL_CLIENT_END && ssl->options.dtls == 0 && ssl->options.serverState == NULL_STATE && type != server_hello) { - CYASSL_MSG("First server message not server hello"); + WOLFSSL_MSG("First server message not server hello"); SendAlert(ssl, alert_fatal, unexpected_message); return OUT_OF_ORDER_E; } - if (ssl->options.side == CYASSL_CLIENT_END && ssl->options.dtls && + if (ssl->options.side == WOLFSSL_CLIENT_END && ssl->options.dtls && type == server_hello_done && ssl->options.serverState < SERVER_HELLO_COMPLETE) { - CYASSL_MSG("Server hello done received before server hello in DTLS"); + WOLFSSL_MSG("Server hello done received before server hello in DTLS"); SendAlert(ssl, alert_fatal, unexpected_message); return OUT_OF_ORDER_E; } - if (ssl->options.side == CYASSL_SERVER_END && + if (ssl->options.side == WOLFSSL_SERVER_END && ssl->options.clientState == NULL_STATE && type != client_hello) { - CYASSL_MSG("First client message not client hello"); + WOLFSSL_MSG("First client message not client hello"); SendAlert(ssl, alert_fatal, unexpected_message); return OUT_OF_ORDER_E; } @@ -5005,36 +5005,36 @@ static int DoHandShakeMsgType(CYASSL* ssl, byte* input, word32* inOutIdx, switch (type) { case hello_request: - CYASSL_MSG("processing hello request"); + WOLFSSL_MSG("processing hello request"); ret = DoHelloRequest(ssl, input, inOutIdx, size, totalSz); break; -#ifndef NO_CYASSL_CLIENT +#ifndef NO_WOLFSSL_CLIENT case hello_verify_request: - CYASSL_MSG("processing hello verify request"); + WOLFSSL_MSG("processing hello verify request"); ret = DoHelloVerifyRequest(ssl, input,inOutIdx, size); break; case server_hello: - CYASSL_MSG("processing server hello"); + WOLFSSL_MSG("processing server hello"); ret = DoServerHello(ssl, input, inOutIdx, size); break; #ifndef NO_CERTS case certificate_request: - CYASSL_MSG("processing certificate request"); + WOLFSSL_MSG("processing certificate request"); ret = DoCertificateRequest(ssl, input, inOutIdx, size); break; #endif case server_key_exchange: - CYASSL_MSG("processing server key exchange"); + WOLFSSL_MSG("processing server key exchange"); ret = DoServerKeyExchange(ssl, input, inOutIdx, size); break; #ifdef HAVE_SESSION_TICKET case session_ticket: - CYASSL_MSG("processing session ticket"); + WOLFSSL_MSG("processing session ticket"); ret = DoSessionTicket(ssl, input, inOutIdx, size); break; #endif /* HAVE_SESSION_TICKET */ @@ -5042,14 +5042,14 @@ static int DoHandShakeMsgType(CYASSL* ssl, byte* input, word32* inOutIdx, #ifndef NO_CERTS case certificate: - CYASSL_MSG("processing certificate"); + WOLFSSL_MSG("processing certificate"); ret = DoCertificate(ssl, input, inOutIdx, size); break; #endif case server_hello_done: - CYASSL_MSG("processing server hello done"); - #ifdef CYASSL_CALLBACKS + WOLFSSL_MSG("processing server hello done"); + #ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("ServerHelloDone", &ssl->handShakeInfo); if (ssl->toInfoOn) @@ -5062,61 +5062,61 @@ static int DoHandShakeMsgType(CYASSL* ssl, byte* input, word32* inOutIdx, break; case finished: - CYASSL_MSG("processing finished"); + WOLFSSL_MSG("processing finished"); ret = DoFinished(ssl, input, inOutIdx, size, totalSz, NO_SNIFF); break; -#ifndef NO_CYASSL_SERVER +#ifndef NO_WOLFSSL_SERVER case client_hello: - CYASSL_MSG("processing client hello"); + WOLFSSL_MSG("processing client hello"); ret = DoClientHello(ssl, input, inOutIdx, size); break; case client_key_exchange: - CYASSL_MSG("processing client key exchange"); + WOLFSSL_MSG("processing client key exchange"); ret = DoClientKeyExchange(ssl, input, inOutIdx, size); break; #if !defined(NO_RSA) || defined(HAVE_ECC) case certificate_verify: - CYASSL_MSG("processing certificate verify"); + WOLFSSL_MSG("processing certificate verify"); ret = DoCertificateVerify(ssl, input, inOutIdx, size); break; #endif /* !NO_RSA || HAVE_ECC */ -#endif /* !NO_CYASSL_SERVER */ +#endif /* !NO_WOLFSSL_SERVER */ default: - CYASSL_MSG("Unknown handshake message type"); + WOLFSSL_MSG("Unknown handshake message type"); ret = UNKNOWN_HANDSHAKE_TYPE; break; } - CYASSL_LEAVE("DoHandShakeMsgType()", ret); + WOLFSSL_LEAVE("DoHandShakeMsgType()", ret); return ret; } -static int DoHandShakeMsg(CYASSL* ssl, byte* input, word32* inOutIdx, +static int DoHandShakeMsg(WOLFSSL* ssl, byte* input, word32* inOutIdx, word32 totalSz) { byte type; word32 size; int ret = 0; - CYASSL_ENTER("DoHandShakeMsg()"); + WOLFSSL_ENTER("DoHandShakeMsg()"); if (GetHandShakeHeader(ssl, input, inOutIdx, &type, &size, totalSz) != 0) return PARSE_ERROR; ret = DoHandShakeMsgType(ssl, input, inOutIdx, type, size, totalSz); - CYASSL_LEAVE("DoHandShakeMsg()", ret); + WOLFSSL_LEAVE("DoHandShakeMsg()", ret); return ret; } -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS static INLINE int DtlsCheckWindow(DtlsState* state) { @@ -5179,7 +5179,7 @@ static INLINE int DtlsUpdateWindow(DtlsState* state) } -static int DtlsMsgDrain(CYASSL* ssl) +static int DtlsMsgDrain(WOLFSSL* ssl) { DtlsMsg* item = ssl->dtls_msg_list; int ret = 0; @@ -5204,7 +5204,7 @@ static int DtlsMsgDrain(CYASSL* ssl) } -static int DoDtlsHandShakeMsg(CYASSL* ssl, byte* input, word32* inOutIdx, +static int DoDtlsHandShakeMsg(WOLFSSL* ssl, byte* input, word32* inOutIdx, word32 totalSz) { byte type; @@ -5212,7 +5212,7 @@ static int DoDtlsHandShakeMsg(CYASSL* ssl, byte* input, word32* inOutIdx, word32 fragOffset, fragSz; int ret = 0; - CYASSL_ENTER("DoDtlsHandShakeMsg()"); + WOLFSSL_ENTER("DoDtlsHandShakeMsg()"); if (GetDtlsHandShakeHeader(ssl, input, inOutIdx, &type, &size, &fragOffset, &fragSz, totalSz) != 0) return PARSE_ERROR; @@ -5266,7 +5266,7 @@ static int DoDtlsHandShakeMsg(CYASSL* ssl, byte* input, word32* inOutIdx, ret = DtlsMsgDrain(ssl); } - CYASSL_LEAVE("DoDtlsHandShakeMsg()", ret); + WOLFSSL_LEAVE("DoDtlsHandShakeMsg()", ret); return ret; } #endif @@ -5274,9 +5274,9 @@ static int DoDtlsHandShakeMsg(CYASSL* ssl, byte* input, word32* inOutIdx, #if !defined(NO_OLD_TLS) || defined(HAVE_CHACHA) || defined(HAVE_AESCCM) \ || defined(HAVE_AESGCM) -static INLINE word32 GetSEQIncrement(CYASSL* ssl, int verify) +static INLINE word32 GetSEQIncrement(WOLFSSL* ssl, int verify) { -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (ssl->options.dtls) { if (verify) return ssl->keys.dtls_state.curSeq; /* explicit from peer */ @@ -5293,7 +5293,7 @@ static INLINE word32 GetSEQIncrement(CYASSL* ssl, int verify) #ifdef HAVE_AEAD -static INLINE void AeadIncrementExpIV(CYASSL* ssl) +static INLINE void AeadIncrementExpIV(WOLFSSL* ssl) { int i; for (i = AEAD_EXP_IV_SZ-1; i >= 0; i--) { @@ -5304,7 +5304,7 @@ static INLINE void AeadIncrementExpIV(CYASSL* ssl) #ifdef HAVE_POLY1305 /*more recent rfc's concatonate input for poly1305 differently*/ -static int Poly1305Tag(CYASSL* ssl, byte* additional, const byte* out, +static int Poly1305Tag(WOLFSSL* ssl, byte* additional, const byte* out, byte* cipher, word16 sz, byte* tag) { int ret = 0; @@ -5363,7 +5363,7 @@ static int Poly1305Tag(CYASSL* ssl, byte* additional, const byte* out, /* Used for the older version of creating AEAD tags with Poly1305 */ -static int Poly1305TagOld(CYASSL* ssl, byte* additional, const byte* out, +static int Poly1305TagOld(WOLFSSL* ssl, byte* additional, const byte* out, byte* cipher, word16 sz, byte* tag) { int ret = 0; @@ -5420,7 +5420,7 @@ static int Poly1305TagOld(CYASSL* ssl, byte* additional, const byte* out, #ifdef HAVE_CHACHA -static int ChachaAEADEncrypt(CYASSL* ssl, byte* out, const byte* input, +static int ChachaAEADEncrypt(WOLFSSL* ssl, byte* out, const byte* input, word16 sz) { const byte* additionalSrc = input - RECORD_HEADER_SZ; @@ -5447,7 +5447,7 @@ static int ChachaAEADEncrypt(CYASSL* ssl, byte* out, const byte* input, /* Store the type, version. Unfortunately, they are in * the input buffer ahead of the plaintext. */ - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { c16toa(ssl->keys.dtls_epoch, additional); additionalSrc -= DTLS_HANDSHAKE_EXTRA; @@ -5524,7 +5524,7 @@ static int ChachaAEADEncrypt(CYASSL* ssl, byte* out, const byte* input, } -static int ChachaAEADDecrypt(CYASSL* ssl, byte* plain, const byte* input, +static int ChachaAEADDecrypt(WOLFSSL* ssl, byte* plain, const byte* input, word16 sz) { byte additional[CHACHA20_BLOCK_SIZE]; @@ -5562,7 +5562,7 @@ static int ChachaAEADDecrypt(CYASSL* ssl, byte* plain, const byte* input, additional[AEAD_VMIN_OFFSET] = ssl->curRL.pvMinor; /* Store the type, version. */ - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) c16toa(ssl->keys.dtls_state.curEpoch, additional); #endif @@ -5605,7 +5605,7 @@ static int ChachaAEADDecrypt(CYASSL* ssl, byte* plain, const byte* input, } if (ret == 1) { - CYASSL_MSG("Mac did not match"); + WOLFSSL_MSG("Mac did not match"); SendAlert(ssl, alert_fatal, bad_record_mac); XMEMSET(nonce, 0, AEAD_NONCE_SZ); return VERIFY_MAC_ERROR; @@ -5632,14 +5632,14 @@ static int ChachaAEADDecrypt(CYASSL* ssl, byte* plain, const byte* input, #endif -static INLINE int Encrypt(CYASSL* ssl, byte* out, const byte* input, word16 sz) +static INLINE int Encrypt(WOLFSSL* ssl, byte* out, const byte* input, word16 sz) { (void)out; (void)input; (void)sz; if (ssl->encrypt.setup == 0) { - CYASSL_MSG("Encrypt ciphers not setup"); + WOLFSSL_MSG("Encrypt ciphers not setup"); return ENCRYPT_ERROR; } @@ -5650,23 +5650,23 @@ static INLINE int Encrypt(CYASSL* ssl, byte* out, const byte* input, word16 sz) switch (ssl->specs.bulk_cipher_algorithm) { #ifdef BUILD_ARC4 - case cyassl_rc4: + case wolfssl_rc4: wc_Arc4Process(ssl->encrypt.arc4, out, input, sz); break; #endif #ifdef BUILD_DES3 - case cyassl_triple_des: + case wolfssl_triple_des: return Des3_CbcEncrypt(ssl->encrypt.des3, out, input, sz); #endif #ifdef BUILD_AES - case cyassl_aes: + case wolfssl_aes: return AesCbcEncrypt(ssl->encrypt.aes, out, input, sz); #endif #ifdef BUILD_AESGCM - case cyassl_aes_gcm: + case wolfssl_aes_gcm: { int gcmRet; byte additional[AEAD_AUTH_DATA_SZ]; @@ -5681,7 +5681,7 @@ static INLINE int Encrypt(CYASSL* ssl, byte* out, const byte* input, word16 sz) /* Store the type, version. Unfortunately, they are in * the input buffer ahead of the plaintext. */ - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { c16toa(ssl->keys.dtls_epoch, additional); additionalSrc -= DTLS_HANDSHAKE_EXTRA; @@ -5713,7 +5713,7 @@ static INLINE int Encrypt(CYASSL* ssl, byte* out, const byte* input, word16 sz) #endif #ifdef HAVE_AESCCM - case cyassl_aes_ccm: + case wolfssl_aes_ccm: { byte additional[AEAD_AUTH_DATA_SZ]; byte nonce[AEAD_NONCE_SZ]; @@ -5727,7 +5727,7 @@ static INLINE int Encrypt(CYASSL* ssl, byte* out, const byte* input, word16 sz) /* Store the type, version. Unfortunately, they are in * the input buffer ahead of the plaintext. */ - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { c16toa(ssl->keys.dtls_epoch, additional); additionalSrc -= DTLS_HANDSHAKE_EXTRA; @@ -5757,28 +5757,28 @@ static INLINE int Encrypt(CYASSL* ssl, byte* out, const byte* input, word16 sz) #endif #ifdef HAVE_CAMELLIA - case cyassl_camellia: + case wolfssl_camellia: CamelliaCbcEncrypt(ssl->encrypt.cam, out, input, sz); break; #endif #ifdef HAVE_HC128 - case cyassl_hc128: + case wolfssl_hc128: return Hc128_Process(ssl->encrypt.hc128, out, input, sz); #endif #ifdef BUILD_RABBIT - case cyassl_rabbit: + case wolfssl_rabbit: return RabbitProcess(ssl->encrypt.rabbit, out, input, sz); #endif #ifdef HAVE_CHACHA - case cyassl_chacha: + case wolfssl_chacha: return ChachaAEADEncrypt(ssl, out, input, sz); #endif #ifdef HAVE_NULL_CIPHER - case cyassl_cipher_null: + case wolfssl_cipher_null: if (input != out) { XMEMMOVE(out, input, sz); } @@ -5786,7 +5786,7 @@ static INLINE int Encrypt(CYASSL* ssl, byte* out, const byte* input, word16 sz) #endif default: - CYASSL_MSG("CyaSSL Encrypt programming error"); + WOLFSSL_MSG("wolfSSL Encrypt programming error"); return ENCRYPT_ERROR; } @@ -5795,7 +5795,7 @@ static INLINE int Encrypt(CYASSL* ssl, byte* out, const byte* input, word16 sz) -static INLINE int Decrypt(CYASSL* ssl, byte* plain, const byte* input, +static INLINE int Decrypt(WOLFSSL* ssl, byte* plain, const byte* input, word16 sz) { (void)plain; @@ -5803,29 +5803,29 @@ static INLINE int Decrypt(CYASSL* ssl, byte* plain, const byte* input, (void)sz; if (ssl->decrypt.setup == 0) { - CYASSL_MSG("Decrypt ciphers not setup"); + WOLFSSL_MSG("Decrypt ciphers not setup"); return DECRYPT_ERROR; } switch (ssl->specs.bulk_cipher_algorithm) { #ifdef BUILD_ARC4 - case cyassl_rc4: + case wolfssl_rc4: wc_Arc4Process(ssl->decrypt.arc4, plain, input, sz); break; #endif #ifdef BUILD_DES3 - case cyassl_triple_des: + case wolfssl_triple_des: return Des3_CbcDecrypt(ssl->decrypt.des3, plain, input, sz); #endif #ifdef BUILD_AES - case cyassl_aes: + case wolfssl_aes: return AesCbcDecrypt(ssl->decrypt.aes, plain, input, sz); #endif #ifdef BUILD_AESGCM - case cyassl_aes_gcm: + case wolfssl_aes_gcm: { byte additional[AEAD_AUTH_DATA_SZ]; byte nonce[AEAD_NONCE_SZ]; @@ -5835,7 +5835,7 @@ static INLINE int Decrypt(CYASSL* ssl, byte* plain, const byte* input, /* sequence number field is 64-bits, we only use 32-bits */ c32toa(GetSEQIncrement(ssl, 1), additional + AEAD_SEQ_OFFSET); - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) c16toa(ssl->keys.dtls_state.curEpoch, additional); #endif @@ -5866,7 +5866,7 @@ static INLINE int Decrypt(CYASSL* ssl, byte* plain, const byte* input, #endif #ifdef HAVE_AESCCM - case cyassl_aes_ccm: + case wolfssl_aes_ccm: { byte additional[AEAD_AUTH_DATA_SZ]; byte nonce[AEAD_NONCE_SZ]; @@ -5876,7 +5876,7 @@ static INLINE int Decrypt(CYASSL* ssl, byte* plain, const byte* input, /* sequence number field is 64-bits, we only use 32-bits */ c32toa(GetSEQIncrement(ssl, 1), additional + AEAD_SEQ_OFFSET); - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) c16toa(ssl->keys.dtls_state.curEpoch, additional); #endif @@ -5907,28 +5907,28 @@ static INLINE int Decrypt(CYASSL* ssl, byte* plain, const byte* input, #endif #ifdef HAVE_CAMELLIA - case cyassl_camellia: + case wolfssl_camellia: CamelliaCbcDecrypt(ssl->decrypt.cam, plain, input, sz); break; #endif #ifdef HAVE_HC128 - case cyassl_hc128: + case wolfssl_hc128: return Hc128_Process(ssl->decrypt.hc128, plain, input, sz); #endif #ifdef BUILD_RABBIT - case cyassl_rabbit: + case wolfssl_rabbit: return RabbitProcess(ssl->decrypt.rabbit, plain, input, sz); #endif #ifdef HAVE_CHACHA - case cyassl_chacha: + case wolfssl_chacha: return ChachaAEADDecrypt(ssl, plain, input, sz); #endif #ifdef HAVE_NULL_CIPHER - case cyassl_cipher_null: + case wolfssl_cipher_null: if (input != plain) { XMEMMOVE(plain, input, sz); } @@ -5936,7 +5936,7 @@ static INLINE int Decrypt(CYASSL* ssl, byte* plain, const byte* input, #endif default: - CYASSL_MSG("CyaSSL Decrypt programming error"); + WOLFSSL_MSG("wolfSSL Decrypt programming error"); return DECRYPT_ERROR; } return 0; @@ -5944,7 +5944,7 @@ static INLINE int Decrypt(CYASSL* ssl, byte* plain, const byte* input, /* check cipher text size for sanity */ -static int SanityCheckCipherText(CYASSL* ssl, word32 encryptSz) +static int SanityCheckCipherText(WOLFSSL* ssl, word32 encryptSz) { #ifdef HAVE_TRUNCATED_HMAC word32 minLength = ssl->truncated_hmac ? TRUNCATED_HMAC_SZ @@ -5955,7 +5955,7 @@ static int SanityCheckCipherText(CYASSL* ssl, word32 encryptSz) if (ssl->specs.cipher_type == block) { if (encryptSz % ssl->specs.block_size) { - CYASSL_MSG("Block ciphertext not block size"); + WOLFSSL_MSG("Block ciphertext not block size"); return SANITY_CIPHER_E; } @@ -5969,12 +5969,12 @@ static int SanityCheckCipherText(CYASSL* ssl, word32 encryptSz) } else if (ssl->specs.cipher_type == aead) { minLength = ssl->specs.aead_mac_size; /* authTag size */ - if (ssl->specs.bulk_cipher_algorithm != cyassl_chacha) + if (ssl->specs.bulk_cipher_algorithm != wolfssl_chacha) minLength += AEAD_EXP_IV_SZ; /* explicit IV */ } if (encryptSz < minLength) { - CYASSL_MSG("Ciphertext not minimum size"); + WOLFSSL_MSG("Ciphertext not minimum size"); return SANITY_CIPHER_E; } @@ -6030,7 +6030,7 @@ static INLINE void Sha256Rounds(int rounds, const byte* data, int sz) #endif -#ifdef CYASSL_SHA384 +#ifdef WOLFSSL_SHA384 static INLINE void Sha384Rounds(int rounds, const byte* data, int sz) { @@ -6048,7 +6048,7 @@ static INLINE void Sha384Rounds(int rounds, const byte* data, int sz) #endif -#ifdef CYASSL_SHA512 +#ifdef WOLFSSL_SHA512 static INLINE void Sha512Rounds(int rounds, const byte* data, int sz) { @@ -6066,7 +6066,7 @@ static INLINE void Sha512Rounds(int rounds, const byte* data, int sz) #endif -#ifdef CYASSL_RIPEMD +#ifdef WOLFSSL_RIPEMD static INLINE void RmdRounds(int rounds, const byte* data, int sz) { @@ -6110,33 +6110,33 @@ static INLINE void DoRounds(int type, int rounds, const byte* data, int sz) break; #endif -#ifdef CYASSL_SHA384 +#ifdef WOLFSSL_SHA384 case sha384_mac : Sha384Rounds(rounds, data, sz); break; #endif -#ifdef CYASSL_SHA512 +#ifdef WOLFSSL_SHA512 case sha512_mac : Sha512Rounds(rounds, data, sz); break; #endif -#ifdef CYASSL_RIPEMD +#ifdef WOLFSSL_RIPEMD case rmd_mac : RmdRounds(rounds, data, sz); break; #endif default: - CYASSL_MSG("Bad round type"); + WOLFSSL_MSG("Bad round type"); break; } } /* do number of compression rounds on dummy data */ -static INLINE void CompressRounds(CYASSL* ssl, int rounds, const byte* dummy) +static INLINE void CompressRounds(WOLFSSL* ssl, int rounds, const byte* dummy) { if (rounds) DoRounds(ssl->specs.mac_algorithm, rounds, dummy, COMPRESS_LOWER); @@ -6213,7 +6213,7 @@ static INLINE int GetRounds(int pLen, int padLen, int t) /* timing resistant pad/verify check, return 0 on success */ -static int TimingPadVerify(CYASSL* ssl, const byte* input, int padLen, int t, +static int TimingPadVerify(WOLFSSL* ssl, const byte* input, int padLen, int t, int pLen, int content) { byte verify[MAX_DIGEST_SIZE]; @@ -6223,7 +6223,7 @@ static int TimingPadVerify(CYASSL* ssl, const byte* input, int padLen, int t, XMEMSET(dummy, 1, sizeof(dummy)); if ( (t + padLen + 1) > pLen) { - CYASSL_MSG("Plain Len not long enough for pad/mac"); + WOLFSSL_MSG("Plain Len not long enough for pad/mac"); PadCheck(dummy, (byte)padLen, MAX_PAD_SIZE); ssl->hmac(ssl, verify, input, pLen - t, content, 1); /* still compare */ ConstantCompare(verify, input + pLen - t, t); @@ -6232,7 +6232,7 @@ static int TimingPadVerify(CYASSL* ssl, const byte* input, int padLen, int t, } if (PadCheck(input + pLen - (padLen + 1), (byte)padLen, padLen + 1) != 0) { - CYASSL_MSG("PadCheck failed"); + WOLFSSL_MSG("PadCheck failed"); PadCheck(dummy, (byte)padLen, MAX_PAD_SIZE - padLen - 1); ssl->hmac(ssl, verify, input, pLen - t, content, 1); /* still compare */ ConstantCompare(verify, input + pLen - t, t); @@ -6246,7 +6246,7 @@ static int TimingPadVerify(CYASSL* ssl, const byte* input, int padLen, int t, CompressRounds(ssl, GetRounds(pLen, padLen, t), dummy); if (ConstantCompare(verify, input + (pLen - padLen - 1 - t), t) != 0) { - CYASSL_MSG("Verify MAC compare failed"); + WOLFSSL_MSG("Verify MAC compare failed"); return VERIFY_MAC_ERROR; } @@ -6256,7 +6256,7 @@ static int TimingPadVerify(CYASSL* ssl, const byte* input, int padLen, int t, } -int DoApplicationData(CYASSL* ssl, byte* input, word32* inOutIdx) +int DoApplicationData(WOLFSSL* ssl, byte* input, word32* inOutIdx) { word32 msgSz = ssl->keys.encryptSz; word32 idx = *inOutIdx; @@ -6268,7 +6268,7 @@ int DoApplicationData(CYASSL* ssl, byte* input, word32* inOutIdx) #endif if (ssl->options.handShakeDone == 0) { - CYASSL_MSG("Received App data before a handshake completed"); + WOLFSSL_MSG("Received App data before a handshake completed"); SendAlert(ssl, alert_fatal, unexpected_message); return OUT_OF_ORDER_E; } @@ -6278,13 +6278,13 @@ int DoApplicationData(CYASSL* ssl, byte* input, word32* inOutIdx) ivExtra = ssl->specs.block_size; } else if (ssl->specs.cipher_type == aead) { - if (ssl->specs.bulk_cipher_algorithm != cyassl_chacha) + if (ssl->specs.bulk_cipher_algorithm != wolfssl_chacha) ivExtra = AEAD_EXP_IV_SZ; } dataSz = msgSz - ivExtra - ssl->keys.padSz; if (dataSz < 0) { - CYASSL_MSG("App data buffer error, malicious input?"); + WOLFSSL_MSG("App data buffer error, malicious input?"); return BUFFER_ERROR; } @@ -6318,13 +6318,13 @@ int DoApplicationData(CYASSL* ssl, byte* input, word32* inOutIdx) /* process alert, return level */ -static int DoAlert(CYASSL* ssl, byte* input, word32* inOutIdx, int* type, +static int DoAlert(WOLFSSL* ssl, byte* input, word32* inOutIdx, int* type, word32 totalSz) { byte level; byte code; - #ifdef CYASSL_CALLBACKS + #ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("Alert", &ssl->handShakeInfo); if (ssl->toInfoOn) @@ -6346,12 +6346,12 @@ static int DoAlert(CYASSL* ssl, byte* input, word32* inOutIdx, int* type, ssl->options.isClosed = 1; /* Don't send close_notify */ } - CYASSL_MSG("Got alert"); + WOLFSSL_MSG("Got alert"); if (*type == close_notify) { - CYASSL_MSG(" close notify"); + WOLFSSL_MSG(" close notify"); ssl->options.closeNotify = 1; } - CYASSL_ERROR(*type); + WOLFSSL_ERROR(*type); if (ssl->keys.encryptionOn) { if (*inOutIdx + ssl->keys.padSz > totalSz) @@ -6362,7 +6362,7 @@ static int DoAlert(CYASSL* ssl, byte* input, word32* inOutIdx, int* type, return level; } -static int GetInputData(CYASSL *ssl, word32 size) +static int GetInputData(WOLFSSL *ssl, word32 size) { int in; int inSz; @@ -6376,7 +6376,7 @@ static int GetInputData(CYASSL *ssl, word32 size) maxLength = ssl->buffers.inputBuffer.bufferSize - usedLength; inSz = (int)(size - usedLength); /* from last partial read */ -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (ssl->options.dtls) { if (size < ssl->dtls_expected_rx) dtlsExtra = (int)(ssl->dtls_expected_rx - size); @@ -6426,7 +6426,7 @@ static int GetInputData(CYASSL *ssl, word32 size) } -static INLINE int VerifyMac(CYASSL* ssl, const byte* input, word32 msgSz, +static INLINE int VerifyMac(WOLFSSL* ssl, const byte* input, word32 msgSz, int content, word32* padSz) { int ivExtra = 0; @@ -6461,7 +6461,7 @@ static INLINE int VerifyMac(CYASSL* ssl, const byte* input, word32 msgSz, XMEMSET(dummy, 1, sizeof(dummy)); if (pad > (msgSz - digestSz - 1)) { - CYASSL_MSG("Plain Len not long enough for pad/mac"); + WOLFSSL_MSG("Plain Len not long enough for pad/mac"); pad = 0; /* no bad read */ badPadLen = 1; } @@ -6497,12 +6497,12 @@ static INLINE int VerifyMac(CYASSL* ssl, const byte* input, word32 msgSz, /* process input requests, return 0 is done, 1 is call again to complete, and negative number is error */ -int ProcessReply(CYASSL* ssl) +int ProcessReply(WOLFSSL* ssl) { int ret = 0, type, readSz; int atomicUser = 0; word32 startIdx = 0; -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS int used; #endif @@ -6512,20 +6512,20 @@ int ProcessReply(CYASSL* ssl) #endif if (ssl->error != 0 && ssl->error != WANT_READ && ssl->error != WANT_WRITE){ - CYASSL_MSG("ProcessReply retry in error state, not allowed"); + WOLFSSL_MSG("ProcessReply retry in error state, not allowed"); return ssl->error; } for (;;) { switch (ssl->options.processReply) { - /* in the CYASSL_SERVER case, get the first byte for detecting + /* in the WOLFSSL_SERVER case, get the first byte for detecting * old client hello */ case doProcessInit: readSz = RECORD_HEADER_SZ; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) readSz = DTLS_RECORD_HEADER_SZ; #endif @@ -6535,7 +6535,7 @@ int ProcessReply(CYASSL* ssl) if ((ret = GetInputData(ssl, readSz)) < 0) return ret; } else { - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS /* read ahead may already have header */ used = ssl->buffers.inputBuffer.length - ssl->buffers.inputBuffer.idx; @@ -6548,7 +6548,7 @@ int ProcessReply(CYASSL* ssl) #ifdef OLD_HELLO_ALLOWED /* see if sending SSLv2 client hello */ - if ( ssl->options.side == CYASSL_SERVER_END && + if ( ssl->options.side == WOLFSSL_SERVER_END && ssl->options.clientState == NULL_STATE && ssl->buffers.inputBuffer.buffer[ssl->buffers.inputBuffer.idx] != handshake) { @@ -6559,7 +6559,7 @@ int ProcessReply(CYASSL* ssl) /* sanity checks before getting size at front */ if (ssl->buffers.inputBuffer.buffer[ ssl->buffers.inputBuffer.idx + 2] != OLD_HELLO_ID) { - CYASSL_MSG("Not a valid old client hello"); + WOLFSSL_MSG("Not a valid old client hello"); return PARSE_ERROR; } @@ -6567,7 +6567,7 @@ int ProcessReply(CYASSL* ssl) ssl->buffers.inputBuffer.idx + 3] != SSLv3_MAJOR && ssl->buffers.inputBuffer.buffer[ ssl->buffers.inputBuffer.idx + 3] != DTLS_MAJOR) { - CYASSL_MSG("Not a valid version in old client hello"); + WOLFSSL_MSG("Not a valid version in old client hello"); return PARSE_ERROR; } @@ -6583,7 +6583,7 @@ int ProcessReply(CYASSL* ssl) continue; } - /* in the CYASSL_SERVER case, run the old client hello */ + /* in the WOLFSSL_SERVER case, run the old client hello */ case runProcessOldClientHello: /* get sz bytes or return error */ @@ -6591,14 +6591,14 @@ int ProcessReply(CYASSL* ssl) if ((ret = GetInputData(ssl, ssl->curSize)) < 0) return ret; } else { - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS /* read ahead may already have */ used = ssl->buffers.inputBuffer.length - ssl->buffers.inputBuffer.idx; if (used < ssl->curSize) if ((ret = GetInputData(ssl, ssl->curSize)) < 0) return ret; - #endif /* CYASSL_DTLS */ + #endif /* WOLFSSL_DTLS */ } ret = ProcessOldClientHello(ssl, ssl->buffers.inputBuffer.buffer, @@ -6623,7 +6623,7 @@ int ProcessReply(CYASSL* ssl) ret = GetRecordHeader(ssl, ssl->buffers.inputBuffer.buffer, &ssl->buffers.inputBuffer.idx, &ssl->curRL, &ssl->curSize); -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (ssl->options.dtls && ret == SEQUENCE_ERROR) { ssl->options.processReply = doProcessInit; ssl->buffers.inputBuffer.length = 0; @@ -6644,7 +6644,7 @@ int ProcessReply(CYASSL* ssl) if ((ret = GetInputData(ssl, ssl->curSize)) < 0) return ret; } else { -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS /* read ahead may already have */ used = ssl->buffers.inputBuffer.length - ssl->buffers.inputBuffer.idx; @@ -6660,7 +6660,7 @@ int ProcessReply(CYASSL* ssl) /* the record layer is here */ case runProcessingOneMessage: - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls && ssl->keys.dtls_state.curEpoch < ssl->keys.dtls_state.nextEpoch) ssl->keys.decryptedCur = 1; @@ -6685,7 +6685,7 @@ int ProcessReply(CYASSL* ssl) ssl->buffers.inputBuffer.idx += ssl->specs.block_size; /* go past TLSv1.1 IV */ if (ssl->specs.cipher_type == aead && - ssl->specs.bulk_cipher_algorithm != cyassl_chacha) + ssl->specs.bulk_cipher_algorithm != wolfssl_chacha) ssl->buffers.inputBuffer.idx += AEAD_EXP_IV_SZ; #endif /* ATOMIC_USER */ } @@ -6696,14 +6696,14 @@ int ProcessReply(CYASSL* ssl) ssl->buffers.inputBuffer.idx, ssl->curSize); if (ret < 0) { - CYASSL_ERROR(ret); + WOLFSSL_ERROR(ret); return DECRYPT_ERROR; } if (ssl->options.tls1_1 && ssl->specs.cipher_type == block) ssl->buffers.inputBuffer.idx += ssl->specs.block_size; /* go past TLSv1.1 IV */ if (ssl->specs.cipher_type == aead && - ssl->specs.bulk_cipher_algorithm != cyassl_chacha) + ssl->specs.bulk_cipher_algorithm != wolfssl_chacha) ssl->buffers.inputBuffer.idx += AEAD_EXP_IV_SZ; ret = VerifyMac(ssl, ssl->buffers.inputBuffer.buffer + @@ -6712,7 +6712,7 @@ int ProcessReply(CYASSL* ssl) &ssl->keys.padSz); } if (ret < 0) { - CYASSL_ERROR(ret); + WOLFSSL_ERROR(ret); return DECRYPT_ERROR; } ssl->keys.encryptSz = ssl->curSize; @@ -6720,12 +6720,12 @@ int ProcessReply(CYASSL* ssl) } if (ssl->options.dtls) { - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS DtlsUpdateWindow(&ssl->keys.dtls_state); - #endif /* CYASSL_DTLS */ + #endif /* WOLFSSL_DTLS */ } - CYASSL_MSG("received record layer msg"); + WOLFSSL_MSG("received record layer msg"); switch (ssl->curRL.type) { case handshake : @@ -6737,7 +6737,7 @@ int ProcessReply(CYASSL* ssl) ssl->buffers.inputBuffer.length); } else { -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS ret = DoDtlsHandShakeMsg(ssl, ssl->buffers.inputBuffer.buffer, &ssl->buffers.inputBuffer.idx, @@ -6749,8 +6749,8 @@ int ProcessReply(CYASSL* ssl) break; case change_cipher_spec: - CYASSL_MSG("got CHANGE CIPHER SPEC"); - #ifdef CYASSL_CALLBACKS + WOLFSSL_MSG("got CHANGE CIPHER SPEC"); + #ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("ChangeCipher", &ssl->handShakeInfo); /* add record header back on info */ @@ -6768,9 +6768,9 @@ int ProcessReply(CYASSL* ssl) return ret; #ifdef HAVE_SESSION_TICKET - if (ssl->options.side == CYASSL_CLIENT_END && + if (ssl->options.side == WOLFSSL_CLIENT_END && ssl->expect_session_ticket) { - CYASSL_MSG("Expected session ticket missing"); + WOLFSSL_MSG("Expected session ticket missing"); return SESSION_TICKET_EXPECT_E; } #endif @@ -6781,15 +6781,15 @@ int ProcessReply(CYASSL* ssl) } if (ssl->curSize != 1) { - CYASSL_MSG("Malicious or corrupted ChangeCipher msg"); + WOLFSSL_MSG("Malicious or corrupted ChangeCipher msg"); return LENGTH_ERROR; } #ifndef NO_CERTS - if (ssl->options.side == CYASSL_SERVER_END && + if (ssl->options.side == WOLFSSL_SERVER_END && ssl->options.verifyPeer && ssl->options.havePeerCert) if (!ssl->options.havePeerVerify) { - CYASSL_MSG("client didn't send cert verify"); + WOLFSSL_MSG("client didn't send cert verify"); return NO_PEER_VERIFY; } #endif @@ -6802,7 +6802,7 @@ int ProcessReply(CYASSL* ssl) if ((ret = SetKeysSide(ssl, DECRYPT_SIDE_ONLY)) != 0) return ret; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { DtlsPoolReset(ssl); ssl->keys.dtls_state.nextEpoch++; @@ -6816,28 +6816,28 @@ int ProcessReply(CYASSL* ssl) return ret; #endif if (ssl->options.resuming && ssl->options.side == - CYASSL_CLIENT_END) + WOLFSSL_CLIENT_END) ret = BuildFinished(ssl, &ssl->verifyHashes, server); else if (!ssl->options.resuming && ssl->options.side == - CYASSL_SERVER_END) + WOLFSSL_SERVER_END) ret = BuildFinished(ssl, &ssl->verifyHashes, client); if (ret != 0) return ret; break; case application_data: - CYASSL_MSG("got app DATA"); + WOLFSSL_MSG("got app DATA"); if ((ret = DoApplicationData(ssl, ssl->buffers.inputBuffer.buffer, &ssl->buffers.inputBuffer.idx)) != 0) { - CYASSL_ERROR(ret); + WOLFSSL_ERROR(ret); return ret; } break; case alert: - CYASSL_MSG("got ALERT!"); + WOLFSSL_MSG("got ALERT!"); ret = DoAlert(ssl, ssl->buffers.inputBuffer.buffer, &ssl->buffers.inputBuffer.idx, &type, ssl->buffers.inputBuffer.length); @@ -6855,7 +6855,7 @@ int ProcessReply(CYASSL* ssl) break; default: - CYASSL_ERROR(UNKNOWN_RECORD_TYPE); + WOLFSSL_ERROR(UNKNOWN_RECORD_TYPE); return UNKNOWN_RECORD_TYPE; } @@ -6866,8 +6866,8 @@ int ProcessReply(CYASSL* ssl) return 0; /* more messages per record */ else if ((ssl->buffers.inputBuffer.idx - startIdx) < ssl->curSize) { - CYASSL_MSG("More messages in record"); - #ifdef CYASSL_DTLS + WOLFSSL_MSG("More messages in record"); + #ifdef WOLFSSL_DTLS /* read-ahead but dtls doesn't bundle messages per record */ if (ssl->options.dtls) { ssl->options.processReply = doProcessInit; @@ -6877,7 +6877,7 @@ int ProcessReply(CYASSL* ssl) ssl->options.processReply = runProcessingOneMessage; if (ssl->keys.encryptionOn) { - CYASSL_MSG("Bundled encrypted messages, remove middle pad"); + WOLFSSL_MSG("Bundled encrypted messages, remove middle pad"); ssl->buffers.inputBuffer.idx -= ssl->keys.padSz; } @@ -6885,27 +6885,27 @@ int ProcessReply(CYASSL* ssl) } /* more records */ else { - CYASSL_MSG("More records in input"); + WOLFSSL_MSG("More records in input"); ssl->options.processReply = doProcessInit; continue; } default: - CYASSL_MSG("Bad process input state, programming error"); + WOLFSSL_MSG("Bad process input state, programming error"); return INPUT_CASE_ERROR; } } } -int SendChangeCipher(CYASSL* ssl) +int SendChangeCipher(WOLFSSL* ssl) { byte *output; int sendSz = RECORD_HEADER_SZ + ENUM_LEN; int idx = RECORD_HEADER_SZ; int ret; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { sendSz += DTLS_RECORD_EXTRA; idx += DTLS_RECORD_EXTRA; @@ -6940,13 +6940,13 @@ int SendChangeCipher(CYASSL* ssl) return sendSz; } - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) return ret; } #endif - #ifdef CYASSL_CALLBACKS + #ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("ChangeCipher", &ssl->handShakeInfo); if (ssl->toInfoOn) AddPacketInfo("ChangeCipher", &ssl->timeoutInfo, output, sendSz, @@ -6956,7 +6956,7 @@ int SendChangeCipher(CYASSL* ssl) if (ssl->options.groupMessages) return 0; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS else if (ssl->options.dtls) { /* If using DTLS, force the ChangeCipherSpec message to be in the * same datagram as the finished message. */ @@ -6969,7 +6969,7 @@ int SendChangeCipher(CYASSL* ssl) #ifndef NO_OLD_TLS -static int SSL_hmac(CYASSL* ssl, byte* digest, const byte* in, word32 sz, +static int SSL_hmac(WOLFSSL* ssl, byte* digest, const byte* in, word32 sz, int content, int verify) { byte result[MAX_DIGEST_SIZE]; @@ -6983,7 +6983,7 @@ static int SSL_hmac(CYASSL* ssl, byte* digest, const byte* in, word32 sz, /* data */ byte seq[SEQ_SZ]; byte conLen[ENUM_LEN + LENGTH_SZ]; /* content & length */ - const byte* macSecret = CyaSSL_GetMacSecret(ssl, verify); + const byte* macSecret = wolfSSL_GetMacSecret(ssl, verify); #ifdef HAVE_FUZZER if (ssl->fuzzerCb) @@ -7033,7 +7033,7 @@ static int SSL_hmac(CYASSL* ssl, byte* digest, const byte* in, word32 sz, } #ifndef NO_CERTS -static void BuildMD5_CertVerify(CYASSL* ssl, byte* digest) +static void BuildMD5_CertVerify(WOLFSSL* ssl, byte* digest) { byte md5_result[MD5_DIGEST_SIZE]; @@ -7051,7 +7051,7 @@ static void BuildMD5_CertVerify(CYASSL* ssl, byte* digest) } -static void BuildSHA_CertVerify(CYASSL* ssl, byte* digest) +static void BuildSHA_CertVerify(WOLFSSL* ssl, byte* digest) { byte sha_result[SHA_DIGEST_SIZE]; @@ -7073,7 +7073,7 @@ static void BuildSHA_CertVerify(CYASSL* ssl, byte* digest) #ifndef NO_CERTS -static int BuildCertHashes(CYASSL* ssl, Hashes* hashes) +static int BuildCertHashes(WOLFSSL* ssl, Hashes* hashes) { /* store current states, building requires get_digest which resets state */ #ifndef NO_OLD_TLS @@ -7083,7 +7083,7 @@ static int BuildCertHashes(CYASSL* ssl, Hashes* hashes) #ifndef NO_SHA256 Sha256 sha256 = ssl->hashSha256; #endif - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 Sha384 sha384 = ssl->hashSha384; #endif @@ -7100,7 +7100,7 @@ static int BuildCertHashes(CYASSL* ssl, Hashes* hashes) if (ret != 0) return ret; #endif - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 ret = Sha384Final(&ssl->hashSha384, hashes->sha384); if (ret != 0) return ret; @@ -7121,7 +7121,7 @@ static int BuildCertHashes(CYASSL* ssl, Hashes* hashes) #ifndef NO_SHA256 ssl->hashSha256 = sha256; #endif - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 ssl->hashSha384 = sha384; #endif } @@ -7129,10 +7129,10 @@ static int BuildCertHashes(CYASSL* ssl, Hashes* hashes) return 0; } -#endif /* CYASSL_LEANPSK */ +#endif /* WOLFSSL_LEANPSK */ /* Build SSL Message, encrypted */ -static int BuildMessage(CYASSL* ssl, byte* output, int outSz, +static int BuildMessage(WOLFSSL* ssl, byte* output, int outSz, const byte* input, int inSz, int type) { #ifdef HAVE_TRUNCATED_HMAC @@ -7151,7 +7151,7 @@ static int BuildMessage(CYASSL* ssl, byte* output, int outSz, int ret = 0; int atomicUser = 0; -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (ssl->options.dtls) { sz += DTLS_RECORD_EXTRA; idx += DTLS_RECORD_EXTRA; @@ -7186,7 +7186,7 @@ static int BuildMessage(CYASSL* ssl, byte* output, int outSz, #ifdef HAVE_AEAD if (ssl->specs.cipher_type == aead) { - if (ssl->specs.bulk_cipher_algorithm != cyassl_chacha) + if (ssl->specs.bulk_cipher_algorithm != wolfssl_chacha) ivSz = AEAD_EXP_IV_SZ; sz += (ivSz + ssl->specs.aead_mac_size - digestSz); @@ -7194,7 +7194,7 @@ static int BuildMessage(CYASSL* ssl, byte* output, int outSz, } #endif if (sz > (word32)outSz) { - CYASSL_MSG("Oops, want to write past output buffer size"); + WOLFSSL_MSG("Oops, want to write past output buffer size"); return BUFFER_E; } size = (word16)(sz - headerSz); /* include mac and digest */ @@ -7234,13 +7234,13 @@ static int BuildMessage(CYASSL* ssl, byte* output, int outSz, if (ssl->specs.cipher_type != aead) { #ifdef HAVE_TRUNCATED_HMAC if (ssl->truncated_hmac && ssl->specs.hash_size > digestSz) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK byte* hmac = NULL; #else byte hmac[MAX_DIGEST_SIZE]; #endif - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK hmac = (byte*)XMALLOC(MAX_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (hmac == NULL) @@ -7251,7 +7251,7 @@ static int BuildMessage(CYASSL* ssl, byte* output, int outSz, type, 0); XMEMCPY(output + idx, hmac, digestSz); - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(hmac, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif } else @@ -7270,7 +7270,7 @@ static int BuildMessage(CYASSL* ssl, byte* output, int outSz, } -int SendFinished(CYASSL* ssl) +int SendFinished(WOLFSSL* ssl) { int sendSz, finishedSz = ssl->options.tls ? TLS_FINISHED_SZ : @@ -7282,7 +7282,7 @@ int SendFinished(CYASSL* ssl) int headerSz = HANDSHAKE_HEADER_SZ; int outputSz; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS word32 sequence_number = ssl->keys.dtls_sequence_number; word16 epoch = ssl->keys.dtls_epoch; #endif @@ -7296,7 +7296,7 @@ int SendFinished(CYASSL* ssl) if ((ret = CheckAvailableSize(ssl, outputSz)) != 0) return ret; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { /* Send Finished message with the next epoch, but don't commit that * change until the other end confirms its reception. */ @@ -7315,12 +7315,12 @@ int SendFinished(CYASSL* ssl) /* make finished hashes */ hashes = (Hashes*)&input[headerSz]; ret = BuildFinished(ssl, hashes, - ssl->options.side == CYASSL_CLIENT_END ? client : server); + ssl->options.side == WOLFSSL_CLIENT_END ? client : server); if (ret != 0) return ret; #ifdef HAVE_SECURE_RENEGOTIATION if (ssl->secure_renegotiation) { - if (ssl->options.side == CYASSL_CLIENT_END) + if (ssl->options.side == WOLFSSL_CLIENT_END) XMEMCPY(ssl->secure_renegotiation->client_verify_data, hashes, TLS_FINISHED_SZ); else @@ -7334,7 +7334,7 @@ int SendFinished(CYASSL* ssl) if (sendSz < 0) return BUILD_MSG_ERROR; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { ssl->keys.dtls_epoch = epoch; ssl->keys.dtls_sequence_number = sequence_number; @@ -7345,14 +7345,14 @@ int SendFinished(CYASSL* ssl) #ifndef NO_SESSION_CACHE AddSession(ssl); /* just try */ #endif - if (ssl->options.side == CYASSL_CLIENT_END) { + if (ssl->options.side == WOLFSSL_CLIENT_END) { ret = BuildFinished(ssl, &ssl->verifyHashes, server); if (ret != 0) return ret; } else { ssl->options.handShakeState = HANDSHAKE_DONE; ssl->options.handShakeDone = 1; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { /* Other side will soon receive our Finished, go to next * epoch. */ @@ -7363,10 +7363,10 @@ int SendFinished(CYASSL* ssl) } } else { - if (ssl->options.side == CYASSL_CLIENT_END) { + if (ssl->options.side == WOLFSSL_CLIENT_END) { ssl->options.handShakeState = HANDSHAKE_DONE; ssl->options.handShakeDone = 1; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { /* Other side will soon receive our Finished, go to next * epoch. */ @@ -7380,14 +7380,14 @@ int SendFinished(CYASSL* ssl) if (ret != 0) return ret; } } - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) return ret; } #endif - #ifdef CYASSL_CALLBACKS + #ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("Finished", &ssl->handShakeInfo); if (ssl->toInfoOn) AddPacketInfo("Finished", &ssl->timeoutInfo, output, sendSz, @@ -7400,7 +7400,7 @@ int SendFinished(CYASSL* ssl) } #ifndef NO_CERTS -int SendCertificate(CYASSL* ssl) +int SendCertificate(WOLFSSL* ssl) { int sendSz, length, ret = 0; word32 i = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ; @@ -7429,7 +7429,7 @@ int SendCertificate(CYASSL* ssl) } sendSz = length + RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { sendSz += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA; i += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA; @@ -7488,21 +7488,21 @@ int SendCertificate(CYASSL* ssl) return ret; } - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) return ret; } #endif - #ifdef CYASSL_CALLBACKS + #ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("Certificate", &ssl->handShakeInfo); if (ssl->toInfoOn) AddPacketInfo("Certificate", &ssl->timeoutInfo, output, sendSz, ssl->heap); #endif - if (ssl->options.side == CYASSL_SERVER_END) + if (ssl->options.side == WOLFSSL_SERVER_END) ssl->options.serverState = SERVER_CERT_COMPLETE; ssl->buffers.outputBuffer.length += sendSz; @@ -7513,7 +7513,7 @@ int SendCertificate(CYASSL* ssl) } -int SendCertificateRequest(CYASSL* ssl) +int SendCertificateRequest(WOLFSSL* ssl) { byte *output; int ret; @@ -7531,7 +7531,7 @@ int SendCertificateRequest(CYASSL* ssl) sendSz = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ + reqSz; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { sendSz += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA; i += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA; @@ -7573,7 +7573,7 @@ int SendCertificateRequest(CYASSL* ssl) /* if add more to output, adjust i i += REQ_HEADER_SZ; */ - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) return ret; @@ -7584,7 +7584,7 @@ int SendCertificateRequest(CYASSL* ssl) if (ret != 0) return ret; - #ifdef CYASSL_CALLBACKS + #ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("CertificateRequest", &ssl->handShakeInfo); if (ssl->toInfoOn) @@ -7600,7 +7600,7 @@ int SendCertificateRequest(CYASSL* ssl) #endif /* !NO_CERTS */ -int SendData(CYASSL* ssl, const void* data, int sz) +int SendData(WOLFSSL* ssl, const void* data, int sz) { int sent = 0, /* plainText size */ sendSz, @@ -7612,16 +7612,16 @@ int SendData(CYASSL* ssl, const void* data, int sz) if (ssl->options.handShakeState != HANDSHAKE_DONE) { int err; - CYASSL_MSG("handshake not complete, trying to finish"); - if ( (err = CyaSSL_negotiate(ssl)) != SSL_SUCCESS) + WOLFSSL_MSG("handshake not complete, trying to finish"); + if ( (err = wolfSSL_negotiate(ssl)) != SSL_SUCCESS) return err; } /* last time system socket output buffer was full, try again to send */ if (ssl->buffers.outputBuffer.length > 0) { - CYASSL_MSG("output buffer was full, trying to send again"); + WOLFSSL_MSG("output buffer was full, trying to send again"); if ( (ssl->error = SendBuffered(ssl)) < 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); if (ssl->error == SOCKET_ERROR_E && ssl->options.connReset) return 0; /* peer reset */ return ssl->error; @@ -7629,16 +7629,16 @@ int SendData(CYASSL* ssl, const void* data, int sz) else { /* advance sent to previous sent + plain size just sent */ sent = ssl->buffers.prevSent + ssl->buffers.plainSz; - CYASSL_MSG("sent write buffered data"); + WOLFSSL_MSG("sent write buffered data"); if (sent > sz) { - CYASSL_MSG("error: write() after WANT_WRITE with short size"); + WOLFSSL_MSG("error: write() after WANT_WRITE with short size"); return ssl->error = BAD_FUNC_ARG; } } } -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (ssl->options.dtls) { dtlsExtra = DTLS_RECORD_EXTRA; } @@ -7660,7 +7660,7 @@ int SendData(CYASSL* ssl, const void* data, int sz) if (sent == sz) break; -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (ssl->options.dtls) { len = min(len, MAX_UDP_SIZE); buffSz = len; @@ -7693,7 +7693,7 @@ int SendData(CYASSL* ssl, const void* data, int sz) ssl->buffers.outputBuffer.length += sendSz; if ( (ret = SendBuffered(ssl)) < 0) { - CYASSL_ERROR(ret); + WOLFSSL_ERROR(ret); /* store for next call if WANT_WRITE or user embedSend() that doesn't present like WANT_WRITE */ ssl->buffers.plainSz = len; @@ -7707,7 +7707,7 @@ int SendData(CYASSL* ssl, const void* data, int sz) /* only one message per attempt */ if (ssl->options.partialWrite == 1) { - CYASSL_MSG("Paritial Write on, only sending one record"); + WOLFSSL_MSG("Paritial Write on, only sending one record"); break; } } @@ -7716,24 +7716,24 @@ int SendData(CYASSL* ssl, const void* data, int sz) } /* process input data */ -int ReceiveData(CYASSL* ssl, byte* output, int sz, int peek) +int ReceiveData(WOLFSSL* ssl, byte* output, int sz, int peek) { int size; - CYASSL_ENTER("ReceiveData()"); + WOLFSSL_ENTER("ReceiveData()"); if (ssl->error == WANT_READ) ssl->error = 0; if (ssl->error != 0 && ssl->error != WANT_WRITE) { - CYASSL_MSG("User calling CyaSSL_read in error state, not allowed"); + WOLFSSL_MSG("User calling wolfSSL_read in error state, not allowed"); return ssl->error; } if (ssl->options.handShakeState != HANDSHAKE_DONE) { int err; - CYASSL_MSG("Handshake not complete, trying to finish"); - if ( (err = CyaSSL_negotiate(ssl)) != SSL_SUCCESS) + WOLFSSL_MSG("Handshake not complete, trying to finish"); + if ( (err = wolfSSL_negotiate(ssl)) != SSL_SUCCESS) return err; } @@ -7742,22 +7742,22 @@ startScr: if (ssl->secure_renegotiation && ssl->secure_renegotiation->startScr) { int err; ssl->secure_renegotiation->startScr = 0; /* only start once */ - CYASSL_MSG("Need to start scr, server requested"); - if ( (err = CyaSSL_Rehandshake(ssl)) != SSL_SUCCESS) + WOLFSSL_MSG("Need to start scr, server requested"); + if ( (err = wolfSSL_Rehandshake(ssl)) != SSL_SUCCESS) return err; } #endif while (ssl->buffers.clearOutputBuffer.length == 0) { if ( (ssl->error = ProcessReply(ssl)) < 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); if (ssl->error == ZERO_RETURN) { - CYASSL_MSG("Zero return, no more data coming"); + WOLFSSL_MSG("Zero return, no more data coming"); return 0; /* no more data coming */ } if (ssl->error == SOCKET_ERROR_E) { if (ssl->options.connReset || ssl->options.isClosed) { - CYASSL_MSG("Peer reset or closed, connection done"); + WOLFSSL_MSG("Peer reset or closed, connection done"); return 0; /* peer reset or closed */ } } @@ -7787,13 +7787,13 @@ startScr: ssl->buffers.inputBuffer.dynamicFlag) ShrinkInputBuffer(ssl, NO_FORCED_FREE); - CYASSL_LEAVE("ReceiveData()", size); + WOLFSSL_LEAVE("ReceiveData()", size); return size; } /* send alert message */ -int SendAlert(CYASSL* ssl, int severity, int type) +int SendAlert(WOLFSSL* ssl, int severity, int type) { byte input[ALERT_SIZE]; byte *output; @@ -7810,7 +7810,7 @@ int SendAlert(CYASSL* ssl, int severity, int type) return ret; } - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) dtlsExtra = DTLS_RECORD_EXTRA; #endif @@ -7840,14 +7840,14 @@ int SendAlert(CYASSL* ssl, int severity, int type) AddRecordHeader(output, ALERT_SIZE, alert, ssl); output += RECORD_HEADER_SZ; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) output += DTLS_RECORD_EXTRA; #endif XMEMCPY(output, input, ALERT_SIZE); sendSz = RECORD_HEADER_SZ + ALERT_SIZE; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) sendSz += DTLS_RECORD_EXTRA; #endif @@ -7855,7 +7855,7 @@ int SendAlert(CYASSL* ssl, int severity, int type) if (sendSz < 0) return BUILD_MSG_ERROR; - #ifdef CYASSL_CALLBACKS + #ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("Alert", &ssl->handShakeInfo); if (ssl->toInfoOn) @@ -7868,7 +7868,7 @@ int SendAlert(CYASSL* ssl, int severity, int type) return SendBuffered(ssl); } -const char* CyaSSL_ERR_reason_error_string(unsigned long e) +const char* wolfSSL_ERR_reason_error_string(unsigned long e) { #ifdef NO_ERROR_STRINGS @@ -7879,9 +7879,9 @@ const char* CyaSSL_ERR_reason_error_string(unsigned long e) int error = (int)e; - /* pass to CTaoCrypt */ + /* pass to wolfCrypt */ if (error < MAX_CODE_E && error > MIN_CODE_E) { - return CTaoCryptGetErrorString(error); + return wc_GetErrorString(error); } switch (error) { @@ -8180,7 +8180,7 @@ const char* CyaSSL_ERR_reason_error_string(unsigned long e) void SetErrorString(int error, char* str) { - XSTRNCPY(str, CyaSSL_ERR_reason_error_string(error), CYASSL_MAX_ERROR_SZ); + XSTRNCPY(str, wolfSSL_ERR_reason_error_string(error), WOLFSSL_MAX_ERROR_SZ); } @@ -9005,12 +9005,12 @@ int SetCipherList(Suites* suites, const char* list) char* next = (char*)list; if (suites == NULL || list == NULL) { - CYASSL_MSG("SetCipherList parameter error"); + WOLFSSL_MSG("SetCipherList parameter error"); return 0; } if (next[0] == 0 || XSTRNCMP(next, "ALL", 3) == 0) - return 1; /* CyaSSL defualt */ + return 1; /* wolfSSL defualt */ do { char* current = next; @@ -9060,7 +9060,7 @@ int SetCipherList(Suites* suites, const char* list) } -static void PickHashSigAlgo(CYASSL* ssl, +static void PickHashSigAlgo(WOLFSSL* ssl, const byte* hashSigAlgo, word32 hashSigAlgoSz) { word32 i; @@ -9080,7 +9080,7 @@ static void PickHashSigAlgo(CYASSL* ssl, break; } #endif - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 else if (hashSigAlgo[i] == sha384_mac) { ssl->suites->hashAlgo = sha384_mac; break; @@ -9091,7 +9091,7 @@ static void PickHashSigAlgo(CYASSL* ssl, } -#ifdef CYASSL_CALLBACKS +#ifdef WOLFSSL_CALLBACKS /* Initialisze HandShakeInfo */ void InitHandShakeInfo(HandShakeInfo* info) @@ -9106,7 +9106,7 @@ static void PickHashSigAlgo(CYASSL* ssl, } /* Set Final HandShakeInfo parameters */ - void FinishHandShakeInfo(HandShakeInfo* info, const CYASSL* ssl) + void FinishHandShakeInfo(HandShakeInfo* info, const WOLFSSL* ssl) { int i; int sz = sizeof(cipher_name_idx)/sizeof(int); @@ -9232,14 +9232,14 @@ static void PickHashSigAlgo(CYASSL* ssl, } } -#endif /* CYASSL_CALLBACKS */ +#endif /* WOLFSSL_CALLBACKS */ /* client only parts */ -#ifndef NO_CYASSL_CLIENT +#ifndef NO_WOLFSSL_CLIENT - int SendClientHello(CYASSL* ssl) + int SendClientHello(WOLFSSL* ssl) { byte *output; word32 length, idx = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ; @@ -9250,7 +9250,7 @@ static void PickHashSigAlgo(CYASSL* ssl, int ret; if (ssl->suites == NULL) { - CYASSL_MSG("Bad suites pointer in SendClientHello"); + WOLFSSL_MSG("Bad suites pointer in SendClientHello"); return SUITES_ERROR; } @@ -9283,7 +9283,7 @@ static void PickHashSigAlgo(CYASSL* ssl, #endif sendSz = length + HANDSHAKE_HEADER_SZ + RECORD_HEADER_SZ; -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (ssl->options.dtls) { length += ENUM_LEN; /* cookie */ if (ssl->arrays->cookieSz != 0) length += ssl->arrays->cookieSz; @@ -9319,7 +9319,7 @@ static void PickHashSigAlgo(CYASSL* ssl, /* store random */ XMEMCPY(ssl->arrays->clientRandom, output + idx, RAN_LEN); } else { -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS /* send same random on hello again */ XMEMCPY(output + idx, ssl->arrays->clientRandom, RAN_LEN); #endif @@ -9335,7 +9335,7 @@ static void PickHashSigAlgo(CYASSL* ssl, } /* then DTLS cookie */ -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (ssl->options.dtls) { byte cookieSz = ssl->arrays->cookieSz; @@ -9403,7 +9403,7 @@ static void PickHashSigAlgo(CYASSL* ssl, return ret; } - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) return ret; @@ -9412,7 +9412,7 @@ static void PickHashSigAlgo(CYASSL* ssl, ssl->options.clientState = CLIENT_HELLO_COMPLETE; -#ifdef CYASSL_CALLBACKS +#ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("ClientHello", &ssl->handShakeInfo); if (ssl->toInfoOn) AddPacketInfo("ClientHello", &ssl->timeoutInfo, output, sendSz, @@ -9425,20 +9425,20 @@ static void PickHashSigAlgo(CYASSL* ssl, } - static int DoHelloVerifyRequest(CYASSL* ssl, const byte* input, + static int DoHelloVerifyRequest(WOLFSSL* ssl, const byte* input, word32* inOutIdx, word32 size) { ProtocolVersion pv; byte cookieSz; word32 begin = *inOutIdx; -#ifdef CYASSL_CALLBACKS +#ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("HelloVerifyRequest", &ssl->handShakeInfo); if (ssl->toInfoOn) AddLateName("HelloVerifyRequest", &ssl->timeoutInfo); #endif -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (ssl->options.dtls) { DtlsPoolReset(ssl); } @@ -9456,7 +9456,7 @@ static void PickHashSigAlgo(CYASSL* ssl, if ((*inOutIdx - begin) + cookieSz > size) return BUFFER_ERROR; -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (cookieSz <= MAX_COOKIE_LEN) { XMEMCPY(ssl->arrays->cookie, input + *inOutIdx, cookieSz); ssl->arrays->cookieSz = cookieSz; @@ -9470,7 +9470,7 @@ static void PickHashSigAlgo(CYASSL* ssl, } - static INLINE int DSH_CheckSessionId(CYASSL* ssl) + static INLINE int DSH_CheckSessionId(WOLFSSL* ssl) { int ret = 0; @@ -9492,7 +9492,7 @@ static void PickHashSigAlgo(CYASSL* ssl, return ret; } - static int DoServerHello(CYASSL* ssl, const byte* input, word32* inOutIdx, + static int DoServerHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx, word32 helloSz) { byte cs0; /* cipher suite bytes 0, 1 */ @@ -9502,7 +9502,7 @@ static void PickHashSigAlgo(CYASSL* ssl, word32 i = *inOutIdx; word32 begin = i; -#ifdef CYASSL_CALLBACKS +#ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("ServerHello", &ssl->handShakeInfo); if (ssl->toInfoOn) AddLateName("ServerHello", &ssl->timeoutInfo); #endif @@ -9516,18 +9516,18 @@ static void PickHashSigAlgo(CYASSL* ssl, i += OPAQUE16_LEN; if (pv.minor > ssl->version.minor) { - CYASSL_MSG("Server using higher version, fatal error"); + WOLFSSL_MSG("Server using higher version, fatal error"); return VERSION_ERROR; } else if (pv.minor < ssl->version.minor) { - CYASSL_MSG("server using lower version"); + WOLFSSL_MSG("server using lower version"); if (!ssl->options.downgrade) { - CYASSL_MSG(" no downgrade allowed, fatal error"); + WOLFSSL_MSG(" no downgrade allowed, fatal error"); return VERSION_ERROR; } if (pv.minor < ssl->options.minDowngrade) { - CYASSL_MSG(" version below minimum allowed, fatal error"); + WOLFSSL_MSG(" version below minimum allowed, fatal error"); return VERSION_ERROR; } @@ -9535,26 +9535,26 @@ static void PickHashSigAlgo(CYASSL* ssl, if (ssl->secure_renegotiation && ssl->secure_renegotiation->enabled && ssl->options.handShakeDone) { - CYASSL_MSG("Server changed version during scr"); + WOLFSSL_MSG("Server changed version during scr"); return VERSION_ERROR; } #endif if (pv.minor == SSLv3_MINOR) { /* turn off tls */ - CYASSL_MSG(" downgrading to SSLv3"); + WOLFSSL_MSG(" downgrading to SSLv3"); ssl->options.tls = 0; ssl->options.tls1_1 = 0; ssl->version.minor = SSLv3_MINOR; } else if (pv.minor == TLSv1_MINOR) { /* turn off tls 1.1+ */ - CYASSL_MSG(" downgrading to TLSv1"); + WOLFSSL_MSG(" downgrading to TLSv1"); ssl->options.tls1_1 = 0; ssl->version.minor = TLSv1_MINOR; } else if (pv.minor == TLSv1_1_MINOR) { - CYASSL_MSG(" downgrading to TLSv1.1"); + WOLFSSL_MSG(" downgrading to TLSv1.1"); ssl->version.minor = TLSv1_1_MINOR; } } @@ -9567,7 +9567,7 @@ static void PickHashSigAlgo(CYASSL* ssl, ssl->arrays->sessionIDSz = input[i++]; if (ssl->arrays->sessionIDSz > ID_LEN) { - CYASSL_MSG("Invalid session ID size"); + WOLFSSL_MSG("Invalid session ID size"); ssl->arrays->sessionIDSz = 0; return BUFFER_ERROR; } @@ -9594,7 +9594,7 @@ static void PickHashSigAlgo(CYASSL* ssl, ssl->options.handShakeDone) { if (ssl->options.cipherSuite0 != cs0 || ssl->options.cipherSuite != cs1) { - CYASSL_MSG("Server changed cipher suite during scr"); + WOLFSSL_MSG("Server changed cipher suite during scr"); return MATCH_SUITE_ERROR; } } @@ -9605,7 +9605,7 @@ static void PickHashSigAlgo(CYASSL* ssl, compression = input[i++]; if (compression != ZLIB_COMPRESSION && ssl->options.usingCompression) { - CYASSL_MSG("Server refused compression, turning off"); + WOLFSSL_MSG("Server refused compression, turning off"); ssl->options.usingCompression = 0; /* turn off if server refused */ } @@ -9677,16 +9677,16 @@ static void PickHashSigAlgo(CYASSL* ssl, return ret; } else { - CYASSL_MSG("Unsupported cipher suite, DoServerHello"); + WOLFSSL_MSG("Unsupported cipher suite, DoServerHello"); return UNSUPPORTED_SUITE; } } else { - CYASSL_MSG("Server denied resumption attempt"); + WOLFSSL_MSG("Server denied resumption attempt"); ssl->options.resuming = 0; /* server denied resumption try */ } } - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { DtlsPoolReset(ssl); } @@ -9697,22 +9697,22 @@ static void PickHashSigAlgo(CYASSL* ssl, /* Make sure client setup is valid for this suite, true on success */ - int VerifyClientSuite(CYASSL* ssl) + int VerifyClientSuite(WOLFSSL* ssl) { int havePSK = 0; byte first = ssl->options.cipherSuite0; byte second = ssl->options.cipherSuite; - CYASSL_ENTER("VerifyClientSuite"); + WOLFSSL_ENTER("VerifyClientSuite"); #ifndef NO_PSK havePSK = ssl->options.havePSK; #endif if (CipherRequires(first, second, REQUIRES_PSK)) { - CYASSL_MSG("Requires PSK"); + WOLFSSL_MSG("Requires PSK"); if (havePSK == 0) { - CYASSL_MSG("Don't have PSK"); + WOLFSSL_MSG("Don't have PSK"); return 0; } } @@ -9723,13 +9723,13 @@ static void PickHashSigAlgo(CYASSL* ssl, #ifndef NO_CERTS /* just read in and ignore for now TODO: */ - static int DoCertificateRequest(CYASSL* ssl, const byte* input, word32* + static int DoCertificateRequest(WOLFSSL* ssl, const byte* input, word32* inOutIdx, word32 size) { word16 len; word32 begin = *inOutIdx; - #ifdef CYASSL_CALLBACKS + #ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("CertificateRequest", &ssl->handShakeInfo); if (ssl->toInfoOn) @@ -9803,7 +9803,7 @@ static void PickHashSigAlgo(CYASSL* ssl, #endif /* !NO_CERTS */ - static int DoServerKeyExchange(CYASSL* ssl, const byte* input, + static int DoServerKeyExchange(WOLFSSL* ssl, const byte* input, word32* inOutIdx, word32 size) { word16 length = 0; @@ -9818,7 +9818,7 @@ static void PickHashSigAlgo(CYASSL* ssl, (void)size; (void)ret; - #ifdef CYASSL_CALLBACKS + #ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("ServerKeyExchange", &ssl->handShakeInfo); if (ssl->toInfoOn) @@ -10041,7 +10041,7 @@ static void PickHashSigAlgo(CYASSL* ssl, ssl->specs.kea == diffie_hellman_kea)) { #ifndef NO_OLD_TLS -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK Md5* md5 = NULL; Sha* sha = NULL; #else @@ -10050,7 +10050,7 @@ static void PickHashSigAlgo(CYASSL* ssl, #endif #endif #ifndef NO_SHA256 -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK Sha256* sha256 = NULL; byte* hash256 = NULL; #else @@ -10058,8 +10058,8 @@ static void PickHashSigAlgo(CYASSL* ssl, byte hash256[SHA256_DIGEST_SIZE]; #endif #endif -#ifdef CYASSL_SHA384 -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SHA384 +#ifdef WOLFSSL_SMALL_STACK Sha384* sha384 = NULL; byte* hash384 = NULL; #else @@ -10067,7 +10067,7 @@ static void PickHashSigAlgo(CYASSL* ssl, byte hash384[SHA384_DIGEST_SIZE]; #endif #endif -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK byte* hash = NULL; byte* messageVerify = NULL; #else @@ -10082,7 +10082,7 @@ static void PickHashSigAlgo(CYASSL* ssl, if (verifySz > MAX_DH_SZ) ERROR_OUT(BUFFER_ERROR, done); - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK messageVerify = (byte*)XMALLOC(MAX_DH_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (messageVerify == NULL) @@ -10112,7 +10112,7 @@ static void PickHashSigAlgo(CYASSL* ssl, /* inOutIdx updated at the end of the function */ /* verify signature */ - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK hash = (byte*)XMALLOC(FINISHED_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (hash == NULL) ERROR_OUT(MEMORY_E, done); @@ -10120,7 +10120,7 @@ static void PickHashSigAlgo(CYASSL* ssl, #ifndef NO_OLD_TLS /* md5 */ - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK md5 = (Md5*)XMALLOC(sizeof(Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (md5 == NULL) ERROR_OUT(MEMORY_E, done); @@ -10132,7 +10132,7 @@ static void PickHashSigAlgo(CYASSL* ssl, Md5Final(md5, hash); /* sha */ - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK sha = (Sha*)XMALLOC(sizeof(Sha), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (sha == NULL) ERROR_OUT(MEMORY_E, done); @@ -10147,7 +10147,7 @@ static void PickHashSigAlgo(CYASSL* ssl, #endif #ifndef NO_SHA256 - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK sha256 = (Sha256*)XMALLOC(sizeof(Sha256), NULL, DYNAMIC_TYPE_TMP_BUFFER); hash256 = (byte*)XMALLOC(SHA256_DIGEST_SIZE, NULL, @@ -10164,8 +10164,8 @@ static void PickHashSigAlgo(CYASSL* ssl, goto done; #endif -#ifdef CYASSL_SHA384 - #ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SHA384 + #ifdef WOLFSSL_SMALL_STACK sha384 = (Sha384*)XMALLOC(sizeof(Sha384), NULL, DYNAMIC_TYPE_TMP_BUFFER); hash384 = (byte*)XMALLOC(SHA384_DIGEST_SIZE, NULL, @@ -10223,7 +10223,7 @@ static void PickHashSigAlgo(CYASSL* ssl, int typeH = SHA256h; int digestSz = SHA256_DIGEST_SIZE; #endif -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK byte* encodedSig = NULL; #else byte encodedSig[MAX_ENCODED_SIG_SZ]; @@ -10244,14 +10244,14 @@ static void PickHashSigAlgo(CYASSL* ssl, #endif } else if (hashAlgo == sha384_mac) { - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 digest = hash384; typeH = SHA384h; digestSz = SHA384_DIGEST_SIZE; #endif } - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK encodedSig = (byte*)XMALLOC(MAX_ENCODED_SIG_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (encodedSig == NULL) @@ -10264,7 +10264,7 @@ static void PickHashSigAlgo(CYASSL* ssl, min(encSigSz, MAX_ENCODED_SIG_SZ)) != 0) ret = VERIFY_SIGN_ERROR; - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encodedSig, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif if (ret != 0) @@ -10310,7 +10310,7 @@ static void PickHashSigAlgo(CYASSL* ssl, #endif } else if (hashAlgo == sha384_mac) { - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 digest = hash384; digestSz = SHA384_DIGEST_SIZE; #endif @@ -10342,7 +10342,7 @@ static void PickHashSigAlgo(CYASSL* ssl, ssl->options.serverState = SERVER_KEYEXCHANGE_COMPLETE; done: -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK #ifndef NO_OLD_TLS XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(sha, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -10351,7 +10351,7 @@ static void PickHashSigAlgo(CYASSL* ssl, XFREE(sha256, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(hash256, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 XFREE(sha384, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(hash384, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -10375,9 +10375,9 @@ static void PickHashSigAlgo(CYASSL* ssl, } - int SendClientKeyExchange(CYASSL* ssl) + int SendClientKeyExchange(WOLFSSL* ssl) { -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK byte* encSecret = NULL; #else byte encSecret[MAX_ENCRYPT_SZ]; @@ -10396,7 +10396,7 @@ static void PickHashSigAlgo(CYASSL* ssl, #endif /* NO_RSA */ #endif /*HAVE_PK_CALLBACKS */ - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK encSecret = (byte*)XMALLOC(MAX_ENCRYPT_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (encSecret == NULL) @@ -10409,7 +10409,7 @@ static void PickHashSigAlgo(CYASSL* ssl, ret = RNG_GenerateBlock(ssl->rng, ssl->arrays->preMasterSecret, SECRET_LEN); if (ret != 0) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; @@ -10420,7 +10420,7 @@ static void PickHashSigAlgo(CYASSL* ssl, ssl->arrays->preMasterSz = SECRET_LEN; if (ssl->peerRsaKeyPresent == 0) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return NO_PEER_KEY; @@ -10457,7 +10457,7 @@ static void PickHashSigAlgo(CYASSL* ssl, buffer serverP = ssl->buffers.serverDH_P; buffer serverG = ssl->buffers.serverDH_G; buffer serverPub = ssl->buffers.serverDH_Pub; - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK byte* priv = NULL; #else byte priv[ENCRYPT_LEN]; @@ -10467,13 +10467,13 @@ static void PickHashSigAlgo(CYASSL* ssl, if (serverP.buffer == 0 || serverG.buffer == 0 || serverPub.buffer == 0) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return NO_PEER_KEY; } - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK priv = (byte*)XMALLOC(ENCRYPT_LEN, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (priv == NULL) { @@ -10493,7 +10493,7 @@ static void PickHashSigAlgo(CYASSL* ssl, ret = DhAgree(&key, ssl->arrays->preMasterSecret, &ssl->arrays->preMasterSz, priv, privSz, serverPub.buffer, serverPub.length); - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(priv, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif FreeDhKey(&key); @@ -10510,14 +10510,14 @@ static void PickHashSigAlgo(CYASSL* ssl, MAX_PSK_ID_LEN, ssl->arrays->psk_key, MAX_PSK_KEY_LEN); if (ssl->arrays->psk_keySz == 0 || ssl->arrays->psk_keySz > MAX_PSK_KEY_LEN) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return PSK_KEY_ERROR; } encSz = (word32)XSTRLEN(ssl->arrays->client_identity); if (encSz > MAX_PSK_ID_LEN) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return CLIENT_ID_ERROR; @@ -10547,7 +10547,7 @@ static void PickHashSigAlgo(CYASSL* ssl, buffer serverP = ssl->buffers.serverDH_P; buffer serverG = ssl->buffers.serverDH_G; buffer serverPub = ssl->buffers.serverDH_Pub; - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK byte* priv = NULL; #else byte priv[ENCRYPT_LEN]; @@ -10559,7 +10559,7 @@ static void PickHashSigAlgo(CYASSL* ssl, if (serverP.buffer == 0 || serverG.buffer == 0 || serverPub.buffer == 0) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return NO_PEER_KEY; @@ -10570,7 +10570,7 @@ static void PickHashSigAlgo(CYASSL* ssl, MAX_PSK_ID_LEN, ssl->arrays->psk_key, MAX_PSK_KEY_LEN); if (ssl->arrays->psk_keySz == 0 || ssl->arrays->psk_keySz > MAX_PSK_KEY_LEN) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return PSK_KEY_ERROR; @@ -10578,13 +10578,13 @@ static void PickHashSigAlgo(CYASSL* ssl, esSz = (word32)XSTRLEN(ssl->arrays->client_identity); if (esSz > MAX_PSK_ID_LEN) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return CLIENT_ID_ERROR; } - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK priv = (byte*)XMALLOC(ENCRYPT_LEN, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (priv == NULL) { @@ -10610,11 +10610,11 @@ static void PickHashSigAlgo(CYASSL* ssl, &ssl->arrays->preMasterSz, priv, privSz, serverPub.buffer, serverPub.length); FreeDhKey(&key); - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(priv, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif if (ret != 0) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; @@ -10644,14 +10644,14 @@ static void PickHashSigAlgo(CYASSL* ssl, word32 rc; word16 cipherLen = MAX_ENCRYPT_SZ; DRBG_HANDLE drbg; - static uint8_t const cyasslStr[] = { + static uint8_t const wolfsslStr[] = { 'C', 'y', 'a', 'S', 'S', 'L', ' ', 'N', 'T', 'R', 'U' }; ret = RNG_GenerateBlock(ssl->rng, ssl->arrays->preMasterSecret, SECRET_LEN); if (ret != 0) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; @@ -10660,17 +10660,17 @@ static void PickHashSigAlgo(CYASSL* ssl, ssl->arrays->preMasterSz = SECRET_LEN; if (ssl->peerNtruKeyPresent == 0) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return NO_PEER_KEY; } - rc = ntru_crypto_drbg_instantiate(MAX_NTRU_BITS, cyasslStr, - sizeof(cyasslStr), GetEntropy, + rc = ntru_crypto_drbg_instantiate(MAX_NTRU_BITS, wolfsslStr, + sizeof(wolfsslStr), GetEntropy, &drbg); if (rc != DRBG_OK) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return NTRU_DRBG_ERROR; @@ -10683,7 +10683,7 @@ static void PickHashSigAlgo(CYASSL* ssl, &cipherLen, encSecret); ntru_crypto_drbg_uninstantiate(drbg); if (rc != NTRU_OK) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return NTRU_ENCRYPT_ERROR; @@ -10705,7 +10705,7 @@ static void PickHashSigAlgo(CYASSL* ssl, /* TODO: EccDsa is really fixed Ecc change naming */ if (!ssl->peerEccDsaKeyPresent || !ssl->peerEccDsaKey->dp) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return NO_PEER_KEY; @@ -10714,7 +10714,7 @@ static void PickHashSigAlgo(CYASSL* ssl, } else { if (!ssl->peerEccKeyPresent || !ssl->peerEccKey->dp) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return NO_PEER_KEY; @@ -10723,7 +10723,7 @@ static void PickHashSigAlgo(CYASSL* ssl, } if (peerKey == NULL) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return NO_PEER_KEY; @@ -10732,7 +10732,7 @@ static void PickHashSigAlgo(CYASSL* ssl, ecc_init(&myKey); ret = ecc_make_key(ssl->rng, peerKey->dp->size, &myKey); if (ret != 0) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return ECC_MAKEKEY_ERROR; @@ -10759,7 +10759,7 @@ static void PickHashSigAlgo(CYASSL* ssl, break; #endif /* HAVE_ECC */ default: - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return ALGO_ID_E; /* unsupported kea */ @@ -10780,7 +10780,7 @@ static void PickHashSigAlgo(CYASSL* ssl, sendSz = encSz + tlsSz + HANDSHAKE_HEADER_SZ + RECORD_HEADER_SZ; idx = HANDSHAKE_HEADER_SZ + RECORD_HEADER_SZ; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { sendSz += DTLS_HANDSHAKE_EXTRA + DTLS_RECORD_EXTRA; idx += DTLS_HANDSHAKE_EXTRA + DTLS_RECORD_EXTRA; @@ -10792,7 +10792,7 @@ static void PickHashSigAlgo(CYASSL* ssl, /* check for available size */ if ((ret = CheckAvailableSize(ssl, sendSz)) != 0) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; @@ -10818,7 +10818,7 @@ static void PickHashSigAlgo(CYASSL* ssl, input = (byte*)XMALLOC(inputSz, ssl->heap, DYNAMIC_TYPE_TMP_BUFFER); if (input == NULL) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return MEMORY_E; @@ -10829,7 +10829,7 @@ static void PickHashSigAlgo(CYASSL* ssl, handshake); XFREE(input, ssl->heap, DYNAMIC_TYPE_TMP_BUFFER); if (sendSz < 0) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return sendSz; @@ -10837,17 +10837,17 @@ static void PickHashSigAlgo(CYASSL* ssl, } else { ret = HashOutput(ssl, output, sendSz, 0); if (ret != 0) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; } } - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; @@ -10855,7 +10855,7 @@ static void PickHashSigAlgo(CYASSL* ssl, } #endif - #ifdef CYASSL_CALLBACKS + #ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("ClientKeyExchange", &ssl->handShakeInfo); if (ssl->toInfoOn) @@ -10871,7 +10871,7 @@ static void PickHashSigAlgo(CYASSL* ssl, ret = SendBuffered(ssl); } - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encSecret, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -10889,7 +10889,7 @@ static void PickHashSigAlgo(CYASSL* ssl, } #ifndef NO_CERTS - int SendCertificateVerify(CYASSL* ssl) + int SendCertificateVerify(WOLFSSL* ssl) { byte *output; int sendSz = MAX_CERT_VERIFY_SZ, length, ret; @@ -10939,18 +10939,18 @@ static void PickHashSigAlgo(CYASSL* ssl, #endif { #ifdef HAVE_ECC - CYASSL_MSG("Trying ECC client cert, RSA didn't work"); + WOLFSSL_MSG("Trying ECC client cert, RSA didn't work"); idx = 0; ret = EccPrivateKeyDecode(ssl->buffers.key.buffer, &idx, &eccKey, ssl->buffers.key.length); if (ret == 0) { - CYASSL_MSG("Using ECC client cert"); + WOLFSSL_MSG("Using ECC client cert"); usingEcc = 1; sigOutSz = MAX_ENCODED_SIG_SZ; } else { - CYASSL_MSG("Bad client cert type"); + WOLFSSL_MSG("Bad client cert type"); } #endif } @@ -10964,13 +10964,13 @@ static void PickHashSigAlgo(CYASSL* ssl, #endif word32 signSz = FINISHED_SZ; word32 extraSz = 0; /* tls 1.2 hash/sig */ -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK byte* encodedSig = NULL; #else byte encodedSig[MAX_ENCODED_SIG_SZ]; #endif -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK encodedSig = (byte*)XMALLOC(MAX_ENCODED_SIG_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (encodedSig == NULL) { @@ -10989,7 +10989,7 @@ static void PickHashSigAlgo(CYASSL* ssl, (void)signSz; (void)signBuffer; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) verify += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA; #endif @@ -11037,7 +11037,7 @@ static void PickHashSigAlgo(CYASSL* ssl, #endif } else if (ssl->suites->hashAlgo == sha384_mac) { - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 digest = ssl->certHashes.sha384; digestSz = SHA384_DIGEST_SIZE; #endif @@ -11101,7 +11101,7 @@ static void PickHashSigAlgo(CYASSL* ssl, #endif } else if (ssl->suites->hashAlgo == sha384_mac) { - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 digest = ssl->certHashes.sha384; typeH = SHA384h; digestSz = SHA384_DIGEST_SIZE; @@ -11135,7 +11135,7 @@ static void PickHashSigAlgo(CYASSL* ssl, ret = 0; /* RSA reset */ } #endif -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(encodedSig, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -11146,7 +11146,7 @@ static void PickHashSigAlgo(CYASSL* ssl, sendSz = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ + length + extraSz + VERIFY_HEADER; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { sendSz += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA; } @@ -11174,7 +11174,7 @@ static void PickHashSigAlgo(CYASSL* ssl, ret = HashOutput(ssl, output, sendSz, 0); } - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) return ret; @@ -11191,7 +11191,7 @@ static void PickHashSigAlgo(CYASSL* ssl, #endif if (ret == 0) { - #ifdef CYASSL_CALLBACKS + #ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("CertificateVerify", &ssl->handShakeInfo); if (ssl->toInfoOn) @@ -11210,7 +11210,7 @@ static void PickHashSigAlgo(CYASSL* ssl, #endif /* NO_CERTS */ #ifdef HAVE_SESSION_TICKET -int DoSessionTicket(CYASSL* ssl, +int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx, word32 size) { word32 begin = *inOutIdx; @@ -11218,7 +11218,7 @@ int DoSessionTicket(CYASSL* ssl, word16 length; if (ssl->expect_session_ticket == 0) { - CYASSL_MSG("Unexpected session ticket"); + WOLFSSL_MSG("Unexpected session ticket"); return SESSION_TICKET_EXPECT_E; } @@ -11276,12 +11276,12 @@ int DoSessionTicket(CYASSL* ssl, } #endif /* HAVE_SESSION_TICKET */ -#endif /* NO_CYASSL_CLIENT */ +#endif /* NO_WOLFSSL_CLIENT */ -#ifndef NO_CYASSL_SERVER +#ifndef NO_WOLFSSL_SERVER - int SendServerHello(CYASSL* ssl) + int SendServerHello(WOLFSSL* ssl) { byte *output; word32 length, idx = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ; @@ -11308,7 +11308,7 @@ int DoSessionTicket(CYASSL* ssl, sendSz = length + HANDSHAKE_HEADER_SZ + RECORD_HEADER_SZ; AddHeaders(output, length, server_hello, ssl); - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { idx += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA; sendSz += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA; @@ -11367,7 +11367,7 @@ int DoSessionTicket(CYASSL* ssl, #endif ssl->buffers.outputBuffer.length += sendSz; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) return ret; @@ -11378,7 +11378,7 @@ int DoSessionTicket(CYASSL* ssl, if (ret != 0) return ret; - #ifdef CYASSL_CALLBACKS + #ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("ServerHello", &ssl->handShakeInfo); if (ssl->toInfoOn) @@ -11420,7 +11420,7 @@ int DoSessionTicket(CYASSL* ssl, #endif /* HAVE_ECC */ - int SendServerKeyExchange(CYASSL* ssl) + int SendServerKeyExchange(WOLFSSL* ssl) { int ret = 0; (void)ssl; @@ -11442,7 +11442,7 @@ int DoSessionTicket(CYASSL* ssl, length += HINT_LEN_SZ; sendSz = length + HANDSHAKE_HEADER_SZ + RECORD_HEADER_SZ; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { sendSz += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA; idx += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA; @@ -11463,7 +11463,7 @@ int DoSessionTicket(CYASSL* ssl, idx += HINT_LEN_SZ; XMEMCPY(output + idx, ssl->arrays->server_hint,length -HINT_LEN_SZ); - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) return ret; @@ -11473,7 +11473,7 @@ int DoSessionTicket(CYASSL* ssl, if (ret != 0) return ret; - #ifdef CYASSL_CALLBACKS + #ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("ServerKeyExchange", &ssl->handShakeInfo); if (ssl->toInfoOn) @@ -11545,7 +11545,7 @@ int DoSessionTicket(CYASSL* ssl, length += hintLen + HINT_LEN_SZ; sendSz = length + HANDSHAKE_HEADER_SZ + RECORD_HEADER_SZ; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { sendSz += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA; idx += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA; @@ -11590,7 +11590,7 @@ int DoSessionTicket(CYASSL* ssl, idx += ssl->buffers.serverDH_Pub.length; (void)idx; /* suppress analyzer warning, and keep idx current */ - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) return ret; @@ -11601,7 +11601,7 @@ int DoSessionTicket(CYASSL* ssl, if (ret != 0) return ret; - #ifdef CYASSL_CALLBACKS + #ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("ServerKeyExchange", &ssl->handShakeInfo); if (ssl->toInfoOn) @@ -11630,7 +11630,7 @@ int DoSessionTicket(CYASSL* ssl, RsaKey rsaKey; #endif ecc_key dsaKey; - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK byte* exportBuf = NULL; #else byte exportBuf[MAX_EXPORT_ECC_SZ]; @@ -11638,14 +11638,14 @@ int DoSessionTicket(CYASSL* ssl, word32 expSz = MAX_EXPORT_ECC_SZ; if (ssl->specs.static_ecdh) { - CYASSL_MSG("Using Static ECDH, not sending ServerKeyExchagne"); + WOLFSSL_MSG("Using Static ECDH, not sending ServerKeyExchagne"); return 0; } /* curve type, named curve, length(1) */ length = ENUM_LEN + CURVE_LEN + ENUM_LEN; /* pub key size */ - CYASSL_MSG("Using ephemeral ECDH"); + WOLFSSL_MSG("Using ephemeral ECDH"); /* need ephemeral key now, create it if missing */ if (ssl->eccTempKeyPresent == 0) { @@ -11656,7 +11656,7 @@ int DoSessionTicket(CYASSL* ssl, ssl->eccTempKeyPresent = 1; } - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK exportBuf = (byte*)XMALLOC(MAX_EXPORT_ECC_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (exportBuf == NULL) @@ -11724,7 +11724,7 @@ int DoSessionTicket(CYASSL* ssl, sendSz = length + HANDSHAKE_HEADER_SZ + RECORD_HEADER_SZ; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { sendSz += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA; idx += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA; @@ -11771,7 +11771,7 @@ int DoSessionTicket(CYASSL* ssl, /* do signature */ { #ifndef NO_OLD_TLS - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK Md5* md5 = NULL; Sha* sha = NULL; #else @@ -11779,13 +11779,13 @@ int DoSessionTicket(CYASSL* ssl, Sha sha[1]; #endif #endif - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK byte* hash = NULL; #else byte hash[FINISHED_SZ]; #endif #ifndef NO_SHA256 - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK Sha256* sha256 = NULL; byte* hash256 = NULL; #else @@ -11793,8 +11793,8 @@ int DoSessionTicket(CYASSL* ssl, byte hash256[SHA256_DIGEST_SIZE]; #endif #endif - #ifdef CYASSL_SHA384 - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SHA384 + #ifdef WOLFSSL_SMALL_STACK Sha384* sha384 = NULL; byte* hash384 = NULL; #else @@ -11803,7 +11803,7 @@ int DoSessionTicket(CYASSL* ssl, #endif #endif - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK hash = (byte*)XMALLOC(FINISHED_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (hash == NULL) @@ -11812,7 +11812,7 @@ int DoSessionTicket(CYASSL* ssl, #ifndef NO_OLD_TLS /* md5 */ - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK md5 = (Md5*)XMALLOC(sizeof(Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (md5 == NULL) ERROR_OUT(MEMORY_E, done_a2); @@ -11824,7 +11824,7 @@ int DoSessionTicket(CYASSL* ssl, Md5Final(md5, hash); /* sha */ - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK sha = (Sha*)XMALLOC(sizeof(Sha), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (sha == NULL) ERROR_OUT(MEMORY_E, done_a2); @@ -11839,7 +11839,7 @@ int DoSessionTicket(CYASSL* ssl, #endif #ifndef NO_SHA256 - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK sha256 = (Sha256*)XMALLOC(sizeof(Sha256), NULL, DYNAMIC_TYPE_TMP_BUFFER); hash256 = (byte*)XMALLOC(SHA256_DIGEST_SIZE, NULL, @@ -11860,8 +11860,8 @@ int DoSessionTicket(CYASSL* ssl, goto done_a2; #endif - #ifdef CYASSL_SHA384 - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SHA384 + #ifdef WOLFSSL_SMALL_STACK sha384 = (Sha384*)XMALLOC(sizeof(Sha384), NULL, DYNAMIC_TYPE_TMP_BUFFER); hash384 = (byte*)XMALLOC(SHA384_DIGEST_SIZE, NULL, @@ -11887,7 +11887,7 @@ int DoSessionTicket(CYASSL* ssl, byte* signBuffer = hash; word32 signSz = FINISHED_SZ; byte doUserRsa = 0; - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK byte* encodedSig = NULL; #else byte encodedSig[MAX_ENCODED_SIG_SZ]; @@ -11898,7 +11898,7 @@ int DoSessionTicket(CYASSL* ssl, doUserRsa = 1; #endif - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK encodedSig = (byte*)XMALLOC(MAX_ENCODED_SIG_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (encodedSig == NULL) @@ -11918,7 +11918,7 @@ int DoSessionTicket(CYASSL* ssl, #endif } else if (ssl->suites->hashAlgo == sha384_mac) { - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 digest = hash384; typeH = SHA384h; digestSz = SHA384_DIGEST_SIZE; @@ -11950,7 +11950,7 @@ int DoSessionTicket(CYASSL* ssl, FreeRsaKey(&rsaKey); ecc_free(&dsaKey); - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encodedSig, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -11989,7 +11989,7 @@ int DoSessionTicket(CYASSL* ssl, #endif } else if (ssl->suites->hashAlgo == sha384_mac) { - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 digest = hash384; digestSz = SHA384_DIGEST_SIZE; #endif @@ -12026,7 +12026,7 @@ int DoSessionTicket(CYASSL* ssl, } done_a2: - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK #ifndef NO_OLD_TLS XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(sha, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -12036,7 +12036,7 @@ int DoSessionTicket(CYASSL* ssl, XFREE(sha256, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(hash256, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 XFREE(sha384, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(hash384, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -12048,7 +12048,7 @@ int DoSessionTicket(CYASSL* ssl, AddHeaders(output, length, server_key_exchange, ssl); - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) goto done_a; @@ -12057,7 +12057,7 @@ int DoSessionTicket(CYASSL* ssl, if ((ret = HashOutput(ssl, output, sendSz, 0)) != 0) goto done_a; - #ifdef CYASSL_CALLBACKS + #ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("ServerKeyExchange", &ssl->handShakeInfo); if (ssl->toInfoOn) @@ -12073,7 +12073,7 @@ int DoSessionTicket(CYASSL* ssl, ssl->options.serverState = SERVER_KEYEXCHANGE_COMPLETE; done_a: - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(exportBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -12161,7 +12161,7 @@ int DoSessionTicket(CYASSL* ssl, sendSz = length + HANDSHAKE_HEADER_SZ + RECORD_HEADER_SZ; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { sendSz += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA; idx += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA; @@ -12212,7 +12212,7 @@ int DoSessionTicket(CYASSL* ssl, /* Add signature */ if (!ssl->options.usingAnon_cipher) { #ifndef NO_OLD_TLS - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK Md5* md5 = NULL; Sha* sha = NULL; #else @@ -12220,13 +12220,13 @@ int DoSessionTicket(CYASSL* ssl, Sha sha[1]; #endif #endif - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK byte* hash = NULL; #else byte hash[FINISHED_SZ]; #endif #ifndef NO_SHA256 - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK Sha256* sha256 = NULL; byte* hash256 = NULL; #else @@ -12234,8 +12234,8 @@ int DoSessionTicket(CYASSL* ssl, byte hash256[SHA256_DIGEST_SIZE]; #endif #endif - #ifdef CYASSL_SHA384 - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SHA384 + #ifdef WOLFSSL_SMALL_STACK Sha384* sha384 = NULL; byte* hash384 = NULL; #else @@ -12255,7 +12255,7 @@ int DoSessionTicket(CYASSL* ssl, idx += LENGTH_SZ; /* do signature */ - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK hash = (byte*)XMALLOC(FINISHED_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (hash == NULL) @@ -12266,7 +12266,7 @@ int DoSessionTicket(CYASSL* ssl, #ifndef NO_OLD_TLS /* md5 */ - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK md5 = (Md5*)XMALLOC(sizeof(Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (md5 == NULL) ERROR_OUT(MEMORY_E, done_b); @@ -12278,7 +12278,7 @@ int DoSessionTicket(CYASSL* ssl, Md5Final(md5, hash); /* sha */ - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK sha = (Sha*)XMALLOC(sizeof(Sha), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (sha == NULL) ERROR_OUT(MEMORY_E, done_b); @@ -12294,7 +12294,7 @@ int DoSessionTicket(CYASSL* ssl, #endif #ifndef NO_SHA256 - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK sha256 = (Sha256*)XMALLOC(sizeof(Sha256), NULL, DYNAMIC_TYPE_TMP_BUFFER); hash256 = (byte*)XMALLOC(SHA256_DIGEST_SIZE, NULL, @@ -12315,8 +12315,8 @@ int DoSessionTicket(CYASSL* ssl, goto done_b; #endif - #ifdef CYASSL_SHA384 - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SHA384 + #ifdef WOLFSSL_SMALL_STACK sha384 = (Sha384*)XMALLOC(sizeof(Sha384), NULL, DYNAMIC_TYPE_TMP_BUFFER); hash384 = (byte*)XMALLOC(SHA384_DIGEST_SIZE, NULL, @@ -12341,7 +12341,7 @@ int DoSessionTicket(CYASSL* ssl, if (ssl->suites->sigAlgo == rsa_sa_algo) { byte* signBuffer = hash; word32 signSz = FINISHED_SZ; - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK byte* encodedSig = NULL; #else byte encodedSig[MAX_ENCODED_SIG_SZ]; @@ -12353,7 +12353,7 @@ int DoSessionTicket(CYASSL* ssl, doUserRsa = 1; #endif - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK encodedSig = (byte*)XMALLOC(MAX_ENCODED_SIG_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (encodedSig == NULL) @@ -12373,7 +12373,7 @@ int DoSessionTicket(CYASSL* ssl, #endif } else if (ssl->suites->hashAlgo == sha384_mac) { - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 digest = hash384; typeH = SHA384h; digestSz = SHA384_DIGEST_SIZE; @@ -12400,14 +12400,14 @@ int DoSessionTicket(CYASSL* ssl, FreeRsaKey(&rsaKey); - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(encodedSig, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif } #endif done_b: - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK #ifndef NO_OLD_TLS XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(sha, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -12417,7 +12417,7 @@ int DoSessionTicket(CYASSL* ssl, XFREE(sha256, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(hash256, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 XFREE(sha384, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(hash384, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -12426,7 +12426,7 @@ int DoSessionTicket(CYASSL* ssl, if (ret < 0) return ret; } - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) return ret; @@ -12435,7 +12435,7 @@ int DoSessionTicket(CYASSL* ssl, if ((ret = HashOutput(ssl, output, sendSz, 0)) != 0) return ret; - #ifdef CYASSL_CALLBACKS + #ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("ServerKeyExchange", &ssl->handShakeInfo); if (ssl->toInfoOn) @@ -12458,17 +12458,17 @@ int DoSessionTicket(CYASSL* ssl, /* Make sure server cert/key are valid for this suite, true on success */ - static int VerifyServerSuite(CYASSL* ssl, word16 idx) + static int VerifyServerSuite(WOLFSSL* ssl, word16 idx) { int haveRSA = !ssl->options.haveStaticECC; int havePSK = 0; byte first; byte second; - CYASSL_ENTER("VerifyServerSuite"); + WOLFSSL_ENTER("VerifyServerSuite"); if (ssl->suites == NULL) { - CYASSL_MSG("Suites pointer error"); + WOLFSSL_MSG("Suites pointer error"); return 0; } @@ -12483,65 +12483,65 @@ int DoSessionTicket(CYASSL* ssl, haveRSA = 0; if (CipherRequires(first, second, REQUIRES_RSA)) { - CYASSL_MSG("Requires RSA"); + WOLFSSL_MSG("Requires RSA"); if (haveRSA == 0) { - CYASSL_MSG("Don't have RSA"); + WOLFSSL_MSG("Don't have RSA"); return 0; } } if (CipherRequires(first, second, REQUIRES_DHE)) { - CYASSL_MSG("Requires DHE"); + WOLFSSL_MSG("Requires DHE"); if (ssl->options.haveDH == 0) { - CYASSL_MSG("Don't have DHE"); + WOLFSSL_MSG("Don't have DHE"); return 0; } } if (CipherRequires(first, second, REQUIRES_ECC_DSA)) { - CYASSL_MSG("Requires ECCDSA"); + WOLFSSL_MSG("Requires ECCDSA"); if (ssl->options.haveECDSAsig == 0) { - CYASSL_MSG("Don't have ECCDSA"); + WOLFSSL_MSG("Don't have ECCDSA"); return 0; } } if (CipherRequires(first, second, REQUIRES_ECC_STATIC)) { - CYASSL_MSG("Requires static ECC"); + WOLFSSL_MSG("Requires static ECC"); if (ssl->options.haveStaticECC == 0) { - CYASSL_MSG("Don't have static ECC"); + WOLFSSL_MSG("Don't have static ECC"); return 0; } } if (CipherRequires(first, second, REQUIRES_PSK)) { - CYASSL_MSG("Requires PSK"); + WOLFSSL_MSG("Requires PSK"); if (havePSK == 0) { - CYASSL_MSG("Don't have PSK"); + WOLFSSL_MSG("Don't have PSK"); return 0; } } if (CipherRequires(first, second, REQUIRES_NTRU)) { - CYASSL_MSG("Requires NTRU"); + WOLFSSL_MSG("Requires NTRU"); if (ssl->options.haveNTRU == 0) { - CYASSL_MSG("Don't have NTRU"); + WOLFSSL_MSG("Don't have NTRU"); return 0; } } if (CipherRequires(first, second, REQUIRES_RSA_SIG)) { - CYASSL_MSG("Requires RSA Signature"); - if (ssl->options.side == CYASSL_SERVER_END && + WOLFSSL_MSG("Requires RSA Signature"); + if (ssl->options.side == WOLFSSL_SERVER_END && ssl->options.haveECDSAsig == 1) { - CYASSL_MSG("Don't have RSA Signature"); + WOLFSSL_MSG("Don't have RSA Signature"); return 0; } } #ifdef HAVE_SUPPORTED_CURVES if (!TLSX_ValidateEllipticCurves(ssl, first, second)) { - CYASSL_MSG("Don't have matching curves"); + WOLFSSL_MSG("Don't have matching curves"); return 0; } #endif @@ -12552,11 +12552,11 @@ int DoSessionTicket(CYASSL* ssl, } - static int MatchSuite(CYASSL* ssl, Suites* peerSuites) + static int MatchSuite(WOLFSSL* ssl, Suites* peerSuites) { word16 i, j; - CYASSL_ENTER("MatchSuite"); + WOLFSSL_ENTER("MatchSuite"); /* & 0x1 equivalent % 2 */ if (peerSuites->suiteSz == 0 || peerSuites->suiteSz & 0x1) @@ -12572,7 +12572,7 @@ int DoSessionTicket(CYASSL* ssl, if (VerifyServerSuite(ssl, i)) { int result; - CYASSL_MSG("Verified suite validity"); + WOLFSSL_MSG("Verified suite validity"); ssl->options.cipherSuite0 = ssl->suites->suites[i]; ssl->options.cipherSuite = ssl->suites->suites[i+1]; result = SetCipherSpecs(ssl); @@ -12582,7 +12582,7 @@ int DoSessionTicket(CYASSL* ssl, return result; } else { - CYASSL_MSG("Could not verify suite validity, continue"); + WOLFSSL_MSG("Could not verify suite validity, continue"); } } @@ -12593,7 +12593,7 @@ int DoSessionTicket(CYASSL* ssl, #ifdef OLD_HELLO_ALLOWED /* process old style client hello, deprecate? */ - int ProcessOldClientHello(CYASSL* ssl, const byte* input, word32* inOutIdx, + int ProcessOldClientHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx, word32 inSz, word16 sz) { word32 idx = *inOutIdx; @@ -12604,8 +12604,8 @@ int DoSessionTicket(CYASSL* ssl, Suites clSuites; (void)inSz; - CYASSL_MSG("Got old format client hello"); -#ifdef CYASSL_CALLBACKS + WOLFSSL_MSG("Got old format client hello"); +#ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("ClientHello", &ssl->handShakeInfo); if (ssl->toInfoOn) @@ -12642,28 +12642,28 @@ int DoSessionTicket(CYASSL* ssl, byte haveRSA = 0; byte havePSK = 0; if (!ssl->options.downgrade) { - CYASSL_MSG("Client trying to connect with lesser version"); + WOLFSSL_MSG("Client trying to connect with lesser version"); return VERSION_ERROR; } if (pv.minor < ssl->options.minDowngrade) { - CYASSL_MSG(" version below minimum allowed, fatal error"); + WOLFSSL_MSG(" version below minimum allowed, fatal error"); return VERSION_ERROR; } if (pv.minor == SSLv3_MINOR) { /* turn off tls */ - CYASSL_MSG(" downgrading to SSLv3"); + WOLFSSL_MSG(" downgrading to SSLv3"); ssl->options.tls = 0; ssl->options.tls1_1 = 0; ssl->version.minor = SSLv3_MINOR; } else if (pv.minor == TLSv1_MINOR) { - CYASSL_MSG(" downgrading to TLSv1"); + WOLFSSL_MSG(" downgrading to TLSv1"); /* turn off tls 1.1+ */ ssl->options.tls1_1 = 0; ssl->version.minor = TLSv1_MINOR; } else if (pv.minor == TLSv1_1_MINOR) { - CYASSL_MSG(" downgrading to TLSv1.1"); + WOLFSSL_MSG(" downgrading to TLSv1.1"); ssl->version.minor = TLSv1_1_MINOR; } #ifndef NO_RSA @@ -12736,13 +12736,13 @@ int DoSessionTicket(CYASSL* ssl, /* DoClientHello uses same resume code */ if (ssl->options.resuming) { /* let's try */ int ret = -1; - CYASSL_SESSION* session = GetSession(ssl,ssl->arrays->masterSecret); + WOLFSSL_SESSION* session = GetSession(ssl,ssl->arrays->masterSecret); if (!session) { - CYASSL_MSG("Session lookup for resume failed"); + WOLFSSL_MSG("Session lookup for resume failed"); ssl->options.resuming = 0; } else { if (MatchSuite(ssl, &clSuites) < 0) { - CYASSL_MSG("Unsupported cipher suite, OldClientHello"); + WOLFSSL_MSG("Unsupported cipher suite, OldClientHello"); return UNSUPPORTED_SUITE; } #ifdef SESSION_CERTS @@ -12776,7 +12776,7 @@ int DoSessionTicket(CYASSL* ssl, #endif /* OLD_HELLO_ALLOWED */ - static int DoClientHello(CYASSL* ssl, const byte* input, word32* inOutIdx, + static int DoClientHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx, word32 helloSz) { byte b; @@ -12785,7 +12785,7 @@ int DoSessionTicket(CYASSL* ssl, word32 i = *inOutIdx; word32 begin = i; -#ifdef CYASSL_CALLBACKS +#ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("ClientHello", &ssl->handShakeInfo); if (ssl->toInfoOn) AddLateName("ClientHello", &ssl->timeoutInfo); #endif @@ -12804,29 +12804,29 @@ int DoSessionTicket(CYASSL* ssl, byte havePSK = 0; if (!ssl->options.downgrade) { - CYASSL_MSG("Client trying to connect with lesser version"); + WOLFSSL_MSG("Client trying to connect with lesser version"); return VERSION_ERROR; } if (pv.minor < ssl->options.minDowngrade) { - CYASSL_MSG(" version below minimum allowed, fatal error"); + WOLFSSL_MSG(" version below minimum allowed, fatal error"); return VERSION_ERROR; } if (pv.minor == SSLv3_MINOR) { /* turn off tls */ - CYASSL_MSG(" downgrading to SSLv3"); + WOLFSSL_MSG(" downgrading to SSLv3"); ssl->options.tls = 0; ssl->options.tls1_1 = 0; ssl->version.minor = SSLv3_MINOR; } else if (pv.minor == TLSv1_MINOR) { /* turn off tls 1.1+ */ - CYASSL_MSG(" downgrading to TLSv1"); + WOLFSSL_MSG(" downgrading to TLSv1"); ssl->options.tls1_1 = 0; ssl->version.minor = TLSv1_MINOR; } else if (pv.minor == TLSv1_1_MINOR) { - CYASSL_MSG(" downgrading to TLSv1.1"); + WOLFSSL_MSG(" downgrading to TLSv1.1"); ssl->version.minor = TLSv1_1_MINOR; } #ifndef NO_RSA @@ -12865,14 +12865,14 @@ int DoSessionTicket(CYASSL* ssl, XMEMCPY(ssl->arrays->sessionID, input + i, ID_LEN); i += ID_LEN; ssl->options.resuming = 1; /* client wants to resume */ - CYASSL_MSG("Client wants to resume session"); + WOLFSSL_MSG("Client wants to resume session"); } else if (b) { - CYASSL_MSG("Invalid session ID size"); + WOLFSSL_MSG("Invalid session ID size"); return BUFFER_ERROR; /* session ID nor 0 neither 32 bytes long */ } - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS /* cookie */ if (ssl->options.dtls) { @@ -12891,7 +12891,7 @@ int DoSessionTicket(CYASSL* ssl, return BUFFER_ERROR; if (ssl->ctx->CBIOCookie == NULL) { - CYASSL_MSG("Your Cookie callback is null, please set"); + WOLFSSL_MSG("Your Cookie callback is null, please set"); return COOKIE_ERROR; } @@ -12942,7 +12942,7 @@ int DoSessionTicket(CYASSL* ssl, } if (!match) { - CYASSL_MSG("Not matching compression, turning off"); + WOLFSSL_MSG("Not matching compression, turning off"); ssl->options.usingCompression = 0; /* turn off */ } } @@ -13025,15 +13025,15 @@ int DoSessionTicket(CYASSL* ssl, if (ssl->options.resuming && (!ssl->options.dtls || ssl->options.acceptState == HELLO_VERIFY_SENT)) { /* let's try */ int ret = -1; - CYASSL_SESSION* session = GetSession(ssl,ssl->arrays->masterSecret); + WOLFSSL_SESSION* session = GetSession(ssl,ssl->arrays->masterSecret); if (!session) { - CYASSL_MSG("Session lookup for resume failed"); + WOLFSSL_MSG("Session lookup for resume failed"); ssl->options.resuming = 0; } else { if (MatchSuite(ssl, &clSuites) < 0) { - CYASSL_MSG("Unsupported cipher suite, ClientHello"); + WOLFSSL_MSG("Unsupported cipher suite, ClientHello"); return UNSUPPORTED_SUITE; } #ifdef SESSION_CERTS @@ -13064,7 +13064,7 @@ int DoSessionTicket(CYASSL* ssl, } #if !defined(NO_RSA) || defined(HAVE_ECC) - static int DoCertificateVerify(CYASSL* ssl, byte* input, word32* inOutIdx, + static int DoCertificateVerify(WOLFSSL* ssl, byte* input, word32* inOutIdx, word32 size) { word16 sz = 0; @@ -13073,7 +13073,7 @@ int DoSessionTicket(CYASSL* ssl, byte sigAlgo = anonymous_sa_algo; word32 begin = *inOutIdx; - #ifdef CYASSL_CALLBACKS + #ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("CertificateVerify", &ssl->handShakeInfo); if (ssl->toInfoOn) @@ -13110,7 +13110,7 @@ int DoSessionTicket(CYASSL* ssl, doUserRsa = 1; #endif /*HAVE_PK_CALLBACKS */ - CYASSL_MSG("Doing RSA peer cert verify"); + WOLFSSL_MSG("Doing RSA peer cert verify"); if (doUserRsa) { #ifdef HAVE_PK_CALLBACKS @@ -13127,7 +13127,7 @@ int DoSessionTicket(CYASSL* ssl, } if (IsAtLeastTLSv1_2(ssl)) { -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK byte* encodedSig = NULL; #else byte encodedSig[MAX_ENCODED_SIG_SZ]; @@ -13137,7 +13137,7 @@ int DoSessionTicket(CYASSL* ssl, int typeH = SHAh; int digestSz = SHA_DIGEST_SIZE; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK encodedSig = (byte*)XMALLOC(MAX_ENCODED_SIG_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (encodedSig == NULL) @@ -13145,7 +13145,7 @@ int DoSessionTicket(CYASSL* ssl, #endif if (sigAlgo != rsa_sa_algo) { - CYASSL_MSG("Oops, peer sent RSA key but not in verify"); + WOLFSSL_MSG("Oops, peer sent RSA key but not in verify"); } if (hashAlgo == sha256_mac) { @@ -13156,7 +13156,7 @@ int DoSessionTicket(CYASSL* ssl, #endif } else if (hashAlgo == sha384_mac) { - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 digest = ssl->certHashes.sha384; typeH = SHA384h; digestSz = SHA384_DIGEST_SIZE; @@ -13169,7 +13169,7 @@ int DoSessionTicket(CYASSL* ssl, min(sigSz, MAX_ENCODED_SIG_SZ)) == 0) ret = 0; /* verified */ -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(encodedSig, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif } @@ -13193,11 +13193,11 @@ int DoSessionTicket(CYASSL* ssl, doUserEcc = 1; #endif - CYASSL_MSG("Doing ECC peer cert verify"); + WOLFSSL_MSG("Doing ECC peer cert verify"); if (IsAtLeastTLSv1_2(ssl)) { if (sigAlgo != ecc_dsa_sa_algo) { - CYASSL_MSG("Oops, peer sent ECC key but not in verify"); + WOLFSSL_MSG("Oops, peer sent ECC key but not in verify"); } if (hashAlgo == sha256_mac) { @@ -13207,7 +13207,7 @@ int DoSessionTicket(CYASSL* ssl, #endif } else if (hashAlgo == sha384_mac) { - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 digest = ssl->certHashes.sha384; digestSz = SHA384_DIGEST_SIZE; #endif @@ -13241,13 +13241,13 @@ int DoSessionTicket(CYASSL* ssl, } #endif /* !NO_RSA || HAVE_ECC */ - int SendServerHelloDone(CYASSL* ssl) + int SendServerHelloDone(WOLFSSL* ssl) { byte *output; int sendSz = RECORD_HEADER_SZ + HANDSHAKE_HEADER_SZ; int ret; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) sendSz += DTLS_RECORD_EXTRA + DTLS_HANDSHAKE_EXTRA; #endif @@ -13261,7 +13261,7 @@ int DoSessionTicket(CYASSL* ssl, AddHeaders(output, 0, server_hello_done, ssl); - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { if ((ret = DtlsPoolSave(ssl, output, sendSz)) != 0) return 0; @@ -13272,7 +13272,7 @@ int DoSessionTicket(CYASSL* ssl, if (ret != 0) return ret; -#ifdef CYASSL_CALLBACKS +#ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("ServerHelloDone", &ssl->handShakeInfo); if (ssl->toInfoOn) @@ -13286,8 +13286,8 @@ int DoSessionTicket(CYASSL* ssl, return SendBuffered(ssl); } -#ifdef CYASSL_DTLS - int SendHelloVerifyRequest(CYASSL* ssl) +#ifdef WOLFSSL_DTLS + int SendHelloVerifyRequest(WOLFSSL* ssl) { byte* output; byte cookieSz = COOKIE_SZ; @@ -13311,7 +13311,7 @@ int DoSessionTicket(CYASSL* ssl, output[idx++] = cookieSz; if (ssl->ctx->CBIOCookie == NULL) { - CYASSL_MSG("Your Cookie callback is null, please set"); + WOLFSSL_MSG("Your Cookie callback is null, please set"); return COOKIE_ERROR; } if ((ret = ssl->ctx->CBIOCookie(ssl, output + idx, cookieSz, @@ -13322,7 +13322,7 @@ int DoSessionTicket(CYASSL* ssl, if (ret != 0) return ret; -#ifdef CYASSL_CALLBACKS +#ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("HelloVerifyRequest", &ssl->handShakeInfo); if (ssl->toInfoOn) @@ -13337,7 +13337,7 @@ int DoSessionTicket(CYASSL* ssl, } #endif - static int DoClientKeyExchange(CYASSL* ssl, byte* input, word32* inOutIdx, + static int DoClientKeyExchange(WOLFSSL* ssl, byte* input, word32* inOutIdx, word32 size) { int ret = 0; @@ -13351,14 +13351,14 @@ int DoSessionTicket(CYASSL* ssl, (void)size; (void)begin; - if (ssl->options.side != CYASSL_SERVER_END) { - CYASSL_MSG("Client received client keyexchange, attack?"); - CYASSL_ERROR(ssl->error = SIDE_ERROR); + if (ssl->options.side != WOLFSSL_SERVER_END) { + WOLFSSL_MSG("Client received client keyexchange, attack?"); + WOLFSSL_ERROR(ssl->error = SIDE_ERROR); return SSL_FATAL_ERROR; } if (ssl->options.clientState < CLIENT_HELLO_COMPLETE) { - CYASSL_MSG("Client sending keyexchange at wrong time"); + WOLFSSL_MSG("Client sending keyexchange at wrong time"); SendAlert(ssl, alert_fatal, unexpected_message); return OUT_OF_ORDER_E; } @@ -13366,12 +13366,12 @@ int DoSessionTicket(CYASSL* ssl, #ifndef NO_CERTS if (ssl->options.verifyPeer && ssl->options.failNoCert) if (!ssl->options.havePeerCert) { - CYASSL_MSG("client didn't present peer cert"); + WOLFSSL_MSG("client didn't present peer cert"); return NO_PEER_CERT; } #endif - #ifdef CYASSL_CALLBACKS + #ifdef WOLFSSL_CALLBACKS if (ssl->hsInfoOn) AddPacketName("ClientKeyExchange", &ssl->handShakeInfo); if (ssl->toInfoOn) @@ -13414,14 +13414,14 @@ int DoSessionTicket(CYASSL* ssl, *inOutIdx += OPAQUE16_LEN; if ((word32) check != length) { - CYASSL_MSG("RSA explicit size doesn't match"); + WOLFSSL_MSG("RSA explicit size doesn't match"); FreeRsaKey(&key); return RSA_PRIVATE_ERROR; } } if ((*inOutIdx - begin) + length > size) { - CYASSL_MSG("RSA message too big"); + WOLFSSL_MSG("RSA message too big"); FreeRsaKey(&key); return BUFFER_ERROR; } @@ -13592,7 +13592,7 @@ int DoSessionTicket(CYASSL* ssl, } else { if (ssl->eccTempKeyPresent == 0) { - CYASSL_MSG("Ecc ephemeral key not made correctly"); + WOLFSSL_MSG("Ecc ephemeral key not made correctly"); ret = ECC_MAKEKEY_ERROR; } else { ret = ecc_shared_secret(ssl->eccTempKey,ssl->peerEccKey, @@ -13723,7 +13723,7 @@ int DoSessionTicket(CYASSL* ssl, #endif /* !NO_DH && !NO_PSK */ default: { - CYASSL_MSG("Bad kea type"); + WOLFSSL_MSG("Bad kea type"); ret = BAD_KEA_TYPE_E; } break; @@ -13744,4 +13744,4 @@ int DoSessionTicket(CYASSL* ssl, return ret; } -#endif /* NO_CYASSL_SERVER */ +#endif /* NO_WOLFSSL_SERVER */ diff --git a/src/io.c b/src/io.c index 905101abf..e8fdfe1d8 100644 --- a/src/io.c +++ b/src/io.c @@ -2,14 +2,14 @@ * * Copyright (C) 2006-2014 wolfSSL Inc. * - * This file is part of CyaSSL. + * This file is part of wolfSSL. (formerly known as CyaSSL) * - * 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 * the Free Software Foundation; either version 2 of the License, or * (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 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -20,35 +20,35 @@ */ /* Name change compatibility layer */ -#include +#include #ifdef HAVE_CONFIG_H #include #endif -#include +#include #ifdef _WIN32_WCE /* On WinCE winsock2.h must be included before windows.h for socket stuff */ #include #endif -#include -#include +#include +#include -/* if user writes own I/O callbacks they can define CYASSL_USER_IO to remove +/* if user writes own I/O callbacks they can define WOLFSSL_USER_IO to remove automatic setting of default I/O functions EmbedSend() and EmbedReceive() but they'll still need SetCallback xxx() at end of file */ -#ifndef CYASSL_USER_IO +#ifndef WOLFSSL_USER_IO #ifdef HAVE_LIBZ #include "zlib.h" #endif #ifndef USE_WINDOWS_API - #ifdef CYASSL_LWIP + #ifdef WOLFSSL_LWIP /* lwIP needs to be configured to use sockets API in this mode */ /* LWIP_SOCKET 1 in lwip/opt.h or in build */ #include "lwip/sockets.h" @@ -59,8 +59,8 @@ #elif defined(FREESCALE_MQX) #include #include - #elif defined(CYASSL_MDK_ARM) - #if defined(CYASSL_MDK5) + #elif defined(WOLFSSL_MDK_ARM) + #if defined(WOLFSSL_MDK5) #include "cmsis_os.h" #include "rl_fs.h" #include "rl_net.h" @@ -68,14 +68,14 @@ #include #endif #undef RNG - #include "CYASSL_MDK_ARM.h" + #include "WOLFSSL_MDK_ARM.h" #undef RNG - #define RNG CyaSSL_RNG + #define RNG wolfSSL_RNG /* for avoiding name conflict in "stm32f2xx.h" */ static int errno; - #elif defined(CYASSL_TIRTOS) + #elif defined(WOLFSSL_TIRTOS) #include - #elif defined(CYASSL_IAR_ARM) + #elif defined(WOLFSSL_IAR_ARM) /* nothing */ #else #include @@ -85,7 +85,7 @@ #endif #include #if !(defined(DEVKITPRO) || defined(HAVE_RTP_SYS) || defined(EBSNET)) \ - || defined(CYASSL_PICOTCP) + || defined(WOLFSSL_PICOTCP) #include #include #include @@ -140,8 +140,8 @@ #define SOCKET_EPIPE EPIPE #define SOCKET_ECONNREFUSED RTCSERR_TCP_CONN_REFUSED #define SOCKET_ECONNABORTED RTCSERR_TCP_CONN_ABORTED -#elif defined(CYASSL_MDK_ARM) - #if defined(CYASSL_MDK5) +#elif defined(WOLFSSL_MDK_ARM) + #if defined(WOLFSSL_MDK5) #define SOCKET_EWOULDBLOCK BSD_ERROR_WOULDBLOCK #define SOCKET_EAGAIN BSD_ERROR_LOCKED #define SOCKET_ECONNRESET BSD_ERROR_CLOSED @@ -158,7 +158,7 @@ #define SOCKET_ECONNREFUSED SCK_ERROR #define SOCKET_ECONNABORTED SCK_ERROR #endif -#elif defined(CYASSL_PICOTCP) +#elif defined(WOLFSSL_PICOTCP) #define SOCKET_EWOULDBLOCK PICO_ERR_EAGAIN #define SOCKET_EAGAIN PICO_ERR_EAGAIN #define SOCKET_ECONNRESET PICO_ERR_ECONNRESET @@ -183,10 +183,10 @@ int net_recv(int, void*, int, unsigned int); #define SEND_FUNCTION net_send #define RECV_FUNCTION net_recv -#elif defined(CYASSL_LWIP) +#elif defined(WOLFSSL_LWIP) #define SEND_FUNCTION lwip_send #define RECV_FUNCTION lwip_recv -#elif defined(CYASSL_PICOTCP) +#elif defined(WOLFSSL_PICOTCP) #define SEND_FUNCTION pico_send #define RECV_FUNCTION pico_recv #else @@ -232,17 +232,17 @@ static INLINE int LastError(void) /* The receive embedded callback * return : nb bytes read, or error */ -int EmbedReceive(CYASSL *ssl, char *buf, int sz, void *ctx) +int EmbedReceive(WOLFSSL *ssl, char *buf, int sz, void *ctx) { int recvd; int err; int sd = *(int*)ctx; -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS { - int dtls_timeout = CyaSSL_dtls_get_current_timeout(ssl); - if (CyaSSL_dtls(ssl) - && !CyaSSL_get_using_nonblock(ssl) + int dtls_timeout = wolfSSL_dtls_get_current_timeout(ssl); + if (wolfSSL_dtls(ssl) + && !wolfSSL_get_using_nonblock(ssl) && dtls_timeout != 0) { #ifdef USE_WINDOWS_API DWORD timeout = dtls_timeout * 1000; @@ -253,7 +253,7 @@ int EmbedReceive(CYASSL *ssl, char *buf, int sz, void *ctx) #endif if (setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout)) != 0) { - CYASSL_MSG("setsockopt rcvtimeo failed"); + WOLFSSL_MSG("setsockopt rcvtimeo failed"); } } } @@ -265,42 +265,42 @@ int EmbedReceive(CYASSL *ssl, char *buf, int sz, void *ctx) if (recvd < 0) { err = LastError(); - CYASSL_MSG("Embed Receive error"); + WOLFSSL_MSG("Embed Receive error"); if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) { - if (!CyaSSL_dtls(ssl) || CyaSSL_get_using_nonblock(ssl)) { - CYASSL_MSG(" Would block"); - return CYASSL_CBIO_ERR_WANT_READ; + if (!wolfSSL_dtls(ssl) || wolfSSL_get_using_nonblock(ssl)) { + WOLFSSL_MSG(" Would block"); + return WOLFSSL_CBIO_ERR_WANT_READ; } else { - CYASSL_MSG(" Socket timeout"); - return CYASSL_CBIO_ERR_TIMEOUT; + WOLFSSL_MSG(" Socket timeout"); + return WOLFSSL_CBIO_ERR_TIMEOUT; } } else if (err == SOCKET_ECONNRESET) { - CYASSL_MSG(" Connection reset"); - return CYASSL_CBIO_ERR_CONN_RST; + WOLFSSL_MSG(" Connection reset"); + return WOLFSSL_CBIO_ERR_CONN_RST; } else if (err == SOCKET_EINTR) { - CYASSL_MSG(" Socket interrupted"); - return CYASSL_CBIO_ERR_ISR; + WOLFSSL_MSG(" Socket interrupted"); + return WOLFSSL_CBIO_ERR_ISR; } else if (err == SOCKET_ECONNREFUSED) { - CYASSL_MSG(" Connection refused"); - return CYASSL_CBIO_ERR_WANT_READ; + WOLFSSL_MSG(" Connection refused"); + return WOLFSSL_CBIO_ERR_WANT_READ; } else if (err == SOCKET_ECONNABORTED) { - CYASSL_MSG(" Connection aborted"); - return CYASSL_CBIO_ERR_CONN_CLOSE; + WOLFSSL_MSG(" Connection aborted"); + return WOLFSSL_CBIO_ERR_CONN_CLOSE; } else { - CYASSL_MSG(" General error"); - return CYASSL_CBIO_ERR_GENERAL; + WOLFSSL_MSG(" General error"); + return WOLFSSL_CBIO_ERR_GENERAL; } } else if (recvd == 0) { - CYASSL_MSG("Embed receive connection closed"); - return CYASSL_CBIO_ERR_CONN_CLOSE; + WOLFSSL_MSG("Embed receive connection closed"); + return WOLFSSL_CBIO_ERR_CONN_CLOSE; } return recvd; @@ -309,7 +309,7 @@ int EmbedReceive(CYASSL *ssl, char *buf, int sz, void *ctx) /* The send embedded callback * return : nb bytes sent, or error */ -int EmbedSend(CYASSL* ssl, char *buf, int sz, void *ctx) +int EmbedSend(WOLFSSL* ssl, char *buf, int sz, void *ctx) { int sd = *(int*)ctx; int sent; @@ -320,27 +320,27 @@ int EmbedSend(CYASSL* ssl, char *buf, int sz, void *ctx) if (sent < 0) { err = LastError(); - CYASSL_MSG("Embed Send error"); + WOLFSSL_MSG("Embed Send error"); if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) { - CYASSL_MSG(" Would Block"); - return CYASSL_CBIO_ERR_WANT_WRITE; + WOLFSSL_MSG(" Would Block"); + return WOLFSSL_CBIO_ERR_WANT_WRITE; } else if (err == SOCKET_ECONNRESET) { - CYASSL_MSG(" Connection reset"); - return CYASSL_CBIO_ERR_CONN_RST; + WOLFSSL_MSG(" Connection reset"); + return WOLFSSL_CBIO_ERR_CONN_RST; } else if (err == SOCKET_EINTR) { - CYASSL_MSG(" Socket interrupted"); - return CYASSL_CBIO_ERR_ISR; + WOLFSSL_MSG(" Socket interrupted"); + return WOLFSSL_CBIO_ERR_ISR; } else if (err == SOCKET_EPIPE) { - CYASSL_MSG(" Socket EPIPE"); - return CYASSL_CBIO_ERR_CONN_CLOSE; + WOLFSSL_MSG(" Socket EPIPE"); + return WOLFSSL_CBIO_ERR_CONN_CLOSE; } else { - CYASSL_MSG(" General error"); - return CYASSL_CBIO_ERR_GENERAL; + WOLFSSL_MSG(" General error"); + return WOLFSSL_CBIO_ERR_GENERAL; } } @@ -348,9 +348,9 @@ int EmbedSend(CYASSL* ssl, char *buf, int sz, void *ctx) } -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS -#include +#include #ifdef USE_WINDOWS_API #define XSOCKLENT int @@ -365,19 +365,19 @@ int EmbedSend(CYASSL* ssl, char *buf, int sz, void *ctx) /* The receive embedded callback * return : nb bytes read, or error */ -int EmbedReceiveFrom(CYASSL *ssl, char *buf, int sz, void *ctx) +int EmbedReceiveFrom(WOLFSSL *ssl, char *buf, int sz, void *ctx) { - CYASSL_DTLS_CTX* dtlsCtx = (CYASSL_DTLS_CTX*)ctx; + WOLFSSL_DTLS_CTX* dtlsCtx = (WOLFSSL_DTLS_CTX*)ctx; int recvd; int err; int sd = dtlsCtx->fd; - int dtls_timeout = CyaSSL_dtls_get_current_timeout(ssl); + int dtls_timeout = wolfSSL_dtls_get_current_timeout(ssl); struct sockaddr_storage peer; XSOCKLENT peerSz = sizeof(peer); - CYASSL_ENTER("EmbedReceiveFrom()"); + WOLFSSL_ENTER("EmbedReceiveFrom()"); - if (!CyaSSL_get_using_nonblock(ssl) && dtls_timeout != 0) { + if (!wolfSSL_get_using_nonblock(ssl) && dtls_timeout != 0) { #ifdef USE_WINDOWS_API DWORD timeout = dtls_timeout * 1000; #else @@ -387,7 +387,7 @@ int EmbedReceiveFrom(CYASSL *ssl, char *buf, int sz, void *ctx) #endif if (setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout)) != 0) { - CYASSL_MSG("setsockopt rcvtimeo failed"); + WOLFSSL_MSG("setsockopt rcvtimeo failed"); } } @@ -398,41 +398,41 @@ int EmbedReceiveFrom(CYASSL *ssl, char *buf, int sz, void *ctx) if (recvd < 0) { err = LastError(); - CYASSL_MSG("Embed Receive From error"); + WOLFSSL_MSG("Embed Receive From error"); if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) { - if (CyaSSL_get_using_nonblock(ssl)) { - CYASSL_MSG(" Would block"); - return CYASSL_CBIO_ERR_WANT_READ; + if (wolfSSL_get_using_nonblock(ssl)) { + WOLFSSL_MSG(" Would block"); + return WOLFSSL_CBIO_ERR_WANT_READ; } else { - CYASSL_MSG(" Socket timeout"); - return CYASSL_CBIO_ERR_TIMEOUT; + WOLFSSL_MSG(" Socket timeout"); + return WOLFSSL_CBIO_ERR_TIMEOUT; } } else if (err == SOCKET_ECONNRESET) { - CYASSL_MSG(" Connection reset"); - return CYASSL_CBIO_ERR_CONN_RST; + WOLFSSL_MSG(" Connection reset"); + return WOLFSSL_CBIO_ERR_CONN_RST; } else if (err == SOCKET_EINTR) { - CYASSL_MSG(" Socket interrupted"); - return CYASSL_CBIO_ERR_ISR; + WOLFSSL_MSG(" Socket interrupted"); + return WOLFSSL_CBIO_ERR_ISR; } else if (err == SOCKET_ECONNREFUSED) { - CYASSL_MSG(" Connection refused"); - return CYASSL_CBIO_ERR_WANT_READ; + WOLFSSL_MSG(" Connection refused"); + return WOLFSSL_CBIO_ERR_WANT_READ; } else { - CYASSL_MSG(" General error"); - return CYASSL_CBIO_ERR_GENERAL; + WOLFSSL_MSG(" General error"); + return WOLFSSL_CBIO_ERR_GENERAL; } } else { if (dtlsCtx->peer.sz > 0 && peerSz != (XSOCKLENT)dtlsCtx->peer.sz && memcmp(&peer, dtlsCtx->peer.sa, peerSz) != 0) { - CYASSL_MSG(" Ignored packet from invalid peer"); - return CYASSL_CBIO_ERR_WANT_READ; + WOLFSSL_MSG(" Ignored packet from invalid peer"); + return WOLFSSL_CBIO_ERR_WANT_READ; } } @@ -443,42 +443,42 @@ int EmbedReceiveFrom(CYASSL *ssl, char *buf, int sz, void *ctx) /* The send embedded callback * return : nb bytes sent, or error */ -int EmbedSendTo(CYASSL* ssl, char *buf, int sz, void *ctx) +int EmbedSendTo(WOLFSSL* ssl, char *buf, int sz, void *ctx) { - CYASSL_DTLS_CTX* dtlsCtx = (CYASSL_DTLS_CTX*)ctx; + WOLFSSL_DTLS_CTX* dtlsCtx = (WOLFSSL_DTLS_CTX*)ctx; int sd = dtlsCtx->fd; int sent; int len = sz; int err; - CYASSL_ENTER("EmbedSendTo()"); + WOLFSSL_ENTER("EmbedSendTo()"); sent = (int)SENDTO_FUNCTION(sd, &buf[sz - len], len, ssl->wflags, (const struct sockaddr*)dtlsCtx->peer.sa, dtlsCtx->peer.sz); if (sent < 0) { err = LastError(); - CYASSL_MSG("Embed Send To error"); + WOLFSSL_MSG("Embed Send To error"); if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) { - CYASSL_MSG(" Would Block"); - return CYASSL_CBIO_ERR_WANT_WRITE; + WOLFSSL_MSG(" Would Block"); + return WOLFSSL_CBIO_ERR_WANT_WRITE; } else if (err == SOCKET_ECONNRESET) { - CYASSL_MSG(" Connection reset"); - return CYASSL_CBIO_ERR_CONN_RST; + WOLFSSL_MSG(" Connection reset"); + return WOLFSSL_CBIO_ERR_CONN_RST; } else if (err == SOCKET_EINTR) { - CYASSL_MSG(" Socket interrupted"); - return CYASSL_CBIO_ERR_ISR; + WOLFSSL_MSG(" Socket interrupted"); + return WOLFSSL_CBIO_ERR_ISR; } else if (err == SOCKET_EPIPE) { - CYASSL_MSG(" Socket EPIPE"); - return CYASSL_CBIO_ERR_CONN_CLOSE; + WOLFSSL_MSG(" Socket EPIPE"); + return WOLFSSL_CBIO_ERR_CONN_CLOSE; } else { - CYASSL_MSG(" General error"); - return CYASSL_CBIO_ERR_GENERAL; + WOLFSSL_MSG(" General error"); + return WOLFSSL_CBIO_ERR_GENERAL; } } @@ -489,7 +489,7 @@ int EmbedSendTo(CYASSL* ssl, char *buf, int sz, void *ctx) /* The DTLS Generate Cookie callback * return : number of bytes copied into buf, or error */ -int EmbedGenerateCookie(CYASSL* ssl, byte *buf, int sz, void *ctx) +int EmbedGenerateCookie(WOLFSSL* ssl, byte *buf, int sz, void *ctx) { int sd = ssl->wfd; struct sockaddr_storage peer; @@ -501,7 +501,7 @@ int EmbedGenerateCookie(CYASSL* ssl, byte *buf, int sz, void *ctx) XMEMSET(&peer, 0, sizeof(peer)); if (getpeername(sd, (struct sockaddr*)&peer, &peerSz) != 0) { - CYASSL_MSG("getpeername failed in EmbedGenerateCookie"); + WOLFSSL_MSG("getpeername failed in EmbedGenerateCookie"); return GEN_COOKIE_E; } @@ -516,7 +516,7 @@ int EmbedGenerateCookie(CYASSL* ssl, byte *buf, int sz, void *ctx) return sz; } -#endif /* CYASSL_DTLS */ +#endif /* WOLFSSL_DTLS */ #ifdef HAVE_OCSP @@ -571,12 +571,12 @@ static int tcp_connect(SOCKET_T* sockfd, const char* ip, word16 port) hints.ai_protocol = IPPROTO_TCP; if (Word16ToString(strPort, port) == 0) { - CYASSL_MSG("invalid port number for OCSP responder"); + WOLFSSL_MSG("invalid port number for OCSP responder"); return -1; } if (getaddrinfo(ip, strPort, &hints, &answer) < 0 || answer == NULL) { - CYASSL_MSG("no addr info for OCSP responder"); + WOLFSSL_MSG("no addr info for OCSP responder"); return -1; } @@ -597,7 +597,7 @@ static int tcp_connect(SOCKET_T* sockfd, const char* ip, word16 port) entry->h_length); } else { - CYASSL_MSG("no addr info for OCSP responder"); + WOLFSSL_MSG("no addr info for OCSP responder"); return -1; } } @@ -607,18 +607,18 @@ static int tcp_connect(SOCKET_T* sockfd, const char* ip, word16 port) #ifdef USE_WINDOWS_API if (*sockfd == INVALID_SOCKET) { - CYASSL_MSG("bad socket fd, out of fds?"); + WOLFSSL_MSG("bad socket fd, out of fds?"); return -1; } #else if (*sockfd < 0) { - CYASSL_MSG("bad socket fd, out of fds?"); + WOLFSSL_MSG("bad socket fd, out of fds?"); return -1; } #endif if (connect(*sockfd, (struct sockaddr *)&addr, sockaddr_len) != 0) { - CYASSL_MSG("OCSP responder tcp connect failed"); + WOLFSSL_MSG("OCSP responder tcp connect failed"); return -1; } @@ -764,7 +764,7 @@ static int process_http_response(int sfd, byte** respBuf, start[len] = 0; } else { - CYASSL_MSG("process_http_response recv http from peer failed"); + WOLFSSL_MSG("process_http_response recv http from peer failed"); return -1; } } @@ -782,7 +782,7 @@ static int process_http_response(int sfd, byte** respBuf, start += 2; } else { - CYASSL_MSG("process_http_response header ended early"); + WOLFSSL_MSG("process_http_response header ended early"); return -1; } } @@ -795,7 +795,7 @@ static int process_http_response(int sfd, byte** respBuf, start += 9; if (XSTRNCASECMP(start, "200 OK", 6) != 0 || state != phr_init) { - CYASSL_MSG("process_http_response not OK"); + WOLFSSL_MSG("process_http_response not OK"); return -1; } state = phr_http_start; @@ -804,14 +804,14 @@ static int process_http_response(int sfd, byte** respBuf, start += 13; while (*start == ' ' && *start != '\0') start++; if (XSTRNCASECMP(start, "application/ocsp-response", 25) != 0) { - CYASSL_MSG("process_http_response not ocsp-response"); + WOLFSSL_MSG("process_http_response not ocsp-response"); return -1; } if (state == phr_http_start) state = phr_have_type; else if (state == phr_have_length) state = phr_wait_end; else { - CYASSL_MSG("process_http_response type invalid state"); + WOLFSSL_MSG("process_http_response type invalid state"); return -1; } } @@ -823,7 +823,7 @@ static int process_http_response(int sfd, byte** respBuf, if (state == phr_http_start) state = phr_have_length; else if (state == phr_have_type) state = phr_wait_end; else { - CYASSL_MSG("process_http_response length invalid state"); + WOLFSSL_MSG("process_http_response length invalid state"); return -1; } } @@ -834,7 +834,7 @@ static int process_http_response(int sfd, byte** respBuf, recvBuf = (byte*)XMALLOC(recvBufSz, NULL, DYNAMIC_TYPE_IN_BUFFER); if (recvBuf == NULL) { - CYASSL_MSG("process_http_response couldn't create response buffer"); + WOLFSSL_MSG("process_http_response couldn't create response buffer"); return -1; } @@ -848,7 +848,7 @@ static int process_http_response(int sfd, byte** respBuf, if (result > 0) len += result; else { - CYASSL_MSG("process_http_response recv ocsp from peer failed"); + WOLFSSL_MSG("process_http_response recv ocsp from peer failed"); return -1; } } while (len != recvBufSz); @@ -866,7 +866,7 @@ int EmbedOcspLookup(void* ctx, const char* url, int urlSz, SOCKET_T sfd = 0; word16 port; int ret = -1; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK char* path; char* domainName; #else @@ -874,7 +874,7 @@ int EmbedOcspLookup(void* ctx, const char* url, int urlSz, char domainName[80]; #endif -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK path = (char*)XMALLOC(80, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (path == NULL) return -1; @@ -889,13 +889,13 @@ int EmbedOcspLookup(void* ctx, const char* url, int urlSz, (void)ctx; if (ocspReqBuf == NULL || ocspReqSz == 0) { - CYASSL_MSG("OCSP request is required for lookup"); + WOLFSSL_MSG("OCSP request is required for lookup"); } else if (ocspRespBuf == NULL) { - CYASSL_MSG("Cannot save OCSP response"); + WOLFSSL_MSG("Cannot save OCSP response"); } else if (decode_url(url, urlSz, domainName, path, &port) < 0) { - CYASSL_MSG("Unable to decode OCSP URL"); + WOLFSSL_MSG("Unable to decode OCSP URL"); } else { /* Note, the library uses the EmbedOcspRespFree() callback to @@ -905,22 +905,22 @@ int EmbedOcspLookup(void* ctx, const char* url, int urlSz, DYNAMIC_TYPE_IN_BUFFER); if (httpBuf == NULL) { - CYASSL_MSG("Unable to create OCSP response buffer"); + WOLFSSL_MSG("Unable to create OCSP response buffer"); } else { httpBufSz = build_http_request(domainName, path, ocspReqSz, httpBuf, httpBufSz); if ((tcp_connect(&sfd, domainName, port) != 0) || (sfd <= 0)) { - CYASSL_MSG("OCSP Responder connection failed"); + WOLFSSL_MSG("OCSP Responder connection failed"); } else if ((int)send(sfd, (char*)httpBuf, httpBufSz, 0) != httpBufSz) { - CYASSL_MSG("OCSP http request failed"); + WOLFSSL_MSG("OCSP http request failed"); } else if ((int)send(sfd, (char*)ocspReqBuf, ocspReqSz, 0) != ocspReqSz) { - CYASSL_MSG("OCSP ocsp request failed"); + WOLFSSL_MSG("OCSP ocsp request failed"); } else { ret = process_http_response(sfd, ocspRespBuf, httpBuf, @@ -932,7 +932,7 @@ int EmbedOcspLookup(void* ctx, const char* url, int urlSz, } } -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(path, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(domainName, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -952,33 +952,33 @@ void EmbedOcspRespFree(void* ctx, byte *resp) #endif -#endif /* CYASSL_USER_IO */ +#endif /* WOLFSSL_USER_IO */ -CYASSL_API void CyaSSL_SetIORecv(CYASSL_CTX *ctx, CallbackIORecv CBIORecv) +WOLFSSL_API void wolfSSL_SetIORecv(WOLFSSL_CTX *ctx, CallbackIORecv CBIORecv) { ctx->CBIORecv = CBIORecv; } -CYASSL_API void CyaSSL_SetIOSend(CYASSL_CTX *ctx, CallbackIOSend CBIOSend) +WOLFSSL_API void wolfSSL_SetIOSend(WOLFSSL_CTX *ctx, CallbackIOSend CBIOSend) { ctx->CBIOSend = CBIOSend; } -CYASSL_API void CyaSSL_SetIOReadCtx(CYASSL* ssl, void *rctx) +WOLFSSL_API void wolfSSL_SetIOReadCtx(WOLFSSL* ssl, void *rctx) { ssl->IOCB_ReadCtx = rctx; } -CYASSL_API void CyaSSL_SetIOWriteCtx(CYASSL* ssl, void *wctx) +WOLFSSL_API void wolfSSL_SetIOWriteCtx(WOLFSSL* ssl, void *wctx) { ssl->IOCB_WriteCtx = wctx; } -CYASSL_API void* CyaSSL_GetIOReadCtx(CYASSL* ssl) +WOLFSSL_API void* wolfSSL_GetIOReadCtx(WOLFSSL* ssl) { if (ssl) return ssl->IOCB_ReadCtx; @@ -987,7 +987,7 @@ CYASSL_API void* CyaSSL_GetIOReadCtx(CYASSL* ssl) } -CYASSL_API void* CyaSSL_GetIOWriteCtx(CYASSL* ssl) +WOLFSSL_API void* wolfSSL_GetIOWriteCtx(WOLFSSL* ssl) { if (ssl) return ssl->IOCB_WriteCtx; @@ -996,33 +996,33 @@ CYASSL_API void* CyaSSL_GetIOWriteCtx(CYASSL* ssl) } -CYASSL_API void CyaSSL_SetIOReadFlags(CYASSL* ssl, int flags) +WOLFSSL_API void wolfSSL_SetIOReadFlags(WOLFSSL* ssl, int flags) { ssl->rflags = flags; } -CYASSL_API void CyaSSL_SetIOWriteFlags(CYASSL* ssl, int flags) +WOLFSSL_API void wolfSSL_SetIOWriteFlags(WOLFSSL* ssl, int flags) { ssl->wflags = flags; } -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS -CYASSL_API void CyaSSL_CTX_SetGenCookie(CYASSL_CTX* ctx, CallbackGenCookie cb) +WOLFSSL_API void wolfSSL_CTX_SetGenCookie(WOLFSSL_CTX* ctx, CallbackGenCookie cb) { ctx->CBIOCookie = cb; } -CYASSL_API void CyaSSL_SetCookieCtx(CYASSL* ssl, void *ctx) +WOLFSSL_API void wolfSSL_SetCookieCtx(WOLFSSL* ssl, void *ctx) { ssl->IOCB_CookieCtx = ctx; } -CYASSL_API void* CyaSSL_GetCookieCtx(CYASSL* ssl) +WOLFSSL_API void* wolfSSL_GetCookieCtx(WOLFSSL* ssl) { if (ssl) return ssl->IOCB_CookieCtx; @@ -1030,7 +1030,7 @@ CYASSL_API void* CyaSSL_GetCookieCtx(CYASSL* ssl) return NULL; } -#endif /* CYASSL_DTLS */ +#endif /* WOLFSSL_DTLS */ #ifdef HAVE_NETX @@ -1038,7 +1038,7 @@ CYASSL_API void* CyaSSL_GetCookieCtx(CYASSL* ssl) /* The NetX receive callback * return : bytes read, or error */ -int NetX_Receive(CYASSL *ssl, char *buf, int sz, void *ctx) +int NetX_Receive(WOLFSSL *ssl, char *buf, int sz, void *ctx) { NetX_Ctx* nxCtx = (NetX_Ctx*)ctx; ULONG left; @@ -1047,38 +1047,38 @@ int NetX_Receive(CYASSL *ssl, char *buf, int sz, void *ctx) UINT status; if (nxCtx == NULL || nxCtx->nxSocket == NULL) { - CYASSL_MSG("NetX Recv NULL parameters"); - return CYASSL_CBIO_ERR_GENERAL; + WOLFSSL_MSG("NetX Recv NULL parameters"); + return WOLFSSL_CBIO_ERR_GENERAL; } if (nxCtx->nxPacket == NULL) { status = nx_tcp_socket_receive(nxCtx->nxSocket, &nxCtx->nxPacket, nxCtx->nxWait); if (status != NX_SUCCESS) { - CYASSL_MSG("NetX Recv receive error"); - return CYASSL_CBIO_ERR_GENERAL; + WOLFSSL_MSG("NetX Recv receive error"); + return WOLFSSL_CBIO_ERR_GENERAL; } } if (nxCtx->nxPacket) { status = nx_packet_length_get(nxCtx->nxPacket, &total); if (status != NX_SUCCESS) { - CYASSL_MSG("NetX Recv length get error"); - return CYASSL_CBIO_ERR_GENERAL; + WOLFSSL_MSG("NetX Recv length get error"); + return WOLFSSL_CBIO_ERR_GENERAL; } left = total - nxCtx->nxOffset; status = nx_packet_data_extract_offset(nxCtx->nxPacket, nxCtx->nxOffset, buf, sz, &copied); if (status != NX_SUCCESS) { - CYASSL_MSG("NetX Recv data extract offset error"); - return CYASSL_CBIO_ERR_GENERAL; + WOLFSSL_MSG("NetX Recv data extract offset error"); + return WOLFSSL_CBIO_ERR_GENERAL; } nxCtx->nxOffset += copied; if (copied == left) { - CYASSL_MSG("NetX Recv Drained packet"); + WOLFSSL_MSG("NetX Recv Drained packet"); nx_packet_release(nxCtx->nxPacket); nxCtx->nxPacket = NULL; nxCtx->nxOffset = 0; @@ -1092,7 +1092,7 @@ int NetX_Receive(CYASSL *ssl, char *buf, int sz, void *ctx) /* The NetX send callback * return : bytes sent, or error */ -int NetX_Send(CYASSL* ssl, char *buf, int sz, void *ctx) +int NetX_Send(WOLFSSL* ssl, char *buf, int sz, void *ctx) { NetX_Ctx* nxCtx = (NetX_Ctx*)ctx; NX_PACKET* packet; @@ -1100,30 +1100,30 @@ int NetX_Send(CYASSL* ssl, char *buf, int sz, void *ctx) UINT status; if (nxCtx == NULL || nxCtx->nxSocket == NULL) { - CYASSL_MSG("NetX Send NULL parameters"); - return CYASSL_CBIO_ERR_GENERAL; + WOLFSSL_MSG("NetX Send NULL parameters"); + return WOLFSSL_CBIO_ERR_GENERAL; } pool = nxCtx->nxSocket->nx_tcp_socket_ip_ptr->nx_ip_default_packet_pool; status = nx_packet_allocate(pool, &packet, NX_TCP_PACKET, nxCtx->nxWait); if (status != NX_SUCCESS) { - CYASSL_MSG("NetX Send packet alloc error"); - return CYASSL_CBIO_ERR_GENERAL; + WOLFSSL_MSG("NetX Send packet alloc error"); + return WOLFSSL_CBIO_ERR_GENERAL; } status = nx_packet_data_append(packet, buf, sz, pool, nxCtx->nxWait); if (status != NX_SUCCESS) { nx_packet_release(packet); - CYASSL_MSG("NetX Send data append error"); - return CYASSL_CBIO_ERR_GENERAL; + WOLFSSL_MSG("NetX Send data append error"); + return WOLFSSL_CBIO_ERR_GENERAL; } status = nx_tcp_socket_send(nxCtx->nxSocket, packet, nxCtx->nxWait); if (status != NX_SUCCESS) { nx_packet_release(packet); - CYASSL_MSG("NetX Send socket send error"); - return CYASSL_CBIO_ERR_GENERAL; + WOLFSSL_MSG("NetX Send socket send error"); + return WOLFSSL_CBIO_ERR_GENERAL; } return sz; @@ -1131,7 +1131,7 @@ int NetX_Send(CYASSL* ssl, char *buf, int sz, void *ctx) /* like set_fd, but for default NetX context */ -void CyaSSL_SetIO_NetX(CYASSL* ssl, NX_TCP_SOCKET* nxSocket, ULONG waitOption) +void wolfSSL_SetIO_NetX(WOLFSSL* ssl, NX_TCP_SOCKET* nxSocket, ULONG waitOption) { if (ssl) { ssl->nxCtx.nxSocket = nxSocket; diff --git a/src/keys.c b/src/keys.c index 867277689..5069dfba3 100644 --- a/src/keys.c +++ b/src/keys.c @@ -2,14 +2,14 @@ * * Copyright (C) 2006-2014 wolfSSL Inc. * - * This file is part of CyaSSL. + * This file is part of wolfSSL. (formerly known as CyaSSL) * - * 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 * the Free Software Foundation; either version 2 of the License, or * (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 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -20,16 +20,16 @@ */ /* Name change compatibility layer */ -#include +#include #ifdef HAVE_CONFIG_H #include #endif -#include +#include -#include -#include +#include +#include #if defined(SHOW_SECRETS) || defined(CHACHA_AEAD_TEST) #ifdef FREESCALE_MQX #include @@ -39,17 +39,17 @@ #endif -int SetCipherSpecs(CYASSL* ssl) +int SetCipherSpecs(WOLFSSL* ssl) { -#ifndef NO_CYASSL_CLIENT - if (ssl->options.side == CYASSL_CLIENT_END) { +#ifndef NO_WOLFSSL_CLIENT + if (ssl->options.side == WOLFSSL_CLIENT_END) { /* server side verified before SetCipherSpecs call */ if (VerifyClientSuite(ssl) != 1) { - CYASSL_MSG("SetCipherSpecs() client has an unusuable suite"); + WOLFSSL_MSG("SetCipherSpecs() client has an unusuable suite"); return UNSUPPORTED_SUITE; } } -#endif /* NO_CYASSL_CLIENT */ +#endif /* NO_WOLFSSL_CLIENT */ /* Chacha extensions, 0xcc */ if (ssl->options.cipherSuite0 == CHACHA_BYTE) { @@ -57,7 +57,7 @@ int SetCipherSpecs(CYASSL* ssl) switch (ssl->options.cipherSuite) { #ifdef BUILD_TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 case TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256: - ssl->specs.bulk_cipher_algorithm = cyassl_chacha; + ssl->specs.bulk_cipher_algorithm = wolfssl_chacha; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -75,7 +75,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 case TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256: - ssl->specs.bulk_cipher_algorithm = cyassl_chacha; + ssl->specs.bulk_cipher_algorithm = wolfssl_chacha; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -93,7 +93,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256 case TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256: - ssl->specs.bulk_cipher_algorithm = cyassl_chacha; + ssl->specs.bulk_cipher_algorithm = wolfssl_chacha; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = diffie_hellman_kea; @@ -109,7 +109,7 @@ int SetCipherSpecs(CYASSL* ssl) break; #endif default: - CYASSL_MSG("Unsupported cipher suite, SetCipherSpecs ChaCha"); + WOLFSSL_MSG("Unsupported cipher suite, SetCipherSpecs ChaCha"); return UNSUPPORTED_SUITE; } } @@ -123,7 +123,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -139,7 +139,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -155,7 +155,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -171,7 +171,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -187,7 +187,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha384_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -203,7 +203,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha384_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -219,7 +219,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha384_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -235,7 +235,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha384_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -251,7 +251,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA case TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -268,7 +268,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA case TLS_ECDH_RSA_WITH_AES_128_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -285,7 +285,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA case TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_triple_des; + ssl->specs.bulk_cipher_algorithm = wolfssl_triple_des; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -302,7 +302,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA case TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_triple_des; + ssl->specs.bulk_cipher_algorithm = wolfssl_triple_des; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -319,7 +319,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDHE_RSA_WITH_RC4_128_SHA case TLS_ECDHE_RSA_WITH_RC4_128_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_rc4; + ssl->specs.bulk_cipher_algorithm = wolfssl_rc4; ssl->specs.cipher_type = stream; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -336,7 +336,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDH_RSA_WITH_RC4_128_SHA case TLS_ECDH_RSA_WITH_RC4_128_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_rc4; + ssl->specs.bulk_cipher_algorithm = wolfssl_rc4; ssl->specs.cipher_type = stream; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -353,7 +353,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA case TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_triple_des; + ssl->specs.bulk_cipher_algorithm = wolfssl_triple_des; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -370,7 +370,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA case TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_triple_des; + ssl->specs.bulk_cipher_algorithm = wolfssl_triple_des; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -387,7 +387,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA case TLS_ECDHE_ECDSA_WITH_RC4_128_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_rc4; + ssl->specs.bulk_cipher_algorithm = wolfssl_rc4; ssl->specs.cipher_type = stream; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -404,7 +404,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDH_ECDSA_WITH_RC4_128_SHA case TLS_ECDH_ECDSA_WITH_RC4_128_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_rc4; + ssl->specs.bulk_cipher_algorithm = wolfssl_rc4; ssl->specs.cipher_type = stream; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -421,7 +421,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA case TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -438,7 +438,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA case TLS_ECDH_RSA_WITH_AES_256_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -455,7 +455,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA case TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -472,7 +472,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA case TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -489,7 +489,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA case TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -506,7 +506,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA case TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -523,7 +523,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 case TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -541,7 +541,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 case TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha384_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -559,7 +559,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 case TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -577,7 +577,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 case TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha384_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -595,7 +595,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 case TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -613,7 +613,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 case TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha384_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -631,7 +631,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 case TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -649,7 +649,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 case TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha384_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -667,7 +667,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 case TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_ccm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -685,7 +685,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 case TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_ccm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = ecc_diffie_hellman_kea; @@ -704,7 +704,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_RSA_WITH_AES_128_CCM_8 case TLS_RSA_WITH_AES_128_CCM_8 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_ccm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = rsa_kea; @@ -722,7 +722,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_RSA_WITH_AES_256_CCM_8 case TLS_RSA_WITH_AES_256_CCM_8 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_ccm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = rsa_kea; @@ -740,7 +740,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_PSK_WITH_AES_128_CCM_8 case TLS_PSK_WITH_AES_128_CCM_8 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_ccm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = psk_kea; @@ -759,7 +759,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_PSK_WITH_AES_256_CCM_8 case TLS_PSK_WITH_AES_256_CCM_8 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_ccm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = psk_kea; @@ -778,7 +778,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_PSK_WITH_AES_128_CCM case TLS_PSK_WITH_AES_128_CCM : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_ccm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = psk_kea; @@ -797,7 +797,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_PSK_WITH_AES_256_CCM case TLS_PSK_WITH_AES_256_CCM : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_ccm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = psk_kea; @@ -816,7 +816,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_DHE_PSK_WITH_AES_128_CCM case TLS_DHE_PSK_WITH_AES_128_CCM : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_ccm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = dhe_psk_kea; @@ -835,7 +835,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_DHE_PSK_WITH_AES_256_CCM case TLS_DHE_PSK_WITH_AES_256_CCM : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_ccm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_ccm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = dhe_psk_kea; @@ -853,7 +853,7 @@ int SetCipherSpecs(CYASSL* ssl) #endif default: - CYASSL_MSG("Unsupported cipher suite, SetCipherSpecs ECC"); + WOLFSSL_MSG("Unsupported cipher suite, SetCipherSpecs ECC"); return UNSUPPORTED_SUITE; } /* switch */ } /* if */ @@ -863,7 +863,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_SSL_RSA_WITH_RC4_128_SHA case SSL_RSA_WITH_RC4_128_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_rc4; + ssl->specs.bulk_cipher_algorithm = wolfssl_rc4; ssl->specs.cipher_type = stream; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = rsa_kea; @@ -880,7 +880,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_NTRU_RSA_WITH_RC4_128_SHA case TLS_NTRU_RSA_WITH_RC4_128_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_rc4; + ssl->specs.bulk_cipher_algorithm = wolfssl_rc4; ssl->specs.cipher_type = stream; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = ntru_kea; @@ -897,7 +897,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_SSL_RSA_WITH_RC4_128_MD5 case SSL_RSA_WITH_RC4_128_MD5 : - ssl->specs.bulk_cipher_algorithm = cyassl_rc4; + ssl->specs.bulk_cipher_algorithm = wolfssl_rc4; ssl->specs.cipher_type = stream; ssl->specs.mac_algorithm = md5_mac; ssl->specs.kea = rsa_kea; @@ -914,7 +914,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_SSL_RSA_WITH_3DES_EDE_CBC_SHA case SSL_RSA_WITH_3DES_EDE_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_triple_des; + ssl->specs.bulk_cipher_algorithm = wolfssl_triple_des; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = rsa_kea; @@ -931,7 +931,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_NTRU_RSA_WITH_3DES_EDE_CBC_SHA case TLS_NTRU_RSA_WITH_3DES_EDE_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_triple_des; + ssl->specs.bulk_cipher_algorithm = wolfssl_triple_des; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = ntru_kea; @@ -948,7 +948,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_SHA case TLS_RSA_WITH_AES_128_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = rsa_kea; @@ -965,7 +965,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_SHA256 case TLS_RSA_WITH_AES_128_CBC_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = rsa_kea; @@ -982,7 +982,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_RSA_WITH_NULL_SHA case TLS_RSA_WITH_NULL_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_cipher_null; + ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null; ssl->specs.cipher_type = stream; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = rsa_kea; @@ -999,7 +999,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_RSA_WITH_NULL_SHA256 case TLS_RSA_WITH_NULL_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_cipher_null; + ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null; ssl->specs.cipher_type = stream; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = rsa_kea; @@ -1016,7 +1016,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_NTRU_RSA_WITH_AES_128_CBC_SHA case TLS_NTRU_RSA_WITH_AES_128_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = ntru_kea; @@ -1033,7 +1033,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_SHA case TLS_RSA_WITH_AES_256_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = rsa_kea; @@ -1050,7 +1050,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_SHA256 case TLS_RSA_WITH_AES_256_CBC_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = rsa_kea; @@ -1067,7 +1067,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_NTRU_RSA_WITH_AES_256_CBC_SHA case TLS_NTRU_RSA_WITH_AES_256_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = ntru_kea; @@ -1084,7 +1084,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_PSK_WITH_AES_128_GCM_SHA256 case TLS_PSK_WITH_AES_128_GCM_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = psk_kea; @@ -1103,7 +1103,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_PSK_WITH_AES_256_GCM_SHA384 case TLS_PSK_WITH_AES_256_GCM_SHA384 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha384_mac; ssl->specs.kea = psk_kea; @@ -1122,7 +1122,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 case TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = dhe_psk_kea; @@ -1141,7 +1141,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 case TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha384_mac; ssl->specs.kea = dhe_psk_kea; @@ -1160,7 +1160,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_PSK_WITH_AES_128_CBC_SHA256 case TLS_PSK_WITH_AES_128_CBC_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = psk_kea; @@ -1178,7 +1178,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_PSK_WITH_AES_256_CBC_SHA384 case TLS_PSK_WITH_AES_256_CBC_SHA384 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha384_mac; ssl->specs.kea = psk_kea; @@ -1196,7 +1196,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 case TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = dhe_psk_kea; @@ -1214,7 +1214,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 case TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha384_mac; ssl->specs.kea = dhe_psk_kea; @@ -1232,7 +1232,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_PSK_WITH_AES_128_CBC_SHA case TLS_PSK_WITH_AES_128_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = psk_kea; @@ -1250,7 +1250,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_PSK_WITH_AES_256_CBC_SHA case TLS_PSK_WITH_AES_256_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = psk_kea; @@ -1268,7 +1268,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_PSK_WITH_NULL_SHA256 case TLS_PSK_WITH_NULL_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_cipher_null; + ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null; ssl->specs.cipher_type = stream; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = psk_kea; @@ -1286,7 +1286,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_PSK_WITH_NULL_SHA384 case TLS_PSK_WITH_NULL_SHA384 : - ssl->specs.bulk_cipher_algorithm = cyassl_cipher_null; + ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null; ssl->specs.cipher_type = stream; ssl->specs.mac_algorithm = sha384_mac; ssl->specs.kea = psk_kea; @@ -1304,7 +1304,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_PSK_WITH_NULL_SHA case TLS_PSK_WITH_NULL_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_cipher_null; + ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null; ssl->specs.cipher_type = stream; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = psk_kea; @@ -1322,7 +1322,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_DHE_PSK_WITH_NULL_SHA256 case TLS_DHE_PSK_WITH_NULL_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_cipher_null; + ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null; ssl->specs.cipher_type = stream; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = dhe_psk_kea; @@ -1340,7 +1340,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_DHE_PSK_WITH_NULL_SHA384 case TLS_DHE_PSK_WITH_NULL_SHA384 : - ssl->specs.bulk_cipher_algorithm = cyassl_cipher_null; + ssl->specs.bulk_cipher_algorithm = wolfssl_cipher_null; ssl->specs.cipher_type = stream; ssl->specs.mac_algorithm = sha384_mac; ssl->specs.kea = dhe_psk_kea; @@ -1358,7 +1358,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 case TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = diffie_hellman_kea; @@ -1375,7 +1375,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 case TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = diffie_hellman_kea; @@ -1392,7 +1392,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_CBC_SHA case TLS_DHE_RSA_WITH_AES_128_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = diffie_hellman_kea; @@ -1409,7 +1409,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_CBC_SHA case TLS_DHE_RSA_WITH_AES_256_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = diffie_hellman_kea; @@ -1426,7 +1426,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_RSA_WITH_HC_128_MD5 case TLS_RSA_WITH_HC_128_MD5 : - ssl->specs.bulk_cipher_algorithm = cyassl_hc128; + ssl->specs.bulk_cipher_algorithm = wolfssl_hc128; ssl->specs.cipher_type = stream; ssl->specs.mac_algorithm = md5_mac; ssl->specs.kea = rsa_kea; @@ -1443,7 +1443,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_RSA_WITH_HC_128_SHA case TLS_RSA_WITH_HC_128_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_hc128; + ssl->specs.bulk_cipher_algorithm = wolfssl_hc128; ssl->specs.cipher_type = stream; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = rsa_kea; @@ -1460,7 +1460,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_RSA_WITH_HC_128_B2B256 case TLS_RSA_WITH_HC_128_B2B256: - ssl->specs.bulk_cipher_algorithm = cyassl_hc128; + ssl->specs.bulk_cipher_algorithm = wolfssl_hc128; ssl->specs.cipher_type = stream; ssl->specs.mac_algorithm = blake2b_mac; ssl->specs.kea = rsa_kea; @@ -1477,7 +1477,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_RSA_WITH_AES_128_CBC_B2B256 case TLS_RSA_WITH_AES_128_CBC_B2B256: - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = blake2b_mac; ssl->specs.kea = rsa_kea; @@ -1494,7 +1494,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_RSA_WITH_AES_256_CBC_B2B256 case TLS_RSA_WITH_AES_256_CBC_B2B256: - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = blake2b_mac; ssl->specs.kea = rsa_kea; @@ -1511,7 +1511,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_RSA_WITH_RABBIT_SHA case TLS_RSA_WITH_RABBIT_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_rabbit; + ssl->specs.bulk_cipher_algorithm = wolfssl_rabbit; ssl->specs.cipher_type = stream; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = rsa_kea; @@ -1528,7 +1528,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_RSA_WITH_AES_128_GCM_SHA256 case TLS_RSA_WITH_AES_128_GCM_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = rsa_kea; @@ -1546,7 +1546,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_RSA_WITH_AES_256_GCM_SHA384 case TLS_RSA_WITH_AES_256_GCM_SHA384 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha384_mac; ssl->specs.kea = rsa_kea; @@ -1564,7 +1564,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 case TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = diffie_hellman_kea; @@ -1582,7 +1582,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 case TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 : - ssl->specs.bulk_cipher_algorithm = cyassl_aes_gcm; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes_gcm; ssl->specs.cipher_type = aead; ssl->specs.mac_algorithm = sha384_mac; ssl->specs.kea = diffie_hellman_kea; @@ -1600,7 +1600,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA case TLS_RSA_WITH_CAMELLIA_128_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_camellia; + ssl->specs.bulk_cipher_algorithm = wolfssl_camellia; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = rsa_kea; @@ -1617,7 +1617,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA case TLS_RSA_WITH_CAMELLIA_256_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_camellia; + ssl->specs.bulk_cipher_algorithm = wolfssl_camellia; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = rsa_kea; @@ -1634,7 +1634,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 case TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_camellia; + ssl->specs.bulk_cipher_algorithm = wolfssl_camellia; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = rsa_kea; @@ -1651,7 +1651,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 case TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_camellia; + ssl->specs.bulk_cipher_algorithm = wolfssl_camellia; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = rsa_kea; @@ -1668,7 +1668,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA case TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_camellia; + ssl->specs.bulk_cipher_algorithm = wolfssl_camellia; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = diffie_hellman_kea; @@ -1685,7 +1685,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA case TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_camellia; + ssl->specs.bulk_cipher_algorithm = wolfssl_camellia; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = diffie_hellman_kea; @@ -1702,7 +1702,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 case TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_camellia; + ssl->specs.bulk_cipher_algorithm = wolfssl_camellia; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = diffie_hellman_kea; @@ -1719,7 +1719,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 case TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 : - ssl->specs.bulk_cipher_algorithm = cyassl_camellia; + ssl->specs.bulk_cipher_algorithm = wolfssl_camellia; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha256_mac; ssl->specs.kea = diffie_hellman_kea; @@ -1736,7 +1736,7 @@ int SetCipherSpecs(CYASSL* ssl) #ifdef BUILD_TLS_DH_anon_WITH_AES_128_CBC_SHA case TLS_DH_anon_WITH_AES_128_CBC_SHA : - ssl->specs.bulk_cipher_algorithm = cyassl_aes; + ssl->specs.bulk_cipher_algorithm = wolfssl_aes; ssl->specs.cipher_type = block; ssl->specs.mac_algorithm = sha_mac; ssl->specs.kea = diffie_hellman_kea; @@ -1753,7 +1753,7 @@ int SetCipherSpecs(CYASSL* ssl) #endif default: - CYASSL_MSG("Unsupported cipher suite, SetCipherSpecs"); + WOLFSSL_MSG("Unsupported cipher suite, SetCipherSpecs"); return UNSUPPORTED_SUITE; } /* switch */ } /* if ECC / Normal suites else */ @@ -1768,7 +1768,7 @@ int SetCipherSpecs(CYASSL* ssl) #endif } -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (ssl->options.dtls) ssl->hmac = TLS_hmac; #endif @@ -1812,7 +1812,7 @@ static int SetPrefix(byte* sha_input, int idx) XMEMCPY(sha_input, "GGGGGGG", 7); break; default: - CYASSL_MSG("Set Prefix error, bad input"); + WOLFSSL_MSG("Set Prefix error, bad input"); return 0; } return 1; @@ -1838,19 +1838,19 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, if (devId != NO_CAVIUM_DEVICE) { if (enc) { if (Arc4InitCavium(enc->arc4, devId) != 0) { - CYASSL_MSG("Arc4InitCavium failed in SetKeys"); + WOLFSSL_MSG("Arc4InitCavium failed in SetKeys"); return CAVIUM_INIT_E; } } if (dec) { if (Arc4InitCavium(dec->arc4, devId) != 0) { - CYASSL_MSG("Arc4InitCavium failed in SetKeys"); + WOLFSSL_MSG("Arc4InitCavium failed in SetKeys"); return CAVIUM_INIT_E; } } } #endif - if (side == CYASSL_CLIENT_END) { + if (side == WOLFSSL_CLIENT_END) { if (enc) wc_Arc4SetKey(enc->arc4, keys->client_write_key, sz); if (dec) @@ -1871,7 +1871,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, #ifdef HAVE_CHACHA - if (specs->bulk_cipher_algorithm == cyassl_chacha) { + if (specs->bulk_cipher_algorithm == wolfssl_chacha) { int chachaRet; if (enc && enc->chacha == NULL) enc->chacha = @@ -1883,7 +1883,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, (ChaCha*)XMALLOC(sizeof(ChaCha), heap, DYNAMIC_TYPE_CIPHER); if (dec && dec->chacha == NULL) return MEMORY_E; - if (side == CYASSL_CLIENT_END) { + if (side == WOLFSSL_CLIENT_END) { if (enc) { chachaRet = Chacha_SetKey(enc->chacha, keys->client_write_key, specs->key_size); @@ -1924,7 +1924,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, #endif #ifdef HAVE_HC128 - if (specs->bulk_cipher_algorithm == cyassl_hc128) { + if (specs->bulk_cipher_algorithm == wolfssl_hc128) { int hcRet; if (enc && enc->hc128 == NULL) enc->hc128 = @@ -1936,7 +1936,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, (HC128*)XMALLOC(sizeof(HC128), heap, DYNAMIC_TYPE_CIPHER); if (dec && dec->hc128 == NULL) return MEMORY_E; - if (side == CYASSL_CLIENT_END) { + if (side == WOLFSSL_CLIENT_END) { if (enc) { hcRet = Hc128_SetKey(enc->hc128, keys->client_write_key, keys->client_write_IV); @@ -1968,7 +1968,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, #endif #ifdef BUILD_RABBIT - if (specs->bulk_cipher_algorithm == cyassl_rabbit) { + if (specs->bulk_cipher_algorithm == wolfssl_rabbit) { int rabRet; if (enc && enc->rabbit == NULL) enc->rabbit = @@ -1980,7 +1980,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, (Rabbit*)XMALLOC(sizeof(Rabbit), heap, DYNAMIC_TYPE_CIPHER); if (dec && dec->rabbit == NULL) return MEMORY_E; - if (side == CYASSL_CLIENT_END) { + if (side == WOLFSSL_CLIENT_END) { if (enc) { rabRet = RabbitSetKey(enc->rabbit, keys->client_write_key, keys->client_write_IV); @@ -2027,19 +2027,19 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, if (devId != NO_CAVIUM_DEVICE) { if (enc) { if (Des3_InitCavium(enc->des3, devId) != 0) { - CYASSL_MSG("Des3_InitCavium failed in SetKeys"); + WOLFSSL_MSG("Des3_InitCavium failed in SetKeys"); return CAVIUM_INIT_E; } } if (dec) { if (Des3_InitCavium(dec->des3, devId) != 0) { - CYASSL_MSG("Des3_InitCavium failed in SetKeys"); + WOLFSSL_MSG("Des3_InitCavium failed in SetKeys"); return CAVIUM_INIT_E; } } } #endif - if (side == CYASSL_CLIENT_END) { + if (side == WOLFSSL_CLIENT_END) { if (enc) { desRet = Des3_SetKey(enc->des3, keys->client_write_key, keys->client_write_IV, DES_ENCRYPTION); @@ -2071,7 +2071,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, #endif #ifdef BUILD_AES - if (specs->bulk_cipher_algorithm == cyassl_aes) { + if (specs->bulk_cipher_algorithm == wolfssl_aes) { int aesRet = 0; if (enc && enc->aes == NULL) @@ -2086,19 +2086,19 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, if (devId != NO_CAVIUM_DEVICE) { if (enc) { if (AesInitCavium(enc->aes, devId) != 0) { - CYASSL_MSG("AesInitCavium failed in SetKeys"); + WOLFSSL_MSG("AesInitCavium failed in SetKeys"); return CAVIUM_INIT_E; } } if (dec) { if (AesInitCavium(dec->aes, devId) != 0) { - CYASSL_MSG("AesInitCavium failed in SetKeys"); + WOLFSSL_MSG("AesInitCavium failed in SetKeys"); return CAVIUM_INIT_E; } } } #endif - if (side == CYASSL_CLIENT_END) { + if (side == WOLFSSL_CLIENT_END) { if (enc) { aesRet = AesSetKey(enc->aes, keys->client_write_key, specs->key_size, keys->client_write_IV, @@ -2134,7 +2134,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, #endif #ifdef BUILD_AESGCM - if (specs->bulk_cipher_algorithm == cyassl_aes_gcm) { + if (specs->bulk_cipher_algorithm == wolfssl_aes_gcm) { int gcmRet; if (enc && enc->aes == NULL) @@ -2146,7 +2146,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, if (dec && dec->aes == NULL) return MEMORY_E; - if (side == CYASSL_CLIENT_END) { + if (side == WOLFSSL_CLIENT_END) { if (enc) { gcmRet = AesGcmSetKey(enc->aes, keys->client_write_key, specs->key_size); @@ -2186,7 +2186,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, #endif #ifdef HAVE_AESCCM - if (specs->bulk_cipher_algorithm == cyassl_aes_ccm) { + if (specs->bulk_cipher_algorithm == wolfssl_aes_ccm) { if (enc && enc->aes == NULL) enc->aes = (Aes*)XMALLOC(sizeof(Aes), heap, DYNAMIC_TYPE_CIPHER); if (enc && enc->aes == NULL) @@ -2196,7 +2196,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, if (dec && dec->aes == NULL) return MEMORY_E; - if (side == CYASSL_CLIENT_END) { + if (side == WOLFSSL_CLIENT_END) { if (enc) { AesCcmSetKey(enc->aes, keys->client_write_key, specs->key_size); XMEMCPY(keys->aead_enc_imp_IV, keys->client_write_IV, @@ -2228,7 +2228,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, #endif #ifdef HAVE_CAMELLIA - if (specs->bulk_cipher_algorithm == cyassl_camellia) { + if (specs->bulk_cipher_algorithm == wolfssl_camellia) { int camRet; if (enc && enc->cam == NULL) @@ -2243,7 +2243,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, if (dec && dec->cam == NULL) return MEMORY_E; - if (side == CYASSL_CLIENT_END) { + if (side == WOLFSSL_CLIENT_END) { if (enc) { camRet = CamelliaSetKey(enc->cam, keys->client_write_key, specs->key_size, keys->client_write_IV); @@ -2275,7 +2275,7 @@ static int SetKeys(Ciphers* enc, Ciphers* dec, Keys* keys, CipherSpecs* specs, #endif #ifdef HAVE_NULL_CIPHER - if (specs->bulk_cipher_algorithm == cyassl_cipher_null) { + if (specs->bulk_cipher_algorithm == wolfssl_cipher_null) { if (enc) enc->setup = 1; if (dec) @@ -2324,7 +2324,7 @@ static int SetAuthKeys(OneTimeAuth* authentication, Keys* keys, /* Set encrypt/decrypt or both sides of key setup */ -int SetKeysSide(CYASSL* ssl, enum encrypt_side side) +int SetKeysSide(WOLFSSL* ssl, enum encrypt_side side) { int devId = NO_CAVIUM_DEVICE, ret, copy = 0; Ciphers* encrypt = NULL; @@ -2377,9 +2377,9 @@ int SetKeysSide(CYASSL* ssl, enum encrypt_side side) if (copy) { int clientCopy = 0; - if (ssl->options.side == CYASSL_CLIENT_END && encrypt) + if (ssl->options.side == WOLFSSL_CLIENT_END && encrypt) clientCopy = 1; - else if (ssl->options.side == CYASSL_SERVER_END && decrypt) + else if (ssl->options.side == WOLFSSL_SERVER_END && decrypt) clientCopy = 1; if (clientCopy) { @@ -2418,7 +2418,7 @@ int SetKeysSide(CYASSL* ssl, enum encrypt_side side) /* TLS can call too */ -int StoreKeys(CYASSL* ssl, const byte* keyData) +int StoreKeys(WOLFSSL* ssl, const byte* keyData) { int sz, i = 0; Keys* keys = &ssl->keys; @@ -2460,7 +2460,7 @@ int StoreKeys(CYASSL* ssl, const byte* keyData) } #ifndef NO_OLD_TLS -int DeriveKeys(CYASSL* ssl) +int DeriveKeys(WOLFSSL* ssl) { int length = 2 * ssl->specs.hash_size + 2 * ssl->specs.key_size + @@ -2468,7 +2468,7 @@ int DeriveKeys(CYASSL* ssl) int rounds = (length + MD5_DIGEST_SIZE - 1 ) / MD5_DIGEST_SIZE, i; int ret = 0; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK byte* shaOutput; byte* md5Input; byte* shaInput; @@ -2484,7 +2484,7 @@ int DeriveKeys(CYASSL* ssl) Sha sha[1]; #endif -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK shaOutput = (byte*)XMALLOC(SHA_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER); md5Input = (byte*)XMALLOC(SECRET_LEN + SHA_DIGEST_SIZE, @@ -2544,7 +2544,7 @@ int DeriveKeys(CYASSL* ssl) ret = StoreKeys(ssl, keyData); } -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(shaOutput, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(md5Input, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(shaInput, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -2557,7 +2557,7 @@ int DeriveKeys(CYASSL* ssl) } -static int CleanPreMaster(CYASSL* ssl) +static int CleanPreMaster(WOLFSSL* ssl) { int i, ret, sz = ssl->arrays->preMasterSz; @@ -2576,13 +2576,13 @@ static int CleanPreMaster(CYASSL* ssl) /* Create and store the master secret see page 32, 6.1 */ -static int MakeSslMasterSecret(CYASSL* ssl) +static int MakeSslMasterSecret(WOLFSSL* ssl) { int i, ret; word32 idx; word32 pmsSz = ssl->arrays->preMasterSz; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK byte* shaOutput; byte* md5Input; byte* shaInput; @@ -2606,7 +2606,7 @@ static int MakeSslMasterSecret(CYASSL* ssl) } #endif -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK shaOutput = (byte*)XMALLOC(SHA_DIGEST_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER); md5Input = (byte*)XMALLOC(ENCRYPT_LEN + SHA_DIGEST_SIZE, @@ -2676,7 +2676,7 @@ static int MakeSslMasterSecret(CYASSL* ssl) ret = DeriveKeys(ssl); } -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(shaOutput, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(md5Input, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(shaInput, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -2695,7 +2695,7 @@ static int MakeSslMasterSecret(CYASSL* ssl) /* Master wrapper, doesn't use SSL stack space in TLS mode */ -int MakeMasterSecret(CYASSL* ssl) +int MakeMasterSecret(WOLFSSL* ssl) { #ifdef NO_OLD_TLS return MakeTlsMasterSecret(ssl); diff --git a/src/ocsp.c b/src/ocsp.c index 95696b25a..d656e4d66 100644 --- a/src/ocsp.c +++ b/src/ocsp.c @@ -2,14 +2,14 @@ * * Copyright (C) 2006-2014 wolfSSL Inc. * - * This file is part of CyaSSL. + * This file is part of wolfSSL. (formerly known as CyaSSL) * - * 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 * the Free Software Foundation; either version 2 of the License, or * (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 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -20,24 +20,24 @@ */ /* Name change compatibility layer */ -#include +#include #ifdef HAVE_CONFIG_H #include #endif -#include +#include #ifdef HAVE_OCSP -#include -#include -#include +#include +#include +#include -int InitOCSP(CYASSL_OCSP* ocsp, CYASSL_CERT_MANAGER* cm) +int InitOCSP(WOLFSSL_OCSP* ocsp, WOLFSSL_CERT_MANAGER* cm) { - CYASSL_ENTER("InitOCSP"); + WOLFSSL_ENTER("InitOCSP"); XMEMSET(ocsp, 0, sizeof(*ocsp)); ocsp->cm = cm; if (InitMutex(&ocsp->ocspLock) != 0) @@ -49,7 +49,7 @@ int InitOCSP(CYASSL_OCSP* ocsp, CYASSL_CERT_MANAGER* cm) static int InitOCSP_Entry(OCSP_Entry* ocspe, DecodedCert* cert) { - CYASSL_ENTER("InitOCSP_Entry"); + WOLFSSL_ENTER("InitOCSP_Entry"); XMEMSET(ocspe, 0, sizeof(*ocspe)); XMEMCPY(ocspe->issuerHash, cert->issuerHash, SHA_DIGEST_SIZE); @@ -63,7 +63,7 @@ static void FreeOCSP_Entry(OCSP_Entry* ocspe) { CertStatus* tmp = ocspe->status; - CYASSL_ENTER("FreeOCSP_Entry"); + WOLFSSL_ENTER("FreeOCSP_Entry"); while (tmp) { CertStatus* next = tmp->next; @@ -73,11 +73,11 @@ static void FreeOCSP_Entry(OCSP_Entry* ocspe) } -void FreeOCSP(CYASSL_OCSP* ocsp, int dynamic) +void FreeOCSP(WOLFSSL_OCSP* ocsp, int dynamic) { OCSP_Entry* tmp = ocsp->ocspList; - CYASSL_ENTER("FreeOCSP"); + WOLFSSL_ENTER("FreeOCSP"); while (tmp) { OCSP_Entry* next = tmp->next; @@ -105,7 +105,7 @@ static int xstat2err(int stat) } -int CheckCertOCSP(CYASSL_OCSP* ocsp, DecodedCert* cert) +int CheckCertOCSP(WOLFSSL_OCSP* ocsp, DecodedCert* cert) { byte* ocspReqBuf = NULL; int ocspReqSz = 2048; @@ -115,7 +115,7 @@ int CheckCertOCSP(CYASSL_OCSP* ocsp, DecodedCert* cert) CertStatus* certStatus = NULL; const char *url; int urlSz; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK CertStatus* newStatus; OcspRequest* ocspRequest; OcspResponse* ocspResponse; @@ -125,10 +125,10 @@ int CheckCertOCSP(CYASSL_OCSP* ocsp, DecodedCert* cert) OcspResponse ocspResponse[1]; #endif - CYASSL_ENTER("CheckCertOCSP"); + WOLFSSL_ENTER("CheckCertOCSP"); if (LockMutex(&ocsp->ocspLock) != 0) { - CYASSL_LEAVE("CheckCertOCSP", BAD_MUTEX_E); + WOLFSSL_LEAVE("CheckCertOCSP", BAD_MUTEX_E); return BAD_MUTEX_E; } @@ -152,7 +152,7 @@ int CheckCertOCSP(CYASSL_OCSP* ocsp, DecodedCert* cert) } else { UnLockMutex(&ocsp->ocspLock); - CYASSL_LEAVE("CheckCertOCSP", MEMORY_ERROR); + WOLFSSL_LEAVE("CheckCertOCSP", MEMORY_ERROR); return MEMORY_ERROR; } } @@ -173,12 +173,12 @@ int CheckCertOCSP(CYASSL_OCSP* ocsp, DecodedCert* cert) (certStatus->nextDate[0] == 0) || !ValidateDate(certStatus->nextDate, certStatus->nextDateFormat, AFTER)) { - CYASSL_MSG("\tinvalid status date, looking up cert"); + WOLFSSL_MSG("\tinvalid status date, looking up cert"); } else { result = xstat2err(certStatus->status); UnLockMutex(&ocsp->ocspLock); - CYASSL_LEAVE("CheckCertOCSP", result); + WOLFSSL_LEAVE("CheckCertOCSP", result); return result; } } @@ -203,11 +203,11 @@ int CheckCertOCSP(CYASSL_OCSP* ocsp, DecodedCert* cert) ocspReqBuf = (byte*)XMALLOC(ocspReqSz, NULL, DYNAMIC_TYPE_IN_BUFFER); if (ocspReqBuf == NULL) { - CYASSL_LEAVE("CheckCertOCSP", MEMORY_ERROR); + WOLFSSL_LEAVE("CheckCertOCSP", MEMORY_ERROR); return MEMORY_ERROR; } -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK newStatus = (CertStatus*)XMALLOC(sizeof(CertStatus), NULL, DYNAMIC_TYPE_TMP_BUFFER); ocspRequest = (OcspRequest*)XMALLOC(sizeof(OcspRequest), NULL, @@ -222,7 +222,7 @@ int CheckCertOCSP(CYASSL_OCSP* ocsp, DecodedCert* cert) XFREE(ocspReqBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); - CYASSL_LEAVE("CheckCertOCSP", MEMORY_ERROR); + WOLFSSL_LEAVE("CheckCertOCSP", MEMORY_ERROR); return MEMORY_E; } #endif @@ -277,7 +277,7 @@ int CheckCertOCSP(CYASSL_OCSP* ocsp, DecodedCert* cert) XFREE(ocspReqBuf, NULL, DYNAMIC_TYPE_IN_BUFFER); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(newStatus, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(ocspRequest, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(ocspResponse, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -286,7 +286,7 @@ int CheckCertOCSP(CYASSL_OCSP* ocsp, DecodedCert* cert) if (ocspRespBuf != NULL && ocsp->cm->ocspRespFreeCb) ocsp->cm->ocspRespFreeCb(ocsp->cm->ocspIOCtx, ocspRespBuf); - CYASSL_LEAVE("CheckCertOCSP", result); + WOLFSSL_LEAVE("CheckCertOCSP", result); return result; } diff --git a/src/sniffer.c b/src/sniffer.c index 41dff99fb..a34b54de7 100644 --- a/src/sniffer.c +++ b/src/sniffer.c @@ -2,14 +2,14 @@ * * Copyright (C) 2006-2014 wolfSSL Inc. * - * This file is part of CyaSSL. + * This file is part of wolfSSL. (formerly known as CyaSSL) * - * 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 * the Free Software Foundation; either version 2 of the License, or * (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 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -20,15 +20,15 @@ */ /* Name change compatibility layer */ -#include +#include #ifdef HAVE_CONFIG_H #include #endif -#include +#include -#ifdef CYASSL_SNIFFER +#ifdef WOLFSSL_SNIFFER #include #include @@ -43,11 +43,11 @@ #define SNPRINTF snprintf #endif -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #ifndef min @@ -59,8 +59,8 @@ static INLINE word32 min(word32 a, word32 b) #endif -#ifndef CYASSL_SNIFFER_TIMEOUT - #define CYASSL_SNIFFER_TIMEOUT 900 +#ifndef WOLFSSL_SNIFFER_TIMEOUT + #define WOLFSSL_SNIFFER_TIMEOUT 900 /* Cache unclosed Sessions for 15 minutes since last used */ #endif @@ -290,7 +290,7 @@ typedef struct SnifferServer { int port; /* server port */ #ifdef HAVE_SNI NamedKey* namedKeys; /* mapping of names and keys */ - CyaSSL_Mutex namedKeysMutex; /* mutex for namedKey list */ + wolfSSL_Mutex namedKeysMutex; /* mutex for namedKey list */ #endif struct SnifferServer* next; /* for list */ } SnifferServer; @@ -343,19 +343,19 @@ typedef struct SnifferSession { /* Sniffer Server List and mutex */ static SnifferServer* ServerList = 0; -static CyaSSL_Mutex ServerListMutex; +static wolfSSL_Mutex ServerListMutex; /* Session Hash Table, mutex, and count */ static SnifferSession* SessionTable[HASH_SIZE]; -static CyaSSL_Mutex SessionMutex; +static wolfSSL_Mutex SessionMutex; static int SessionCount = 0; /* Initialize overall Sniffer */ void ssl_InitSniffer(void) { - CyaSSL_Init(); + wolfSSL_Init(); InitMutex(&ServerListMutex); InitMutex(&SessionMutex); } @@ -488,7 +488,7 @@ void ssl_FreeSniffer(void) TraceFile = NULL; } - CyaSSL_Cleanup(); + wolfSSL_Cleanup(); } @@ -980,9 +980,9 @@ static SnifferSession* GetSnifferSession(IpInfo* ipInfo, TcpInfo* tcpInfo) if (session) { if (ipInfo->dst == session->context->server && tcpInfo->dstPort == session->context->port) - session->flags.side = CYASSL_SERVER_END; + session->flags.side = WOLFSSL_SERVER_END; else - session->flags.side = CYASSL_CLIENT_END; + session->flags.side = WOLFSSL_CLIENT_END; } return session; @@ -1024,7 +1024,7 @@ static int LoadKeyFile(byte** keyBuf, word32* keyBufSz, if (typeKey == SSL_FILETYPE_PEM) { saveBuf = (byte*)malloc(fileSz); - saveBufSz = CyaSSL_KeyPemToDer(loadBuf, (int)fileSz, + saveBufSz = wolfSSL_KeyPemToDer(loadBuf, (int)fileSz, saveBuf, (int)fileSz, password); free(loadBuf); @@ -1560,10 +1560,10 @@ static int ProcessClientHello(const byte* input, int* sslBytes, word32 nameSz = sizeof(name); int ret; - ret = CyaSSL_SNI_GetFromBuffer( + ret = wolfSSL_SNI_GetFromBuffer( input - HANDSHAKE_HEADER_SZ - RECORD_HEADER_SZ, *sslBytes + HANDSHAKE_HEADER_SZ + RECORD_HEADER_SZ, - CYASSL_SNI_HOST_NAME, name, &nameSz); + WOLFSSL_SNI_HOST_NAME, name, &nameSz); if (ret == SSL_SUCCESS) { NamedKey* namedKey; @@ -1574,7 +1574,7 @@ static int ProcessClientHello(const byte* input, int* sslBytes, while (namedKey != NULL) { if (nameSz == namedKey->nameSz && XSTRNCMP((char*)name, namedKey->name, nameSz) == 0) { - if (CyaSSL_use_PrivateKey_buffer(session->sslServer, + if (wolfSSL_use_PrivateKey_buffer(session->sslServer, namedKey->key, namedKey->keySz, SSL_FILETYPE_ASN1) != SSL_SUCCESS) { UnLockMutex(&session->context->namedKeysMutex); @@ -1741,7 +1741,7 @@ static int ProcessFinished(const byte* input, int size, int* sslBytes, word32 inOutIdx = 0; int ret; - if (session->flags.side == CYASSL_SERVER_END) + if (session->flags.side == WOLFSSL_SERVER_END) ssl = session->sslServer; else ssl = session->sslClient; @@ -1757,7 +1757,7 @@ static int ProcessFinished(const byte* input, int size, int* sslBytes, if (ret == 0 && session->flags.cached == 0) { if (session->sslServer->options.haveSessionId) { - CYASSL_SESSION* sess = GetSession(session->sslServer, NULL); + WOLFSSL_SESSION* sess = GetSession(session->sslServer, NULL); if (sess == NULL) AddSession(session->sslServer); /* don't re add */ session->flags.cached = 1; @@ -1858,37 +1858,37 @@ static int Decrypt(SSL* ssl, byte* output, const byte* input, word32 sz) switch (ssl->specs.bulk_cipher_algorithm) { #ifdef BUILD_ARC4 - case cyassl_rc4: + case wolfssl_rc4: Arc4Process(ssl->decrypt.arc4, output, input, sz); break; #endif #ifdef BUILD_DES3 - case cyassl_triple_des: + case wolfssl_triple_des: ret = Des3_CbcDecrypt(ssl->decrypt.des3, output, input, sz); break; #endif #ifdef BUILD_AES - case cyassl_aes: + case wolfssl_aes: ret = AesCbcDecrypt(ssl->decrypt.aes, output, input, sz); break; #endif #ifdef HAVE_HC128 - case cyassl_hc128: + case wolfssl_hc128: Hc128_Process(ssl->decrypt.hc128, output, input, sz); break; #endif #ifdef BUILD_RABBIT - case cyassl_rabbit: + case wolfssl_rabbit: RabbitProcess(ssl->decrypt.rabbit, output, input, sz); break; #endif #ifdef HAVE_CAMELLIA - case cyassl_camellia: + case wolfssl_camellia: CamelliaCbcDecrypt(ssl->decrypt.cam, output, input, sz); break; #endif @@ -1981,7 +1981,7 @@ static void RemoveStaleSessions(void) session = SessionTable[i]; while (session) { SnifferSession* next = session->next; - if (time(NULL) >= session->lastUsed + CYASSL_SNIFFER_TIMEOUT) { + if (time(NULL) >= session->lastUsed + WOLFSSL_SNIFFER_TIMEOUT) { TraceStaleSession(); RemoveSession(session, NULL, NULL, i); } @@ -2037,7 +2037,7 @@ static SnifferSession* CreateSession(IpInfo* ipInfo, TcpInfo* tcpInfo, return 0; } /* put server back into server mode */ - session->sslServer->options.side = CYASSL_SERVER_END; + session->sslServer->options.side = WOLFSSL_SERVER_END; row = SessionHash(ipInfo, tcpInfo); @@ -2059,9 +2059,9 @@ static SnifferSession* CreateSession(IpInfo* ipInfo, TcpInfo* tcpInfo, /* determine headed side */ if (ipInfo->dst == session->context->server && tcpInfo->dstPort == session->context->port) - session->flags.side = CYASSL_SERVER_END; + session->flags.side = WOLFSSL_SERVER_END; else - session->flags.side = CYASSL_CLIENT_END; + session->flags.side = WOLFSSL_CLIENT_END; return session; } @@ -2276,7 +2276,7 @@ static int AddToReassembly(byte from, word32 seq, const byte* sslFrame, int sslBytes, SnifferSession* session, char* error) { PacketBuffer* add; - PacketBuffer** front = (from == CYASSL_SERVER_END) ? + PacketBuffer** front = (from == WOLFSSL_SERVER_END) ? &session->cliReassemblyList: &session->srvReassemblyList; PacketBuffer* curr = *front; PacketBuffer* prev = curr; @@ -2356,7 +2356,7 @@ static int AddToReassembly(byte from, word32 seq, const byte* sslFrame, /* returns 1 for success (end) */ static int AddFinCapture(SnifferSession* session, word32 sequence) { - if (session->flags.side == CYASSL_SERVER_END) { + if (session->flags.side == WOLFSSL_SERVER_END) { if (session->finCaputre.cliCounted == 0) session->finCaputre.cliFinSeq = sequence; } @@ -2373,12 +2373,12 @@ static int AddFinCapture(SnifferSession* session, word32 sequence) static int AdjustSequence(TcpInfo* tcpInfo, SnifferSession* session, int* sslBytes, const byte** sslFrame, char* error) { - word32 seqStart = (session->flags.side == CYASSL_SERVER_END) ? + word32 seqStart = (session->flags.side == WOLFSSL_SERVER_END) ? session->cliSeqStart :session->srvSeqStart; word32 real = tcpInfo->sequence - seqStart; - word32* expected = (session->flags.side == CYASSL_SERVER_END) ? + word32* expected = (session->flags.side == WOLFSSL_SERVER_END) ? &session->cliExpected : &session->srvExpected; - PacketBuffer* reassemblyList = (session->flags.side == CYASSL_SERVER_END) ? + PacketBuffer* reassemblyList = (session->flags.side == WOLFSSL_SERVER_END) ? session->cliReassemblyList : session->srvReassemblyList; /* handle rollover of sequence */ @@ -2442,10 +2442,10 @@ static int AdjustSequence(TcpInfo* tcpInfo, SnifferSession* session, static int CheckAck(TcpInfo* tcpInfo, SnifferSession* session) { if (tcpInfo->ack) { - word32 seqStart = (session->flags.side == CYASSL_SERVER_END) ? + word32 seqStart = (session->flags.side == WOLFSSL_SERVER_END) ? session->srvSeqStart :session->cliSeqStart; word32 real = tcpInfo->ackNumber - seqStart; - word32 expected = (session->flags.side == CYASSL_SERVER_END) ? + word32 expected = (session->flags.side == WOLFSSL_SERVER_END) ? session->srvExpected : session->cliExpected; /* handle rollover of sequence */ @@ -2500,7 +2500,7 @@ static int CheckPreRecord(IpInfo* ipInfo, TcpInfo* tcpInfo, int* sslBytes, const byte** end, char* error) { word32 length; - SSL* ssl = ((*session)->flags.side == CYASSL_SERVER_END) ? + SSL* ssl = ((*session)->flags.side == WOLFSSL_SERVER_END) ? (*session)->sslServer : (*session)->sslClient; /* remove SnifferSession on 2nd FIN or RST */ if (tcpInfo->fin || tcpInfo->rst) { @@ -2576,21 +2576,21 @@ static int HaveMoreInput(SnifferSession* session, const byte** sslFrame, { /* sequence and reassembly based on from, not to */ int moreInput = 0; - PacketBuffer** front = (session->flags.side == CYASSL_SERVER_END) ? + PacketBuffer** front = (session->flags.side == WOLFSSL_SERVER_END) ? &session->cliReassemblyList : &session->srvReassemblyList; - word32* expected = (session->flags.side == CYASSL_SERVER_END) ? + word32* expected = (session->flags.side == WOLFSSL_SERVER_END) ? &session->cliExpected : &session->srvExpected; /* buffer is on receiving end */ - word32* length = (session->flags.side == CYASSL_SERVER_END) ? + word32* length = (session->flags.side == WOLFSSL_SERVER_END) ? &session->sslServer->buffers.inputBuffer.length : &session->sslClient->buffers.inputBuffer.length; - byte* myBuffer = (session->flags.side == CYASSL_SERVER_END) ? + byte* myBuffer = (session->flags.side == WOLFSSL_SERVER_END) ? session->sslServer->buffers.inputBuffer.buffer : session->sslClient->buffers.inputBuffer.buffer; - word32 bufferSize = (session->flags.side == CYASSL_SERVER_END) ? + word32 bufferSize = (session->flags.side == WOLFSSL_SERVER_END) ? session->sslServer->buffers.inputBuffer.bufferSize : session->sslClient->buffers.inputBuffer.bufferSize; - SSL* ssl = (session->flags.side == CYASSL_SERVER_END) ? + SSL* ssl = (session->flags.side == WOLFSSL_SERVER_END) ? session->sslServer : session->sslClient; while (*front && ((*front)->begin == *expected) ) { @@ -2645,7 +2645,7 @@ static int ProcessMessage(const byte* sslFrame, SnifferSession* session, int decoded = 0; /* bytes stored for user in data */ int notEnough; /* notEnough bytes yet flag */ int decrypted = 0; /* was current msg decrypted */ - SSL* ssl = (session->flags.side == CYASSL_SERVER_END) ? + SSL* ssl = (session->flags.side == WOLFSSL_SERVER_END) ? session->sslServer : session->sslClient; doMessage: notEnough = 0; @@ -2687,9 +2687,9 @@ doMessage: inRecordEnd = recordEnd; /* decrypt if needed */ - if ((session->flags.side == CYASSL_SERVER_END && + if ((session->flags.side == WOLFSSL_SERVER_END && session->flags.serverCipherOn) - || (session->flags.side == CYASSL_CLIENT_END && + || (session->flags.side == WOLFSSL_CLIENT_END && session->flags.clientCipherOn)) { int ivAdvance = 0; /* TLSv1.1 advance amount */ if (ssl->decrypt.setup != 1) { @@ -2737,7 +2737,7 @@ doPart: } break; case change_cipher_spec: - if (session->flags.side == CYASSL_SERVER_END) + if (session->flags.side == WOLFSSL_SERVER_END) session->flags.serverCipherOn = 1; else session->flags.clientCipherOn = 1; @@ -2920,4 +2920,4 @@ int ssl_Trace(const char* traceFile, char* error) -#endif /* CYASSL_SNIFFER */ +#endif /* WOLFSSL_SNIFFER */ diff --git a/src/ssl.c b/src/ssl.c index 3d8cb18dc..b37e922bb 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -2,14 +2,14 @@ * * Copyright (C) 2006-2014 wolfSSL Inc. * - * This file is part of CyaSSL. + * This file is part of wolfSSL. (formerly known as CyaSSL) * - * 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 * the Free Software Foundation; either version 2 of the License, or * (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 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -20,50 +20,50 @@ */ /* Name change compatibility layer */ -#include +#include #ifdef HAVE_CONFIG_H #include #endif -#include +#include #ifdef HAVE_ERRNO_H #include #endif -#include -#include -#include -#include +#include +#include +#include +#include #if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) - #include + #include #endif #ifdef OPENSSL_EXTRA /* openssl headers begin */ - #include - #include - #include - #include - #include - #include - #include - /* openssl headers end, cyassl internal headers next */ - #include - #include - #include - #include - #include - #include - #ifdef CYASSL_SHA512 - #include + #include + #include + #include + #include + #include + #include + #include + /* openssl headers end, wolfssl internal headers next */ + #include + #include + #include + #include + #include + #include + #ifdef WOLFSSL_SHA512 + #include #endif #endif #ifndef NO_FILESYSTEM - #if !defined(USE_WINDOWS_API) && !defined(NO_CYASSL_DIR) \ + #if !defined(USE_WINDOWS_API) && !defined(NO_WOLFSSL_DIR) \ && !defined(EBSNET) #include #include @@ -91,7 +91,7 @@ #endif /* min */ #ifndef max -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS static INLINE word32 max(word32 a, word32 b) { return a > b ? a : b; @@ -100,7 +100,7 @@ #endif /* min */ -#ifndef CYASSL_LEANPSK +#ifndef WOLFSSL_LEANPSK char* mystrnstr(const char* s1, const char* s2, unsigned int n) { unsigned int s2_len = (unsigned int)XSTRLEN(s2); @@ -123,100 +123,100 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n) /* prevent multiple mutex initializations */ static volatile int initRefCount = 0; -static CyaSSL_Mutex count_mutex; /* init ref count mutex */ +static wolfSSL_Mutex count_mutex; /* init ref count mutex */ -CYASSL_CTX* CyaSSL_CTX_new(CYASSL_METHOD* method) +WOLFSSL_CTX* wolfSSL_CTX_new(WOLFSSL_METHOD* method) { - CYASSL_CTX* ctx = NULL; + WOLFSSL_CTX* ctx = NULL; - CYASSL_ENTER("CYASSL_CTX_new"); + WOLFSSL_ENTER("WOLFSSL_CTX_new"); if (initRefCount == 0) - CyaSSL_Init(); /* user no longer forced to call Init themselves */ + wolfSSL_Init(); /* user no longer forced to call Init themselves */ if (method == NULL) return ctx; - ctx = (CYASSL_CTX*) XMALLOC(sizeof(CYASSL_CTX), 0, DYNAMIC_TYPE_CTX); + ctx = (WOLFSSL_CTX*) XMALLOC(sizeof(WOLFSSL_CTX), 0, DYNAMIC_TYPE_CTX); if (ctx) { if (InitSSL_Ctx(ctx, method) < 0) { - CYASSL_MSG("Init CTX failed"); - CyaSSL_CTX_free(ctx); + WOLFSSL_MSG("Init CTX failed"); + wolfSSL_CTX_free(ctx); ctx = NULL; } } else { - CYASSL_MSG("Alloc CTX failed, method freed"); + WOLFSSL_MSG("Alloc CTX failed, method freed"); XFREE(method, NULL, DYNAMIC_TYPE_METHOD); } - CYASSL_LEAVE("CYASSL_CTX_new", 0); + WOLFSSL_LEAVE("WOLFSSL_CTX_new", 0); return ctx; } -void CyaSSL_CTX_free(CYASSL_CTX* ctx) +void wolfSSL_CTX_free(WOLFSSL_CTX* ctx) { - CYASSL_ENTER("SSL_CTX_free"); + WOLFSSL_ENTER("SSL_CTX_free"); if (ctx) FreeSSL_Ctx(ctx); - CYASSL_LEAVE("SSL_CTX_free", 0); + WOLFSSL_LEAVE("SSL_CTX_free", 0); } -CYASSL* CyaSSL_new(CYASSL_CTX* ctx) +WOLFSSL* wolfSSL_new(WOLFSSL_CTX* ctx) { - CYASSL* ssl = NULL; + WOLFSSL* ssl = NULL; int ret = 0; (void)ret; - CYASSL_ENTER("SSL_new"); + WOLFSSL_ENTER("SSL_new"); if (ctx == NULL) return ssl; - ssl = (CYASSL*) XMALLOC(sizeof(CYASSL), ctx->heap,DYNAMIC_TYPE_SSL); + ssl = (WOLFSSL*) XMALLOC(sizeof(WOLFSSL), ctx->heap,DYNAMIC_TYPE_SSL); if (ssl) if ( (ret = InitSSL(ssl, ctx)) < 0) { FreeSSL(ssl); ssl = 0; } - CYASSL_LEAVE("SSL_new", ret); + WOLFSSL_LEAVE("SSL_new", ret); return ssl; } -void CyaSSL_free(CYASSL* ssl) +void wolfSSL_free(WOLFSSL* ssl) { - CYASSL_ENTER("SSL_free"); + WOLFSSL_ENTER("SSL_free"); if (ssl) FreeSSL(ssl); - CYASSL_LEAVE("SSL_free", 0); + WOLFSSL_LEAVE("SSL_free", 0); } #ifdef HAVE_POLY1305 /* set if to use old poly 1 for yes 0 to use new poly */ -int CyaSSL_use_old_poly(CYASSL* ssl, int value) +int wolfSSL_use_old_poly(WOLFSSL* ssl, int value) { - CYASSL_ENTER("SSL_use_old_poly"); + WOLFSSL_ENTER("SSL_use_old_poly"); ssl->options.oldPoly = value; - CYASSL_LEAVE("SSL_use_old_poly", 0); + WOLFSSL_LEAVE("SSL_use_old_poly", 0); return 0; } #endif -int CyaSSL_set_fd(CYASSL* ssl, int fd) +int wolfSSL_set_fd(WOLFSSL* ssl, int fd) { - CYASSL_ENTER("SSL_set_fd"); + WOLFSSL_ENTER("SSL_set_fd"); ssl->rfd = fd; /* not used directly to allow IO callbacks */ ssl->wfd = fd; ssl->IOCB_ReadCtx = &ssl->rfd; ssl->IOCB_WriteCtx = &ssl->wfd; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { ssl->IOCB_ReadCtx = &ssl->buffers.dtlsCtx; ssl->IOCB_WriteCtx = &ssl->buffers.dtlsCtx; @@ -224,12 +224,12 @@ int CyaSSL_set_fd(CYASSL* ssl, int fd) } #endif - CYASSL_LEAVE("SSL_set_fd", SSL_SUCCESS); + WOLFSSL_LEAVE("SSL_set_fd", SSL_SUCCESS); return SSL_SUCCESS; } -int CyaSSL_get_ciphers(char* buf, int len) +int wolfSSL_get_ciphers(char* buf, int len) { const char* const* ciphers = GetCipherNames(); int totalInc = 0; @@ -261,39 +261,39 @@ int CyaSSL_get_ciphers(char* buf, int len) } -int CyaSSL_get_fd(const CYASSL* ssl) +int wolfSSL_get_fd(const WOLFSSL* ssl) { - CYASSL_ENTER("SSL_get_fd"); - CYASSL_LEAVE("SSL_get_fd", ssl->rfd); + WOLFSSL_ENTER("SSL_get_fd"); + WOLFSSL_LEAVE("SSL_get_fd", ssl->rfd); return ssl->rfd; } -int CyaSSL_get_using_nonblock(CYASSL* ssl) +int wolfSSL_get_using_nonblock(WOLFSSL* ssl) { - CYASSL_ENTER("CyaSSL_get_using_nonblock"); - CYASSL_LEAVE("CyaSSL_get_using_nonblock", ssl->options.usingNonblock); + WOLFSSL_ENTER("wolfSSL_get_using_nonblock"); + WOLFSSL_LEAVE("wolfSSL_get_using_nonblock", ssl->options.usingNonblock); return ssl->options.usingNonblock; } -int CyaSSL_dtls(CYASSL* ssl) +int wolfSSL_dtls(WOLFSSL* ssl) { return ssl->options.dtls; } -#ifndef CYASSL_LEANPSK -void CyaSSL_set_using_nonblock(CYASSL* ssl, int nonblock) +#ifndef WOLFSSL_LEANPSK +void wolfSSL_set_using_nonblock(WOLFSSL* ssl, int nonblock) { - CYASSL_ENTER("CyaSSL_set_using_nonblock"); + WOLFSSL_ENTER("wolfSSL_set_using_nonblock"); ssl->options.usingNonblock = (nonblock != 0); } -int CyaSSL_dtls_set_peer(CYASSL* ssl, void* peer, unsigned int peerSz) +int wolfSSL_dtls_set_peer(WOLFSSL* ssl, void* peer, unsigned int peerSz) { -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS void* sa = (void*)XMALLOC(peerSz, ssl->heap, DYNAMIC_TYPE_SOCKADDR); if (sa != NULL) { if (ssl->buffers.dtlsCtx.peer.sa != NULL) @@ -312,9 +312,9 @@ int CyaSSL_dtls_set_peer(CYASSL* ssl, void* peer, unsigned int peerSz) #endif } -int CyaSSL_dtls_get_peer(CYASSL* ssl, void* peer, unsigned int* peerSz) +int wolfSSL_dtls_get_peer(WOLFSSL* ssl, void* peer, unsigned int* peerSz) { -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (peer != NULL && peerSz != NULL && *peerSz >= ssl->buffers.dtlsCtx.peer.sz) { *peerSz = ssl->buffers.dtlsCtx.peer.sz; @@ -329,34 +329,34 @@ int CyaSSL_dtls_get_peer(CYASSL* ssl, void* peer, unsigned int* peerSz) return SSL_NOT_IMPLEMENTED; #endif } -#endif /* CYASSL_LEANPSK */ +#endif /* WOLFSSL_LEANPSK */ /* return underlyig connect or accept, SSL_SUCCESS on ok */ -int CyaSSL_negotiate(CYASSL* ssl) +int wolfSSL_negotiate(WOLFSSL* ssl) { int err = SSL_FATAL_ERROR; - CYASSL_ENTER("CyaSSL_negotiate"); -#ifndef NO_CYASSL_SERVER - if (ssl->options.side == CYASSL_SERVER_END) - err = CyaSSL_accept(ssl); + WOLFSSL_ENTER("wolfSSL_negotiate"); +#ifndef NO_WOLFSSL_SERVER + if (ssl->options.side == WOLFSSL_SERVER_END) + err = wolfSSL_accept(ssl); #endif -#ifndef NO_CYASSL_CLIENT - if (ssl->options.side == CYASSL_CLIENT_END) - err = CyaSSL_connect(ssl); +#ifndef NO_WOLFSSL_CLIENT + if (ssl->options.side == WOLFSSL_CLIENT_END) + err = wolfSSL_connect(ssl); #endif - CYASSL_LEAVE("CyaSSL_negotiate", err); + WOLFSSL_LEAVE("wolfSSL_negotiate", err); return err; } -#ifndef CYASSL_LEANPSK +#ifndef WOLFSSL_LEANPSK /* object size based on build */ -int CyaSSL_GetObjectSize(void) +int wolfSSL_GetObjectSize(void) { #ifdef SHOW_SIZES printf("sizeof suites = %lu\n", sizeof(Suites)); @@ -386,10 +386,10 @@ int CyaSSL_GetObjectSize(void) #ifndef NO_SHA256 printf(" sizeof SHA256 = %lu\n", sizeof(Sha256)); #endif -#ifdef CYASSL_SHA384 +#ifdef WOLFSSL_SHA384 printf(" sizeof SHA384 = %lu\n", sizeof(Sha384)); #endif -#ifdef CYASSL_SHA384 +#ifdef WOLFSSL_SHA384 printf(" sizeof SHA512 = %lu\n", sizeof(Sha512)); #endif printf("sizeof Buffers = %lu\n", sizeof(Buffers)); @@ -401,29 +401,29 @@ int CyaSSL_GetObjectSize(void) #ifdef HAVE_ECC printf("sizeof ecc_key = %lu\n", sizeof(ecc_key)); #endif - printf("sizeof CYASSL_CIPHER = %lu\n", sizeof(CYASSL_CIPHER)); - printf("sizeof CYASSL_SESSION = %lu\n", sizeof(CYASSL_SESSION)); - printf("sizeof CYASSL = %lu\n", sizeof(CYASSL)); - printf("sizeof CYASSL_CTX = %lu\n", sizeof(CYASSL_CTX)); + printf("sizeof WOLFSSL_CIPHER = %lu\n", sizeof(WOLFSSL_CIPHER)); + printf("sizeof WOLFSSL_SESSION = %lu\n", sizeof(WOLFSSL_SESSION)); + printf("sizeof WOLFSSL = %lu\n", sizeof(WOLFSSL)); + printf("sizeof WOLFSSL_CTX = %lu\n", sizeof(WOLFSSL_CTX)); #endif - return sizeof(CYASSL); + return sizeof(WOLFSSL); } #endif #ifndef NO_DH /* server Diffie-Hellman parameters, SSL_SUCCESS on ok */ -int CyaSSL_SetTmpDH(CYASSL* ssl, const unsigned char* p, int pSz, +int wolfSSL_SetTmpDH(WOLFSSL* ssl, const unsigned char* p, int pSz, const unsigned char* g, int gSz) { byte havePSK = 0; byte haveRSA = 1; - CYASSL_ENTER("CyaSSL_SetTmpDH"); + WOLFSSL_ENTER("wolfSSL_SetTmpDH"); if (ssl == NULL || p == NULL || g == NULL) return BAD_FUNC_ARG; - if (ssl->options.side != CYASSL_SERVER_END) + if (ssl->options.side != WOLFSSL_SERVER_END) return SIDE_ERROR; if (ssl->buffers.serverDH_P.buffer && ssl->buffers.weOwnDH) @@ -461,17 +461,17 @@ int CyaSSL_SetTmpDH(CYASSL* ssl, const unsigned char* p, int pSz, ssl->options.haveNTRU, ssl->options.haveECDSAsig, ssl->options.haveStaticECC, ssl->options.side); - CYASSL_LEAVE("CyaSSL_SetTmpDH", 0); + WOLFSSL_LEAVE("wolfSSL_SetTmpDH", 0); return SSL_SUCCESS; } #endif /* !NO_DH */ -int CyaSSL_write(CYASSL* ssl, const void* data, int sz) +int wolfSSL_write(WOLFSSL* ssl, const void* data, int sz) { int ret; - CYASSL_ENTER("SSL_write()"); + WOLFSSL_ENTER("SSL_write()"); if (ssl == NULL || data == NULL || sz < 0) return BAD_FUNC_ARG; @@ -482,7 +482,7 @@ int CyaSSL_write(CYASSL* ssl, const void* data, int sz) ret = SendData(ssl, data, sz); - CYASSL_LEAVE("SSL_write()", ret); + WOLFSSL_LEAVE("SSL_write()", ret); if (ret < 0) return SSL_FATAL_ERROR; @@ -491,11 +491,11 @@ int CyaSSL_write(CYASSL* ssl, const void* data, int sz) } -static int CyaSSL_read_internal(CYASSL* ssl, void* data, int sz, int peek) +static int wolfSSL_read_internal(WOLFSSL* ssl, void* data, int sz, int peek) { int ret; - CYASSL_ENTER("CyaSSL_read_internal()"); + WOLFSSL_ENTER("wolfSSL_read_internal()"); if (ssl == NULL || data == NULL || sz < 0) return BAD_FUNC_ARG; @@ -503,7 +503,7 @@ static int CyaSSL_read_internal(CYASSL* ssl, void* data, int sz, int peek) #ifdef HAVE_ERRNO_H errno = 0; #endif -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (ssl->options.dtls) ssl->dtls_expected_rx = max(sz + 100, MAX_MTU); #endif @@ -515,7 +515,7 @@ static int CyaSSL_read_internal(CYASSL* ssl, void* data, int sz, int peek) ret = ReceiveData(ssl, (byte*)data, min(sz, OUTPUT_RECORD_SIZE), peek); #endif - CYASSL_LEAVE("CyaSSL_read_internal()", ret); + WOLFSSL_LEAVE("wolfSSL_read_internal()", ret); if (ret < 0) return SSL_FATAL_ERROR; @@ -524,26 +524,26 @@ static int CyaSSL_read_internal(CYASSL* ssl, void* data, int sz, int peek) } -int CyaSSL_peek(CYASSL* ssl, void* data, int sz) +int wolfSSL_peek(WOLFSSL* ssl, void* data, int sz) { - CYASSL_ENTER("CyaSSL_peek()"); + WOLFSSL_ENTER("wolfSSL_peek()"); - return CyaSSL_read_internal(ssl, data, sz, TRUE); + return wolfSSL_read_internal(ssl, data, sz, TRUE); } -int CyaSSL_read(CYASSL* ssl, void* data, int sz) +int wolfSSL_read(WOLFSSL* ssl, void* data, int sz) { - CYASSL_ENTER("CyaSSL_read()"); + WOLFSSL_ENTER("wolfSSL_read()"); - return CyaSSL_read_internal(ssl, data, sz, FALSE); + return wolfSSL_read_internal(ssl, data, sz, FALSE); } #ifdef HAVE_CAVIUM /* let's use cavium, SSL_SUCCESS on ok */ -int CyaSSL_UseCavium(CYASSL* ssl, int devId) +int wolfSSL_UseCavium(WOLFSSL* ssl, int devId) { if (ssl == NULL) return BAD_FUNC_ARG; @@ -555,7 +555,7 @@ int CyaSSL_UseCavium(CYASSL* ssl, int devId) /* let's use cavium, SSL_SUCCESS on ok */ -int CyaSSL_CTX_UseCavium(CYASSL_CTX* ctx, int devId) +int wolfSSL_CTX_UseCavium(WOLFSSL_CTX* ctx, int devId) { if (ctx == NULL) return BAD_FUNC_ARG; @@ -570,7 +570,7 @@ int CyaSSL_CTX_UseCavium(CYASSL_CTX* ctx, int devId) #ifdef HAVE_SNI -int CyaSSL_UseSNI(CYASSL* ssl, byte type, const void* data, word16 size) +int wolfSSL_UseSNI(WOLFSSL* ssl, byte type, const void* data, word16 size) { if (ssl == NULL) return BAD_FUNC_ARG; @@ -578,7 +578,7 @@ int CyaSSL_UseSNI(CYASSL* ssl, byte type, const void* data, word16 size) return TLSX_UseSNI(&ssl->extensions, type, data, size); } -int CyaSSL_CTX_UseSNI(CYASSL_CTX* ctx, byte type, const void* data, word16 size) +int wolfSSL_CTX_UseSNI(WOLFSSL_CTX* ctx, byte type, const void* data, word16 size) { if (ctx == NULL) return BAD_FUNC_ARG; @@ -586,26 +586,26 @@ int CyaSSL_CTX_UseSNI(CYASSL_CTX* ctx, byte type, const void* data, word16 size) return TLSX_UseSNI(&ctx->extensions, type, data, size); } -#ifndef NO_CYASSL_SERVER +#ifndef NO_WOLFSSL_SERVER -void CyaSSL_SNI_SetOptions(CYASSL* ssl, byte type, byte options) +void wolfSSL_SNI_SetOptions(WOLFSSL* ssl, byte type, byte options) { if (ssl && ssl->extensions) TLSX_SNI_SetOptions(ssl->extensions, type, options); } -void CyaSSL_CTX_SNI_SetOptions(CYASSL_CTX* ctx, byte type, byte options) +void wolfSSL_CTX_SNI_SetOptions(WOLFSSL_CTX* ctx, byte type, byte options) { if (ctx && ctx->extensions) TLSX_SNI_SetOptions(ctx->extensions, type, options); } -byte CyaSSL_SNI_Status(CYASSL* ssl, byte type) +byte wolfSSL_SNI_Status(WOLFSSL* ssl, byte type) { return TLSX_SNI_Status(ssl ? ssl->extensions : NULL, type); } -word16 CyaSSL_SNI_GetRequest(CYASSL* ssl, byte type, void** data) +word16 wolfSSL_SNI_GetRequest(WOLFSSL* ssl, byte type, void** data) { if (data) *data = NULL; @@ -616,7 +616,7 @@ word16 CyaSSL_SNI_GetRequest(CYASSL* ssl, byte type, void** data) return 0; } -int CyaSSL_SNI_GetFromBuffer(const byte* clientHello, word32 helloSz, byte type, +int wolfSSL_SNI_GetFromBuffer(const byte* clientHello, word32 helloSz, byte type, byte* sni, word32* inOutSz) { if (clientHello && helloSz > 0 && sni && inOutSz && *inOutSz > 0) @@ -625,14 +625,14 @@ int CyaSSL_SNI_GetFromBuffer(const byte* clientHello, word32 helloSz, byte type, return BAD_FUNC_ARG; } -#endif /* NO_CYASSL_SERVER */ +#endif /* NO_WOLFSSL_SERVER */ #endif /* HAVE_SNI */ #ifdef HAVE_MAX_FRAGMENT -#ifndef NO_CYASSL_CLIENT -int CyaSSL_UseMaxFragment(CYASSL* ssl, byte mfl) +#ifndef NO_WOLFSSL_CLIENT +int wolfSSL_UseMaxFragment(WOLFSSL* ssl, byte mfl) { if (ssl == NULL) return BAD_FUNC_ARG; @@ -640,19 +640,19 @@ int CyaSSL_UseMaxFragment(CYASSL* ssl, byte mfl) return TLSX_UseMaxFragment(&ssl->extensions, mfl); } -int CyaSSL_CTX_UseMaxFragment(CYASSL_CTX* ctx, byte mfl) +int wolfSSL_CTX_UseMaxFragment(WOLFSSL_CTX* ctx, byte mfl) { if (ctx == NULL) return BAD_FUNC_ARG; return TLSX_UseMaxFragment(&ctx->extensions, mfl); } -#endif /* NO_CYASSL_CLIENT */ +#endif /* NO_WOLFSSL_CLIENT */ #endif /* HAVE_MAX_FRAGMENT */ #ifdef HAVE_TRUNCATED_HMAC -#ifndef NO_CYASSL_CLIENT -int CyaSSL_UseTruncatedHMAC(CYASSL* ssl) +#ifndef NO_WOLFSSL_CLIENT +int wolfSSL_UseTruncatedHMAC(WOLFSSL* ssl) { if (ssl == NULL) return BAD_FUNC_ARG; @@ -660,32 +660,32 @@ int CyaSSL_UseTruncatedHMAC(CYASSL* ssl) return TLSX_UseTruncatedHMAC(&ssl->extensions); } -int CyaSSL_CTX_UseTruncatedHMAC(CYASSL_CTX* ctx) +int wolfSSL_CTX_UseTruncatedHMAC(WOLFSSL_CTX* ctx) { if (ctx == NULL) return BAD_FUNC_ARG; return TLSX_UseTruncatedHMAC(&ctx->extensions); } -#endif /* NO_CYASSL_CLIENT */ +#endif /* NO_WOLFSSL_CLIENT */ #endif /* HAVE_TRUNCATED_HMAC */ /* Elliptic Curves */ #ifdef HAVE_SUPPORTED_CURVES -#ifndef NO_CYASSL_CLIENT +#ifndef NO_WOLFSSL_CLIENT -int CyaSSL_UseSupportedCurve(CYASSL* ssl, word16 name) +int wolfSSL_UseSupportedCurve(WOLFSSL* ssl, word16 name) { if (ssl == NULL) return BAD_FUNC_ARG; switch (name) { - case CYASSL_ECC_SECP160R1: - case CYASSL_ECC_SECP192R1: - case CYASSL_ECC_SECP224R1: - case CYASSL_ECC_SECP256R1: - case CYASSL_ECC_SECP384R1: - case CYASSL_ECC_SECP521R1: + case WOLFSSL_ECC_SECP160R1: + case WOLFSSL_ECC_SECP192R1: + case WOLFSSL_ECC_SECP224R1: + case WOLFSSL_ECC_SECP256R1: + case WOLFSSL_ECC_SECP384R1: + case WOLFSSL_ECC_SECP521R1: break; default: @@ -695,18 +695,18 @@ int CyaSSL_UseSupportedCurve(CYASSL* ssl, word16 name) return TLSX_UseSupportedCurve(&ssl->extensions, name); } -int CyaSSL_CTX_UseSupportedCurve(CYASSL_CTX* ctx, word16 name) +int wolfSSL_CTX_UseSupportedCurve(WOLFSSL_CTX* ctx, word16 name) { if (ctx == NULL) return BAD_FUNC_ARG; switch (name) { - case CYASSL_ECC_SECP160R1: - case CYASSL_ECC_SECP192R1: - case CYASSL_ECC_SECP224R1: - case CYASSL_ECC_SECP256R1: - case CYASSL_ECC_SECP384R1: - case CYASSL_ECC_SECP521R1: + case WOLFSSL_ECC_SECP160R1: + case WOLFSSL_ECC_SECP192R1: + case WOLFSSL_ECC_SECP224R1: + case WOLFSSL_ECC_SECP256R1: + case WOLFSSL_ECC_SECP384R1: + case WOLFSSL_ECC_SECP521R1: break; default: @@ -716,14 +716,14 @@ int CyaSSL_CTX_UseSupportedCurve(CYASSL_CTX* ctx, word16 name) return TLSX_UseSupportedCurve(&ctx->extensions, name); } -#endif /* NO_CYASSL_CLIENT */ +#endif /* NO_WOLFSSL_CLIENT */ #endif /* HAVE_SUPPORTED_CURVES */ /* Secure Renegotiation */ #ifdef HAVE_SECURE_RENEGOTIATION /* user is forcing ability to use secure renegotiation, we discourage it */ -int CyaSSL_UseSecureRenegotiation(CYASSL* ssl) +int wolfSSL_UseSecureRenegotiation(WOLFSSL* ssl) { int ret = BAD_FUNC_ARG; @@ -742,7 +742,7 @@ int CyaSSL_UseSecureRenegotiation(CYASSL* ssl) /* do a secure renegotiation handshake, user forced, we discourage */ -int CyaSSL_Rehandshake(CYASSL* ssl) +int wolfSSL_Rehandshake(WOLFSSL* ssl) { int ret; @@ -750,17 +750,17 @@ int CyaSSL_Rehandshake(CYASSL* ssl) return BAD_FUNC_ARG; if (ssl->secure_renegotiation == NULL) { - CYASSL_MSG("Secure Renegotiation not forced on by user"); + WOLFSSL_MSG("Secure Renegotiation not forced on by user"); return SECURE_RENEGOTIATION_E; } if (ssl->secure_renegotiation->enabled == 0) { - CYASSL_MSG("Secure Renegotiation not enabled at extension level"); + WOLFSSL_MSG("Secure Renegotiation not enabled at extension level"); return SECURE_RENEGOTIATION_E; } if (ssl->options.handShakeState != HANDSHAKE_DONE) { - CYASSL_MSG("Can't renegotiate until previous handshake complete"); + WOLFSSL_MSG("Can't renegotiate until previous handshake complete"); return SECURE_RENEGOTIATION_E; } @@ -800,21 +800,21 @@ int CyaSSL_Rehandshake(CYASSL* ssl) if (ret !=0) return ret; #endif -#ifdef CYASSL_SHA384 +#ifdef WOLFSSL_SHA384 ret = InitSha384(&ssl->hashSha384); if (ret !=0) return ret; #endif - ret = CyaSSL_negotiate(ssl); + ret = wolfSSL_negotiate(ssl); return ret; } #endif /* HAVE_SECURE_RENEGOTIATION */ /* Session Ticket */ -#if !defined(NO_CYASSL_CLIENT) && defined(HAVE_SESSION_TICKET) -int CyaSSL_UseSessionTicket(CYASSL* ssl) +#if !defined(NO_WOLFSSL_CLIENT) && defined(HAVE_SESSION_TICKET) +int wolfSSL_UseSessionTicket(WOLFSSL* ssl) { if (ssl == NULL) return BAD_FUNC_ARG; @@ -822,7 +822,7 @@ int CyaSSL_UseSessionTicket(CYASSL* ssl) return TLSX_UseSessionTicket(&ssl->extensions, NULL); } -int CyaSSL_CTX_UseSessionTicket(CYASSL_CTX* ctx) +int wolfSSL_CTX_UseSessionTicket(WOLFSSL_CTX* ctx) { if (ctx == NULL) return BAD_FUNC_ARG; @@ -830,7 +830,7 @@ int CyaSSL_CTX_UseSessionTicket(CYASSL_CTX* ctx) return TLSX_UseSessionTicket(&ctx->extensions, NULL); } -CYASSL_API int CyaSSL_get_SessionTicket(CYASSL* ssl, byte* buf, word32* bufSz) +WOLFSSL_API int wolfSSL_get_SessionTicket(WOLFSSL* ssl, byte* buf, word32* bufSz) { if (ssl == NULL || buf == NULL || bufSz == NULL || *bufSz == 0) return BAD_FUNC_ARG; @@ -845,7 +845,7 @@ CYASSL_API int CyaSSL_get_SessionTicket(CYASSL* ssl, byte* buf, word32* bufSz) return SSL_SUCCESS; } -CYASSL_API int CyaSSL_set_SessionTicket(CYASSL* ssl, byte* buf, word32 bufSz) +WOLFSSL_API int wolfSSL_set_SessionTicket(WOLFSSL* ssl, byte* buf, word32 bufSz) { if (ssl == NULL || (buf == NULL && bufSz > 0)) return BAD_FUNC_ARG; @@ -858,7 +858,7 @@ CYASSL_API int CyaSSL_set_SessionTicket(CYASSL* ssl, byte* buf, word32 bufSz) } -CYASSL_API int CyaSSL_set_SessionTicket_cb(CYASSL* ssl, +WOLFSSL_API int wolfSSL_set_SessionTicket_cb(WOLFSSL* ssl, CallbackSessionTicket cb, void* ctx) { if (ssl == NULL) @@ -871,14 +871,14 @@ CYASSL_API int CyaSSL_set_SessionTicket_cb(CYASSL* ssl, } #endif -#ifndef CYASSL_LEANPSK +#ifndef WOLFSSL_LEANPSK -int CyaSSL_send(CYASSL* ssl, const void* data, int sz, int flags) +int wolfSSL_send(WOLFSSL* ssl, const void* data, int sz, int flags) { int ret; int oldFlags; - CYASSL_ENTER("CyaSSL_send()"); + WOLFSSL_ENTER("wolfSSL_send()"); if (ssl == NULL || data == NULL || sz < 0) return BAD_FUNC_ARG; @@ -886,21 +886,21 @@ int CyaSSL_send(CYASSL* ssl, const void* data, int sz, int flags) oldFlags = ssl->wflags; ssl->wflags = flags; - ret = CyaSSL_write(ssl, data, sz); + ret = wolfSSL_write(ssl, data, sz); ssl->wflags = oldFlags; - CYASSL_LEAVE("CyaSSL_send()", ret); + WOLFSSL_LEAVE("wolfSSL_send()", ret); return ret; } -int CyaSSL_recv(CYASSL* ssl, void* data, int sz, int flags) +int wolfSSL_recv(WOLFSSL* ssl, void* data, int sz, int flags) { int ret; int oldFlags; - CYASSL_ENTER("CyaSSL_recv()"); + WOLFSSL_ENTER("wolfSSL_recv()"); if (ssl == NULL || data == NULL || sz < 0) return BAD_FUNC_ARG; @@ -908,10 +908,10 @@ int CyaSSL_recv(CYASSL* ssl, void* data, int sz, int flags) oldFlags = ssl->rflags; ssl->rflags = flags; - ret = CyaSSL_read(ssl, data, sz); + ret = wolfSSL_read(ssl, data, sz); ssl->rflags = oldFlags; - CYASSL_LEAVE("CyaSSL_recv()", ret); + WOLFSSL_LEAVE("wolfSSL_recv()", ret); return ret; } @@ -919,15 +919,15 @@ int CyaSSL_recv(CYASSL* ssl, void* data, int sz, int flags) /* SSL_SUCCESS on ok */ -int CyaSSL_shutdown(CYASSL* ssl) +int wolfSSL_shutdown(WOLFSSL* ssl) { - CYASSL_ENTER("SSL_shutdown()"); + WOLFSSL_ENTER("SSL_shutdown()"); if (ssl == NULL) return SSL_FATAL_ERROR; if (ssl->options.quietShutdown) { - CYASSL_MSG("quiet shutdown, no close notify sent"); + WOLFSSL_MSG("quiet shutdown, no close notify sent"); return SSL_SUCCESS; } @@ -936,13 +936,13 @@ int CyaSSL_shutdown(CYASSL* ssl) !ssl->options.sentNotify) { ssl->error = SendAlert(ssl, alert_warning, close_notify); if (ssl->error < 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } ssl->options.sentNotify = 1; /* don't send close_notify twice */ } - CYASSL_LEAVE("SSL_shutdown()", ssl->error); + WOLFSSL_LEAVE("SSL_shutdown()", ssl->error); ssl->error = SSL_ERROR_SYSCALL; /* simulate OpenSSL behavior */ @@ -950,16 +950,16 @@ int CyaSSL_shutdown(CYASSL* ssl) } -int CyaSSL_get_error(CYASSL* ssl, int ret) +int wolfSSL_get_error(WOLFSSL* ssl, int ret) { - CYASSL_ENTER("SSL_get_error"); + WOLFSSL_ENTER("SSL_get_error"); if (ret > 0) return SSL_ERROR_NONE; if (ssl == NULL) return BAD_FUNC_ARG; - CYASSL_LEAVE("SSL_get_error", ssl->error); + WOLFSSL_LEAVE("SSL_get_error", ssl->error); /* make sure converted types are handled in SetErrorString() too */ if (ssl->error == WANT_READ) @@ -973,7 +973,7 @@ int CyaSSL_get_error(CYASSL* ssl, int ret) /* retrive alert history, SSL_SUCCESS on ok */ -int CyaSSL_get_alert_history(CYASSL* ssl, CYASSL_ALERT_HISTORY *h) +int wolfSSL_get_alert_history(WOLFSSL* ssl, WOLFSSL_ALERT_HISTORY *h) { if (ssl && h) { *h = ssl->alert_history; @@ -983,9 +983,9 @@ int CyaSSL_get_alert_history(CYASSL* ssl, CYASSL_ALERT_HISTORY *h) /* return TRUE if current error is want read */ -int CyaSSL_want_read(CYASSL* ssl) +int wolfSSL_want_read(WOLFSSL* ssl) { - CYASSL_ENTER("SSL_want_read"); + WOLFSSL_ENTER("SSL_want_read"); if (ssl->error == WANT_READ) return 1; @@ -994,9 +994,9 @@ int CyaSSL_want_read(CYASSL* ssl) /* return TRUE if current error is want write */ -int CyaSSL_want_write(CYASSL* ssl) +int wolfSSL_want_write(WOLFSSL* ssl) { - CYASSL_ENTER("SSL_want_write"); + WOLFSSL_ENTER("SSL_want_write"); if (ssl->error == WANT_WRITE) return 1; @@ -1004,11 +1004,11 @@ int CyaSSL_want_write(CYASSL* ssl) } -char* CyaSSL_ERR_error_string(unsigned long errNumber, char* data) +char* wolfSSL_ERR_error_string(unsigned long errNumber, char* data) { static const char* msg = "Please supply a buffer for error string"; - CYASSL_ENTER("ERR_error_string"); + WOLFSSL_ENTER("ERR_error_string"); if (data) { SetErrorString((int)errNumber, data); return data; @@ -1018,17 +1018,17 @@ char* CyaSSL_ERR_error_string(unsigned long errNumber, char* data) } -void CyaSSL_ERR_error_string_n(unsigned long e, char* buf, unsigned long len) +void wolfSSL_ERR_error_string_n(unsigned long e, char* buf, unsigned long len) { - CYASSL_ENTER("CyaSSL_ERR_error_string_n"); - if (len >= CYASSL_MAX_ERROR_SZ) - CyaSSL_ERR_error_string(e, buf); + WOLFSSL_ENTER("wolfSSL_ERR_error_string_n"); + if (len >= WOLFSSL_MAX_ERROR_SZ) + wolfSSL_ERR_error_string(e, buf); else { - char tmp[CYASSL_MAX_ERROR_SZ]; + char tmp[WOLFSSL_MAX_ERROR_SZ]; - CYASSL_MSG("Error buffer too short, truncating"); + WOLFSSL_MSG("Error buffer too short, truncating"); if (len) { - CyaSSL_ERR_error_string(e, tmp); + wolfSSL_ERR_error_string(e, tmp); XMEMCPY(buf, tmp, len-1); buf[len-1] = '\0'; } @@ -1037,7 +1037,7 @@ void CyaSSL_ERR_error_string_n(unsigned long e, char* buf, unsigned long len) /* don't free temporary arrays at end of handshake */ -void CyaSSL_KeepArrays(CYASSL* ssl) +void wolfSSL_KeepArrays(WOLFSSL* ssl) { if (ssl) ssl->options.saveArrays = 1; @@ -1045,7 +1045,7 @@ void CyaSSL_KeepArrays(CYASSL* ssl) /* user doesn't need temporary arrays anymore, Free */ -void CyaSSL_FreeArrays(CYASSL* ssl) +void wolfSSL_FreeArrays(WOLFSSL* ssl) { if (ssl && ssl->options.handShakeState == HANDSHAKE_DONE) { ssl->options.saveArrays = 0; @@ -1054,13 +1054,13 @@ void CyaSSL_FreeArrays(CYASSL* ssl) } -const byte* CyaSSL_GetMacSecret(CYASSL* ssl, int verify) +const byte* wolfSSL_GetMacSecret(WOLFSSL* ssl, int verify) { if (ssl == NULL) return NULL; - if ( (ssl->options.side == CYASSL_CLIENT_END && !verify) || - (ssl->options.side == CYASSL_SERVER_END && verify) ) + if ( (ssl->options.side == WOLFSSL_CLIENT_END && !verify) || + (ssl->options.side == WOLFSSL_SERVER_END && verify) ) return ssl->keys.client_write_MAC_secret; else return ssl->keys.server_write_MAC_secret; @@ -1069,21 +1069,21 @@ const byte* CyaSSL_GetMacSecret(CYASSL* ssl, int verify) #ifdef ATOMIC_USER -void CyaSSL_CTX_SetMacEncryptCb(CYASSL_CTX* ctx, CallbackMacEncrypt cb) +void wolfSSL_CTX_SetMacEncryptCb(WOLFSSL_CTX* ctx, CallbackMacEncrypt cb) { if (ctx) ctx->MacEncryptCb = cb; } -void CyaSSL_SetMacEncryptCtx(CYASSL* ssl, void *ctx) +void wolfSSL_SetMacEncryptCtx(WOLFSSL* ssl, void *ctx) { if (ssl) ssl->MacEncryptCtx = ctx; } -void* CyaSSL_GetMacEncryptCtx(CYASSL* ssl) +void* wolfSSL_GetMacEncryptCtx(WOLFSSL* ssl) { if (ssl) return ssl->MacEncryptCtx; @@ -1092,21 +1092,21 @@ void* CyaSSL_GetMacEncryptCtx(CYASSL* ssl) } -void CyaSSL_CTX_SetDecryptVerifyCb(CYASSL_CTX* ctx, CallbackDecryptVerify cb) +void wolfSSL_CTX_SetDecryptVerifyCb(WOLFSSL_CTX* ctx, CallbackDecryptVerify cb) { if (ctx) ctx->DecryptVerifyCb = cb; } -void CyaSSL_SetDecryptVerifyCtx(CYASSL* ssl, void *ctx) +void wolfSSL_SetDecryptVerifyCtx(WOLFSSL* ssl, void *ctx) { if (ssl) ssl->DecryptVerifyCtx = ctx; } -void* CyaSSL_GetDecryptVerifyCtx(CYASSL* ssl) +void* wolfSSL_GetDecryptVerifyCtx(WOLFSSL* ssl) { if (ssl) return ssl->DecryptVerifyCtx; @@ -1115,7 +1115,7 @@ void* CyaSSL_GetDecryptVerifyCtx(CYASSL* ssl) } -const byte* CyaSSL_GetClientWriteKey(CYASSL* ssl) +const byte* wolfSSL_GetClientWriteKey(WOLFSSL* ssl) { if (ssl) return ssl->keys.client_write_key; @@ -1124,7 +1124,7 @@ const byte* CyaSSL_GetClientWriteKey(CYASSL* ssl) } -const byte* CyaSSL_GetClientWriteIV(CYASSL* ssl) +const byte* wolfSSL_GetClientWriteIV(WOLFSSL* ssl) { if (ssl) return ssl->keys.client_write_IV; @@ -1133,7 +1133,7 @@ const byte* CyaSSL_GetClientWriteIV(CYASSL* ssl) } -const byte* CyaSSL_GetServerWriteKey(CYASSL* ssl) +const byte* wolfSSL_GetServerWriteKey(WOLFSSL* ssl) { if (ssl) return ssl->keys.server_write_key; @@ -1142,7 +1142,7 @@ const byte* CyaSSL_GetServerWriteKey(CYASSL* ssl) } -const byte* CyaSSL_GetServerWriteIV(CYASSL* ssl) +const byte* wolfSSL_GetServerWriteIV(WOLFSSL* ssl) { if (ssl) return ssl->keys.server_write_IV; @@ -1151,7 +1151,7 @@ const byte* CyaSSL_GetServerWriteIV(CYASSL* ssl) } -int CyaSSL_GetKeySize(CYASSL* ssl) +int wolfSSL_GetKeySize(WOLFSSL* ssl) { if (ssl) return ssl->specs.key_size; @@ -1160,7 +1160,7 @@ int CyaSSL_GetKeySize(CYASSL* ssl) } -int CyaSSL_GetIVSize(CYASSL* ssl) +int wolfSSL_GetIVSize(WOLFSSL* ssl) { if (ssl) return ssl->specs.iv_size; @@ -1169,7 +1169,7 @@ int CyaSSL_GetIVSize(CYASSL* ssl) } -int CyaSSL_GetBulkCipher(CYASSL* ssl) +int wolfSSL_GetBulkCipher(WOLFSSL* ssl) { if (ssl) return ssl->specs.bulk_cipher_algorithm; @@ -1178,23 +1178,23 @@ int CyaSSL_GetBulkCipher(CYASSL* ssl) } -int CyaSSL_GetCipherType(CYASSL* ssl) +int wolfSSL_GetCipherType(WOLFSSL* ssl) { if (ssl == NULL) return BAD_FUNC_ARG; if (ssl->specs.cipher_type == block) - return CYASSL_BLOCK_TYPE; + return WOLFSSL_BLOCK_TYPE; if (ssl->specs.cipher_type == stream) - return CYASSL_STREAM_TYPE; + return WOLFSSL_STREAM_TYPE; if (ssl->specs.cipher_type == aead) - return CYASSL_AEAD_TYPE; + return WOLFSSL_AEAD_TYPE; return -1; } -int CyaSSL_GetCipherBlockSize(CYASSL* ssl) +int wolfSSL_GetCipherBlockSize(WOLFSSL* ssl) { if (ssl == NULL) return BAD_FUNC_ARG; @@ -1203,7 +1203,7 @@ int CyaSSL_GetCipherBlockSize(CYASSL* ssl) } -int CyaSSL_GetAeadMacSize(CYASSL* ssl) +int wolfSSL_GetAeadMacSize(WOLFSSL* ssl) { if (ssl == NULL) return BAD_FUNC_ARG; @@ -1212,7 +1212,7 @@ int CyaSSL_GetAeadMacSize(CYASSL* ssl) } -int CyaSSL_IsTLSv1_1(CYASSL* ssl) +int wolfSSL_IsTLSv1_1(WOLFSSL* ssl) { if (ssl == NULL) return BAD_FUNC_ARG; @@ -1224,7 +1224,7 @@ int CyaSSL_IsTLSv1_1(CYASSL* ssl) } -int CyaSSL_GetSide(CYASSL* ssl) +int wolfSSL_GetSide(WOLFSSL* ssl) { if (ssl) return ssl->options.side; @@ -1233,7 +1233,7 @@ int CyaSSL_GetSide(CYASSL* ssl) } -int CyaSSL_GetHmacSize(CYASSL* ssl) +int wolfSSL_GetHmacSize(WOLFSSL* ssl) { /* AEAD ciphers don't have HMAC keys */ if (ssl) @@ -1246,20 +1246,20 @@ int CyaSSL_GetHmacSize(CYASSL* ssl) #ifndef NO_CERTS -CYASSL_CERT_MANAGER* CyaSSL_CertManagerNew(void) +WOLFSSL_CERT_MANAGER* wolfSSL_CertManagerNew(void) { - CYASSL_CERT_MANAGER* cm = NULL; + WOLFSSL_CERT_MANAGER* cm = NULL; - CYASSL_ENTER("CyaSSL_CertManagerNew"); + WOLFSSL_ENTER("wolfSSL_CertManagerNew"); - cm = (CYASSL_CERT_MANAGER*) XMALLOC(sizeof(CYASSL_CERT_MANAGER), 0, + cm = (WOLFSSL_CERT_MANAGER*) XMALLOC(sizeof(WOLFSSL_CERT_MANAGER), 0, DYNAMIC_TYPE_CERT_MANAGER); if (cm) { - XMEMSET(cm, 0, sizeof(CYASSL_CERT_MANAGER)); + XMEMSET(cm, 0, sizeof(WOLFSSL_CERT_MANAGER)); if (InitMutex(&cm->caLock) != 0) { - CYASSL_MSG("Bad mutex init"); - CyaSSL_CertManagerFree(cm); + WOLFSSL_MSG("Bad mutex init"); + wolfSSL_CertManagerFree(cm); return NULL; } } @@ -1268,9 +1268,9 @@ CYASSL_CERT_MANAGER* CyaSSL_CertManagerNew(void) } -void CyaSSL_CertManagerFree(CYASSL_CERT_MANAGER* cm) +void wolfSSL_CertManagerFree(WOLFSSL_CERT_MANAGER* cm) { - CYASSL_ENTER("CyaSSL_CertManagerFree"); + WOLFSSL_ENTER("wolfSSL_CertManagerFree"); if (cm) { #ifdef HAVE_CRL @@ -1290,9 +1290,9 @@ void CyaSSL_CertManagerFree(CYASSL_CERT_MANAGER* cm) /* Unload the CA signer list */ -int CyaSSL_CertManagerUnloadCAs(CYASSL_CERT_MANAGER* cm) +int wolfSSL_CertManagerUnloadCAs(WOLFSSL_CERT_MANAGER* cm) { - CYASSL_ENTER("CyaSSL_CertManagerUnloadCAs"); + WOLFSSL_ENTER("wolfSSL_CertManagerUnloadCAs"); if (cm == NULL) return BAD_FUNC_ARG; @@ -1310,32 +1310,32 @@ int CyaSSL_CertManagerUnloadCAs(CYASSL_CERT_MANAGER* cm) /* Return bytes written to buff or < 0 for error */ -int CyaSSL_CertPemToDer(const unsigned char* pem, int pemSz, +int wolfSSL_CertPemToDer(const unsigned char* pem, int pemSz, unsigned char* buff, int buffSz, int type) { int eccKey = 0; int ret; buffer der; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK EncryptedInfo* info = NULL; #else EncryptedInfo info[1]; #endif - CYASSL_ENTER("CyaSSL_CertPemToDer"); + WOLFSSL_ENTER("wolfSSL_CertPemToDer"); if (pem == NULL || buff == NULL || buffSz <= 0) { - CYASSL_MSG("Bad pem der args"); + WOLFSSL_MSG("Bad pem der args"); return BAD_FUNC_ARG; } if (type != CERT_TYPE && type != CA_TYPE && type != CERTREQ_TYPE) { - CYASSL_MSG("Bad cert type"); + WOLFSSL_MSG("Bad cert type"); return BAD_FUNC_ARG; } -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK info = (EncryptedInfo*)XMALLOC(sizeof(EncryptedInfo), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (info == NULL) @@ -1349,12 +1349,12 @@ int CyaSSL_CertPemToDer(const unsigned char* pem, int pemSz, ret = PemToDer(pem, pemSz, type, &der, NULL, info, &eccKey); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif if (ret < 0) { - CYASSL_MSG("Bad Pem To Der"); + WOLFSSL_MSG("Bad Pem To Der"); } else { if (der.length <= (word32)buffSz) { @@ -1362,7 +1362,7 @@ int CyaSSL_CertPemToDer(const unsigned char* pem, int pemSz, ret = der.length; } else { - CYASSL_MSG("Bad der length"); + WOLFSSL_MSG("Bad der length"); ret = BAD_FUNC_ARG; } } @@ -1391,13 +1391,13 @@ static INLINE int OurPasswordCb(char* passwd, int sz, int rw, void* userdata) /* Return bytes written to buff or < 0 for error */ -int CyaSSL_KeyPemToDer(const unsigned char* pem, int pemSz, unsigned char* buff, +int wolfSSL_KeyPemToDer(const unsigned char* pem, int pemSz, unsigned char* buff, int buffSz, const char* pass) { int eccKey = 0; int ret; buffer der; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK EncryptedInfo* info = NULL; #else EncryptedInfo info[1]; @@ -1405,14 +1405,14 @@ int CyaSSL_KeyPemToDer(const unsigned char* pem, int pemSz, unsigned char* buff, (void)pass; - CYASSL_ENTER("CyaSSL_KeyPemToDer"); + WOLFSSL_ENTER("wolfSSL_KeyPemToDer"); if (pem == NULL || buff == NULL || buffSz <= 0) { - CYASSL_MSG("Bad pem der args"); + WOLFSSL_MSG("Bad pem der args"); return BAD_FUNC_ARG; } -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK info = (EncryptedInfo*)XMALLOC(sizeof(EncryptedInfo), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (info == NULL) @@ -1426,30 +1426,30 @@ int CyaSSL_KeyPemToDer(const unsigned char* pem, int pemSz, unsigned char* buff, #if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) if (pass) { - info->ctx = CyaSSL_CTX_new(CyaSSLv23_client_method()); + info->ctx = wolfSSL_CTX_new(wolfSSLv23_client_method()); if (info->ctx == NULL) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return MEMORY_E; } - CyaSSL_CTX_set_default_passwd_cb(info->ctx, OurPasswordCb); - CyaSSL_CTX_set_default_passwd_cb_userdata(info->ctx, (void*)pass); + wolfSSL_CTX_set_default_passwd_cb(info->ctx, OurPasswordCb); + wolfSSL_CTX_set_default_passwd_cb_userdata(info->ctx, (void*)pass); } #endif ret = PemToDer(pem, pemSz, PRIVATEKEY_TYPE, &der, NULL, info, &eccKey); if (info->ctx) - CyaSSL_CTX_free(info->ctx); + wolfSSL_CTX_free(info->ctx); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif if (ret < 0) { - CYASSL_MSG("Bad Pem To Der"); + WOLFSSL_MSG("Bad Pem To Der"); } else { if (der.length <= (word32)buffSz) { @@ -1457,7 +1457,7 @@ int CyaSSL_KeyPemToDer(const unsigned char* pem, int pemSz, unsigned char* buff, ret = der.length; } else { - CYASSL_MSG("Bad der length"); + WOLFSSL_MSG("Bad der length"); ret = BAD_FUNC_ARG; } } @@ -1474,11 +1474,11 @@ int CyaSSL_KeyPemToDer(const unsigned char* pem, int pemSz, unsigned char* buff, #if !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM) -void CyaSSL_ERR_print_errors_fp(FILE* fp, int err) +void wolfSSL_ERR_print_errors_fp(FILE* fp, int err) { - char data[CYASSL_MAX_ERROR_SZ + 1]; + char data[WOLFSSL_MAX_ERROR_SZ + 1]; - CYASSL_ENTER("CyaSSL_ERR_print_errors_fp"); + WOLFSSL_ENTER("wolfSSL_ERR_print_errors_fp"); SetErrorString(err, data); fprintf(fp, "%s", data); } @@ -1486,16 +1486,16 @@ void CyaSSL_ERR_print_errors_fp(FILE* fp, int err) #endif -int CyaSSL_pending(CYASSL* ssl) +int wolfSSL_pending(WOLFSSL* ssl) { - CYASSL_ENTER("SSL_pending"); + WOLFSSL_ENTER("SSL_pending"); return ssl->buffers.clearOutputBuffer.length; } -#ifndef CYASSL_LEANPSK +#ifndef WOLFSSL_LEANPSK /* trun on handshake group messages for context */ -int CyaSSL_CTX_set_group_messages(CYASSL_CTX* ctx) +int wolfSSL_CTX_set_group_messages(WOLFSSL_CTX* ctx) { if (ctx == NULL) return BAD_FUNC_ARG; @@ -1507,9 +1507,9 @@ int CyaSSL_CTX_set_group_messages(CYASSL_CTX* ctx) #endif -#ifndef NO_CYASSL_CLIENT +#ifndef NO_WOLFSSL_CLIENT /* connect enough to get peer cert chain */ -int CyaSSL_connect_cert(CYASSL* ssl) +int wolfSSL_connect_cert(WOLFSSL* ssl) { int ret; @@ -1517,7 +1517,7 @@ int CyaSSL_connect_cert(CYASSL* ssl) return SSL_FAILURE; ssl->options.certOnly = 1; - ret = CyaSSL_connect(ssl); + ret = wolfSSL_connect(ssl); ssl->options.certOnly = 0; return ret; @@ -1525,9 +1525,9 @@ int CyaSSL_connect_cert(CYASSL* ssl) #endif -#ifndef CYASSL_LEANPSK +#ifndef WOLFSSL_LEANPSK /* trun on handshake group messages for ssl object */ -int CyaSSL_set_group_messages(CYASSL* ssl) +int wolfSSL_set_group_messages(WOLFSSL* ssl) { if (ssl == NULL) return BAD_FUNC_ARG; @@ -1539,39 +1539,39 @@ int CyaSSL_set_group_messages(CYASSL* ssl) /* Set minimum downgrade version allowed, SSL_SUCCESS on ok */ -int CyaSSL_SetMinVersion(CYASSL* ssl, int version) +int wolfSSL_SetMinVersion(WOLFSSL* ssl, int version) { - CYASSL_ENTER("CyaSSL_SetMinVersion"); + WOLFSSL_ENTER("wolfSSL_SetMinVersion"); if (ssl == NULL) { - CYASSL_MSG("Bad function argument"); + WOLFSSL_MSG("Bad function argument"); return BAD_FUNC_ARG; } switch (version) { #ifndef NO_OLD_TLS - case CYASSL_SSLV3: + case WOLFSSL_SSLV3: ssl->options.minDowngrade = SSLv3_MINOR; break; #endif #ifndef NO_TLS #ifndef NO_OLD_TLS - case CYASSL_TLSV1: + case WOLFSSL_TLSV1: ssl->options.minDowngrade = TLSv1_MINOR; break; - case CYASSL_TLSV1_1: + case WOLFSSL_TLSV1_1: ssl->options.minDowngrade = TLSv1_1_MINOR; break; #endif - case CYASSL_TLSV1_2: + case WOLFSSL_TLSV1_2: ssl->options.minDowngrade = TLSv1_2_MINOR; break; #endif default: - CYASSL_MSG("Bad function argument"); + WOLFSSL_MSG("Bad function argument"); return BAD_FUNC_ARG; } @@ -1580,42 +1580,42 @@ int CyaSSL_SetMinVersion(CYASSL* ssl, int version) } -int CyaSSL_SetVersion(CYASSL* ssl, int version) +int wolfSSL_SetVersion(WOLFSSL* ssl, int version) { byte haveRSA = 1; byte havePSK = 0; - CYASSL_ENTER("CyaSSL_SetVersion"); + WOLFSSL_ENTER("wolfSSL_SetVersion"); if (ssl == NULL) { - CYASSL_MSG("Bad function argument"); + WOLFSSL_MSG("Bad function argument"); return BAD_FUNC_ARG; } switch (version) { #ifndef NO_OLD_TLS - case CYASSL_SSLV3: + case WOLFSSL_SSLV3: ssl->version = MakeSSLv3(); break; #endif #ifndef NO_TLS #ifndef NO_OLD_TLS - case CYASSL_TLSV1: + case WOLFSSL_TLSV1: ssl->version = MakeTLSv1(); break; - case CYASSL_TLSV1_1: + case WOLFSSL_TLSV1_1: ssl->version = MakeTLSv1_1(); break; #endif - case CYASSL_TLSV1_2: + case WOLFSSL_TLSV1_2: ssl->version = MakeTLSv1_2(); break; #endif default: - CYASSL_MSG("Bad function argument"); + WOLFSSL_MSG("Bad function argument"); return BAD_FUNC_ARG; } @@ -1657,7 +1657,7 @@ static INLINE word32 HashSigner(const byte* hash) /* does CA already exist on signer list */ -int AlreadySigner(CYASSL_CERT_MANAGER* cm, byte* hash) +int AlreadySigner(WOLFSSL_CERT_MANAGER* cm, byte* hash) { Signer* signers; int ret = 0; @@ -1688,7 +1688,7 @@ int AlreadySigner(CYASSL_CERT_MANAGER* cm, byte* hash) /* return CA if found, otherwise NULL */ Signer* GetCA(void* vp, byte* hash) { - CYASSL_CERT_MANAGER* cm = (CYASSL_CERT_MANAGER*)vp; + WOLFSSL_CERT_MANAGER* cm = (WOLFSSL_CERT_MANAGER*)vp; Signer* ret = NULL; Signer* signers; word32 row = HashSigner(hash); @@ -1723,7 +1723,7 @@ Signer* GetCA(void* vp, byte* hash) /* return CA if found, otherwise NULL. Walk through hash table. */ Signer* GetCAByName(void* vp, byte* hash) { - CYASSL_CERT_MANAGER* cm = (CYASSL_CERT_MANAGER*)vp; + WOLFSSL_CERT_MANAGER* cm = (WOLFSSL_CERT_MANAGER*)vp; Signer* ret = NULL; Signer* signers; word32 row; @@ -1753,21 +1753,21 @@ Signer* GetCAByName(void* vp, byte* hash) /* owns der, internal now uses too */ /* type flag ids from user or from chain received during verify don't allow chain ones to be added w/o isCA extension */ -int AddCA(CYASSL_CERT_MANAGER* cm, buffer der, int type, int verify) +int AddCA(WOLFSSL_CERT_MANAGER* cm, buffer der, int type, int verify) { int ret; Signer* signer = 0; word32 row; byte* subjectHash; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK DecodedCert* cert = NULL; #else DecodedCert cert[1]; #endif - CYASSL_MSG("Adding a CA"); + WOLFSSL_MSG("Adding a CA"); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK cert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (cert == NULL) @@ -1776,7 +1776,7 @@ int AddCA(CYASSL_CERT_MANAGER* cm, buffer der, int type, int verify) InitDecodedCert(cert, der.buffer, der.length, cm->heap); ret = ParseCert(cert, CA_TYPE, verify, cm); - CYASSL_MSG(" Parsed new CA"); + WOLFSSL_MSG(" Parsed new CA"); #ifndef NO_SKID subjectHash = cert->extSubjKeyId; @@ -1784,21 +1784,21 @@ int AddCA(CYASSL_CERT_MANAGER* cm, buffer der, int type, int verify) subjectHash = cert->subjectHash; #endif - if (ret == 0 && cert->isCA == 0 && type != CYASSL_USER_CA) { - CYASSL_MSG(" Can't add as CA if not actually one"); + if (ret == 0 && cert->isCA == 0 && type != WOLFSSL_USER_CA) { + WOLFSSL_MSG(" Can't add as CA if not actually one"); ret = NOT_CA_ERROR; } #ifndef ALLOW_INVALID_CERTSIGN - else if (ret == 0 && cert->isCA == 1 && type != CYASSL_USER_CA && + else if (ret == 0 && cert->isCA == 1 && type != WOLFSSL_USER_CA && (cert->extKeyUsage & KEYUSE_KEY_CERT_SIGN) == 0) { /* Intermediate CA certs are required to have the keyCertSign * extension set. User loaded root certs are not. */ - CYASSL_MSG(" Doesn't have key usage certificate signing"); + WOLFSSL_MSG(" Doesn't have key usage certificate signing"); ret = NOT_CA_ERROR; } #endif else if (ret == 0 && AlreadySigner(cm, subjectHash)) { - CYASSL_MSG(" Already have this CA, not adding again"); + WOLFSSL_MSG(" Already have this CA, not adding again"); (void)ret; } else if (ret == 0) { @@ -1846,23 +1846,23 @@ int AddCA(CYASSL_CERT_MANAGER* cm, buffer der, int type, int verify) cm->caCacheCallback(der.buffer, (int)der.length, type); } else { - CYASSL_MSG(" CA Mutex Lock failed"); + WOLFSSL_MSG(" CA Mutex Lock failed"); ret = BAD_MUTEX_E; FreeSigner(signer, cm->heap); } } } - CYASSL_MSG(" Freeing Parsed CA"); + WOLFSSL_MSG(" Freeing Parsed CA"); FreeDecodedCert(cert); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(cert, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif - CYASSL_MSG(" Freeing der CA"); + WOLFSSL_MSG(" Freeing der CA"); XFREE(der.buffer, cm->heap, DYNAMIC_TYPE_CA); - CYASSL_MSG(" OK Freeing der CA"); + WOLFSSL_MSG(" OK Freeing der CA"); - CYASSL_LEAVE("AddCA", ret); + WOLFSSL_LEAVE("AddCA", ret); return ret == 0 ? SSL_SUCCESS : ret; } @@ -1910,12 +1910,12 @@ int AddCA(CYASSL_CERT_MANAGER* cm, buffer der, int type, int verify) typedef struct SessionRow { int nextIdx; /* where to place next one */ int totalCount; /* sessions ever on this row */ - CYASSL_SESSION Sessions[SESSIONS_PER_ROW]; + WOLFSSL_SESSION Sessions[SESSIONS_PER_ROW]; } SessionRow; static SessionRow SessionCache[SESSION_ROWS]; - static CyaSSL_Mutex session_mutex; /* SessionCache mutex */ + static wolfSSL_Mutex session_mutex; /* SessionCache mutex */ #ifndef NO_CLIENT_CACHE @@ -1937,11 +1937,11 @@ int AddCA(CYASSL_CERT_MANAGER* cm, buffer der, int type, int verify) #endif /* NO_SESSION_CACHE */ -int CyaSSL_Init(void) +int wolfSSL_Init(void) { int ret = SSL_SUCCESS; - CYASSL_ENTER("CyaSSL_Init"); + WOLFSSL_ENTER("wolfSSL_Init"); if (initRefCount == 0) { #ifndef NO_SESSION_CACHE @@ -1953,7 +1953,7 @@ int CyaSSL_Init(void) } if (ret == SSL_SUCCESS) { if (LockMutex(&count_mutex) != 0) { - CYASSL_MSG("Bad Lock Mutex count"); + WOLFSSL_MSG("Bad Lock Mutex count"); return BAD_MUTEX_E; } initRefCount++; @@ -2036,7 +2036,7 @@ int PemToDer(const unsigned char* buff, long longSz, int type, } if (!headerEnd) { - CYASSL_MSG("Couldn't find PEM header"); + WOLFSSL_MSG("Couldn't find PEM header"); return SSL_NO_PEM_HEADER; } @@ -2146,7 +2146,7 @@ int PemToDer(const unsigned char* buff, long longSz, int type, #if (defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER)) && !defined(NO_PWDBASED) if (header == BEGIN_ENC_PRIV_KEY) { int passwordSz; - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK char* password = NULL; #else char password[80]; @@ -2155,7 +2155,7 @@ int PemToDer(const unsigned char* buff, long longSz, int type, if (!info || !info->ctx || !info->ctx->passwd_cb) return SSL_BAD_FILE; /* no callback error */ - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK password = (char*)XMALLOC(80, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (password == NULL) return MEMORY_E; @@ -2165,7 +2165,7 @@ int PemToDer(const unsigned char* buff, long longSz, int type, /* convert and adjust length */ ret = ToTraditionalEnc(der->buffer, der->length, password, passwordSz); - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(password, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -2184,8 +2184,8 @@ int PemToDer(const unsigned char* buff, long longSz, int type, /* process the buffer buff, legnth sz, into ctx of format and type used tracks bytes consumed, userChain specifies a user cert chain to pass during the handshake */ -static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff, - long sz, int format, int type, CYASSL* ssl, +static int ProcessBuffer(WOLFSSL_CTX* ctx, const unsigned char* buff, + long sz, int format, int type, WOLFSSL* ssl, long* used, int userChain) { buffer der; /* holds DER or RAW (for NTRU) */ @@ -2194,7 +2194,7 @@ static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff, int eccKey = 0; int rsaKey = 0; void* heap = ctx ? ctx->heap : NULL; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK EncryptedInfo* info = NULL; #else EncryptedInfo info[1]; @@ -2220,7 +2220,7 @@ static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff, else dynamicType = DYNAMIC_TYPE_KEY; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK info = (EncryptedInfo*)XMALLOC(sizeof(EncryptedInfo), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (info == NULL) @@ -2235,7 +2235,7 @@ static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff, if (format == SSL_FILETYPE_PEM) { ret = PemToDer(buff, sz, type, &der, heap, info, &eccKey); if (ret < 0) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif XFREE(der.buffer, heap, dynamicType); @@ -2247,7 +2247,7 @@ static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff, /* we may have a user cert chain, try to consume */ if (userChain && type == CERT_TYPE && info->consumed < sz) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK byte staticBuffer[1]; /* force heap usage */ #else byte staticBuffer[FILE_BUFFER_SIZE]; /* tmp chain buffer */ @@ -2262,12 +2262,12 @@ static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff, int gotOne = 0; if ( (sz - consumed) > (int)bufferSz) { - CYASSL_MSG("Growing Tmp Chain Buffer"); + WOLFSSL_MSG("Growing Tmp Chain Buffer"); bufferSz = (word32)(sz - consumed); /* will shrink to actual size */ chainBuffer = (byte*)XMALLOC(bufferSz, heap, DYNAMIC_TYPE_FILE); if (chainBuffer == NULL) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif XFREE(der.buffer, heap, dynamicType); @@ -2276,7 +2276,7 @@ static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff, dynamicBuffer = 1; } - CYASSL_MSG("Processing Cert Chain"); + WOLFSSL_MSG("Processing Cert Chain"); while (consumed < sz) { buffer part; info->consumed = 0; @@ -2287,7 +2287,7 @@ static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff, if (ret == 0) { gotOne = 1; if ( (idx + part.length) > bufferSz) { - CYASSL_MSG(" Cert Chain bigger than buffer"); + WOLFSSL_MSG(" Cert Chain bigger than buffer"); ret = BUFFER_E; } else { @@ -2304,23 +2304,23 @@ static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff, XFREE(part.buffer, heap, dynamicType); if (ret == SSL_NO_PEM_HEADER && gotOne) { - CYASSL_MSG("We got one good PEM so stuff at end ok"); + WOLFSSL_MSG("We got one good PEM so stuff at end ok"); break; } if (ret < 0) { - CYASSL_MSG(" Error in Cert in Chain"); + WOLFSSL_MSG(" Error in Cert in Chain"); if (dynamicBuffer) XFREE(chainBuffer, heap, DYNAMIC_TYPE_FILE); - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif XFREE(der.buffer, heap, dynamicType); return ret; } - CYASSL_MSG(" Consumed another Cert in Chain"); + WOLFSSL_MSG(" Consumed another Cert in Chain"); } - CYASSL_MSG("Finished Processing Cert Chain"); + WOLFSSL_MSG("Finished Processing Cert Chain"); /* only retain actual size used */ shrinked = (byte*)XMALLOC(idx, heap, dynamicType); @@ -2348,7 +2348,7 @@ static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff, XFREE(chainBuffer, heap, DYNAMIC_TYPE_FILE); if (shrinked == NULL) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif XFREE(der.buffer, heap, dynamicType); @@ -2359,7 +2359,7 @@ static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff, else { /* ASN1 (DER) or RAW (NTRU) */ der.buffer = (byte*) XMALLOC(sz, heap, dynamicType); if (!der.buffer) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return MEMORY_ERROR; @@ -2373,7 +2373,7 @@ static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff, if (info->set) { /* decrypt */ int passwordSz; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK char* password = NULL; byte* key = NULL; byte* iv = NULL; @@ -2383,7 +2383,7 @@ static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff, byte iv[AES_IV_SIZE]; #endif - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK password = (char*)XMALLOC(80, NULL, DYNAMIC_TYPE_TMP_BUFFER); key = (byte*)XMALLOC(AES_256_KEY_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -2439,14 +2439,14 @@ static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff, } } - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(password, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(iv, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif if (ret != 0) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif XFREE(der.buffer, heap, dynamicType); @@ -2455,17 +2455,17 @@ static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff, } #endif /* OPENSSL_EXTRA || HAVE_WEBSERVER */ -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif if (type == CA_TYPE) { if (ctx == NULL) { - CYASSL_MSG("Need context for CA load"); + WOLFSSL_MSG("Need context for CA load"); XFREE(der.buffer, heap, dynamicType); return BAD_FUNC_ARG; } - return AddCA(ctx->cm, der, CYASSL_USER_CA, ctx->verifyPeer); + return AddCA(ctx->cm, der, WOLFSSL_USER_CA, ctx->verifyPeer); /* takes der over */ } else if (type == CERT_TYPE) { @@ -2504,13 +2504,13 @@ static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff, if (!eccKey) { /* make sure RSA key can be used */ word32 idx = 0; - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK RsaKey* key = NULL; #else RsaKey key[1]; #endif - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK key = (RsaKey*)XMALLOC(sizeof(RsaKey), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (key == NULL) @@ -2535,7 +2535,7 @@ static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff, FreeRsaKey(key); - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(key, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -2564,25 +2564,25 @@ static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff, #endif /* HAVE_ECC */ } else if (type == CERT_TYPE) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK DecodedCert* cert = NULL; #else DecodedCert cert[1]; #endif - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK cert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (cert == NULL) return MEMORY_E; #endif - CYASSL_MSG("Checking cert signature type"); + WOLFSSL_MSG("Checking cert signature type"); InitDecodedCert(cert, der.buffer, der.length, heap); if (DecodeToKey(cert, 0) < 0) { - CYASSL_MSG("Decode to key failed"); - #ifdef CYASSL_SMALL_STACK + WOLFSSL_MSG("Decode to key failed"); + #ifdef WOLFSSL_SMALL_STACK XFREE(cert, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return SSL_BAD_FILE; @@ -2592,14 +2592,14 @@ static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff, case CTC_SHA256wECDSA: case CTC_SHA384wECDSA: case CTC_SHA512wECDSA: - CYASSL_MSG("ECDSA cert signature"); + WOLFSSL_MSG("ECDSA cert signature"); if (ctx) ctx->haveECDSAsig = 1; if (ssl) ssl->options.haveECDSAsig = 1; break; default: - CYASSL_MSG("Not ECDSA cert signature"); + WOLFSSL_MSG("Not ECDSA cert signature"); break; } @@ -2611,7 +2611,7 @@ static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff, #endif FreeDecodedCert(cert); - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(cert, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif } @@ -2621,14 +2621,14 @@ static int ProcessBuffer(CYASSL_CTX* ctx, const unsigned char* buff, /* CA PEM file for verification, may have multiple/chain certs to process */ -static int ProcessChainBuffer(CYASSL_CTX* ctx, const unsigned char* buff, - long sz, int format, int type, CYASSL* ssl) +static int ProcessChainBuffer(WOLFSSL_CTX* ctx, const unsigned char* buff, + long sz, int format, int type, WOLFSSL* ssl) { long used = 0; int ret = 0; int gotOne = 0; - CYASSL_MSG("Processing CA PEM file"); + WOLFSSL_MSG("Processing CA PEM file"); while (used < sz) { long consumed = 0; @@ -2636,7 +2636,7 @@ static int ProcessChainBuffer(CYASSL_CTX* ctx, const unsigned char* buff, &consumed, 0); if (ret == SSL_NO_PEM_HEADER && gotOne) { - CYASSL_MSG("We got one good PEM file so stuff at end ok"); + WOLFSSL_MSG("We got one good PEM file so stuff at end ok"); ret = SSL_SUCCESS; break; } @@ -2644,7 +2644,7 @@ static int ProcessChainBuffer(CYASSL_CTX* ctx, const unsigned char* buff, if (ret < 0) break; - CYASSL_MSG(" Processed a CA"); + WOLFSSL_MSG(" Processed a CA"); gotOne = 1; used += consumed; } @@ -2654,20 +2654,20 @@ static int ProcessChainBuffer(CYASSL_CTX* ctx, const unsigned char* buff, /* Verify the ceritficate, SSL_SUCCESS for ok, < 0 for error */ -int CyaSSL_CertManagerVerifyBuffer(CYASSL_CERT_MANAGER* cm, const byte* buff, +int wolfSSL_CertManagerVerifyBuffer(WOLFSSL_CERT_MANAGER* cm, const byte* buff, long sz, int format) { int ret = 0; buffer der; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK DecodedCert* cert = NULL; #else DecodedCert cert[1]; #endif - CYASSL_ENTER("CyaSSL_CertManagerVerifyBuffer"); + WOLFSSL_ENTER("wolfSSL_CertManagerVerifyBuffer"); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK cert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (cert == NULL) @@ -2679,13 +2679,13 @@ int CyaSSL_CertManagerVerifyBuffer(CYASSL_CERT_MANAGER* cm, const byte* buff, if (format == SSL_FILETYPE_PEM) { int eccKey = 0; /* not used */ - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK EncryptedInfo* info = NULL; #else EncryptedInfo info[1]; #endif - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK info = (EncryptedInfo*)XMALLOC(sizeof(EncryptedInfo), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (info == NULL) { @@ -2703,7 +2703,7 @@ int CyaSSL_CertManagerVerifyBuffer(CYASSL_CERT_MANAGER* cm, const byte* buff, if (ret == 0) InitDecodedCert(cert, der.buffer, der.length, cm->heap); - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif } @@ -2721,7 +2721,7 @@ int CyaSSL_CertManagerVerifyBuffer(CYASSL_CERT_MANAGER* cm, const byte* buff, FreeDecodedCert(cert); XFREE(der.buffer, cm->heap, DYNAMIC_TYPE_CERT); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(cert, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -2730,41 +2730,41 @@ int CyaSSL_CertManagerVerifyBuffer(CYASSL_CERT_MANAGER* cm, const byte* buff, /* turn on OCSP if off and compiled in, set options */ -int CyaSSL_CertManagerEnableOCSP(CYASSL_CERT_MANAGER* cm, int options) +int wolfSSL_CertManagerEnableOCSP(WOLFSSL_CERT_MANAGER* cm, int options) { int ret = SSL_SUCCESS; (void)options; - CYASSL_ENTER("CyaSSL_CertManagerEnableOCSP"); + WOLFSSL_ENTER("wolfSSL_CertManagerEnableOCSP"); if (cm == NULL) return BAD_FUNC_ARG; #ifdef HAVE_OCSP if (cm->ocsp == NULL) { - cm->ocsp = (CYASSL_OCSP*)XMALLOC(sizeof(CYASSL_OCSP), cm->heap, + cm->ocsp = (WOLFSSL_OCSP*)XMALLOC(sizeof(WOLFSSL_OCSP), cm->heap, DYNAMIC_TYPE_OCSP); if (cm->ocsp == NULL) return MEMORY_E; if (InitOCSP(cm->ocsp, cm) != 0) { - CYASSL_MSG("Init OCSP failed"); + WOLFSSL_MSG("Init OCSP failed"); FreeOCSP(cm->ocsp, 1); cm->ocsp = NULL; return SSL_FAILURE; } } cm->ocspEnabled = 1; - if (options & CYASSL_OCSP_URL_OVERRIDE) + if (options & WOLFSSL_OCSP_URL_OVERRIDE) cm->ocspUseOverrideURL = 1; - if (options & CYASSL_OCSP_NO_NONCE) + if (options & WOLFSSL_OCSP_NO_NONCE) cm->ocspSendNonce = 0; else cm->ocspSendNonce = 1; - #ifndef CYASSL_USER_IO + #ifndef WOLFSSL_USER_IO cm->ocspIOCb = EmbedOcspLookup; cm->ocspRespFreeCb = EmbedOcspRespFree; - #endif /* CYASSL_USER_IO */ + #endif /* WOLFSSL_USER_IO */ #else ret = NOT_COMPILED_IN; #endif @@ -2773,9 +2773,9 @@ int CyaSSL_CertManagerEnableOCSP(CYASSL_CERT_MANAGER* cm, int options) } -int CyaSSL_CertManagerDisableOCSP(CYASSL_CERT_MANAGER* cm) +int wolfSSL_CertManagerDisableOCSP(WOLFSSL_CERT_MANAGER* cm) { - CYASSL_ENTER("CyaSSL_CertManagerDisableOCSP"); + WOLFSSL_ENTER("wolfSSL_CertManagerDisableOCSP"); if (cm == NULL) return BAD_FUNC_ARG; @@ -2789,16 +2789,16 @@ int CyaSSL_CertManagerDisableOCSP(CYASSL_CERT_MANAGER* cm) /* check CRL if enabled, SSL_SUCCESS */ -int CyaSSL_CertManagerCheckOCSP(CYASSL_CERT_MANAGER* cm, byte* der, int sz) +int wolfSSL_CertManagerCheckOCSP(WOLFSSL_CERT_MANAGER* cm, byte* der, int sz) { int ret; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK DecodedCert* cert = NULL; #else DecodedCert cert[1]; #endif - CYASSL_ENTER("CyaSSL_CertManagerCheckOCSP"); + WOLFSSL_ENTER("wolfSSL_CertManagerCheckOCSP"); if (cm == NULL) return BAD_FUNC_ARG; @@ -2806,7 +2806,7 @@ int CyaSSL_CertManagerCheckOCSP(CYASSL_CERT_MANAGER* cm, byte* der, int sz) if (cm->ocspEnabled == 0) return SSL_SUCCESS; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK cert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (cert == NULL) @@ -2816,14 +2816,14 @@ int CyaSSL_CertManagerCheckOCSP(CYASSL_CERT_MANAGER* cm, byte* der, int sz) InitDecodedCert(cert, der, sz, NULL); if ((ret = ParseCertRelative(cert, CERT_TYPE, NO_VERIFY, cm)) != 0) { - CYASSL_MSG("ParseCert failed"); + WOLFSSL_MSG("ParseCert failed"); } else if ((ret = CheckCertOCSP(cm->ocsp, cert)) != 0) { - CYASSL_MSG("CheckCertOCSP failed"); + WOLFSSL_MSG("CheckCertOCSP failed"); } FreeDecodedCert(cert); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(cert, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -2831,10 +2831,10 @@ int CyaSSL_CertManagerCheckOCSP(CYASSL_CERT_MANAGER* cm, byte* der, int sz) } -int CyaSSL_CertManagerSetOCSPOverrideURL(CYASSL_CERT_MANAGER* cm, +int wolfSSL_CertManagerSetOCSPOverrideURL(WOLFSSL_CERT_MANAGER* cm, const char* url) { - CYASSL_ENTER("CyaSSL_CertManagerSetOCSPOverrideURL"); + WOLFSSL_ENTER("wolfSSL_CertManagerSetOCSPOverrideURL"); if (cm == NULL) return BAD_FUNC_ARG; @@ -2855,10 +2855,10 @@ int CyaSSL_CertManagerSetOCSPOverrideURL(CYASSL_CERT_MANAGER* cm, } -int CyaSSL_CertManagerSetOCSP_Cb(CYASSL_CERT_MANAGER* cm, +int wolfSSL_CertManagerSetOCSP_Cb(WOLFSSL_CERT_MANAGER* cm, CbOCSPIO ioCb, CbOCSPRespFree respFreeCb, void* ioCbCtx) { - CYASSL_ENTER("CyaSSL_CertManagerSetOCSP_Cb"); + WOLFSSL_ENTER("wolfSSL_CertManagerSetOCSP_Cb"); if (cm == NULL) return BAD_FUNC_ARG; @@ -2870,84 +2870,84 @@ int CyaSSL_CertManagerSetOCSP_Cb(CYASSL_CERT_MANAGER* cm, } -int CyaSSL_EnableOCSP(CYASSL* ssl, int options) +int wolfSSL_EnableOCSP(WOLFSSL* ssl, int options) { - CYASSL_ENTER("CyaSSL_EnableOCSP"); + WOLFSSL_ENTER("wolfSSL_EnableOCSP"); if (ssl) - return CyaSSL_CertManagerEnableOCSP(ssl->ctx->cm, options); + return wolfSSL_CertManagerEnableOCSP(ssl->ctx->cm, options); else return BAD_FUNC_ARG; } -int CyaSSL_DisableOCSP(CYASSL* ssl) +int wolfSSL_DisableOCSP(WOLFSSL* ssl) { - CYASSL_ENTER("CyaSSL_DisableOCSP"); + WOLFSSL_ENTER("wolfSSL_DisableOCSP"); if (ssl) - return CyaSSL_CertManagerDisableOCSP(ssl->ctx->cm); + return wolfSSL_CertManagerDisableOCSP(ssl->ctx->cm); else return BAD_FUNC_ARG; } -int CyaSSL_SetOCSP_OverrideURL(CYASSL* ssl, const char* url) +int wolfSSL_SetOCSP_OverrideURL(WOLFSSL* ssl, const char* url) { - CYASSL_ENTER("CyaSSL_SetOCSP_OverrideURL"); + WOLFSSL_ENTER("wolfSSL_SetOCSP_OverrideURL"); if (ssl) - return CyaSSL_CertManagerSetOCSPOverrideURL(ssl->ctx->cm, url); + return wolfSSL_CertManagerSetOCSPOverrideURL(ssl->ctx->cm, url); else return BAD_FUNC_ARG; } -int CyaSSL_SetOCSP_Cb(CYASSL* ssl, +int wolfSSL_SetOCSP_Cb(WOLFSSL* ssl, CbOCSPIO ioCb, CbOCSPRespFree respFreeCb, void* ioCbCtx) { - CYASSL_ENTER("CyaSSL_SetOCSP_Cb"); + WOLFSSL_ENTER("wolfSSL_SetOCSP_Cb"); if (ssl) - return CyaSSL_CertManagerSetOCSP_Cb(ssl->ctx->cm, + return wolfSSL_CertManagerSetOCSP_Cb(ssl->ctx->cm, ioCb, respFreeCb, ioCbCtx); else return BAD_FUNC_ARG; } -int CyaSSL_CTX_EnableOCSP(CYASSL_CTX* ctx, int options) +int wolfSSL_CTX_EnableOCSP(WOLFSSL_CTX* ctx, int options) { - CYASSL_ENTER("CyaSSL_CTX_EnableOCSP"); + WOLFSSL_ENTER("wolfSSL_CTX_EnableOCSP"); if (ctx) - return CyaSSL_CertManagerEnableOCSP(ctx->cm, options); + return wolfSSL_CertManagerEnableOCSP(ctx->cm, options); else return BAD_FUNC_ARG; } -int CyaSSL_CTX_DisableOCSP(CYASSL_CTX* ctx) +int wolfSSL_CTX_DisableOCSP(WOLFSSL_CTX* ctx) { - CYASSL_ENTER("CyaSSL_CTX_DisableOCSP"); + WOLFSSL_ENTER("wolfSSL_CTX_DisableOCSP"); if (ctx) - return CyaSSL_CertManagerDisableOCSP(ctx->cm); + return wolfSSL_CertManagerDisableOCSP(ctx->cm); else return BAD_FUNC_ARG; } -int CyaSSL_CTX_SetOCSP_OverrideURL(CYASSL_CTX* ctx, const char* url) +int wolfSSL_CTX_SetOCSP_OverrideURL(WOLFSSL_CTX* ctx, const char* url) { - CYASSL_ENTER("CyaSSL_SetOCSP_OverrideURL"); + WOLFSSL_ENTER("wolfSSL_SetOCSP_OverrideURL"); if (ctx) - return CyaSSL_CertManagerSetOCSPOverrideURL(ctx->cm, url); + return wolfSSL_CertManagerSetOCSPOverrideURL(ctx->cm, url); else return BAD_FUNC_ARG; } -int CyaSSL_CTX_SetOCSP_Cb(CYASSL_CTX* ctx, +int wolfSSL_CTX_SetOCSP_Cb(WOLFSSL_CTX* ctx, CbOCSPIO ioCb, CbOCSPRespFree respFreeCb, void* ioCbCtx) { - CYASSL_ENTER("CyaSSL_CTX_SetOCSP_Cb"); + WOLFSSL_ENTER("wolfSSL_CTX_SetOCSP_Cb"); if (ctx) - return CyaSSL_CertManagerSetOCSP_Cb(ctx->cm, ioCb, respFreeCb, ioCbCtx); + return wolfSSL_CertManagerSetOCSP_Cb(ctx->cm, ioCb, respFreeCb, ioCbCtx); else return BAD_FUNC_ARG; } @@ -2958,19 +2958,19 @@ int CyaSSL_CTX_SetOCSP_Cb(CYASSL_CTX* ctx, #ifndef NO_FILESYSTEM - #if defined(CYASSL_MDK_ARM) - extern FILE * CyaSSL_fopen(const char *name, const char *mode) ; - #define XFOPEN CyaSSL_fopen + #if defined(WOLFSSL_MDK_ARM) + extern FILE * wolfSSL_fopen(const char *name, const char *mode) ; + #define XFOPEN wolfSSL_fopen #else #define XFOPEN fopen #endif /* process a file with name fname into ctx of format and type userChain specifies a user certificate chain to pass during handshake */ -int ProcessFile(CYASSL_CTX* ctx, const char* fname, int format, int type, - CYASSL* ssl, int userChain, CYASSL_CRL* crl) +int ProcessFile(WOLFSSL_CTX* ctx, const char* fname, int format, int type, + WOLFSSL* ssl, int userChain, WOLFSSL_CRL* crl) { -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK byte staticBuffer[1]; /* force heap usage */ #else byte staticBuffer[FILE_BUFFER_SIZE]; @@ -2994,7 +2994,7 @@ int ProcessFile(CYASSL_CTX* ctx, const char* fname, int format, int type, XREWIND(file); if (sz > (long)sizeof(staticBuffer)) { - CYASSL_MSG("Getting dynamic buffer"); + WOLFSSL_MSG("Getting dynamic buffer"); myBuffer = (byte*)XMALLOC(sz, heapHint, DYNAMIC_TYPE_FILE); if (myBuffer == NULL) { XFCLOSE(file); @@ -3030,12 +3030,12 @@ int ProcessFile(CYASSL_CTX* ctx, const char* fname, int format, int type, /* loads file then loads each file in path, no c_rehash */ -int CyaSSL_CTX_load_verify_locations(CYASSL_CTX* ctx, const char* file, +int wolfSSL_CTX_load_verify_locations(WOLFSSL_CTX* ctx, const char* file, const char* path) { int ret = SSL_SUCCESS; - CYASSL_ENTER("CyaSSL_CTX_load_verify_locations"); + WOLFSSL_ENTER("wolfSSL_CTX_load_verify_locations"); (void)path; if (ctx == NULL || (file == NULL && path == NULL) ) @@ -3049,13 +3049,13 @@ int CyaSSL_CTX_load_verify_locations(CYASSL_CTX* ctx, const char* file, #ifdef USE_WINDOWS_API WIN32_FIND_DATAA FindFileData; HANDLE hFind; - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK char* name = NULL; #else char name[MAX_FILENAME_SZ]; #endif - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK name = (char*)XMALLOC(MAX_FILENAME_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (name == NULL) return MEMORY_E; @@ -3067,8 +3067,8 @@ int CyaSSL_CTX_load_verify_locations(CYASSL_CTX* ctx, const char* file, hFind = FindFirstFileA(name, &FindFileData); if (hFind == INVALID_HANDLE_VALUE) { - CYASSL_MSG("FindFirstFile for path verify locations failed"); - #ifdef CYASSL_SMALL_STACK + WOLFSSL_MSG("FindFirstFile for path verify locations failed"); + #ifdef WOLFSSL_SMALL_STACK XFREE(name, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return BAD_PATH_ERROR; @@ -3085,26 +3085,26 @@ int CyaSSL_CTX_load_verify_locations(CYASSL_CTX* ctx, const char* file, } } while (ret == SSL_SUCCESS && FindNextFileA(hFind, &FindFileData)); - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(name, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif FindClose(hFind); - #elif !defined(NO_CYASSL_DIR) + #elif !defined(NO_WOLFSSL_DIR) struct dirent* entry; DIR* dir = opendir(path); - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK char* name = NULL; #else char name[MAX_FILENAME_SZ]; #endif if (dir == NULL) { - CYASSL_MSG("opendir path verify locations failed"); + WOLFSSL_MSG("opendir path verify locations failed"); return BAD_PATH_ERROR; } - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK name = (char*)XMALLOC(MAX_FILENAME_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (name == NULL) return MEMORY_E; @@ -3119,14 +3119,14 @@ int CyaSSL_CTX_load_verify_locations(CYASSL_CTX* ctx, const char* file, XSTRNCAT(name, entry->d_name, MAX_FILENAME_SZ/2); if (stat(name, &s) != 0) { - CYASSL_MSG("stat on name failed"); + WOLFSSL_MSG("stat on name failed"); ret = BAD_PATH_ERROR; } else if (s.st_mode & S_IFREG) ret = ProcessFile(ctx, name, SSL_FILETYPE_PEM, CA_TYPE, NULL,0, NULL); } - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(name, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -3139,11 +3139,11 @@ int CyaSSL_CTX_load_verify_locations(CYASSL_CTX* ctx, const char* file, /* Verify the ceritficate, SSL_SUCCESS for ok, < 0 for error */ -int CyaSSL_CertManagerVerify(CYASSL_CERT_MANAGER* cm, const char* fname, +int wolfSSL_CertManagerVerify(WOLFSSL_CERT_MANAGER* cm, const char* fname, int format) { int ret = SSL_FATAL_ERROR; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK byte staticBuffer[1]; /* force heap usage */ #else byte staticBuffer[FILE_BUFFER_SIZE]; @@ -3153,21 +3153,21 @@ int CyaSSL_CertManagerVerify(CYASSL_CERT_MANAGER* cm, const char* fname, long sz = 0; XFILE file = XFOPEN(fname, "rb"); - CYASSL_ENTER("CyaSSL_CertManagerVerify"); + WOLFSSL_ENTER("wolfSSL_CertManagerVerify"); if (file == XBADFILE) return SSL_BAD_FILE; XFSEEK(file, 0, XSEEK_END); sz = XFTELL(file); XREWIND(file); - if (sz > MAX_CYASSL_FILE_SIZE || sz < 0) { - CYASSL_MSG("CertManagerVerify file bad size"); + if (sz > MAX_WOLFSSL_FILE_SIZE || sz < 0) { + WOLFSSL_MSG("CertManagerVerify file bad size"); XFCLOSE(file); return SSL_BAD_FILE; } if (sz > (long)sizeof(staticBuffer)) { - CYASSL_MSG("Getting dynamic buffer"); + WOLFSSL_MSG("Getting dynamic buffer"); myBuffer = (byte*) XMALLOC(sz, cm->heap, DYNAMIC_TYPE_FILE); if (myBuffer == NULL) { XFCLOSE(file); @@ -3179,7 +3179,7 @@ int CyaSSL_CertManagerVerify(CYASSL_CERT_MANAGER* cm, const char* fname, if ( (ret = (int)XFREAD(myBuffer, sz, 1, file)) < 0) ret = SSL_BAD_FILE; else - ret = CyaSSL_CertManagerVerifyBuffer(cm, myBuffer, sz, format); + ret = wolfSSL_CertManagerVerifyBuffer(cm, myBuffer, sz, format); XFCLOSE(file); if (dynamic) @@ -3189,17 +3189,17 @@ int CyaSSL_CertManagerVerify(CYASSL_CERT_MANAGER* cm, const char* fname, } -static INLINE CYASSL_METHOD* cm_pick_method(void) +static INLINE WOLFSSL_METHOD* cm_pick_method(void) { - #ifndef NO_CYASSL_CLIENT + #ifndef NO_WOLFSSL_CLIENT #ifdef NO_OLD_TLS - return CyaTLSv1_2_client_method(); + return wolfTLSv1_2_client_method(); #else return wolfSSLv3_client_method(); #endif - #elif !defined(NO_CYASSL_SERVER) + #elif !defined(NO_WOLFSSL_SERVER) #ifdef NO_OLD_TLS - return CyaTLSv1_2_server_method(); + return wolfTLSv1_2_server_method(); #else return wolfSSLv3_server_method(); #endif @@ -3210,34 +3210,34 @@ static INLINE CYASSL_METHOD* cm_pick_method(void) /* like load verify locations, 1 for success, < 0 for error */ -int CyaSSL_CertManagerLoadCA(CYASSL_CERT_MANAGER* cm, const char* file, +int wolfSSL_CertManagerLoadCA(WOLFSSL_CERT_MANAGER* cm, const char* file, const char* path) { int ret = SSL_FATAL_ERROR; - CYASSL_CTX* tmp; + WOLFSSL_CTX* tmp; - CYASSL_ENTER("CyaSSL_CertManagerLoadCA"); + WOLFSSL_ENTER("wolfSSL_CertManagerLoadCA"); if (cm == NULL) { - CYASSL_MSG("No CertManager error"); + WOLFSSL_MSG("No CertManager error"); return ret; } - tmp = CyaSSL_CTX_new(cm_pick_method()); + tmp = wolfSSL_CTX_new(cm_pick_method()); if (tmp == NULL) { - CYASSL_MSG("CTX new failed"); + WOLFSSL_MSG("CTX new failed"); return ret; } /* for tmp use */ - CyaSSL_CertManagerFree(tmp->cm); + wolfSSL_CertManagerFree(tmp->cm); tmp->cm = cm; - ret = CyaSSL_CTX_load_verify_locations(tmp, file, path); + ret = wolfSSL_CTX_load_verify_locations(tmp, file, path); /* don't loose our good one */ tmp->cm = NULL; - CyaSSL_CTX_free(tmp); + wolfSSL_CTX_free(tmp); return ret; } @@ -3245,32 +3245,32 @@ int CyaSSL_CertManagerLoadCA(CYASSL_CERT_MANAGER* cm, const char* file, /* turn on CRL if off and compiled in, set options */ -int CyaSSL_CertManagerEnableCRL(CYASSL_CERT_MANAGER* cm, int options) +int wolfSSL_CertManagerEnableCRL(WOLFSSL_CERT_MANAGER* cm, int options) { int ret = SSL_SUCCESS; (void)options; - CYASSL_ENTER("CyaSSL_CertManagerEnableCRL"); + WOLFSSL_ENTER("wolfSSL_CertManagerEnableCRL"); if (cm == NULL) return BAD_FUNC_ARG; #ifdef HAVE_CRL if (cm->crl == NULL) { - cm->crl = (CYASSL_CRL*)XMALLOC(sizeof(CYASSL_CRL), cm->heap, + cm->crl = (WOLFSSL_CRL*)XMALLOC(sizeof(WOLFSSL_CRL), cm->heap, DYNAMIC_TYPE_CRL); if (cm->crl == NULL) return MEMORY_E; if (InitCRL(cm->crl, cm) != 0) { - CYASSL_MSG("Init CRL failed"); + WOLFSSL_MSG("Init CRL failed"); FreeCRL(cm->crl, 1); cm->crl = NULL; return SSL_FAILURE; } } cm->crlEnabled = 1; - if (options & CYASSL_CRL_CHECKALL) + if (options & WOLFSSL_CRL_CHECKALL) cm->crlCheckAll = 1; #else ret = NOT_COMPILED_IN; @@ -3280,9 +3280,9 @@ int CyaSSL_CertManagerEnableCRL(CYASSL_CERT_MANAGER* cm, int options) } -int CyaSSL_CertManagerDisableCRL(CYASSL_CERT_MANAGER* cm) +int wolfSSL_CertManagerDisableCRL(WOLFSSL_CERT_MANAGER* cm) { - CYASSL_ENTER("CyaSSL_CertManagerDisableCRL"); + WOLFSSL_ENTER("wolfSSL_CertManagerDisableCRL"); if (cm == NULL) return BAD_FUNC_ARG; @@ -3292,11 +3292,11 @@ int CyaSSL_CertManagerDisableCRL(CYASSL_CERT_MANAGER* cm) } -int CyaSSL_CTX_check_private_key(CYASSL_CTX* ctx) +int wolfSSL_CTX_check_private_key(WOLFSSL_CTX* ctx) { /* TODO: check private against public for RSA match */ (void)ctx; - CYASSL_ENTER("SSL_CTX_check_private_key"); + WOLFSSL_ENTER("SSL_CTX_check_private_key"); return SSL_SUCCESS; } @@ -3305,16 +3305,16 @@ int CyaSSL_CTX_check_private_key(CYASSL_CTX* ctx) /* check CRL if enabled, SSL_SUCCESS */ -int CyaSSL_CertManagerCheckCRL(CYASSL_CERT_MANAGER* cm, byte* der, int sz) +int wolfSSL_CertManagerCheckCRL(WOLFSSL_CERT_MANAGER* cm, byte* der, int sz) { int ret = 0; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK DecodedCert* cert = NULL; #else DecodedCert cert[1]; #endif - CYASSL_ENTER("CyaSSL_CertManagerCheckCRL"); + WOLFSSL_ENTER("wolfSSL_CertManagerCheckCRL"); if (cm == NULL) return BAD_FUNC_ARG; @@ -3322,7 +3322,7 @@ int CyaSSL_CertManagerCheckCRL(CYASSL_CERT_MANAGER* cm, byte* der, int sz) if (cm->crlEnabled == 0) return SSL_SUCCESS; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK cert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (cert == NULL) @@ -3332,14 +3332,14 @@ int CyaSSL_CertManagerCheckCRL(CYASSL_CERT_MANAGER* cm, byte* der, int sz) InitDecodedCert(cert, der, sz, NULL); if ((ret = ParseCertRelative(cert, CERT_TYPE, NO_VERIFY, cm)) != 0) { - CYASSL_MSG("ParseCert failed"); + WOLFSSL_MSG("ParseCert failed"); } else if ((ret = CheckCertCRL(cm->crl, cert)) != 0) { - CYASSL_MSG("CheckCertCRL failed"); + WOLFSSL_MSG("CheckCertCRL failed"); } FreeDecodedCert(cert); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(cert, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -3347,9 +3347,9 @@ int CyaSSL_CertManagerCheckCRL(CYASSL_CERT_MANAGER* cm, byte* der, int sz) } -int CyaSSL_CertManagerSetCRL_Cb(CYASSL_CERT_MANAGER* cm, CbMissingCRL cb) +int wolfSSL_CertManagerSetCRL_Cb(WOLFSSL_CERT_MANAGER* cm, CbMissingCRL cb) { - CYASSL_ENTER("CyaSSL_CertManagerSetCRL_Cb"); + WOLFSSL_ENTER("wolfSSL_CertManagerSetCRL_Cb"); if (cm == NULL) return BAD_FUNC_ARG; @@ -3359,16 +3359,16 @@ int CyaSSL_CertManagerSetCRL_Cb(CYASSL_CERT_MANAGER* cm, CbMissingCRL cb) } -int CyaSSL_CertManagerLoadCRL(CYASSL_CERT_MANAGER* cm, const char* path, +int wolfSSL_CertManagerLoadCRL(WOLFSSL_CERT_MANAGER* cm, const char* path, int type, int monitor) { - CYASSL_ENTER("CyaSSL_CertManagerLoadCRL"); + WOLFSSL_ENTER("wolfSSL_CertManagerLoadCRL"); if (cm == NULL) return BAD_FUNC_ARG; if (cm->crl == NULL) { - if (CyaSSL_CertManagerEnableCRL(cm, 0) != SSL_SUCCESS) { - CYASSL_MSG("Enable CRL failed"); + if (wolfSSL_CertManagerEnableCRL(cm, 0) != SSL_SUCCESS) { + WOLFSSL_MSG("Enable CRL failed"); return SSL_FATAL_ERROR; } } @@ -3377,81 +3377,81 @@ int CyaSSL_CertManagerLoadCRL(CYASSL_CERT_MANAGER* cm, const char* path, } -int CyaSSL_EnableCRL(CYASSL* ssl, int options) +int wolfSSL_EnableCRL(WOLFSSL* ssl, int options) { - CYASSL_ENTER("CyaSSL_EnableCRL"); + WOLFSSL_ENTER("wolfSSL_EnableCRL"); if (ssl) - return CyaSSL_CertManagerEnableCRL(ssl->ctx->cm, options); + return wolfSSL_CertManagerEnableCRL(ssl->ctx->cm, options); else return BAD_FUNC_ARG; } -int CyaSSL_DisableCRL(CYASSL* ssl) +int wolfSSL_DisableCRL(WOLFSSL* ssl) { - CYASSL_ENTER("CyaSSL_DisableCRL"); + WOLFSSL_ENTER("wolfSSL_DisableCRL"); if (ssl) - return CyaSSL_CertManagerDisableCRL(ssl->ctx->cm); + return wolfSSL_CertManagerDisableCRL(ssl->ctx->cm); else return BAD_FUNC_ARG; } -int CyaSSL_LoadCRL(CYASSL* ssl, const char* path, int type, int monitor) +int wolfSSL_LoadCRL(WOLFSSL* ssl, const char* path, int type, int monitor) { - CYASSL_ENTER("CyaSSL_LoadCRL"); + WOLFSSL_ENTER("wolfSSL_LoadCRL"); if (ssl) - return CyaSSL_CertManagerLoadCRL(ssl->ctx->cm, path, type, monitor); + return wolfSSL_CertManagerLoadCRL(ssl->ctx->cm, path, type, monitor); else return BAD_FUNC_ARG; } -int CyaSSL_SetCRL_Cb(CYASSL* ssl, CbMissingCRL cb) +int wolfSSL_SetCRL_Cb(WOLFSSL* ssl, CbMissingCRL cb) { - CYASSL_ENTER("CyaSSL_SetCRL_Cb"); + WOLFSSL_ENTER("wolfSSL_SetCRL_Cb"); if (ssl) - return CyaSSL_CertManagerSetCRL_Cb(ssl->ctx->cm, cb); + return wolfSSL_CertManagerSetCRL_Cb(ssl->ctx->cm, cb); else return BAD_FUNC_ARG; } -int CyaSSL_CTX_EnableCRL(CYASSL_CTX* ctx, int options) +int wolfSSL_CTX_EnableCRL(WOLFSSL_CTX* ctx, int options) { - CYASSL_ENTER("CyaSSL_CTX_EnableCRL"); + WOLFSSL_ENTER("wolfSSL_CTX_EnableCRL"); if (ctx) - return CyaSSL_CertManagerEnableCRL(ctx->cm, options); + return wolfSSL_CertManagerEnableCRL(ctx->cm, options); else return BAD_FUNC_ARG; } -int CyaSSL_CTX_DisableCRL(CYASSL_CTX* ctx) +int wolfSSL_CTX_DisableCRL(WOLFSSL_CTX* ctx) { - CYASSL_ENTER("CyaSSL_CTX_DisableCRL"); + WOLFSSL_ENTER("wolfSSL_CTX_DisableCRL"); if (ctx) - return CyaSSL_CertManagerDisableCRL(ctx->cm); + return wolfSSL_CertManagerDisableCRL(ctx->cm); else return BAD_FUNC_ARG; } -int CyaSSL_CTX_LoadCRL(CYASSL_CTX* ctx, const char* path, int type, int monitor) +int wolfSSL_CTX_LoadCRL(WOLFSSL_CTX* ctx, const char* path, int type, int monitor) { - CYASSL_ENTER("CyaSSL_CTX_LoadCRL"); + WOLFSSL_ENTER("wolfSSL_CTX_LoadCRL"); if (ctx) - return CyaSSL_CertManagerLoadCRL(ctx->cm, path, type, monitor); + return wolfSSL_CertManagerLoadCRL(ctx->cm, path, type, monitor); else return BAD_FUNC_ARG; } -int CyaSSL_CTX_SetCRL_Cb(CYASSL_CTX* ctx, CbMissingCRL cb) +int wolfSSL_CTX_SetCRL_Cb(WOLFSSL_CTX* ctx, CbMissingCRL cb) { - CYASSL_ENTER("CyaSSL_CTX_SetCRL_Cb"); + WOLFSSL_ENTER("wolfSSL_CTX_SetCRL_Cb"); if (ctx) - return CyaSSL_CertManagerSetCRL_Cb(ctx->cm, cb); + return wolfSSL_CertManagerSetCRL_Cb(ctx->cm, cb); else return BAD_FUNC_ARG; } @@ -3460,13 +3460,13 @@ int CyaSSL_CTX_SetCRL_Cb(CYASSL_CTX* ctx, CbMissingCRL cb) #endif /* HAVE_CRL */ -#ifdef CYASSL_DER_LOAD +#ifdef WOLFSSL_DER_LOAD /* Add format parameter to allow DER load of CA files */ -int CyaSSL_CTX_der_load_verify_locations(CYASSL_CTX* ctx, const char* file, +int wolfSSL_CTX_der_load_verify_locations(WOLFSSL_CTX* ctx, const char* file, int format) { - CYASSL_ENTER("CyaSSL_CTX_der_load_verify_locations"); + WOLFSSL_ENTER("wolfSSL_CTX_der_load_verify_locations"); if (ctx == NULL || file == NULL) return SSL_FAILURE; @@ -3476,15 +3476,15 @@ int CyaSSL_CTX_der_load_verify_locations(CYASSL_CTX* ctx, const char* file, return SSL_FAILURE; } -#endif /* CYASSL_DER_LOAD */ +#endif /* WOLFSSL_DER_LOAD */ -#ifdef CYASSL_CERT_GEN +#ifdef WOLFSSL_CERT_GEN /* load pem cert from file into der buffer, return der size or error */ -int CyaSSL_PemCertToDer(const char* fileName, unsigned char* derBuf, int derSz) +int wolfSSL_PemCertToDer(const char* fileName, unsigned char* derBuf, int derSz) { -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK EncryptedInfo* info = NULL; byte staticBuffer[1]; /* force XMALLOC */ #else @@ -3499,7 +3499,7 @@ int CyaSSL_PemCertToDer(const char* fileName, unsigned char* derBuf, int derSz) XFILE file = XFOPEN(fileName, "rb"); buffer converted; - CYASSL_ENTER("CyaSSL_PemCertToDer"); + WOLFSSL_ENTER("wolfSSL_PemCertToDer"); if (file == XBADFILE) ret = SSL_BAD_FILE; @@ -3525,7 +3525,7 @@ int CyaSSL_PemCertToDer(const char* fileName, unsigned char* derBuf, int derSz) if ( (ret = (int)XFREAD(fileBuf, sz, 1, file)) < 0) ret = SSL_BAD_FILE; else { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK info = (EncryptedInfo*)XMALLOC(sizeof(EncryptedInfo), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (info == NULL) @@ -3535,7 +3535,7 @@ int CyaSSL_PemCertToDer(const char* fileName, unsigned char* derBuf, int derSz) { ret = PemToDer(fileBuf, sz, CA_TYPE, &converted, 0, info, &ecc); - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif } @@ -3561,13 +3561,13 @@ int CyaSSL_PemCertToDer(const char* fileName, unsigned char* derBuf, int derSz) return ret; } -#endif /* CYASSL_CERT_GEN */ +#endif /* WOLFSSL_CERT_GEN */ -int CyaSSL_CTX_use_certificate_file(CYASSL_CTX* ctx, const char* file, +int wolfSSL_CTX_use_certificate_file(WOLFSSL_CTX* ctx, const char* file, int format) { - CYASSL_ENTER("CyaSSL_CTX_use_certificate_file"); + WOLFSSL_ENTER("wolfSSL_CTX_use_certificate_file"); if (ProcessFile(ctx, file, format, CERT_TYPE, NULL, 0, NULL) == SSL_SUCCESS) return SSL_SUCCESS; @@ -3575,9 +3575,9 @@ int CyaSSL_CTX_use_certificate_file(CYASSL_CTX* ctx, const char* file, } -int CyaSSL_CTX_use_PrivateKey_file(CYASSL_CTX* ctx, const char* file,int format) +int wolfSSL_CTX_use_PrivateKey_file(WOLFSSL_CTX* ctx, const char* file,int format) { - CYASSL_ENTER("CyaSSL_CTX_use_PrivateKey_file"); + WOLFSSL_ENTER("wolfSSL_CTX_use_PrivateKey_file"); if (ProcessFile(ctx, file, format, PRIVATEKEY_TYPE, NULL, 0, NULL) == SSL_SUCCESS) return SSL_SUCCESS; @@ -3586,10 +3586,10 @@ int CyaSSL_CTX_use_PrivateKey_file(CYASSL_CTX* ctx, const char* file,int format) } -int CyaSSL_CTX_use_certificate_chain_file(CYASSL_CTX* ctx, const char* file) +int wolfSSL_CTX_use_certificate_chain_file(WOLFSSL_CTX* ctx, const char* file) { /* procces up to MAX_CHAIN_DEPTH plus subject cert */ - CYASSL_ENTER("CyaSSL_CTX_use_certificate_chain_file"); + WOLFSSL_ENTER("wolfSSL_CTX_use_certificate_chain_file"); if (ProcessFile(ctx, file, SSL_FILETYPE_PEM,CERT_TYPE,NULL,1, NULL) == SSL_SUCCESS) return SSL_SUCCESS; @@ -3601,7 +3601,7 @@ int CyaSSL_CTX_use_certificate_chain_file(CYASSL_CTX* ctx, const char* file) #ifndef NO_DH /* server wrapper for ctx or ssl Diffie-Hellman parameters */ -static int CyaSSL_SetTmpDH_buffer_wrapper(CYASSL_CTX* ctx, CYASSL* ssl, +static int wolfSSL_SetTmpDH_buffer_wrapper(WOLFSSL_CTX* ctx, WOLFSSL* ssl, const unsigned char* buf, long sz, int format) { buffer der; @@ -3609,7 +3609,7 @@ static int CyaSSL_SetTmpDH_buffer_wrapper(CYASSL_CTX* ctx, CYASSL* ssl, int weOwnDer = 0; word32 pSz = MAX_DH_SIZE; word32 gSz = MAX_DH_SIZE; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK byte* p = NULL; byte* g = NULL; #else @@ -3620,7 +3620,7 @@ static int CyaSSL_SetTmpDH_buffer_wrapper(CYASSL_CTX* ctx, CYASSL* ssl, der.buffer = (byte*)buf; der.length = (word32)sz; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK p = (byte*)XMALLOC(pSz, NULL, DYNAMIC_TYPE_TMP_BUFFER); g = (byte*)XMALLOC(gSz, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -3644,16 +3644,16 @@ static int CyaSSL_SetTmpDH_buffer_wrapper(CYASSL_CTX* ctx, CYASSL* ssl, if (DhParamsLoad(der.buffer, der.length, p, &pSz, g, &gSz) < 0) ret = SSL_BAD_FILETYPE; else if (ssl) - ret = CyaSSL_SetTmpDH(ssl, p, pSz, g, gSz); + ret = wolfSSL_SetTmpDH(ssl, p, pSz, g, gSz); else - ret = CyaSSL_CTX_SetTmpDH(ctx, p, pSz, g, gSz); + ret = wolfSSL_CTX_SetTmpDH(ctx, p, pSz, g, gSz); } } if (weOwnDer) XFREE(der.buffer, ctx->heap, DYNAMIC_TYPE_KEY); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(p, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(g, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -3663,26 +3663,26 @@ static int CyaSSL_SetTmpDH_buffer_wrapper(CYASSL_CTX* ctx, CYASSL* ssl, /* server Diffie-Hellman parameters, SSL_SUCCESS on ok */ -int CyaSSL_SetTmpDH_buffer(CYASSL* ssl, const unsigned char* buf, long sz, +int wolfSSL_SetTmpDH_buffer(WOLFSSL* ssl, const unsigned char* buf, long sz, int format) { - return CyaSSL_SetTmpDH_buffer_wrapper(ssl->ctx, ssl, buf, sz, format); + return wolfSSL_SetTmpDH_buffer_wrapper(ssl->ctx, ssl, buf, sz, format); } /* server ctx Diffie-Hellman parameters, SSL_SUCCESS on ok */ -int CyaSSL_CTX_SetTmpDH_buffer(CYASSL_CTX* ctx, const unsigned char* buf, +int wolfSSL_CTX_SetTmpDH_buffer(WOLFSSL_CTX* ctx, const unsigned char* buf, long sz, int format) { - return CyaSSL_SetTmpDH_buffer_wrapper(ctx, NULL, buf, sz, format); + return wolfSSL_SetTmpDH_buffer_wrapper(ctx, NULL, buf, sz, format); } /* server Diffie-Hellman parameters */ -static int CyaSSL_SetTmpDH_file_wrapper(CYASSL_CTX* ctx, CYASSL* ssl, +static int wolfSSL_SetTmpDH_file_wrapper(WOLFSSL_CTX* ctx, WOLFSSL* ssl, const char* fname, int format) { -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK byte staticBuffer[1]; /* force heap usage */ #else byte staticBuffer[FILE_BUFFER_SIZE]; @@ -3699,7 +3699,7 @@ static int CyaSSL_SetTmpDH_file_wrapper(CYASSL_CTX* ctx, CYASSL* ssl, XREWIND(file); if (sz > (long)sizeof(staticBuffer)) { - CYASSL_MSG("Getting dynamic buffer"); + WOLFSSL_MSG("Getting dynamic buffer"); myBuffer = (byte*) XMALLOC(sz, ctx->heap, DYNAMIC_TYPE_FILE); if (myBuffer == NULL) { XFCLOSE(file); @@ -3716,9 +3716,9 @@ static int CyaSSL_SetTmpDH_file_wrapper(CYASSL_CTX* ctx, CYASSL* ssl, ret = SSL_BAD_FILE; else { if (ssl) - ret = CyaSSL_SetTmpDH_buffer(ssl, myBuffer, sz, format); + ret = wolfSSL_SetTmpDH_buffer(ssl, myBuffer, sz, format); else - ret = CyaSSL_CTX_SetTmpDH_buffer(ctx, myBuffer, sz, format); + ret = wolfSSL_CTX_SetTmpDH_buffer(ctx, myBuffer, sz, format); } XFCLOSE(file); @@ -3729,24 +3729,24 @@ static int CyaSSL_SetTmpDH_file_wrapper(CYASSL_CTX* ctx, CYASSL* ssl, } /* server Diffie-Hellman parameters */ -int CyaSSL_SetTmpDH_file(CYASSL* ssl, const char* fname, int format) +int wolfSSL_SetTmpDH_file(WOLFSSL* ssl, const char* fname, int format) { - return CyaSSL_SetTmpDH_file_wrapper(ssl->ctx, ssl, fname, format); + return wolfSSL_SetTmpDH_file_wrapper(ssl->ctx, ssl, fname, format); } /* server Diffie-Hellman parameters */ -int CyaSSL_CTX_SetTmpDH_file(CYASSL_CTX* ctx, const char* fname, int format) +int wolfSSL_CTX_SetTmpDH_file(WOLFSSL_CTX* ctx, const char* fname, int format) { - return CyaSSL_SetTmpDH_file_wrapper(ctx, NULL, fname, format); + return wolfSSL_SetTmpDH_file_wrapper(ctx, NULL, fname, format); } /* server ctx Diffie-Hellman parameters, SSL_SUCCESS on ok */ - int CyaSSL_CTX_SetTmpDH(CYASSL_CTX* ctx, const unsigned char* p, int pSz, + int wolfSSL_CTX_SetTmpDH(WOLFSSL_CTX* ctx, const unsigned char* p, int pSz, const unsigned char* g, int gSz) { - CYASSL_ENTER("CyaSSL_CTX_SetTmpDH"); + WOLFSSL_ENTER("wolfSSL_CTX_SetTmpDH"); if (ctx == NULL || p == NULL || g == NULL) return BAD_FUNC_ARG; XFREE(ctx->serverDH_P.buffer, ctx->heap, DYNAMIC_TYPE_DH); @@ -3770,7 +3770,7 @@ int CyaSSL_CTX_SetTmpDH_file(CYASSL_CTX* ctx, const char* fname, int format) ctx->haveDH = 1; - CYASSL_LEAVE("CyaSSL_CTX_SetTmpDH", 0); + WOLFSSL_LEAVE("wolfSSL_CTX_SetTmpDH", 0); return SSL_SUCCESS; } #endif /* NO_DH */ @@ -3779,9 +3779,9 @@ int CyaSSL_CTX_SetTmpDH_file(CYASSL_CTX* ctx, const char* fname, int format) #ifdef OPENSSL_EXTRA /* put SSL type in extra for now, not very common */ -int CyaSSL_use_certificate_file(CYASSL* ssl, const char* file, int format) +int wolfSSL_use_certificate_file(WOLFSSL* ssl, const char* file, int format) { - CYASSL_ENTER("CyaSSL_use_certificate_file"); + WOLFSSL_ENTER("wolfSSL_use_certificate_file"); if (ProcessFile(ssl->ctx, file, format, CERT_TYPE, ssl, 0, NULL) == SSL_SUCCESS) return SSL_SUCCESS; @@ -3790,9 +3790,9 @@ int CyaSSL_use_certificate_file(CYASSL* ssl, const char* file, int format) } -int CyaSSL_use_PrivateKey_file(CYASSL* ssl, const char* file, int format) +int wolfSSL_use_PrivateKey_file(WOLFSSL* ssl, const char* file, int format) { - CYASSL_ENTER("CyaSSL_use_PrivateKey_file"); + WOLFSSL_ENTER("wolfSSL_use_PrivateKey_file"); if (ProcessFile(ssl->ctx, file, format, PRIVATEKEY_TYPE, ssl, 0, NULL) == SSL_SUCCESS) return SSL_SUCCESS; @@ -3801,10 +3801,10 @@ int CyaSSL_use_PrivateKey_file(CYASSL* ssl, const char* file, int format) } -int CyaSSL_use_certificate_chain_file(CYASSL* ssl, const char* file) +int wolfSSL_use_certificate_chain_file(WOLFSSL* ssl, const char* file) { /* procces up to MAX_CHAIN_DEPTH plus subject cert */ - CYASSL_ENTER("CyaSSL_use_certificate_chain_file"); + WOLFSSL_ENTER("wolfSSL_use_certificate_chain_file"); if (ProcessFile(ssl->ctx, file, SSL_FILETYPE_PEM, CERT_TYPE, ssl, 1, NULL) == SSL_SUCCESS) return SSL_SUCCESS; @@ -3817,7 +3817,7 @@ int CyaSSL_use_certificate_chain_file(CYASSL* ssl, const char* file) #ifdef HAVE_ECC /* Set Temp CTX EC-DHE size in octets, should be 20 - 66 for 160 - 521 bit */ -int CyaSSL_CTX_SetTmpEC_DHE_Sz(CYASSL_CTX* ctx, word16 sz) +int wolfSSL_CTX_SetTmpEC_DHE_Sz(WOLFSSL_CTX* ctx, word16 sz) { if (ctx == NULL || sz < ECC_MINSIZE || sz > ECC_MAXSIZE) return BAD_FUNC_ARG; @@ -3829,7 +3829,7 @@ int CyaSSL_CTX_SetTmpEC_DHE_Sz(CYASSL_CTX* ctx, word16 sz) /* Set Temp SSL EC-DHE size in octets, should be 20 - 66 for 160 - 521 bit */ -int CyaSSL_SetTmpEC_DHE_Sz(CYASSL* ssl, word16 sz) +int wolfSSL_SetTmpEC_DHE_Sz(WOLFSSL* ssl, word16 sz) { if (ssl == NULL || sz < ECC_MINSIZE || sz > ECC_MAXSIZE) return BAD_FUNC_ARG; @@ -3844,29 +3844,29 @@ int CyaSSL_SetTmpEC_DHE_Sz(CYASSL* ssl, word16 sz) -int CyaSSL_CTX_use_RSAPrivateKey_file(CYASSL_CTX* ctx,const char* file, +int wolfSSL_CTX_use_RSAPrivateKey_file(WOLFSSL_CTX* ctx,const char* file, int format) { - CYASSL_ENTER("SSL_CTX_use_RSAPrivateKey_file"); + WOLFSSL_ENTER("SSL_CTX_use_RSAPrivateKey_file"); - return CyaSSL_CTX_use_PrivateKey_file(ctx, file, format); + return wolfSSL_CTX_use_PrivateKey_file(ctx, file, format); } -int CyaSSL_use_RSAPrivateKey_file(CYASSL* ssl, const char* file, int format) +int wolfSSL_use_RSAPrivateKey_file(WOLFSSL* ssl, const char* file, int format) { - CYASSL_ENTER("CyaSSL_use_RSAPrivateKey_file"); + WOLFSSL_ENTER("wolfSSL_use_RSAPrivateKey_file"); - return CyaSSL_use_PrivateKey_file(ssl, file, format); + return wolfSSL_use_PrivateKey_file(ssl, file, format); } #endif /* OPENSSL_EXTRA */ #ifdef HAVE_NTRU -int CyaSSL_CTX_use_NTRUPrivateKey_file(CYASSL_CTX* ctx, const char* file) +int wolfSSL_CTX_use_NTRUPrivateKey_file(WOLFSSL_CTX* ctx, const char* file) { - CYASSL_ENTER("CyaSSL_CTX_use_NTRUPrivateKey_file"); + WOLFSSL_ENTER("wolfSSL_CTX_use_NTRUPrivateKey_file"); if (ctx == NULL) return SSL_FAILURE; @@ -3885,9 +3885,9 @@ int CyaSSL_CTX_use_NTRUPrivateKey_file(CYASSL_CTX* ctx, const char* file) #endif /* NO_FILESYSTEM */ -void CyaSSL_CTX_set_verify(CYASSL_CTX* ctx, int mode, VerifyCallback vc) +void wolfSSL_CTX_set_verify(WOLFSSL_CTX* ctx, int mode, VerifyCallback vc) { - CYASSL_ENTER("CyaSSL_CTX_set_verify"); + WOLFSSL_ENTER("wolfSSL_CTX_set_verify"); if (mode & SSL_VERIFY_PEER) { ctx->verifyPeer = 1; ctx->verifyNone = 0; /* in case perviously set */ @@ -3905,9 +3905,9 @@ void CyaSSL_CTX_set_verify(CYASSL_CTX* ctx, int mode, VerifyCallback vc) } -void CyaSSL_set_verify(CYASSL* ssl, int mode, VerifyCallback vc) +void wolfSSL_set_verify(WOLFSSL* ssl, int mode, VerifyCallback vc) { - CYASSL_ENTER("CyaSSL_set_verify"); + WOLFSSL_ENTER("wolfSSL_set_verify"); if (mode & SSL_VERIFY_PEER) { ssl->options.verifyPeer = 1; ssl->options.verifyNone = 0; /* in case perviously set */ @@ -3926,16 +3926,16 @@ void CyaSSL_set_verify(CYASSL* ssl, int mode, VerifyCallback vc) /* store user ctx for verify callback */ -void CyaSSL_SetCertCbCtx(CYASSL* ssl, void* ctx) +void wolfSSL_SetCertCbCtx(WOLFSSL* ssl, void* ctx) { - CYASSL_ENTER("CyaSSL_SetCertCbCtx"); + WOLFSSL_ENTER("wolfSSL_SetCertCbCtx"); if (ssl) ssl->verifyCbCtx = ctx; } /* store context CA Cache addition callback */ -void CyaSSL_CTX_SetCACb(CYASSL_CTX* ctx, CallbackCACache cb) +void wolfSSL_CTX_SetCACb(WOLFSSL_CTX* ctx, CallbackCACache cb) { if (ctx && ctx->cm) ctx->cm->caCacheCallback = cb; @@ -3947,9 +3947,9 @@ void CyaSSL_CTX_SetCACb(CYASSL_CTX* ctx, CallbackCACache cb) #if !defined(NO_FILESYSTEM) /* Persist cert cache to file */ -int CyaSSL_CTX_save_cert_cache(CYASSL_CTX* ctx, const char* fname) +int wolfSSL_CTX_save_cert_cache(WOLFSSL_CTX* ctx, const char* fname) { - CYASSL_ENTER("CyaSSL_CTX_save_cert_cache"); + WOLFSSL_ENTER("wolfSSL_CTX_save_cert_cache"); if (ctx == NULL || fname == NULL) return BAD_FUNC_ARG; @@ -3959,9 +3959,9 @@ int CyaSSL_CTX_save_cert_cache(CYASSL_CTX* ctx, const char* fname) /* Persist cert cache from file */ -int CyaSSL_CTX_restore_cert_cache(CYASSL_CTX* ctx, const char* fname) +int wolfSSL_CTX_restore_cert_cache(WOLFSSL_CTX* ctx, const char* fname) { - CYASSL_ENTER("CyaSSL_CTX_restore_cert_cache"); + WOLFSSL_ENTER("wolfSSL_CTX_restore_cert_cache"); if (ctx == NULL || fname == NULL) return BAD_FUNC_ARG; @@ -3972,9 +3972,9 @@ int CyaSSL_CTX_restore_cert_cache(CYASSL_CTX* ctx, const char* fname) #endif /* NO_FILESYSTEM */ /* Persist cert cache to memory */ -int CyaSSL_CTX_memsave_cert_cache(CYASSL_CTX* ctx, void* mem, int sz, int* used) +int wolfSSL_CTX_memsave_cert_cache(WOLFSSL_CTX* ctx, void* mem, int sz, int* used) { - CYASSL_ENTER("CyaSSL_CTX_memsave_cert_cache"); + WOLFSSL_ENTER("wolfSSL_CTX_memsave_cert_cache"); if (ctx == NULL || mem == NULL || used == NULL || sz <= 0) return BAD_FUNC_ARG; @@ -3984,9 +3984,9 @@ int CyaSSL_CTX_memsave_cert_cache(CYASSL_CTX* ctx, void* mem, int sz, int* used) /* Restore cert cache from memory */ -int CyaSSL_CTX_memrestore_cert_cache(CYASSL_CTX* ctx, const void* mem, int sz) +int wolfSSL_CTX_memrestore_cert_cache(WOLFSSL_CTX* ctx, const void* mem, int sz) { - CYASSL_ENTER("CyaSSL_CTX_memrestore_cert_cache"); + WOLFSSL_ENTER("wolfSSL_CTX_memrestore_cert_cache"); if (ctx == NULL || mem == NULL || sz <= 0) return BAD_FUNC_ARG; @@ -3996,9 +3996,9 @@ int CyaSSL_CTX_memrestore_cert_cache(CYASSL_CTX* ctx, const void* mem, int sz) /* get how big the the cert cache save buffer needs to be */ -int CyaSSL_CTX_get_cert_cache_memsize(CYASSL_CTX* ctx) +int wolfSSL_CTX_get_cert_cache_memsize(WOLFSSL_CTX* ctx) { - CYASSL_ENTER("CyaSSL_CTX_get_cert_cache_memsize"); + WOLFSSL_ENTER("wolfSSL_CTX_get_cert_cache_memsize"); if (ctx == NULL) return BAD_FUNC_ARG; @@ -4012,9 +4012,9 @@ int CyaSSL_CTX_get_cert_cache_memsize(CYASSL_CTX* ctx) #ifndef NO_SESSION_CACHE -CYASSL_SESSION* CyaSSL_get_session(CYASSL* ssl) +WOLFSSL_SESSION* wolfSSL_get_session(WOLFSSL* ssl) { - CYASSL_ENTER("SSL_get_session"); + WOLFSSL_ENTER("SSL_get_session"); if (ssl) return GetSession(ssl, 0); @@ -4022,9 +4022,9 @@ CYASSL_SESSION* CyaSSL_get_session(CYASSL* ssl) } -int CyaSSL_set_session(CYASSL* ssl, CYASSL_SESSION* session) +int wolfSSL_set_session(WOLFSSL* ssl, WOLFSSL_SESSION* session) { - CYASSL_ENTER("SSL_set_session"); + WOLFSSL_ENTER("SSL_set_session"); if (session) return SetSession(ssl, session); @@ -4037,11 +4037,11 @@ int CyaSSL_set_session(CYASSL* ssl, CYASSL_SESSION* session) /* Associate client session with serverID, find existing or store for saving if newSession flag on, don't reuse existing session SSL_SUCCESS on ok */ -int CyaSSL_SetServerID(CYASSL* ssl, const byte* id, int len, int newSession) +int wolfSSL_SetServerID(WOLFSSL* ssl, const byte* id, int len, int newSession) { - CYASSL_SESSION* session = NULL; + WOLFSSL_SESSION* session = NULL; - CYASSL_ENTER("CyaSSL_SetServerID"); + WOLFSSL_ENTER("wolfSSL_SetServerID"); if (ssl == NULL || id == NULL || len <= 0) return BAD_FUNC_ARG; @@ -4050,14 +4050,14 @@ int CyaSSL_SetServerID(CYASSL* ssl, const byte* id, int len, int newSession) session = GetSessionClient(ssl, id, len); if (session) { if (SetSession(ssl, session) != SSL_SUCCESS) { - CYASSL_MSG("SetSession failed"); + WOLFSSL_MSG("SetSession failed"); session = NULL; } } } if (session == NULL) { - CYASSL_MSG("Valid ServerID not cached already"); + WOLFSSL_MSG("Valid ServerID not cached already"); ssl->session.idLen = (word16)min(SERVER_ID_LEN, (word32)len); XMEMCPY(ssl->session.serverID, id, ssl->session.idLen); @@ -4072,14 +4072,14 @@ int CyaSSL_SetServerID(CYASSL* ssl, const byte* id, int len, int newSession) /* for persistance, if changes to layout need to increment and modify save_session_cache() and restore_session_cache and memory versions too */ -#define CYASSL_CACHE_VERSION 2 +#define WOLFSSL_CACHE_VERSION 2 /* Session Cache Header information */ typedef struct { int version; /* cache layout version id */ int rows; /* session rows */ int columns; /* session columns */ - int sessionSz; /* sizeof CYASSL_SESSION */ + int sessionSz; /* sizeof WOLFSSL_SESSION */ } cache_header_t; /* current persistence layout is: @@ -4088,13 +4088,13 @@ typedef struct { 2) SessionCache 3) ClientCache - update CYASSL_CACHE_VERSION if change layout for the following + update WOLFSSL_CACHE_VERSION if change layout for the following PERSISTENT_SESSION_CACHE functions */ /* get how big the the session cache save buffer needs to be */ -int CyaSSL_get_session_cache_memsize(void) +int wolfSSL_get_session_cache_memsize(void) { int sz = (int)(sizeof(SessionCache) + sizeof(cache_header_t)); @@ -4107,7 +4107,7 @@ int CyaSSL_get_session_cache_memsize(void) /* Persist session cache to memory */ -int CyaSSL_memsave_session_cache(void* mem, int sz) +int wolfSSL_memsave_session_cache(void* mem, int sz) { int i; cache_header_t cache_header; @@ -4116,21 +4116,21 @@ int CyaSSL_memsave_session_cache(void* mem, int sz) ClientRow* clRow; #endif - CYASSL_ENTER("CyaSSL_memsave_session_cache"); + WOLFSSL_ENTER("wolfSSL_memsave_session_cache"); - if (sz < CyaSSL_get_session_cache_memsize()) { - CYASSL_MSG("Memory buffer too small"); + if (sz < wolfSSL_get_session_cache_memsize()) { + WOLFSSL_MSG("Memory buffer too small"); return BUFFER_E; } - cache_header.version = CYASSL_CACHE_VERSION; + cache_header.version = WOLFSSL_CACHE_VERSION; cache_header.rows = SESSION_ROWS; cache_header.columns = SESSIONS_PER_ROW; - cache_header.sessionSz = (int)sizeof(CYASSL_SESSION); + cache_header.sessionSz = (int)sizeof(WOLFSSL_SESSION); XMEMCPY(mem, &cache_header, sizeof(cache_header)); if (LockMutex(&session_mutex) != 0) { - CYASSL_MSG("Session cache mutex lock failed"); + WOLFSSL_MSG("Session cache mutex lock failed"); return BAD_MUTEX_E; } @@ -4145,14 +4145,14 @@ int CyaSSL_memsave_session_cache(void* mem, int sz) UnLockMutex(&session_mutex); - CYASSL_LEAVE("CyaSSL_memsave_session_cache", SSL_SUCCESS); + WOLFSSL_LEAVE("wolfSSL_memsave_session_cache", SSL_SUCCESS); return SSL_SUCCESS; } /* Restore the persistant session cache from memory */ -int CyaSSL_memrestore_session_cache(const void* mem, int sz) +int wolfSSL_memrestore_session_cache(const void* mem, int sz) { int i; cache_header_t cache_header; @@ -4161,25 +4161,25 @@ int CyaSSL_memrestore_session_cache(const void* mem, int sz) ClientRow* clRow; #endif - CYASSL_ENTER("CyaSSL_memrestore_session_cache"); + WOLFSSL_ENTER("wolfSSL_memrestore_session_cache"); - if (sz < CyaSSL_get_session_cache_memsize()) { - CYASSL_MSG("Memory buffer too small"); + if (sz < wolfSSL_get_session_cache_memsize()) { + WOLFSSL_MSG("Memory buffer too small"); return BUFFER_E; } XMEMCPY(&cache_header, mem, sizeof(cache_header)); - if (cache_header.version != CYASSL_CACHE_VERSION || + if (cache_header.version != WOLFSSL_CACHE_VERSION || cache_header.rows != SESSION_ROWS || cache_header.columns != SESSIONS_PER_ROW || - cache_header.sessionSz != (int)sizeof(CYASSL_SESSION)) { + cache_header.sessionSz != (int)sizeof(WOLFSSL_SESSION)) { - CYASSL_MSG("Session cache header match failed"); + WOLFSSL_MSG("Session cache header match failed"); return CACHE_MATCH_ERROR; } if (LockMutex(&session_mutex) != 0) { - CYASSL_MSG("Session cache mutex lock failed"); + WOLFSSL_MSG("Session cache mutex lock failed"); return BAD_MUTEX_E; } @@ -4194,7 +4194,7 @@ int CyaSSL_memrestore_session_cache(const void* mem, int sz) UnLockMutex(&session_mutex); - CYASSL_LEAVE("CyaSSL_memrestore_session_cache", SSL_SUCCESS); + WOLFSSL_LEAVE("wolfSSL_memrestore_session_cache", SSL_SUCCESS); return SSL_SUCCESS; } @@ -4203,7 +4203,7 @@ int CyaSSL_memrestore_session_cache(const void* mem, int sz) /* Persist session cache to file */ /* doesn't use memsave because of additional memory use */ -int CyaSSL_save_session_cache(const char *fname) +int wolfSSL_save_session_cache(const char *fname) { XFILE file; int ret; @@ -4211,28 +4211,28 @@ int CyaSSL_save_session_cache(const char *fname) int i; cache_header_t cache_header; - CYASSL_ENTER("CyaSSL_save_session_cache"); + WOLFSSL_ENTER("wolfSSL_save_session_cache"); file = XFOPEN(fname, "w+b"); if (file == XBADFILE) { - CYASSL_MSG("Couldn't open session cache save file"); + WOLFSSL_MSG("Couldn't open session cache save file"); return SSL_BAD_FILE; } - cache_header.version = CYASSL_CACHE_VERSION; + cache_header.version = WOLFSSL_CACHE_VERSION; cache_header.rows = SESSION_ROWS; cache_header.columns = SESSIONS_PER_ROW; - cache_header.sessionSz = (int)sizeof(CYASSL_SESSION); + cache_header.sessionSz = (int)sizeof(WOLFSSL_SESSION); /* cache header */ ret = (int)XFWRITE(&cache_header, sizeof cache_header, 1, file); if (ret != 1) { - CYASSL_MSG("Session cache header file write failed"); + WOLFSSL_MSG("Session cache header file write failed"); XFCLOSE(file); return FWRITE_ERROR; } if (LockMutex(&session_mutex) != 0) { - CYASSL_MSG("Session cache mutex lock failed"); + WOLFSSL_MSG("Session cache mutex lock failed"); XFCLOSE(file); return BAD_MUTEX_E; } @@ -4241,7 +4241,7 @@ int CyaSSL_save_session_cache(const char *fname) for (i = 0; i < cache_header.rows; ++i) { ret = (int)XFWRITE(SessionCache + i, sizeof(SessionRow), 1, file); if (ret != 1) { - CYASSL_MSG("Session cache member file write failed"); + WOLFSSL_MSG("Session cache member file write failed"); rc = FWRITE_ERROR; break; } @@ -4252,7 +4252,7 @@ int CyaSSL_save_session_cache(const char *fname) for (i = 0; i < cache_header.rows; ++i) { ret = (int)XFWRITE(ClientCache + i, sizeof(ClientRow), 1, file); if (ret != 1) { - CYASSL_MSG("Client cache member file write failed"); + WOLFSSL_MSG("Client cache member file write failed"); rc = FWRITE_ERROR; break; } @@ -4262,7 +4262,7 @@ int CyaSSL_save_session_cache(const char *fname) UnLockMutex(&session_mutex); XFCLOSE(file); - CYASSL_LEAVE("CyaSSL_save_session_cache", rc); + WOLFSSL_LEAVE("wolfSSL_save_session_cache", rc); return rc; } @@ -4270,7 +4270,7 @@ int CyaSSL_save_session_cache(const char *fname) /* Restore the persistant session cache from file */ /* doesn't use memstore because of additional memory use */ -int CyaSSL_restore_session_cache(const char *fname) +int wolfSSL_restore_session_cache(const char *fname) { XFILE file; int rc = SSL_SUCCESS; @@ -4278,32 +4278,32 @@ int CyaSSL_restore_session_cache(const char *fname) int i; cache_header_t cache_header; - CYASSL_ENTER("CyaSSL_restore_session_cache"); + WOLFSSL_ENTER("wolfSSL_restore_session_cache"); file = XFOPEN(fname, "rb"); if (file == XBADFILE) { - CYASSL_MSG("Couldn't open session cache save file"); + WOLFSSL_MSG("Couldn't open session cache save file"); return SSL_BAD_FILE; } /* cache header */ ret = (int)XFREAD(&cache_header, sizeof cache_header, 1, file); if (ret != 1) { - CYASSL_MSG("Session cache header file read failed"); + WOLFSSL_MSG("Session cache header file read failed"); XFCLOSE(file); return FREAD_ERROR; } - if (cache_header.version != CYASSL_CACHE_VERSION || + if (cache_header.version != WOLFSSL_CACHE_VERSION || cache_header.rows != SESSION_ROWS || cache_header.columns != SESSIONS_PER_ROW || - cache_header.sessionSz != (int)sizeof(CYASSL_SESSION)) { + cache_header.sessionSz != (int)sizeof(WOLFSSL_SESSION)) { - CYASSL_MSG("Session cache header match failed"); + WOLFSSL_MSG("Session cache header match failed"); XFCLOSE(file); return CACHE_MATCH_ERROR; } if (LockMutex(&session_mutex) != 0) { - CYASSL_MSG("Session cache mutex lock failed"); + WOLFSSL_MSG("Session cache mutex lock failed"); XFCLOSE(file); return BAD_MUTEX_E; } @@ -4312,7 +4312,7 @@ int CyaSSL_restore_session_cache(const char *fname) for (i = 0; i < cache_header.rows; ++i) { ret = (int)XFREAD(SessionCache + i, sizeof(SessionRow), 1, file); if (ret != 1) { - CYASSL_MSG("Session cache member file read failed"); + WOLFSSL_MSG("Session cache member file read failed"); XMEMSET(SessionCache, 0, sizeof SessionCache); rc = FREAD_ERROR; break; @@ -4324,7 +4324,7 @@ int CyaSSL_restore_session_cache(const char *fname) for (i = 0; i < cache_header.rows; ++i) { ret = (int)XFREAD(ClientCache + i, sizeof(ClientRow), 1, file); if (ret != 1) { - CYASSL_MSG("Client cache member file read failed"); + WOLFSSL_MSG("Client cache member file read failed"); XMEMSET(ClientCache, 0, sizeof ClientCache); rc = FREAD_ERROR; break; @@ -4336,7 +4336,7 @@ int CyaSSL_restore_session_cache(const char *fname) UnLockMutex(&session_mutex); XFCLOSE(file); - CYASSL_LEAVE("CyaSSL_restore_session_cache", rc); + WOLFSSL_LEAVE("wolfSSL_restore_session_cache", rc); return rc; } @@ -4346,14 +4346,14 @@ int CyaSSL_restore_session_cache(const char *fname) #endif /* NO_SESSION_CACHE */ -void CyaSSL_load_error_strings(void) /* compatibility only */ +void wolfSSL_load_error_strings(void) /* compatibility only */ {} -int CyaSSL_library_init(void) +int wolfSSL_library_init(void) { - CYASSL_ENTER("SSL_library_init"); - if (CyaSSL_Init() == SSL_SUCCESS) + WOLFSSL_ENTER("SSL_library_init"); + if (wolfSSL_Init() == SSL_SUCCESS) return SSL_SUCCESS; else return SSL_FATAL_ERROR; @@ -4362,9 +4362,9 @@ int CyaSSL_library_init(void) #ifdef HAVE_SECRET_CALLBACK -int CyaSSL_set_session_secret_cb(CYASSL* ssl, SessionSecretCb cb, void* ctx) +int wolfSSL_set_session_secret_cb(WOLFSSL* ssl, SessionSecretCb cb, void* ctx) { - CYASSL_ENTER("CyaSSL_set_session_secret_cb"); + WOLFSSL_ENTER("wolfSSL_set_session_secret_cb"); if (ssl == NULL) return SSL_FATAL_ERROR; @@ -4383,9 +4383,9 @@ int CyaSSL_set_session_secret_cb(CYASSL* ssl, SessionSecretCb cb, void* ctx) #ifndef NO_SESSION_CACHE /* on by default if built in but allow user to turn off */ -long CyaSSL_CTX_set_session_cache_mode(CYASSL_CTX* ctx, long mode) +long wolfSSL_CTX_set_session_cache_mode(WOLFSSL_CTX* ctx, long mode) { - CYASSL_ENTER("SSL_CTX_set_session_cache_mode"); + WOLFSSL_ENTER("SSL_CTX_set_session_cache_mode"); if (mode == SSL_SESS_CACHE_OFF) ctx->sessionCacheOff = 1; @@ -4402,7 +4402,7 @@ long CyaSSL_CTX_set_session_cache_mode(CYASSL_CTX* ctx, long mode) #if defined(PERSIST_CERT_CACHE) -#define CYASSL_CACHE_CERT_VERSION 1 +#define WOLFSSL_CACHE_CERT_VERSION 1 typedef struct { int version; /* cache cert layout version id */ @@ -4416,7 +4416,7 @@ typedef struct { 1) CertCacheHeader 2) caTable - update CYASSL_CERT_CACHE_VERSION if change layout for the following + update WOLFSSL_CERT_CACHE_VERSION if change layout for the following PERSIST_CERT_CACHE functions */ @@ -4454,7 +4454,7 @@ static INLINE int GetCertCacheRowMemory(Signer* row) /* get the size of persist cert cache, have lock */ -static INLINE int GetCertCacheMemSize(CYASSL_CERT_MANAGER* cm) +static INLINE int GetCertCacheMemSize(WOLFSSL_CERT_MANAGER* cm) { int sz; int i; @@ -4469,7 +4469,7 @@ static INLINE int GetCertCacheMemSize(CYASSL_CERT_MANAGER* cm) /* Store cert cache header columns with number of items per list, have lock */ -static INLINE void SetCertHeaderColumns(CYASSL_CERT_MANAGER* cm, int* columns) +static INLINE void SetCertHeaderColumns(WOLFSSL_CERT_MANAGER* cm, int* columns) { int i; Signer* row; @@ -4489,13 +4489,13 @@ static INLINE void SetCertHeaderColumns(CYASSL_CERT_MANAGER* cm, int* columns) /* Restore whole cert row from memory, have lock, return bytes consumed, < 0 on error, have lock */ -static INLINE int RestoreCertRow(CYASSL_CERT_MANAGER* cm, byte* current, +static INLINE int RestoreCertRow(WOLFSSL_CERT_MANAGER* cm, byte* current, int row, int listSz, const byte* end) { int idx = 0; if (listSz < 0) { - CYASSL_MSG("Row header corrupted, negative value"); + WOLFSSL_MSG("Row header corrupted, negative value"); return PARSE_ERROR; } @@ -4509,7 +4509,7 @@ static INLINE int RestoreCertRow(CYASSL_CERT_MANAGER* cm, byte* current, #endif if (start + minSz > end) { - CYASSL_MSG("Would overread restore buffer"); + WOLFSSL_MSG("Would overread restore buffer"); return BUFFER_E; } signer = MakeSigner(cm->heap); @@ -4526,7 +4526,7 @@ static INLINE int RestoreCertRow(CYASSL_CERT_MANAGER* cm, byte* current, /* pulicKey */ if (start + minSz + signer->pubKeySize > end) { - CYASSL_MSG("Would overread restore buffer"); + WOLFSSL_MSG("Would overread restore buffer"); FreeSigner(signer, cm->heap); return BUFFER_E; } @@ -4546,7 +4546,7 @@ static INLINE int RestoreCertRow(CYASSL_CERT_MANAGER* cm, byte* current, /* name */ if (start + minSz + signer->pubKeySize + signer->nameLen > end) { - CYASSL_MSG("Would overread restore buffer"); + WOLFSSL_MSG("Would overread restore buffer"); FreeSigner(signer, cm->heap); return BUFFER_E; } @@ -4581,7 +4581,7 @@ static INLINE int RestoreCertRow(CYASSL_CERT_MANAGER* cm, byte* current, /* Store whole cert row into memory, have lock, return bytes added */ -static INLINE int StoreCertRow(CYASSL_CERT_MANAGER* cm, byte* current, int row) +static INLINE int StoreCertRow(WOLFSSL_CERT_MANAGER* cm, byte* current, int row) { int added = 0; Signer* list = cm->caTable[row]; @@ -4618,24 +4618,24 @@ static INLINE int StoreCertRow(CYASSL_CERT_MANAGER* cm, byte* current, int row) /* Persist cert cache to memory, have lock */ -static INLINE int DoMemSaveCertCache(CYASSL_CERT_MANAGER* cm, void* mem, int sz) +static INLINE int DoMemSaveCertCache(WOLFSSL_CERT_MANAGER* cm, void* mem, int sz) { int realSz; int ret = SSL_SUCCESS; int i; - CYASSL_ENTER("DoMemSaveCertCache"); + WOLFSSL_ENTER("DoMemSaveCertCache"); realSz = GetCertCacheMemSize(cm); if (realSz > sz) { - CYASSL_MSG("Mem output buffer too small"); + WOLFSSL_MSG("Mem output buffer too small"); ret = BUFFER_E; } else { byte* current; CertCacheHeader hdr; - hdr.version = CYASSL_CACHE_CERT_VERSION; + hdr.version = WOLFSSL_CACHE_CERT_VERSION; hdr.rows = CA_TABLE_SIZE; SetCertHeaderColumns(cm, hdr.columns); hdr.signerSz = (int)sizeof(Signer); @@ -4654,23 +4654,23 @@ static INLINE int DoMemSaveCertCache(CYASSL_CERT_MANAGER* cm, void* mem, int sz) #if !defined(NO_FILESYSTEM) /* Persist cert cache to file */ -int CM_SaveCertCache(CYASSL_CERT_MANAGER* cm, const char* fname) +int CM_SaveCertCache(WOLFSSL_CERT_MANAGER* cm, const char* fname) { XFILE file; int rc = SSL_SUCCESS; int memSz; byte* mem; - CYASSL_ENTER("CM_SaveCertCache"); + WOLFSSL_ENTER("CM_SaveCertCache"); file = XFOPEN(fname, "w+b"); if (file == XBADFILE) { - CYASSL_MSG("Couldn't open cert cache save file"); + WOLFSSL_MSG("Couldn't open cert cache save file"); return SSL_BAD_FILE; } if (LockMutex(&cm->caLock) != 0) { - CYASSL_MSG("LockMutex on caLock failed"); + WOLFSSL_MSG("LockMutex on caLock failed"); XFCLOSE(file); return BAD_MUTEX_E; } @@ -4678,14 +4678,14 @@ int CM_SaveCertCache(CYASSL_CERT_MANAGER* cm, const char* fname) memSz = GetCertCacheMemSize(cm); mem = (byte*)XMALLOC(memSz, cm->heap, DYNAMIC_TYPE_TMP_BUFFER); if (mem == NULL) { - CYASSL_MSG("Alloc for tmp buffer failed"); + WOLFSSL_MSG("Alloc for tmp buffer failed"); rc = MEMORY_E; } else { rc = DoMemSaveCertCache(cm, mem, memSz); if (rc == SSL_SUCCESS) { int ret = (int)XFWRITE(mem, memSz, 1, file); if (ret != 1) { - CYASSL_MSG("Cert cache file write failed"); + WOLFSSL_MSG("Cert cache file write failed"); rc = FWRITE_ERROR; } } @@ -4700,7 +4700,7 @@ int CM_SaveCertCache(CYASSL_CERT_MANAGER* cm, const char* fname) /* Restore cert cache from file */ -int CM_RestoreCertCache(CYASSL_CERT_MANAGER* cm, const char* fname) +int CM_RestoreCertCache(WOLFSSL_CERT_MANAGER* cm, const char* fname) { XFILE file; int rc = SSL_SUCCESS; @@ -4708,11 +4708,11 @@ int CM_RestoreCertCache(CYASSL_CERT_MANAGER* cm, const char* fname) int memSz; byte* mem; - CYASSL_ENTER("CM_RestoreCertCache"); + WOLFSSL_ENTER("CM_RestoreCertCache"); file = XFOPEN(fname, "rb"); if (file == XBADFILE) { - CYASSL_MSG("Couldn't open cert cache save file"); + WOLFSSL_MSG("Couldn't open cert cache save file"); return SSL_BAD_FILE; } @@ -4721,26 +4721,26 @@ int CM_RestoreCertCache(CYASSL_CERT_MANAGER* cm, const char* fname) XREWIND(file); if (memSz <= 0) { - CYASSL_MSG("Bad file size"); + WOLFSSL_MSG("Bad file size"); XFCLOSE(file); return SSL_BAD_FILE; } mem = (byte*)XMALLOC(memSz, cm->heap, DYNAMIC_TYPE_TMP_BUFFER); if (mem == NULL) { - CYASSL_MSG("Alloc for tmp buffer failed"); + WOLFSSL_MSG("Alloc for tmp buffer failed"); XFCLOSE(file); return MEMORY_E; } ret = (int)XFREAD(mem, memSz, 1, file); if (ret != 1) { - CYASSL_MSG("Cert file read error"); + WOLFSSL_MSG("Cert file read error"); rc = FREAD_ERROR; } else { rc = CM_MemRestoreCertCache(cm, mem, memSz); if (rc != SSL_SUCCESS) { - CYASSL_MSG("Mem restore cert cache failed"); + WOLFSSL_MSG("Mem restore cert cache failed"); } } @@ -4754,14 +4754,14 @@ int CM_RestoreCertCache(CYASSL_CERT_MANAGER* cm, const char* fname) /* Persist cert cache to memory */ -int CM_MemSaveCertCache(CYASSL_CERT_MANAGER* cm, void* mem, int sz, int* used) +int CM_MemSaveCertCache(WOLFSSL_CERT_MANAGER* cm, void* mem, int sz, int* used) { int ret = SSL_SUCCESS; - CYASSL_ENTER("CM_MemSaveCertCache"); + WOLFSSL_ENTER("CM_MemSaveCertCache"); if (LockMutex(&cm->caLock) != 0) { - CYASSL_MSG("LockMutex on caLock failed"); + WOLFSSL_MSG("LockMutex on caLock failed"); return BAD_MUTEX_E; } @@ -4776,7 +4776,7 @@ int CM_MemSaveCertCache(CYASSL_CERT_MANAGER* cm, void* mem, int sz, int* used) /* Restore cert cache from memory */ -int CM_MemRestoreCertCache(CYASSL_CERT_MANAGER* cm, const void* mem, int sz) +int CM_MemRestoreCertCache(WOLFSSL_CERT_MANAGER* cm, const void* mem, int sz) { int ret = SSL_SUCCESS; int i; @@ -4784,23 +4784,23 @@ int CM_MemRestoreCertCache(CYASSL_CERT_MANAGER* cm, const void* mem, int sz) byte* current = (byte*)mem + sizeof(CertCacheHeader); byte* end = (byte*)mem + sz; /* don't go over */ - CYASSL_ENTER("CM_MemRestoreCertCache"); + WOLFSSL_ENTER("CM_MemRestoreCertCache"); if (current > end) { - CYASSL_MSG("Cert Cache Memory buffer too small"); + WOLFSSL_MSG("Cert Cache Memory buffer too small"); return BUFFER_E; } - if (hdr->version != CYASSL_CACHE_CERT_VERSION || + if (hdr->version != WOLFSSL_CACHE_CERT_VERSION || hdr->rows != CA_TABLE_SIZE || hdr->signerSz != (int)sizeof(Signer)) { - CYASSL_MSG("Cert Cache Memory header mismatch"); + WOLFSSL_MSG("Cert Cache Memory header mismatch"); return CACHE_MATCH_ERROR; } if (LockMutex(&cm->caLock) != 0) { - CYASSL_MSG("LockMutex on caLock failed"); + WOLFSSL_MSG("LockMutex on caLock failed"); return BAD_MUTEX_E; } @@ -4809,7 +4809,7 @@ int CM_MemRestoreCertCache(CYASSL_CERT_MANAGER* cm, const void* mem, int sz) for (i = 0; i < CA_TABLE_SIZE; ++i) { int added = RestoreCertRow(cm, current, i, hdr->columns[i], end); if (added < 0) { - CYASSL_MSG("RestoreCertRow error"); + WOLFSSL_MSG("RestoreCertRow error"); ret = added; break; } @@ -4823,14 +4823,14 @@ int CM_MemRestoreCertCache(CYASSL_CERT_MANAGER* cm, const void* mem, int sz) /* get how big the the cert cache save buffer needs to be */ -int CM_GetCertCacheMemSize(CYASSL_CERT_MANAGER* cm) +int CM_GetCertCacheMemSize(WOLFSSL_CERT_MANAGER* cm) { int sz; - CYASSL_ENTER("CM_GetCertCacheMemSize"); + WOLFSSL_ENTER("CM_GetCertCacheMemSize"); if (LockMutex(&cm->caLock) != 0) { - CYASSL_MSG("LockMutex on caLock failed"); + WOLFSSL_MSG("LockMutex on caLock failed"); return BAD_MUTEX_E; } @@ -4845,24 +4845,24 @@ int CM_GetCertCacheMemSize(CYASSL_CERT_MANAGER* cm) #endif /* NO_CERTS */ -int CyaSSL_CTX_set_cipher_list(CYASSL_CTX* ctx, const char* list) +int wolfSSL_CTX_set_cipher_list(WOLFSSL_CTX* ctx, const char* list) { - CYASSL_ENTER("CyaSSL_CTX_set_cipher_list"); + WOLFSSL_ENTER("wolfSSL_CTX_set_cipher_list"); return (SetCipherList(&ctx->suites, list)) ? SSL_SUCCESS : SSL_FAILURE; } -int CyaSSL_set_cipher_list(CYASSL* ssl, const char* list) +int wolfSSL_set_cipher_list(WOLFSSL* ssl, const char* list) { - CYASSL_ENTER("CyaSSL_set_cipher_list"); + WOLFSSL_ENTER("wolfSSL_set_cipher_list"); return (SetCipherList(ssl->suites, list)) ? SSL_SUCCESS : SSL_FAILURE; } -#ifndef CYASSL_LEANPSK -#ifdef CYASSL_DTLS +#ifndef WOLFSSL_LEANPSK +#ifdef WOLFSSL_DTLS -int CyaSSL_dtls_get_current_timeout(CYASSL* ssl) +int wolfSSL_dtls_get_current_timeout(WOLFSSL* ssl) { (void)ssl; @@ -4871,13 +4871,13 @@ int CyaSSL_dtls_get_current_timeout(CYASSL* ssl) /* user may need to alter init dtls recv timeout, SSL_SUCCESS on ok */ -int CyaSSL_dtls_set_timeout_init(CYASSL* ssl, int timeout) +int wolfSSL_dtls_set_timeout_init(WOLFSSL* ssl, int timeout) { if (ssl == NULL || timeout < 0) return BAD_FUNC_ARG; if (timeout > ssl->dtls_timeout_max) { - CYASSL_MSG("Can't set dtls timeout init greater than dtls timeout max"); + WOLFSSL_MSG("Can't set dtls timeout init greater than dtls timeout max"); return BAD_FUNC_ARG; } @@ -4889,13 +4889,13 @@ int CyaSSL_dtls_set_timeout_init(CYASSL* ssl, int timeout) /* user may need to alter max dtls recv timeout, SSL_SUCCESS on ok */ -int CyaSSL_dtls_set_timeout_max(CYASSL* ssl, int timeout) +int wolfSSL_dtls_set_timeout_max(WOLFSSL* ssl, int timeout) { if (ssl == NULL || timeout < 0) return BAD_FUNC_ARG; if (timeout < ssl->dtls_timeout_init) { - CYASSL_MSG("Can't set dtls timeout max less than dtls timeout init"); + WOLFSSL_MSG("Can't set dtls timeout max less than dtls timeout init"); return BAD_FUNC_ARG; } @@ -4905,7 +4905,7 @@ int CyaSSL_dtls_set_timeout_max(CYASSL* ssl, int timeout) } -int CyaSSL_dtls_got_timeout(CYASSL* ssl) +int wolfSSL_dtls_got_timeout(WOLFSSL* ssl) { int result = SSL_SUCCESS; @@ -4922,39 +4922,39 @@ int CyaSSL_dtls_got_timeout(CYASSL* ssl) /* client only parts */ -#ifndef NO_CYASSL_CLIENT +#ifndef NO_WOLFSSL_CLIENT #ifndef NO_OLD_TLS - CYASSL_METHOD* wolfSSLv3_client_method(void) + WOLFSSL_METHOD* wolfSSLv3_client_method(void) { - CYASSL_METHOD* method = - (CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, + WOLFSSL_METHOD* method = + (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0, DYNAMIC_TYPE_METHOD); - CYASSL_ENTER("SSLv3_client_method"); + WOLFSSL_ENTER("SSLv3_client_method"); if (method) InitSSL_Method(method, MakeSSLv3()); return method; } #endif - #ifdef CYASSL_DTLS - CYASSL_METHOD* CyaDTLSv1_client_method(void) + #ifdef WOLFSSL_DTLS + WOLFSSL_METHOD* wolfDTLSv1_client_method(void) { - CYASSL_METHOD* method = - (CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, + WOLFSSL_METHOD* method = + (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0, DYNAMIC_TYPE_METHOD); - CYASSL_ENTER("DTLSv1_client_method"); + WOLFSSL_ENTER("DTLSv1_client_method"); if (method) InitSSL_Method(method, MakeDTLSv1()); return method; } - CYASSL_METHOD* CyaDTLSv1_2_client_method(void) + WOLFSSL_METHOD* wolfDTLSv1_2_client_method(void) { - CYASSL_METHOD* method = - (CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, + WOLFSSL_METHOD* method = + (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0, DYNAMIC_TYPE_METHOD); - CYASSL_ENTER("DTLSv1_2_client_method"); + WOLFSSL_ENTER("DTLSv1_2_client_method"); if (method) InitSSL_Method(method, MakeDTLSv1_2()); return method; @@ -4963,22 +4963,22 @@ int CyaSSL_dtls_got_timeout(CYASSL* ssl) /* please see note at top of README if you get an error from connect */ - int CyaSSL_connect(CYASSL* ssl) + int wolfSSL_connect(WOLFSSL* ssl) { int neededState; - CYASSL_ENTER("SSL_connect()"); + WOLFSSL_ENTER("SSL_connect()"); #ifdef HAVE_ERRNO_H errno = 0; #endif - if (ssl->options.side != CYASSL_CLIENT_END) { - CYASSL_ERROR(ssl->error = SIDE_ERROR); + if (ssl->options.side != WOLFSSL_CLIENT_END) { + WOLFSSL_ERROR(ssl->error = SIDE_ERROR); return SSL_FATAL_ERROR; } - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->version.major == DTLS_MAJOR) { ssl->options.dtls = 1; ssl->options.tls = 1; @@ -4986,7 +4986,7 @@ int CyaSSL_dtls_got_timeout(CYASSL* ssl) if (DtlsPoolInit(ssl) != 0) { ssl->error = MEMORY_ERROR; - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } } @@ -4995,10 +4995,10 @@ int CyaSSL_dtls_got_timeout(CYASSL* ssl) if (ssl->buffers.outputBuffer.length > 0) { if ( (ssl->error = SendBuffered(ssl)) == 0) { ssl->options.connectState++; - CYASSL_MSG("connect state: Advanced from buffered send"); + WOLFSSL_MSG("connect state: Advanced from buffered send"); } else { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } } @@ -5008,16 +5008,16 @@ int CyaSSL_dtls_got_timeout(CYASSL* ssl) case CONNECT_BEGIN : /* always send client hello first */ if ( (ssl->error = SendClientHello(ssl)) != 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } ssl->options.connectState = CLIENT_HELLO_SENT; - CYASSL_MSG("connect state: CLIENT_HELLO_SENT"); + WOLFSSL_MSG("connect state: CLIENT_HELLO_SENT"); case CLIENT_HELLO_SENT : neededState = ssl->options.resuming ? SERVER_FINISHED_COMPLETE : SERVER_HELLODONE_COMPLETE; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS /* In DTLS, when resuming, we can go straight to FINISHED, * or do a cookie exchange and then skip to FINISHED, assume * we need the cookie exchange first. */ @@ -5027,7 +5027,7 @@ int CyaSSL_dtls_got_timeout(CYASSL* ssl) /* get response */ while (ssl->options.serverState < neededState) { if ( (ssl->error = ProcessReply(ssl)) < 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } /* if resumption failed, reset needed state */ @@ -5041,19 +5041,19 @@ int CyaSSL_dtls_got_timeout(CYASSL* ssl) } ssl->options.connectState = HELLO_AGAIN; - CYASSL_MSG("connect state: HELLO_AGAIN"); + WOLFSSL_MSG("connect state: HELLO_AGAIN"); case HELLO_AGAIN : if (ssl->options.certOnly) return SSL_SUCCESS; - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { /* re-init hashes, exclude first hello and verify request */ #ifndef NO_OLD_TLS InitMd5(&ssl->hashMd5); if ( (ssl->error = InitSha(&ssl->hashSha)) != 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } #endif @@ -5061,30 +5061,30 @@ int CyaSSL_dtls_got_timeout(CYASSL* ssl) #ifndef NO_SHA256 if ( (ssl->error = InitSha256(&ssl->hashSha256)) != 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } #endif - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 if ( (ssl->error = InitSha384(&ssl->hashSha384)) != 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } #endif } if ( (ssl->error = SendClientHello(ssl)) != 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } } #endif ssl->options.connectState = HELLO_AGAIN_REPLY; - CYASSL_MSG("connect state: HELLO_AGAIN_REPLY"); + WOLFSSL_MSG("connect state: HELLO_AGAIN_REPLY"); case HELLO_AGAIN_REPLY : - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { neededState = ssl->options.resuming ? SERVER_FINISHED_COMPLETE : SERVER_HELLODONE_COMPLETE; @@ -5092,7 +5092,7 @@ int CyaSSL_dtls_got_timeout(CYASSL* ssl) /* get response */ while (ssl->options.serverState < neededState) { if ( (ssl->error = ProcessReply(ssl)) < 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } /* if resumption failed, reset needed state */ @@ -5104,143 +5104,143 @@ int CyaSSL_dtls_got_timeout(CYASSL* ssl) #endif ssl->options.connectState = FIRST_REPLY_DONE; - CYASSL_MSG("connect state: FIRST_REPLY_DONE"); + WOLFSSL_MSG("connect state: FIRST_REPLY_DONE"); case FIRST_REPLY_DONE : #ifndef NO_CERTS if (ssl->options.sendVerify) { if ( (ssl->error = SendCertificate(ssl)) != 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } - CYASSL_MSG("sent: certificate"); + WOLFSSL_MSG("sent: certificate"); } #endif ssl->options.connectState = FIRST_REPLY_FIRST; - CYASSL_MSG("connect state: FIRST_REPLY_FIRST"); + WOLFSSL_MSG("connect state: FIRST_REPLY_FIRST"); case FIRST_REPLY_FIRST : if (!ssl->options.resuming) { if ( (ssl->error = SendClientKeyExchange(ssl)) != 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } - CYASSL_MSG("sent: client key exchange"); + WOLFSSL_MSG("sent: client key exchange"); } ssl->options.connectState = FIRST_REPLY_SECOND; - CYASSL_MSG("connect state: FIRST_REPLY_SECOND"); + WOLFSSL_MSG("connect state: FIRST_REPLY_SECOND"); case FIRST_REPLY_SECOND : #ifndef NO_CERTS if (ssl->options.sendVerify) { if ( (ssl->error = SendCertificateVerify(ssl)) != 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } - CYASSL_MSG("sent: certificate verify"); + WOLFSSL_MSG("sent: certificate verify"); } #endif ssl->options.connectState = FIRST_REPLY_THIRD; - CYASSL_MSG("connect state: FIRST_REPLY_THIRD"); + WOLFSSL_MSG("connect state: FIRST_REPLY_THIRD"); case FIRST_REPLY_THIRD : if ( (ssl->error = SendChangeCipher(ssl)) != 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } - CYASSL_MSG("sent: change cipher spec"); + WOLFSSL_MSG("sent: change cipher spec"); ssl->options.connectState = FIRST_REPLY_FOURTH; - CYASSL_MSG("connect state: FIRST_REPLY_FOURTH"); + WOLFSSL_MSG("connect state: FIRST_REPLY_FOURTH"); case FIRST_REPLY_FOURTH : if ( (ssl->error = SendFinished(ssl)) != 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } - CYASSL_MSG("sent: finished"); + WOLFSSL_MSG("sent: finished"); ssl->options.connectState = FINISHED_DONE; - CYASSL_MSG("connect state: FINISHED_DONE"); + WOLFSSL_MSG("connect state: FINISHED_DONE"); case FINISHED_DONE : /* get response */ while (ssl->options.serverState < SERVER_FINISHED_COMPLETE) if ( (ssl->error = ProcessReply(ssl)) < 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } ssl->options.connectState = SECOND_REPLY_DONE; - CYASSL_MSG("connect state: SECOND_REPLY_DONE"); + WOLFSSL_MSG("connect state: SECOND_REPLY_DONE"); case SECOND_REPLY_DONE: FreeHandshakeResources(ssl); - CYASSL_LEAVE("SSL_connect()", SSL_SUCCESS); + WOLFSSL_LEAVE("SSL_connect()", SSL_SUCCESS); return SSL_SUCCESS; default: - CYASSL_MSG("Unknown connect state ERROR"); + WOLFSSL_MSG("Unknown connect state ERROR"); return SSL_FATAL_ERROR; /* unknown connect state */ } } -#endif /* NO_CYASSL_CLIENT */ +#endif /* NO_WOLFSSL_CLIENT */ /* server only parts */ -#ifndef NO_CYASSL_SERVER +#ifndef NO_WOLFSSL_SERVER #ifndef NO_OLD_TLS - CYASSL_METHOD* wolfSSLv3_server_method(void) + WOLFSSL_METHOD* wolfSSLv3_server_method(void) { - CYASSL_METHOD* method = - (CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, + WOLFSSL_METHOD* method = + (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0, DYNAMIC_TYPE_METHOD); - CYASSL_ENTER("SSLv3_server_method"); + WOLFSSL_ENTER("SSLv3_server_method"); if (method) { InitSSL_Method(method, MakeSSLv3()); - method->side = CYASSL_SERVER_END; + method->side = WOLFSSL_SERVER_END; } return method; } #endif - #ifdef CYASSL_DTLS - CYASSL_METHOD* CyaDTLSv1_server_method(void) + #ifdef WOLFSSL_DTLS + WOLFSSL_METHOD* wolfDTLSv1_server_method(void) { - CYASSL_METHOD* method = - (CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, + WOLFSSL_METHOD* method = + (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0, DYNAMIC_TYPE_METHOD); - CYASSL_ENTER("DTLSv1_server_method"); + WOLFSSL_ENTER("DTLSv1_server_method"); if (method) { InitSSL_Method(method, MakeDTLSv1()); - method->side = CYASSL_SERVER_END; + method->side = WOLFSSL_SERVER_END; } return method; } - CYASSL_METHOD* CyaDTLSv1_2_server_method(void) + WOLFSSL_METHOD* wolfDTLSv1_2_server_method(void) { - CYASSL_METHOD* method = - (CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, + WOLFSSL_METHOD* method = + (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0, DYNAMIC_TYPE_METHOD); - CYASSL_ENTER("DTLSv1_2_server_method"); + WOLFSSL_ENTER("DTLSv1_2_server_method"); if (method) { InitSSL_Method(method, MakeDTLSv1_2()); - method->side = CYASSL_SERVER_END; + method->side = WOLFSSL_SERVER_END; } return method; } #endif - int CyaSSL_accept(CYASSL* ssl) + int wolfSSL_accept(WOLFSSL* ssl) { byte havePSK = 0; byte haveAnon = 0; - CYASSL_ENTER("SSL_accept()"); + WOLFSSL_ENTER("SSL_accept()"); #ifdef HAVE_ERRNO_H errno = 0; @@ -5256,8 +5256,8 @@ int CyaSSL_dtls_got_timeout(CYASSL* ssl) #endif (void)haveAnon; - if (ssl->options.side != CYASSL_SERVER_END) { - CYASSL_ERROR(ssl->error = SIDE_ERROR); + if (ssl->options.side != WOLFSSL_SERVER_END) { + WOLFSSL_ERROR(ssl->error = SIDE_ERROR); return SSL_FATAL_ERROR; } @@ -5266,14 +5266,14 @@ int CyaSSL_dtls_got_timeout(CYASSL* ssl) if (!havePSK && !haveAnon && (ssl->buffers.certificate.buffer == NULL || ssl->buffers.key.buffer == NULL)) { - CYASSL_MSG("accept error: don't have server cert and key"); + WOLFSSL_MSG("accept error: don't have server cert and key"); ssl->error = NO_PRIVATE_KEY; - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } #endif - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->version.major == DTLS_MAJOR) { ssl->options.dtls = 1; ssl->options.tls = 1; @@ -5281,7 +5281,7 @@ int CyaSSL_dtls_got_timeout(CYASSL* ssl) if (DtlsPoolInit(ssl) != 0) { ssl->error = MEMORY_ERROR; - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } } @@ -5290,10 +5290,10 @@ int CyaSSL_dtls_got_timeout(CYASSL* ssl) if (ssl->buffers.outputBuffer.length > 0) { if ( (ssl->error = SendBuffered(ssl)) == 0) { ssl->options.acceptState++; - CYASSL_MSG("accept state: Advanced from buffered send"); + WOLFSSL_MSG("accept state: Advanced from buffered send"); } else { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } } @@ -5304,25 +5304,25 @@ int CyaSSL_dtls_got_timeout(CYASSL* ssl) /* get response */ while (ssl->options.clientState < CLIENT_HELLO_COMPLETE) if ( (ssl->error = ProcessReply(ssl)) < 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } ssl->options.acceptState = ACCEPT_CLIENT_HELLO_DONE; - CYASSL_MSG("accept state ACCEPT_CLIENT_HELLO_DONE"); + WOLFSSL_MSG("accept state ACCEPT_CLIENT_HELLO_DONE"); case ACCEPT_CLIENT_HELLO_DONE : - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) if ( (ssl->error = SendHelloVerifyRequest(ssl)) != 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } #endif ssl->options.acceptState = HELLO_VERIFY_SENT; - CYASSL_MSG("accept state HELLO_VERIFY_SENT"); + WOLFSSL_MSG("accept state HELLO_VERIFY_SENT"); case HELLO_VERIFY_SENT: - #ifdef CYASSL_DTLS + #ifdef WOLFSSL_DTLS if (ssl->options.dtls) { ssl->options.clientState = NULL_STATE; /* get again */ /* reset messages received */ @@ -5331,7 +5331,7 @@ int CyaSSL_dtls_got_timeout(CYASSL* ssl) #ifndef NO_OLD_TLS InitMd5(&ssl->hashMd5); if ( (ssl->error = InitSha(&ssl->hashSha)) != 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } #endif @@ -5339,14 +5339,14 @@ int CyaSSL_dtls_got_timeout(CYASSL* ssl) #ifndef NO_SHA256 if ( (ssl->error = InitSha256(&ssl->hashSha256)) != 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } #endif - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 if ( (ssl->error = InitSha384(&ssl->hashSha384)) != 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } #endif @@ -5354,128 +5354,128 @@ int CyaSSL_dtls_got_timeout(CYASSL* ssl) while (ssl->options.clientState < CLIENT_HELLO_COMPLETE) if ( (ssl->error = ProcessReply(ssl)) < 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } } #endif ssl->options.acceptState = ACCEPT_FIRST_REPLY_DONE; - CYASSL_MSG("accept state ACCEPT_FIRST_REPLY_DONE"); + WOLFSSL_MSG("accept state ACCEPT_FIRST_REPLY_DONE"); case ACCEPT_FIRST_REPLY_DONE : if ( (ssl->error = SendServerHello(ssl)) != 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } ssl->options.acceptState = SERVER_HELLO_SENT; - CYASSL_MSG("accept state SERVER_HELLO_SENT"); + WOLFSSL_MSG("accept state SERVER_HELLO_SENT"); case SERVER_HELLO_SENT : #ifndef NO_CERTS if (!ssl->options.resuming) if ( (ssl->error = SendCertificate(ssl)) != 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } #endif ssl->options.acceptState = CERT_SENT; - CYASSL_MSG("accept state CERT_SENT"); + WOLFSSL_MSG("accept state CERT_SENT"); case CERT_SENT : if (!ssl->options.resuming) if ( (ssl->error = SendServerKeyExchange(ssl)) != 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } ssl->options.acceptState = KEY_EXCHANGE_SENT; - CYASSL_MSG("accept state KEY_EXCHANGE_SENT"); + WOLFSSL_MSG("accept state KEY_EXCHANGE_SENT"); case KEY_EXCHANGE_SENT : #ifndef NO_CERTS if (!ssl->options.resuming) if (ssl->options.verifyPeer) if ( (ssl->error = SendCertificateRequest(ssl)) != 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } #endif ssl->options.acceptState = CERT_REQ_SENT; - CYASSL_MSG("accept state CERT_REQ_SENT"); + WOLFSSL_MSG("accept state CERT_REQ_SENT"); case CERT_REQ_SENT : if (!ssl->options.resuming) if ( (ssl->error = SendServerHelloDone(ssl)) != 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } ssl->options.acceptState = SERVER_HELLO_DONE; - CYASSL_MSG("accept state SERVER_HELLO_DONE"); + WOLFSSL_MSG("accept state SERVER_HELLO_DONE"); case SERVER_HELLO_DONE : if (!ssl->options.resuming) { while (ssl->options.clientState < CLIENT_FINISHED_COMPLETE) if ( (ssl->error = ProcessReply(ssl)) < 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } } ssl->options.acceptState = ACCEPT_SECOND_REPLY_DONE; - CYASSL_MSG("accept state ACCEPT_SECOND_REPLY_DONE"); + WOLFSSL_MSG("accept state ACCEPT_SECOND_REPLY_DONE"); case ACCEPT_SECOND_REPLY_DONE : if ( (ssl->error = SendChangeCipher(ssl)) != 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } ssl->options.acceptState = CHANGE_CIPHER_SENT; - CYASSL_MSG("accept state CHANGE_CIPHER_SENT"); + WOLFSSL_MSG("accept state CHANGE_CIPHER_SENT"); case CHANGE_CIPHER_SENT : if ( (ssl->error = SendFinished(ssl)) != 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } ssl->options.acceptState = ACCEPT_FINISHED_DONE; - CYASSL_MSG("accept state ACCEPT_FINISHED_DONE"); + WOLFSSL_MSG("accept state ACCEPT_FINISHED_DONE"); case ACCEPT_FINISHED_DONE : if (ssl->options.resuming) while (ssl->options.clientState < CLIENT_FINISHED_COMPLETE) if ( (ssl->error = ProcessReply(ssl)) < 0) { - CYASSL_ERROR(ssl->error); + WOLFSSL_ERROR(ssl->error); return SSL_FATAL_ERROR; } ssl->options.acceptState = ACCEPT_THIRD_REPLY_DONE; - CYASSL_MSG("accept state ACCEPT_THIRD_REPLY_DONE"); + WOLFSSL_MSG("accept state ACCEPT_THIRD_REPLY_DONE"); case ACCEPT_THIRD_REPLY_DONE : FreeHandshakeResources(ssl); - CYASSL_LEAVE("SSL_accept()", SSL_SUCCESS); + WOLFSSL_LEAVE("SSL_accept()", SSL_SUCCESS); return SSL_SUCCESS; default : - CYASSL_MSG("Unknown accept state ERROR"); + WOLFSSL_MSG("Unknown accept state ERROR"); return SSL_FATAL_ERROR; } } -#endif /* NO_CYASSL_SERVER */ +#endif /* NO_WOLFSSL_SERVER */ -int CyaSSL_Cleanup(void) +int wolfSSL_Cleanup(void) { int ret = SSL_SUCCESS; int release = 0; - CYASSL_ENTER("CyaSSL_Cleanup"); + WOLFSSL_ENTER("wolfSSL_Cleanup"); if (initRefCount == 0) return ret; /* possibly no init yet, but not failure either way */ if (LockMutex(&count_mutex) != 0) { - CYASSL_MSG("Bad Lock Mutex count"); + WOLFSSL_MSG("Bad Lock Mutex count"); return BAD_MUTEX_E; } @@ -5525,7 +5525,7 @@ static INLINE word32 HashSession(const byte* sessionID, word32 len, int* error) } -void CyaSSL_flush_sessions(CYASSL_CTX* ctx, long tm) +void wolfSSL_flush_sessions(WOLFSSL_CTX* ctx, long tm) { /* static table now, no flusing needed */ (void)ctx; @@ -5534,7 +5534,7 @@ void CyaSSL_flush_sessions(CYASSL_CTX* ctx, long tm) /* set ssl session timeout in seconds */ -int CyaSSL_set_timeout(CYASSL* ssl, unsigned int to) +int wolfSSL_set_timeout(WOLFSSL* ssl, unsigned int to) { if (ssl == NULL) return BAD_FUNC_ARG; @@ -5546,7 +5546,7 @@ int CyaSSL_set_timeout(CYASSL* ssl, unsigned int to) /* set ctx session timeout in seconds */ -int CyaSSL_CTX_set_timeout(CYASSL_CTX* ctx, unsigned int to) +int wolfSSL_CTX_set_timeout(WOLFSSL_CTX* ctx, unsigned int to) { if (ctx == NULL) return BAD_FUNC_ARG; @@ -5560,28 +5560,28 @@ int CyaSSL_CTX_set_timeout(CYASSL_CTX* ctx, unsigned int to) #ifndef NO_CLIENT_CACHE /* Get Session from Client cache based on id/len, return NULL on failure */ -CYASSL_SESSION* GetSessionClient(CYASSL* ssl, const byte* id, int len) +WOLFSSL_SESSION* GetSessionClient(WOLFSSL* ssl, const byte* id, int len) { - CYASSL_SESSION* ret = NULL; + WOLFSSL_SESSION* ret = NULL; word32 row; int idx; int count; int error = 0; - CYASSL_ENTER("GetSessionClient"); + WOLFSSL_ENTER("GetSessionClient"); - if (ssl->options.side == CYASSL_SERVER_END) + if (ssl->options.side == WOLFSSL_SERVER_END) return NULL; len = min(SERVER_ID_LEN, (word32)len); row = HashSession(id, len, &error) % SESSION_ROWS; if (error != 0) { - CYASSL_MSG("Hash session failed"); + WOLFSSL_MSG("Hash session failed"); return NULL; } if (LockMutex(&session_mutex) != 0) { - CYASSL_MSG("Lock session mutex failed"); + WOLFSSL_MSG("Lock session mutex failed"); return NULL; } @@ -5592,11 +5592,11 @@ CYASSL_SESSION* GetSessionClient(CYASSL* ssl, const byte* id, int len) idx = SESSIONS_PER_ROW - 1; /* if back to front, the previous was end */ for (; count > 0; --count, idx = idx ? idx - 1 : SESSIONS_PER_ROW - 1) { - CYASSL_SESSION* current; + WOLFSSL_SESSION* current; ClientSession clSess; if (idx >= SESSIONS_PER_ROW || idx < 0) { /* sanity check */ - CYASSL_MSG("Bad idx"); + WOLFSSL_MSG("Bad idx"); break; } @@ -5604,16 +5604,16 @@ CYASSL_SESSION* GetSessionClient(CYASSL* ssl, const byte* id, int len) current = &SessionCache[clSess.serverRow].Sessions[clSess.serverIdx]; if (XMEMCMP(current->serverID, id, len) == 0) { - CYASSL_MSG("Found a serverid match for client"); + WOLFSSL_MSG("Found a serverid match for client"); if (LowResTimer() < (current->bornOn + current->timeout)) { - CYASSL_MSG("Session valid"); + WOLFSSL_MSG("Session valid"); ret = current; break; } else { - CYASSL_MSG("Session timed out"); /* could have more for id */ + WOLFSSL_MSG("Session timed out"); /* could have more for id */ } } else { - CYASSL_MSG("ServerID not a match from client table"); + WOLFSSL_MSG("ServerID not a match from client table"); } } @@ -5625,9 +5625,9 @@ CYASSL_SESSION* GetSessionClient(CYASSL* ssl, const byte* id, int len) #endif /* NO_CLIENT_CACHE */ -CYASSL_SESSION* GetSession(CYASSL* ssl, byte* masterSecret) +WOLFSSL_SESSION* GetSession(WOLFSSL* ssl, byte* masterSecret) { - CYASSL_SESSION* ret = 0; + WOLFSSL_SESSION* ret = 0; const byte* id = NULL; word32 row; int idx; @@ -5647,7 +5647,7 @@ CYASSL_SESSION* GetSession(CYASSL* ssl, byte* masterSecret) row = HashSession(id, ID_LEN, &error) % SESSION_ROWS; if (error != 0) { - CYASSL_MSG("Hash session failed"); + WOLFSSL_MSG("Hash session failed"); return NULL; } @@ -5661,27 +5661,27 @@ CYASSL_SESSION* GetSession(CYASSL* ssl, byte* masterSecret) idx = SESSIONS_PER_ROW - 1; /* if back to front, the previous was end */ for (; count > 0; --count, idx = idx ? idx - 1 : SESSIONS_PER_ROW - 1) { - CYASSL_SESSION* current; + WOLFSSL_SESSION* current; if (idx >= SESSIONS_PER_ROW || idx < 0) { /* sanity check */ - CYASSL_MSG("Bad idx"); + WOLFSSL_MSG("Bad idx"); break; } current = &SessionCache[row].Sessions[idx]; if (XMEMCMP(current->sessionID, id, ID_LEN) == 0) { - CYASSL_MSG("Found a session match"); + WOLFSSL_MSG("Found a session match"); if (LowResTimer() < (current->bornOn + current->timeout)) { - CYASSL_MSG("Session valid"); + WOLFSSL_MSG("Session valid"); ret = current; if (masterSecret) XMEMCPY(masterSecret, current->masterSecret, SECRET_LEN); } else { - CYASSL_MSG("Session timed out"); + WOLFSSL_MSG("Session timed out"); } break; /* no more sessionIDs whether valid or not that match */ } else { - CYASSL_MSG("SessionID not a match at this idx"); + WOLFSSL_MSG("SessionID not a match at this idx"); } } @@ -5691,7 +5691,7 @@ CYASSL_SESSION* GetSession(CYASSL* ssl, byte* masterSecret) } -int SetSession(CYASSL* ssl, CYASSL_SESSION* session) +int SetSession(WOLFSSL* ssl, WOLFSSL_SESSION* session) { if (ssl->options.sessionCacheOff) return SSL_FAILURE; @@ -5712,7 +5712,7 @@ int SetSession(CYASSL* ssl, CYASSL_SESSION* session) } -int AddSession(CYASSL* ssl) +int AddSession(WOLFSSL* ssl) { word32 row, idx; int error = 0; @@ -5725,7 +5725,7 @@ int AddSession(CYASSL* ssl) row = HashSession(ssl->arrays->sessionID, ID_LEN, &error) % SESSION_ROWS; if (error != 0) { - CYASSL_MSG("Hash session failed"); + WOLFSSL_MSG("Hash session failed"); return error; } @@ -5767,10 +5767,10 @@ int AddSession(CYASSL* ssl) SessionCache[row].nextIdx = 0; #ifndef NO_CLIENT_CACHE - if (ssl->options.side == CYASSL_CLIENT_END && ssl->session.idLen) { + if (ssl->options.side == WOLFSSL_CLIENT_END && ssl->session.idLen) { word32 clientRow, clientIdx; - CYASSL_MSG("Adding client cache entry"); + WOLFSSL_MSG("Adding client cache entry"); SessionCache[row].Sessions[idx].idLen = ssl->session.idLen; XMEMCPY(SessionCache[row].Sessions[idx].serverID, ssl->session.serverID, @@ -5779,7 +5779,7 @@ int AddSession(CYASSL* ssl) clientRow = HashSession(ssl->session.serverID, ssl->session.idLen, &error) % SESSION_ROWS; if (error != 0) { - CYASSL_MSG("Hash session failed"); + WOLFSSL_MSG("Hash session failed"); } else { clientIdx = ClientCache[clientRow].nextIdx++; @@ -5804,19 +5804,19 @@ int AddSession(CYASSL* ssl) #ifdef SESSION_INDEX -int CyaSSL_GetSessionIndex(CYASSL* ssl) +int wolfSSL_GetSessionIndex(WOLFSSL* ssl) { - CYASSL_ENTER("CyaSSL_GetSessionIndex"); - CYASSL_LEAVE("CyaSSL_GetSessionIndex", ssl->sessionIndex); + WOLFSSL_ENTER("wolfSSL_GetSessionIndex"); + WOLFSSL_LEAVE("wolfSSL_GetSessionIndex", ssl->sessionIndex); return ssl->sessionIndex; } -int CyaSSL_GetSessionAtIndex(int idx, CYASSL_SESSION* session) +int wolfSSL_GetSessionAtIndex(int idx, WOLFSSL_SESSION* session) { int row, col, result = SSL_FAILURE; - CYASSL_ENTER("CyaSSL_GetSessionAtIndex"); + WOLFSSL_ENTER("wolfSSL_GetSessionAtIndex"); row = idx >> SESSIDX_ROW_SHIFT; col = idx & SESSIDX_IDX_MASK; @@ -5828,14 +5828,14 @@ int CyaSSL_GetSessionAtIndex(int idx, CYASSL_SESSION* session) if (row < SESSION_ROWS && col < (int)min(SessionCache[row].totalCount, SESSIONS_PER_ROW)) { XMEMCPY(session, - &SessionCache[row].Sessions[col], sizeof(CYASSL_SESSION)); + &SessionCache[row].Sessions[col], sizeof(WOLFSSL_SESSION)); result = SSL_SUCCESS; } if (UnLockMutex(&session_mutex) != 0) result = BAD_MUTEX_E; - CYASSL_LEAVE("CyaSSL_GetSessionAtIndex", result); + WOLFSSL_LEAVE("wolfSSL_GetSessionAtIndex", result); return result; } @@ -5843,15 +5843,15 @@ int CyaSSL_GetSessionAtIndex(int idx, CYASSL_SESSION* session) #if defined(SESSION_INDEX) && defined(SESSION_CERTS) -CYASSL_X509_CHAIN* CyaSSL_SESSION_get_peer_chain(CYASSL_SESSION* session) +WOLFSSL_X509_CHAIN* wolfSSL_SESSION_get_peer_chain(WOLFSSL_SESSION* session) { - CYASSL_X509_CHAIN* chain = NULL; + WOLFSSL_X509_CHAIN* chain = NULL; - CYASSL_ENTER("CyaSSL_SESSION_get_peer_chain"); + WOLFSSL_ENTER("wolfSSL_SESSION_get_peer_chain"); if (session) chain = &session->chain; - CYASSL_LEAVE("CyaSSL_SESSION_get_peer_chain", chain ? 1 : 0); + WOLFSSL_LEAVE("wolfSSL_SESSION_get_peer_chain", chain ? 1 : 0); return chain; } @@ -5860,7 +5860,7 @@ CYASSL_X509_CHAIN* CyaSSL_SESSION_get_peer_chain(CYASSL_SESSION* session) #ifdef SESSION_STATS - CYASSL_API + WOLFSSL_API void PrintSessionStats(void) { word32 totalSessionsSeen = 0; @@ -5915,7 +5915,7 @@ CYASSL_X509_CHAIN* CyaSSL_SESSION_get_peer_chain(CYASSL_SESSION* session) #else /* NO_SESSION_CACHE */ /* No session cache version */ -CYASSL_SESSION* GetSession(CYASSL* ssl, byte* masterSecret) +WOLFSSL_SESSION* GetSession(WOLFSSL* ssl, byte* masterSecret) { (void)ssl; (void)masterSecret; @@ -5928,9 +5928,9 @@ CYASSL_SESSION* GetSession(CYASSL* ssl, byte* masterSecret) /* call before SSL_connect, if verifying will add name check to date check and signature check */ -int CyaSSL_check_domain_name(CYASSL* ssl, const char* dn) +int wolfSSL_check_domain_name(WOLFSSL* ssl, const char* dn) { - CYASSL_ENTER("CyaSSL_check_domain_name"); + WOLFSSL_ENTER("wolfSSL_check_domain_name"); if (ssl->buffers.domainName.buffer) XFREE(ssl->buffers.domainName.buffer, ssl->heap, DYNAMIC_TYPE_DOMAIN); @@ -5950,12 +5950,12 @@ int CyaSSL_check_domain_name(CYASSL* ssl, const char* dn) } -/* turn on CyaSSL zlib compression +/* turn on wolfSSL zlib compression returns SSL_SUCCESS for success, else error (not built in) */ -int CyaSSL_set_compression(CYASSL* ssl) +int wolfSSL_set_compression(WOLFSSL* ssl) { - CYASSL_ENTER("CyaSSL_set_compression"); + WOLFSSL_ENTER("wolfSSL_set_compression"); (void)ssl; #ifdef HAVE_LIBZ ssl->options.usingCompression = 1; @@ -5971,9 +5971,9 @@ int CyaSSL_set_compression(CYASSL* ssl) /* simulate writev semantics, doesn't actually do block at a time though because of SSL_write behavior and because front adds may be small */ - int CyaSSL_writev(CYASSL* ssl, const struct iovec* iov, int iovcnt) + int wolfSSL_writev(WOLFSSL* ssl, const struct iovec* iov, int iovcnt) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK byte staticBuffer[1]; /* force heap usage */ #else byte staticBuffer[FILE_BUFFER_SIZE]; @@ -5985,7 +5985,7 @@ int CyaSSL_set_compression(CYASSL* ssl) int i; int ret; - CYASSL_ENTER("CyaSSL_writev"); + WOLFSSL_ENTER("wolfSSL_writev"); for (i = 0; i < iovcnt; i++) sending += (int)iov[i].iov_len; @@ -6004,7 +6004,7 @@ int CyaSSL_set_compression(CYASSL* ssl) idx += (int)iov[i].iov_len; } - ret = CyaSSL_write(ssl, myBuffer, sending); + ret = wolfSSL_write(ssl, myBuffer, sending); if (dynamic) XFREE(myBuffer, ssl->heap, DYNAMIC_TYPE_WRITEV); @@ -6015,7 +6015,7 @@ int CyaSSL_set_compression(CYASSL* ssl) #endif -#ifdef CYASSL_CALLBACKS +#ifdef WOLFSSL_CALLBACKS typedef struct itimerval Itimerval; @@ -6057,7 +6057,7 @@ int CyaSSL_set_compression(CYASSL* ssl) } - static int CyaSSL_ex_wrapper(CYASSL* ssl, HandShakeCallBack hsCb, + static int wolfSSL_ex_wrapper(WOLFSSL* ssl, HandShakeCallBack hsCb, TimeoutCallBack toCb, Timeval timeout) { int ret = SSL_FATAL_ERROR; @@ -6117,13 +6117,13 @@ int CyaSSL_set_compression(CYASSL* ssl) } /* do main work */ -#ifndef NO_CYASSL_CLIENT - if (ssl->options.side == CYASSL_CLIENT_END) - ret = CyaSSL_connect(ssl); +#ifndef NO_WOLFSSL_CLIENT + if (ssl->options.side == WOLFSSL_CLIENT_END) + ret = wolfSSL_connect(ssl); #endif -#ifndef NO_CYASSL_SERVER - if (ssl->options.side == CYASSL_SERVER_END) - ret = CyaSSL_accept(ssl); +#ifndef NO_WOLFSSL_SERVER + if (ssl->options.side == WOLFSSL_SERVER_END) + ret = wolfSSL_accept(ssl); #endif /* do callbacks */ @@ -6169,48 +6169,48 @@ int CyaSSL_set_compression(CYASSL* ssl) } -#ifndef NO_CYASSL_CLIENT +#ifndef NO_WOLFSSL_CLIENT - int CyaSSL_connect_ex(CYASSL* ssl, HandShakeCallBack hsCb, + int wolfSSL_connect_ex(WOLFSSL* ssl, HandShakeCallBack hsCb, TimeoutCallBack toCb, Timeval timeout) { - CYASSL_ENTER("CyaSSL_connect_ex"); - return CyaSSL_ex_wrapper(ssl, hsCb, toCb, timeout); + WOLFSSL_ENTER("wolfSSL_connect_ex"); + return wolfSSL_ex_wrapper(ssl, hsCb, toCb, timeout); } #endif -#ifndef NO_CYASSL_SERVER +#ifndef NO_WOLFSSL_SERVER - int CyaSSL_accept_ex(CYASSL* ssl, HandShakeCallBack hsCb, + int wolfSSL_accept_ex(WOLFSSL* ssl, HandShakeCallBack hsCb, TimeoutCallBack toCb,Timeval timeout) { - CYASSL_ENTER("CyaSSL_accept_ex"); - return CyaSSL_ex_wrapper(ssl, hsCb, toCb, timeout); + WOLFSSL_ENTER("wolfSSL_accept_ex"); + return wolfSSL_ex_wrapper(ssl, hsCb, toCb, timeout); } #endif -#endif /* CYASSL_CALLBACKS */ +#endif /* WOLFSSL_CALLBACKS */ #ifndef NO_PSK - void CyaSSL_CTX_set_psk_client_callback(CYASSL_CTX* ctx, + void wolfSSL_CTX_set_psk_client_callback(WOLFSSL_CTX* ctx, psk_client_callback cb) { - CYASSL_ENTER("SSL_CTX_set_psk_client_callback"); + WOLFSSL_ENTER("SSL_CTX_set_psk_client_callback"); ctx->havePSK = 1; ctx->client_psk_cb = cb; } - void CyaSSL_set_psk_client_callback(CYASSL* ssl, psk_client_callback cb) + void wolfSSL_set_psk_client_callback(WOLFSSL* ssl, psk_client_callback cb) { byte haveRSA = 1; - CYASSL_ENTER("SSL_set_psk_client_callback"); + WOLFSSL_ENTER("SSL_set_psk_client_callback"); ssl->options.havePSK = 1; ssl->options.client_psk_cb = cb; @@ -6224,20 +6224,20 @@ int CyaSSL_set_compression(CYASSL* ssl) } - void CyaSSL_CTX_set_psk_server_callback(CYASSL_CTX* ctx, + void wolfSSL_CTX_set_psk_server_callback(WOLFSSL_CTX* ctx, psk_server_callback cb) { - CYASSL_ENTER("SSL_CTX_set_psk_server_callback"); + WOLFSSL_ENTER("SSL_CTX_set_psk_server_callback"); ctx->havePSK = 1; ctx->server_psk_cb = cb; } - void CyaSSL_set_psk_server_callback(CYASSL* ssl, psk_server_callback cb) + void wolfSSL_set_psk_server_callback(WOLFSSL* ssl, psk_server_callback cb) { byte haveRSA = 1; - CYASSL_ENTER("SSL_set_psk_server_callback"); + WOLFSSL_ENTER("SSL_set_psk_server_callback"); ssl->options.havePSK = 1; ssl->options.server_psk_cb = cb; @@ -6251,9 +6251,9 @@ int CyaSSL_set_compression(CYASSL* ssl) } - const char* CyaSSL_get_psk_identity_hint(const CYASSL* ssl) + const char* wolfSSL_get_psk_identity_hint(const WOLFSSL* ssl) { - CYASSL_ENTER("SSL_get_psk_identity_hint"); + WOLFSSL_ENTER("SSL_get_psk_identity_hint"); if (ssl == NULL || ssl->arrays == NULL) return NULL; @@ -6262,9 +6262,9 @@ int CyaSSL_set_compression(CYASSL* ssl) } - const char* CyaSSL_get_psk_identity(const CYASSL* ssl) + const char* wolfSSL_get_psk_identity(const WOLFSSL* ssl) { - CYASSL_ENTER("SSL_get_psk_identity"); + WOLFSSL_ENTER("SSL_get_psk_identity"); if (ssl == NULL || ssl->arrays == NULL) return NULL; @@ -6273,9 +6273,9 @@ int CyaSSL_set_compression(CYASSL* ssl) } - int CyaSSL_CTX_use_psk_identity_hint(CYASSL_CTX* ctx, const char* hint) + int wolfSSL_CTX_use_psk_identity_hint(WOLFSSL_CTX* ctx, const char* hint) { - CYASSL_ENTER("SSL_CTX_use_psk_identity_hint"); + WOLFSSL_ENTER("SSL_CTX_use_psk_identity_hint"); if (hint == 0) ctx->server_hint[0] = 0; else { @@ -6286,9 +6286,9 @@ int CyaSSL_set_compression(CYASSL* ssl) } - int CyaSSL_use_psk_identity_hint(CYASSL* ssl, const char* hint) + int wolfSSL_use_psk_identity_hint(WOLFSSL* ssl, const char* hint) { - CYASSL_ENTER("SSL_use_psk_identity_hint"); + WOLFSSL_ENTER("SSL_use_psk_identity_hint"); if (ssl == NULL || ssl->arrays == NULL) return SSL_FAILURE; @@ -6307,9 +6307,9 @@ int CyaSSL_set_compression(CYASSL* ssl) #ifdef HAVE_ANON - int CyaSSL_CTX_allow_anon_cipher(CYASSL_CTX* ctx) + int wolfSSL_CTX_allow_anon_cipher(WOLFSSL_CTX* ctx) { - CYASSL_ENTER("CyaSSL_CTX_allow_anon_cipher"); + WOLFSSL_ENTER("wolfSSL_CTX_allow_anon_cipher"); if (ctx == NULL) return SSL_FAILURE; @@ -6325,11 +6325,11 @@ int CyaSSL_set_compression(CYASSL* ssl) #ifndef NO_CERTS /* used to be defined on NO_FILESYSTEM only, but are generally useful */ - /* CyaSSL extension allows DER files to be loaded from buffers as well */ - int CyaSSL_CTX_load_verify_buffer(CYASSL_CTX* ctx, const unsigned char* in, + /* wolfSSL extension allows DER files to be loaded from buffers as well */ + int wolfSSL_CTX_load_verify_buffer(WOLFSSL_CTX* ctx, const unsigned char* in, long sz, int format) { - CYASSL_ENTER("CyaSSL_CTX_load_verify_buffer"); + WOLFSSL_ENTER("wolfSSL_CTX_load_verify_buffer"); if (format == SSL_FILETYPE_PEM) return ProcessChainBuffer(ctx, in, sz, format, CA_TYPE, NULL); else @@ -6337,51 +6337,51 @@ int CyaSSL_set_compression(CYASSL* ssl) } - int CyaSSL_CTX_use_certificate_buffer(CYASSL_CTX* ctx, + int wolfSSL_CTX_use_certificate_buffer(WOLFSSL_CTX* ctx, const unsigned char* in, long sz, int format) { - CYASSL_ENTER("CyaSSL_CTX_use_certificate_buffer"); + WOLFSSL_ENTER("wolfSSL_CTX_use_certificate_buffer"); return ProcessBuffer(ctx, in, sz, format, CERT_TYPE, NULL, NULL, 0); } - int CyaSSL_CTX_use_PrivateKey_buffer(CYASSL_CTX* ctx, + int wolfSSL_CTX_use_PrivateKey_buffer(WOLFSSL_CTX* ctx, const unsigned char* in, long sz, int format) { - CYASSL_ENTER("CyaSSL_CTX_use_PrivateKey_buffer"); + WOLFSSL_ENTER("wolfSSL_CTX_use_PrivateKey_buffer"); return ProcessBuffer(ctx, in, sz, format, PRIVATEKEY_TYPE, NULL,NULL,0); } - int CyaSSL_CTX_use_certificate_chain_buffer(CYASSL_CTX* ctx, + int wolfSSL_CTX_use_certificate_chain_buffer(WOLFSSL_CTX* ctx, const unsigned char* in, long sz) { - CYASSL_ENTER("CyaSSL_CTX_use_certificate_chain_buffer"); + WOLFSSL_ENTER("wolfSSL_CTX_use_certificate_chain_buffer"); return ProcessBuffer(ctx, in, sz, SSL_FILETYPE_PEM, CERT_TYPE, NULL, NULL, 1); } - int CyaSSL_use_certificate_buffer(CYASSL* ssl, + int wolfSSL_use_certificate_buffer(WOLFSSL* ssl, const unsigned char* in, long sz, int format) { - CYASSL_ENTER("CyaSSL_use_certificate_buffer"); + WOLFSSL_ENTER("wolfSSL_use_certificate_buffer"); return ProcessBuffer(ssl->ctx, in, sz, format,CERT_TYPE,ssl,NULL,0); } - int CyaSSL_use_PrivateKey_buffer(CYASSL* ssl, + int wolfSSL_use_PrivateKey_buffer(WOLFSSL* ssl, const unsigned char* in, long sz, int format) { - CYASSL_ENTER("CyaSSL_use_PrivateKey_buffer"); + WOLFSSL_ENTER("wolfSSL_use_PrivateKey_buffer"); return ProcessBuffer(ssl->ctx, in, sz, format, PRIVATEKEY_TYPE, ssl, NULL, 0); } - int CyaSSL_use_certificate_chain_buffer(CYASSL* ssl, + int wolfSSL_use_certificate_chain_buffer(WOLFSSL* ssl, const unsigned char* in, long sz) { - CYASSL_ENTER("CyaSSL_use_certificate_chain_buffer"); + WOLFSSL_ENTER("wolfSSL_use_certificate_chain_buffer"); return ProcessBuffer(ssl->ctx, in, sz, SSL_FILETYPE_PEM, CERT_TYPE, ssl, NULL, 1); } @@ -6389,15 +6389,15 @@ int CyaSSL_set_compression(CYASSL* ssl) /* unload any certs or keys that SSL owns, leave CTX as is SSL_SUCCESS on ok */ - int CyaSSL_UnloadCertsKeys(CYASSL* ssl) + int wolfSSL_UnloadCertsKeys(WOLFSSL* ssl) { if (ssl == NULL) { - CYASSL_MSG("Null function arg"); + WOLFSSL_MSG("Null function arg"); return BAD_FUNC_ARG; } if (ssl->buffers.weOwnCert) { - CYASSL_MSG("Unloading cert"); + WOLFSSL_MSG("Unloading cert"); XFREE(ssl->buffers.certificate.buffer, ssl->heap,DYNAMIC_TYPE_CERT); ssl->buffers.weOwnCert = 0; ssl->buffers.certificate.length = 0; @@ -6405,7 +6405,7 @@ int CyaSSL_set_compression(CYASSL* ssl) } if (ssl->buffers.weOwnCertChain) { - CYASSL_MSG("Unloading cert chain"); + WOLFSSL_MSG("Unloading cert chain"); XFREE(ssl->buffers.certChain.buffer, ssl->heap,DYNAMIC_TYPE_CERT); ssl->buffers.weOwnCertChain = 0; ssl->buffers.certChain.length = 0; @@ -6413,7 +6413,7 @@ int CyaSSL_set_compression(CYASSL* ssl) } if (ssl->buffers.weOwnKey) { - CYASSL_MSG("Unloading key"); + WOLFSSL_MSG("Unloading key"); XFREE(ssl->buffers.key.buffer, ssl->heap, DYNAMIC_TYPE_KEY); ssl->buffers.weOwnKey = 0; ssl->buffers.key.length = 0; @@ -6424,14 +6424,14 @@ int CyaSSL_set_compression(CYASSL* ssl) } - int CyaSSL_CTX_UnloadCAs(CYASSL_CTX* ctx) + int wolfSSL_CTX_UnloadCAs(WOLFSSL_CTX* ctx) { - CYASSL_ENTER("CyaSSL_CTX_UnloadCAs"); + WOLFSSL_ENTER("wolfSSL_CTX_UnloadCAs"); if (ctx == NULL) return BAD_FUNC_ARG; - return CyaSSL_CertManagerUnloadCAs(ctx->cm); + return wolfSSL_CertManagerUnloadCAs(ctx->cm); } /* old NO_FILESYSTEM end */ @@ -6441,66 +6441,66 @@ int CyaSSL_set_compression(CYASSL* ssl) #if defined(OPENSSL_EXTRA) || defined(GOAHEAD_WS) - int CyaSSL_add_all_algorithms(void) + int wolfSSL_add_all_algorithms(void) { - CYASSL_ENTER("CyaSSL_add_all_algorithms"); - CyaSSL_Init(); + WOLFSSL_ENTER("wolfSSL_add_all_algorithms"); + wolfSSL_Init(); return SSL_SUCCESS; } - long CyaSSL_CTX_sess_set_cache_size(CYASSL_CTX* ctx, long sz) + long wolfSSL_CTX_sess_set_cache_size(WOLFSSL_CTX* ctx, long sz) { - /* cache size fixed at compile time in CyaSSL */ + /* cache size fixed at compile time in wolfSSL */ (void)ctx; (void)sz; return 0; } - void CyaSSL_CTX_set_quiet_shutdown(CYASSL_CTX* ctx, int mode) + void wolfSSL_CTX_set_quiet_shutdown(WOLFSSL_CTX* ctx, int mode) { - CYASSL_ENTER("CyaSSL_CTX_set_quiet_shutdown"); + WOLFSSL_ENTER("wolfSSL_CTX_set_quiet_shutdown"); if (mode) ctx->quietShutdown = 1; } - void CyaSSL_set_quiet_shutdown(CYASSL* ssl, int mode) + void wolfSSL_set_quiet_shutdown(WOLFSSL* ssl, int mode) { - CYASSL_ENTER("CyaSSL_CTX_set_quiet_shutdown"); + WOLFSSL_ENTER("wolfSSL_CTX_set_quiet_shutdown"); if (mode) ssl->options.quietShutdown = 1; } - void CyaSSL_set_bio(CYASSL* ssl, CYASSL_BIO* rd, CYASSL_BIO* wr) + void wolfSSL_set_bio(WOLFSSL* ssl, WOLFSSL_BIO* rd, WOLFSSL_BIO* wr) { - CYASSL_ENTER("SSL_set_bio"); - CyaSSL_set_rfd(ssl, rd->fd); - CyaSSL_set_wfd(ssl, wr->fd); + WOLFSSL_ENTER("SSL_set_bio"); + wolfSSL_set_rfd(ssl, rd->fd); + wolfSSL_set_wfd(ssl, wr->fd); ssl->biord = rd; ssl->biowr = wr; } - void CyaSSL_CTX_set_client_CA_list(CYASSL_CTX* ctx, - STACK_OF(CYASSL_X509_NAME)* names) + void wolfSSL_CTX_set_client_CA_list(WOLFSSL_CTX* ctx, + STACK_OF(WOLFSSL_X509_NAME)* names) { (void)ctx; (void)names; } - STACK_OF(CYASSL_X509_NAME)* CyaSSL_load_client_CA_file(const char* fname) + STACK_OF(WOLFSSL_X509_NAME)* wolfSSL_load_client_CA_file(const char* fname) { (void)fname; return 0; } - int CyaSSL_CTX_set_default_verify_paths(CYASSL_CTX* ctx) + int wolfSSL_CTX_set_default_verify_paths(WOLFSSL_CTX* ctx) { /* TODO:, not needed in goahead */ (void)ctx; @@ -6509,7 +6509,7 @@ int CyaSSL_set_compression(CYASSL* ssl) /* keyblock size in bytes or -1 */ - int CyaSSL_get_keyblock_size(CYASSL* ssl) + int wolfSSL_get_keyblock_size(WOLFSSL* ssl) { if (ssl == NULL) return SSL_FATAL_ERROR; @@ -6520,7 +6520,7 @@ int CyaSSL_set_compression(CYASSL* ssl) /* store keys returns SSL_SUCCESS or -1 on error */ - int CyaSSL_get_keys(CYASSL* ssl, unsigned char** ms, unsigned int* msLen, + int wolfSSL_get_keys(WOLFSSL* ssl, unsigned char** ms, unsigned int* msLen, unsigned char** sr, unsigned int* srLen, unsigned char** cr, unsigned int* crLen) { @@ -6539,13 +6539,13 @@ int CyaSSL_set_compression(CYASSL* ssl) } - void CyaSSL_set_accept_state(CYASSL* ssl) + void wolfSSL_set_accept_state(WOLFSSL* ssl) { byte haveRSA = 1; byte havePSK = 0; - CYASSL_ENTER("SSL_set_accept_state"); - ssl->options.side = CYASSL_SERVER_END; + WOLFSSL_ENTER("SSL_set_accept_state"); + ssl->options.side = WOLFSSL_SERVER_END; /* reset suites in case user switched */ #ifdef NO_RSA @@ -6562,7 +6562,7 @@ int CyaSSL_set_compression(CYASSL* ssl) #endif /* return true if connection established */ - int CyaSSL_is_init_finished(CYASSL* ssl) + int wolfSSL_is_init_finished(WOLFSSL* ssl) { if (ssl == NULL) return 0; @@ -6574,34 +6574,34 @@ int CyaSSL_set_compression(CYASSL* ssl) } #if defined(OPENSSL_EXTRA) || defined(GOAHEAD_WS) - void CyaSSL_CTX_set_tmp_rsa_callback(CYASSL_CTX* ctx, - CYASSL_RSA*(*f)(CYASSL*, int, int)) + void wolfSSL_CTX_set_tmp_rsa_callback(WOLFSSL_CTX* ctx, + WOLFSSL_RSA*(*f)(WOLFSSL*, int, int)) { - /* CyaSSL verifies all these internally */ + /* wolfSSL verifies all these internally */ (void)ctx; (void)f; } - void CyaSSL_set_shutdown(CYASSL* ssl, int opt) + void wolfSSL_set_shutdown(WOLFSSL* ssl, int opt) { (void)ssl; (void)opt; } - long CyaSSL_CTX_set_options(CYASSL_CTX* ctx, long opt) + long wolfSSL_CTX_set_options(WOLFSSL_CTX* ctx, long opt) { /* goahead calls with 0, do nothing */ - CYASSL_ENTER("SSL_CTX_set_options"); + WOLFSSL_ENTER("SSL_CTX_set_options"); (void)ctx; return opt; } - int CyaSSL_set_rfd(CYASSL* ssl, int rfd) + int wolfSSL_set_rfd(WOLFSSL* ssl, int rfd) { - CYASSL_ENTER("SSL_set_rfd"); + WOLFSSL_ENTER("SSL_set_rfd"); ssl->rfd = rfd; /* not used directly to allow IO callbacks */ ssl->IOCB_ReadCtx = &ssl->rfd; @@ -6610,9 +6610,9 @@ int CyaSSL_set_compression(CYASSL* ssl) } - int CyaSSL_set_wfd(CYASSL* ssl, int wfd) + int wolfSSL_set_wfd(WOLFSSL* ssl, int wfd) { - CYASSL_ENTER("SSL_set_wfd"); + WOLFSSL_ENTER("SSL_set_wfd"); ssl->wfd = wfd; /* not used directly to allow IO callbacks */ ssl->IOCB_WriteCtx = &ssl->wfd; @@ -6621,11 +6621,11 @@ int CyaSSL_set_compression(CYASSL* ssl) } - CYASSL_RSA* CyaSSL_RSA_generate_key(int len, unsigned long bits, + WOLFSSL_RSA* wolfSSL_RSA_generate_key(int len, unsigned long bits, void(*f)(int, int, void*), void* data) { /* no tmp key needed, actual generation not supported */ - CYASSL_ENTER("RSA_generate_key"); + WOLFSSL_ENTER("RSA_generate_key"); (void)len; (void)bits; (void)f; @@ -6635,15 +6635,15 @@ int CyaSSL_set_compression(CYASSL* ssl) - CYASSL_X509* CyaSSL_X509_STORE_CTX_get_current_cert( - CYASSL_X509_STORE_CTX* ctx) + WOLFSSL_X509* wolfSSL_X509_STORE_CTX_get_current_cert( + WOLFSSL_X509_STORE_CTX* ctx) { (void)ctx; return 0; } - int CyaSSL_X509_STORE_CTX_get_error(CYASSL_X509_STORE_CTX* ctx) + int wolfSSL_X509_STORE_CTX_get_error(WOLFSSL_X509_STORE_CTX* ctx) { if (ctx != NULL) return ctx->error; @@ -6651,50 +6651,50 @@ int CyaSSL_set_compression(CYASSL* ssl) } - int CyaSSL_X509_STORE_CTX_get_error_depth(CYASSL_X509_STORE_CTX* ctx) + int wolfSSL_X509_STORE_CTX_get_error_depth(WOLFSSL_X509_STORE_CTX* ctx) { (void)ctx; return 0; } - CYASSL_BIO_METHOD* CyaSSL_BIO_f_buffer(void) + WOLFSSL_BIO_METHOD* wolfSSL_BIO_f_buffer(void) { - static CYASSL_BIO_METHOD meth; + static WOLFSSL_BIO_METHOD meth; - CYASSL_ENTER("BIO_f_buffer"); + WOLFSSL_ENTER("BIO_f_buffer"); meth.type = BIO_BUFFER; return &meth; } - long CyaSSL_BIO_set_write_buffer_size(CYASSL_BIO* bio, long size) + long wolfSSL_BIO_set_write_buffer_size(WOLFSSL_BIO* bio, long size) { - /* CyaSSL has internal buffer, compatibility only */ - CYASSL_ENTER("BIO_set_write_buffer_size"); + /* wolfSSL has internal buffer, compatibility only */ + WOLFSSL_ENTER("BIO_set_write_buffer_size"); (void)bio; return size; } - CYASSL_BIO_METHOD* CyaSSL_BIO_f_ssl(void) + WOLFSSL_BIO_METHOD* wolfSSL_BIO_f_ssl(void) { - static CYASSL_BIO_METHOD meth; + static WOLFSSL_BIO_METHOD meth; - CYASSL_ENTER("BIO_f_ssl"); + WOLFSSL_ENTER("BIO_f_ssl"); meth.type = BIO_SSL; return &meth; } - CYASSL_BIO* CyaSSL_BIO_new_socket(int sfd, int closeF) + WOLFSSL_BIO* wolfSSL_BIO_new_socket(int sfd, int closeF) { - CYASSL_BIO* bio = (CYASSL_BIO*) XMALLOC(sizeof(CYASSL_BIO), 0, + WOLFSSL_BIO* bio = (WOLFSSL_BIO*) XMALLOC(sizeof(WOLFSSL_BIO), 0, DYNAMIC_TYPE_OPENSSL); - CYASSL_ENTER("BIO_new_socket"); + WOLFSSL_ENTER("BIO_new_socket"); if (bio) { bio->type = BIO_SOCKET; bio->close = (byte)closeF; @@ -6710,9 +6710,9 @@ int CyaSSL_set_compression(CYASSL* ssl) } - int CyaSSL_BIO_eof(CYASSL_BIO* b) + int wolfSSL_BIO_eof(WOLFSSL_BIO* b) { - CYASSL_ENTER("BIO_eof"); + WOLFSSL_ENTER("BIO_eof"); if (b->eof) return 1; @@ -6720,9 +6720,9 @@ int CyaSSL_set_compression(CYASSL* ssl) } - long CyaSSL_BIO_set_ssl(CYASSL_BIO* b, CYASSL* ssl, int closeF) + long wolfSSL_BIO_set_ssl(WOLFSSL_BIO* b, WOLFSSL* ssl, int closeF) { - CYASSL_ENTER("BIO_set_ssl"); + WOLFSSL_ENTER("BIO_set_ssl"); b->ssl = ssl; b->close = (byte)closeF; /* add to ssl for bio free if SSL_free called before/instead of free_all? */ @@ -6731,11 +6731,11 @@ int CyaSSL_set_compression(CYASSL* ssl) } - CYASSL_BIO* CyaSSL_BIO_new(CYASSL_BIO_METHOD* method) + WOLFSSL_BIO* wolfSSL_BIO_new(WOLFSSL_BIO_METHOD* method) { - CYASSL_BIO* bio = (CYASSL_BIO*) XMALLOC(sizeof(CYASSL_BIO), 0, + WOLFSSL_BIO* bio = (WOLFSSL_BIO*) XMALLOC(sizeof(WOLFSSL_BIO), 0, DYNAMIC_TYPE_OPENSSL); - CYASSL_ENTER("BIO_new"); + WOLFSSL_ENTER("BIO_new"); if (bio) { bio->type = method->type; bio->close = 0; @@ -6751,7 +6751,7 @@ int CyaSSL_set_compression(CYASSL* ssl) } - int CyaSSL_BIO_get_mem_data(CYASSL_BIO* bio, const byte** p) + int wolfSSL_BIO_get_mem_data(WOLFSSL_BIO* bio, const byte** p) { if (bio == NULL || p == NULL) return SSL_FATAL_ERROR; @@ -6762,13 +6762,13 @@ int CyaSSL_set_compression(CYASSL* ssl) } - CYASSL_BIO* CyaSSL_BIO_new_mem_buf(void* buf, int len) + WOLFSSL_BIO* wolfSSL_BIO_new_mem_buf(void* buf, int len) { - CYASSL_BIO* bio = NULL; + WOLFSSL_BIO* bio = NULL; if (buf == NULL) return bio; - bio = CyaSSL_BIO_new(CyaSSL_BIO_s_mem()); + bio = wolfSSL_BIO_new(wolfSSL_BIO_s_mem()); if (bio == NULL) return bio; @@ -6787,21 +6787,21 @@ int CyaSSL_set_compression(CYASSL* ssl) #ifdef USE_WINDOWS_API #define CloseSocket(s) closesocket(s) -#elif defined(CYASSL_MDK_ARM) +#elif defined(WOLFSSL_MDK_ARM) #define CloseSocket(s) closesocket(s) extern int closesocket(int) ; #else #define CloseSocket(s) close(s) #endif - int CyaSSL_BIO_free(CYASSL_BIO* bio) + int wolfSSL_BIO_free(WOLFSSL_BIO* bio) { /* unchain?, doesn't matter in goahead since from free all */ - CYASSL_ENTER("BIO_free"); + WOLFSSL_ENTER("BIO_free"); if (bio) { if (bio->close) { if (bio->ssl) - CyaSSL_free(bio->ssl); + wolfSSL_free(bio->ssl); if (bio->fd) CloseSocket(bio->fd); } @@ -6813,25 +6813,25 @@ int CyaSSL_set_compression(CYASSL* ssl) } - int CyaSSL_BIO_free_all(CYASSL_BIO* bio) + int wolfSSL_BIO_free_all(WOLFSSL_BIO* bio) { - CYASSL_ENTER("BIO_free_all"); + WOLFSSL_ENTER("BIO_free_all"); while (bio) { - CYASSL_BIO* next = bio->next; - CyaSSL_BIO_free(bio); + WOLFSSL_BIO* next = bio->next; + wolfSSL_BIO_free(bio); bio = next; } return 0; } - int CyaSSL_BIO_read(CYASSL_BIO* bio, void* buf, int len) + int wolfSSL_BIO_read(WOLFSSL_BIO* bio, void* buf, int len) { int ret; - CYASSL* ssl = 0; - CYASSL_BIO* front = bio; + WOLFSSL* ssl = 0; + WOLFSSL_BIO* front = bio; - CYASSL_ENTER("BIO_read"); + WOLFSSL_ENTER("BIO_read"); /* already got eof, again is error */ if (front->eof) return SSL_FATAL_ERROR; @@ -6841,11 +6841,11 @@ int CyaSSL_set_compression(CYASSL* ssl) if (ssl == 0) return BAD_FUNC_ARG; - ret = CyaSSL_read(ssl, buf, len); + ret = wolfSSL_read(ssl, buf, len); if (ret == 0) front->eof = 1; else if (ret < 0) { - int err = CyaSSL_get_error(ssl, 0); + int err = wolfSSL_get_error(ssl, 0); if ( !(err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) ) front->eof = 1; } @@ -6853,13 +6853,13 @@ int CyaSSL_set_compression(CYASSL* ssl) } - int CyaSSL_BIO_write(CYASSL_BIO* bio, const void* data, int len) + int wolfSSL_BIO_write(WOLFSSL_BIO* bio, const void* data, int len) { int ret; - CYASSL* ssl = 0; - CYASSL_BIO* front = bio; + WOLFSSL* ssl = 0; + WOLFSSL_BIO* front = bio; - CYASSL_ENTER("BIO_write"); + WOLFSSL_ENTER("BIO_write"); /* already got eof, again is error */ if (front->eof) return SSL_FATAL_ERROR; @@ -6869,11 +6869,11 @@ int CyaSSL_set_compression(CYASSL* ssl) if (ssl == 0) return BAD_FUNC_ARG; - ret = CyaSSL_write(ssl, data, len); + ret = wolfSSL_write(ssl, data, len); if (ret == 0) front->eof = 1; else if (ret < 0) { - int err = CyaSSL_get_error(ssl, 0); + int err = wolfSSL_get_error(ssl, 0); if ( !(err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE) ) front->eof = 1; } @@ -6882,9 +6882,9 @@ int CyaSSL_set_compression(CYASSL* ssl) } - CYASSL_BIO* CyaSSL_BIO_push(CYASSL_BIO* top, CYASSL_BIO* append) + WOLFSSL_BIO* wolfSSL_BIO_push(WOLFSSL_BIO* top, WOLFSSL_BIO* append) { - CYASSL_ENTER("BIO_push"); + WOLFSSL_ENTER("BIO_push"); top->next = append; append->prev = top; @@ -6892,10 +6892,10 @@ int CyaSSL_set_compression(CYASSL* ssl) } - int CyaSSL_BIO_flush(CYASSL_BIO* bio) + int wolfSSL_BIO_flush(WOLFSSL_BIO* bio) { - /* for CyaSSL no flushing needed */ - CYASSL_ENTER("BIO_flush"); + /* for wolfSSL no flushing needed */ + WOLFSSL_ENTER("BIO_flush"); (void)bio; return 1; } @@ -6906,43 +6906,43 @@ int CyaSSL_set_compression(CYASSL* ssl) #if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) - void CyaSSL_CTX_set_default_passwd_cb_userdata(CYASSL_CTX* ctx, + void wolfSSL_CTX_set_default_passwd_cb_userdata(WOLFSSL_CTX* ctx, void* userdata) { - CYASSL_ENTER("SSL_CTX_set_default_passwd_cb_userdata"); + WOLFSSL_ENTER("SSL_CTX_set_default_passwd_cb_userdata"); ctx->userdata = userdata; } - void CyaSSL_CTX_set_default_passwd_cb(CYASSL_CTX* ctx, pem_password_cb cb) + void wolfSSL_CTX_set_default_passwd_cb(WOLFSSL_CTX* ctx, pem_password_cb cb) { - CYASSL_ENTER("SSL_CTX_set_default_passwd_cb"); + WOLFSSL_ENTER("SSL_CTX_set_default_passwd_cb"); ctx->passwd_cb = cb; } - int CyaSSL_num_locks(void) + int wolfSSL_num_locks(void) { return 0; } - void CyaSSL_set_locking_callback(void (*f)(int, int, const char*, int)) + void wolfSSL_set_locking_callback(void (*f)(int, int, const char*, int)) { (void)f; } - void CyaSSL_set_id_callback(unsigned long (*f)(void)) + void wolfSSL_set_id_callback(unsigned long (*f)(void)) { (void)f; } - unsigned long CyaSSL_ERR_get_error(void) + unsigned long wolfSSL_ERR_get_error(void) { /* TODO: */ return 0; } - int CyaSSL_EVP_BytesToKey(const CYASSL_EVP_CIPHER* type, - const CYASSL_EVP_MD* md, const byte* salt, + int wolfSSL_EVP_BytesToKey(const WOLFSSL_EVP_CIPHER* type, + const WOLFSSL_EVP_MD* md, const byte* salt, const byte* data, int sz, int count, byte* key, byte* iv) { int keyLen = 0; @@ -6952,19 +6952,19 @@ int CyaSSL_set_compression(CYASSL* ssl) int ivLeft; int keyOutput = 0; byte digest[MD5_DIGEST_SIZE]; - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK Md5* md5 = NULL; #else Md5 md5[1]; #endif - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK md5 = (Md5*)XMALLOC(sizeof(Md5), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (md5 == NULL) return 0; #endif - CYASSL_ENTER("EVP_BytesToKey"); + WOLFSSL_ENTER("EVP_BytesToKey"); InitMd5(md5); /* only support MD5 for now */ @@ -6992,7 +6992,7 @@ int CyaSSL_set_compression(CYASSL* ssl) ivLen = AES_IV_SIZE; } else { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return 0; @@ -7036,7 +7036,7 @@ int CyaSSL_set_compression(CYASSL* ssl) } } - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(md5, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -7048,327 +7048,327 @@ int CyaSSL_set_compression(CYASSL* ssl) #ifdef OPENSSL_EXTRA - unsigned long CyaSSLeay(void) + unsigned long wolfSSLeay(void) { return SSLEAY_VERSION_NUMBER; } - const char* CyaSSLeay_version(int type) + const char* wolfSSLeay_version(int type) { - static const char* version = "SSLeay CyaSSL compatibility"; + static const char* version = "SSLeay wolfSSL compatibility"; (void)type; return version; } - void CyaSSL_MD5_Init(CYASSL_MD5_CTX* md5) + void wolfSSL_MD5_Init(WOLFSSL_MD5_CTX* md5) { typedef char md5_test[sizeof(MD5_CTX) >= sizeof(Md5) ? 1 : -1]; (void)sizeof(md5_test); - CYASSL_ENTER("MD5_Init"); + WOLFSSL_ENTER("MD5_Init"); InitMd5((Md5*)md5); } - void CyaSSL_MD5_Update(CYASSL_MD5_CTX* md5, const void* input, + void wolfSSL_MD5_Update(WOLFSSL_MD5_CTX* md5, const void* input, unsigned long sz) { - CYASSL_ENTER("CyaSSL_MD5_Update"); + WOLFSSL_ENTER("wolfSSL_MD5_Update"); Md5Update((Md5*)md5, (const byte*)input, (word32)sz); } - void CyaSSL_MD5_Final(byte* input, CYASSL_MD5_CTX* md5) + void wolfSSL_MD5_Final(byte* input, WOLFSSL_MD5_CTX* md5) { - CYASSL_ENTER("MD5_Final"); + WOLFSSL_ENTER("MD5_Final"); Md5Final((Md5*)md5, input); } - void CyaSSL_SHA_Init(CYASSL_SHA_CTX* sha) + void wolfSSL_SHA_Init(WOLFSSL_SHA_CTX* sha) { typedef char sha_test[sizeof(SHA_CTX) >= sizeof(Sha) ? 1 : -1]; (void)sizeof(sha_test); - CYASSL_ENTER("SHA_Init"); + WOLFSSL_ENTER("SHA_Init"); InitSha((Sha*)sha); /* OpenSSL compat, no ret */ } - void CyaSSL_SHA_Update(CYASSL_SHA_CTX* sha, const void* input, + void wolfSSL_SHA_Update(WOLFSSL_SHA_CTX* sha, const void* input, unsigned long sz) { - CYASSL_ENTER("SHA_Update"); + WOLFSSL_ENTER("SHA_Update"); ShaUpdate((Sha*)sha, (const byte*)input, (word32)sz); } - void CyaSSL_SHA_Final(byte* input, CYASSL_SHA_CTX* sha) + void wolfSSL_SHA_Final(byte* input, WOLFSSL_SHA_CTX* sha) { - CYASSL_ENTER("SHA_Final"); + WOLFSSL_ENTER("SHA_Final"); ShaFinal((Sha*)sha, input); } - void CyaSSL_SHA1_Init(CYASSL_SHA_CTX* sha) + void wolfSSL_SHA1_Init(WOLFSSL_SHA_CTX* sha) { - CYASSL_ENTER("SHA1_Init"); + WOLFSSL_ENTER("SHA1_Init"); SHA_Init(sha); } - void CyaSSL_SHA1_Update(CYASSL_SHA_CTX* sha, const void* input, + void wolfSSL_SHA1_Update(WOLFSSL_SHA_CTX* sha, const void* input, unsigned long sz) { - CYASSL_ENTER("SHA1_Update"); + WOLFSSL_ENTER("SHA1_Update"); SHA_Update(sha, input, sz); } - void CyaSSL_SHA1_Final(byte* input, CYASSL_SHA_CTX* sha) + void wolfSSL_SHA1_Final(byte* input, WOLFSSL_SHA_CTX* sha) { - CYASSL_ENTER("SHA1_Final"); + WOLFSSL_ENTER("SHA1_Final"); SHA_Final(input, sha); } - void CyaSSL_SHA256_Init(CYASSL_SHA256_CTX* sha256) + void wolfSSL_SHA256_Init(WOLFSSL_SHA256_CTX* sha256) { typedef char sha_test[sizeof(SHA256_CTX) >= sizeof(Sha256) ? 1 : -1]; (void)sizeof(sha_test); - CYASSL_ENTER("SHA256_Init"); + WOLFSSL_ENTER("SHA256_Init"); InitSha256((Sha256*)sha256); /* OpenSSL compat, no error */ } - void CyaSSL_SHA256_Update(CYASSL_SHA256_CTX* sha, const void* input, + void wolfSSL_SHA256_Update(WOLFSSL_SHA256_CTX* sha, const void* input, unsigned long sz) { - CYASSL_ENTER("SHA256_Update"); + WOLFSSL_ENTER("SHA256_Update"); Sha256Update((Sha256*)sha, (const byte*)input, (word32)sz); /* OpenSSL compat, no error */ } - void CyaSSL_SHA256_Final(byte* input, CYASSL_SHA256_CTX* sha) + void wolfSSL_SHA256_Final(byte* input, WOLFSSL_SHA256_CTX* sha) { - CYASSL_ENTER("SHA256_Final"); + WOLFSSL_ENTER("SHA256_Final"); Sha256Final((Sha256*)sha, input); /* OpenSSL compat, no error */ } - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 - void CyaSSL_SHA384_Init(CYASSL_SHA384_CTX* sha) + void wolfSSL_SHA384_Init(WOLFSSL_SHA384_CTX* sha) { typedef char sha_test[sizeof(SHA384_CTX) >= sizeof(Sha384) ? 1 : -1]; (void)sizeof(sha_test); - CYASSL_ENTER("SHA384_Init"); + WOLFSSL_ENTER("SHA384_Init"); InitSha384((Sha384*)sha); /* OpenSSL compat, no error */ } - void CyaSSL_SHA384_Update(CYASSL_SHA384_CTX* sha, const void* input, + void wolfSSL_SHA384_Update(WOLFSSL_SHA384_CTX* sha, const void* input, unsigned long sz) { - CYASSL_ENTER("SHA384_Update"); + WOLFSSL_ENTER("SHA384_Update"); Sha384Update((Sha384*)sha, (const byte*)input, (word32)sz); /* OpenSSL compat, no error */ } - void CyaSSL_SHA384_Final(byte* input, CYASSL_SHA384_CTX* sha) + void wolfSSL_SHA384_Final(byte* input, WOLFSSL_SHA384_CTX* sha) { - CYASSL_ENTER("SHA384_Final"); + WOLFSSL_ENTER("SHA384_Final"); Sha384Final((Sha384*)sha, input); /* OpenSSL compat, no error */ } - #endif /* CYASSL_SHA384 */ + #endif /* WOLFSSL_SHA384 */ - #ifdef CYASSL_SHA512 + #ifdef WOLFSSL_SHA512 - void CyaSSL_SHA512_Init(CYASSL_SHA512_CTX* sha) + void wolfSSL_SHA512_Init(WOLFSSL_SHA512_CTX* sha) { typedef char sha_test[sizeof(SHA512_CTX) >= sizeof(Sha512) ? 1 : -1]; (void)sizeof(sha_test); - CYASSL_ENTER("SHA512_Init"); + WOLFSSL_ENTER("SHA512_Init"); InitSha512((Sha512*)sha); /* OpenSSL compat, no error */ } - void CyaSSL_SHA512_Update(CYASSL_SHA512_CTX* sha, const void* input, + void wolfSSL_SHA512_Update(WOLFSSL_SHA512_CTX* sha, const void* input, unsigned long sz) { - CYASSL_ENTER("SHA512_Update"); + WOLFSSL_ENTER("SHA512_Update"); Sha512Update((Sha512*)sha, (const byte*)input, (word32)sz); /* OpenSSL compat, no error */ } - void CyaSSL_SHA512_Final(byte* input, CYASSL_SHA512_CTX* sha) + void wolfSSL_SHA512_Final(byte* input, WOLFSSL_SHA512_CTX* sha) { - CYASSL_ENTER("SHA512_Final"); + WOLFSSL_ENTER("SHA512_Final"); Sha512Final((Sha512*)sha, input); /* OpenSSL compat, no error */ } - #endif /* CYASSL_SHA512 */ + #endif /* WOLFSSL_SHA512 */ - const CYASSL_EVP_MD* CyaSSL_EVP_md5(void) + const WOLFSSL_EVP_MD* wolfSSL_EVP_md5(void) { static const char* type = "MD5"; - CYASSL_ENTER("EVP_md5"); + WOLFSSL_ENTER("EVP_md5"); return type; } - const CYASSL_EVP_MD* CyaSSL_EVP_sha1(void) + const WOLFSSL_EVP_MD* wolfSSL_EVP_sha1(void) { static const char* type = "SHA"; - CYASSL_ENTER("EVP_sha1"); + WOLFSSL_ENTER("EVP_sha1"); return type; } - const CYASSL_EVP_MD* CyaSSL_EVP_sha256(void) + const WOLFSSL_EVP_MD* wolfSSL_EVP_sha256(void) { static const char* type = "SHA256"; - CYASSL_ENTER("EVP_sha256"); + WOLFSSL_ENTER("EVP_sha256"); return type; } - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 - const CYASSL_EVP_MD* CyaSSL_EVP_sha384(void) + const WOLFSSL_EVP_MD* wolfSSL_EVP_sha384(void) { static const char* type = "SHA384"; - CYASSL_ENTER("EVP_sha384"); + WOLFSSL_ENTER("EVP_sha384"); return type; } - #endif /* CYASSL_SHA384 */ + #endif /* WOLFSSL_SHA384 */ - #ifdef CYASSL_SHA512 + #ifdef WOLFSSL_SHA512 - const CYASSL_EVP_MD* CyaSSL_EVP_sha512(void) + const WOLFSSL_EVP_MD* wolfSSL_EVP_sha512(void) { static const char* type = "SHA512"; - CYASSL_ENTER("EVP_sha512"); + WOLFSSL_ENTER("EVP_sha512"); return type; } - #endif /* CYASSL_SHA512 */ + #endif /* WOLFSSL_SHA512 */ - void CyaSSL_EVP_MD_CTX_init(CYASSL_EVP_MD_CTX* ctx) + void wolfSSL_EVP_MD_CTX_init(WOLFSSL_EVP_MD_CTX* ctx) { - CYASSL_ENTER("EVP_CIPHER_MD_CTX_init"); + WOLFSSL_ENTER("EVP_CIPHER_MD_CTX_init"); (void)ctx; /* do nothing */ } - const CYASSL_EVP_CIPHER* CyaSSL_EVP_aes_128_cbc(void) + const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_128_cbc(void) { static const char* type = "AES128-CBC"; - CYASSL_ENTER("CyaSSL_EVP_aes_128_cbc"); + WOLFSSL_ENTER("wolfSSL_EVP_aes_128_cbc"); return type; } - const CYASSL_EVP_CIPHER* CyaSSL_EVP_aes_192_cbc(void) + const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_192_cbc(void) { static const char* type = "AES192-CBC"; - CYASSL_ENTER("CyaSSL_EVP_aes_192_cbc"); + WOLFSSL_ENTER("wolfSSL_EVP_aes_192_cbc"); return type; } - const CYASSL_EVP_CIPHER* CyaSSL_EVP_aes_256_cbc(void) + const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_256_cbc(void) { static const char* type = "AES256-CBC"; - CYASSL_ENTER("CyaSSL_EVP_aes_256_cbc"); + WOLFSSL_ENTER("wolfSSL_EVP_aes_256_cbc"); return type; } - const CYASSL_EVP_CIPHER* CyaSSL_EVP_aes_128_ctr(void) + const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_128_ctr(void) { static const char* type = "AES128-CTR"; - CYASSL_ENTER("CyaSSL_EVP_aes_128_ctr"); + WOLFSSL_ENTER("wolfSSL_EVP_aes_128_ctr"); return type; } - const CYASSL_EVP_CIPHER* CyaSSL_EVP_aes_192_ctr(void) + const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_192_ctr(void) { static const char* type = "AES192-CTR"; - CYASSL_ENTER("CyaSSL_EVP_aes_192_ctr"); + WOLFSSL_ENTER("wolfSSL_EVP_aes_192_ctr"); return type; } - const CYASSL_EVP_CIPHER* CyaSSL_EVP_aes_256_ctr(void) + const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_aes_256_ctr(void) { static const char* type = "AES256-CTR"; - CYASSL_ENTER("CyaSSL_EVP_aes_256_ctr"); + WOLFSSL_ENTER("wolfSSL_EVP_aes_256_ctr"); return type; } - const CYASSL_EVP_CIPHER* CyaSSL_EVP_des_cbc(void) + const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_cbc(void) { static const char* type = "DES-CBC"; - CYASSL_ENTER("CyaSSL_EVP_des_cbc"); + WOLFSSL_ENTER("wolfSSL_EVP_des_cbc"); return type; } - const CYASSL_EVP_CIPHER* CyaSSL_EVP_des_ede3_cbc(void) + const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_des_ede3_cbc(void) { static const char* type = "DES-EDE3-CBC"; - CYASSL_ENTER("CyaSSL_EVP_des_ede3_cbc"); + WOLFSSL_ENTER("wolfSSL_EVP_des_ede3_cbc"); return type; } - const CYASSL_EVP_CIPHER* CyaSSL_EVP_rc4(void) + const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_rc4(void) { static const char* type = "ARC4"; - CYASSL_ENTER("CyaSSL_EVP_rc4"); + WOLFSSL_ENTER("wolfSSL_EVP_rc4"); return type; } - const CYASSL_EVP_CIPHER* CyaSSL_EVP_enc_null(void) + const WOLFSSL_EVP_CIPHER* wolfSSL_EVP_enc_null(void) { static const char* type = "NULL"; - CYASSL_ENTER("CyaSSL_EVP_enc_null"); + WOLFSSL_ENTER("wolfSSL_EVP_enc_null"); return type; } - int CyaSSL_EVP_MD_CTX_cleanup(CYASSL_EVP_MD_CTX* ctx) + int wolfSSL_EVP_MD_CTX_cleanup(WOLFSSL_EVP_MD_CTX* ctx) { - CYASSL_ENTER("EVP_MD_CTX_cleanup"); + WOLFSSL_ENTER("EVP_MD_CTX_cleanup"); (void)ctx; return 0; } - void CyaSSL_EVP_CIPHER_CTX_init(CYASSL_EVP_CIPHER_CTX* ctx) + void wolfSSL_EVP_CIPHER_CTX_init(WOLFSSL_EVP_CIPHER_CTX* ctx) { - CYASSL_ENTER("EVP_CIPHER_CTX_init"); + WOLFSSL_ENTER("EVP_CIPHER_CTX_init"); if (ctx) { ctx->cipherType = 0xff; /* no init */ ctx->keyLen = 0; @@ -7378,9 +7378,9 @@ int CyaSSL_set_compression(CYASSL* ssl) /* SSL_SUCCESS on ok */ - int CyaSSL_EVP_CIPHER_CTX_cleanup(CYASSL_EVP_CIPHER_CTX* ctx) + int wolfSSL_EVP_CIPHER_CTX_cleanup(WOLFSSL_EVP_CIPHER_CTX* ctx) { - CYASSL_ENTER("EVP_CIPHER_CTX_cleanup"); + WOLFSSL_ENTER("EVP_CIPHER_CTX_cleanup"); if (ctx) { ctx->cipherType = 0xff; /* no more init */ ctx->keyLen = 0; @@ -7391,26 +7391,26 @@ int CyaSSL_set_compression(CYASSL* ssl) /* SSL_SUCCESS on ok */ - int CyaSSL_EVP_CipherInit(CYASSL_EVP_CIPHER_CTX* ctx, - const CYASSL_EVP_CIPHER* type, byte* key, + int wolfSSL_EVP_CipherInit(WOLFSSL_EVP_CIPHER_CTX* ctx, + const WOLFSSL_EVP_CIPHER* type, byte* key, byte* iv, int enc) { int ret = 0; - CYASSL_ENTER("CyaSSL_EVP_CipherInit"); + WOLFSSL_ENTER("wolfSSL_EVP_CipherInit"); if (ctx == NULL) { - CYASSL_MSG("no ctx"); + WOLFSSL_MSG("no ctx"); return 0; /* failure */ } if (type == NULL && ctx->cipherType == 0xff) { - CYASSL_MSG("no type set"); + WOLFSSL_MSG("no type set"); return 0; /* failure */ } if (ctx->cipherType == AES_128_CBC_TYPE || (type && XSTRNCMP(type, "AES128-CBC", 10) == 0)) { - CYASSL_MSG("AES-128-CBC"); + WOLFSSL_MSG("AES-128-CBC"); ctx->cipherType = AES_128_CBC_TYPE; ctx->keyLen = 16; if (enc == 0 || enc == 1) @@ -7429,7 +7429,7 @@ int CyaSSL_set_compression(CYASSL* ssl) } else if (ctx->cipherType == AES_192_CBC_TYPE || (type && XSTRNCMP(type, "AES192-CBC", 10) == 0)) { - CYASSL_MSG("AES-192-CBC"); + WOLFSSL_MSG("AES-192-CBC"); ctx->cipherType = AES_192_CBC_TYPE; ctx->keyLen = 24; if (enc == 0 || enc == 1) @@ -7448,7 +7448,7 @@ int CyaSSL_set_compression(CYASSL* ssl) } else if (ctx->cipherType == AES_256_CBC_TYPE || (type && XSTRNCMP(type, "AES256-CBC", 10) == 0)) { - CYASSL_MSG("AES-256-CBC"); + WOLFSSL_MSG("AES-256-CBC"); ctx->cipherType = AES_256_CBC_TYPE; ctx->keyLen = 32; if (enc == 0 || enc == 1) @@ -7465,10 +7465,10 @@ int CyaSSL_set_compression(CYASSL* ssl) return ret; } } -#ifdef CYASSL_AES_COUNTER +#ifdef WOLFSSL_AES_COUNTER else if (ctx->cipherType == AES_128_CTR_TYPE || (type && XSTRNCMP(type, "AES128-CTR", 10) == 0)) { - CYASSL_MSG("AES-128-CTR"); + WOLFSSL_MSG("AES-128-CTR"); ctx->cipherType = AES_128_CTR_TYPE; ctx->keyLen = 16; if (enc == 0 || enc == 1) @@ -7487,7 +7487,7 @@ int CyaSSL_set_compression(CYASSL* ssl) } else if (ctx->cipherType == AES_192_CTR_TYPE || (type && XSTRNCMP(type, "AES192-CTR", 10) == 0)) { - CYASSL_MSG("AES-192-CTR"); + WOLFSSL_MSG("AES-192-CTR"); ctx->cipherType = AES_192_CTR_TYPE; ctx->keyLen = 24; if (enc == 0 || enc == 1) @@ -7506,7 +7506,7 @@ int CyaSSL_set_compression(CYASSL* ssl) } else if (ctx->cipherType == AES_256_CTR_TYPE || (type && XSTRNCMP(type, "AES256-CTR", 10) == 0)) { - CYASSL_MSG("AES-256-CTR"); + WOLFSSL_MSG("AES-256-CTR"); ctx->cipherType = AES_256_CTR_TYPE; ctx->keyLen = 32; if (enc == 0 || enc == 1) @@ -7523,10 +7523,10 @@ int CyaSSL_set_compression(CYASSL* ssl) return ret; } } -#endif /* CYASSL_AES_CTR */ +#endif /* WOLFSSL_AES_CTR */ else if (ctx->cipherType == DES_CBC_TYPE || (type && XSTRNCMP(type, "DES-CBC", 7) == 0)) { - CYASSL_MSG("DES-CBC"); + WOLFSSL_MSG("DES-CBC"); ctx->cipherType = DES_CBC_TYPE; ctx->keyLen = 8; if (enc == 0 || enc == 1) @@ -7543,7 +7543,7 @@ int CyaSSL_set_compression(CYASSL* ssl) } else if (ctx->cipherType == DES_EDE3_CBC_TYPE || (type && XSTRNCMP(type, "DES-EDE3-CBC", 11) == 0)) { - CYASSL_MSG("DES-EDE3-CBC"); + WOLFSSL_MSG("DES-EDE3-CBC"); ctx->cipherType = DES_EDE3_CBC_TYPE; ctx->keyLen = 24; if (enc == 0 || enc == 1) @@ -7563,7 +7563,7 @@ int CyaSSL_set_compression(CYASSL* ssl) } else if (ctx->cipherType == ARC4_TYPE || (type && XSTRNCMP(type, "ARC4", 4) == 0)) { - CYASSL_MSG("ARC4"); + WOLFSSL_MSG("ARC4"); ctx->cipherType = ARC4_TYPE; if (ctx->keyLen == 0) /* user may have already set */ ctx->keyLen = 16; /* default to 128 */ @@ -7572,7 +7572,7 @@ int CyaSSL_set_compression(CYASSL* ssl) } else if (ctx->cipherType == NULL_CIPHER_TYPE || (type && XSTRNCMP(type, "NULL", 4) == 0)) { - CYASSL_MSG("NULL cipher"); + WOLFSSL_MSG("NULL cipher"); ctx->cipherType = NULL_CIPHER_TYPE; ctx->keyLen = 0; } @@ -7585,9 +7585,9 @@ int CyaSSL_set_compression(CYASSL* ssl) /* SSL_SUCCESS on ok */ - int CyaSSL_EVP_CIPHER_CTX_key_length(CYASSL_EVP_CIPHER_CTX* ctx) + int wolfSSL_EVP_CIPHER_CTX_key_length(WOLFSSL_EVP_CIPHER_CTX* ctx) { - CYASSL_ENTER("CyaSSL_EVP_CIPHER_CTX_key_length"); + WOLFSSL_ENTER("wolfSSL_EVP_CIPHER_CTX_key_length"); if (ctx) return ctx->keyLen; @@ -7596,10 +7596,10 @@ int CyaSSL_set_compression(CYASSL* ssl) /* SSL_SUCCESS on ok */ - int CyaSSL_EVP_CIPHER_CTX_set_key_length(CYASSL_EVP_CIPHER_CTX* ctx, + int wolfSSL_EVP_CIPHER_CTX_set_key_length(WOLFSSL_EVP_CIPHER_CTX* ctx, int keylen) { - CYASSL_ENTER("CyaSSL_EVP_CIPHER_CTX_set_key_length"); + WOLFSSL_ENTER("wolfSSL_EVP_CIPHER_CTX_set_key_length"); if (ctx) ctx->keyLen = keylen; else @@ -7610,19 +7610,19 @@ int CyaSSL_set_compression(CYASSL* ssl) /* SSL_SUCCESS on ok */ - int CyaSSL_EVP_Cipher(CYASSL_EVP_CIPHER_CTX* ctx, byte* dst, byte* src, + int wolfSSL_EVP_Cipher(WOLFSSL_EVP_CIPHER_CTX* ctx, byte* dst, byte* src, word32 len) { int ret = 0; - CYASSL_ENTER("CyaSSL_EVP_Cipher"); + WOLFSSL_ENTER("wolfSSL_EVP_Cipher"); if (ctx == NULL || dst == NULL || src == NULL) { - CYASSL_MSG("Bad function argument"); + WOLFSSL_MSG("Bad function argument"); return 0; /* failure */ } if (ctx->cipherType == 0xff) { - CYASSL_MSG("no init"); + WOLFSSL_MSG("no init"); return 0; /* failure */ } @@ -7631,18 +7631,18 @@ int CyaSSL_set_compression(CYASSL* ssl) case AES_128_CBC_TYPE : case AES_192_CBC_TYPE : case AES_256_CBC_TYPE : - CYASSL_MSG("AES CBC"); + WOLFSSL_MSG("AES CBC"); if (ctx->enc) ret = AesCbcEncrypt(&ctx->cipher.aes, dst, src, len); else ret = AesCbcDecrypt(&ctx->cipher.aes, dst, src, len); break; -#ifdef CYASSL_AES_COUNTER +#ifdef WOLFSSL_AES_COUNTER case AES_128_CTR_TYPE : case AES_192_CTR_TYPE : case AES_256_CTR_TYPE : - CYASSL_MSG("AES CTR"); + WOLFSSL_MSG("AES CTR"); AesCtrEncrypt(&ctx->cipher.aes, dst, src, len); break; #endif @@ -7670,28 +7670,28 @@ int CyaSSL_set_compression(CYASSL* ssl) break; default: { - CYASSL_MSG("bad type"); + WOLFSSL_MSG("bad type"); return 0; /* failure */ } } if (ret != 0) { - CYASSL_MSG("CyaSSL_EVP_Cipher failure"); + WOLFSSL_MSG("wolfSSL_EVP_Cipher failure"); return 0; /* failuer */ } - CYASSL_MSG("CyaSSL_EVP_Cipher success"); + WOLFSSL_MSG("wolfSSL_EVP_Cipher success"); return SSL_SUCCESS; /* success */ } /* store for external read of iv, SSL_SUCCESS on success */ - int CyaSSL_StoreExternalIV(CYASSL_EVP_CIPHER_CTX* ctx) + int wolfSSL_StoreExternalIV(WOLFSSL_EVP_CIPHER_CTX* ctx) { - CYASSL_ENTER("CyaSSL_StoreExternalIV"); + WOLFSSL_ENTER("wolfSSL_StoreExternalIV"); if (ctx == NULL) { - CYASSL_MSG("Bad function argument"); + WOLFSSL_MSG("Bad function argument"); return SSL_FATAL_ERROR; } @@ -7700,39 +7700,39 @@ int CyaSSL_set_compression(CYASSL* ssl) case AES_128_CBC_TYPE : case AES_192_CBC_TYPE : case AES_256_CBC_TYPE : - CYASSL_MSG("AES CBC"); + WOLFSSL_MSG("AES CBC"); memcpy(ctx->iv, &ctx->cipher.aes.reg, AES_BLOCK_SIZE); break; -#ifdef CYASSL_AES_COUNTER +#ifdef WOLFSSL_AES_COUNTER case AES_128_CTR_TYPE : case AES_192_CTR_TYPE : case AES_256_CTR_TYPE : - CYASSL_MSG("AES CTR"); + WOLFSSL_MSG("AES CTR"); memcpy(ctx->iv, &ctx->cipher.aes.reg, AES_BLOCK_SIZE); break; #endif case DES_CBC_TYPE : - CYASSL_MSG("DES CBC"); + WOLFSSL_MSG("DES CBC"); memcpy(ctx->iv, &ctx->cipher.des.reg, DES_BLOCK_SIZE); break; case DES_EDE3_CBC_TYPE : - CYASSL_MSG("DES EDE3 CBC"); + WOLFSSL_MSG("DES EDE3 CBC"); memcpy(ctx->iv, &ctx->cipher.des.reg, DES_BLOCK_SIZE); break; case ARC4_TYPE : - CYASSL_MSG("ARC4"); + WOLFSSL_MSG("ARC4"); break; case NULL_CIPHER_TYPE : - CYASSL_MSG("NULL"); + WOLFSSL_MSG("NULL"); break; default: { - CYASSL_MSG("bad type"); + WOLFSSL_MSG("bad type"); return SSL_FATAL_ERROR; } } @@ -7741,13 +7741,13 @@ int CyaSSL_set_compression(CYASSL* ssl) /* set internal IV from external, SSL_SUCCESS on success */ - int CyaSSL_SetInternalIV(CYASSL_EVP_CIPHER_CTX* ctx) + int wolfSSL_SetInternalIV(WOLFSSL_EVP_CIPHER_CTX* ctx) { - CYASSL_ENTER("CyaSSL_SetInternalIV"); + WOLFSSL_ENTER("wolfSSL_SetInternalIV"); if (ctx == NULL) { - CYASSL_MSG("Bad function argument"); + WOLFSSL_MSG("Bad function argument"); return SSL_FATAL_ERROR; } @@ -7756,39 +7756,39 @@ int CyaSSL_set_compression(CYASSL* ssl) case AES_128_CBC_TYPE : case AES_192_CBC_TYPE : case AES_256_CBC_TYPE : - CYASSL_MSG("AES CBC"); + WOLFSSL_MSG("AES CBC"); memcpy(&ctx->cipher.aes.reg, ctx->iv, AES_BLOCK_SIZE); break; -#ifdef CYASSL_AES_COUNTER +#ifdef WOLFSSL_AES_COUNTER case AES_128_CTR_TYPE : case AES_192_CTR_TYPE : case AES_256_CTR_TYPE : - CYASSL_MSG("AES CTR"); + WOLFSSL_MSG("AES CTR"); memcpy(&ctx->cipher.aes.reg, ctx->iv, AES_BLOCK_SIZE); break; #endif case DES_CBC_TYPE : - CYASSL_MSG("DES CBC"); + WOLFSSL_MSG("DES CBC"); memcpy(&ctx->cipher.des.reg, ctx->iv, DES_BLOCK_SIZE); break; case DES_EDE3_CBC_TYPE : - CYASSL_MSG("DES EDE3 CBC"); + WOLFSSL_MSG("DES EDE3 CBC"); memcpy(&ctx->cipher.des.reg, ctx->iv, DES_BLOCK_SIZE); break; case ARC4_TYPE : - CYASSL_MSG("ARC4"); + WOLFSSL_MSG("ARC4"); break; case NULL_CIPHER_TYPE : - CYASSL_MSG("NULL"); + WOLFSSL_MSG("NULL"); break; default: { - CYASSL_MSG("bad type"); + WOLFSSL_MSG("bad type"); return SSL_FATAL_ERROR; } } @@ -7797,33 +7797,33 @@ int CyaSSL_set_compression(CYASSL* ssl) /* SSL_SUCCESS on ok */ - int CyaSSL_EVP_DigestInit(CYASSL_EVP_MD_CTX* ctx, const CYASSL_EVP_MD* type) + int wolfSSL_EVP_DigestInit(WOLFSSL_EVP_MD_CTX* ctx, const WOLFSSL_EVP_MD* type) { - CYASSL_ENTER("EVP_DigestInit"); + WOLFSSL_ENTER("EVP_DigestInit"); if (XSTRNCMP(type, "MD5", 3) == 0) { ctx->macType = MD5; - CyaSSL_MD5_Init((MD5_CTX*)&ctx->hash); + wolfSSL_MD5_Init((MD5_CTX*)&ctx->hash); } else if (XSTRNCMP(type, "SHA256", 6) == 0) { ctx->macType = SHA256; - CyaSSL_SHA256_Init((SHA256_CTX*)&ctx->hash); + wolfSSL_SHA256_Init((SHA256_CTX*)&ctx->hash); } - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 else if (XSTRNCMP(type, "SHA384", 6) == 0) { ctx->macType = SHA384; - CyaSSL_SHA384_Init((SHA384_CTX*)&ctx->hash); + wolfSSL_SHA384_Init((SHA384_CTX*)&ctx->hash); } #endif - #ifdef CYASSL_SHA512 + #ifdef WOLFSSL_SHA512 else if (XSTRNCMP(type, "SHA512", 6) == 0) { ctx->macType = SHA512; - CyaSSL_SHA512_Init((SHA512_CTX*)&ctx->hash); + wolfSSL_SHA512_Init((SHA512_CTX*)&ctx->hash); } #endif /* has to be last since would pick or 256, 384, or 512 too */ else if (XSTRNCMP(type, "SHA", 3) == 0) { ctx->macType = SHA; - CyaSSL_SHA_Init((SHA_CTX*)&ctx->hash); + wolfSSL_SHA_Init((SHA_CTX*)&ctx->hash); } else return BAD_FUNC_ARG; @@ -7833,25 +7833,25 @@ int CyaSSL_set_compression(CYASSL* ssl) /* SSL_SUCCESS on ok */ - int CyaSSL_EVP_DigestUpdate(CYASSL_EVP_MD_CTX* ctx, const void* data, + int wolfSSL_EVP_DigestUpdate(WOLFSSL_EVP_MD_CTX* ctx, const void* data, unsigned long sz) { - CYASSL_ENTER("EVP_DigestUpdate"); + WOLFSSL_ENTER("EVP_DigestUpdate"); if (ctx->macType == MD5) - CyaSSL_MD5_Update((MD5_CTX*)&ctx->hash, data, (unsigned long)sz); + wolfSSL_MD5_Update((MD5_CTX*)&ctx->hash, data, (unsigned long)sz); else if (ctx->macType == SHA) - CyaSSL_SHA_Update((SHA_CTX*)&ctx->hash, data, (unsigned long)sz); + wolfSSL_SHA_Update((SHA_CTX*)&ctx->hash, data, (unsigned long)sz); else if (ctx->macType == SHA256) - CyaSSL_SHA256_Update((SHA256_CTX*)&ctx->hash, data, + wolfSSL_SHA256_Update((SHA256_CTX*)&ctx->hash, data, (unsigned long)sz); - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 else if (ctx->macType == SHA384) - CyaSSL_SHA384_Update((SHA384_CTX*)&ctx->hash, data, + wolfSSL_SHA384_Update((SHA384_CTX*)&ctx->hash, data, (unsigned long)sz); #endif - #ifdef CYASSL_SHA512 + #ifdef WOLFSSL_SHA512 else if (ctx->macType == SHA512) - CyaSSL_SHA512_Update((SHA512_CTX*)&ctx->hash, data, + wolfSSL_SHA512_Update((SHA512_CTX*)&ctx->hash, data, (unsigned long)sz); #endif else @@ -7862,31 +7862,31 @@ int CyaSSL_set_compression(CYASSL* ssl) /* SSL_SUCCESS on ok */ - int CyaSSL_EVP_DigestFinal(CYASSL_EVP_MD_CTX* ctx, unsigned char* md, + int wolfSSL_EVP_DigestFinal(WOLFSSL_EVP_MD_CTX* ctx, unsigned char* md, unsigned int* s) { - CYASSL_ENTER("EVP_DigestFinal"); + WOLFSSL_ENTER("EVP_DigestFinal"); if (ctx->macType == MD5) { - CyaSSL_MD5_Final(md, (MD5_CTX*)&ctx->hash); + wolfSSL_MD5_Final(md, (MD5_CTX*)&ctx->hash); if (s) *s = MD5_DIGEST_SIZE; } else if (ctx->macType == SHA) { - CyaSSL_SHA_Final(md, (SHA_CTX*)&ctx->hash); + wolfSSL_SHA_Final(md, (SHA_CTX*)&ctx->hash); if (s) *s = SHA_DIGEST_SIZE; } else if (ctx->macType == SHA256) { - CyaSSL_SHA256_Final(md, (SHA256_CTX*)&ctx->hash); + wolfSSL_SHA256_Final(md, (SHA256_CTX*)&ctx->hash); if (s) *s = SHA256_DIGEST_SIZE; } - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 else if (ctx->macType == SHA384) { - CyaSSL_SHA384_Final(md, (SHA384_CTX*)&ctx->hash); + wolfSSL_SHA384_Final(md, (SHA384_CTX*)&ctx->hash); if (s) *s = SHA384_DIGEST_SIZE; } #endif - #ifdef CYASSL_SHA512 + #ifdef WOLFSSL_SHA512 else if (ctx->macType == SHA512) { - CyaSSL_SHA512_Final(md, (SHA512_CTX*)&ctx->hash); + wolfSSL_SHA512_Final(md, (SHA512_CTX*)&ctx->hash); if (s) *s = SHA512_DIGEST_SIZE; } #endif @@ -7898,27 +7898,27 @@ int CyaSSL_set_compression(CYASSL* ssl) /* SSL_SUCCESS on ok */ - int CyaSSL_EVP_DigestFinal_ex(CYASSL_EVP_MD_CTX* ctx, unsigned char* md, + int wolfSSL_EVP_DigestFinal_ex(WOLFSSL_EVP_MD_CTX* ctx, unsigned char* md, unsigned int* s) { - CYASSL_ENTER("EVP_DigestFinal_ex"); + WOLFSSL_ENTER("EVP_DigestFinal_ex"); return EVP_DigestFinal(ctx, md, s); } - unsigned char* CyaSSL_HMAC(const CYASSL_EVP_MD* evp_md, const void* key, + unsigned char* wolfSSL_HMAC(const WOLFSSL_EVP_MD* evp_md, const void* key, int key_len, const unsigned char* d, int n, unsigned char* md, unsigned int* md_len) { int type; unsigned char* ret = NULL; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK Hmac* hmac = NULL; #else Hmac hmac[1]; #endif - CYASSL_ENTER("HMAC"); + WOLFSSL_ENTER("HMAC"); if (!md) return NULL; /* no static buffer support */ @@ -7929,7 +7929,7 @@ int CyaSSL_set_compression(CYASSL* ssl) else return NULL; - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK hmac = (Hmac*)XMALLOC(sizeof(Hmac), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (hmac == NULL) return NULL; @@ -7944,55 +7944,55 @@ int CyaSSL_set_compression(CYASSL* ssl) ret = md; } - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(hmac, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; } - void CyaSSL_ERR_clear_error(void) + void wolfSSL_ERR_clear_error(void) { /* TODO: */ } - int CyaSSL_RAND_status(void) + int wolfSSL_RAND_status(void) { - return SSL_SUCCESS; /* CTaoCrypt provides enough seed internally */ + return SSL_SUCCESS; /* wolfCrypt provides enough seed internally */ } - void CyaSSL_RAND_add(const void* add, int len, double entropy) + void wolfSSL_RAND_add(const void* add, int len, double entropy) { (void)add; (void)len; (void)entropy; - /* CyaSSL seeds/adds internally, use explicit RNG if you want + /* wolfSSL seeds/adds internally, use explicit RNG if you want to take control */ } /* SSL_SUCCESS on ok */ - int CyaSSL_DES_key_sched(CYASSL_const_DES_cblock* key, - CYASSL_DES_key_schedule* schedule) + int wolfSSL_DES_key_sched(WOLFSSL_const_DES_cblock* key, + WOLFSSL_DES_key_schedule* schedule) { - CYASSL_ENTER("DES_key_sched"); + WOLFSSL_ENTER("DES_key_sched"); XMEMCPY(schedule, key, sizeof(const_DES_cblock)); return SSL_SUCCESS; } - void CyaSSL_DES_cbc_encrypt(const unsigned char* input, + void wolfSSL_DES_cbc_encrypt(const unsigned char* input, unsigned char* output, long length, - CYASSL_DES_key_schedule* schedule, CYASSL_DES_cblock* ivec, + WOLFSSL_DES_key_schedule* schedule, WOLFSSL_DES_cblock* ivec, int enc) { Des myDes; - CYASSL_ENTER("DES_cbc_encrypt"); + WOLFSSL_ENTER("DES_cbc_encrypt"); /* OpenSSL compat, no ret */ Des_SetKey(&myDes, (const byte*)schedule, (const byte*)ivec, !enc); @@ -8005,14 +8005,14 @@ int CyaSSL_set_compression(CYASSL* ssl) /* correctly sets ivec for next call */ - void CyaSSL_DES_ncbc_encrypt(const unsigned char* input, + void wolfSSL_DES_ncbc_encrypt(const unsigned char* input, unsigned char* output, long length, - CYASSL_DES_key_schedule* schedule, CYASSL_DES_cblock* ivec, + WOLFSSL_DES_key_schedule* schedule, WOLFSSL_DES_cblock* ivec, int enc) { Des myDes; - CYASSL_ENTER("DES_ncbc_encrypt"); + WOLFSSL_ENTER("DES_ncbc_encrypt"); /* OpenSSL compat, no ret */ Des_SetKey(&myDes, (const byte*)schedule, (const byte*)ivec, !enc); @@ -8026,36 +8026,36 @@ int CyaSSL_set_compression(CYASSL* ssl) } - void CyaSSL_ERR_free_strings(void) + void wolfSSL_ERR_free_strings(void) { /* handled internally */ } - void CyaSSL_ERR_remove_state(unsigned long state) + void wolfSSL_ERR_remove_state(unsigned long state) { /* TODO: GetErrors().Remove(); */ (void)state; } - void CyaSSL_EVP_cleanup(void) + void wolfSSL_EVP_cleanup(void) { /* nothing to do here */ } - void CyaSSL_cleanup_all_ex_data(void) + void wolfSSL_cleanup_all_ex_data(void) { /* nothing to do here */ } - long CyaSSL_CTX_set_mode(CYASSL_CTX* ctx, long mode) + long wolfSSL_CTX_set_mode(WOLFSSL_CTX* ctx, long mode) { - /* SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER is CyaSSL default mode */ + /* SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER is wolfSSL default mode */ - CYASSL_ENTER("SSL_CTX_set_mode"); + WOLFSSL_ENTER("SSL_CTX_set_mode"); if (mode == SSL_MODE_ENABLE_PARTIAL_WRITE) ctx->partialWrite = 1; @@ -8063,7 +8063,7 @@ int CyaSSL_set_compression(CYASSL* ssl) } - long CyaSSL_CTX_get_mode(CYASSL_CTX* ctx) + long wolfSSL_CTX_get_mode(WOLFSSL_CTX* ctx) { /* TODO: */ (void)ctx; @@ -8071,7 +8071,7 @@ int CyaSSL_set_compression(CYASSL* ssl) } - void CyaSSL_CTX_set_default_read_ahead(CYASSL_CTX* ctx, int m) + void wolfSSL_CTX_set_default_read_ahead(WOLFSSL_CTX* ctx, int m) { /* TODO: maybe? */ (void)ctx; @@ -8079,11 +8079,11 @@ int CyaSSL_set_compression(CYASSL* ssl) } - int CyaSSL_CTX_set_session_id_context(CYASSL_CTX* ctx, + int wolfSSL_CTX_set_session_id_context(WOLFSSL_CTX* ctx, const unsigned char* sid_ctx, unsigned int sid_ctx_len) { - /* No application specific context needed for cyaSSL */ + /* No application specific context needed for wolfSSL */ (void)ctx; (void)sid_ctx; (void)sid_ctx_len; @@ -8091,14 +8091,14 @@ int CyaSSL_set_compression(CYASSL* ssl) } - long CyaSSL_CTX_sess_get_cache_size(CYASSL_CTX* ctx) + long wolfSSL_CTX_sess_get_cache_size(WOLFSSL_CTX* ctx) { /* TODO: maybe? */ (void)ctx; return (~0); } - unsigned long CyaSSL_ERR_get_error_line_data(const char** file, int* line, + unsigned long wolfSSL_ERR_get_error_line_data(const char** file, int* line, const char** data, int *flags) { /* Not implemented */ @@ -8114,9 +8114,9 @@ int CyaSSL_set_compression(CYASSL* ssl) #if defined(KEEP_PEER_CERT) - CYASSL_X509* CyaSSL_get_peer_certificate(CYASSL* ssl) + WOLFSSL_X509* wolfSSL_get_peer_certificate(WOLFSSL* ssl) { - CYASSL_ENTER("SSL_get_peer_certificate"); + WOLFSSL_ENTER("SSL_get_peer_certificate"); if (ssl->peerCert.issuer.sz) return &ssl->peerCert; else @@ -8128,18 +8128,18 @@ int CyaSSL_set_compression(CYASSL* ssl) #if defined(KEEP_PEER_CERT) || defined(SESSION_CERTS) - void CyaSSL_FreeX509(CYASSL_X509* x509) + void wolfSSL_FreeX509(WOLFSSL_X509* x509) { - CYASSL_ENTER("CyaSSL_FreeX509"); + WOLFSSL_ENTER("wolfSSL_FreeX509"); FreeX509(x509); } /* return the next, if any, altname from the peer cert */ - char* CyaSSL_X509_get_next_altname(CYASSL_X509* cert) + char* wolfSSL_X509_get_next_altname(WOLFSSL_X509* cert) { char* ret = NULL; - CYASSL_ENTER("CyaSSL_X509_get_next_altname"); + WOLFSSL_ENTER("wolfSSL_X509_get_next_altname"); /* don't have any to work with */ if (cert == NULL || cert->altNames == NULL) @@ -8156,41 +8156,41 @@ int CyaSSL_set_compression(CYASSL* ssl) } - CYASSL_X509_NAME* CyaSSL_X509_get_issuer_name(CYASSL_X509* cert) + WOLFSSL_X509_NAME* wolfSSL_X509_get_issuer_name(WOLFSSL_X509* cert) { - CYASSL_ENTER("X509_get_issuer_name"); + WOLFSSL_ENTER("X509_get_issuer_name"); return &cert->issuer; } - CYASSL_X509_NAME* CyaSSL_X509_get_subject_name(CYASSL_X509* cert) + WOLFSSL_X509_NAME* wolfSSL_X509_get_subject_name(WOLFSSL_X509* cert) { - CYASSL_ENTER("X509_get_subject_name"); + WOLFSSL_ENTER("X509_get_subject_name"); return &cert->subject; } - int CyaSSL_X509_get_isCA(CYASSL_X509* x509) + int wolfSSL_X509_get_isCA(WOLFSSL_X509* x509) { int isCA = 0; - CYASSL_ENTER("CyaSSL_X509_get_isCA"); + WOLFSSL_ENTER("wolfSSL_X509_get_isCA"); if (x509 != NULL) isCA = x509->isCa; - CYASSL_LEAVE("CyaSSL_X509_get_isCA", isCA); + WOLFSSL_LEAVE("wolfSSL_X509_get_isCA", isCA); return isCA; } #ifdef OPENSSL_EXTRA - int CyaSSL_X509_ext_isSet_by_NID(CYASSL_X509* x509, int nid) + int wolfSSL_X509_ext_isSet_by_NID(WOLFSSL_X509* x509, int nid) { int isSet = 0; - CYASSL_ENTER("CyaSSL_X509_ext_isSet_by_NID"); + WOLFSSL_ENTER("wolfSSL_X509_ext_isSet_by_NID"); if (x509 != NULL) { switch (nid) { @@ -8199,23 +8199,23 @@ int CyaSSL_set_compression(CYASSL* ssl) case AUTH_KEY_OID: isSet = x509->authKeyIdSet; break; case SUBJ_KEY_OID: isSet = x509->subjKeyIdSet; break; case KEY_USAGE_OID: isSet = x509->keyUsageSet; break; - #ifdef CYASSL_SEP + #ifdef WOLFSSL_SEP case CERT_POLICY_OID: isSet = x509->certPolicySet; break; - #endif /* CYASSL_SEP */ + #endif /* WOLFSSL_SEP */ } } - CYASSL_LEAVE("CyaSSL_X509_ext_isSet_by_NID", isSet); + WOLFSSL_LEAVE("wolfSSL_X509_ext_isSet_by_NID", isSet); return isSet; } - int CyaSSL_X509_ext_get_critical_by_NID(CYASSL_X509* x509, int nid) + int wolfSSL_X509_ext_get_critical_by_NID(WOLFSSL_X509* x509, int nid) { int crit = 0; - CYASSL_ENTER("CyaSSL_X509_ext_get_critical_by_NID"); + WOLFSSL_ENTER("wolfSSL_X509_ext_get_critical_by_NID"); if (x509 != NULL) { switch (nid) { @@ -8224,70 +8224,70 @@ int CyaSSL_set_compression(CYASSL* ssl) case AUTH_KEY_OID: crit = x509->authKeyIdCrit; break; case SUBJ_KEY_OID: crit = x509->subjKeyIdCrit; break; case KEY_USAGE_OID: crit = x509->keyUsageCrit; break; - #ifdef CYASSL_SEP + #ifdef WOLFSSL_SEP case CERT_POLICY_OID: crit = x509->certPolicyCrit; break; - #endif /* CYASSL_SEP */ + #endif /* WOLFSSL_SEP */ } } - CYASSL_LEAVE("CyaSSL_X509_ext_get_critical_by_NID", crit); + WOLFSSL_LEAVE("wolfSSL_X509_ext_get_critical_by_NID", crit); return crit; } - int CyaSSL_X509_get_isSet_pathLength(CYASSL_X509* x509) + int wolfSSL_X509_get_isSet_pathLength(WOLFSSL_X509* x509) { int isSet = 0; - CYASSL_ENTER("CyaSSL_X509_get_isSet_pathLength"); + WOLFSSL_ENTER("wolfSSL_X509_get_isSet_pathLength"); if (x509 != NULL) isSet = x509->basicConstPlSet; - CYASSL_LEAVE("CyaSSL_X509_get_isSet_pathLength", isSet); + WOLFSSL_LEAVE("wolfSSL_X509_get_isSet_pathLength", isSet); return isSet; } - word32 CyaSSL_X509_get_pathLength(CYASSL_X509* x509) + word32 wolfSSL_X509_get_pathLength(WOLFSSL_X509* x509) { word32 pathLength = 0; - CYASSL_ENTER("CyaSSL_X509_get_pathLength"); + WOLFSSL_ENTER("wolfSSL_X509_get_pathLength"); if (x509 != NULL) pathLength = x509->pathLength; - CYASSL_LEAVE("CyaSSL_X509_get_pathLength", pathLength); + WOLFSSL_LEAVE("wolfSSL_X509_get_pathLength", pathLength); return pathLength; } - unsigned int CyaSSL_X509_get_keyUsage(CYASSL_X509* x509) + unsigned int wolfSSL_X509_get_keyUsage(WOLFSSL_X509* x509) { word16 usage = 0; - CYASSL_ENTER("CyaSSL_X509_get_keyUsage"); + WOLFSSL_ENTER("wolfSSL_X509_get_keyUsage"); if (x509 != NULL) usage = x509->keyUsage; - CYASSL_LEAVE("CyaSSL_X509_get_keyUsage", usage); + WOLFSSL_LEAVE("wolfSSL_X509_get_keyUsage", usage); return usage; } - byte* CyaSSL_X509_get_authorityKeyID( - CYASSL_X509* x509, byte* dst, int* dstLen) + byte* wolfSSL_X509_get_authorityKeyID( + WOLFSSL_X509* x509, byte* dst, int* dstLen) { byte *id = NULL; int copySz = 0; - CYASSL_ENTER("CyaSSL_X509_get_authorityKeyID"); + WOLFSSL_ENTER("wolfSSL_X509_get_authorityKeyID"); if (x509 != NULL) { if (x509->authKeyIdSet) { @@ -8303,19 +8303,19 @@ int CyaSSL_set_compression(CYASSL* ssl) } } - CYASSL_LEAVE("CyaSSL_X509_get_authorityKeyID", copySz); + WOLFSSL_LEAVE("wolfSSL_X509_get_authorityKeyID", copySz); return id; } - byte* CyaSSL_X509_get_subjectKeyID( - CYASSL_X509* x509, byte* dst, int* dstLen) + byte* wolfSSL_X509_get_subjectKeyID( + WOLFSSL_X509* x509, byte* dst, int* dstLen) { byte *id = NULL; int copySz = 0; - CYASSL_ENTER("CyaSSL_X509_get_subjectKeyID"); + WOLFSSL_ENTER("wolfSSL_X509_get_subjectKeyID"); if (x509 != NULL) { if (x509->subjKeyIdSet) { @@ -8331,33 +8331,33 @@ int CyaSSL_set_compression(CYASSL* ssl) } } - CYASSL_LEAVE("CyaSSL_X509_get_subjectKeyID", copySz); + WOLFSSL_LEAVE("wolfSSL_X509_get_subjectKeyID", copySz); return id; } - int CyaSSL_X509_NAME_entry_count(CYASSL_X509_NAME* name) + int wolfSSL_X509_NAME_entry_count(WOLFSSL_X509_NAME* name) { int count = 0; - CYASSL_ENTER("CyaSSL_X509_NAME_entry_count"); + WOLFSSL_ENTER("wolfSSL_X509_NAME_entry_count"); if (name != NULL) count = name->fullName.entryCount; - CYASSL_LEAVE("CyaSSL_X509_NAME_entry_count", count); + WOLFSSL_LEAVE("wolfSSL_X509_NAME_entry_count", count); return count; } - int CyaSSL_X509_NAME_get_text_by_NID(CYASSL_X509_NAME* name, + int wolfSSL_X509_NAME_get_text_by_NID(WOLFSSL_X509_NAME* name, int nid, char* buf, int len) { char *text = NULL; int textSz = 0; - CYASSL_ENTER("CyaSSL_X509_NAME_get_text_by_NID"); + WOLFSSL_ENTER("wolfSSL_X509_NAME_get_text_by_NID"); switch (nid) { case ASN_COMMON_NAME: @@ -8402,7 +8402,7 @@ int CyaSSL_set_compression(CYASSL* ssl) buf[textSz] = '\0'; } - CYASSL_LEAVE("CyaSSL_X509_NAME_get_text_by_NID", textSz); + WOLFSSL_LEAVE("wolfSSL_X509_NAME_get_text_by_NID", textSz); return textSz; } #endif @@ -8410,11 +8410,11 @@ int CyaSSL_set_compression(CYASSL* ssl) /* copy name into in buffer, at most sz bytes, if buffer is null will malloc buffer, call responsible for freeing */ - char* CyaSSL_X509_NAME_oneline(CYASSL_X509_NAME* name, char* in, int sz) + char* wolfSSL_X509_NAME_oneline(WOLFSSL_X509_NAME* name, char* in, int sz) { int copySz = min(sz, name->sz); - CYASSL_ENTER("CyaSSL_X509_NAME_oneline"); + WOLFSSL_ENTER("wolfSSL_X509_NAME_oneline"); if (!name->sz) return in; if (!in) { @@ -8433,11 +8433,11 @@ int CyaSSL_set_compression(CYASSL* ssl) } - int CyaSSL_X509_get_signature_type(CYASSL_X509* x509) + int wolfSSL_X509_get_signature_type(WOLFSSL_X509* x509) { int type = 0; - CYASSL_ENTER("CyaSSL_X509_get_signature_type"); + WOLFSSL_ENTER("wolfSSL_X509_get_signature_type"); if (x509 != NULL) type = x509->sigOID; @@ -8446,10 +8446,10 @@ int CyaSSL_set_compression(CYASSL* ssl) } - int CyaSSL_X509_get_signature(CYASSL_X509* x509, + int wolfSSL_X509_get_signature(WOLFSSL_X509* x509, unsigned char* buf, int* bufSz) { - CYASSL_ENTER("CyaSSL_X509_get_signature"); + WOLFSSL_ENTER("wolfSSL_X509_get_signature"); if (x509 == NULL || bufSz == NULL || *bufSz < (int)x509->sig.length) return SSL_FATAL_ERROR; @@ -8464,9 +8464,9 @@ int CyaSSL_set_compression(CYASSL* ssl) /* write X509 serial number in unsigned binary to buffer buffer needs to be at least EXTERNAL_SERIAL_SIZE (32) for all cases return SSL_SUCCESS on success */ - int CyaSSL_X509_get_serial_number(CYASSL_X509* x509, byte* in, int* inOutSz) + int wolfSSL_X509_get_serial_number(WOLFSSL_X509* x509, byte* in, int* inOutSz) { - CYASSL_ENTER("CyaSSL_X509_get_serial_number"); + WOLFSSL_ENTER("wolfSSL_X509_get_serial_number"); if (x509 == NULL || in == NULL || inOutSz == NULL || *inOutSz < x509->serialSz) return BAD_FUNC_ARG; @@ -8478,9 +8478,9 @@ int CyaSSL_set_compression(CYASSL* ssl) } - const byte* CyaSSL_X509_get_der(CYASSL_X509* x509, int* outSz) + const byte* wolfSSL_X509_get_der(WOLFSSL_X509* x509, int* outSz) { - CYASSL_ENTER("CyaSSL_X509_get_der"); + WOLFSSL_ENTER("wolfSSL_X509_get_der"); if (x509 == NULL || outSz == NULL) return NULL; @@ -8490,9 +8490,9 @@ int CyaSSL_set_compression(CYASSL* ssl) } - int CyaSSL_X509_version(CYASSL_X509* x509) + int wolfSSL_X509_version(WOLFSSL_X509* x509) { - CYASSL_ENTER("CyaSSL_X509_version"); + WOLFSSL_ENTER("wolfSSL_X509_version"); if (x509 == NULL) return 0; @@ -8501,9 +8501,9 @@ int CyaSSL_set_compression(CYASSL* ssl) } - const byte* CyaSSL_X509_notBefore(CYASSL_X509* x509) + const byte* wolfSSL_X509_notBefore(WOLFSSL_X509* x509) { - CYASSL_ENTER("CyaSSL_X509_notBefore"); + WOLFSSL_ENTER("wolfSSL_X509_notBefore"); if (x509 == NULL) return NULL; @@ -8512,9 +8512,9 @@ int CyaSSL_set_compression(CYASSL* ssl) } - const byte* CyaSSL_X509_notAfter(CYASSL_X509* x509) + const byte* wolfSSL_X509_notAfter(WOLFSSL_X509* x509) { - CYASSL_ENTER("CyaSSL_X509_notAfter"); + WOLFSSL_ENTER("wolfSSL_X509_notAfter"); if (x509 == NULL) return NULL; @@ -8523,16 +8523,16 @@ int CyaSSL_set_compression(CYASSL* ssl) } -#ifdef CYASSL_SEP +#ifdef WOLFSSL_SEP /* copy oid into in buffer, at most *inOutSz bytes, if buffer is null will malloc buffer, call responsible for freeing. Actual size returned in *inOutSz. Requires inOutSz be non-null */ -byte* CyaSSL_X509_get_device_type(CYASSL_X509* x509, byte* in, int *inOutSz) +byte* wolfSSL_X509_get_device_type(WOLFSSL_X509* x509, byte* in, int *inOutSz) { int copySz; - CYASSL_ENTER("CyaSSL_X509_get_dev_type"); + WOLFSSL_ENTER("wolfSSL_X509_get_dev_type"); if (inOutSz == NULL) return NULL; if (!x509->deviceTypeSz) return in; @@ -8551,11 +8551,11 @@ byte* CyaSSL_X509_get_device_type(CYASSL_X509* x509, byte* in, int *inOutSz) } -byte* CyaSSL_X509_get_hw_type(CYASSL_X509* x509, byte* in, int* inOutSz) +byte* wolfSSL_X509_get_hw_type(WOLFSSL_X509* x509, byte* in, int* inOutSz) { int copySz; - CYASSL_ENTER("CyaSSL_X509_get_hw_type"); + WOLFSSL_ENTER("wolfSSL_X509_get_hw_type"); if (inOutSz == NULL) return NULL; if (!x509->hwTypeSz) return in; @@ -8574,11 +8574,11 @@ byte* CyaSSL_X509_get_hw_type(CYASSL_X509* x509, byte* in, int* inOutSz) } -byte* CyaSSL_X509_get_hw_serial_number(CYASSL_X509* x509,byte* in,int* inOutSz) +byte* wolfSSL_X509_get_hw_serial_number(WOLFSSL_X509* x509,byte* in,int* inOutSz) { int copySz; - CYASSL_ENTER("CyaSSL_X509_get_hw_serial_number"); + WOLFSSL_ENTER("wolfSSL_X509_get_hw_serial_number"); if (inOutSz == NULL) return NULL; if (!x509->hwTypeSz) return in; @@ -8596,23 +8596,23 @@ byte* CyaSSL_X509_get_hw_serial_number(CYASSL_X509* x509,byte* in,int* inOutSz) return in; } -#endif /* CYASSL_SEP */ +#endif /* WOLFSSL_SEP */ -CYASSL_X509* CyaSSL_X509_d2i(CYASSL_X509** x509, const byte* in, int len) +WOLFSSL_X509* wolfSSL_X509_d2i(WOLFSSL_X509** x509, const byte* in, int len) { - CYASSL_X509 *newX509 = NULL; + WOLFSSL_X509 *newX509 = NULL; - CYASSL_ENTER("CyaSSL_X509_d2i"); + WOLFSSL_ENTER("wolfSSL_X509_d2i"); if (in != NULL && len != 0) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK DecodedCert* cert = NULL; #else DecodedCert cert[1]; #endif - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK cert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (cert == NULL) @@ -8621,7 +8621,7 @@ CYASSL_X509* CyaSSL_X509_d2i(CYASSL_X509** x509, const byte* in, int len) InitDecodedCert(cert, (byte*)in, len, NULL); if (ParseCertRelative(cert, CERT_TYPE, 0, NULL) == 0) { - newX509 = (CYASSL_X509*)XMALLOC(sizeof(CYASSL_X509), + newX509 = (WOLFSSL_X509*)XMALLOC(sizeof(WOLFSSL_X509), NULL, DYNAMIC_TYPE_X509); if (newX509 != NULL) { InitX509(newX509, 1); @@ -8632,7 +8632,7 @@ CYASSL_X509* CyaSSL_X509_d2i(CYASSL_X509** x509, const byte* in, int len) } } FreeDecodedCert(cert); - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(cert, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif } @@ -8648,11 +8648,11 @@ CYASSL_X509* CyaSSL_X509_d2i(CYASSL_X509** x509, const byte* in, int len) #ifndef NO_STDIO_FILESYSTEM -CYASSL_X509* CyaSSL_X509_d2i_fp(CYASSL_X509** x509, XFILE file) +WOLFSSL_X509* wolfSSL_X509_d2i_fp(WOLFSSL_X509** x509, XFILE file) { - CYASSL_X509* newX509 = NULL; + WOLFSSL_X509* newX509 = NULL; - CYASSL_ENTER("CyaSSL_X509_d2i_fp"); + WOLFSSL_ENTER("wolfSSL_X509_d2i_fp"); if (file != XBADFILE) { byte* fileBuffer = NULL; @@ -8663,7 +8663,7 @@ CYASSL_X509* CyaSSL_X509_d2i_fp(CYASSL_X509** x509, XFILE file) XREWIND(file); if (sz < 0) { - CYASSL_MSG("Bad tell on FILE"); + WOLFSSL_MSG("Bad tell on FILE"); return NULL; } @@ -8671,7 +8671,7 @@ CYASSL_X509* CyaSSL_X509_d2i_fp(CYASSL_X509** x509, XFILE file) if (fileBuffer != NULL) { int ret = (int)XFREAD(fileBuffer, sz, 1, file); if (ret > 0) { - newX509 = CyaSSL_X509_d2i(NULL, fileBuffer, (int)sz); + newX509 = wolfSSL_X509_d2i(NULL, fileBuffer, (int)sz); } XFREE(fileBuffer, NULL, DYNAMIC_TYPE_FILE); } @@ -8685,9 +8685,9 @@ CYASSL_X509* CyaSSL_X509_d2i_fp(CYASSL_X509** x509, XFILE file) #endif /* NO_STDIO_FILESYSTEM */ -CYASSL_X509* CyaSSL_X509_load_certificate_file(const char* fname, int format) +WOLFSSL_X509* wolfSSL_X509_load_certificate_file(const char* fname, int format) { -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK byte staticBuffer[1]; /* force heap usage */ #else byte staticBuffer[FILE_BUFFER_SIZE]; @@ -8698,10 +8698,10 @@ CYASSL_X509* CyaSSL_X509_load_certificate_file(const char* fname, int format) long sz = 0; XFILE file; - CYASSL_X509* x509 = NULL; + WOLFSSL_X509* x509 = NULL; buffer der; - CYASSL_ENTER("CyaSSL_X509_load_certificate"); + WOLFSSL_ENTER("wolfSSL_X509_load_certificate"); /* Check the inputs */ if ((fname == NULL) || @@ -8744,13 +8744,13 @@ CYASSL_X509* CyaSSL_X509_load_certificate_file(const char* fname, int format) if (format == SSL_FILETYPE_PEM) { int ecc = 0; - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK EncryptedInfo* info = NULL; #else EncryptedInfo info[1]; #endif - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK info = (EncryptedInfo*)XMALLOC(sizeof(EncryptedInfo), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (info == NULL) { @@ -8776,7 +8776,7 @@ CYASSL_X509* CyaSSL_X509_load_certificate_file(const char* fname, int format) } } - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif } @@ -8794,13 +8794,13 @@ CYASSL_X509* CyaSSL_X509_load_certificate_file(const char* fname, int format) /* At this point we want `der` to have the certificate in DER format */ /* ready to be decoded. */ if (der.buffer != NULL) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK DecodedCert* cert = NULL; #else DecodedCert cert[1]; #endif - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK cert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (cert != NULL) @@ -8808,7 +8808,7 @@ CYASSL_X509* CyaSSL_X509_load_certificate_file(const char* fname, int format) { InitDecodedCert(cert, der.buffer, der.length, NULL); if (ParseCertRelative(cert, CERT_TYPE, 0, NULL) == 0) { - x509 = (CYASSL_X509*)XMALLOC(sizeof(CYASSL_X509), NULL, + x509 = (WOLFSSL_X509*)XMALLOC(sizeof(WOLFSSL_X509), NULL, DYNAMIC_TYPE_X509); if (x509 != NULL) { InitX509(x509, 1); @@ -8820,7 +8820,7 @@ CYASSL_X509* CyaSSL_X509_load_certificate_file(const char* fname, int format) } FreeDecodedCert(cert); - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(cert, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif } @@ -8837,7 +8837,7 @@ CYASSL_X509* CyaSSL_X509_load_certificate_file(const char* fname, int format) #ifdef OPENSSL_EXTRA -int CyaSSL_set_ex_data(CYASSL* ssl, int idx, void* data) +int wolfSSL_set_ex_data(WOLFSSL* ssl, int idx, void* data) { #ifdef FORTRESS if (ssl != NULL && idx < MAX_EX_DATA) @@ -8854,7 +8854,7 @@ int CyaSSL_set_ex_data(CYASSL* ssl, int idx, void* data) } -int CyaSSL_set_session_id_context(CYASSL* ssl, const unsigned char* id, +int wolfSSL_set_session_id_context(WOLFSSL* ssl, const unsigned char* id, unsigned int len) { (void)ssl; @@ -8864,14 +8864,14 @@ int CyaSSL_set_session_id_context(CYASSL* ssl, const unsigned char* id, } -void CyaSSL_set_connect_state(CYASSL* ssl) +void wolfSSL_set_connect_state(WOLFSSL* ssl) { (void)ssl; /* client by default */ } #endif -int CyaSSL_get_shutdown(const CYASSL* ssl) +int wolfSSL_get_shutdown(const WOLFSSL* ssl) { return (ssl->options.isClosed || ssl->options.connReset || @@ -8879,21 +8879,21 @@ int CyaSSL_get_shutdown(const CYASSL* ssl) } -int CyaSSL_session_reused(CYASSL* ssl) +int wolfSSL_session_reused(WOLFSSL* ssl) { return ssl->options.resuming; } #ifdef OPENSSL_EXTRA -void CyaSSL_SESSION_free(CYASSL_SESSION* session) +void wolfSSL_SESSION_free(WOLFSSL_SESSION* session) { (void)session; } #endif -const char* CyaSSL_get_version(CYASSL* ssl) +const char* wolfSSL_get_version(WOLFSSL* ssl) { - CYASSL_ENTER("SSL_get_version"); + WOLFSSL_ENTER("SSL_get_version"); if (ssl->version.major == SSLv3_MAJOR) { switch (ssl->version.minor) { case SSLv3_MINOR : @@ -8921,17 +8921,17 @@ const char* CyaSSL_get_version(CYASSL* ssl) return "unknown"; } -int CyaSSL_get_current_cipher_suite(CYASSL* ssl) +int wolfSSL_get_current_cipher_suite(WOLFSSL* ssl) { - CYASSL_ENTER("SSL_get_current_cipher_suite"); + WOLFSSL_ENTER("SSL_get_current_cipher_suite"); if (ssl) return (ssl->options.cipherSuite0 << 8) | ssl->options.cipherSuite; return 0; } -CYASSL_CIPHER* CyaSSL_get_current_cipher(CYASSL* ssl) +WOLFSSL_CIPHER* wolfSSL_get_current_cipher(WOLFSSL* ssl) { - CYASSL_ENTER("SSL_get_current_cipher"); + WOLFSSL_ENTER("SSL_get_current_cipher"); if (ssl) return &ssl->cipher; else @@ -8939,11 +8939,11 @@ CYASSL_CIPHER* CyaSSL_get_current_cipher(CYASSL* ssl) } -const char* CyaSSL_CIPHER_get_name(const CYASSL_CIPHER* cipher) +const char* wolfSSL_CIPHER_get_name(const WOLFSSL_CIPHER* cipher) { (void)cipher; - CYASSL_ENTER("SSL_CIPHER_get_name"); + WOLFSSL_ENTER("SSL_CIPHER_get_name"); #ifndef NO_ERROR_STRINGS if (cipher) { #if defined(HAVE_CHACHA) @@ -9177,7 +9177,7 @@ const char* CyaSSL_CIPHER_get_name(const CYASSL_CIPHER* cipher) return "TLS_DHE_PSK_WITH_AES_128_GCM_SHA256"; #endif #endif -#ifdef CYASSL_SHA384 +#ifdef WOLFSSL_SHA384 case TLS_PSK_WITH_AES_256_CBC_SHA384 : return "TLS_PSK_WITH_AES_256_CBC_SHA384"; case TLS_PSK_WITH_NULL_SHA384 : @@ -9286,17 +9286,17 @@ const char* CyaSSL_CIPHER_get_name(const CYASSL_CIPHER* cipher) } -const char* CyaSSL_get_cipher(CYASSL* ssl) +const char* wolfSSL_get_cipher(WOLFSSL* ssl) { - CYASSL_ENTER("CyaSSL_get_cipher"); - return CyaSSL_CIPHER_get_name(CyaSSL_get_current_cipher(ssl)); + WOLFSSL_ENTER("wolfSSL_get_cipher"); + return wolfSSL_CIPHER_get_name(wolfSSL_get_current_cipher(ssl)); } #ifdef OPENSSL_EXTRA -char* CyaSSL_CIPHER_description(CYASSL_CIPHER* cipher, char* in, int len) +char* wolfSSL_CIPHER_description(WOLFSSL_CIPHER* cipher, char* in, int len) { (void)cipher; (void)in; @@ -9305,14 +9305,14 @@ char* CyaSSL_CIPHER_description(CYASSL_CIPHER* cipher, char* in, int len) } -CYASSL_SESSION* CyaSSL_get1_session(CYASSL* ssl) /* what's ref count */ +WOLFSSL_SESSION* wolfSSL_get1_session(WOLFSSL* ssl) /* what's ref count */ { (void)ssl; return 0; } -void CyaSSL_X509_free(CYASSL_X509* buf) +void wolfSSL_X509_free(WOLFSSL_X509* buf) { (void)buf; } @@ -9327,7 +9327,7 @@ void OPENSSL_free(void* buf) */ -int CyaSSL_OCSP_parse_url(char* url, char** host, char** port, char** path, +int wolfSSL_OCSP_parse_url(char* url, char** host, char** port, char** path, int* ssl) { (void)url; @@ -9339,13 +9339,13 @@ int CyaSSL_OCSP_parse_url(char* url, char** host, char** port, char** path, } -CYASSL_METHOD* CyaSSLv2_client_method(void) +WOLFSSL_METHOD* wolfSSLv2_client_method(void) { return 0; } -CYASSL_METHOD* CyaSSLv2_server_method(void) +WOLFSSL_METHOD* wolfSSLv2_server_method(void) { return 0; } @@ -9353,42 +9353,42 @@ CYASSL_METHOD* CyaSSLv2_server_method(void) #ifndef NO_MD4 -void CyaSSL_MD4_Init(CYASSL_MD4_CTX* md4) +void wolfSSL_MD4_Init(WOLFSSL_MD4_CTX* md4) { /* make sure we have a big enough buffer */ typedef char ok[sizeof(md4->buffer) >= sizeof(Md4) ? 1 : -1]; (void) sizeof(ok); - CYASSL_ENTER("MD4_Init"); + WOLFSSL_ENTER("MD4_Init"); InitMd4((Md4*)md4); } -void CyaSSL_MD4_Update(CYASSL_MD4_CTX* md4, const void* data, +void wolfSSL_MD4_Update(WOLFSSL_MD4_CTX* md4, const void* data, unsigned long len) { - CYASSL_ENTER("MD4_Update"); + WOLFSSL_ENTER("MD4_Update"); Md4Update((Md4*)md4, (const byte*)data, (word32)len); } -void CyaSSL_MD4_Final(unsigned char* digest, CYASSL_MD4_CTX* md4) +void wolfSSL_MD4_Final(unsigned char* digest, WOLFSSL_MD4_CTX* md4) { - CYASSL_ENTER("MD4_Final"); + WOLFSSL_ENTER("MD4_Final"); Md4Final((Md4*)md4, digest); } #endif /* NO_MD4 */ -CYASSL_BIO* CyaSSL_BIO_pop(CYASSL_BIO* top) +WOLFSSL_BIO* wolfSSL_BIO_pop(WOLFSSL_BIO* top) { (void)top; return 0; } -int CyaSSL_BIO_pending(CYASSL_BIO* bio) +int wolfSSL_BIO_pending(WOLFSSL_BIO* bio) { (void)bio; return 0; @@ -9396,24 +9396,24 @@ int CyaSSL_BIO_pending(CYASSL_BIO* bio) -CYASSL_BIO_METHOD* CyaSSL_BIO_s_mem(void) +WOLFSSL_BIO_METHOD* wolfSSL_BIO_s_mem(void) { - static CYASSL_BIO_METHOD meth; + static WOLFSSL_BIO_METHOD meth; - CYASSL_ENTER("BIO_s_mem"); + WOLFSSL_ENTER("BIO_s_mem"); meth.type = BIO_MEMORY; return &meth; } -CYASSL_BIO_METHOD* CyaSSL_BIO_f_base64(void) +WOLFSSL_BIO_METHOD* wolfSSL_BIO_f_base64(void) { return 0; } -void CyaSSL_BIO_set_flags(CYASSL_BIO* bio, int flags) +void wolfSSL_BIO_set_flags(WOLFSSL_BIO* bio, int flags) { (void)bio; (void)flags; @@ -9421,13 +9421,13 @@ void CyaSSL_BIO_set_flags(CYASSL_BIO* bio, int flags) -void CyaSSL_RAND_screen(void) +void wolfSSL_RAND_screen(void) { } -const char* CyaSSL_RAND_file_name(char* fname, unsigned long len) +const char* wolfSSL_RAND_file_name(char* fname, unsigned long len) { (void)fname; (void)len; @@ -9435,17 +9435,17 @@ const char* CyaSSL_RAND_file_name(char* fname, unsigned long len) } -int CyaSSL_RAND_write_file(const char* fname) +int wolfSSL_RAND_write_file(const char* fname) { (void)fname; return 0; } -int CyaSSL_RAND_load_file(const char* fname, long len) +int wolfSSL_RAND_load_file(const char* fname, long len) { (void)fname; - /* CTaoCrypt provides enough entropy internally or will report error */ + /* wolfCrypt provides enough entropy internally or will report error */ if (len == -1) return 1024; else @@ -9453,7 +9453,7 @@ int CyaSSL_RAND_load_file(const char* fname, long len) } -int CyaSSL_RAND_egd(const char* path) +int wolfSSL_RAND_egd(const char* path) { (void)path; return 0; @@ -9461,19 +9461,19 @@ int CyaSSL_RAND_egd(const char* path) -CYASSL_COMP_METHOD* CyaSSL_COMP_zlib(void) +WOLFSSL_COMP_METHOD* wolfSSL_COMP_zlib(void) { return 0; } -CYASSL_COMP_METHOD* CyaSSL_COMP_rle(void) +WOLFSSL_COMP_METHOD* wolfSSL_COMP_rle(void) { return 0; } -int CyaSSL_COMP_add_compression_method(int method, void* data) +int wolfSSL_COMP_add_compression_method(int method, void* data) { (void)method; (void)data; @@ -9482,7 +9482,7 @@ int CyaSSL_COMP_add_compression_method(int method, void* data) -int CyaSSL_get_ex_new_index(long idx, void* data, void* cb1, void* cb2, +int wolfSSL_get_ex_new_index(long idx, void* data, void* cb1, void* cb2, void* cb3) { (void)idx; @@ -9494,29 +9494,29 @@ int CyaSSL_get_ex_new_index(long idx, void* data, void* cb1, void* cb2, } -void CyaSSL_set_dynlock_create_callback(CYASSL_dynlock_value* (*f)( +void wolfSSL_set_dynlock_create_callback(WOLFSSL_dynlock_value* (*f)( const char*, int)) { (void)f; } -void CyaSSL_set_dynlock_lock_callback( - void (*f)(int, CYASSL_dynlock_value*, const char*, int)) +void wolfSSL_set_dynlock_lock_callback( + void (*f)(int, WOLFSSL_dynlock_value*, const char*, int)) { (void)f; } -void CyaSSL_set_dynlock_destroy_callback( - void (*f)(CYASSL_dynlock_value*, const char*, int)) +void wolfSSL_set_dynlock_destroy_callback( + void (*f)(WOLFSSL_dynlock_value*, const char*, int)) { (void)f; } -const char* CyaSSL_X509_verify_cert_error_string(long err) +const char* wolfSSL_X509_verify_cert_error_string(long err) { (void)err; return 0; @@ -9524,7 +9524,7 @@ const char* CyaSSL_X509_verify_cert_error_string(long err) -int CyaSSL_X509_LOOKUP_add_dir(CYASSL_X509_LOOKUP* lookup, const char* dir, +int wolfSSL_X509_LOOKUP_add_dir(WOLFSSL_X509_LOOKUP* lookup, const char* dir, long len) { (void)lookup; @@ -9534,7 +9534,7 @@ int CyaSSL_X509_LOOKUP_add_dir(CYASSL_X509_LOOKUP* lookup, const char* dir, } -int CyaSSL_X509_LOOKUP_load_file(CYASSL_X509_LOOKUP* lookup, +int wolfSSL_X509_LOOKUP_load_file(WOLFSSL_X509_LOOKUP* lookup, const char* file, long len) { (void)lookup; @@ -9544,21 +9544,21 @@ int CyaSSL_X509_LOOKUP_load_file(CYASSL_X509_LOOKUP* lookup, } -CYASSL_X509_LOOKUP_METHOD* CyaSSL_X509_LOOKUP_hash_dir(void) +WOLFSSL_X509_LOOKUP_METHOD* wolfSSL_X509_LOOKUP_hash_dir(void) { return 0; } -CYASSL_X509_LOOKUP_METHOD* CyaSSL_X509_LOOKUP_file(void) +WOLFSSL_X509_LOOKUP_METHOD* wolfSSL_X509_LOOKUP_file(void) { return 0; } -CYASSL_X509_LOOKUP* CyaSSL_X509_STORE_add_lookup(CYASSL_X509_STORE* store, - CYASSL_X509_LOOKUP_METHOD* m) +WOLFSSL_X509_LOOKUP* wolfSSL_X509_STORE_add_lookup(WOLFSSL_X509_STORE* store, + WOLFSSL_X509_LOOKUP_METHOD* m) { (void)store; (void)m; @@ -9566,11 +9566,11 @@ CYASSL_X509_LOOKUP* CyaSSL_X509_STORE_add_lookup(CYASSL_X509_STORE* store, } -int CyaSSL_X509_STORE_add_cert(CYASSL_X509_STORE* store, CYASSL_X509* x509) +int wolfSSL_X509_STORE_add_cert(WOLFSSL_X509_STORE* store, WOLFSSL_X509* x509) { int result = SSL_FATAL_ERROR; - CYASSL_ENTER("CyaSSL_X509_STORE_add_cert"); + WOLFSSL_ENTER("wolfSSL_X509_STORE_add_cert"); if (store != NULL && store->cm != NULL && x509 != NULL) { buffer derCert; derCert.buffer = (byte*)XMALLOC(x509->derCert.length, @@ -9580,23 +9580,23 @@ int CyaSSL_X509_STORE_add_cert(CYASSL_X509_STORE* store, CYASSL_X509* x509) /* AddCA() frees the buffer. */ XMEMCPY(derCert.buffer, x509->derCert.buffer, x509->derCert.length); - result = AddCA(store->cm, derCert, CYASSL_USER_CA, 1); + result = AddCA(store->cm, derCert, WOLFSSL_USER_CA, 1); if (result != SSL_SUCCESS) result = SSL_FATAL_ERROR; } } - CYASSL_LEAVE("CyaSSL_X509_STORE_add_cert", result); + WOLFSSL_LEAVE("wolfSSL_X509_STORE_add_cert", result); return result; } -CYASSL_X509_STORE* CyaSSL_X509_STORE_new(void) +WOLFSSL_X509_STORE* wolfSSL_X509_STORE_new(void) { - CYASSL_X509_STORE* store = NULL; + WOLFSSL_X509_STORE* store = NULL; - store = (CYASSL_X509_STORE*)XMALLOC(sizeof(CYASSL_X509_STORE), NULL, 0); + store = (WOLFSSL_X509_STORE*)XMALLOC(sizeof(WOLFSSL_X509_STORE), NULL, 0); if (store != NULL) { - store->cm = CyaSSL_CertManagerNew(); + store->cm = wolfSSL_CertManagerNew(); if (store->cm == NULL) { XFREE(store, NULL, 0); store = NULL; @@ -9607,25 +9607,25 @@ CYASSL_X509_STORE* CyaSSL_X509_STORE_new(void) } -void CyaSSL_X509_STORE_free(CYASSL_X509_STORE* store) +void wolfSSL_X509_STORE_free(WOLFSSL_X509_STORE* store) { if (store != NULL) { if (store->cm != NULL) - CyaSSL_CertManagerFree(store->cm); + wolfSSL_CertManagerFree(store->cm); XFREE(store, NULL, 0); } } -int CyaSSL_X509_STORE_set_default_paths(CYASSL_X509_STORE* store) +int wolfSSL_X509_STORE_set_default_paths(WOLFSSL_X509_STORE* store) { (void)store; return SSL_SUCCESS; } -int CyaSSL_X509_STORE_get_by_subject(CYASSL_X509_STORE_CTX* ctx, int idx, - CYASSL_X509_NAME* name, CYASSL_X509_OBJECT* obj) +int wolfSSL_X509_STORE_get_by_subject(WOLFSSL_X509_STORE_CTX* ctx, int idx, + WOLFSSL_X509_NAME* name, WOLFSSL_X509_OBJECT* obj) { (void)ctx; (void)idx; @@ -9635,20 +9635,20 @@ int CyaSSL_X509_STORE_get_by_subject(CYASSL_X509_STORE_CTX* ctx, int idx, } -CYASSL_X509_STORE_CTX* CyaSSL_X509_STORE_CTX_new(void) +WOLFSSL_X509_STORE_CTX* wolfSSL_X509_STORE_CTX_new(void) { - CYASSL_X509_STORE_CTX* ctx = (CYASSL_X509_STORE_CTX*)XMALLOC( - sizeof(CYASSL_X509_STORE_CTX), NULL, 0); + WOLFSSL_X509_STORE_CTX* ctx = (WOLFSSL_X509_STORE_CTX*)XMALLOC( + sizeof(WOLFSSL_X509_STORE_CTX), NULL, 0); if (ctx != NULL) - CyaSSL_X509_STORE_CTX_init(ctx, NULL, NULL, NULL); + wolfSSL_X509_STORE_CTX_init(ctx, NULL, NULL, NULL); return ctx; } -int CyaSSL_X509_STORE_CTX_init(CYASSL_X509_STORE_CTX* ctx, - CYASSL_X509_STORE* store, CYASSL_X509* x509, STACK_OF(CYASSL_X509)* sk) +int wolfSSL_X509_STORE_CTX_init(WOLFSSL_X509_STORE_CTX* ctx, + WOLFSSL_X509_STORE* store, WOLFSSL_X509* x509, STACK_OF(WOLFSSL_X509)* sk) { (void)sk; if (ctx != NULL) { @@ -9666,29 +9666,29 @@ int CyaSSL_X509_STORE_CTX_init(CYASSL_X509_STORE_CTX* ctx, } -void CyaSSL_X509_STORE_CTX_free(CYASSL_X509_STORE_CTX* ctx) +void wolfSSL_X509_STORE_CTX_free(WOLFSSL_X509_STORE_CTX* ctx) { if (ctx != NULL) { if (ctx->store != NULL) - CyaSSL_X509_STORE_free(ctx->store); + wolfSSL_X509_STORE_free(ctx->store); if (ctx->current_cert != NULL) - CyaSSL_FreeX509(ctx->current_cert); + wolfSSL_FreeX509(ctx->current_cert); XFREE(ctx, NULL, 0); } } -void CyaSSL_X509_STORE_CTX_cleanup(CYASSL_X509_STORE_CTX* ctx) +void wolfSSL_X509_STORE_CTX_cleanup(WOLFSSL_X509_STORE_CTX* ctx) { (void)ctx; } -int CyaSSL_X509_verify_cert(CYASSL_X509_STORE_CTX* ctx) +int wolfSSL_X509_verify_cert(WOLFSSL_X509_STORE_CTX* ctx) { if (ctx != NULL && ctx->store != NULL && ctx->store->cm != NULL && ctx->current_cert != NULL) { - return CyaSSL_CertManagerVerifyBuffer(ctx->store->cm, + return wolfSSL_CertManagerVerifyBuffer(ctx->store->cm, ctx->current_cert->derCert.buffer, ctx->current_cert->derCert.length, SSL_FILETYPE_ASN1); @@ -9697,14 +9697,14 @@ int CyaSSL_X509_verify_cert(CYASSL_X509_STORE_CTX* ctx) } -CYASSL_ASN1_TIME* CyaSSL_X509_CRL_get_lastUpdate(CYASSL_X509_CRL* crl) +WOLFSSL_ASN1_TIME* wolfSSL_X509_CRL_get_lastUpdate(WOLFSSL_X509_CRL* crl) { (void)crl; return 0; } -CYASSL_ASN1_TIME* CyaSSL_X509_CRL_get_nextUpdate(CYASSL_X509_CRL* crl) +WOLFSSL_ASN1_TIME* wolfSSL_X509_CRL_get_nextUpdate(WOLFSSL_X509_CRL* crl) { (void)crl; return 0; @@ -9712,12 +9712,12 @@ CYASSL_ASN1_TIME* CyaSSL_X509_CRL_get_nextUpdate(CYASSL_X509_CRL* crl) -CYASSL_EVP_PKEY* CyaSSL_X509_get_pubkey(CYASSL_X509* x509) +WOLFSSL_EVP_PKEY* wolfSSL_X509_get_pubkey(WOLFSSL_X509* x509) { - CYASSL_EVP_PKEY* key = NULL; + WOLFSSL_EVP_PKEY* key = NULL; if (x509 != NULL) { - key = (CYASSL_EVP_PKEY*)XMALLOC( - sizeof(CYASSL_EVP_PKEY), NULL, DYNAMIC_TYPE_PUBLIC_KEY); + key = (WOLFSSL_EVP_PKEY*)XMALLOC( + sizeof(WOLFSSL_EVP_PKEY), NULL, DYNAMIC_TYPE_PUBLIC_KEY); if (key != NULL) { key->type = x509->pubKeyOID; key->save_type = 0; @@ -9739,7 +9739,7 @@ CYASSL_EVP_PKEY* CyaSSL_X509_get_pubkey(CYASSL_X509* x509) } -int CyaSSL_X509_CRL_verify(CYASSL_X509_CRL* crl, CYASSL_EVP_PKEY* key) +int wolfSSL_X509_CRL_verify(WOLFSSL_X509_CRL* crl, WOLFSSL_EVP_PKEY* key) { (void)crl; (void)key; @@ -9747,20 +9747,20 @@ int CyaSSL_X509_CRL_verify(CYASSL_X509_CRL* crl, CYASSL_EVP_PKEY* key) } -void CyaSSL_X509_STORE_CTX_set_error(CYASSL_X509_STORE_CTX* ctx, int err) +void wolfSSL_X509_STORE_CTX_set_error(WOLFSSL_X509_STORE_CTX* ctx, int err) { (void)ctx; (void)err; } -void CyaSSL_X509_OBJECT_free_contents(CYASSL_X509_OBJECT* obj) +void wolfSSL_X509_OBJECT_free_contents(WOLFSSL_X509_OBJECT* obj) { (void)obj; } -void CyaSSL_EVP_PKEY_free(CYASSL_EVP_PKEY* key) +void wolfSSL_EVP_PKEY_free(WOLFSSL_EVP_PKEY* key) { if (key != NULL) { if (key->pkey.ptr != NULL) @@ -9770,14 +9770,14 @@ void CyaSSL_EVP_PKEY_free(CYASSL_EVP_PKEY* key) } -int CyaSSL_X509_cmp_current_time(const CYASSL_ASN1_TIME* asnTime) +int wolfSSL_X509_cmp_current_time(const WOLFSSL_ASN1_TIME* asnTime) { (void)asnTime; return 0; } -int CyaSSL_sk_X509_REVOKED_num(CYASSL_X509_REVOKED* revoked) +int wolfSSL_sk_X509_REVOKED_num(WOLFSSL_X509_REVOKED* revoked) { (void)revoked; return 0; @@ -9785,15 +9785,15 @@ int CyaSSL_sk_X509_REVOKED_num(CYASSL_X509_REVOKED* revoked) -CYASSL_X509_REVOKED* CyaSSL_X509_CRL_get_REVOKED(CYASSL_X509_CRL* crl) +WOLFSSL_X509_REVOKED* wolfSSL_X509_CRL_get_REVOKED(WOLFSSL_X509_CRL* crl) { (void)crl; return 0; } -CYASSL_X509_REVOKED* CyaSSL_sk_X509_REVOKED_value( - CYASSL_X509_REVOKED* revoked, int value) +WOLFSSL_X509_REVOKED* wolfSSL_sk_X509_REVOKED_value( + WOLFSSL_X509_REVOKED* revoked, int value) { (void)revoked; (void)value; @@ -9802,14 +9802,14 @@ CYASSL_X509_REVOKED* CyaSSL_sk_X509_REVOKED_value( -CYASSL_ASN1_INTEGER* CyaSSL_X509_get_serialNumber(CYASSL_X509* x509) +WOLFSSL_ASN1_INTEGER* wolfSSL_X509_get_serialNumber(WOLFSSL_X509* x509) { (void)x509; return 0; } -int CyaSSL_ASN1_TIME_print(CYASSL_BIO* bio, const CYASSL_ASN1_TIME* asnTime) +int wolfSSL_ASN1_TIME_print(WOLFSSL_BIO* bio, const WOLFSSL_ASN1_TIME* asnTime) { (void)bio; (void)asnTime; @@ -9818,8 +9818,8 @@ int CyaSSL_ASN1_TIME_print(CYASSL_BIO* bio, const CYASSL_ASN1_TIME* asnTime) -int CyaSSL_ASN1_INTEGER_cmp(const CYASSL_ASN1_INTEGER* a, - const CYASSL_ASN1_INTEGER* b) +int wolfSSL_ASN1_INTEGER_cmp(const WOLFSSL_ASN1_INTEGER* a, + const WOLFSSL_ASN1_INTEGER* b) { (void)a; (void)b; @@ -9827,7 +9827,7 @@ int CyaSSL_ASN1_INTEGER_cmp(const CYASSL_ASN1_INTEGER* a, } -long CyaSSL_ASN1_INTEGER_get(const CYASSL_ASN1_INTEGER* i) +long wolfSSL_ASN1_INTEGER_get(const WOLFSSL_ASN1_INTEGER* i) { (void)i; return 0; @@ -9835,7 +9835,7 @@ long CyaSSL_ASN1_INTEGER_get(const CYASSL_ASN1_INTEGER* i) -void* CyaSSL_X509_STORE_CTX_get_ex_data(CYASSL_X509_STORE_CTX* ctx, int idx) +void* wolfSSL_X509_STORE_CTX_get_ex_data(WOLFSSL_X509_STORE_CTX* ctx, int idx) { #ifdef FORTRESS if (ctx != NULL && idx == 0) @@ -9848,13 +9848,13 @@ void* CyaSSL_X509_STORE_CTX_get_ex_data(CYASSL_X509_STORE_CTX* ctx, int idx) } -int CyaSSL_get_ex_data_X509_STORE_CTX_idx(void) +int wolfSSL_get_ex_data_X509_STORE_CTX_idx(void) { return 0; } -void* CyaSSL_get_ex_data(const CYASSL* ssl, int idx) +void* wolfSSL_get_ex_data(const WOLFSSL* ssl, int idx) { #ifdef FORTRESS if (ssl != NULL && idx < MAX_EX_DATA) @@ -9867,48 +9867,48 @@ void* CyaSSL_get_ex_data(const CYASSL* ssl, int idx) } -void CyaSSL_CTX_set_info_callback(CYASSL_CTX* ctx, void (*f)(void)) +void wolfSSL_CTX_set_info_callback(WOLFSSL_CTX* ctx, void (*f)(void)) { (void)ctx; (void)f; } -unsigned long CyaSSL_ERR_peek_error(void) +unsigned long wolfSSL_ERR_peek_error(void) { return 0; } -int CyaSSL_ERR_GET_REASON(int err) +int wolfSSL_ERR_GET_REASON(int err) { (void)err; return 0; } -char* CyaSSL_alert_type_string_long(int alertID) +char* wolfSSL_alert_type_string_long(int alertID) { (void)alertID; return 0; } -char* CyaSSL_alert_desc_string_long(int alertID) +char* wolfSSL_alert_desc_string_long(int alertID) { (void)alertID; return 0; } -char* CyaSSL_state_string_long(CYASSL* ssl) +char* wolfSSL_state_string_long(WOLFSSL* ssl) { (void)ssl; return 0; } -int CyaSSL_PEM_def_callback(char* name, int num, int w, void* key) +int wolfSSL_PEM_def_callback(char* name, int num, int w, void* key) { (void)name; (void)num; @@ -9918,106 +9918,106 @@ int CyaSSL_PEM_def_callback(char* name, int num, int w, void* key) } -long CyaSSL_CTX_sess_accept(CYASSL_CTX* ctx) +long wolfSSL_CTX_sess_accept(WOLFSSL_CTX* ctx) { (void)ctx; return 0; } -long CyaSSL_CTX_sess_connect(CYASSL_CTX* ctx) +long wolfSSL_CTX_sess_connect(WOLFSSL_CTX* ctx) { (void)ctx; return 0; } -long CyaSSL_CTX_sess_accept_good(CYASSL_CTX* ctx) +long wolfSSL_CTX_sess_accept_good(WOLFSSL_CTX* ctx) { (void)ctx; return 0; } -long CyaSSL_CTX_sess_connect_good(CYASSL_CTX* ctx) +long wolfSSL_CTX_sess_connect_good(WOLFSSL_CTX* ctx) { (void)ctx; return 0; } -long CyaSSL_CTX_sess_accept_renegotiate(CYASSL_CTX* ctx) +long wolfSSL_CTX_sess_accept_renegotiate(WOLFSSL_CTX* ctx) { (void)ctx; return 0; } -long CyaSSL_CTX_sess_connect_renegotiate(CYASSL_CTX* ctx) +long wolfSSL_CTX_sess_connect_renegotiate(WOLFSSL_CTX* ctx) { (void)ctx; return 0; } -long CyaSSL_CTX_sess_hits(CYASSL_CTX* ctx) +long wolfSSL_CTX_sess_hits(WOLFSSL_CTX* ctx) { (void)ctx; return 0; } -long CyaSSL_CTX_sess_cb_hits(CYASSL_CTX* ctx) +long wolfSSL_CTX_sess_cb_hits(WOLFSSL_CTX* ctx) { (void)ctx; return 0; } -long CyaSSL_CTX_sess_cache_full(CYASSL_CTX* ctx) +long wolfSSL_CTX_sess_cache_full(WOLFSSL_CTX* ctx) { (void)ctx; return 0; } -long CyaSSL_CTX_sess_misses(CYASSL_CTX* ctx) +long wolfSSL_CTX_sess_misses(WOLFSSL_CTX* ctx) { (void)ctx; return 0; } -long CyaSSL_CTX_sess_timeouts(CYASSL_CTX* ctx) +long wolfSSL_CTX_sess_timeouts(WOLFSSL_CTX* ctx) { (void)ctx; return 0; } -long CyaSSL_CTX_sess_number(CYASSL_CTX* ctx) +long wolfSSL_CTX_sess_number(WOLFSSL_CTX* ctx) { (void)ctx; return 0; } -void CyaSSL_DES_set_key_unchecked(CYASSL_const_DES_cblock* myDes, - CYASSL_DES_key_schedule* key) +void wolfSSL_DES_set_key_unchecked(WOLFSSL_const_DES_cblock* myDes, + WOLFSSL_DES_key_schedule* key) { (void)myDes; (void)key; } -void CyaSSL_DES_set_odd_parity(CYASSL_DES_cblock* myDes) +void wolfSSL_DES_set_odd_parity(WOLFSSL_DES_cblock* myDes) { (void)myDes; } -void CyaSSL_DES_ecb_encrypt(CYASSL_DES_cblock* desa, - CYASSL_DES_cblock* desb, CYASSL_DES_key_schedule* key, int len) +void wolfSSL_DES_ecb_encrypt(WOLFSSL_DES_cblock* desa, + WOLFSSL_DES_cblock* desb, WOLFSSL_DES_key_schedule* key, int len) { (void)desa; (void)desb; @@ -10025,7 +10025,7 @@ void CyaSSL_DES_ecb_encrypt(CYASSL_DES_cblock* desa, (void)len; } -int CyaSSL_BIO_printf(CYASSL_BIO* bio, const char* format, ...) +int wolfSSL_BIO_printf(WOLFSSL_BIO* bio, const char* format, ...) { (void)bio; (void)format; @@ -10033,7 +10033,7 @@ int CyaSSL_BIO_printf(CYASSL_BIO* bio, const char* format, ...) } -int CyaSSL_ASN1_UTCTIME_print(CYASSL_BIO* bio, const CYASSL_ASN1_UTCTIME* a) +int wolfSSL_ASN1_UTCTIME_print(WOLFSSL_BIO* bio, const WOLFSSL_ASN1_UTCTIME* a) { (void)bio; (void)a; @@ -10041,14 +10041,14 @@ int CyaSSL_ASN1_UTCTIME_print(CYASSL_BIO* bio, const CYASSL_ASN1_UTCTIME* a) } -int CyaSSL_sk_num(CYASSL_X509_REVOKED* rev) +int wolfSSL_sk_num(WOLFSSL_X509_REVOKED* rev) { (void)rev; return 0; } -void* CyaSSL_sk_value(CYASSL_X509_REVOKED* rev, int i) +void* wolfSSL_sk_value(WOLFSSL_X509_REVOKED* rev, int i) { (void)rev; (void)i; @@ -10057,7 +10057,7 @@ void* CyaSSL_sk_value(CYASSL_X509_REVOKED* rev, int i) /* stunnel 4.28 needs */ -void* CyaSSL_CTX_get_ex_data(const CYASSL_CTX* ctx, int d) +void* wolfSSL_CTX_get_ex_data(const WOLFSSL_CTX* ctx, int d) { (void)ctx; (void)d; @@ -10065,7 +10065,7 @@ void* CyaSSL_CTX_get_ex_data(const CYASSL_CTX* ctx, int d) } -int CyaSSL_CTX_set_ex_data(CYASSL_CTX* ctx, int d, void* p) +int wolfSSL_CTX_set_ex_data(WOLFSSL_CTX* ctx, int d, void* p) { (void)ctx; (void)d; @@ -10074,39 +10074,39 @@ int CyaSSL_CTX_set_ex_data(CYASSL_CTX* ctx, int d, void* p) } -void CyaSSL_CTX_sess_set_get_cb(CYASSL_CTX* ctx, - CYASSL_SESSION*(*f)(CYASSL*, unsigned char*, int, int*)) +void wolfSSL_CTX_sess_set_get_cb(WOLFSSL_CTX* ctx, + WOLFSSL_SESSION*(*f)(WOLFSSL*, unsigned char*, int, int*)) { (void)ctx; (void)f; } -void CyaSSL_CTX_sess_set_new_cb(CYASSL_CTX* ctx, - int (*f)(CYASSL*, CYASSL_SESSION*)) +void wolfSSL_CTX_sess_set_new_cb(WOLFSSL_CTX* ctx, + int (*f)(WOLFSSL*, WOLFSSL_SESSION*)) { (void)ctx; (void)f; } -void CyaSSL_CTX_sess_set_remove_cb(CYASSL_CTX* ctx, void (*f)(CYASSL_CTX*, - CYASSL_SESSION*)) +void wolfSSL_CTX_sess_set_remove_cb(WOLFSSL_CTX* ctx, void (*f)(WOLFSSL_CTX*, + WOLFSSL_SESSION*)) { (void)ctx; (void)f; } -int CyaSSL_i2d_SSL_SESSION(CYASSL_SESSION* sess, unsigned char** p) +int wolfSSL_i2d_SSL_SESSION(WOLFSSL_SESSION* sess, unsigned char** p) { (void)sess; (void)p; - return sizeof(CYASSL_SESSION); + return sizeof(WOLFSSL_SESSION); } -CYASSL_SESSION* CyaSSL_d2i_SSL_SESSION(CYASSL_SESSION** sess, +WOLFSSL_SESSION* wolfSSL_d2i_SSL_SESSION(WOLFSSL_SESSION** sess, const unsigned char** p, long i) { (void)p; @@ -10117,21 +10117,21 @@ CYASSL_SESSION* CyaSSL_d2i_SSL_SESSION(CYASSL_SESSION** sess, } -long CyaSSL_SESSION_get_timeout(const CYASSL_SESSION* sess) +long wolfSSL_SESSION_get_timeout(const WOLFSSL_SESSION* sess) { - CYASSL_ENTER("CyaSSL_SESSION_get_timeout"); + WOLFSSL_ENTER("wolfSSL_SESSION_get_timeout"); return sess->timeout; } -long CyaSSL_SESSION_get_time(const CYASSL_SESSION* sess) +long wolfSSL_SESSION_get_time(const WOLFSSL_SESSION* sess) { - CYASSL_ENTER("CyaSSL_SESSION_get_time"); + WOLFSSL_ENTER("wolfSSL_SESSION_get_time"); return sess->bornOn; } -int CyaSSL_CTX_get_ex_new_index(long idx, void* arg, void* a, void* b, +int wolfSSL_CTX_get_ex_new_index(long idx, void* arg, void* a, void* b, void* c) { (void)idx; @@ -10146,7 +10146,7 @@ int CyaSSL_CTX_get_ex_new_index(long idx, void* arg, void* a, void* b, #ifdef KEEP_PEER_CERT -char* CyaSSL_X509_get_subjectCN(CYASSL_X509* x509) +char* wolfSSL_X509_get_subjectCN(WOLFSSL_X509* x509) { if (x509 == NULL) return NULL; @@ -10158,14 +10158,14 @@ char* CyaSSL_X509_get_subjectCN(CYASSL_X509* x509) #ifdef OPENSSL_EXTRA #ifdef FORTRESS -int CyaSSL_cmp_peer_cert_to_file(CYASSL* ssl, const char *fname) +int wolfSSL_cmp_peer_cert_to_file(WOLFSSL* ssl, const char *fname) { int ret = SSL_FATAL_ERROR; - CYASSL_ENTER("CyaSSL_cmp_peer_cert_to_file"); + WOLFSSL_ENTER("wolfSSL_cmp_peer_cert_to_file"); if (ssl != NULL && fname != NULL) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK EncryptedInfo* info = NULL; byte staticBuffer[1]; /* force heap usage */ #else @@ -10177,8 +10177,8 @@ int CyaSSL_cmp_peer_cert_to_file(CYASSL* ssl, const char *fname) XFILE file = XBADFILE; long sz = 0; int eccKey = 0; - CYASSL_CTX* ctx = ssl->ctx; - CYASSL_X509* peer_cert = &ssl->peerCert; + WOLFSSL_CTX* ctx = ssl->ctx; + WOLFSSL_X509* peer_cert = &ssl->peerCert; buffer fileDer; file = XFOPEN(fname, "rb"); @@ -10190,12 +10190,12 @@ int CyaSSL_cmp_peer_cert_to_file(CYASSL* ssl, const char *fname) XREWIND(file); if (sz > (long)sizeof(staticBuffer)) { - CYASSL_MSG("Getting dynamic buffer"); + WOLFSSL_MSG("Getting dynamic buffer"); myBuffer = (byte*)XMALLOC(sz, ctx->heap, DYNAMIC_TYPE_FILE); dynamic = 1; } - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK info = (EncryptedInfo*)XMALLOC(sizeof(EncryptedInfo), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (info == NULL) @@ -10221,7 +10221,7 @@ int CyaSSL_cmp_peer_cert_to_file(CYASSL* ssl, const char *fname) ret = 0; } - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(info, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif } @@ -10242,17 +10242,17 @@ static RNG globalRNG; static int initGlobalRNG = 0; /* SSL_SUCCESS on ok */ -int CyaSSL_RAND_seed(const void* seed, int len) +int wolfSSL_RAND_seed(const void* seed, int len) { - CYASSL_MSG("CyaSSL_RAND_seed"); + WOLFSSL_MSG("wolfSSL_RAND_seed"); (void)seed; (void)len; if (initGlobalRNG == 0) { if (InitRng(&globalRNG) < 0) { - CYASSL_MSG("CyaSSL Init Global RNG failed"); + WOLFSSL_MSG("wolfSSL Init Global RNG failed"); return 0; } initGlobalRNG = 1; @@ -10263,20 +10263,20 @@ int CyaSSL_RAND_seed(const void* seed, int len) /* SSL_SUCCESS on ok */ -int CyaSSL_RAND_bytes(unsigned char* buf, int num) +int wolfSSL_RAND_bytes(unsigned char* buf, int num) { int ret = 0; int initTmpRng = 0; RNG* rng = NULL; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK RNG* tmpRNG = NULL; #else RNG tmpRNG[1]; #endif - CYASSL_ENTER("RAND_bytes"); + WOLFSSL_ENTER("RAND_bytes"); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK tmpRNG = (RNG*)XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (tmpRNG == NULL) return ret; @@ -10291,7 +10291,7 @@ int CyaSSL_RAND_bytes(unsigned char* buf, int num) if (rng) { if (RNG_GenerateBlock(rng, buf, num) != 0) - CYASSL_MSG("Bad RNG_GenerateBlock"); + WOLFSSL_MSG("Bad RNG_GenerateBlock"); else ret = SSL_SUCCESS; } @@ -10302,41 +10302,41 @@ int CyaSSL_RAND_bytes(unsigned char* buf, int num) #endif } -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(tmpRNG, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif return ret; } -CYASSL_BN_CTX* CyaSSL_BN_CTX_new(void) +WOLFSSL_BN_CTX* wolfSSL_BN_CTX_new(void) { - static int ctx; /* ctaocrypt doesn't now need ctx */ + static int ctx; /* wolfcrypt doesn't now need ctx */ - CYASSL_MSG("CyaSSL_BN_CTX_new"); + WOLFSSL_MSG("wolfSSL_BN_CTX_new"); - return (CYASSL_BN_CTX*)&ctx; + return (WOLFSSL_BN_CTX*)&ctx; } -void CyaSSL_BN_CTX_init(CYASSL_BN_CTX* ctx) +void wolfSSL_BN_CTX_init(WOLFSSL_BN_CTX* ctx) { (void)ctx; - CYASSL_MSG("CyaSSL_BN_CTX_init"); + WOLFSSL_MSG("wolfSSL_BN_CTX_init"); } -void CyaSSL_BN_CTX_free(CYASSL_BN_CTX* ctx) +void wolfSSL_BN_CTX_free(WOLFSSL_BN_CTX* ctx) { (void)ctx; - CYASSL_MSG("CyaSSL_BN_CTX_free"); + WOLFSSL_MSG("wolfSSL_BN_CTX_free"); /* do free since static ctx that does nothing */ } -static void InitCyaSSL_BigNum(CYASSL_BIGNUM* bn) +static void InitwolfSSL_BigNum(WOLFSSL_BIGNUM* bn) { - CYASSL_MSG("InitCyaSSL_BigNum"); + WOLFSSL_MSG("InitwolfSSL_BigNum"); if (bn) { bn->neg = 0; bn->internal = NULL; @@ -10344,31 +10344,31 @@ static void InitCyaSSL_BigNum(CYASSL_BIGNUM* bn) } -CYASSL_BIGNUM* CyaSSL_BN_new(void) +WOLFSSL_BIGNUM* wolfSSL_BN_new(void) { - CYASSL_BIGNUM* external; + WOLFSSL_BIGNUM* external; mp_int* mpi; - CYASSL_MSG("CyaSSL_BN_new"); + WOLFSSL_MSG("wolfSSL_BN_new"); mpi = (mp_int*) XMALLOC(sizeof(mp_int), NULL, DYNAMIC_TYPE_BIGINT); if (mpi == NULL) { - CYASSL_MSG("CyaSSL_BN_new malloc mpi failure"); + WOLFSSL_MSG("wolfSSL_BN_new malloc mpi failure"); return NULL; } - external = (CYASSL_BIGNUM*) XMALLOC(sizeof(CYASSL_BIGNUM), NULL, + external = (WOLFSSL_BIGNUM*) XMALLOC(sizeof(WOLFSSL_BIGNUM), NULL, DYNAMIC_TYPE_BIGINT); if (external == NULL) { - CYASSL_MSG("CyaSSL_BN_new malloc CYASSL_BIGNUM failure"); + WOLFSSL_MSG("wolfSSL_BN_new malloc WOLFSSL_BIGNUM failure"); XFREE(mpi, NULL, DYNAMIC_TYPE_BIGINT); return NULL; } - InitCyaSSL_BigNum(external); + InitwolfSSL_BigNum(external); external->internal = mpi; if (mp_init(mpi) != MP_OKAY) { - CyaSSL_BN_free(external); + wolfSSL_BN_free(external); return NULL; } @@ -10376,9 +10376,9 @@ CYASSL_BIGNUM* CyaSSL_BN_new(void) } -void CyaSSL_BN_free(CYASSL_BIGNUM* bn) +void wolfSSL_BN_free(WOLFSSL_BIGNUM* bn) { - CYASSL_MSG("CyaSSL_BN_free"); + WOLFSSL_MSG("wolfSSL_BN_free"); if (bn) { if (bn->internal) { mp_clear((mp_int*)bn->internal); @@ -10390,19 +10390,19 @@ void CyaSSL_BN_free(CYASSL_BIGNUM* bn) } -void CyaSSL_BN_clear_free(CYASSL_BIGNUM* bn) +void wolfSSL_BN_clear_free(WOLFSSL_BIGNUM* bn) { - CYASSL_MSG("CyaSSL_BN_clear_free"); + WOLFSSL_MSG("wolfSSL_BN_clear_free"); - CyaSSL_BN_free(bn); + wolfSSL_BN_free(bn); } /* SSL_SUCCESS on ok */ -int CyaSSL_BN_sub(CYASSL_BIGNUM* r, const CYASSL_BIGNUM* a, - const CYASSL_BIGNUM* b) +int wolfSSL_BN_sub(WOLFSSL_BIGNUM* r, const WOLFSSL_BIGNUM* a, + const WOLFSSL_BIGNUM* b) { - CYASSL_MSG("CyaSSL_BN_sub"); + WOLFSSL_MSG("wolfSSL_BN_sub"); if (r == NULL || a == NULL || b == NULL) return 0; @@ -10411,17 +10411,17 @@ int CyaSSL_BN_sub(CYASSL_BIGNUM* r, const CYASSL_BIGNUM* a, (mp_int*)r->internal) == MP_OKAY) return SSL_SUCCESS; - CYASSL_MSG("CyaSSL_BN_sub mp_sub failed"); + WOLFSSL_MSG("wolfSSL_BN_sub mp_sub failed"); return 0; } /* SSL_SUCCESS on ok */ -int CyaSSL_BN_mod(CYASSL_BIGNUM* r, const CYASSL_BIGNUM* a, - const CYASSL_BIGNUM* b, const CYASSL_BN_CTX* c) +int wolfSSL_BN_mod(WOLFSSL_BIGNUM* r, const WOLFSSL_BIGNUM* a, + const WOLFSSL_BIGNUM* b, const WOLFSSL_BN_CTX* c) { (void)c; - CYASSL_MSG("CyaSSL_BN_mod"); + WOLFSSL_MSG("wolfSSL_BN_mod"); if (r == NULL || a == NULL || b == NULL) return 0; @@ -10430,19 +10430,19 @@ int CyaSSL_BN_mod(CYASSL_BIGNUM* r, const CYASSL_BIGNUM* a, (mp_int*)r->internal) == MP_OKAY) return SSL_SUCCESS; - CYASSL_MSG("CyaSSL_BN_mod mp_mod failed"); + WOLFSSL_MSG("wolfSSL_BN_mod mp_mod failed"); return 0; } -const CYASSL_BIGNUM* CyaSSL_BN_value_one(void) +const WOLFSSL_BIGNUM* wolfSSL_BN_value_one(void) { - static CYASSL_BIGNUM* bn_one = NULL; + static WOLFSSL_BIGNUM* bn_one = NULL; - CYASSL_MSG("CyaSSL_BN_value_one"); + WOLFSSL_MSG("wolfSSL_BN_value_one"); if (bn_one == NULL) { - bn_one = CyaSSL_BN_new(); + bn_one = wolfSSL_BN_new(); if (bn_one) mp_set_int((mp_int*)bn_one->internal, 1); } @@ -10451,9 +10451,9 @@ const CYASSL_BIGNUM* CyaSSL_BN_value_one(void) } -int CyaSSL_BN_num_bytes(const CYASSL_BIGNUM* bn) +int wolfSSL_BN_num_bytes(const WOLFSSL_BIGNUM* bn) { - CYASSL_MSG("CyaSSL_BN_num_bytes"); + WOLFSSL_MSG("wolfSSL_BN_num_bytes"); if (bn == NULL || bn->internal == NULL) return 0; @@ -10462,9 +10462,9 @@ int CyaSSL_BN_num_bytes(const CYASSL_BIGNUM* bn) } -int CyaSSL_BN_num_bits(const CYASSL_BIGNUM* bn) +int wolfSSL_BN_num_bits(const WOLFSSL_BIGNUM* bn) { - CYASSL_MSG("CyaSSL_BN_num_bits"); + WOLFSSL_MSG("wolfSSL_BN_num_bits"); if (bn == NULL || bn->internal == NULL) return 0; @@ -10473,9 +10473,9 @@ int CyaSSL_BN_num_bits(const CYASSL_BIGNUM* bn) } -int CyaSSL_BN_is_zero(const CYASSL_BIGNUM* bn) +int wolfSSL_BN_is_zero(const WOLFSSL_BIGNUM* bn) { - CYASSL_MSG("CyaSSL_BN_is_zero"); + WOLFSSL_MSG("wolfSSL_BN_is_zero"); if (bn == NULL || bn->internal == NULL) return 0; @@ -10484,9 +10484,9 @@ int CyaSSL_BN_is_zero(const CYASSL_BIGNUM* bn) } -int CyaSSL_BN_is_one(const CYASSL_BIGNUM* bn) +int wolfSSL_BN_is_one(const WOLFSSL_BIGNUM* bn) { - CYASSL_MSG("CyaSSL_BN_is_one"); + WOLFSSL_MSG("wolfSSL_BN_is_one"); if (bn == NULL || bn->internal == NULL) return 0; @@ -10498,9 +10498,9 @@ int CyaSSL_BN_is_one(const CYASSL_BIGNUM* bn) } -int CyaSSL_BN_is_odd(const CYASSL_BIGNUM* bn) +int wolfSSL_BN_is_odd(const WOLFSSL_BIGNUM* bn) { - CYASSL_MSG("CyaSSL_BN_is_odd"); + WOLFSSL_MSG("wolfSSL_BN_is_odd"); if (bn == NULL || bn->internal == NULL) return 0; @@ -10509,9 +10509,9 @@ int CyaSSL_BN_is_odd(const CYASSL_BIGNUM* bn) } -int CyaSSL_BN_cmp(const CYASSL_BIGNUM* a, const CYASSL_BIGNUM* b) +int wolfSSL_BN_cmp(const WOLFSSL_BIGNUM* a, const WOLFSSL_BIGNUM* b) { - CYASSL_MSG("CyaSSL_BN_cmp"); + WOLFSSL_MSG("wolfSSL_BN_cmp"); if (a == NULL || a->internal == NULL || b == NULL || b->internal ==NULL) return 0; @@ -10520,12 +10520,12 @@ int CyaSSL_BN_cmp(const CYASSL_BIGNUM* a, const CYASSL_BIGNUM* b) } -int CyaSSL_BN_bn2bin(const CYASSL_BIGNUM* bn, unsigned char* r) +int wolfSSL_BN_bn2bin(const WOLFSSL_BIGNUM* bn, unsigned char* r) { - CYASSL_MSG("CyaSSL_BN_bn2bin"); + WOLFSSL_MSG("wolfSSL_BN_bn2bin"); if (bn == NULL || bn->internal == NULL) { - CYASSL_MSG("NULL bn error"); + WOLFSSL_MSG("NULL bn error"); return SSL_FATAL_ERROR; } @@ -10533,7 +10533,7 @@ int CyaSSL_BN_bn2bin(const CYASSL_BIGNUM* bn, unsigned char* r) return mp_unsigned_bin_size((mp_int*)bn->internal); if (mp_to_unsigned_bin((mp_int*)bn->internal, r) != MP_OKAY) { - CYASSL_MSG("mp_to_unsigned_bin error"); + WOLFSSL_MSG("mp_to_unsigned_bin error"); return SSL_FATAL_ERROR; } @@ -10541,42 +10541,42 @@ int CyaSSL_BN_bn2bin(const CYASSL_BIGNUM* bn, unsigned char* r) } -CYASSL_BIGNUM* CyaSSL_BN_bin2bn(const unsigned char* str, int len, - CYASSL_BIGNUM* ret) +WOLFSSL_BIGNUM* wolfSSL_BN_bin2bn(const unsigned char* str, int len, + WOLFSSL_BIGNUM* ret) { - CYASSL_MSG("CyaSSL_BN_bin2bn"); + WOLFSSL_MSG("wolfSSL_BN_bin2bn"); if (ret && ret->internal) { if (mp_read_unsigned_bin((mp_int*)ret->internal, str, len) != 0) { - CYASSL_MSG("mp_read_unsigned_bin failure"); + WOLFSSL_MSG("mp_read_unsigned_bin failure"); return NULL; } } else { - CYASSL_MSG("CyaSSL_BN_bin2bn wants return bignum"); + WOLFSSL_MSG("wolfSSL_BN_bin2bn wants return bignum"); } return ret; } -int CyaSSL_mask_bits(CYASSL_BIGNUM* bn, int n) +int wolfSSL_mask_bits(WOLFSSL_BIGNUM* bn, int n) { (void)bn; (void)n; - CYASSL_MSG("CyaSSL_BN_mask_bits"); + WOLFSSL_MSG("wolfSSL_BN_mask_bits"); return SSL_FATAL_ERROR; } /* SSL_SUCCESS on ok */ -int CyaSSL_BN_rand(CYASSL_BIGNUM* bn, int bits, int top, int bottom) +int wolfSSL_BN_rand(WOLFSSL_BIGNUM* bn, int bits, int top, int bottom) { int ret = 0; int len = bits / 8; RNG* rng = NULL; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK RNG* tmpRNG = NULL; byte* buff = NULL; #else @@ -10586,12 +10586,12 @@ int CyaSSL_BN_rand(CYASSL_BIGNUM* bn, int bits, int top, int bottom) (void)top; (void)bottom; - CYASSL_MSG("CyaSSL_BN_rand"); + WOLFSSL_MSG("wolfSSL_BN_rand"); if (bits % 8) len++; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK buff = (byte*)XMALLOC(1024, NULL, DYNAMIC_TYPE_TMP_BUFFER); tmpRNG = (RNG*) XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (buff == NULL || tmpRNG == NULL) { @@ -10602,7 +10602,7 @@ int CyaSSL_BN_rand(CYASSL_BIGNUM* bn, int bits, int top, int bottom) #endif if (bn == NULL || bn->internal == NULL) - CYASSL_MSG("Bad function arguments"); + WOLFSSL_MSG("Bad function arguments"); else if (InitRng(tmpRNG) == 0) rng = tmpRNG; else if (initGlobalRNG) @@ -10610,19 +10610,19 @@ int CyaSSL_BN_rand(CYASSL_BIGNUM* bn, int bits, int top, int bottom) if (rng) { if (RNG_GenerateBlock(rng, buff, len) != 0) - CYASSL_MSG("Bad RNG_GenerateBlock"); + WOLFSSL_MSG("Bad RNG_GenerateBlock"); else { buff[0] |= 0x80 | 0x40; buff[len-1] |= 0x01; if (mp_read_unsigned_bin((mp_int*)bn->internal,buff,len) != MP_OKAY) - CYASSL_MSG("mp read bin failed"); + WOLFSSL_MSG("mp read bin failed"); else ret = SSL_SUCCESS; } } -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(buff, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(tmpRNG, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -10631,55 +10631,55 @@ int CyaSSL_BN_rand(CYASSL_BIGNUM* bn, int bits, int top, int bottom) } -int CyaSSL_BN_is_bit_set(const CYASSL_BIGNUM* bn, int n) +int wolfSSL_BN_is_bit_set(const WOLFSSL_BIGNUM* bn, int n) { (void)bn; (void)n; - CYASSL_MSG("CyaSSL_BN_is_bit_set"); + WOLFSSL_MSG("wolfSSL_BN_is_bit_set"); return 0; } /* SSL_SUCCESS on ok */ -int CyaSSL_BN_hex2bn(CYASSL_BIGNUM** bn, const char* str) +int wolfSSL_BN_hex2bn(WOLFSSL_BIGNUM** bn, const char* str) { int ret = 0; word32 decSz = 1024; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK byte* decoded = NULL; #else byte decoded[1024]; #endif - CYASSL_MSG("CyaSSL_BN_hex2bn"); + WOLFSSL_MSG("wolfSSL_BN_hex2bn"); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK decoded = (byte*)XMALLOC(decSz, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (decoded == NULL) return ret; #endif if (str == NULL) - CYASSL_MSG("Bad function argument"); + WOLFSSL_MSG("Bad function argument"); else if (Base16_Decode((byte*)str, (int)XSTRLEN(str), decoded, &decSz) < 0) - CYASSL_MSG("Bad Base16_Decode error"); + WOLFSSL_MSG("Bad Base16_Decode error"); else if (bn == NULL) ret = decSz; else { if (*bn == NULL) - *bn = CyaSSL_BN_new(); + *bn = wolfSSL_BN_new(); if (*bn == NULL) - CYASSL_MSG("BN new failed"); - else if (CyaSSL_BN_bin2bn(decoded, decSz, *bn) == NULL) - CYASSL_MSG("Bad bin2bn error"); + WOLFSSL_MSG("BN new failed"); + else if (wolfSSL_BN_bin2bn(decoded, decSz, *bn) == NULL) + WOLFSSL_MSG("Bad bin2bn error"); else ret = SSL_SUCCESS; } -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(decoded, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -10687,26 +10687,26 @@ int CyaSSL_BN_hex2bn(CYASSL_BIGNUM** bn, const char* str) } -CYASSL_BIGNUM* CyaSSL_BN_dup(const CYASSL_BIGNUM* bn) +WOLFSSL_BIGNUM* wolfSSL_BN_dup(const WOLFSSL_BIGNUM* bn) { - CYASSL_BIGNUM* ret; + WOLFSSL_BIGNUM* ret; - CYASSL_MSG("CyaSSL_BN_dup"); + WOLFSSL_MSG("wolfSSL_BN_dup"); if (bn == NULL || bn->internal == NULL) { - CYASSL_MSG("bn NULL error"); + WOLFSSL_MSG("bn NULL error"); return NULL; } - ret = CyaSSL_BN_new(); + ret = wolfSSL_BN_new(); if (ret == NULL) { - CYASSL_MSG("bn new error"); + WOLFSSL_MSG("bn new error"); return NULL; } if (mp_copy((mp_int*)bn->internal, (mp_int*)ret->internal) != MP_OKAY) { - CYASSL_MSG("mp_copy error"); - CyaSSL_BN_free(ret); + WOLFSSL_MSG("mp_copy error"); + wolfSSL_BN_free(ret); return NULL; } @@ -10714,44 +10714,44 @@ CYASSL_BIGNUM* CyaSSL_BN_dup(const CYASSL_BIGNUM* bn) } -CYASSL_BIGNUM* CyaSSL_BN_copy(CYASSL_BIGNUM* r, const CYASSL_BIGNUM* bn) +WOLFSSL_BIGNUM* wolfSSL_BN_copy(WOLFSSL_BIGNUM* r, const WOLFSSL_BIGNUM* bn) { (void)r; (void)bn; - CYASSL_MSG("CyaSSL_BN_copy"); + WOLFSSL_MSG("wolfSSL_BN_copy"); return NULL; } -int CyaSSL_BN_set_word(CYASSL_BIGNUM* bn, unsigned long w) +int wolfSSL_BN_set_word(WOLFSSL_BIGNUM* bn, unsigned long w) { (void)bn; (void)w; - CYASSL_MSG("CyaSSL_BN_set_word"); + WOLFSSL_MSG("wolfSSL_BN_set_word"); return SSL_FATAL_ERROR; } -int CyaSSL_BN_dec2bn(CYASSL_BIGNUM** bn, const char* str) +int wolfSSL_BN_dec2bn(WOLFSSL_BIGNUM** bn, const char* str) { (void)bn; (void)str; - CYASSL_MSG("CyaSSL_BN_dec2bn"); + WOLFSSL_MSG("wolfSSL_BN_dec2bn"); return SSL_FATAL_ERROR; } -char* CyaSSL_BN_bn2dec(const CYASSL_BIGNUM* bn) +char* wolfSSL_BN_bn2dec(const WOLFSSL_BIGNUM* bn) { (void)bn; - CYASSL_MSG("CyaSSL_BN_bn2dec"); + WOLFSSL_MSG("wolfSSL_BN_bn2dec"); return NULL; } @@ -10759,7 +10759,7 @@ char* CyaSSL_BN_bn2dec(const CYASSL_BIGNUM* bn) #ifndef NO_DH -static void InitCyaSSL_DH(CYASSL_DH* dh) +static void InitwolfSSL_DH(WOLFSSL_DH* dh) { if (dh) { dh->p = NULL; @@ -10773,28 +10773,28 @@ static void InitCyaSSL_DH(CYASSL_DH* dh) } -CYASSL_DH* CyaSSL_DH_new(void) +WOLFSSL_DH* wolfSSL_DH_new(void) { - CYASSL_DH* external; + WOLFSSL_DH* external; DhKey* key; - CYASSL_MSG("CyaSSL_DH_new"); + WOLFSSL_MSG("wolfSSL_DH_new"); key = (DhKey*) XMALLOC(sizeof(DhKey), NULL, DYNAMIC_TYPE_DH); if (key == NULL) { - CYASSL_MSG("CyaSSL_DH_new malloc DhKey failure"); + WOLFSSL_MSG("wolfSSL_DH_new malloc DhKey failure"); return NULL; } - external = (CYASSL_DH*) XMALLOC(sizeof(CYASSL_DH), NULL, + external = (WOLFSSL_DH*) XMALLOC(sizeof(WOLFSSL_DH), NULL, DYNAMIC_TYPE_DH); if (external == NULL) { - CYASSL_MSG("CyaSSL_DH_new malloc CYASSL_DH failure"); + WOLFSSL_MSG("wolfSSL_DH_new malloc WOLFSSL_DH failure"); XFREE(key, NULL, DYNAMIC_TYPE_DH); return NULL; } - InitCyaSSL_DH(external); + InitwolfSSL_DH(external); InitDhKey(key); external->internal = key; @@ -10802,9 +10802,9 @@ CYASSL_DH* CyaSSL_DH_new(void) } -void CyaSSL_DH_free(CYASSL_DH* dh) +void wolfSSL_DH_free(WOLFSSL_DH* dh) { - CYASSL_MSG("CyaSSL_DH_free"); + WOLFSSL_MSG("wolfSSL_DH_free"); if (dh) { if (dh->internal) { @@ -10812,23 +10812,23 @@ void CyaSSL_DH_free(CYASSL_DH* dh) XFREE(dh->internal, NULL, DYNAMIC_TYPE_DH); dh->internal = NULL; } - CyaSSL_BN_free(dh->priv_key); - CyaSSL_BN_free(dh->pub_key); - CyaSSL_BN_free(dh->g); - CyaSSL_BN_free(dh->p); - InitCyaSSL_DH(dh); /* set back to NULLs for safety */ + wolfSSL_BN_free(dh->priv_key); + wolfSSL_BN_free(dh->pub_key); + wolfSSL_BN_free(dh->g); + wolfSSL_BN_free(dh->p); + InitwolfSSL_DH(dh); /* set back to NULLs for safety */ XFREE(dh, NULL, DYNAMIC_TYPE_DH); } } -static int SetDhInternal(CYASSL_DH* dh) +static int SetDhInternal(WOLFSSL_DH* dh) { int ret = SSL_FATAL_ERROR; int pSz = 1024; int gSz = 1024; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK unsigned char* p = NULL; unsigned char* g = NULL; #else @@ -10836,16 +10836,16 @@ static int SetDhInternal(CYASSL_DH* dh) unsigned char g[1024]; #endif - CYASSL_ENTER("SetDhInternal"); + WOLFSSL_ENTER("SetDhInternal"); if (dh == NULL || dh->p == NULL || dh->g == NULL) - CYASSL_MSG("Bad function arguments"); - else if (CyaSSL_BN_bn2bin(dh->p, NULL) > pSz) - CYASSL_MSG("Bad p internal size"); - else if (CyaSSL_BN_bn2bin(dh->g, NULL) > gSz) - CYASSL_MSG("Bad g internal size"); + WOLFSSL_MSG("Bad function arguments"); + else if (wolfSSL_BN_bn2bin(dh->p, NULL) > pSz) + WOLFSSL_MSG("Bad p internal size"); + else if (wolfSSL_BN_bn2bin(dh->g, NULL) > gSz) + WOLFSSL_MSG("Bad g internal size"); else { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK p = (unsigned char*)XMALLOC(pSz, NULL, DYNAMIC_TYPE_TMP_BUFFER); g = (unsigned char*)XMALLOC(gSz, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -10856,19 +10856,19 @@ static int SetDhInternal(CYASSL_DH* dh) } #endif - pSz = CyaSSL_BN_bn2bin(dh->p, p); - gSz = CyaSSL_BN_bn2bin(dh->g, g); + pSz = wolfSSL_BN_bn2bin(dh->p, p); + gSz = wolfSSL_BN_bn2bin(dh->g, g); if (pSz <= 0 || gSz <= 0) - CYASSL_MSG("Bad BN2bin set"); + WOLFSSL_MSG("Bad BN2bin set"); else if (DhSetKey((DhKey*)dh->internal, p, pSz, g, gSz) < 0) - CYASSL_MSG("Bad DH SetKey"); + WOLFSSL_MSG("Bad DH SetKey"); else { dh->inSet = 1; ret = 0; } - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(p, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(g, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -10879,25 +10879,25 @@ static int SetDhInternal(CYASSL_DH* dh) } -int CyaSSL_DH_size(CYASSL_DH* dh) +int wolfSSL_DH_size(WOLFSSL_DH* dh) { - CYASSL_MSG("CyaSSL_DH_size"); + WOLFSSL_MSG("wolfSSL_DH_size"); if (dh == NULL) return 0; - return CyaSSL_BN_num_bytes(dh->p); + return wolfSSL_BN_num_bytes(dh->p); } /* return SSL_SUCCESS on ok, else 0 */ -int CyaSSL_DH_generate_key(CYASSL_DH* dh) +int wolfSSL_DH_generate_key(WOLFSSL_DH* dh) { int ret = 0; word32 pubSz = 768; word32 privSz = 768; RNG* rng = NULL; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK unsigned char* pub = NULL; unsigned char* priv = NULL; RNG* tmpRNG = NULL; @@ -10907,9 +10907,9 @@ int CyaSSL_DH_generate_key(CYASSL_DH* dh) RNG tmpRNG[1]; #endif - CYASSL_MSG("CyaSSL_DH_generate_key"); + WOLFSSL_MSG("wolfSSL_DH_generate_key"); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK tmpRNG = (RNG*)XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER); pub = (unsigned char*)XMALLOC(pubSz, NULL, DYNAMIC_TYPE_TMP_BUFFER); priv = (unsigned char*)XMALLOC(privSz, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -10923,15 +10923,15 @@ int CyaSSL_DH_generate_key(CYASSL_DH* dh) #endif if (dh == NULL || dh->p == NULL || dh->g == NULL) - CYASSL_MSG("Bad function arguments"); + WOLFSSL_MSG("Bad function arguments"); else if (dh->inSet == 0 && SetDhInternal(dh) < 0) - CYASSL_MSG("Bad DH set internal"); + WOLFSSL_MSG("Bad DH set internal"); else if (InitRng(tmpRNG) == 0) rng = tmpRNG; else { - CYASSL_MSG("Bad RNG Init, trying global"); + WOLFSSL_MSG("Bad RNG Init, trying global"); if (initGlobalRNG == 0) - CYASSL_MSG("Global RNG no Init"); + WOLFSSL_MSG("Global RNG no Init"); else rng = &globalRNG; } @@ -10939,36 +10939,36 @@ int CyaSSL_DH_generate_key(CYASSL_DH* dh) if (rng) { if (DhGenerateKeyPair((DhKey*)dh->internal, rng, priv, &privSz, pub, &pubSz) < 0) - CYASSL_MSG("Bad DhGenerateKeyPair"); + WOLFSSL_MSG("Bad DhGenerateKeyPair"); else { if (dh->pub_key) - CyaSSL_BN_free(dh->pub_key); + wolfSSL_BN_free(dh->pub_key); - dh->pub_key = CyaSSL_BN_new(); + dh->pub_key = wolfSSL_BN_new(); if (dh->pub_key == NULL) { - CYASSL_MSG("Bad DH new pub"); + WOLFSSL_MSG("Bad DH new pub"); } if (dh->priv_key) - CyaSSL_BN_free(dh->priv_key); + wolfSSL_BN_free(dh->priv_key); - dh->priv_key = CyaSSL_BN_new(); + dh->priv_key = wolfSSL_BN_new(); if (dh->priv_key == NULL) { - CYASSL_MSG("Bad DH new priv"); + WOLFSSL_MSG("Bad DH new priv"); } if (dh->pub_key && dh->priv_key) { - if (CyaSSL_BN_bin2bn(pub, pubSz, dh->pub_key) == NULL) - CYASSL_MSG("Bad DH bn2bin error pub"); - else if (CyaSSL_BN_bin2bn(priv, privSz, dh->priv_key) == NULL) - CYASSL_MSG("Bad DH bn2bin error priv"); + if (wolfSSL_BN_bin2bn(pub, pubSz, dh->pub_key) == NULL) + WOLFSSL_MSG("Bad DH bn2bin error pub"); + else if (wolfSSL_BN_bin2bn(priv, privSz, dh->priv_key) == NULL) + WOLFSSL_MSG("Bad DH bn2bin error priv"); else ret = SSL_SUCCESS; } } } -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(tmpRNG, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(pub, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(priv, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -10979,14 +10979,14 @@ int CyaSSL_DH_generate_key(CYASSL_DH* dh) /* return key size on ok, 0 otherwise */ -int CyaSSL_DH_compute_key(unsigned char* key, CYASSL_BIGNUM* otherPub, - CYASSL_DH* dh) +int wolfSSL_DH_compute_key(unsigned char* key, WOLFSSL_BIGNUM* otherPub, + WOLFSSL_DH* dh) { int ret = 0; word32 keySz = 0; word32 pubSz = 1024; word32 privSz = 1024; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK unsigned char* pub = NULL; unsigned char* priv = NULL; #else @@ -10994,9 +10994,9 @@ int CyaSSL_DH_compute_key(unsigned char* key, CYASSL_BIGNUM* otherPub, unsigned char priv[1024]; #endif - CYASSL_MSG("CyaSSL_DH_compute_key"); + WOLFSSL_MSG("wolfSSL_DH_compute_key"); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK pub = (unsigned char*)XMALLOC(pubSz, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (pub == NULL) return ret; @@ -11009,27 +11009,27 @@ int CyaSSL_DH_compute_key(unsigned char* key, CYASSL_BIGNUM* otherPub, #endif if (dh == NULL || dh->priv_key == NULL || otherPub == NULL) - CYASSL_MSG("Bad function arguments"); + WOLFSSL_MSG("Bad function arguments"); else if ((keySz = (word32)DH_size(dh)) == 0) - CYASSL_MSG("Bad DH_size"); - else if (CyaSSL_BN_bn2bin(dh->priv_key, NULL) > (int)privSz) - CYASSL_MSG("Bad priv internal size"); - else if (CyaSSL_BN_bn2bin(otherPub, NULL) > (int)pubSz) - CYASSL_MSG("Bad otherPub size"); + WOLFSSL_MSG("Bad DH_size"); + else if (wolfSSL_BN_bn2bin(dh->priv_key, NULL) > (int)privSz) + WOLFSSL_MSG("Bad priv internal size"); + else if (wolfSSL_BN_bn2bin(otherPub, NULL) > (int)pubSz) + WOLFSSL_MSG("Bad otherPub size"); else { - privSz = CyaSSL_BN_bn2bin(dh->priv_key, priv); - pubSz = CyaSSL_BN_bn2bin(otherPub, pub); + privSz = wolfSSL_BN_bn2bin(dh->priv_key, priv); + pubSz = wolfSSL_BN_bn2bin(otherPub, pub); if (privSz <= 0 || pubSz <= 0) - CYASSL_MSG("Bad BN2bin set"); + WOLFSSL_MSG("Bad BN2bin set"); else if (DhAgree((DhKey*)dh->internal, key, &keySz, priv, privSz, pub, pubSz) < 0) - CYASSL_MSG("DhAgree failed"); + WOLFSSL_MSG("DhAgree failed"); else ret = (int)keySz; } -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(pub, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(priv, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -11040,7 +11040,7 @@ int CyaSSL_DH_compute_key(unsigned char* key, CYASSL_BIGNUM* otherPub, #ifndef NO_DSA -static void InitCyaSSL_DSA(CYASSL_DSA* dsa) +static void InitwolfSSL_DSA(WOLFSSL_DSA* dsa) { if (dsa) { dsa->p = NULL; @@ -11055,28 +11055,28 @@ static void InitCyaSSL_DSA(CYASSL_DSA* dsa) } -CYASSL_DSA* CyaSSL_DSA_new(void) +WOLFSSL_DSA* wolfSSL_DSA_new(void) { - CYASSL_DSA* external; + WOLFSSL_DSA* external; DsaKey* key; - CYASSL_MSG("CyaSSL_DSA_new"); + WOLFSSL_MSG("wolfSSL_DSA_new"); key = (DsaKey*) XMALLOC(sizeof(DsaKey), NULL, DYNAMIC_TYPE_DSA); if (key == NULL) { - CYASSL_MSG("CyaSSL_DSA_new malloc DsaKey failure"); + WOLFSSL_MSG("wolfSSL_DSA_new malloc DsaKey failure"); return NULL; } - external = (CYASSL_DSA*) XMALLOC(sizeof(CYASSL_DSA), NULL, + external = (WOLFSSL_DSA*) XMALLOC(sizeof(WOLFSSL_DSA), NULL, DYNAMIC_TYPE_DSA); if (external == NULL) { - CYASSL_MSG("CyaSSL_DSA_new malloc CYASSL_DSA failure"); + WOLFSSL_MSG("wolfSSL_DSA_new malloc WOLFSSL_DSA failure"); XFREE(key, NULL, DYNAMIC_TYPE_DSA); return NULL; } - InitCyaSSL_DSA(external); + InitwolfSSL_DSA(external); InitDsaKey(key); external->internal = key; @@ -11084,9 +11084,9 @@ CYASSL_DSA* CyaSSL_DSA_new(void) } -void CyaSSL_DSA_free(CYASSL_DSA* dsa) +void wolfSSL_DSA_free(WOLFSSL_DSA* dsa) { - CYASSL_MSG("CyaSSL_DSA_free"); + WOLFSSL_MSG("wolfSSL_DSA_free"); if (dsa) { if (dsa->internal) { @@ -11094,29 +11094,29 @@ void CyaSSL_DSA_free(CYASSL_DSA* dsa) XFREE(dsa->internal, NULL, DYNAMIC_TYPE_DSA); dsa->internal = NULL; } - CyaSSL_BN_free(dsa->priv_key); - CyaSSL_BN_free(dsa->pub_key); - CyaSSL_BN_free(dsa->g); - CyaSSL_BN_free(dsa->q); - CyaSSL_BN_free(dsa->p); - InitCyaSSL_DSA(dsa); /* set back to NULLs for safety */ + wolfSSL_BN_free(dsa->priv_key); + wolfSSL_BN_free(dsa->pub_key); + wolfSSL_BN_free(dsa->g); + wolfSSL_BN_free(dsa->q); + wolfSSL_BN_free(dsa->p); + InitwolfSSL_DSA(dsa); /* set back to NULLs for safety */ XFREE(dsa, NULL, DYNAMIC_TYPE_DSA); } } -int CyaSSL_DSA_generate_key(CYASSL_DSA* dsa) +int wolfSSL_DSA_generate_key(WOLFSSL_DSA* dsa) { (void)dsa; - CYASSL_MSG("CyaSSL_DSA_generate_key"); + WOLFSSL_MSG("wolfSSL_DSA_generate_key"); return 0; /* key gen not needed by server */ } -int CyaSSL_DSA_generate_parameters_ex(CYASSL_DSA* dsa, int bits, +int wolfSSL_DSA_generate_parameters_ex(WOLFSSL_DSA* dsa, int bits, unsigned char* seed, int seedLen, int* counterRet, unsigned long* hRet, void* cb) { @@ -11128,14 +11128,14 @@ int CyaSSL_DSA_generate_parameters_ex(CYASSL_DSA* dsa, int bits, (void)hRet; (void)cb; - CYASSL_MSG("CyaSSL_DSA_generate_parameters_ex"); + WOLFSSL_MSG("wolfSSL_DSA_generate_parameters_ex"); return 0; /* key gen not needed by server */ } #endif /* NO_DSA */ #ifndef NO_RSA -static void InitCyaSSL_Rsa(CYASSL_RSA* rsa) +static void InitwolfSSL_Rsa(WOLFSSL_RSA* rsa) { if (rsa) { rsa->n = NULL; @@ -11153,30 +11153,30 @@ static void InitCyaSSL_Rsa(CYASSL_RSA* rsa) } -CYASSL_RSA* CyaSSL_RSA_new(void) +WOLFSSL_RSA* wolfSSL_RSA_new(void) { - CYASSL_RSA* external; + WOLFSSL_RSA* external; RsaKey* key; - CYASSL_MSG("CyaSSL_RSA_new"); + WOLFSSL_MSG("wolfSSL_RSA_new"); key = (RsaKey*) XMALLOC(sizeof(RsaKey), NULL, DYNAMIC_TYPE_RSA); if (key == NULL) { - CYASSL_MSG("CyaSSL_RSA_new malloc RsaKey failure"); + WOLFSSL_MSG("wolfSSL_RSA_new malloc RsaKey failure"); return NULL; } - external = (CYASSL_RSA*) XMALLOC(sizeof(CYASSL_RSA), NULL, + external = (WOLFSSL_RSA*) XMALLOC(sizeof(WOLFSSL_RSA), NULL, DYNAMIC_TYPE_RSA); if (external == NULL) { - CYASSL_MSG("CyaSSL_RSA_new malloc CYASSL_RSA failure"); + WOLFSSL_MSG("wolfSSL_RSA_new malloc WOLFSSL_RSA failure"); XFREE(key, NULL, DYNAMIC_TYPE_RSA); return NULL; } - InitCyaSSL_Rsa(external); + InitwolfSSL_Rsa(external); if (InitRsaKey(key, NULL) != 0) { - CYASSL_MSG("InitRsaKey CYASSL_RSA failure"); + WOLFSSL_MSG("InitRsaKey WOLFSSL_RSA failure"); XFREE(external, NULL, DYNAMIC_TYPE_RSA); XFREE(key, NULL, DYNAMIC_TYPE_RSA); return NULL; @@ -11187,9 +11187,9 @@ CYASSL_RSA* CyaSSL_RSA_new(void) } -void CyaSSL_RSA_free(CYASSL_RSA* rsa) +void wolfSSL_RSA_free(WOLFSSL_RSA* rsa) { - CYASSL_MSG("CyaSSL_RSA_free"); + WOLFSSL_MSG("wolfSSL_RSA_free"); if (rsa) { if (rsa->internal) { @@ -11197,15 +11197,15 @@ void CyaSSL_RSA_free(CYASSL_RSA* rsa) XFREE(rsa->internal, NULL, DYNAMIC_TYPE_RSA); rsa->internal = NULL; } - CyaSSL_BN_free(rsa->iqmp); - CyaSSL_BN_free(rsa->dmq1); - CyaSSL_BN_free(rsa->dmp1); - CyaSSL_BN_free(rsa->q); - CyaSSL_BN_free(rsa->p); - CyaSSL_BN_free(rsa->d); - CyaSSL_BN_free(rsa->e); - CyaSSL_BN_free(rsa->n); - InitCyaSSL_Rsa(rsa); /* set back to NULLs for safety */ + wolfSSL_BN_free(rsa->iqmp); + wolfSSL_BN_free(rsa->dmq1); + wolfSSL_BN_free(rsa->dmp1); + wolfSSL_BN_free(rsa->q); + wolfSSL_BN_free(rsa->p); + wolfSSL_BN_free(rsa->d); + wolfSSL_BN_free(rsa->e); + wolfSSL_BN_free(rsa->n); + InitwolfSSL_Rsa(rsa); /* set back to NULLs for safety */ XFREE(rsa, NULL, DYNAMIC_TYPE_RSA); } @@ -11214,25 +11214,25 @@ void CyaSSL_RSA_free(CYASSL_RSA* rsa) #if !defined(NO_RSA) || !defined(NO_DSA) -static int SetIndividualExternal(CYASSL_BIGNUM** bn, mp_int* mpi) +static int SetIndividualExternal(WOLFSSL_BIGNUM** bn, mp_int* mpi) { - CYASSL_MSG("Entering SetIndividualExternal"); + WOLFSSL_MSG("Entering SetIndividualExternal"); if (mpi == NULL) { - CYASSL_MSG("mpi NULL error"); + WOLFSSL_MSG("mpi NULL error"); return SSL_FATAL_ERROR; } if (*bn == NULL) { - *bn = CyaSSL_BN_new(); + *bn = wolfSSL_BN_new(); if (*bn == NULL) { - CYASSL_MSG("SetIndividualExternal alloc failed"); + WOLFSSL_MSG("SetIndividualExternal alloc failed"); return SSL_FATAL_ERROR; } } if (mp_copy(mpi, (mp_int*)((*bn)->internal)) != MP_OKAY) { - CYASSL_MSG("mp_copy error"); + WOLFSSL_MSG("mp_copy error"); return SSL_FATAL_ERROR; } @@ -11242,40 +11242,40 @@ static int SetIndividualExternal(CYASSL_BIGNUM** bn, mp_int* mpi) #ifndef NO_DSA -static int SetDsaExternal(CYASSL_DSA* dsa) +static int SetDsaExternal(WOLFSSL_DSA* dsa) { DsaKey* key; - CYASSL_MSG("Entering SetDsaExternal"); + WOLFSSL_MSG("Entering SetDsaExternal"); if (dsa == NULL || dsa->internal == NULL) { - CYASSL_MSG("dsa key NULL error"); + WOLFSSL_MSG("dsa key NULL error"); return SSL_FATAL_ERROR; } key = (DsaKey*)dsa->internal; if (SetIndividualExternal(&dsa->p, &key->p) < 0) { - CYASSL_MSG("dsa p key error"); + WOLFSSL_MSG("dsa p key error"); return SSL_FATAL_ERROR; } if (SetIndividualExternal(&dsa->q, &key->q) < 0) { - CYASSL_MSG("dsa q key error"); + WOLFSSL_MSG("dsa q key error"); return SSL_FATAL_ERROR; } if (SetIndividualExternal(&dsa->g, &key->g) < 0) { - CYASSL_MSG("dsa g key error"); + WOLFSSL_MSG("dsa g key error"); return SSL_FATAL_ERROR; } if (SetIndividualExternal(&dsa->pub_key, &key->y) < 0) { - CYASSL_MSG("dsa y key error"); + WOLFSSL_MSG("dsa y key error"); return SSL_FATAL_ERROR; } if (SetIndividualExternal(&dsa->priv_key, &key->x) < 0) { - CYASSL_MSG("dsa x key error"); + WOLFSSL_MSG("dsa x key error"); return SSL_FATAL_ERROR; } @@ -11287,55 +11287,55 @@ static int SetDsaExternal(CYASSL_DSA* dsa) #ifndef NO_RSA -static int SetRsaExternal(CYASSL_RSA* rsa) +static int SetRsaExternal(WOLFSSL_RSA* rsa) { RsaKey* key; - CYASSL_MSG("Entering SetRsaExternal"); + WOLFSSL_MSG("Entering SetRsaExternal"); if (rsa == NULL || rsa->internal == NULL) { - CYASSL_MSG("rsa key NULL error"); + WOLFSSL_MSG("rsa key NULL error"); return SSL_FATAL_ERROR; } key = (RsaKey*)rsa->internal; if (SetIndividualExternal(&rsa->n, &key->n) < 0) { - CYASSL_MSG("rsa n key error"); + WOLFSSL_MSG("rsa n key error"); return SSL_FATAL_ERROR; } if (SetIndividualExternal(&rsa->e, &key->e) < 0) { - CYASSL_MSG("rsa e key error"); + WOLFSSL_MSG("rsa e key error"); return SSL_FATAL_ERROR; } if (SetIndividualExternal(&rsa->d, &key->d) < 0) { - CYASSL_MSG("rsa d key error"); + WOLFSSL_MSG("rsa d key error"); return SSL_FATAL_ERROR; } if (SetIndividualExternal(&rsa->p, &key->p) < 0) { - CYASSL_MSG("rsa p key error"); + WOLFSSL_MSG("rsa p key error"); return SSL_FATAL_ERROR; } if (SetIndividualExternal(&rsa->q, &key->q) < 0) { - CYASSL_MSG("rsa q key error"); + WOLFSSL_MSG("rsa q key error"); return SSL_FATAL_ERROR; } if (SetIndividualExternal(&rsa->dmp1, &key->dP) < 0) { - CYASSL_MSG("rsa dP key error"); + WOLFSSL_MSG("rsa dP key error"); return SSL_FATAL_ERROR; } if (SetIndividualExternal(&rsa->dmq1, &key->dQ) < 0) { - CYASSL_MSG("rsa dQ key error"); + WOLFSSL_MSG("rsa dQ key error"); return SSL_FATAL_ERROR; } if (SetIndividualExternal(&rsa->iqmp, &key->u) < 0) { - CYASSL_MSG("rsa u key error"); + WOLFSSL_MSG("rsa u key error"); return SSL_FATAL_ERROR; } @@ -11346,68 +11346,68 @@ static int SetRsaExternal(CYASSL_RSA* rsa) /* SSL_SUCCESS on ok */ -int CyaSSL_RSA_generate_key_ex(CYASSL_RSA* rsa, int bits, CYASSL_BIGNUM* bn, +int wolfSSL_RSA_generate_key_ex(WOLFSSL_RSA* rsa, int bits, WOLFSSL_BIGNUM* bn, void* cb) { int ret = SSL_FATAL_ERROR; - CYASSL_MSG("CyaSSL_RSA_generate_key_ex"); + WOLFSSL_MSG("wolfSSL_RSA_generate_key_ex"); (void)rsa; (void)bits; (void)cb; (void)bn; -#ifdef CYASSL_KEY_GEN +#ifdef WOLFSSL_KEY_GEN { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK RNG* rng = NULL; #else RNG rng[1]; #endif - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK rng = (RNG*)XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (rng == NULL) return SSL_FATAL_ERROR; #endif if (InitRng(rng) < 0) - CYASSL_MSG("RNG init failed"); + WOLFSSL_MSG("RNG init failed"); else if (MakeRsaKey((RsaKey*)rsa->internal, bits, 65537, rng) < 0) - CYASSL_MSG("MakeRsaKey failed"); + WOLFSSL_MSG("MakeRsaKey failed"); else if (SetRsaExternal(rsa) < 0) - CYASSL_MSG("SetRsaExternal failed"); + WOLFSSL_MSG("SetRsaExternal failed"); else { rsa->inSet = 1; ret = SSL_SUCCESS; } - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(rng, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif } #else - CYASSL_MSG("No Key Gen built in"); + WOLFSSL_MSG("No Key Gen built in"); #endif return ret; } /* SSL_SUCCESS on ok */ -int CyaSSL_RSA_blinding_on(CYASSL_RSA* rsa, CYASSL_BN_CTX* bn) +int wolfSSL_RSA_blinding_on(WOLFSSL_RSA* rsa, WOLFSSL_BN_CTX* bn) { (void)rsa; (void)bn; - CYASSL_MSG("CyaSSL_RSA_blinding_on"); + WOLFSSL_MSG("wolfSSL_RSA_blinding_on"); return SSL_SUCCESS; /* on by default */ } -int CyaSSL_RSA_public_encrypt(int len, unsigned char* fr, - unsigned char* to, CYASSL_RSA* rsa, int padding) +int wolfSSL_RSA_public_encrypt(int len, unsigned char* fr, + unsigned char* to, WOLFSSL_RSA* rsa, int padding) { (void)len; (void)fr; @@ -11415,14 +11415,14 @@ int CyaSSL_RSA_public_encrypt(int len, unsigned char* fr, (void)rsa; (void)padding; - CYASSL_MSG("CyaSSL_RSA_public_encrypt"); + WOLFSSL_MSG("wolfSSL_RSA_public_encrypt"); return SSL_FATAL_ERROR; } -int CyaSSL_RSA_private_decrypt(int len, unsigned char* fr, - unsigned char* to, CYASSL_RSA* rsa, int padding) +int wolfSSL_RSA_private_decrypt(int len, unsigned char* fr, + unsigned char* to, WOLFSSL_RSA* rsa, int padding) { (void)len; (void)fr; @@ -11430,45 +11430,45 @@ int CyaSSL_RSA_private_decrypt(int len, unsigned char* fr, (void)rsa; (void)padding; - CYASSL_MSG("CyaSSL_RSA_private_decrypt"); + WOLFSSL_MSG("wolfSSL_RSA_private_decrypt"); return SSL_FATAL_ERROR; } -int CyaSSL_RSA_size(const CYASSL_RSA* rsa) +int wolfSSL_RSA_size(const WOLFSSL_RSA* rsa) { - CYASSL_MSG("CyaSSL_RSA_size"); + WOLFSSL_MSG("wolfSSL_RSA_size"); if (rsa == NULL) return 0; - return CyaSSL_BN_num_bytes(rsa->n); + return wolfSSL_BN_num_bytes(rsa->n); } #endif /* NO_RSA */ #ifndef NO_DSA /* return SSL_SUCCESS on success, < 0 otherwise */ -int CyaSSL_DSA_do_sign(const unsigned char* d, unsigned char* sigRet, - CYASSL_DSA* dsa) +int wolfSSL_DSA_do_sign(const unsigned char* d, unsigned char* sigRet, + WOLFSSL_DSA* dsa) { int ret = SSL_FATAL_ERROR; RNG* rng = NULL; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK RNG* tmpRNG = NULL; #else RNG tmpRNG[1]; #endif - CYASSL_MSG("CyaSSL_DSA_do_sign"); + WOLFSSL_MSG("wolfSSL_DSA_do_sign"); if (d == NULL || sigRet == NULL || dsa == NULL) - CYASSL_MSG("Bad function arguments"); + WOLFSSL_MSG("Bad function arguments"); else if (dsa->inSet == 0) - CYASSL_MSG("No DSA internal set"); + WOLFSSL_MSG("No DSA internal set"); else { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK tmpRNG = (RNG*)XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (tmpRNG == NULL) return SSL_FATAL_ERROR; @@ -11477,21 +11477,21 @@ int CyaSSL_DSA_do_sign(const unsigned char* d, unsigned char* sigRet, if (InitRng(tmpRNG) == 0) rng = tmpRNG; else { - CYASSL_MSG("Bad RNG Init, trying global"); + WOLFSSL_MSG("Bad RNG Init, trying global"); if (initGlobalRNG == 0) - CYASSL_MSG("Global RNG no Init"); + WOLFSSL_MSG("Global RNG no Init"); else rng = &globalRNG; } if (rng) { if (DsaSign(d, sigRet, (DsaKey*)dsa->internal, rng) < 0) - CYASSL_MSG("DsaSign failed"); + WOLFSSL_MSG("DsaSign failed"); else ret = SSL_SUCCESS; } - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(RNG, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif } @@ -11503,15 +11503,15 @@ int CyaSSL_DSA_do_sign(const unsigned char* d, unsigned char* sigRet, #ifndef NO_RSA /* return SSL_SUCCES on ok, 0 otherwise */ -int CyaSSL_RSA_sign(int type, const unsigned char* m, +int wolfSSL_RSA_sign(int type, const unsigned char* m, unsigned int mLen, unsigned char* sigRet, - unsigned int* sigLen, CYASSL_RSA* rsa) + unsigned int* sigLen, WOLFSSL_RSA* rsa) { word32 outLen; word32 signSz; RNG* rng = NULL; int ret = 0; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK RNG* tmpRNG = NULL; byte* encodedSig = NULL; #else @@ -11519,18 +11519,18 @@ int CyaSSL_RSA_sign(int type, const unsigned char* m, byte encodedSig[MAX_ENCODED_SIG_SZ]; #endif - CYASSL_MSG("CyaSSL_RSA_sign"); + WOLFSSL_MSG("wolfSSL_RSA_sign"); if (m == NULL || sigRet == NULL || sigLen == NULL || rsa == NULL) - CYASSL_MSG("Bad function arguments"); + WOLFSSL_MSG("Bad function arguments"); else if (rsa->inSet == 0) - CYASSL_MSG("No RSA internal set"); + WOLFSSL_MSG("No RSA internal set"); else if (type != NID_md5 && type != NID_sha1) - CYASSL_MSG("Bad md type"); + WOLFSSL_MSG("Bad md type"); else { - outLen = (word32)CyaSSL_BN_num_bytes(rsa->n); + outLen = (word32)wolfSSL_BN_num_bytes(rsa->n); - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK tmpRNG = (RNG*)XMALLOC(sizeof(RNG), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (tmpRNG == NULL) return 0; @@ -11544,14 +11544,14 @@ int CyaSSL_RSA_sign(int type, const unsigned char* m, #endif if (outLen == 0) - CYASSL_MSG("Bad RSA size"); + WOLFSSL_MSG("Bad RSA size"); else if (InitRng(tmpRNG) == 0) rng = tmpRNG; else { - CYASSL_MSG("Bad RNG Init, trying global"); + WOLFSSL_MSG("Bad RNG Init, trying global"); if (initGlobalRNG == 0) - CYASSL_MSG("Global RNG no Init"); + WOLFSSL_MSG("Global RNG no Init"); else rng = &globalRNG; } @@ -11562,31 +11562,31 @@ int CyaSSL_RSA_sign(int type, const unsigned char* m, signSz = EncodeSignature(encodedSig, m, mLen, type); if (signSz == 0) { - CYASSL_MSG("Bad Encode Signature"); + WOLFSSL_MSG("Bad Encode Signature"); } else { *sigLen = RsaSSL_Sign(encodedSig, signSz, sigRet, outLen, (RsaKey*)rsa->internal, rng); if (*sigLen <= 0) - CYASSL_MSG("Bad Rsa Sign"); + WOLFSSL_MSG("Bad Rsa Sign"); else ret = SSL_SUCCESS; } } -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(tmpRNG, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(encodedSig, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif - CYASSL_MSG("CyaSSL_RSA_sign success"); + WOLFSSL_MSG("wolfSSL_RSA_sign success"); return ret; } -int CyaSSL_RSA_public_decrypt(int flen, unsigned char* from, - unsigned char* to, CYASSL_RSA* rsa, int padding) +int wolfSSL_RSA_public_decrypt(int flen, unsigned char* from, + unsigned char* to, WOLFSSL_RSA* rsa, int padding) { (void)flen; (void)from; @@ -11594,46 +11594,46 @@ int CyaSSL_RSA_public_decrypt(int flen, unsigned char* from, (void)rsa; (void)padding; - CYASSL_MSG("CyaSSL_RSA_public_decrypt"); + WOLFSSL_MSG("wolfSSL_RSA_public_decrypt"); return SSL_FATAL_ERROR; } /* generate p-1 and q-1, SSL_SUCCESS on ok */ -int CyaSSL_RSA_GenAdd(CYASSL_RSA* rsa) +int wolfSSL_RSA_GenAdd(WOLFSSL_RSA* rsa) { int err; mp_int tmp; - CYASSL_MSG("CyaSSL_RsaGenAdd"); + WOLFSSL_MSG("wolfSSL_RsaGenAdd"); if (rsa == NULL || rsa->p == NULL || rsa->q == NULL || rsa->d == NULL || rsa->dmp1 == NULL || rsa->dmq1 == NULL) { - CYASSL_MSG("rsa no init error"); + WOLFSSL_MSG("rsa no init error"); return SSL_FATAL_ERROR; } if (mp_init(&tmp) != MP_OKAY) { - CYASSL_MSG("mp_init error"); + WOLFSSL_MSG("mp_init error"); return SSL_FATAL_ERROR; } err = mp_sub_d((mp_int*)rsa->p->internal, 1, &tmp); if (err != MP_OKAY) { - CYASSL_MSG("mp_sub_d error"); + WOLFSSL_MSG("mp_sub_d error"); } else err = mp_mod((mp_int*)rsa->d->internal, &tmp, (mp_int*)rsa->dmp1->internal); if (err != MP_OKAY) { - CYASSL_MSG("mp_mod error"); + WOLFSSL_MSG("mp_mod error"); } else err = mp_sub_d((mp_int*)rsa->q->internal, 1, &tmp); if (err != MP_OKAY) { - CYASSL_MSG("mp_sub_d error"); + WOLFSSL_MSG("mp_sub_d error"); } else err = mp_mod((mp_int*)rsa->d->internal, &tmp, @@ -11649,71 +11649,71 @@ int CyaSSL_RSA_GenAdd(CYASSL_RSA* rsa) #endif /* NO_RSA */ -void CyaSSL_HMAC_Init(CYASSL_HMAC_CTX* ctx, const void* key, int keylen, +void wolfSSL_HMAC_Init(WOLFSSL_HMAC_CTX* ctx, const void* key, int keylen, const EVP_MD* type) { - CYASSL_MSG("CyaSSL_HMAC_Init"); + WOLFSSL_MSG("wolfSSL_HMAC_Init"); if (ctx == NULL) { - CYASSL_MSG("no ctx on init"); + WOLFSSL_MSG("no ctx on init"); return; } if (type) { - CYASSL_MSG("init has type"); + WOLFSSL_MSG("init has type"); if (XSTRNCMP(type, "MD5", 3) == 0) { - CYASSL_MSG("md5 hmac"); + WOLFSSL_MSG("md5 hmac"); ctx->type = MD5; } else if (XSTRNCMP(type, "SHA256", 6) == 0) { - CYASSL_MSG("sha256 hmac"); + WOLFSSL_MSG("sha256 hmac"); ctx->type = SHA256; } /* has to be last since would pick or 256, 384, or 512 too */ else if (XSTRNCMP(type, "SHA", 3) == 0) { - CYASSL_MSG("sha hmac"); + WOLFSSL_MSG("sha hmac"); ctx->type = SHA; } else { - CYASSL_MSG("bad init type"); + WOLFSSL_MSG("bad init type"); } } if (key && keylen) { - CYASSL_MSG("keying hmac"); + WOLFSSL_MSG("keying hmac"); HmacSetKey(&ctx->hmac, ctx->type, (const byte*)key, (word32)keylen); /* OpenSSL compat, no error */ } } -void CyaSSL_HMAC_Update(CYASSL_HMAC_CTX* ctx, const unsigned char* data, +void wolfSSL_HMAC_Update(WOLFSSL_HMAC_CTX* ctx, const unsigned char* data, int len) { - CYASSL_MSG("CyaSSL_HMAC_Update"); + WOLFSSL_MSG("wolfSSL_HMAC_Update"); if (ctx && data) { - CYASSL_MSG("updating hmac"); + WOLFSSL_MSG("updating hmac"); HmacUpdate(&ctx->hmac, data, (word32)len); /* OpenSSL compat, no error */ } } -void CyaSSL_HMAC_Final(CYASSL_HMAC_CTX* ctx, unsigned char* hash, +void wolfSSL_HMAC_Final(WOLFSSL_HMAC_CTX* ctx, unsigned char* hash, unsigned int* len) { - CYASSL_MSG("CyaSSL_HMAC_Final"); + WOLFSSL_MSG("wolfSSL_HMAC_Final"); if (ctx && hash) { - CYASSL_MSG("final hmac"); + WOLFSSL_MSG("final hmac"); HmacFinal(&ctx->hmac, hash); /* OpenSSL compat, no error */ if (len) { - CYASSL_MSG("setting output len"); + WOLFSSL_MSG("setting output len"); switch (ctx->type) { case MD5: *len = MD5_DIGEST_SIZE; @@ -11728,70 +11728,70 @@ void CyaSSL_HMAC_Final(CYASSL_HMAC_CTX* ctx, unsigned char* hash, break; default: - CYASSL_MSG("bad hmac type"); + WOLFSSL_MSG("bad hmac type"); } } } } -void CyaSSL_HMAC_cleanup(CYASSL_HMAC_CTX* ctx) +void wolfSSL_HMAC_cleanup(WOLFSSL_HMAC_CTX* ctx) { (void)ctx; - CYASSL_MSG("CyaSSL_HMAC_cleanup"); + WOLFSSL_MSG("wolfSSL_HMAC_cleanup"); } -const CYASSL_EVP_MD* CyaSSL_EVP_get_digestbynid(int id) +const WOLFSSL_EVP_MD* wolfSSL_EVP_get_digestbynid(int id) { - CYASSL_MSG("CyaSSL_get_digestbynid"); + WOLFSSL_MSG("wolfSSL_get_digestbynid"); switch(id) { case NID_md5: - return CyaSSL_EVP_md5(); + return wolfSSL_EVP_md5(); case NID_sha1: - return CyaSSL_EVP_sha1(); + return wolfSSL_EVP_sha1(); default: - CYASSL_MSG("Bad digest id value"); + WOLFSSL_MSG("Bad digest id value"); } return NULL; } -CYASSL_RSA* CyaSSL_EVP_PKEY_get1_RSA(CYASSL_EVP_PKEY* key) +WOLFSSL_RSA* wolfSSL_EVP_PKEY_get1_RSA(WOLFSSL_EVP_PKEY* key) { (void)key; - CYASSL_MSG("CyaSSL_EVP_PKEY_get1_RSA"); + WOLFSSL_MSG("wolfSSL_EVP_PKEY_get1_RSA"); return NULL; } -CYASSL_DSA* CyaSSL_EVP_PKEY_get1_DSA(CYASSL_EVP_PKEY* key) +WOLFSSL_DSA* wolfSSL_EVP_PKEY_get1_DSA(WOLFSSL_EVP_PKEY* key) { (void)key; - CYASSL_MSG("CyaSSL_EVP_PKEY_get1_DSA"); + WOLFSSL_MSG("wolfSSL_EVP_PKEY_get1_DSA"); return NULL; } -void* CyaSSL_EVP_X_STATE(const CYASSL_EVP_CIPHER_CTX* ctx) +void* wolfSSL_EVP_X_STATE(const WOLFSSL_EVP_CIPHER_CTX* ctx) { - CYASSL_MSG("CyaSSL_EVP_X_STATE"); + WOLFSSL_MSG("wolfSSL_EVP_X_STATE"); if (ctx) { switch (ctx->cipherType) { case ARC4_TYPE: - CYASSL_MSG("returning arc4 state"); + WOLFSSL_MSG("returning arc4 state"); return (void*)&ctx->cipher.arc4.x; default: - CYASSL_MSG("bad x state type"); + WOLFSSL_MSG("bad x state type"); return 0; } } @@ -11800,18 +11800,18 @@ void* CyaSSL_EVP_X_STATE(const CYASSL_EVP_CIPHER_CTX* ctx) } -int CyaSSL_EVP_X_STATE_LEN(const CYASSL_EVP_CIPHER_CTX* ctx) +int wolfSSL_EVP_X_STATE_LEN(const WOLFSSL_EVP_CIPHER_CTX* ctx) { - CYASSL_MSG("CyaSSL_EVP_X_STATE_LEN"); + WOLFSSL_MSG("wolfSSL_EVP_X_STATE_LEN"); if (ctx) { switch (ctx->cipherType) { case ARC4_TYPE: - CYASSL_MSG("returning arc4 state size"); + WOLFSSL_MSG("returning arc4 state size"); return sizeof(Arc4); default: - CYASSL_MSG("bad x state type"); + WOLFSSL_MSG("bad x state type"); return 0; } } @@ -11820,15 +11820,15 @@ int CyaSSL_EVP_X_STATE_LEN(const CYASSL_EVP_CIPHER_CTX* ctx) } -void CyaSSL_3des_iv(CYASSL_EVP_CIPHER_CTX* ctx, int doset, +void wolfSSL_3des_iv(WOLFSSL_EVP_CIPHER_CTX* ctx, int doset, unsigned char* iv, int len) { (void)len; - CYASSL_MSG("CyaSSL_3des_iv"); + WOLFSSL_MSG("wolfSSL_3des_iv"); if (ctx == NULL || iv == NULL) { - CYASSL_MSG("Bad function argument"); + WOLFSSL_MSG("Bad function argument"); return; } @@ -11839,15 +11839,15 @@ void CyaSSL_3des_iv(CYASSL_EVP_CIPHER_CTX* ctx, int doset, } -void CyaSSL_aes_ctr_iv(CYASSL_EVP_CIPHER_CTX* ctx, int doset, +void wolfSSL_aes_ctr_iv(WOLFSSL_EVP_CIPHER_CTX* ctx, int doset, unsigned char* iv, int len) { (void)len; - CYASSL_MSG("CyaSSL_aes_ctr_iv"); + WOLFSSL_MSG("wolfSSL_aes_ctr_iv"); if (ctx == NULL || iv == NULL) { - CYASSL_MSG("Bad function argument"); + WOLFSSL_MSG("Bad function argument"); return; } @@ -11858,20 +11858,20 @@ void CyaSSL_aes_ctr_iv(CYASSL_EVP_CIPHER_CTX* ctx, int doset, } -const CYASSL_EVP_MD* CyaSSL_EVP_ripemd160(void) +const WOLFSSL_EVP_MD* wolfSSL_EVP_ripemd160(void) { - CYASSL_MSG("CyaSSL_ripemd160"); + WOLFSSL_MSG("wolfSSL_ripemd160"); return NULL; } -int CyaSSL_EVP_MD_size(const CYASSL_EVP_MD* type) +int wolfSSL_EVP_MD_size(const WOLFSSL_EVP_MD* type) { - CYASSL_MSG("CyaSSL_EVP_MD_size"); + WOLFSSL_MSG("wolfSSL_EVP_MD_size"); if (type == NULL) { - CYASSL_MSG("No md type arg"); + WOLFSSL_MSG("No md type arg"); return BAD_FUNC_ARG; } @@ -11881,12 +11881,12 @@ int CyaSSL_EVP_MD_size(const CYASSL_EVP_MD* type) else if (XSTRNCMP(type, "SHA256", 6) == 0) { return SHA256_DIGEST_SIZE; } -#ifdef CYASSL_SHA384 +#ifdef WOLFSSL_SHA384 else if (XSTRNCMP(type, "SHA384", 6) == 0) { return SHA384_DIGEST_SIZE; } #endif -#ifdef CYASSL_SHA512 +#ifdef WOLFSSL_SHA512 else if (XSTRNCMP(type, "SHA512", 6) == 0) { return SHA512_DIGEST_SIZE; } @@ -11900,59 +11900,59 @@ int CyaSSL_EVP_MD_size(const CYASSL_EVP_MD* type) } -int CyaSSL_EVP_CIPHER_CTX_iv_length(const CYASSL_EVP_CIPHER_CTX* ctx) +int wolfSSL_EVP_CIPHER_CTX_iv_length(const WOLFSSL_EVP_CIPHER_CTX* ctx) { - CYASSL_MSG("CyaSSL_EVP_CIPHER_CTX_iv_length"); + WOLFSSL_MSG("wolfSSL_EVP_CIPHER_CTX_iv_length"); switch (ctx->cipherType) { case AES_128_CBC_TYPE : case AES_192_CBC_TYPE : case AES_256_CBC_TYPE : - CYASSL_MSG("AES CBC"); + WOLFSSL_MSG("AES CBC"); return AES_BLOCK_SIZE; -#ifdef CYASSL_AES_COUNTER +#ifdef WOLFSSL_AES_COUNTER case AES_128_CTR_TYPE : case AES_192_CTR_TYPE : case AES_256_CTR_TYPE : - CYASSL_MSG("AES CTR"); + WOLFSSL_MSG("AES CTR"); return AES_BLOCK_SIZE; #endif case DES_CBC_TYPE : - CYASSL_MSG("DES CBC"); + WOLFSSL_MSG("DES CBC"); return DES_BLOCK_SIZE; case DES_EDE3_CBC_TYPE : - CYASSL_MSG("DES EDE3 CBC"); + WOLFSSL_MSG("DES EDE3 CBC"); return DES_BLOCK_SIZE; case ARC4_TYPE : - CYASSL_MSG("ARC4"); + WOLFSSL_MSG("ARC4"); return 0; case NULL_CIPHER_TYPE : - CYASSL_MSG("NULL"); + WOLFSSL_MSG("NULL"); return 0; default: { - CYASSL_MSG("bad type"); + WOLFSSL_MSG("bad type"); } } return 0; } -void CyaSSL_OPENSSL_free(void* p) +void wolfSSL_OPENSSL_free(void* p) { - CYASSL_MSG("CyaSSL_OPENSSL_free"); + WOLFSSL_MSG("wolfSSL_OPENSSL_free"); XFREE(p, NULL, 0); } -int CyaSSL_PEM_write_bio_RSAPrivateKey(CYASSL_BIO* bio, RSA* rsa, +int wolfSSL_PEM_write_bio_RSAPrivateKey(WOLFSSL_BIO* bio, RSA* rsa, const EVP_CIPHER* cipher, unsigned char* passwd, int len, pem_password_cb cb, void* arg) @@ -11965,14 +11965,14 @@ int CyaSSL_PEM_write_bio_RSAPrivateKey(CYASSL_BIO* bio, RSA* rsa, (void)cb; (void)arg; - CYASSL_MSG("CyaSSL_PEM_write_bio_RSAPrivateKey"); + WOLFSSL_MSG("wolfSSL_PEM_write_bio_RSAPrivateKey"); return SSL_FATAL_ERROR; } -int CyaSSL_PEM_write_bio_DSAPrivateKey(CYASSL_BIO* bio, DSA* rsa, +int wolfSSL_PEM_write_bio_DSAPrivateKey(WOLFSSL_BIO* bio, DSA* rsa, const EVP_CIPHER* cipher, unsigned char* passwd, int len, pem_password_cb cb, void* arg) @@ -11985,22 +11985,22 @@ int CyaSSL_PEM_write_bio_DSAPrivateKey(CYASSL_BIO* bio, DSA* rsa, (void)cb; (void)arg; - CYASSL_MSG("CyaSSL_PEM_write_bio_DSAPrivateKey"); + WOLFSSL_MSG("wolfSSL_PEM_write_bio_DSAPrivateKey"); return SSL_FATAL_ERROR; } -CYASSL_EVP_PKEY* CyaSSL_PEM_read_bio_PrivateKey(CYASSL_BIO* bio, - CYASSL_EVP_PKEY** key, pem_password_cb cb, void* arg) +WOLFSSL_EVP_PKEY* wolfSSL_PEM_read_bio_PrivateKey(WOLFSSL_BIO* bio, + WOLFSSL_EVP_PKEY** key, pem_password_cb cb, void* arg) { (void)bio; (void)key; (void)cb; (void)arg; - CYASSL_MSG("CyaSSL_PEM_read_bio_PrivateKey"); + WOLFSSL_MSG("wolfSSL_PEM_read_bio_PrivateKey"); return NULL; } @@ -12009,26 +12009,26 @@ CYASSL_EVP_PKEY* CyaSSL_PEM_read_bio_PrivateKey(CYASSL_BIO* bio, #ifndef NO_RSA /* Load RSA from Der, SSL_SUCCESS on success < 0 on error */ -int CyaSSL_RSA_LoadDer(CYASSL_RSA* rsa, const unsigned char* der, int derSz) +int wolfSSL_RSA_LoadDer(WOLFSSL_RSA* rsa, const unsigned char* der, int derSz) { word32 idx = 0; int ret; - CYASSL_ENTER("CyaSSL_RSA_LoadDer"); + WOLFSSL_ENTER("wolfSSL_RSA_LoadDer"); if (rsa == NULL || rsa->internal == NULL || der == NULL || derSz <= 0) { - CYASSL_MSG("Bad function arguments"); + WOLFSSL_MSG("Bad function arguments"); return BAD_FUNC_ARG; } ret = RsaPrivateKeyDecode(der, &idx, (RsaKey*)rsa->internal, derSz); if (ret < 0) { - CYASSL_MSG("RsaPrivateKeyDecode failed"); + WOLFSSL_MSG("RsaPrivateKeyDecode failed"); return ret; } if (SetRsaExternal(rsa) < 0) { - CYASSL_MSG("SetRsaExternal failed"); + WOLFSSL_MSG("SetRsaExternal failed"); return SSL_FATAL_ERROR; } @@ -12041,26 +12041,26 @@ int CyaSSL_RSA_LoadDer(CYASSL_RSA* rsa, const unsigned char* der, int derSz) #ifndef NO_DSA /* Load DSA from Der, SSL_SUCCESS on success < 0 on error */ -int CyaSSL_DSA_LoadDer(CYASSL_DSA* dsa, const unsigned char* der, int derSz) +int wolfSSL_DSA_LoadDer(WOLFSSL_DSA* dsa, const unsigned char* der, int derSz) { word32 idx = 0; int ret; - CYASSL_ENTER("CyaSSL_DSA_LoadDer"); + WOLFSSL_ENTER("wolfSSL_DSA_LoadDer"); if (dsa == NULL || dsa->internal == NULL || der == NULL || derSz <= 0) { - CYASSL_MSG("Bad function arguments"); + WOLFSSL_MSG("Bad function arguments"); return BAD_FUNC_ARG; } ret = DsaPrivateKeyDecode(der, &idx, (DsaKey*)dsa->internal, derSz); if (ret < 0) { - CYASSL_MSG("DsaPrivateKeyDecode failed"); + WOLFSSL_MSG("DsaPrivateKeyDecode failed"); return ret; } if (SetDsaExternal(dsa) < 0) { - CYASSL_MSG("SetDsaExternal failed"); + WOLFSSL_MSG("SetDsaExternal failed"); return SSL_FATAL_ERROR; } @@ -12080,9 +12080,9 @@ int CyaSSL_DSA_LoadDer(CYASSL_DSA* dsa, const unsigned char* der, int derSz) /* Get peer's certificate chain */ -CYASSL_X509_CHAIN* CyaSSL_get_peer_chain(CYASSL* ssl) +WOLFSSL_X509_CHAIN* wolfSSL_get_peer_chain(WOLFSSL* ssl) { - CYASSL_ENTER("CyaSSL_get_peer_chain"); + WOLFSSL_ENTER("wolfSSL_get_peer_chain"); if (ssl) return &ssl->session.chain; @@ -12091,9 +12091,9 @@ CYASSL_X509_CHAIN* CyaSSL_get_peer_chain(CYASSL* ssl) /* Get peer's certificate chain total count */ -int CyaSSL_get_chain_count(CYASSL_X509_CHAIN* chain) +int wolfSSL_get_chain_count(WOLFSSL_X509_CHAIN* chain) { - CYASSL_ENTER("CyaSSL_get_chain_count"); + WOLFSSL_ENTER("wolfSSL_get_chain_count"); if (chain) return chain->count; @@ -12102,9 +12102,9 @@ int CyaSSL_get_chain_count(CYASSL_X509_CHAIN* chain) /* Get peer's ASN.1 DER ceritifcate at index (idx) length in bytes */ -int CyaSSL_get_chain_length(CYASSL_X509_CHAIN* chain, int idx) +int wolfSSL_get_chain_length(WOLFSSL_X509_CHAIN* chain, int idx) { - CYASSL_ENTER("CyaSSL_get_chain_length"); + WOLFSSL_ENTER("wolfSSL_get_chain_length"); if (chain) return chain->certs[idx].length; @@ -12113,9 +12113,9 @@ int CyaSSL_get_chain_length(CYASSL_X509_CHAIN* chain, int idx) /* Get peer's ASN.1 DER ceritifcate at index (idx) */ -byte* CyaSSL_get_chain_cert(CYASSL_X509_CHAIN* chain, int idx) +byte* wolfSSL_get_chain_cert(WOLFSSL_X509_CHAIN* chain, int idx) { - CYASSL_ENTER("CyaSSL_get_chain_cert"); + WOLFSSL_ENTER("wolfSSL_get_chain_cert"); if (chain) return chain->certs[idx].buffer; @@ -12123,20 +12123,20 @@ byte* CyaSSL_get_chain_cert(CYASSL_X509_CHAIN* chain, int idx) } -/* Get peer's CyaSSL X509 ceritifcate at index (idx) */ -CYASSL_X509* CyaSSL_get_chain_X509(CYASSL_X509_CHAIN* chain, int idx) +/* Get peer's wolfSSL X509 ceritifcate at index (idx) */ +WOLFSSL_X509* wolfSSL_get_chain_X509(WOLFSSL_X509_CHAIN* chain, int idx) { int ret; - CYASSL_X509* x509 = NULL; -#ifdef CYASSL_SMALL_STACK + WOLFSSL_X509* x509 = NULL; +#ifdef WOLFSSL_SMALL_STACK DecodedCert* cert = NULL; #else DecodedCert cert[1]; #endif - CYASSL_ENTER("CyaSSL_get_chain_X509"); + WOLFSSL_ENTER("wolfSSL_get_chain_X509"); if (chain != NULL) { - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK cert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL, DYNAMIC_TYPE_TMP_BUFFER); if (cert != NULL) @@ -12146,18 +12146,18 @@ CYASSL_X509* CyaSSL_get_chain_X509(CYASSL_X509_CHAIN* chain, int idx) chain->certs[idx].length, NULL); if ((ret = ParseCertRelative(cert, CERT_TYPE, 0, NULL)) != 0) - CYASSL_MSG("Failed to parse cert"); + WOLFSSL_MSG("Failed to parse cert"); else { - x509 = (CYASSL_X509*)XMALLOC(sizeof(CYASSL_X509), NULL, + x509 = (WOLFSSL_X509*)XMALLOC(sizeof(WOLFSSL_X509), NULL, DYNAMIC_TYPE_X509); if (x509 == NULL) { - CYASSL_MSG("Failed alloc X509"); + WOLFSSL_MSG("Failed alloc X509"); } else { InitX509(x509, 1); if ((ret = CopyDecodedToX509(x509, cert)) != 0) { - CYASSL_MSG("Failed to copy decoded"); + WOLFSSL_MSG("Failed to copy decoded"); XFREE(x509, NULL, DYNAMIC_TYPE_X509); x509 = NULL; } @@ -12165,7 +12165,7 @@ CYASSL_X509* CyaSSL_get_chain_X509(CYASSL_X509_CHAIN* chain, int idx) } FreeDecodedCert(cert); - #ifdef CYASSL_SMALL_STACK + #ifdef WOLFSSL_SMALL_STACK XFREE(cert, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif } @@ -12178,7 +12178,7 @@ CYASSL_X509* CyaSSL_get_chain_X509(CYASSL_X509_CHAIN* chain, int idx) /* Get peer's PEM ceritifcate at index (idx), output to buffer if inLen big enough else return error (-1), output length is in *outLen SSL_SUCCESS on ok */ -int CyaSSL_get_chain_cert_pem(CYASSL_X509_CHAIN* chain, int idx, +int wolfSSL_get_chain_cert_pem(WOLFSSL_X509_CHAIN* chain, int idx, unsigned char* buf, int inLen, int* outLen) { const char header[] = "-----BEGIN CERTIFICATE-----\n"; @@ -12189,7 +12189,7 @@ int CyaSSL_get_chain_cert_pem(CYASSL_X509_CHAIN* chain, int idx, int i; int err; - CYASSL_ENTER("CyaSSL_get_chain_cert_pem"); + WOLFSSL_ENTER("wolfSSL_get_chain_cert_pem"); if (!chain || !outLen || !buf) return BAD_FUNC_ARG; @@ -12219,9 +12219,9 @@ int CyaSSL_get_chain_cert_pem(CYASSL_X509_CHAIN* chain, int idx, /* get session ID */ -const byte* CyaSSL_get_sessionID(const CYASSL_SESSION* session) +const byte* wolfSSL_get_sessionID(const WOLFSSL_SESSION* session) { - CYASSL_ENTER("CyaSSL_get_sessionID"); + WOLFSSL_ENTER("wolfSSL_get_sessionID"); if (session) return session->sessionID; @@ -12232,7 +12232,7 @@ const byte* CyaSSL_get_sessionID(const CYASSL_SESSION* session) #endif /* SESSION_CERTS */ #ifdef HAVE_FUZZER -void CyaSSL_SetFuzzerCb(CYASSL* ssl, CallbackFuzzer cbf, void* fCtx) +void wolfSSL_SetFuzzerCb(WOLFSSL* ssl, CallbackFuzzer cbf, void* fCtx) { if (ssl) { ssl->fuzzerCb = cbf; @@ -12246,21 +12246,21 @@ void CyaSSL_SetFuzzerCb(CYASSL* ssl, CallbackFuzzer cbf, void* fCtx) #ifdef HAVE_ECC -void CyaSSL_CTX_SetEccSignCb(CYASSL_CTX* ctx, CallbackEccSign cb) +void wolfSSL_CTX_SetEccSignCb(WOLFSSL_CTX* ctx, CallbackEccSign cb) { if (ctx) ctx->EccSignCb = cb; } -void CyaSSL_SetEccSignCtx(CYASSL* ssl, void *ctx) +void wolfSSL_SetEccSignCtx(WOLFSSL* ssl, void *ctx) { if (ssl) ssl->EccSignCtx = ctx; } -void* CyaSSL_GetEccSignCtx(CYASSL* ssl) +void* wolfSSL_GetEccSignCtx(WOLFSSL* ssl) { if (ssl) return ssl->EccSignCtx; @@ -12269,21 +12269,21 @@ void* CyaSSL_GetEccSignCtx(CYASSL* ssl) } -void CyaSSL_CTX_SetEccVerifyCb(CYASSL_CTX* ctx, CallbackEccVerify cb) +void wolfSSL_CTX_SetEccVerifyCb(WOLFSSL_CTX* ctx, CallbackEccVerify cb) { if (ctx) ctx->EccVerifyCb = cb; } -void CyaSSL_SetEccVerifyCtx(CYASSL* ssl, void *ctx) +void wolfSSL_SetEccVerifyCtx(WOLFSSL* ssl, void *ctx) { if (ssl) ssl->EccVerifyCtx = ctx; } -void* CyaSSL_GetEccVerifyCtx(CYASSL* ssl) +void* wolfSSL_GetEccVerifyCtx(WOLFSSL* ssl) { if (ssl) return ssl->EccVerifyCtx; @@ -12295,21 +12295,21 @@ void* CyaSSL_GetEccVerifyCtx(CYASSL* ssl) #ifndef NO_RSA -void CyaSSL_CTX_SetRsaSignCb(CYASSL_CTX* ctx, CallbackRsaSign cb) +void wolfSSL_CTX_SetRsaSignCb(WOLFSSL_CTX* ctx, CallbackRsaSign cb) { if (ctx) ctx->RsaSignCb = cb; } -void CyaSSL_SetRsaSignCtx(CYASSL* ssl, void *ctx) +void wolfSSL_SetRsaSignCtx(WOLFSSL* ssl, void *ctx) { if (ssl) ssl->RsaSignCtx = ctx; } -void* CyaSSL_GetRsaSignCtx(CYASSL* ssl) +void* wolfSSL_GetRsaSignCtx(WOLFSSL* ssl) { if (ssl) return ssl->RsaSignCtx; @@ -12318,21 +12318,21 @@ void* CyaSSL_GetRsaSignCtx(CYASSL* ssl) } -void CyaSSL_CTX_SetRsaVerifyCb(CYASSL_CTX* ctx, CallbackRsaVerify cb) +void wolfSSL_CTX_SetRsaVerifyCb(WOLFSSL_CTX* ctx, CallbackRsaVerify cb) { if (ctx) ctx->RsaVerifyCb = cb; } -void CyaSSL_SetRsaVerifyCtx(CYASSL* ssl, void *ctx) +void wolfSSL_SetRsaVerifyCtx(WOLFSSL* ssl, void *ctx) { if (ssl) ssl->RsaVerifyCtx = ctx; } -void* CyaSSL_GetRsaVerifyCtx(CYASSL* ssl) +void* wolfSSL_GetRsaVerifyCtx(WOLFSSL* ssl) { if (ssl) return ssl->RsaVerifyCtx; @@ -12340,21 +12340,21 @@ void* CyaSSL_GetRsaVerifyCtx(CYASSL* ssl) return NULL; } -void CyaSSL_CTX_SetRsaEncCb(CYASSL_CTX* ctx, CallbackRsaEnc cb) +void wolfSSL_CTX_SetRsaEncCb(WOLFSSL_CTX* ctx, CallbackRsaEnc cb) { if (ctx) ctx->RsaEncCb = cb; } -void CyaSSL_SetRsaEncCtx(CYASSL* ssl, void *ctx) +void wolfSSL_SetRsaEncCtx(WOLFSSL* ssl, void *ctx) { if (ssl) ssl->RsaEncCtx = ctx; } -void* CyaSSL_GetRsaEncCtx(CYASSL* ssl) +void* wolfSSL_GetRsaEncCtx(WOLFSSL* ssl) { if (ssl) return ssl->RsaEncCtx; @@ -12362,21 +12362,21 @@ void* CyaSSL_GetRsaEncCtx(CYASSL* ssl) return NULL; } -void CyaSSL_CTX_SetRsaDecCb(CYASSL_CTX* ctx, CallbackRsaDec cb) +void wolfSSL_CTX_SetRsaDecCb(WOLFSSL_CTX* ctx, CallbackRsaDec cb) { if (ctx) ctx->RsaDecCb = cb; } -void CyaSSL_SetRsaDecCtx(CYASSL* ssl, void *ctx) +void wolfSSL_SetRsaDecCtx(WOLFSSL* ssl, void *ctx) { if (ssl) ssl->RsaDecCtx = ctx; } -void* CyaSSL_GetRsaDecCtx(CYASSL* ssl) +void* wolfSSL_GetRsaDecCtx(WOLFSSL* ssl) { if (ssl) return ssl->RsaDecCtx; @@ -12391,14 +12391,14 @@ void* CyaSSL_GetRsaDecCtx(CYASSL* ssl) #endif /* NO_CERTS */ -#ifdef CYASSL_HAVE_WOLFSCEP +#ifdef WOLFSSL_HAVE_WOLFSCEP /* Used by autoconf to see if wolfSCEP is available */ - void CyaSSL_wolfSCEP(void) {} + void wolfSSL_wolfSCEP(void) {} #endif -#ifdef CYASSL_HAVE_CERT_SERVICE +#ifdef WOLFSSL_HAVE_CERT_SERVICE /* Used by autoconf to see if cert service is available */ - void CyaSSL_cert_service(void) {} + void wolfSSL_cert_service(void) {} #endif diff --git a/src/tls.c b/src/tls.c index dd8a0b119..89da2d22b 100644 --- a/src/tls.c +++ b/src/tls.c @@ -2,14 +2,14 @@ * * 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 * the Free Software Foundation; either version 2 of the License, or * (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 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -20,18 +20,18 @@ */ /* Name change compatibility layer */ -#include +#include #ifdef HAVE_CONFIG_H #include #endif -#include +#include #include -#include -#include -#include +#include +#include +#include @@ -48,7 +48,7 @@ #endif /* min */ -#ifdef CYASSL_SHA384 +#ifdef WOLFSSL_SHA384 #define P_HASH_MAX_SIZE SHA384_DIGEST_SIZE #else #define P_HASH_MAX_SIZE SHA256_DIGEST_SIZE @@ -65,7 +65,7 @@ static int p_hash(byte* result, word32 resLen, const byte* secret, word32 i; word32 idx = 0; int ret = 0; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK byte* previous; byte* current; Hmac* hmac; @@ -75,7 +75,7 @@ static int p_hash(byte* result, word32 resLen, const byte* secret, Hmac hmac[1]; #endif -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK previous = (byte*)XMALLOC(P_HASH_MAX_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER); current = (byte*)XMALLOC(P_HASH_MAX_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER); hmac = (Hmac*)XMALLOC(sizeof(Hmac), NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -104,7 +104,7 @@ static int p_hash(byte* result, word32 resLen, const byte* secret, break; #endif - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 case sha384_mac: hash = SHA384; len = SHA384_DIGEST_SIZE; @@ -164,7 +164,7 @@ static int p_hash(byte* result, word32 resLen, const byte* secret, XMEMSET(current, 0, P_HASH_MAX_SIZE); XMEMSET(hmac, 0, sizeof(Hmac)); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(previous, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(current, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(hmac, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -196,7 +196,7 @@ static int doPRF(byte* digest, word32 digLen, const byte* secret,word32 secLen, int ret = 0; word32 half = (secLen + 1) / 2; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK byte* md5_half; byte* sha_half; byte* labelSeed; @@ -217,7 +217,7 @@ static int doPRF(byte* digest, word32 digLen, const byte* secret,word32 secLen, if (digLen > MAX_PRF_DIG) return BUFFER_E; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK md5_half = (byte*)XMALLOC(MAX_PRF_HALF, NULL, DYNAMIC_TYPE_TMP_BUFFER); sha_half = (byte*)XMALLOC(MAX_PRF_HALF, NULL, DYNAMIC_TYPE_TMP_BUFFER); labelSeed = (byte*)XMALLOC(MAX_PRF_LABSEED, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -253,7 +253,7 @@ static int doPRF(byte* digest, word32 digLen, const byte* secret,word32 secLen, } } -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(md5_half, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(sha_half, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(labelSeed, NULL, DYNAMIC_TYPE_TMP_BUFFER); @@ -276,7 +276,7 @@ static int PRF(byte* digest, word32 digLen, const byte* secret, word32 secLen, int ret = 0; if (useAtLeastSha256) { -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK byte* labelSeed; #else byte labelSeed[MAX_PRF_LABSEED]; /* labLen + seedLen is real size */ @@ -285,7 +285,7 @@ static int PRF(byte* digest, word32 digLen, const byte* secret, word32 secLen, if (labLen + seedLen > MAX_PRF_LABSEED) return BUFFER_E; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK labelSeed = (byte*)XMALLOC(MAX_PRF_LABSEED, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (labelSeed == NULL) @@ -302,7 +302,7 @@ static int PRF(byte* digest, word32 digLen, const byte* secret, word32 secLen, ret = p_hash(digest, digLen, secret, secLen, labelSeed, labLen + seedLen, hash_type); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(labelSeed, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif } @@ -317,14 +317,14 @@ static int PRF(byte* digest, word32 digLen, const byte* secret, word32 secLen, } -#ifdef CYASSL_SHA384 +#ifdef WOLFSSL_SHA384 #define HSHASH_SZ SHA384_DIGEST_SIZE #else #define HSHASH_SZ FINISHED_SZ #endif -int BuildTlsFinished(CYASSL* ssl, Hashes* hashes, const byte* sender) +int BuildTlsFinished(WOLFSSL* ssl, Hashes* hashes, const byte* sender) { const byte* side; byte handshake_hash[HSHASH_SZ]; @@ -346,7 +346,7 @@ int BuildTlsFinished(CYASSL* ssl, Hashes* hashes, const byte* sender) hashSz = SHA256_DIGEST_SIZE; } #endif -#ifdef CYASSL_SHA384 +#ifdef WOLFSSL_SHA384 if (ssl->specs.mac_algorithm == sha384_mac) { int ret = Sha384Final(&ssl->hashSha384, handshake_hash); @@ -408,7 +408,7 @@ static const byte key_label [KEY_LABEL_SZ + 1] = "key expansion"; /* External facing wrapper so user can call as well, 0 on success */ -int CyaSSL_DeriveTlsKeys(byte* key_data, word32 keyLen, +int wolfSSL_DeriveTlsKeys(byte* key_data, word32 keyLen, const byte* ms, word32 msLen, const byte* sr, const byte* cr, int tls1_2, int hash_type) @@ -423,33 +423,33 @@ int CyaSSL_DeriveTlsKeys(byte* key_data, word32 keyLen, } -int DeriveTlsKeys(CYASSL* ssl) +int DeriveTlsKeys(WOLFSSL* ssl) { int ret; int length = 2 * ssl->specs.hash_size + 2 * ssl->specs.key_size + 2 * ssl->specs.iv_size; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK byte* key_data; #else byte key_data[MAX_PRF_DIG]; #endif -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK key_data = (byte*)XMALLOC(MAX_PRF_DIG, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (key_data == NULL) { return MEMORY_E; } #endif - ret = CyaSSL_DeriveTlsKeys(key_data, length, + ret = wolfSSL_DeriveTlsKeys(key_data, length, ssl->arrays->masterSecret, SECRET_LEN, ssl->arrays->serverRandom, ssl->arrays->clientRandom, IsAtLeastTLSv1_2(ssl), ssl->specs.mac_algorithm); if (ret == 0) ret = StoreKeys(ssl, key_data); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(key_data, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -458,7 +458,7 @@ int DeriveTlsKeys(CYASSL* ssl) /* External facing wrapper so user can call as well, 0 on success */ -int CyaSSL_MakeTlsMasterSecret(byte* ms, word32 msLen, +int wolfSSL_MakeTlsMasterSecret(byte* ms, word32 msLen, const byte* pms, word32 pmsLen, const byte* cr, const byte* sr, int tls1_2, int hash_type) @@ -473,11 +473,11 @@ int CyaSSL_MakeTlsMasterSecret(byte* ms, word32 msLen, } -int MakeTlsMasterSecret(CYASSL* ssl) +int MakeTlsMasterSecret(WOLFSSL* ssl) { int ret; - ret = CyaSSL_MakeTlsMasterSecret(ssl->arrays->masterSecret, SECRET_LEN, + ret = wolfSSL_MakeTlsMasterSecret(ssl->arrays->masterSecret, SECRET_LEN, ssl->arrays->preMasterSecret, ssl->arrays->preMasterSz, ssl->arrays->clientRandom, ssl->arrays->serverRandom, IsAtLeastTLSv1_2(ssl), ssl->specs.mac_algorithm); @@ -501,17 +501,17 @@ int MakeTlsMasterSecret(CYASSL* ssl) /* Used by EAP-TLS and EAP-TTLS to derive keying material from * the master_secret. */ -int CyaSSL_make_eap_keys(CYASSL* ssl, void* msk, unsigned int len, +int wolfSSL_make_eap_keys(WOLFSSL* ssl, void* msk, unsigned int len, const char* label) { int ret; -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK byte* seed; #else byte seed[SEED_LEN]; #endif -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK seed = (byte*)XMALLOC(SEED_LEN, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (seed == NULL) return MEMORY_E; @@ -528,7 +528,7 @@ int CyaSSL_make_eap_keys(CYASSL* ssl, void* msk, unsigned int len, (const byte *)label, (word32)strlen(label), seed, SEED_LEN, IsAtLeastTLSv1_2(ssl), ssl->specs.mac_algorithm); -#ifdef CYASSL_SMALL_STACK +#ifdef WOLFSSL_SMALL_STACK XFREE(seed, NULL, DYNAMIC_TYPE_TMP_BUFFER); #endif @@ -571,9 +571,9 @@ static INLINE void c32toa(word32 u32, byte* c) } -static INLINE word32 GetSEQIncrement(CYASSL* ssl, int verify) +static INLINE word32 GetSEQIncrement(WOLFSSL* ssl, int verify) { -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (ssl->options.dtls) { if (verify) return ssl->keys.dtls_state.curSeq; /* explicit from peer */ @@ -588,9 +588,9 @@ static INLINE word32 GetSEQIncrement(CYASSL* ssl, int verify) } -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS -static INLINE word32 GetEpoch(CYASSL* ssl, int verify) +static INLINE word32 GetEpoch(WOLFSSL* ssl, int verify) { if (verify) return ssl->keys.dtls_state.curEpoch; @@ -598,14 +598,14 @@ static INLINE word32 GetEpoch(CYASSL* ssl, int verify) return ssl->keys.dtls_epoch; } -#endif /* CYASSL_DTLS */ +#endif /* WOLFSSL_DTLS */ /*** end copy ***/ -/* return HMAC digest type in CyaSSL format */ -int CyaSSL_GetHmacType(CYASSL* ssl) +/* return HMAC digest type in wolfSSL format */ +int wolfSSL_GetHmacType(WOLFSSL* ssl) { if (ssl == NULL) return BAD_FUNC_ARG; @@ -623,7 +623,7 @@ int CyaSSL_GetHmacType(CYASSL* ssl) return SHA256; } #endif - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 case sha384_mac: { return SHA384; @@ -650,15 +650,15 @@ int CyaSSL_GetHmacType(CYASSL* ssl) } -int CyaSSL_SetTlsHmacInner(CYASSL* ssl, byte* inner, word32 sz, int content, +int wolfSSL_SetTlsHmacInner(WOLFSSL* ssl, byte* inner, word32 sz, int content, int verify) { if (ssl == NULL || inner == NULL) return BAD_FUNC_ARG; - XMEMSET(inner, 0, CYASSL_TLS_HMAC_INNER_SZ); + XMEMSET(inner, 0, WOLFSSL_TLS_HMAC_INNER_SZ); -#ifdef CYASSL_DTLS +#ifdef WOLFSSL_DTLS if (ssl->options.dtls) c16toa((word16)GetEpoch(ssl, verify), inner); #endif @@ -673,12 +673,12 @@ int CyaSSL_SetTlsHmacInner(CYASSL* ssl, byte* inner, word32 sz, int content, /* TLS type HMAC */ -int TLS_hmac(CYASSL* ssl, byte* digest, const byte* in, word32 sz, +int TLS_hmac(WOLFSSL* ssl, byte* digest, const byte* in, word32 sz, int content, int verify) { Hmac hmac; int ret; - byte myInner[CYASSL_TLS_HMAC_INNER_SZ]; + byte myInner[WOLFSSL_TLS_HMAC_INNER_SZ]; if (ssl == NULL) return BAD_FUNC_ARG; @@ -688,10 +688,10 @@ int TLS_hmac(CYASSL* ssl, byte* digest, const byte* in, word32 sz, ssl->fuzzerCb(ssl, in, sz, FUZZ_HMAC, ssl->fuzzerCtx); #endif - CyaSSL_SetTlsHmacInner(ssl, myInner, sz, content, verify); + wolfSSL_SetTlsHmacInner(ssl, myInner, sz, content, verify); - ret = HmacSetKey(&hmac, CyaSSL_GetHmacType(ssl), - CyaSSL_GetMacSecret(ssl, verify), ssl->specs.hash_size); + ret = HmacSetKey(&hmac, wolfSSL_GetHmacType(ssl), + wolfSSL_GetMacSecret(ssl, verify), ssl->specs.hash_size); if (ret != 0) return ret; ret = HmacUpdate(&hmac, myInner, sizeof(myInner)); @@ -728,7 +728,7 @@ static INLINE word16 TLSX_ToSemaphore(word16 type) is assigned to be used by another extension. Use this check value for the new extension and decrement the check value by one. */ - CYASSL_MSG("### TLSX semaphore colision or overflow detected!"); + WOLFSSL_MSG("### TLSX semaphore colision or overflow detected!"); } } @@ -778,11 +778,11 @@ static int TLSX_Push(TLSX** list, TLSX_Type type, void* data) } -#ifndef NO_CYASSL_SERVER +#ifndef NO_WOLFSSL_SERVER -void TLSX_SetResponse(CYASSL* ssl, TLSX_Type type); +void TLSX_SetResponse(WOLFSSL* ssl, TLSX_Type type); -void TLSX_SetResponse(CYASSL* ssl, TLSX_Type type) +void TLSX_SetResponse(WOLFSSL* ssl, TLSX_Type type) { TLSX *ext = TLSX_Find(ssl->extensions, type); @@ -800,7 +800,7 @@ static void TLSX_SNI_Free(SNI* sni) { if (sni) { switch (sni->type) { - case CYASSL_SNI_HOST_NAME: + case WOLFSSL_SNI_HOST_NAME: XFREE(sni->data.host_name, 0, DYNAMIC_TYPE_TLSX); break; } @@ -830,7 +830,7 @@ static int TLSX_SNI_Append(SNI** list, byte type, const void* data, word16 size) return MEMORY_E; switch (type) { - case CYASSL_SNI_HOST_NAME: { + case WOLFSSL_SNI_HOST_NAME: { sni->data.host_name = XMALLOC(size + 1, 0, DYNAMIC_TYPE_TLSX); if (sni->data.host_name) { @@ -851,9 +851,9 @@ static int TLSX_SNI_Append(SNI** list, byte type, const void* data, word16 size) sni->type = type; sni->next = *list; -#ifndef NO_CYASSL_SERVER +#ifndef NO_WOLFSSL_SERVER sni->options = 0; - sni->status = CYASSL_SNI_NO_MATCH; + sni->status = WOLFSSL_SNI_NO_MATCH; #endif *list = sni; @@ -872,7 +872,7 @@ static word16 TLSX_SNI_GetSize(SNI* list) length += ENUM_LEN + OPAQUE16_LEN; /* sni type + sni length */ switch (sni->type) { - case CYASSL_SNI_HOST_NAME: + case WOLFSSL_SNI_HOST_NAME: length += XSTRLEN((char*)sni->data.host_name); break; } @@ -893,7 +893,7 @@ static word16 TLSX_SNI_Write(SNI* list, byte* output) output[offset++] = sni->type; /* sni type */ switch (sni->type) { - case CYASSL_SNI_HOST_NAME: + case WOLFSSL_SNI_HOST_NAME: length = XSTRLEN((char*)sni->data.host_name); c16toa(length, output + offset); /* sni length */ @@ -921,7 +921,7 @@ static SNI* TLSX_SNI_Find(SNI *list, byte type) return sni; } -#ifndef NO_CYASSL_SERVER +#ifndef NO_WOLFSSL_SERVER static void TLSX_SNI_SetStatus(TLSX* extensions, byte type, byte status) { TLSX* extension = TLSX_Find(extensions, SERVER_NAME_INDICATION); @@ -929,7 +929,7 @@ static void TLSX_SNI_SetStatus(TLSX* extensions, byte type, byte status) if (sni) { sni->status = status; - CYASSL_MSG("SNI did match!"); + WOLFSSL_MSG("SNI did match!"); } } @@ -945,10 +945,10 @@ byte TLSX_SNI_Status(TLSX* extensions, byte type) } #endif -static int TLSX_SNI_Parse(CYASSL* ssl, byte* input, word16 length, +static int TLSX_SNI_Parse(WOLFSSL* ssl, byte* input, word16 length, byte isRequest) { -#ifndef NO_CYASSL_SERVER +#ifndef NO_WOLFSSL_SERVER word16 size = 0; word16 offset = 0; #endif @@ -966,7 +966,7 @@ static int TLSX_SNI_Parse(CYASSL* ssl, byte* input, word16 length, return length ? BUFFER_ERROR : 0; /* SNI response must be empty! Nothing else to do. */ -#ifndef NO_CYASSL_SERVER +#ifndef NO_WOLFSSL_SERVER if (OPAQUE16_LEN > length) return BUFFER_ERROR; @@ -996,21 +996,21 @@ static int TLSX_SNI_Parse(CYASSL* ssl, byte* input, word16 length, } switch(type) { - case CYASSL_SNI_HOST_NAME: { + case WOLFSSL_SNI_HOST_NAME: { byte matched = (XSTRLEN(sni->data.host_name) == size) && (XSTRNCMP(sni->data.host_name, (const char*)input + offset, size) == 0); - if (matched || sni->options & CYASSL_SNI_ANSWER_ON_MISMATCH) { + if (matched || sni->options & WOLFSSL_SNI_ANSWER_ON_MISMATCH) { int r = TLSX_UseSNI(&ssl->extensions, type, input + offset, size); if (r != SSL_SUCCESS) return r; /* throw error */ TLSX_SNI_SetStatus(ssl->extensions, type, - matched ? CYASSL_SNI_REAL_MATCH : CYASSL_SNI_FAKE_MATCH); + matched ? WOLFSSL_SNI_REAL_MATCH : WOLFSSL_SNI_FAKE_MATCH); - } else if (!(sni->options & CYASSL_SNI_CONTINUE_ON_MISMATCH)) { + } else if (!(sni->options & WOLFSSL_SNI_CONTINUE_ON_MISMATCH)) { SendAlert(ssl, alert_fatal, unrecognized_name); return UNKNOWN_SNI_HOST_NAME_E; @@ -1067,15 +1067,15 @@ int TLSX_UseSNI(TLSX** extensions, byte type, const void* data, word16 size) return SSL_SUCCESS; } -#ifndef NO_CYASSL_SERVER +#ifndef NO_WOLFSSL_SERVER word16 TLSX_SNI_GetRequest(TLSX* extensions, byte type, void** data) { TLSX* extension = TLSX_Find(extensions, SERVER_NAME_INDICATION); SNI* sni = TLSX_SNI_Find(extension ? extension->data : NULL, type); - if (sni && sni->status != CYASSL_SNI_NO_MATCH) { + if (sni && sni->status != WOLFSSL_SNI_NO_MATCH) { switch (sni->type) { - case CYASSL_SNI_HOST_NAME: + case WOLFSSL_SNI_HOST_NAME: *data = sni->data.host_name; return XSTRLEN(*data); } @@ -1246,18 +1246,18 @@ static word16 TLSX_MFL_Write(byte* data, byte* output) return ENUM_LEN; } -static int TLSX_MFL_Parse(CYASSL* ssl, byte* input, word16 length, +static int TLSX_MFL_Parse(WOLFSSL* ssl, byte* input, word16 length, byte isRequest) { if (length != ENUM_LEN) return BUFFER_ERROR; switch (*input) { - case CYASSL_MFL_2_9 : ssl->max_fragment = 512; break; - case CYASSL_MFL_2_10: ssl->max_fragment = 1024; break; - case CYASSL_MFL_2_11: ssl->max_fragment = 2048; break; - case CYASSL_MFL_2_12: ssl->max_fragment = 4096; break; - case CYASSL_MFL_2_13: ssl->max_fragment = 8192; break; + case WOLFSSL_MFL_2_9 : ssl->max_fragment = 512; break; + case WOLFSSL_MFL_2_10: ssl->max_fragment = 1024; break; + case WOLFSSL_MFL_2_11: ssl->max_fragment = 2048; break; + case WOLFSSL_MFL_2_12: ssl->max_fragment = 4096; break; + case WOLFSSL_MFL_2_13: ssl->max_fragment = 8192; break; default: SendAlert(ssl, alert_fatal, illegal_parameter); @@ -1265,7 +1265,7 @@ static int TLSX_MFL_Parse(CYASSL* ssl, byte* input, word16 length, return UNKNOWN_MAX_FRAG_LEN_E; } -#ifndef NO_CYASSL_SERVER +#ifndef NO_WOLFSSL_SERVER if (isRequest) { int r = TLSX_UseMaxFragment(&ssl->extensions, *input); @@ -1286,7 +1286,7 @@ int TLSX_UseMaxFragment(TLSX** extensions, byte mfl) if (extensions == NULL) return BAD_FUNC_ARG; - if (mfl < CYASSL_MFL_2_9 || CYASSL_MFL_2_13 < mfl) + if (mfl < WOLFSSL_MFL_2_9 || WOLFSSL_MFL_2_13 < mfl) return BAD_FUNC_ARG; if ((data = XMALLOC(ENUM_LEN, 0, DYNAMIC_TYPE_TLSX)) == NULL) @@ -1320,13 +1320,13 @@ int TLSX_UseMaxFragment(TLSX** extensions, byte mfl) #ifdef HAVE_TRUNCATED_HMAC -static int TLSX_THM_Parse(CYASSL* ssl, byte* input, word16 length, +static int TLSX_THM_Parse(WOLFSSL* ssl, byte* input, word16 length, byte isRequest) { if (length != 0 || input == NULL) return BUFFER_ERROR; -#ifndef NO_CYASSL_SERVER +#ifndef NO_WOLFSSL_SERVER if (isRequest) { int r = TLSX_UseTruncatedHMAC(&ssl->extensions); @@ -1397,9 +1397,9 @@ static int TLSX_EllipticCurve_Append(EllipticCurve** list, word16 name) return 0; } -#ifndef NO_CYASSL_CLIENT +#ifndef NO_WOLFSSL_CLIENT -static void TLSX_EllipticCurve_ValidateRequest(CYASSL* ssl, byte* semaphore) +static void TLSX_EllipticCurve_ValidateRequest(WOLFSSL* ssl, byte* semaphore) { int i; @@ -1447,10 +1447,10 @@ static word16 TLSX_EllipticCurve_Write(EllipticCurve* list, byte* output) return OPAQUE16_LEN + length; } -#endif /* NO_CYASSL_CLIENT */ -#ifndef NO_CYASSL_SERVER +#endif /* NO_WOLFSSL_CLIENT */ +#ifndef NO_WOLFSSL_SERVER -static int TLSX_EllipticCurve_Parse(CYASSL* ssl, byte* input, word16 length, +static int TLSX_EllipticCurve_Parse(WOLFSSL* ssl, byte* input, word16 length, byte isRequest) { word16 offset; @@ -1480,7 +1480,7 @@ static int TLSX_EllipticCurve_Parse(CYASSL* ssl, byte* input, word16 length, return 0; } -int TLSX_ValidateEllipticCurves(CYASSL* ssl, byte first, byte second) { +int TLSX_ValidateEllipticCurves(WOLFSSL* ssl, byte first, byte second) { TLSX* extension = (first == ECC_BYTE) ? TLSX_Find(ssl->extensions, ELLIPTIC_CURVES) : NULL; @@ -1499,12 +1499,12 @@ int TLSX_ValidateEllipticCurves(CYASSL* ssl, byte first, byte second) { for (curve = extension->data; curve && !(sig && key); curve = curve->next) { switch (curve->name) { - case CYASSL_ECC_SECP160R1: oid = ECC_160R1; octets = 20; break; - case CYASSL_ECC_SECP192R1: oid = ECC_192R1; octets = 24; break; - case CYASSL_ECC_SECP224R1: oid = ECC_224R1; octets = 28; break; - case CYASSL_ECC_SECP256R1: oid = ECC_256R1; octets = 32; break; - case CYASSL_ECC_SECP384R1: oid = ECC_384R1; octets = 48; break; - case CYASSL_ECC_SECP521R1: oid = ECC_521R1; octets = 66; break; + case WOLFSSL_ECC_SECP160R1: oid = ECC_160R1; octets = 20; break; + case WOLFSSL_ECC_SECP192R1: oid = ECC_192R1; octets = 24; break; + case WOLFSSL_ECC_SECP224R1: oid = ECC_224R1; octets = 28; break; + case WOLFSSL_ECC_SECP256R1: oid = ECC_256R1; octets = 32; break; + case WOLFSSL_ECC_SECP384R1: oid = ECC_384R1; octets = 48; break; + case WOLFSSL_ECC_SECP521R1: oid = ECC_521R1; octets = 66; break; default: continue; /* unsupported curve */ } @@ -1575,7 +1575,7 @@ int TLSX_ValidateEllipticCurves(CYASSL* ssl, byte first, byte second) { return sig && key; } -#endif /* NO_CYASSL_SERVER */ +#endif /* NO_WOLFSSL_SERVER */ int TLSX_UseSupportedCurve(TLSX** extensions, word16 name) { @@ -1619,7 +1619,7 @@ int TLSX_UseSupportedCurve(TLSX** extensions, word16 name) #define EC_FREE_ALL TLSX_EllipticCurve_FreeAll #define EC_VALIDATE_REQUEST TLSX_EllipticCurve_ValidateRequest -#ifndef NO_CYASSL_CLIENT +#ifndef NO_WOLFSSL_CLIENT #define EC_GET_SIZE TLSX_EllipticCurve_GetSize #define EC_WRITE TLSX_EllipticCurve_Write #else @@ -1627,7 +1627,7 @@ int TLSX_UseSupportedCurve(TLSX** extensions, word16 name) #define EC_WRITE(a, b) 0 #endif -#ifndef NO_CYASSL_SERVER +#ifndef NO_WOLFSSL_SERVER #define EC_PARSE TLSX_EllipticCurve_Parse #else #define EC_PARSE(a, b, c, d) 0 @@ -1684,21 +1684,21 @@ static word16 TLSX_SecureRenegotiation_Write(SecureRenegotiation* data, return offset; } -static int TLSX_SecureRenegotiation_Parse(CYASSL* ssl, byte* input, +static int TLSX_SecureRenegotiation_Parse(WOLFSSL* ssl, byte* input, word16 length, byte isRequest) { int ret = SECURE_RENEGOTIATION_E; if (length >= OPAQUE8_LEN) { if (ssl->secure_renegotiation == NULL) { - #ifndef NO_CYASSL_SERVER + #ifndef NO_WOLFSSL_SERVER if (isRequest && *input == 0) { ret = 0; /* don't reply, user didn't enable */ } #endif } else if (isRequest) { - #ifndef NO_CYASSL_SERVER + #ifndef NO_WOLFSSL_SERVER if (*input == TLS_FINISHED_SZ) { /* TODO compare client_verify_data */ ret = 0; @@ -1706,7 +1706,7 @@ static int TLSX_SecureRenegotiation_Parse(CYASSL* ssl, byte* input, #endif } else { - #ifndef NO_CYASSL_CLIENT + #ifndef NO_WOLFSSL_CLIENT if (!ssl->secure_renegotiation->enabled) { if (*input == 0) { ssl->secure_renegotiation->enabled = 1; @@ -1767,7 +1767,7 @@ int TLSX_UseSecureRenegotiation(TLSX** extensions) #ifdef HAVE_SESSION_TICKET -static void TLSX_SessionTicket_ValidateRequest(CYASSL* ssl) +static void TLSX_SessionTicket_ValidateRequest(WOLFSSL* ssl) { TLSX* extension = TLSX_Find(ssl->extensions, SESSION_TICKET); SessionTicket* ticket = extension ? extension->data : NULL; @@ -1801,7 +1801,7 @@ static word16 TLSX_SessionTicket_Write(SessionTicket* ticket, byte* output, } -static int TLSX_SessionTicket_Parse(CYASSL* ssl, byte* input, word16 length, +static int TLSX_SessionTicket_Parse(WOLFSSL* ssl, byte* input, word16 length, byte isRequest) { if (!isRequest) { @@ -1818,7 +1818,7 @@ static int TLSX_SessionTicket_Parse(CYASSL* ssl, byte* input, word16 length, return 0; } -CYASSL_LOCAL SessionTicket* TLSX_SessionTicket_Create(word32 lifetime, +WOLFSSL_LOCAL SessionTicket* TLSX_SessionTicket_Create(word32 lifetime, byte* data, word16 size) { SessionTicket* ticket = (SessionTicket*)XMALLOC(sizeof(SessionTicket), @@ -1837,7 +1837,7 @@ CYASSL_LOCAL SessionTicket* TLSX_SessionTicket_Create(word32 lifetime, return ticket; } -CYASSL_LOCAL void TLSX_SessionTicket_Free(SessionTicket* ticket) +WOLFSSL_LOCAL void TLSX_SessionTicket_Free(SessionTicket* ticket) { if (ticket) { XFREE(ticket->data, NULL, DYNAMIC_TYPE_TLSX); @@ -1922,7 +1922,7 @@ void TLSX_FreeAll(TLSX* list) } } -int TLSX_SupportExtensions(CYASSL* ssl) { +int TLSX_SupportExtensions(WOLFSSL* ssl) { return ssl && (IsTLS(ssl) || ssl->version.major == DTLS_MAJOR); } @@ -2035,9 +2035,9 @@ static word16 TLSX_Write(TLSX* list, byte* output, byte* semaphore, return offset; } -#ifndef NO_CYASSL_CLIENT +#ifndef NO_WOLFSSL_CLIENT -word16 TLSX_GetRequestSize(CYASSL* ssl) +word16 TLSX_GetRequestSize(WOLFSSL* ssl) { word16 length = 0; @@ -2063,7 +2063,7 @@ word16 TLSX_GetRequestSize(CYASSL* ssl) return length; } -word16 TLSX_WriteRequest(CYASSL* ssl, byte* output) +word16 TLSX_WriteRequest(WOLFSSL* ssl, byte* output) { word16 offset = 0; @@ -2109,11 +2109,11 @@ word16 TLSX_WriteRequest(CYASSL* ssl, byte* output) return offset; } -#endif /* NO_CYASSL_CLIENT */ +#endif /* NO_WOLFSSL_CLIENT */ -#ifndef NO_CYASSL_SERVER +#ifndef NO_WOLFSSL_SERVER -word16 TLSX_GetResponseSize(CYASSL* ssl) +word16 TLSX_GetResponseSize(WOLFSSL* ssl) { word16 length = 0; byte semaphore[SEMAPHORE_SIZE] = {0}; @@ -2129,7 +2129,7 @@ word16 TLSX_GetResponseSize(CYASSL* ssl) return length; } -word16 TLSX_WriteResponse(CYASSL *ssl, byte* output) +word16 TLSX_WriteResponse(WOLFSSL *ssl, byte* output) { word16 offset = 0; @@ -2147,9 +2147,9 @@ word16 TLSX_WriteResponse(CYASSL *ssl, byte* output) return offset; } -#endif /* NO_CYASSL_SERVER */ +#endif /* NO_WOLFSSL_SERVER */ -int TLSX_Parse(CYASSL* ssl, byte* input, word16 length, byte isRequest, +int TLSX_Parse(WOLFSSL* ssl, byte* input, word16 length, byte isRequest, Suites *suites) { int ret = 0; @@ -2176,37 +2176,37 @@ int TLSX_Parse(CYASSL* ssl, byte* input, word16 length, byte isRequest, switch (type) { case SERVER_NAME_INDICATION: - CYASSL_MSG("SNI extension received"); + WOLFSSL_MSG("SNI extension received"); ret = SNI_PARSE(ssl, input + offset, size, isRequest); break; case MAX_FRAGMENT_LENGTH: - CYASSL_MSG("Max Fragment Length extension received"); + WOLFSSL_MSG("Max Fragment Length extension received"); ret = MFL_PARSE(ssl, input + offset, size, isRequest); break; case TRUNCATED_HMAC: - CYASSL_MSG("Truncated HMAC extension received"); + WOLFSSL_MSG("Truncated HMAC extension received"); ret = THM_PARSE(ssl, input + offset, size, isRequest); break; case ELLIPTIC_CURVES: - CYASSL_MSG("Elliptic Curves extension received"); + WOLFSSL_MSG("Elliptic Curves extension received"); ret = EC_PARSE(ssl, input + offset, size, isRequest); break; case SECURE_RENEGOTIATION: - CYASSL_MSG("Secure Renegotiation extension received"); + WOLFSSL_MSG("Secure Renegotiation extension received"); ret = SCR_PARSE(ssl, input + offset, size, isRequest); break; case SESSION_TICKET: - CYASSL_MSG("Session Ticket extension received"); + WOLFSSL_MSG("Session Ticket extension received"); ret = STK_PARSE(ssl, input + offset, size, isRequest); break; @@ -2226,7 +2226,7 @@ int TLSX_Parse(CYASSL* ssl, byte* input, word16 length, byte isRequest, HELLO_EXT_SIGALGO_MAX)); } } else { - CYASSL_MSG("Servers MUST NOT send SIG ALGO extension."); + WOLFSSL_MSG("Servers MUST NOT send SIG ALGO extension."); } break; @@ -2247,14 +2247,14 @@ int TLSX_Parse(CYASSL* ssl, byte* input, word16 length, byte isRequest, #endif -#ifndef NO_CYASSL_CLIENT +#ifndef NO_WOLFSSL_CLIENT #ifndef NO_OLD_TLS - CYASSL_METHOD* CyaTLSv1_client_method(void) + WOLFSSL_METHOD* wolfTLSv1_client_method(void) { - CYASSL_METHOD* method = - (CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, + WOLFSSL_METHOD* method = + (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0, DYNAMIC_TYPE_METHOD); if (method) InitSSL_Method(method, MakeTLSv1()); @@ -2262,10 +2262,10 @@ int TLSX_Parse(CYASSL* ssl, byte* input, word16 length, byte isRequest, } - CYASSL_METHOD* CyaTLSv1_1_client_method(void) + WOLFSSL_METHOD* wolfTLSv1_1_client_method(void) { - CYASSL_METHOD* method = - (CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, + WOLFSSL_METHOD* method = + (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0, DYNAMIC_TYPE_METHOD); if (method) InitSSL_Method(method, MakeTLSv1_1()); @@ -2276,10 +2276,10 @@ int TLSX_Parse(CYASSL* ssl, byte* input, word16 length, byte isRequest, #ifndef NO_SHA256 /* can't use without SHA256 */ - CYASSL_METHOD* CyaTLSv1_2_client_method(void) + WOLFSSL_METHOD* wolfTLSv1_2_client_method(void) { - CYASSL_METHOD* method = - (CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, + WOLFSSL_METHOD* method = + (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0, DYNAMIC_TYPE_METHOD); if (method) InitSSL_Method(method, MakeTLSv1_2()); @@ -2289,10 +2289,10 @@ int TLSX_Parse(CYASSL* ssl, byte* input, word16 length, byte isRequest, #endif - CYASSL_METHOD* CyaSSLv23_client_method(void) + WOLFSSL_METHOD* wolfSSLv23_client_method(void) { - CYASSL_METHOD* method = - (CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, + WOLFSSL_METHOD* method = + (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0, DYNAMIC_TYPE_METHOD); if (method) { #ifndef NO_SHA256 /* 1.2 requires SHA256 */ @@ -2308,35 +2308,35 @@ int TLSX_Parse(CYASSL* ssl, byte* input, word16 length, byte isRequest, } -#endif /* NO_CYASSL_CLIENT */ +#endif /* NO_WOLFSSL_CLIENT */ -#ifndef NO_CYASSL_SERVER +#ifndef NO_WOLFSSL_SERVER #ifndef NO_OLD_TLS - CYASSL_METHOD* CyaTLSv1_server_method(void) + WOLFSSL_METHOD* wolfTLSv1_server_method(void) { - CYASSL_METHOD* method = - (CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, + WOLFSSL_METHOD* method = + (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0, DYNAMIC_TYPE_METHOD); if (method) { InitSSL_Method(method, MakeTLSv1()); - method->side = CYASSL_SERVER_END; + method->side = WOLFSSL_SERVER_END; } return method; } - CYASSL_METHOD* CyaTLSv1_1_server_method(void) + WOLFSSL_METHOD* wolfTLSv1_1_server_method(void) { - CYASSL_METHOD* method = - (CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, + WOLFSSL_METHOD* method = + (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0, DYNAMIC_TYPE_METHOD); if (method) { InitSSL_Method(method, MakeTLSv1_1()); - method->side = CYASSL_SERVER_END; + method->side = WOLFSSL_SERVER_END; } return method; } @@ -2345,14 +2345,14 @@ int TLSX_Parse(CYASSL* ssl, byte* input, word16 length, byte isRequest, #ifndef NO_SHA256 /* can't use without SHA256 */ - CYASSL_METHOD* CyaTLSv1_2_server_method(void) + WOLFSSL_METHOD* wolfTLSv1_2_server_method(void) { - CYASSL_METHOD* method = - (CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, + WOLFSSL_METHOD* method = + (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0, DYNAMIC_TYPE_METHOD); if (method) { InitSSL_Method(method, MakeTLSv1_2()); - method->side = CYASSL_SERVER_END; + method->side = WOLFSSL_SERVER_END; } return method; } @@ -2360,10 +2360,10 @@ int TLSX_Parse(CYASSL* ssl, byte* input, word16 length, byte isRequest, #endif - CYASSL_METHOD* CyaSSLv23_server_method(void) + WOLFSSL_METHOD* wolfSSLv23_server_method(void) { - CYASSL_METHOD* method = - (CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, + WOLFSSL_METHOD* method = + (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0, DYNAMIC_TYPE_METHOD); if (method) { #ifndef NO_SHA256 /* 1.2 requires SHA256 */ @@ -2371,7 +2371,7 @@ int TLSX_Parse(CYASSL* ssl, byte* input, word16 length, byte isRequest, #else InitSSL_Method(method, MakeTLSv1_1()); #endif - method->side = CYASSL_SERVER_END; + method->side = WOLFSSL_SERVER_END; #ifndef NO_OLD_TLS method->downgrade = 1; #endif /* !NO_OLD_TLS */ @@ -2381,6 +2381,6 @@ int TLSX_Parse(CYASSL* ssl, byte* input, word16 length, byte isRequest, -#endif /* NO_CYASSL_SERVER */ +#endif /* NO_WOLFSSL_SERVER */ #endif /* NO_TLS */ diff --git a/wolfcrypt/src/camellia.c b/wolfcrypt/src/camellia.c index f0dfd76f6..87ac1a5b9 100644 --- a/wolfcrypt/src/camellia.c +++ b/wolfcrypt/src/camellia.c @@ -1528,7 +1528,7 @@ static void Camellia_DecryptBlock(const int keyBitLength, -/* CTaoCrypt wrappers to the Camellia code */ +/* wolfCrypt wrappers to the Camellia code */ int CamelliaSetKey(Camellia* cam, const byte* key, word32 len, const byte* iv) { diff --git a/wolfcrypt/src/error.c b/wolfcrypt/src/error.c index 84c90e927..7580b111e 100644 --- a/wolfcrypt/src/error.c +++ b/wolfcrypt/src/error.c @@ -2,14 +2,14 @@ * * Copyright (C) 2006-2014 wolfSSL Inc. * - * This file is part of CyaSSL. + * This file is part of wolfSSL. (formerly known as CyaSSL) * - * 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 * the Free Software Foundation; either version 2 of the License, or * (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 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -23,16 +23,16 @@ #include #endif -#include +#include -#include +#include #ifdef _MSC_VER /* 4996 warning to use MS extensions e.g., strcpy_s instead of XSTRNCPY */ #pragma warning(disable: 4996) #endif -const char* CTaoCryptGetErrorString(int error) +const char* wc_GetErrorString(int error) { #ifdef NO_ERROR_STRINGS @@ -319,7 +319,7 @@ const char* CTaoCryptGetErrorString(int error) } -void CTaoCryptErrorString(int error, char* buffer) +void wc_ErrorString(int error, char* buffer) { - XSTRNCPY(buffer, CTaoCryptGetErrorString(error), CYASSL_MAX_ERROR_SZ); + XSTRNCPY(buffer, wc_GetErrorString(error), WOLFSSL_MAX_ERROR_SZ); } diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index d207761ef..dbc3b70ac 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -2,14 +2,14 @@ * * Copyright (C) 2006-2014 wolfSSL Inc. * - * This file is part of CyaSSL. + * This file is part of wolfSSL. (formerly known as CyaSSL) * - * 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 * the Free Software Foundation; either version 2 of the License, or * (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 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. @@ -19,14 +19,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -/* wolfssl_cyassl compatibility layer */ -#include +/* wolfssl_wolfssl compatibility layer */ +#include #ifdef HAVE_CONFIG_H #include #endif -#include +#include #ifdef XMALLOC_USER #include /* we're using malloc / free direct here */ @@ -34,48 +34,48 @@ #ifndef NO_CRYPT_TEST -#ifdef CYASSL_TEST_CERT - #include +#ifdef WOLFSSL_TEST_CERT + #include #else - #include + #include #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef HAVE_ECC - #include + #include #endif #ifdef HAVE_BLAKE2 - #include + #include #endif #ifdef HAVE_LIBZ - #include + #include #endif #ifdef HAVE_PKCS7 - #include + #include #endif #ifdef HAVE_FIPS - #include + #include #endif #ifdef _MSC_VER @@ -84,29 +84,29 @@ #endif #ifdef OPENSSL_EXTRA - #include - #include - #include - #include + #include + #include + #include + #include #endif #if defined(USE_CERT_BUFFERS_1024) || defined(USE_CERT_BUFFERS_2048) /* include test cert and key buffers for use with NO_FILESYSTEM */ - #if defined(CYASSL_MDK_ARM) + #if defined(WOLFSSL_MDK_ARM) #include "cert_data.h" /* use certs_test.c for initial data, so other commands can share the data. */ #else - #include + #include #endif #endif -#if defined(CYASSL_MDK_ARM) +#if defined(WOLFSSL_MDK_ARM) #include #include - extern FILE * CyaSSL_fopen(const char *fname, const char *mode) ; - #define fopen CyaSSL_fopen + extern FILE * wolfSSL_fopen(const char *fname, const char *mode) ; + #define fopen wolfSSL_fopen #endif #ifdef HAVE_NTRU @@ -134,7 +134,7 @@ #define printf dc_log_printf #endif -#include "ctaocrypt/test/test.h" +#include "wolfcrypt/test/test.h" typedef struct testVector { @@ -219,7 +219,7 @@ typedef struct func_args { static void myFipsCb(int ok, int err, const char* hash) { printf("in my Fips callback, ok = %d, err = %d\n", ok, err); - printf("message = %s\n", CTaoCryptGetErrorString(err)); + printf("message = %s\n", wc_GetErrorString(err)); printf("hash = %s\n", hash); if (err == IN_CORE_FIPS_E) { @@ -231,7 +231,7 @@ static void myFipsCb(int ok, int err, const char* hash) #endif /* HAVE_FIPS */ -int ctaocrypt_test(void* args) +int wolfcrypt_test(void* args) { int ret = 0; @@ -260,7 +260,7 @@ int ctaocrypt_test(void* args) printf( "MD5 test passed!\n"); #endif -#ifdef CYASSL_MD2 +#ifdef WOLFSSL_MD2 if ( (ret = md2_test()) != 0) return err_sys("MD2 test failed!\n", ret); else @@ -288,21 +288,21 @@ int ctaocrypt_test(void* args) printf( "SHA-256 test passed!\n"); #endif -#ifdef CYASSL_SHA384 +#ifdef WOLFSSL_SHA384 if ( (ret = sha384_test()) != 0) return err_sys("SHA-384 test failed!\n", ret); else printf( "SHA-384 test passed!\n"); #endif -#ifdef CYASSL_SHA512 +#ifdef WOLFSSL_SHA512 if ( (ret = sha512_test()) != 0) return err_sys("SHA-512 test failed!\n", ret); else printf( "SHA-512 test passed!\n"); #endif -#ifdef CYASSL_RIPEMD +#ifdef WOLFSSL_RIPEMD if ( (ret = ripemd_test()) != 0) return err_sys("RIPEMD test failed!\n", ret); else @@ -338,14 +338,14 @@ int ctaocrypt_test(void* args) printf( "HMAC-SHA256 test passed!\n"); #endif - #ifdef CYASSL_SHA384 + #ifdef WOLFSSL_SHA384 if ( (ret = hmac_sha384_test()) != 0) return err_sys("HMAC-SHA384 test failed!\n", ret); else printf( "HMAC-SHA384 test passed!\n"); #endif - #ifdef CYASSL_SHA512 + #ifdef WOLFSSL_SHA512 if ( (ret = hmac_sha512_test()) != 0) return err_sys("HMAC-SHA512 test failed!\n", ret); else @@ -574,7 +574,7 @@ static int OpenNitroxDevice(int dma_mode,int dev_id) args.argc = argc; args.argv = argv; - ctaocrypt_test(&args); + wolfcrypt_test(&args); #ifdef HAVE_CAVIUM CspShutdown(CAVIUM_DEV_ID); @@ -586,7 +586,7 @@ static int OpenNitroxDevice(int dma_mode,int dev_id) #endif /* NO_MAIN_DRIVER */ -#ifdef CYASSL_MD2 +#ifdef WOLFSSL_MD2 int md2_test() { Md2 md2; @@ -864,7 +864,7 @@ int sha_test(void) #endif /* NO_SHA */ -#ifdef CYASSL_RIPEMD +#ifdef WOLFSSL_RIPEMD int ripemd_test(void) { RipeMd ripemd; @@ -917,7 +917,7 @@ int ripemd_test(void) return 0; } -#endif /* CYASSL_RIPEMD */ +#endif /* WOLFSSL_RIPEMD */ #ifdef HAVE_BLAKE2 @@ -1043,7 +1043,7 @@ int sha256_test(void) #endif -#ifdef CYASSL_SHA512 +#ifdef WOLFSSL_SHA512 int sha512_test(void) { Sha512 sha; @@ -1098,7 +1098,7 @@ int sha512_test(void) #endif -#ifdef CYASSL_SHA384 +#ifdef WOLFSSL_SHA384 int sha384_test(void) { Sha384 sha; @@ -1148,7 +1148,7 @@ int sha384_test(void) return 0; } -#endif /* CYASSL_SHA384 */ +#endif /* WOLFSSL_SHA384 */ #if !defined(NO_HMAC) && !defined(NO_MD5) @@ -1467,7 +1467,7 @@ int hmac_blake2b_test(void) #endif -#if !defined(NO_HMAC) && defined(CYASSL_SHA384) +#if !defined(NO_HMAC) && defined(WOLFSSL_SHA384) int hmac_sha384_test(void) { Hmac hmac; @@ -1544,7 +1544,7 @@ int hmac_sha384_test(void) #endif -#if !defined(NO_HMAC) && defined(CYASSL_SHA512) +#if !defined(NO_HMAC) && defined(WOLFSSL_SHA512) int hmac_sha512_test(void) { Hmac hmac; @@ -2147,7 +2147,7 @@ int aes_test(void) AesFreeCavium(&enc); AesFreeCavium(&dec); #endif -#ifdef CYASSL_AES_COUNTER +#ifdef WOLFSSL_AES_COUNTER { const byte ctrKey[] = { @@ -2229,9 +2229,9 @@ int aes_test(void) if (memcmp(cipher, oddCipher, 9)) return -71; } -#endif /* CYASSL_AES_COUNTER */ +#endif /* WOLFSSL_AES_COUNTER */ -#if defined(CYASSL_AESNI) && defined(CYASSL_AES_DIRECT) +#if defined(WOLFSSL_AESNI) && defined(WOLFSSL_AES_DIRECT) { const byte niPlain[] = { @@ -2269,7 +2269,7 @@ int aes_test(void) if (XMEMCMP(plain, niPlain, AES_BLOCK_SIZE) != 0) return -20007; } -#endif /* CYASSL_AESNI && CYASSL_AES_DIRECT */ +#endif /* WOLFSSL_AESNI && WOLFSSL_AES_DIRECT */ return 0; } @@ -2968,7 +2968,7 @@ byte GetEntropy(ENTROPY_CMD cmd, byte* out) #ifdef FREESCALE_MQX static const char* clientKey = "a:\\certs\\client-key.der"; static const char* clientCert = "a:\\certs\\client-cert.der"; - #ifdef CYASSL_CERT_GEN + #ifdef WOLFSSL_CERT_GEN static const char* caKeyFile = "a:\\certs\\ca-key.der"; static const char* caCertFile = "a:\\certs\\ca-cert.pem"; #ifdef HAVE_ECC @@ -2976,12 +2976,12 @@ byte GetEntropy(ENTROPY_CMD cmd, byte* out) static const char* eccCaCertFile = "a:\\certs\\server-ecc.pem"; #endif #endif - #elif defined(CYASSL_MKD_SHELL) + #elif defined(WOLFSSL_MKD_SHELL) static char* clientKey = "certs/client-key.der"; static char* clientCert = "certs/client-cert.der"; void set_clientKey(char *key) { clientKey = key ; } void set_clientCert(char *cert) { clientCert = cert ; } - #ifdef CYASSL_CERT_GEN + #ifdef WOLFSSL_CERT_GEN static char* caKeyFile = "certs/ca-key.der"; static char* caCertFile = "certs/ca-cert.pem"; void set_caKeyFile (char * key) { caKeyFile = key ; } @@ -2996,7 +2996,7 @@ byte GetEntropy(ENTROPY_CMD cmd, byte* out) #else static const char* clientKey = "./certs/client-key.der"; static const char* clientCert = "./certs/client-cert.der"; - #ifdef CYASSL_CERT_GEN + #ifdef WOLFSSL_CERT_GEN static const char* caKeyFile = "./certs/ca-key.der"; static const char* caCertFile = "./certs/ca-cert.pem"; #ifdef HAVE_ECC @@ -3026,7 +3026,7 @@ int rsa_test(void) #if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048) FILE* file, * file2; #endif -#ifdef CYASSL_TEST_CERT +#ifdef WOLFSSL_TEST_CERT DecodedCert cert; #endif @@ -3045,7 +3045,7 @@ int rsa_test(void) if (!file) { err_sys("can't open ./certs/client-key.der, " - "Please run from CyaSSL home dir", -40); + "Please run from wolfSSL home dir", -40); free(tmp); return -40; } @@ -3082,7 +3082,7 @@ int rsa_test(void) if (memcmp(plain, in, ret)) return -48; -#if defined(CYASSL_MDK_ARM) +#if defined(WOLFSSL_MDK_ARM) #define sizeof(s) strlen((char *)(s)) #endif @@ -3105,7 +3105,7 @@ int rsa_test(void) #undef sizeof #endif -#ifdef CYASSL_TEST_CERT +#ifdef WOLFSSL_TEST_CERT InitDecodedCert(&cert, tmp, (word32)bytes, 0); ret = ParseCert(&cert, CERT_TYPE, NO_VERIFY, 0); @@ -3117,7 +3117,7 @@ int rsa_test(void) #endif -#ifdef CYASSL_KEY_GEN +#ifdef WOLFSSL_KEY_GEN { byte* der; byte* pem; @@ -3216,10 +3216,10 @@ int rsa_test(void) free(pem); free(der); } -#endif /* CYASSL_KEY_GEN */ +#endif /* WOLFSSL_KEY_GEN */ -#ifdef CYASSL_CERT_GEN +#ifdef WOLFSSL_CERT_GEN /* self signed */ { Cert myCert; @@ -3229,7 +3229,7 @@ int rsa_test(void) FILE* pemFile; int certSz; int pemSz; -#ifdef CYASSL_TEST_CERT +#ifdef WOLFSSL_TEST_CERT DecodedCert decode; #endif @@ -3261,7 +3261,7 @@ int rsa_test(void) return -401; } -#ifdef CYASSL_TEST_CERT +#ifdef WOLFSSL_TEST_CERT InitDecodedCert(&decode, derCert, certSz, 0); ret = ParseCert(&decode, CERT_TYPE, NO_VERIFY, 0); if (ret != 0) { @@ -3321,7 +3321,7 @@ int rsa_test(void) size_t bytes3; word32 idx3 = 0; FILE* file3 ; -#ifdef CYASSL_TEST_CERT +#ifdef WOLFSSL_TEST_CERT DecodedCert decode; #endif @@ -3395,7 +3395,7 @@ int rsa_test(void) } -#ifdef CYASSL_TEST_CERT +#ifdef WOLFSSL_TEST_CERT InitDecodedCert(&decode, derCert, certSz, 0); ret = ParseCert(&decode, CERT_TYPE, NO_VERIFY, 0); if (ret != 0) { @@ -3464,7 +3464,7 @@ int rsa_test(void) size_t bytes3; word32 idx3 = 0; FILE* file3; -#ifdef CYASSL_TEST_CERT +#ifdef WOLFSSL_TEST_CERT DecodedCert decode; #endif @@ -3532,7 +3532,7 @@ int rsa_test(void) return -5408; } -#ifdef CYASSL_TEST_CERT +#ifdef WOLFSSL_TEST_CERT InitDecodedCert(&decode, derCert, certSz, 0); ret = ParseCert(&decode, CERT_TYPE, NO_VERIFY, 0); if (ret != 0) { @@ -3601,7 +3601,7 @@ int rsa_test(void) int certSz; int pemSz; word32 idx3; -#ifdef CYASSL_TEST_CERT +#ifdef WOLFSSL_TEST_CERT DecodedCert decode; #endif derCert = (byte*)malloc(FOURK_BUF); @@ -3716,7 +3716,7 @@ int rsa_test(void) } -#ifdef CYASSL_TEST_CERT +#ifdef WOLFSSL_TEST_CERT InitDecodedCert(&decode, derCert, certSz, 0); ret = ParseCert(&decode, CERT_TYPE, NO_VERIFY, 0); if (ret != 0) { @@ -3778,7 +3778,7 @@ int rsa_test(void) free(derCert); } #endif /* HAVE_NTRU */ -#ifdef CYASSL_CERT_REQ +#ifdef WOLFSSL_CERT_REQ { Cert req; byte* der; @@ -3864,8 +3864,8 @@ int rsa_test(void) free(pem); free(der); } -#endif /* CYASSL_CERT_REQ */ -#endif /* CYASSL_CERT_GEN */ +#endif /* WOLFSSL_CERT_REQ */ +#endif /* WOLFSSL_CERT_GEN */ FreeRsaKey(&key); #ifdef HAVE_CAVIUM @@ -4095,7 +4095,7 @@ int openssl_test(void) if (memcmp(hash, d.output, SHA256_DIGEST_SIZE) != 0) return -78; -#ifdef CYASSL_SHA384 +#ifdef WOLFSSL_SHA384 e.input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhi" "jklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; @@ -4115,10 +4115,10 @@ int openssl_test(void) if (memcmp(hash, e.output, SHA384_DIGEST_SIZE) != 0) return -79; -#endif /* CYASSL_SHA384 */ +#endif /* WOLFSSL_SHA384 */ -#ifdef CYASSL_SHA512 +#ifdef WOLFSSL_SHA512 f.input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhi" "jklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; @@ -4139,7 +4139,7 @@ int openssl_test(void) if (memcmp(hash, f.output, SHA512_DIGEST_SIZE) != 0) return -80; -#endif /* CYASSL_SHA512 */ +#endif /* WOLFSSL_SHA512 */ if (RAND_bytes(hash, sizeof(hash)) != 1) @@ -4667,7 +4667,7 @@ int ecc_test(void) } -#ifdef CYASSL_KEY_GEN +#ifdef WOLFSSL_KEY_GEN { int derSz, pemSz; byte der[FOURK_BUF]; @@ -4705,7 +4705,7 @@ int ecc_test(void) return -1029; } } -#endif /* CYASSL_KEY_GEN */ +#endif /* WOLFSSL_KEY_GEN */ ecc_free(&pubKey); ecc_free(&userB); @@ -4788,8 +4788,8 @@ int ecc_encrypt_test(void) ret = ecc_ctx_set_peer_salt(cliCtx, srvSalt); ret += ecc_ctx_set_peer_salt(srvCtx, cliSalt); - ret += ecc_ctx_set_info(cliCtx, (byte*)"CyaSSL MSGE", 11); - ret += ecc_ctx_set_info(srvCtx, (byte*)"CyaSSL MSGE", 11); + ret += ecc_ctx_set_info(cliCtx, (byte*)"wolfSSL MSGE", 11); + ret += ecc_ctx_set_info(srvCtx, (byte*)"wolfSSL MSGE", 11); if (ret != 0) return -3008; @@ -5009,7 +5009,7 @@ int pkcs7enveloped_test(void) free(cert); free(privKey); err_sys("can't open ./certs/client-cert.der, " - "Please run from CyaSSL home dir", -42); + "Please run from wolfSSL home dir", -42); return -42; } @@ -5021,7 +5021,7 @@ int pkcs7enveloped_test(void) free(cert); free(privKey); err_sys("can't open ./certs/client-key.der, " - "Please run from CyaSSL home dir", -43); + "Please run from wolfSSL home dir", -43); return -43; } @@ -5143,7 +5143,7 @@ int pkcs7signed_test(void) free(keyDer); free(out); err_sys("can't open ./certs/client-cert.der, " - "Please run from CyaSSL home dir", -44); + "Please run from wolfSSL home dir", -44); return -44; } certDerSz = (word32)fread(certDer, 1, FOURK_BUF, file); @@ -5155,7 +5155,7 @@ int pkcs7signed_test(void) free(keyDer); free(out); err_sys("can't open ./certs/client-key.der, " - "Please run from CyaSSL home dir", -45); + "Please run from wolfSSL home dir", -45); return -45; } keyDerSz = (word32)fread(keyDer, 1, FOURK_BUF, file); diff --git a/wolfssl/wolfcrypt/error-crypt.h b/wolfssl/wolfcrypt/error-crypt.h index ad6e4966f..1c5dec1be 100644 --- a/wolfssl/wolfcrypt/error-crypt.h +++ b/wolfssl/wolfcrypt/error-crypt.h @@ -20,10 +20,10 @@ */ -#ifndef CTAO_CRYPT_ERROR_H -#define CTAO_CRYPT_ERROR_H +#ifndef WOLF_CRYPT_ERROR_H +#define WOLF_CRYPT_ERROR_H -#include +#include #ifdef __cplusplus @@ -143,8 +143,8 @@ enum { }; -CYASSL_API void CTaoCryptErrorString(int err, char* buff); -CYASSL_API const char* CTaoCryptGetErrorString(int error); +WOLFSSL_API void wc_ErrorString(int err, char* buff); +WOLFSSL_API const char* wc_GetErrorString(int error); #ifdef __cplusplus