src updated, CTaoCrypt -> wc_

This commit is contained in:
Kaleb Himes 2014-12-19 11:27:01 -07:00
parent 42e5c8fb35
commit c97db6ba6e
12 changed files with 3400 additions and 3400 deletions

200
src/crl.c
View File

@ -2,14 +2,14 @@
* *
* Copyright (C) 2006-2014 wolfSSL Inc. * Copyright (C) 2006-2014 wolfSSL Inc.
* *
* This file is part of CyaSSL. * This file is part of wolfSSL. (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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* CyaSSL is distributed in the hope that it will be useful, * wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
@ -20,18 +20,18 @@
*/ */
/* Name change compatibility layer */ /* Name change compatibility layer */
#include <cyassl/ssl.h> #include <wolfssl/ssl.h>
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
#endif #endif
#include <cyassl/ctaocrypt/settings.h> #include <wolfssl/wolfcrypt/settings.h>
#ifdef HAVE_CRL #ifdef HAVE_CRL
#include <cyassl/internal.h> #include <wolfssl/internal.h>
#include <cyassl/error-ssl.h> #include <wolfssl/error-ssl.h>
#include <dirent.h> #include <dirent.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -43,9 +43,9 @@
/* Initialze CRL members */ /* 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->cm = cm;
crl->crlList = NULL; crl->crlList = NULL;
@ -65,7 +65,7 @@ int InitCRL(CYASSL_CRL* crl, CYASSL_CERT_MANAGER* cm)
/* Initialze CRL Entry */ /* Initialze CRL Entry */
static int InitCRL_Entry(CRL_Entry* crle, DecodedCRL* dcrl) 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->issuerHash, dcrl->issuerHash, SHA_DIGEST_SIZE);
/* XMEMCPY(crle->crlHash, dcrl->crlHash, 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; RevokedCert* tmp = crle->certs;
CYASSL_ENTER("FreeCRL_Entry"); WOLFSSL_ENTER("FreeCRL_Entry");
while(tmp) { while(tmp) {
RevokedCert* next = tmp->next; RevokedCert* next = tmp->next;
@ -100,11 +100,11 @@ static void FreeCRL_Entry(CRL_Entry* crle)
/* Free all CRL resources */ /* Free all CRL resources */
void FreeCRL(CYASSL_CRL* crl, int dynamic) void FreeCRL(WOLFSSL_CRL* crl, int dynamic)
{ {
CRL_Entry* tmp = crl->crlList; CRL_Entry* tmp = crl->crlList;
CYASSL_ENTER("FreeCRL"); WOLFSSL_ENTER("FreeCRL");
if (crl->monitors[0].path) if (crl->monitors[0].path)
XFREE(crl->monitors[0].path, NULL, DYNAMIC_TYPE_CRL_MONITOR); 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 #ifdef HAVE_CRL_MONITOR
if (crl->tid != 0) { if (crl->tid != 0) {
CYASSL_MSG("stopping monitor thread"); WOLFSSL_MSG("stopping monitor thread");
if (StopMonitor(crl->mfd) == 0) if (StopMonitor(crl->mfd) == 0)
pthread_join(crl->tid, NULL); pthread_join(crl->tid, NULL);
else { else {
CYASSL_MSG("stop monitor failed, cancel instead"); WOLFSSL_MSG("stop monitor failed, cancel instead");
pthread_cancel(crl->tid); 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 */ /* 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; CRL_Entry* crle;
int foundEntry = 0; int foundEntry = 0;
int ret = 0; int ret = 0;
CYASSL_ENTER("CheckCertCRL"); WOLFSSL_ENTER("CheckCertCRL");
if (LockMutex(&crl->crlLock) != 0) { if (LockMutex(&crl->crlLock) != 0) {
CYASSL_MSG("LockMutex failed"); WOLFSSL_MSG("LockMutex failed");
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
@ -154,11 +154,11 @@ int CheckCertCRL(CYASSL_CRL* crl, DecodedCert* cert)
while (crle) { while (crle) {
if (XMEMCMP(crle->issuerHash, cert->issuerHash, SHA_DIGEST_SIZE) == 0) { if (XMEMCMP(crle->issuerHash, cert->issuerHash, SHA_DIGEST_SIZE) == 0) {
CYASSL_MSG("Found CRL Entry on list"); WOLFSSL_MSG("Found CRL Entry on list");
CYASSL_MSG("Checking next date validity"); WOLFSSL_MSG("Checking next date validity");
if (!ValidateDate(crle->nextDate, crle->nextDateFormat, AFTER)) { 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; ret = ASN_AFTER_DATE_E;
} }
else else
@ -173,7 +173,7 @@ int CheckCertCRL(CYASSL_CRL* crl, DecodedCert* cert)
while (rc) { while (rc) {
if (XMEMCMP(rc->serialNumber, cert->serial, rc->serialSz) == 0) { if (XMEMCMP(rc->serialNumber, cert->serial, rc->serialSz) == 0) {
CYASSL_MSG("Cert revoked"); WOLFSSL_MSG("Cert revoked");
ret = CRL_CERT_REVOKED; ret = CRL_CERT_REVOKED;
break; break;
} }
@ -184,19 +184,19 @@ int CheckCertCRL(CYASSL_CRL* crl, DecodedCert* cert)
UnLockMutex(&crl->crlLock); UnLockMutex(&crl->crlLock);
if (foundEntry == 0) { if (foundEntry == 0) {
CYASSL_MSG("Couldn't find CRL for status check"); WOLFSSL_MSG("Couldn't find CRL for status check");
ret = CRL_MISSING; ret = CRL_MISSING;
if (crl->cm->cbMissingCRL) { if (crl->cm->cbMissingCRL) {
char url[256]; char url[256];
CYASSL_MSG("Issuing missing CRL callback"); WOLFSSL_MSG("Issuing missing CRL callback");
url[0] = '\0'; url[0] = '\0';
if (cert->extCrlInfoSz < (int)sizeof(url) -1 ) { if (cert->extCrlInfoSz < (int)sizeof(url) -1 ) {
XMEMCPY(url, cert->extCrlInfo, cert->extCrlInfoSz); XMEMCPY(url, cert->extCrlInfo, cert->extCrlInfoSz);
url[cert->extCrlInfoSz] = '\0'; url[cert->extCrlInfoSz] = '\0';
} }
else { else {
CYASSL_MSG("CRL url too long"); WOLFSSL_MSG("CRL url too long");
} }
crl->cm->cbMissingCRL(url); crl->cm->cbMissingCRL(url);
} }
@ -208,26 +208,26 @@ int CheckCertCRL(CYASSL_CRL* crl, DecodedCert* cert)
/* Add Decoded CRL, 0 on success */ /* 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; CRL_Entry* crle;
CYASSL_ENTER("AddCRL"); WOLFSSL_ENTER("AddCRL");
crle = (CRL_Entry*)XMALLOC(sizeof(CRL_Entry), NULL, DYNAMIC_TYPE_CRL_ENTRY); crle = (CRL_Entry*)XMALLOC(sizeof(CRL_Entry), NULL, DYNAMIC_TYPE_CRL_ENTRY);
if (crle == NULL) { if (crle == NULL) {
CYASSL_MSG("alloc CRL Entry failed"); WOLFSSL_MSG("alloc CRL Entry failed");
return -1; return -1;
} }
if (InitCRL_Entry(crle, dcrl) < 0) { 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); XFREE(crle, NULL, DYNAMIC_TYPE_CRL_ENTRY);
return -1; return -1;
} }
if (LockMutex(&crl->crlLock) != 0) { if (LockMutex(&crl->crlLock) != 0) {
CYASSL_MSG("LockMutex failed"); WOLFSSL_MSG("LockMutex failed");
FreeCRL_Entry(crle); FreeCRL_Entry(crle);
XFREE(crle, NULL, DYNAMIC_TYPE_CRL_ENTRY); XFREE(crle, NULL, DYNAMIC_TYPE_CRL_ENTRY);
return BAD_MUTEX_E; 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 */ /* 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; int ret = SSL_SUCCESS;
const byte* myBuffer = buff; /* if DER ok, otherwise switch */ const byte* myBuffer = buff; /* if DER ok, otherwise switch */
buffer der; buffer der;
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
DecodedCRL* dcrl; DecodedCRL* dcrl;
#else #else
DecodedCRL dcrl[1]; DecodedCRL dcrl[1];
@ -254,7 +254,7 @@ int BufferLoadCRL(CYASSL_CRL* crl, const byte* buff, long sz, int type)
der.buffer = NULL; der.buffer = NULL;
CYASSL_ENTER("BufferLoadCRL"); WOLFSSL_ENTER("BufferLoadCRL");
if (crl == NULL || buff == NULL || sz == 0) if (crl == NULL || buff == NULL || sz == 0)
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
@ -270,12 +270,12 @@ int BufferLoadCRL(CYASSL_CRL* crl, const byte* buff, long sz, int type)
sz = der.length; sz = der.length;
} }
else { else {
CYASSL_MSG("Pem to Der failed"); WOLFSSL_MSG("Pem to Der failed");
return -1; return -1;
} }
} }
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
dcrl = (DecodedCRL*)XMALLOC(sizeof(DecodedCRL), NULL, DYNAMIC_TYPE_TMP_BUFFER); dcrl = (DecodedCRL*)XMALLOC(sizeof(DecodedCRL), NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (dcrl == NULL) { if (dcrl == NULL) {
if (der.buffer) if (der.buffer)
@ -288,18 +288,18 @@ int BufferLoadCRL(CYASSL_CRL* crl, const byte* buff, long sz, int type)
InitDecodedCRL(dcrl); InitDecodedCRL(dcrl);
ret = ParseCRL(dcrl, myBuffer, (word32)sz, crl->cm); ret = ParseCRL(dcrl, myBuffer, (word32)sz, crl->cm);
if (ret != 0) { if (ret != 0) {
CYASSL_MSG("ParseCRL error"); WOLFSSL_MSG("ParseCRL error");
} }
else { else {
ret = AddCRL(crl, dcrl); ret = AddCRL(crl, dcrl);
if (ret != 0) { if (ret != 0) {
CYASSL_MSG("AddCRL error"); WOLFSSL_MSG("AddCRL error");
} }
} }
FreeDecodedCRL(dcrl); FreeDecodedCRL(dcrl);
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
XFREE(dcrl, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(dcrl, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif #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 */ /* read in new CRL entries and save new list */
static int SwapLists(CYASSL_CRL* crl) static int SwapLists(WOLFSSL_CRL* crl)
{ {
int ret; int ret;
CRL_Entry* newList; CRL_Entry* newList;
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
CYASSL_CRL* tmp; WOLFSSL_CRL* tmp;
#else #else
CYASSL_CRL tmp[1]; WOLFSSL_CRL tmp[1];
#endif #endif
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
tmp = (CYASSL_CRL*)XMALLOC(sizeof(CYASSL_CRL), NULL, DYNAMIC_TYPE_TMP_BUFFER); tmp = (WOLFSSL_CRL*)XMALLOC(sizeof(WOLFSSL_CRL), NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (tmp == NULL) if (tmp == NULL)
return MEMORY_E; return MEMORY_E;
#endif #endif
if (InitCRL(tmp, crl->cm) < 0) { if (InitCRL(tmp, crl->cm) < 0) {
CYASSL_MSG("Init tmp CRL failed"); WOLFSSL_MSG("Init tmp CRL failed");
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif #endif
return -1; return -1;
@ -341,9 +341,9 @@ static int SwapLists(CYASSL_CRL* crl)
if (crl->monitors[0].path) { if (crl->monitors[0].path) {
ret = LoadCRL(tmp, crl->monitors[0].path, SSL_FILETYPE_PEM, 0); ret = LoadCRL(tmp, crl->monitors[0].path, SSL_FILETYPE_PEM, 0);
if (ret != SSL_SUCCESS) { if (ret != SSL_SUCCESS) {
CYASSL_MSG("PEM LoadCRL on dir change failed"); WOLFSSL_MSG("PEM LoadCRL on dir change failed");
FreeCRL(tmp, 0); FreeCRL(tmp, 0);
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif #endif
return -1; return -1;
@ -353,9 +353,9 @@ static int SwapLists(CYASSL_CRL* crl)
if (crl->monitors[1].path) { if (crl->monitors[1].path) {
ret = LoadCRL(tmp, crl->monitors[1].path, SSL_FILETYPE_ASN1, 0); ret = LoadCRL(tmp, crl->monitors[1].path, SSL_FILETYPE_ASN1, 0);
if (ret != SSL_SUCCESS) { if (ret != SSL_SUCCESS) {
CYASSL_MSG("DER LoadCRL on dir change failed"); WOLFSSL_MSG("DER LoadCRL on dir change failed");
FreeCRL(tmp, 0); FreeCRL(tmp, 0);
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif #endif
return -1; return -1;
@ -363,9 +363,9 @@ static int SwapLists(CYASSL_CRL* crl)
} }
if (LockMutex(&crl->crlLock) != 0) { if (LockMutex(&crl->crlLock) != 0) {
CYASSL_MSG("LockMutex failed"); WOLFSSL_MSG("LockMutex failed");
FreeCRL(tmp, 0); FreeCRL(tmp, 0);
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif #endif
return -1; return -1;
@ -381,7 +381,7 @@ static int SwapLists(CYASSL_CRL* crl)
FreeCRL(tmp, 0); FreeCRL(tmp, 0);
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif #endif
@ -419,7 +419,7 @@ static int StopMonitor(int mfd)
/* trigger custom shutdown */ /* trigger custom shutdown */
EV_SET(&change, CRL_CUSTOM_FD, EVFILT_USER, 0, NOTE_TRIGGER, 0, NULL); EV_SET(&change, CRL_CUSTOM_FD, EVFILT_USER, 0, NOTE_TRIGGER, 0, NULL);
if (kevent(mfd, &change, 1, NULL, 0, NULL) < 0) { 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; return -1;
} }
@ -433,20 +433,20 @@ static void* DoMonitor(void* arg)
int fPEM, fDER; int fPEM, fDER;
struct kevent change; struct kevent change;
CYASSL_CRL* crl = (CYASSL_CRL*)arg; WOLFSSL_CRL* crl = (WOLFSSL_CRL*)arg;
CYASSL_ENTER("DoMonitor"); WOLFSSL_ENTER("DoMonitor");
crl->mfd = kqueue(); crl->mfd = kqueue();
if (crl->mfd == -1) { if (crl->mfd == -1) {
CYASSL_MSG("kqueue failed"); WOLFSSL_MSG("kqueue failed");
return NULL; return NULL;
} }
/* listen for custom shutdown event */ /* listen for custom shutdown event */
EV_SET(&change, CRL_CUSTOM_FD, EVFILT_USER, EV_ADD, 0, 0, NULL); EV_SET(&change, CRL_CUSTOM_FD, EVFILT_USER, EV_ADD, 0, 0, NULL);
if (kevent(crl->mfd, &change, 1, NULL, 0, NULL) < 0) { 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); close(crl->mfd);
return NULL; return NULL;
} }
@ -457,7 +457,7 @@ static void* DoMonitor(void* arg)
if (crl->monitors[0].path) { if (crl->monitors[0].path) {
fPEM = open(crl->monitors[0].path, XEVENT_MODE); fPEM = open(crl->monitors[0].path, XEVENT_MODE);
if (fPEM == -1) { if (fPEM == -1) {
CYASSL_MSG("PEM event dir open failed"); WOLFSSL_MSG("PEM event dir open failed");
close(crl->mfd); close(crl->mfd);
return NULL; return NULL;
} }
@ -466,7 +466,7 @@ static void* DoMonitor(void* arg)
if (crl->monitors[1].path) { if (crl->monitors[1].path) {
fDER = open(crl->monitors[1].path, XEVENT_MODE); fDER = open(crl->monitors[1].path, XEVENT_MODE);
if (fDER == -1) { if (fDER == -1) {
CYASSL_MSG("DER event dir open failed"); WOLFSSL_MSG("DER event dir open failed");
close(crl->mfd); close(crl->mfd);
return NULL; return NULL;
} }
@ -484,20 +484,20 @@ static void* DoMonitor(void* arg)
struct kevent event; struct kevent event;
int numEvents = kevent(crl->mfd, &change, 1, &event, 1, NULL); int numEvents = kevent(crl->mfd, &change, 1, &event, 1, NULL);
CYASSL_MSG("Got kevent"); WOLFSSL_MSG("Got kevent");
if (numEvents == -1) { if (numEvents == -1) {
CYASSL_MSG("kevent problem, continue"); WOLFSSL_MSG("kevent problem, continue");
continue; continue;
} }
if (event.filter == EVFILT_USER) { if (event.filter == EVFILT_USER) {
CYASSL_MSG("Got user shutdown event, breaking out"); WOLFSSL_MSG("Got user shutdown event, breaking out");
break; break;
} }
if (SwapLists(crl) < 0) { 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 */ /* write to our custom event */
if (write(mfd, &w64, sizeof(w64)) < 0) { if (write(mfd, &w64, sizeof(w64)) < 0) {
CYASSL_MSG("StopMonitor write failed"); WOLFSSL_MSG("StopMonitor write failed");
return -1; return -1;
} }
@ -548,24 +548,24 @@ static void* DoMonitor(void* arg)
{ {
int notifyFd; int notifyFd;
int wd = -1; int wd = -1;
CYASSL_CRL* crl = (CYASSL_CRL*)arg; WOLFSSL_CRL* crl = (WOLFSSL_CRL*)arg;
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
char* buff; char* buff;
#else #else
char buff[8192]; char buff[8192];
#endif #endif
CYASSL_ENTER("DoMonitor"); WOLFSSL_ENTER("DoMonitor");
crl->mfd = eventfd(0, 0); /* our custom shutdown event */ crl->mfd = eventfd(0, 0); /* our custom shutdown event */
if (crl->mfd < 0) { if (crl->mfd < 0) {
CYASSL_MSG("eventfd failed"); WOLFSSL_MSG("eventfd failed");
return NULL; return NULL;
} }
notifyFd = inotify_init(); notifyFd = inotify_init();
if (notifyFd < 0) { if (notifyFd < 0) {
CYASSL_MSG("inotify failed"); WOLFSSL_MSG("inotify failed");
close(crl->mfd); close(crl->mfd);
return NULL; return NULL;
} }
@ -574,7 +574,7 @@ static void* DoMonitor(void* arg)
wd = inotify_add_watch(notifyFd, crl->monitors[0].path, IN_CLOSE_WRITE | wd = inotify_add_watch(notifyFd, crl->monitors[0].path, IN_CLOSE_WRITE |
IN_DELETE); IN_DELETE);
if (wd < 0) { if (wd < 0) {
CYASSL_MSG("PEM notify add watch failed"); WOLFSSL_MSG("PEM notify add watch failed");
close(crl->mfd); close(crl->mfd);
close(notifyFd); close(notifyFd);
return NULL; return NULL;
@ -585,14 +585,14 @@ static void* DoMonitor(void* arg)
wd = inotify_add_watch(notifyFd, crl->monitors[1].path, IN_CLOSE_WRITE | wd = inotify_add_watch(notifyFd, crl->monitors[1].path, IN_CLOSE_WRITE |
IN_DELETE); IN_DELETE);
if (wd < 0) { if (wd < 0) {
CYASSL_MSG("DER notify add watch failed"); WOLFSSL_MSG("DER notify add watch failed");
close(crl->mfd); close(crl->mfd);
close(notifyFd); close(notifyFd);
return NULL; return NULL;
} }
} }
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
buff = (char*)XMALLOC(8192, NULL, DYNAMIC_TYPE_TMP_BUFFER); buff = (char*)XMALLOC(8192, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (buff == NULL) if (buff == NULL)
return NULL; return NULL;
@ -609,30 +609,30 @@ static void* DoMonitor(void* arg)
result = select(max(notifyFd, crl->mfd) + 1, &readfds, NULL, NULL,NULL); result = select(max(notifyFd, crl->mfd) + 1, &readfds, NULL, NULL,NULL);
CYASSL_MSG("Got notify event"); WOLFSSL_MSG("Got notify event");
if (result < 0) { if (result < 0) {
CYASSL_MSG("select problem, continue"); WOLFSSL_MSG("select problem, continue");
continue; continue;
} }
if (FD_ISSET(crl->mfd, &readfds)) { if (FD_ISSET(crl->mfd, &readfds)) {
CYASSL_MSG("got custom shutdown event, breaking out"); WOLFSSL_MSG("got custom shutdown event, breaking out");
break; break;
} }
length = read(notifyFd, buff, 8192); length = read(notifyFd, buff, 8192);
if (length < 0) { if (length < 0) {
CYASSL_MSG("notify read problem, continue"); WOLFSSL_MSG("notify read problem, continue");
continue; continue;
} }
if (SwapLists(crl) < 0) { 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); XFREE(buff, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif #endif
@ -653,24 +653,24 @@ static void* DoMonitor(void* arg)
/* Start Monitoring the CRL path(s) in a thread */ /* 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; pthread_attr_t attr;
CYASSL_ENTER("StartMonitorCRL"); WOLFSSL_ENTER("StartMonitorCRL");
if (crl == NULL) if (crl == NULL)
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
if (crl->tid != 0) { if (crl->tid != 0) {
CYASSL_MSG("Monitor thread already running"); WOLFSSL_MSG("Monitor thread already running");
return MONITOR_RUNNING_E; return MONITOR_RUNNING_E;
} }
pthread_attr_init(&attr); pthread_attr_init(&attr);
if (pthread_create(&crl->tid, &attr, DoMonitor, crl) != 0) { if (pthread_create(&crl->tid, &attr, DoMonitor, crl) != 0) {
CYASSL_MSG("Thread creation error"); WOLFSSL_MSG("Thread creation error");
return THREAD_CREATE_E; return THREAD_CREATE_E;
} }
@ -680,12 +680,12 @@ static int StartMonitorCRL(CYASSL_CRL* crl)
#else /* HAVE_CRL_MONITOR */ #else /* HAVE_CRL_MONITOR */
static int StartMonitorCRL(CYASSL_CRL* crl) static int StartMonitorCRL(WOLFSSL_CRL* crl)
{ {
(void)crl; (void)crl;
CYASSL_ENTER("StartMonitorCRL"); WOLFSSL_ENTER("StartMonitorCRL");
CYASSL_MSG("Not compiled in"); WOLFSSL_MSG("Not compiled in");
return 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 */ /* 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; struct dirent* entry;
DIR* dir; DIR* dir;
int ret = SSL_SUCCESS; int ret = SSL_SUCCESS;
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
char* name; char* name;
#else #else
char name[MAX_FILENAME_SZ]; char name[MAX_FILENAME_SZ];
#endif #endif
CYASSL_ENTER("LoadCRL"); WOLFSSL_ENTER("LoadCRL");
if (crl == NULL) if (crl == NULL)
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
dir = opendir(path); dir = opendir(path);
if (dir == NULL) { if (dir == NULL) {
CYASSL_MSG("opendir path crl load failed"); WOLFSSL_MSG("opendir path crl load failed");
return BAD_PATH_ERROR; return BAD_PATH_ERROR;
} }
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
name = (char*)XMALLOC(MAX_FILENAME_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER); name = (char*)XMALLOC(MAX_FILENAME_SZ, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (name == NULL) if (name == NULL)
return MEMORY_E; 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); XSTRNCAT(name, entry->d_name, MAX_FILENAME_SZ/2);
if (stat(name, &s) != 0) { if (stat(name, &s) != 0) {
CYASSL_MSG("stat on name failed"); WOLFSSL_MSG("stat on name failed");
continue; continue;
} }
if (s.st_mode & S_IFREG) { if (s.st_mode & S_IFREG) {
if (type == SSL_FILETYPE_PEM) { if (type == SSL_FILETYPE_PEM) {
if (strstr(entry->d_name, ".pem") == NULL) { if (strstr(entry->d_name, ".pem") == NULL) {
CYASSL_MSG("not .pem file, skipping"); WOLFSSL_MSG("not .pem file, skipping");
continue; continue;
} }
} }
@ -745,24 +745,24 @@ int LoadCRL(CYASSL_CRL* crl, const char* path, int type, int monitor)
if (strstr(entry->d_name, ".der") == NULL && if (strstr(entry->d_name, ".der") == NULL &&
strstr(entry->d_name, ".crl") == NULL) { strstr(entry->d_name, ".crl") == NULL) {
CYASSL_MSG("not .der or .crl file, skipping"); WOLFSSL_MSG("not .der or .crl file, skipping");
continue; continue;
} }
} }
if (ProcessFile(NULL, name, type, CRL_TYPE, NULL, 0, crl) if (ProcessFile(NULL, name, type, CRL_TYPE, NULL, 0, crl)
!= SSL_SUCCESS) { != 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); XFREE(name, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif #endif
if (monitor & CYASSL_CRL_MONITOR) { if (monitor & WOLFSSL_CRL_MONITOR) {
CYASSL_MSG("monitor path requested"); WOLFSSL_MSG("monitor path requested");
if (type == SSL_FILETYPE_PEM) { if (type == SSL_FILETYPE_PEM) {
crl->monitors[0].path = strdup(path); 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; ret = MEMORY_E;
} }
if (monitor & CYASSL_CRL_START_MON) { if (monitor & WOLFSSL_CRL_START_MON) {
CYASSL_MSG("start monitoring requested"); WOLFSSL_MSG("start monitoring requested");
ret = StartMonitorCRL(crl); ret = StartMonitorCRL(crl);
} }

File diff suppressed because it is too large Load Diff

314
src/io.c
View File

@ -2,14 +2,14 @@
* *
* Copyright (C) 2006-2014 wolfSSL Inc. * Copyright (C) 2006-2014 wolfSSL Inc.
* *
* This file is part of CyaSSL. * This file is part of wolfSSL. (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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* CyaSSL is distributed in the hope that it will be useful, * wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
@ -20,35 +20,35 @@
*/ */
/* Name change compatibility layer */ /* Name change compatibility layer */
#include <cyassl/ssl.h> #include <wolfssl/ssl.h>
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
#endif #endif
#include <cyassl/ctaocrypt/settings.h> #include <wolfssl/wolfcrypt/settings.h>
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
/* On WinCE winsock2.h must be included before windows.h for socket stuff */ /* On WinCE winsock2.h must be included before windows.h for socket stuff */
#include <winsock2.h> #include <winsock2.h>
#endif #endif
#include <cyassl/internal.h> #include <wolfssl/internal.h>
#include <cyassl/error-ssl.h> #include <wolfssl/error-ssl.h>
/* 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() automatic setting of default I/O functions EmbedSend() and EmbedReceive()
but they'll still need SetCallback xxx() at end of file but they'll still need SetCallback xxx() at end of file
*/ */
#ifndef CYASSL_USER_IO #ifndef WOLFSSL_USER_IO
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
#include "zlib.h" #include "zlib.h"
#endif #endif
#ifndef USE_WINDOWS_API #ifndef USE_WINDOWS_API
#ifdef CYASSL_LWIP #ifdef WOLFSSL_LWIP
/* lwIP needs to be configured to use sockets API in this mode */ /* lwIP needs to be configured to use sockets API in this mode */
/* LWIP_SOCKET 1 in lwip/opt.h or in build */ /* LWIP_SOCKET 1 in lwip/opt.h or in build */
#include "lwip/sockets.h" #include "lwip/sockets.h"
@ -59,8 +59,8 @@
#elif defined(FREESCALE_MQX) #elif defined(FREESCALE_MQX)
#include <posix.h> #include <posix.h>
#include <rtcs.h> #include <rtcs.h>
#elif defined(CYASSL_MDK_ARM) #elif defined(WOLFSSL_MDK_ARM)
#if defined(CYASSL_MDK5) #if defined(WOLFSSL_MDK5)
#include "cmsis_os.h" #include "cmsis_os.h"
#include "rl_fs.h" #include "rl_fs.h"
#include "rl_net.h" #include "rl_net.h"
@ -68,14 +68,14 @@
#include <rtl.h> #include <rtl.h>
#endif #endif
#undef RNG #undef RNG
#include "CYASSL_MDK_ARM.h" #include "WOLFSSL_MDK_ARM.h"
#undef RNG #undef RNG
#define RNG CyaSSL_RNG #define RNG wolfSSL_RNG
/* for avoiding name conflict in "stm32f2xx.h" */ /* for avoiding name conflict in "stm32f2xx.h" */
static int errno; static int errno;
#elif defined(CYASSL_TIRTOS) #elif defined(WOLFSSL_TIRTOS)
#include <sys/socket.h> #include <sys/socket.h>
#elif defined(CYASSL_IAR_ARM) #elif defined(WOLFSSL_IAR_ARM)
/* nothing */ /* nothing */
#else #else
#include <sys/types.h> #include <sys/types.h>
@ -85,7 +85,7 @@
#endif #endif
#include <fcntl.h> #include <fcntl.h>
#if !(defined(DEVKITPRO) || defined(HAVE_RTP_SYS) || defined(EBSNET)) \ #if !(defined(DEVKITPRO) || defined(HAVE_RTP_SYS) || defined(EBSNET)) \
|| defined(CYASSL_PICOTCP) || defined(WOLFSSL_PICOTCP)
#include <sys/socket.h> #include <sys/socket.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netinet/in.h> #include <netinet/in.h>
@ -140,8 +140,8 @@
#define SOCKET_EPIPE EPIPE #define SOCKET_EPIPE EPIPE
#define SOCKET_ECONNREFUSED RTCSERR_TCP_CONN_REFUSED #define SOCKET_ECONNREFUSED RTCSERR_TCP_CONN_REFUSED
#define SOCKET_ECONNABORTED RTCSERR_TCP_CONN_ABORTED #define SOCKET_ECONNABORTED RTCSERR_TCP_CONN_ABORTED
#elif defined(CYASSL_MDK_ARM) #elif defined(WOLFSSL_MDK_ARM)
#if defined(CYASSL_MDK5) #if defined(WOLFSSL_MDK5)
#define SOCKET_EWOULDBLOCK BSD_ERROR_WOULDBLOCK #define SOCKET_EWOULDBLOCK BSD_ERROR_WOULDBLOCK
#define SOCKET_EAGAIN BSD_ERROR_LOCKED #define SOCKET_EAGAIN BSD_ERROR_LOCKED
#define SOCKET_ECONNRESET BSD_ERROR_CLOSED #define SOCKET_ECONNRESET BSD_ERROR_CLOSED
@ -158,7 +158,7 @@
#define SOCKET_ECONNREFUSED SCK_ERROR #define SOCKET_ECONNREFUSED SCK_ERROR
#define SOCKET_ECONNABORTED SCK_ERROR #define SOCKET_ECONNABORTED SCK_ERROR
#endif #endif
#elif defined(CYASSL_PICOTCP) #elif defined(WOLFSSL_PICOTCP)
#define SOCKET_EWOULDBLOCK PICO_ERR_EAGAIN #define SOCKET_EWOULDBLOCK PICO_ERR_EAGAIN
#define SOCKET_EAGAIN PICO_ERR_EAGAIN #define SOCKET_EAGAIN PICO_ERR_EAGAIN
#define SOCKET_ECONNRESET PICO_ERR_ECONNRESET #define SOCKET_ECONNRESET PICO_ERR_ECONNRESET
@ -183,10 +183,10 @@
int net_recv(int, void*, int, unsigned int); int net_recv(int, void*, int, unsigned int);
#define SEND_FUNCTION net_send #define SEND_FUNCTION net_send
#define RECV_FUNCTION net_recv #define RECV_FUNCTION net_recv
#elif defined(CYASSL_LWIP) #elif defined(WOLFSSL_LWIP)
#define SEND_FUNCTION lwip_send #define SEND_FUNCTION lwip_send
#define RECV_FUNCTION lwip_recv #define RECV_FUNCTION lwip_recv
#elif defined(CYASSL_PICOTCP) #elif defined(WOLFSSL_PICOTCP)
#define SEND_FUNCTION pico_send #define SEND_FUNCTION pico_send
#define RECV_FUNCTION pico_recv #define RECV_FUNCTION pico_recv
#else #else
@ -232,17 +232,17 @@ static INLINE int LastError(void)
/* The receive embedded callback /* The receive embedded callback
* return : nb bytes read, or error * 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 recvd;
int err; int err;
int sd = *(int*)ctx; int sd = *(int*)ctx;
#ifdef CYASSL_DTLS #ifdef WOLFSSL_DTLS
{ {
int dtls_timeout = CyaSSL_dtls_get_current_timeout(ssl); int dtls_timeout = wolfSSL_dtls_get_current_timeout(ssl);
if (CyaSSL_dtls(ssl) if (wolfSSL_dtls(ssl)
&& !CyaSSL_get_using_nonblock(ssl) && !wolfSSL_get_using_nonblock(ssl)
&& dtls_timeout != 0) { && dtls_timeout != 0) {
#ifdef USE_WINDOWS_API #ifdef USE_WINDOWS_API
DWORD timeout = dtls_timeout * 1000; DWORD timeout = dtls_timeout * 1000;
@ -253,7 +253,7 @@ int EmbedReceive(CYASSL *ssl, char *buf, int sz, void *ctx)
#endif #endif
if (setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, if (setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout,
sizeof(timeout)) != 0) { 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) { if (recvd < 0) {
err = LastError(); err = LastError();
CYASSL_MSG("Embed Receive error"); WOLFSSL_MSG("Embed Receive error");
if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) { if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) {
if (!CyaSSL_dtls(ssl) || CyaSSL_get_using_nonblock(ssl)) { if (!wolfSSL_dtls(ssl) || wolfSSL_get_using_nonblock(ssl)) {
CYASSL_MSG(" Would block"); WOLFSSL_MSG(" Would block");
return CYASSL_CBIO_ERR_WANT_READ; return WOLFSSL_CBIO_ERR_WANT_READ;
} }
else { else {
CYASSL_MSG(" Socket timeout"); WOLFSSL_MSG(" Socket timeout");
return CYASSL_CBIO_ERR_TIMEOUT; return WOLFSSL_CBIO_ERR_TIMEOUT;
} }
} }
else if (err == SOCKET_ECONNRESET) { else if (err == SOCKET_ECONNRESET) {
CYASSL_MSG(" Connection reset"); WOLFSSL_MSG(" Connection reset");
return CYASSL_CBIO_ERR_CONN_RST; return WOLFSSL_CBIO_ERR_CONN_RST;
} }
else if (err == SOCKET_EINTR) { else if (err == SOCKET_EINTR) {
CYASSL_MSG(" Socket interrupted"); WOLFSSL_MSG(" Socket interrupted");
return CYASSL_CBIO_ERR_ISR; return WOLFSSL_CBIO_ERR_ISR;
} }
else if (err == SOCKET_ECONNREFUSED) { else if (err == SOCKET_ECONNREFUSED) {
CYASSL_MSG(" Connection refused"); WOLFSSL_MSG(" Connection refused");
return CYASSL_CBIO_ERR_WANT_READ; return WOLFSSL_CBIO_ERR_WANT_READ;
} }
else if (err == SOCKET_ECONNABORTED) { else if (err == SOCKET_ECONNABORTED) {
CYASSL_MSG(" Connection aborted"); WOLFSSL_MSG(" Connection aborted");
return CYASSL_CBIO_ERR_CONN_CLOSE; return WOLFSSL_CBIO_ERR_CONN_CLOSE;
} }
else { else {
CYASSL_MSG(" General error"); WOLFSSL_MSG(" General error");
return CYASSL_CBIO_ERR_GENERAL; return WOLFSSL_CBIO_ERR_GENERAL;
} }
} }
else if (recvd == 0) { else if (recvd == 0) {
CYASSL_MSG("Embed receive connection closed"); WOLFSSL_MSG("Embed receive connection closed");
return CYASSL_CBIO_ERR_CONN_CLOSE; return WOLFSSL_CBIO_ERR_CONN_CLOSE;
} }
return recvd; return recvd;
@ -309,7 +309,7 @@ int EmbedReceive(CYASSL *ssl, char *buf, int sz, void *ctx)
/* The send embedded callback /* The send embedded callback
* return : nb bytes sent, or error * 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 sd = *(int*)ctx;
int sent; int sent;
@ -320,27 +320,27 @@ int EmbedSend(CYASSL* ssl, char *buf, int sz, void *ctx)
if (sent < 0) { if (sent < 0) {
err = LastError(); err = LastError();
CYASSL_MSG("Embed Send error"); WOLFSSL_MSG("Embed Send error");
if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) { if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) {
CYASSL_MSG(" Would Block"); WOLFSSL_MSG(" Would Block");
return CYASSL_CBIO_ERR_WANT_WRITE; return WOLFSSL_CBIO_ERR_WANT_WRITE;
} }
else if (err == SOCKET_ECONNRESET) { else if (err == SOCKET_ECONNRESET) {
CYASSL_MSG(" Connection reset"); WOLFSSL_MSG(" Connection reset");
return CYASSL_CBIO_ERR_CONN_RST; return WOLFSSL_CBIO_ERR_CONN_RST;
} }
else if (err == SOCKET_EINTR) { else if (err == SOCKET_EINTR) {
CYASSL_MSG(" Socket interrupted"); WOLFSSL_MSG(" Socket interrupted");
return CYASSL_CBIO_ERR_ISR; return WOLFSSL_CBIO_ERR_ISR;
} }
else if (err == SOCKET_EPIPE) { else if (err == SOCKET_EPIPE) {
CYASSL_MSG(" Socket EPIPE"); WOLFSSL_MSG(" Socket EPIPE");
return CYASSL_CBIO_ERR_CONN_CLOSE; return WOLFSSL_CBIO_ERR_CONN_CLOSE;
} }
else { else {
CYASSL_MSG(" General error"); WOLFSSL_MSG(" General error");
return CYASSL_CBIO_ERR_GENERAL; 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 <cyassl/ctaocrypt/sha.h> #include <wolfssl/wolfcrypt/sha.h>
#ifdef USE_WINDOWS_API #ifdef USE_WINDOWS_API
#define XSOCKLENT int #define XSOCKLENT int
@ -365,19 +365,19 @@ int EmbedSend(CYASSL* ssl, char *buf, int sz, void *ctx)
/* The receive embedded callback /* The receive embedded callback
* return : nb bytes read, or error * 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 recvd;
int err; int err;
int sd = dtlsCtx->fd; 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; struct sockaddr_storage peer;
XSOCKLENT peerSz = sizeof(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 #ifdef USE_WINDOWS_API
DWORD timeout = dtls_timeout * 1000; DWORD timeout = dtls_timeout * 1000;
#else #else
@ -387,7 +387,7 @@ int EmbedReceiveFrom(CYASSL *ssl, char *buf, int sz, void *ctx)
#endif #endif
if (setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, if (setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout,
sizeof(timeout)) != 0) { 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) { if (recvd < 0) {
err = LastError(); err = LastError();
CYASSL_MSG("Embed Receive From error"); WOLFSSL_MSG("Embed Receive From error");
if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) { if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) {
if (CyaSSL_get_using_nonblock(ssl)) { if (wolfSSL_get_using_nonblock(ssl)) {
CYASSL_MSG(" Would block"); WOLFSSL_MSG(" Would block");
return CYASSL_CBIO_ERR_WANT_READ; return WOLFSSL_CBIO_ERR_WANT_READ;
} }
else { else {
CYASSL_MSG(" Socket timeout"); WOLFSSL_MSG(" Socket timeout");
return CYASSL_CBIO_ERR_TIMEOUT; return WOLFSSL_CBIO_ERR_TIMEOUT;
} }
} }
else if (err == SOCKET_ECONNRESET) { else if (err == SOCKET_ECONNRESET) {
CYASSL_MSG(" Connection reset"); WOLFSSL_MSG(" Connection reset");
return CYASSL_CBIO_ERR_CONN_RST; return WOLFSSL_CBIO_ERR_CONN_RST;
} }
else if (err == SOCKET_EINTR) { else if (err == SOCKET_EINTR) {
CYASSL_MSG(" Socket interrupted"); WOLFSSL_MSG(" Socket interrupted");
return CYASSL_CBIO_ERR_ISR; return WOLFSSL_CBIO_ERR_ISR;
} }
else if (err == SOCKET_ECONNREFUSED) { else if (err == SOCKET_ECONNREFUSED) {
CYASSL_MSG(" Connection refused"); WOLFSSL_MSG(" Connection refused");
return CYASSL_CBIO_ERR_WANT_READ; return WOLFSSL_CBIO_ERR_WANT_READ;
} }
else { else {
CYASSL_MSG(" General error"); WOLFSSL_MSG(" General error");
return CYASSL_CBIO_ERR_GENERAL; return WOLFSSL_CBIO_ERR_GENERAL;
} }
} }
else { else {
if (dtlsCtx->peer.sz > 0 if (dtlsCtx->peer.sz > 0
&& peerSz != (XSOCKLENT)dtlsCtx->peer.sz && peerSz != (XSOCKLENT)dtlsCtx->peer.sz
&& memcmp(&peer, dtlsCtx->peer.sa, peerSz) != 0) { && memcmp(&peer, dtlsCtx->peer.sa, peerSz) != 0) {
CYASSL_MSG(" Ignored packet from invalid peer"); WOLFSSL_MSG(" Ignored packet from invalid peer");
return CYASSL_CBIO_ERR_WANT_READ; return WOLFSSL_CBIO_ERR_WANT_READ;
} }
} }
@ -443,42 +443,42 @@ int EmbedReceiveFrom(CYASSL *ssl, char *buf, int sz, void *ctx)
/* The send embedded callback /* The send embedded callback
* return : nb bytes sent, or error * 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 sd = dtlsCtx->fd;
int sent; int sent;
int len = sz; int len = sz;
int err; int err;
CYASSL_ENTER("EmbedSendTo()"); WOLFSSL_ENTER("EmbedSendTo()");
sent = (int)SENDTO_FUNCTION(sd, &buf[sz - len], len, ssl->wflags, sent = (int)SENDTO_FUNCTION(sd, &buf[sz - len], len, ssl->wflags,
(const struct sockaddr*)dtlsCtx->peer.sa, (const struct sockaddr*)dtlsCtx->peer.sa,
dtlsCtx->peer.sz); dtlsCtx->peer.sz);
if (sent < 0) { if (sent < 0) {
err = LastError(); err = LastError();
CYASSL_MSG("Embed Send To error"); WOLFSSL_MSG("Embed Send To error");
if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) { if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) {
CYASSL_MSG(" Would Block"); WOLFSSL_MSG(" Would Block");
return CYASSL_CBIO_ERR_WANT_WRITE; return WOLFSSL_CBIO_ERR_WANT_WRITE;
} }
else if (err == SOCKET_ECONNRESET) { else if (err == SOCKET_ECONNRESET) {
CYASSL_MSG(" Connection reset"); WOLFSSL_MSG(" Connection reset");
return CYASSL_CBIO_ERR_CONN_RST; return WOLFSSL_CBIO_ERR_CONN_RST;
} }
else if (err == SOCKET_EINTR) { else if (err == SOCKET_EINTR) {
CYASSL_MSG(" Socket interrupted"); WOLFSSL_MSG(" Socket interrupted");
return CYASSL_CBIO_ERR_ISR; return WOLFSSL_CBIO_ERR_ISR;
} }
else if (err == SOCKET_EPIPE) { else if (err == SOCKET_EPIPE) {
CYASSL_MSG(" Socket EPIPE"); WOLFSSL_MSG(" Socket EPIPE");
return CYASSL_CBIO_ERR_CONN_CLOSE; return WOLFSSL_CBIO_ERR_CONN_CLOSE;
} }
else { else {
CYASSL_MSG(" General error"); WOLFSSL_MSG(" General error");
return CYASSL_CBIO_ERR_GENERAL; return WOLFSSL_CBIO_ERR_GENERAL;
} }
} }
@ -489,7 +489,7 @@ int EmbedSendTo(CYASSL* ssl, char *buf, int sz, void *ctx)
/* The DTLS Generate Cookie callback /* The DTLS Generate Cookie callback
* return : number of bytes copied into buf, or error * 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; int sd = ssl->wfd;
struct sockaddr_storage peer; struct sockaddr_storage peer;
@ -501,7 +501,7 @@ int EmbedGenerateCookie(CYASSL* ssl, byte *buf, int sz, void *ctx)
XMEMSET(&peer, 0, sizeof(peer)); XMEMSET(&peer, 0, sizeof(peer));
if (getpeername(sd, (struct sockaddr*)&peer, &peerSz) != 0) { if (getpeername(sd, (struct sockaddr*)&peer, &peerSz) != 0) {
CYASSL_MSG("getpeername failed in EmbedGenerateCookie"); WOLFSSL_MSG("getpeername failed in EmbedGenerateCookie");
return GEN_COOKIE_E; return GEN_COOKIE_E;
} }
@ -516,7 +516,7 @@ int EmbedGenerateCookie(CYASSL* ssl, byte *buf, int sz, void *ctx)
return sz; return sz;
} }
#endif /* CYASSL_DTLS */ #endif /* WOLFSSL_DTLS */
#ifdef HAVE_OCSP #ifdef HAVE_OCSP
@ -571,12 +571,12 @@ static int tcp_connect(SOCKET_T* sockfd, const char* ip, word16 port)
hints.ai_protocol = IPPROTO_TCP; hints.ai_protocol = IPPROTO_TCP;
if (Word16ToString(strPort, port) == 0) { if (Word16ToString(strPort, port) == 0) {
CYASSL_MSG("invalid port number for OCSP responder"); WOLFSSL_MSG("invalid port number for OCSP responder");
return -1; return -1;
} }
if (getaddrinfo(ip, strPort, &hints, &answer) < 0 || answer == NULL) { 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; return -1;
} }
@ -597,7 +597,7 @@ static int tcp_connect(SOCKET_T* sockfd, const char* ip, word16 port)
entry->h_length); entry->h_length);
} }
else { else {
CYASSL_MSG("no addr info for OCSP responder"); WOLFSSL_MSG("no addr info for OCSP responder");
return -1; return -1;
} }
} }
@ -607,18 +607,18 @@ static int tcp_connect(SOCKET_T* sockfd, const char* ip, word16 port)
#ifdef USE_WINDOWS_API #ifdef USE_WINDOWS_API
if (*sockfd == INVALID_SOCKET) { if (*sockfd == INVALID_SOCKET) {
CYASSL_MSG("bad socket fd, out of fds?"); WOLFSSL_MSG("bad socket fd, out of fds?");
return -1; return -1;
} }
#else #else
if (*sockfd < 0) { if (*sockfd < 0) {
CYASSL_MSG("bad socket fd, out of fds?"); WOLFSSL_MSG("bad socket fd, out of fds?");
return -1; return -1;
} }
#endif #endif
if (connect(*sockfd, (struct sockaddr *)&addr, sockaddr_len) != 0) { 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; return -1;
} }
@ -764,7 +764,7 @@ static int process_http_response(int sfd, byte** respBuf,
start[len] = 0; start[len] = 0;
} }
else { else {
CYASSL_MSG("process_http_response recv http from peer failed"); WOLFSSL_MSG("process_http_response recv http from peer failed");
return -1; return -1;
} }
} }
@ -782,7 +782,7 @@ static int process_http_response(int sfd, byte** respBuf,
start += 2; start += 2;
} }
else { else {
CYASSL_MSG("process_http_response header ended early"); WOLFSSL_MSG("process_http_response header ended early");
return -1; return -1;
} }
} }
@ -795,7 +795,7 @@ static int process_http_response(int sfd, byte** respBuf,
start += 9; start += 9;
if (XSTRNCASECMP(start, "200 OK", 6) != 0 || if (XSTRNCASECMP(start, "200 OK", 6) != 0 ||
state != phr_init) { state != phr_init) {
CYASSL_MSG("process_http_response not OK"); WOLFSSL_MSG("process_http_response not OK");
return -1; return -1;
} }
state = phr_http_start; state = phr_http_start;
@ -804,14 +804,14 @@ static int process_http_response(int sfd, byte** respBuf,
start += 13; start += 13;
while (*start == ' ' && *start != '\0') start++; while (*start == ' ' && *start != '\0') start++;
if (XSTRNCASECMP(start, "application/ocsp-response", 25) != 0) { 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; return -1;
} }
if (state == phr_http_start) state = phr_have_type; if (state == phr_http_start) state = phr_have_type;
else if (state == phr_have_length) state = phr_wait_end; else if (state == phr_have_length) state = phr_wait_end;
else { else {
CYASSL_MSG("process_http_response type invalid state"); WOLFSSL_MSG("process_http_response type invalid state");
return -1; return -1;
} }
} }
@ -823,7 +823,7 @@ static int process_http_response(int sfd, byte** respBuf,
if (state == phr_http_start) state = phr_have_length; if (state == phr_http_start) state = phr_have_length;
else if (state == phr_have_type) state = phr_wait_end; else if (state == phr_have_type) state = phr_wait_end;
else { else {
CYASSL_MSG("process_http_response length invalid state"); WOLFSSL_MSG("process_http_response length invalid state");
return -1; return -1;
} }
} }
@ -834,7 +834,7 @@ static int process_http_response(int sfd, byte** respBuf,
recvBuf = (byte*)XMALLOC(recvBufSz, NULL, DYNAMIC_TYPE_IN_BUFFER); recvBuf = (byte*)XMALLOC(recvBufSz, NULL, DYNAMIC_TYPE_IN_BUFFER);
if (recvBuf == NULL) { 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; return -1;
} }
@ -848,7 +848,7 @@ static int process_http_response(int sfd, byte** respBuf,
if (result > 0) if (result > 0)
len += result; len += result;
else { else {
CYASSL_MSG("process_http_response recv ocsp from peer failed"); WOLFSSL_MSG("process_http_response recv ocsp from peer failed");
return -1; return -1;
} }
} while (len != recvBufSz); } while (len != recvBufSz);
@ -866,7 +866,7 @@ int EmbedOcspLookup(void* ctx, const char* url, int urlSz,
SOCKET_T sfd = 0; SOCKET_T sfd = 0;
word16 port; word16 port;
int ret = -1; int ret = -1;
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
char* path; char* path;
char* domainName; char* domainName;
#else #else
@ -874,7 +874,7 @@ int EmbedOcspLookup(void* ctx, const char* url, int urlSz,
char domainName[80]; char domainName[80];
#endif #endif
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
path = (char*)XMALLOC(80, NULL, DYNAMIC_TYPE_TMP_BUFFER); path = (char*)XMALLOC(80, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (path == NULL) if (path == NULL)
return -1; return -1;
@ -889,13 +889,13 @@ int EmbedOcspLookup(void* ctx, const char* url, int urlSz,
(void)ctx; (void)ctx;
if (ocspReqBuf == NULL || ocspReqSz == 0) { 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) { 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) { 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 { else {
/* Note, the library uses the EmbedOcspRespFree() callback to /* 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); DYNAMIC_TYPE_IN_BUFFER);
if (httpBuf == NULL) { if (httpBuf == NULL) {
CYASSL_MSG("Unable to create OCSP response buffer"); WOLFSSL_MSG("Unable to create OCSP response buffer");
} }
else { else {
httpBufSz = build_http_request(domainName, path, ocspReqSz, httpBufSz = build_http_request(domainName, path, ocspReqSz,
httpBuf, httpBufSz); httpBuf, httpBufSz);
if ((tcp_connect(&sfd, domainName, port) != 0) || (sfd <= 0)) { 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) != else if ((int)send(sfd, (char*)httpBuf, httpBufSz, 0) !=
httpBufSz) { httpBufSz) {
CYASSL_MSG("OCSP http request failed"); WOLFSSL_MSG("OCSP http request failed");
} }
else if ((int)send(sfd, (char*)ocspReqBuf, ocspReqSz, 0) != else if ((int)send(sfd, (char*)ocspReqBuf, ocspReqSz, 0) !=
ocspReqSz) { ocspReqSz) {
CYASSL_MSG("OCSP ocsp request failed"); WOLFSSL_MSG("OCSP ocsp request failed");
} }
else { else {
ret = process_http_response(sfd, ocspRespBuf, httpBuf, 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(path, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(domainName, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(domainName, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif #endif
@ -952,33 +952,33 @@ void EmbedOcspRespFree(void* ctx, byte *resp)
#endif #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; 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; 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; 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; ssl->IOCB_WriteCtx = wctx;
} }
CYASSL_API void* CyaSSL_GetIOReadCtx(CYASSL* ssl) WOLFSSL_API void* wolfSSL_GetIOReadCtx(WOLFSSL* ssl)
{ {
if (ssl) if (ssl)
return ssl->IOCB_ReadCtx; 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) if (ssl)
return ssl->IOCB_WriteCtx; 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; ssl->rflags = flags;
} }
CYASSL_API void CyaSSL_SetIOWriteFlags(CYASSL* ssl, int flags) WOLFSSL_API void wolfSSL_SetIOWriteFlags(WOLFSSL* ssl, int flags)
{ {
ssl->wflags = 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; 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; ssl->IOCB_CookieCtx = ctx;
} }
CYASSL_API void* CyaSSL_GetCookieCtx(CYASSL* ssl) WOLFSSL_API void* wolfSSL_GetCookieCtx(WOLFSSL* ssl)
{ {
if (ssl) if (ssl)
return ssl->IOCB_CookieCtx; return ssl->IOCB_CookieCtx;
@ -1030,7 +1030,7 @@ CYASSL_API void* CyaSSL_GetCookieCtx(CYASSL* ssl)
return NULL; return NULL;
} }
#endif /* CYASSL_DTLS */ #endif /* WOLFSSL_DTLS */
#ifdef HAVE_NETX #ifdef HAVE_NETX
@ -1038,7 +1038,7 @@ CYASSL_API void* CyaSSL_GetCookieCtx(CYASSL* ssl)
/* The NetX receive callback /* The NetX receive callback
* return : bytes read, or error * 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; NetX_Ctx* nxCtx = (NetX_Ctx*)ctx;
ULONG left; ULONG left;
@ -1047,38 +1047,38 @@ int NetX_Receive(CYASSL *ssl, char *buf, int sz, void *ctx)
UINT status; UINT status;
if (nxCtx == NULL || nxCtx->nxSocket == NULL) { if (nxCtx == NULL || nxCtx->nxSocket == NULL) {
CYASSL_MSG("NetX Recv NULL parameters"); WOLFSSL_MSG("NetX Recv NULL parameters");
return CYASSL_CBIO_ERR_GENERAL; return WOLFSSL_CBIO_ERR_GENERAL;
} }
if (nxCtx->nxPacket == NULL) { if (nxCtx->nxPacket == NULL) {
status = nx_tcp_socket_receive(nxCtx->nxSocket, &nxCtx->nxPacket, status = nx_tcp_socket_receive(nxCtx->nxSocket, &nxCtx->nxPacket,
nxCtx->nxWait); nxCtx->nxWait);
if (status != NX_SUCCESS) { if (status != NX_SUCCESS) {
CYASSL_MSG("NetX Recv receive error"); WOLFSSL_MSG("NetX Recv receive error");
return CYASSL_CBIO_ERR_GENERAL; return WOLFSSL_CBIO_ERR_GENERAL;
} }
} }
if (nxCtx->nxPacket) { if (nxCtx->nxPacket) {
status = nx_packet_length_get(nxCtx->nxPacket, &total); status = nx_packet_length_get(nxCtx->nxPacket, &total);
if (status != NX_SUCCESS) { if (status != NX_SUCCESS) {
CYASSL_MSG("NetX Recv length get error"); WOLFSSL_MSG("NetX Recv length get error");
return CYASSL_CBIO_ERR_GENERAL; return WOLFSSL_CBIO_ERR_GENERAL;
} }
left = total - nxCtx->nxOffset; left = total - nxCtx->nxOffset;
status = nx_packet_data_extract_offset(nxCtx->nxPacket, nxCtx->nxOffset, status = nx_packet_data_extract_offset(nxCtx->nxPacket, nxCtx->nxOffset,
buf, sz, &copied); buf, sz, &copied);
if (status != NX_SUCCESS) { if (status != NX_SUCCESS) {
CYASSL_MSG("NetX Recv data extract offset error"); WOLFSSL_MSG("NetX Recv data extract offset error");
return CYASSL_CBIO_ERR_GENERAL; return WOLFSSL_CBIO_ERR_GENERAL;
} }
nxCtx->nxOffset += copied; nxCtx->nxOffset += copied;
if (copied == left) { if (copied == left) {
CYASSL_MSG("NetX Recv Drained packet"); WOLFSSL_MSG("NetX Recv Drained packet");
nx_packet_release(nxCtx->nxPacket); nx_packet_release(nxCtx->nxPacket);
nxCtx->nxPacket = NULL; nxCtx->nxPacket = NULL;
nxCtx->nxOffset = 0; nxCtx->nxOffset = 0;
@ -1092,7 +1092,7 @@ int NetX_Receive(CYASSL *ssl, char *buf, int sz, void *ctx)
/* The NetX send callback /* The NetX send callback
* return : bytes sent, or error * 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; NetX_Ctx* nxCtx = (NetX_Ctx*)ctx;
NX_PACKET* packet; NX_PACKET* packet;
@ -1100,30 +1100,30 @@ int NetX_Send(CYASSL* ssl, char *buf, int sz, void *ctx)
UINT status; UINT status;
if (nxCtx == NULL || nxCtx->nxSocket == NULL) { if (nxCtx == NULL || nxCtx->nxSocket == NULL) {
CYASSL_MSG("NetX Send NULL parameters"); WOLFSSL_MSG("NetX Send NULL parameters");
return CYASSL_CBIO_ERR_GENERAL; return WOLFSSL_CBIO_ERR_GENERAL;
} }
pool = nxCtx->nxSocket->nx_tcp_socket_ip_ptr->nx_ip_default_packet_pool; pool = nxCtx->nxSocket->nx_tcp_socket_ip_ptr->nx_ip_default_packet_pool;
status = nx_packet_allocate(pool, &packet, NX_TCP_PACKET, status = nx_packet_allocate(pool, &packet, NX_TCP_PACKET,
nxCtx->nxWait); nxCtx->nxWait);
if (status != NX_SUCCESS) { if (status != NX_SUCCESS) {
CYASSL_MSG("NetX Send packet alloc error"); WOLFSSL_MSG("NetX Send packet alloc error");
return CYASSL_CBIO_ERR_GENERAL; return WOLFSSL_CBIO_ERR_GENERAL;
} }
status = nx_packet_data_append(packet, buf, sz, pool, nxCtx->nxWait); status = nx_packet_data_append(packet, buf, sz, pool, nxCtx->nxWait);
if (status != NX_SUCCESS) { if (status != NX_SUCCESS) {
nx_packet_release(packet); nx_packet_release(packet);
CYASSL_MSG("NetX Send data append error"); WOLFSSL_MSG("NetX Send data append error");
return CYASSL_CBIO_ERR_GENERAL; return WOLFSSL_CBIO_ERR_GENERAL;
} }
status = nx_tcp_socket_send(nxCtx->nxSocket, packet, nxCtx->nxWait); status = nx_tcp_socket_send(nxCtx->nxSocket, packet, nxCtx->nxWait);
if (status != NX_SUCCESS) { if (status != NX_SUCCESS) {
nx_packet_release(packet); nx_packet_release(packet);
CYASSL_MSG("NetX Send socket send error"); WOLFSSL_MSG("NetX Send socket send error");
return CYASSL_CBIO_ERR_GENERAL; return WOLFSSL_CBIO_ERR_GENERAL;
} }
return sz; 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 */ /* 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) { if (ssl) {
ssl->nxCtx.nxSocket = nxSocket; ssl->nxCtx.nxSocket = nxSocket;

File diff suppressed because it is too large Load Diff

View File

@ -2,14 +2,14 @@
* *
* Copyright (C) 2006-2014 wolfSSL Inc. * Copyright (C) 2006-2014 wolfSSL Inc.
* *
* This file is part of CyaSSL. * This file is part of wolfSSL. (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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* CyaSSL is distributed in the hope that it will be useful, * wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
@ -20,24 +20,24 @@
*/ */
/* Name change compatibility layer */ /* Name change compatibility layer */
#include <cyassl/ssl.h> #include <wolfssl/ssl.h>
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
#endif #endif
#include <cyassl/ctaocrypt/settings.h> #include <wolfssl/wolfcrypt/settings.h>
#ifdef HAVE_OCSP #ifdef HAVE_OCSP
#include <cyassl/error-ssl.h> #include <wolfssl/error-ssl.h>
#include <cyassl/ocsp.h> #include <wolfssl/ocsp.h>
#include <cyassl/internal.h> #include <wolfssl/internal.h>
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)); XMEMSET(ocsp, 0, sizeof(*ocsp));
ocsp->cm = cm; ocsp->cm = cm;
if (InitMutex(&ocsp->ocspLock) != 0) 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) static int InitOCSP_Entry(OCSP_Entry* ocspe, DecodedCert* cert)
{ {
CYASSL_ENTER("InitOCSP_Entry"); WOLFSSL_ENTER("InitOCSP_Entry");
XMEMSET(ocspe, 0, sizeof(*ocspe)); XMEMSET(ocspe, 0, sizeof(*ocspe));
XMEMCPY(ocspe->issuerHash, cert->issuerHash, SHA_DIGEST_SIZE); XMEMCPY(ocspe->issuerHash, cert->issuerHash, SHA_DIGEST_SIZE);
@ -63,7 +63,7 @@ static void FreeOCSP_Entry(OCSP_Entry* ocspe)
{ {
CertStatus* tmp = ocspe->status; CertStatus* tmp = ocspe->status;
CYASSL_ENTER("FreeOCSP_Entry"); WOLFSSL_ENTER("FreeOCSP_Entry");
while (tmp) { while (tmp) {
CertStatus* next = tmp->next; 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; OCSP_Entry* tmp = ocsp->ocspList;
CYASSL_ENTER("FreeOCSP"); WOLFSSL_ENTER("FreeOCSP");
while (tmp) { while (tmp) {
OCSP_Entry* next = tmp->next; 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; byte* ocspReqBuf = NULL;
int ocspReqSz = 2048; int ocspReqSz = 2048;
@ -115,7 +115,7 @@ int CheckCertOCSP(CYASSL_OCSP* ocsp, DecodedCert* cert)
CertStatus* certStatus = NULL; CertStatus* certStatus = NULL;
const char *url; const char *url;
int urlSz; int urlSz;
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
CertStatus* newStatus; CertStatus* newStatus;
OcspRequest* ocspRequest; OcspRequest* ocspRequest;
OcspResponse* ocspResponse; OcspResponse* ocspResponse;
@ -125,10 +125,10 @@ int CheckCertOCSP(CYASSL_OCSP* ocsp, DecodedCert* cert)
OcspResponse ocspResponse[1]; OcspResponse ocspResponse[1];
#endif #endif
CYASSL_ENTER("CheckCertOCSP"); WOLFSSL_ENTER("CheckCertOCSP");
if (LockMutex(&ocsp->ocspLock) != 0) { if (LockMutex(&ocsp->ocspLock) != 0) {
CYASSL_LEAVE("CheckCertOCSP", BAD_MUTEX_E); WOLFSSL_LEAVE("CheckCertOCSP", BAD_MUTEX_E);
return BAD_MUTEX_E; return BAD_MUTEX_E;
} }
@ -152,7 +152,7 @@ int CheckCertOCSP(CYASSL_OCSP* ocsp, DecodedCert* cert)
} }
else { else {
UnLockMutex(&ocsp->ocspLock); UnLockMutex(&ocsp->ocspLock);
CYASSL_LEAVE("CheckCertOCSP", MEMORY_ERROR); WOLFSSL_LEAVE("CheckCertOCSP", MEMORY_ERROR);
return MEMORY_ERROR; return MEMORY_ERROR;
} }
} }
@ -173,12 +173,12 @@ int CheckCertOCSP(CYASSL_OCSP* ocsp, DecodedCert* cert)
(certStatus->nextDate[0] == 0) || (certStatus->nextDate[0] == 0) ||
!ValidateDate(certStatus->nextDate, !ValidateDate(certStatus->nextDate,
certStatus->nextDateFormat, AFTER)) { certStatus->nextDateFormat, AFTER)) {
CYASSL_MSG("\tinvalid status date, looking up cert"); WOLFSSL_MSG("\tinvalid status date, looking up cert");
} }
else { else {
result = xstat2err(certStatus->status); result = xstat2err(certStatus->status);
UnLockMutex(&ocsp->ocspLock); UnLockMutex(&ocsp->ocspLock);
CYASSL_LEAVE("CheckCertOCSP", result); WOLFSSL_LEAVE("CheckCertOCSP", result);
return result; return result;
} }
} }
@ -203,11 +203,11 @@ int CheckCertOCSP(CYASSL_OCSP* ocsp, DecodedCert* cert)
ocspReqBuf = (byte*)XMALLOC(ocspReqSz, NULL, DYNAMIC_TYPE_IN_BUFFER); ocspReqBuf = (byte*)XMALLOC(ocspReqSz, NULL, DYNAMIC_TYPE_IN_BUFFER);
if (ocspReqBuf == NULL) { if (ocspReqBuf == NULL) {
CYASSL_LEAVE("CheckCertOCSP", MEMORY_ERROR); WOLFSSL_LEAVE("CheckCertOCSP", MEMORY_ERROR);
return MEMORY_ERROR; return MEMORY_ERROR;
} }
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
newStatus = (CertStatus*)XMALLOC(sizeof(CertStatus), NULL, newStatus = (CertStatus*)XMALLOC(sizeof(CertStatus), NULL,
DYNAMIC_TYPE_TMP_BUFFER); DYNAMIC_TYPE_TMP_BUFFER);
ocspRequest = (OcspRequest*)XMALLOC(sizeof(OcspRequest), NULL, ocspRequest = (OcspRequest*)XMALLOC(sizeof(OcspRequest), NULL,
@ -222,7 +222,7 @@ int CheckCertOCSP(CYASSL_OCSP* ocsp, DecodedCert* cert)
XFREE(ocspReqBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(ocspReqBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER);
CYASSL_LEAVE("CheckCertOCSP", MEMORY_ERROR); WOLFSSL_LEAVE("CheckCertOCSP", MEMORY_ERROR);
return MEMORY_E; return MEMORY_E;
} }
#endif #endif
@ -277,7 +277,7 @@ int CheckCertOCSP(CYASSL_OCSP* ocsp, DecodedCert* cert)
XFREE(ocspReqBuf, NULL, DYNAMIC_TYPE_IN_BUFFER); XFREE(ocspReqBuf, NULL, DYNAMIC_TYPE_IN_BUFFER);
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
XFREE(newStatus, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(newStatus, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(ocspRequest, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(ocspRequest, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(ocspResponse, 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) if (ocspRespBuf != NULL && ocsp->cm->ocspRespFreeCb)
ocsp->cm->ocspRespFreeCb(ocsp->cm->ocspIOCtx, ocspRespBuf); ocsp->cm->ocspRespFreeCb(ocsp->cm->ocspIOCtx, ocspRespBuf);
CYASSL_LEAVE("CheckCertOCSP", result); WOLFSSL_LEAVE("CheckCertOCSP", result);
return result; return result;
} }

View File

@ -2,14 +2,14 @@
* *
* Copyright (C) 2006-2014 wolfSSL Inc. * Copyright (C) 2006-2014 wolfSSL Inc.
* *
* This file is part of CyaSSL. * This file is part of wolfSSL. (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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* CyaSSL is distributed in the hope that it will be useful, * wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
@ -20,15 +20,15 @@
*/ */
/* Name change compatibility layer */ /* Name change compatibility layer */
#include <cyassl/ssl.h> #include <wolfssl/ssl.h>
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
#endif #endif
#include <cyassl/ctaocrypt/settings.h> #include <wolfssl/wolfcrypt/settings.h>
#ifdef CYASSL_SNIFFER #ifdef WOLFSSL_SNIFFER
#include <assert.h> #include <assert.h>
#include <time.h> #include <time.h>
@ -43,11 +43,11 @@
#define SNPRINTF snprintf #define SNPRINTF snprintf
#endif #endif
#include <cyassl/openssl/ssl.h> #include <wolfssl/openssl/ssl.h>
#include <cyassl/internal.h> #include <wolfssl/internal.h>
#include <cyassl/error-ssl.h> #include <wolfssl/error-ssl.h>
#include <cyassl/sniffer.h> #include <wolfssl/sniffer.h>
#include <cyassl/sniffer_error.h> #include <wolfssl/sniffer_error.h>
#ifndef min #ifndef min
@ -59,8 +59,8 @@ static INLINE word32 min(word32 a, word32 b)
#endif #endif
#ifndef CYASSL_SNIFFER_TIMEOUT #ifndef WOLFSSL_SNIFFER_TIMEOUT
#define CYASSL_SNIFFER_TIMEOUT 900 #define WOLFSSL_SNIFFER_TIMEOUT 900
/* Cache unclosed Sessions for 15 minutes since last used */ /* Cache unclosed Sessions for 15 minutes since last used */
#endif #endif
@ -290,7 +290,7 @@ typedef struct SnifferServer {
int port; /* server port */ int port; /* server port */
#ifdef HAVE_SNI #ifdef HAVE_SNI
NamedKey* namedKeys; /* mapping of names and keys */ NamedKey* namedKeys; /* mapping of names and keys */
CyaSSL_Mutex namedKeysMutex; /* mutex for namedKey list */ wolfSSL_Mutex namedKeysMutex; /* mutex for namedKey list */
#endif #endif
struct SnifferServer* next; /* for list */ struct SnifferServer* next; /* for list */
} SnifferServer; } SnifferServer;
@ -343,19 +343,19 @@ typedef struct SnifferSession {
/* Sniffer Server List and mutex */ /* Sniffer Server List and mutex */
static SnifferServer* ServerList = 0; static SnifferServer* ServerList = 0;
static CyaSSL_Mutex ServerListMutex; static wolfSSL_Mutex ServerListMutex;
/* Session Hash Table, mutex, and count */ /* Session Hash Table, mutex, and count */
static SnifferSession* SessionTable[HASH_SIZE]; static SnifferSession* SessionTable[HASH_SIZE];
static CyaSSL_Mutex SessionMutex; static wolfSSL_Mutex SessionMutex;
static int SessionCount = 0; static int SessionCount = 0;
/* Initialize overall Sniffer */ /* Initialize overall Sniffer */
void ssl_InitSniffer(void) void ssl_InitSniffer(void)
{ {
CyaSSL_Init(); wolfSSL_Init();
InitMutex(&ServerListMutex); InitMutex(&ServerListMutex);
InitMutex(&SessionMutex); InitMutex(&SessionMutex);
} }
@ -488,7 +488,7 @@ void ssl_FreeSniffer(void)
TraceFile = NULL; TraceFile = NULL;
} }
CyaSSL_Cleanup(); wolfSSL_Cleanup();
} }
@ -980,9 +980,9 @@ static SnifferSession* GetSnifferSession(IpInfo* ipInfo, TcpInfo* tcpInfo)
if (session) { if (session) {
if (ipInfo->dst == session->context->server && if (ipInfo->dst == session->context->server &&
tcpInfo->dstPort == session->context->port) tcpInfo->dstPort == session->context->port)
session->flags.side = CYASSL_SERVER_END; session->flags.side = WOLFSSL_SERVER_END;
else else
session->flags.side = CYASSL_CLIENT_END; session->flags.side = WOLFSSL_CLIENT_END;
} }
return session; return session;
@ -1024,7 +1024,7 @@ static int LoadKeyFile(byte** keyBuf, word32* keyBufSz,
if (typeKey == SSL_FILETYPE_PEM) { if (typeKey == SSL_FILETYPE_PEM) {
saveBuf = (byte*)malloc(fileSz); saveBuf = (byte*)malloc(fileSz);
saveBufSz = CyaSSL_KeyPemToDer(loadBuf, (int)fileSz, saveBufSz = wolfSSL_KeyPemToDer(loadBuf, (int)fileSz,
saveBuf, (int)fileSz, password); saveBuf, (int)fileSz, password);
free(loadBuf); free(loadBuf);
@ -1560,10 +1560,10 @@ static int ProcessClientHello(const byte* input, int* sslBytes,
word32 nameSz = sizeof(name); word32 nameSz = sizeof(name);
int ret; int ret;
ret = CyaSSL_SNI_GetFromBuffer( ret = wolfSSL_SNI_GetFromBuffer(
input - HANDSHAKE_HEADER_SZ - RECORD_HEADER_SZ, input - HANDSHAKE_HEADER_SZ - RECORD_HEADER_SZ,
*sslBytes + 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) { if (ret == SSL_SUCCESS) {
NamedKey* namedKey; NamedKey* namedKey;
@ -1574,7 +1574,7 @@ static int ProcessClientHello(const byte* input, int* sslBytes,
while (namedKey != NULL) { while (namedKey != NULL) {
if (nameSz == namedKey->nameSz && if (nameSz == namedKey->nameSz &&
XSTRNCMP((char*)name, namedKey->name, nameSz) == 0) { 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, namedKey->key, namedKey->keySz,
SSL_FILETYPE_ASN1) != SSL_SUCCESS) { SSL_FILETYPE_ASN1) != SSL_SUCCESS) {
UnLockMutex(&session->context->namedKeysMutex); UnLockMutex(&session->context->namedKeysMutex);
@ -1741,7 +1741,7 @@ static int ProcessFinished(const byte* input, int size, int* sslBytes,
word32 inOutIdx = 0; word32 inOutIdx = 0;
int ret; int ret;
if (session->flags.side == CYASSL_SERVER_END) if (session->flags.side == WOLFSSL_SERVER_END)
ssl = session->sslServer; ssl = session->sslServer;
else else
ssl = session->sslClient; 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 (ret == 0 && session->flags.cached == 0) {
if (session->sslServer->options.haveSessionId) { if (session->sslServer->options.haveSessionId) {
CYASSL_SESSION* sess = GetSession(session->sslServer, NULL); WOLFSSL_SESSION* sess = GetSession(session->sslServer, NULL);
if (sess == NULL) if (sess == NULL)
AddSession(session->sslServer); /* don't re add */ AddSession(session->sslServer); /* don't re add */
session->flags.cached = 1; 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) { switch (ssl->specs.bulk_cipher_algorithm) {
#ifdef BUILD_ARC4 #ifdef BUILD_ARC4
case cyassl_rc4: case wolfssl_rc4:
Arc4Process(ssl->decrypt.arc4, output, input, sz); Arc4Process(ssl->decrypt.arc4, output, input, sz);
break; break;
#endif #endif
#ifdef BUILD_DES3 #ifdef BUILD_DES3
case cyassl_triple_des: case wolfssl_triple_des:
ret = Des3_CbcDecrypt(ssl->decrypt.des3, output, input, sz); ret = Des3_CbcDecrypt(ssl->decrypt.des3, output, input, sz);
break; break;
#endif #endif
#ifdef BUILD_AES #ifdef BUILD_AES
case cyassl_aes: case wolfssl_aes:
ret = AesCbcDecrypt(ssl->decrypt.aes, output, input, sz); ret = AesCbcDecrypt(ssl->decrypt.aes, output, input, sz);
break; break;
#endif #endif
#ifdef HAVE_HC128 #ifdef HAVE_HC128
case cyassl_hc128: case wolfssl_hc128:
Hc128_Process(ssl->decrypt.hc128, output, input, sz); Hc128_Process(ssl->decrypt.hc128, output, input, sz);
break; break;
#endif #endif
#ifdef BUILD_RABBIT #ifdef BUILD_RABBIT
case cyassl_rabbit: case wolfssl_rabbit:
RabbitProcess(ssl->decrypt.rabbit, output, input, sz); RabbitProcess(ssl->decrypt.rabbit, output, input, sz);
break; break;
#endif #endif
#ifdef HAVE_CAMELLIA #ifdef HAVE_CAMELLIA
case cyassl_camellia: case wolfssl_camellia:
CamelliaCbcDecrypt(ssl->decrypt.cam, output, input, sz); CamelliaCbcDecrypt(ssl->decrypt.cam, output, input, sz);
break; break;
#endif #endif
@ -1981,7 +1981,7 @@ static void RemoveStaleSessions(void)
session = SessionTable[i]; session = SessionTable[i];
while (session) { while (session) {
SnifferSession* next = session->next; SnifferSession* next = session->next;
if (time(NULL) >= session->lastUsed + CYASSL_SNIFFER_TIMEOUT) { if (time(NULL) >= session->lastUsed + WOLFSSL_SNIFFER_TIMEOUT) {
TraceStaleSession(); TraceStaleSession();
RemoveSession(session, NULL, NULL, i); RemoveSession(session, NULL, NULL, i);
} }
@ -2037,7 +2037,7 @@ static SnifferSession* CreateSession(IpInfo* ipInfo, TcpInfo* tcpInfo,
return 0; return 0;
} }
/* put server back into server mode */ /* put server back into server mode */
session->sslServer->options.side = CYASSL_SERVER_END; session->sslServer->options.side = WOLFSSL_SERVER_END;
row = SessionHash(ipInfo, tcpInfo); row = SessionHash(ipInfo, tcpInfo);
@ -2059,9 +2059,9 @@ static SnifferSession* CreateSession(IpInfo* ipInfo, TcpInfo* tcpInfo,
/* determine headed side */ /* determine headed side */
if (ipInfo->dst == session->context->server && if (ipInfo->dst == session->context->server &&
tcpInfo->dstPort == session->context->port) tcpInfo->dstPort == session->context->port)
session->flags.side = CYASSL_SERVER_END; session->flags.side = WOLFSSL_SERVER_END;
else else
session->flags.side = CYASSL_CLIENT_END; session->flags.side = WOLFSSL_CLIENT_END;
return session; return session;
} }
@ -2276,7 +2276,7 @@ static int AddToReassembly(byte from, word32 seq, const byte* sslFrame,
int sslBytes, SnifferSession* session, char* error) int sslBytes, SnifferSession* session, char* error)
{ {
PacketBuffer* add; PacketBuffer* add;
PacketBuffer** front = (from == CYASSL_SERVER_END) ? PacketBuffer** front = (from == WOLFSSL_SERVER_END) ?
&session->cliReassemblyList: &session->srvReassemblyList; &session->cliReassemblyList: &session->srvReassemblyList;
PacketBuffer* curr = *front; PacketBuffer* curr = *front;
PacketBuffer* prev = curr; PacketBuffer* prev = curr;
@ -2356,7 +2356,7 @@ static int AddToReassembly(byte from, word32 seq, const byte* sslFrame,
/* returns 1 for success (end) */ /* returns 1 for success (end) */
static int AddFinCapture(SnifferSession* session, word32 sequence) 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) if (session->finCaputre.cliCounted == 0)
session->finCaputre.cliFinSeq = sequence; session->finCaputre.cliFinSeq = sequence;
} }
@ -2373,12 +2373,12 @@ static int AddFinCapture(SnifferSession* session, word32 sequence)
static int AdjustSequence(TcpInfo* tcpInfo, SnifferSession* session, static int AdjustSequence(TcpInfo* tcpInfo, SnifferSession* session,
int* sslBytes, const byte** sslFrame, char* error) 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; session->cliSeqStart :session->srvSeqStart;
word32 real = tcpInfo->sequence - seqStart; 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; &session->cliExpected : &session->srvExpected;
PacketBuffer* reassemblyList = (session->flags.side == CYASSL_SERVER_END) ? PacketBuffer* reassemblyList = (session->flags.side == WOLFSSL_SERVER_END) ?
session->cliReassemblyList : session->srvReassemblyList; session->cliReassemblyList : session->srvReassemblyList;
/* handle rollover of sequence */ /* handle rollover of sequence */
@ -2442,10 +2442,10 @@ static int AdjustSequence(TcpInfo* tcpInfo, SnifferSession* session,
static int CheckAck(TcpInfo* tcpInfo, SnifferSession* session) static int CheckAck(TcpInfo* tcpInfo, SnifferSession* session)
{ {
if (tcpInfo->ack) { if (tcpInfo->ack) {
word32 seqStart = (session->flags.side == CYASSL_SERVER_END) ? word32 seqStart = (session->flags.side == WOLFSSL_SERVER_END) ?
session->srvSeqStart :session->cliSeqStart; session->srvSeqStart :session->cliSeqStart;
word32 real = tcpInfo->ackNumber - seqStart; 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; session->srvExpected : session->cliExpected;
/* handle rollover of sequence */ /* handle rollover of sequence */
@ -2500,7 +2500,7 @@ static int CheckPreRecord(IpInfo* ipInfo, TcpInfo* tcpInfo,
int* sslBytes, const byte** end, char* error) int* sslBytes, const byte** end, char* error)
{ {
word32 length; word32 length;
SSL* ssl = ((*session)->flags.side == CYASSL_SERVER_END) ? SSL* ssl = ((*session)->flags.side == WOLFSSL_SERVER_END) ?
(*session)->sslServer : (*session)->sslClient; (*session)->sslServer : (*session)->sslClient;
/* remove SnifferSession on 2nd FIN or RST */ /* remove SnifferSession on 2nd FIN or RST */
if (tcpInfo->fin || tcpInfo->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 */ /* sequence and reassembly based on from, not to */
int moreInput = 0; int moreInput = 0;
PacketBuffer** front = (session->flags.side == CYASSL_SERVER_END) ? PacketBuffer** front = (session->flags.side == WOLFSSL_SERVER_END) ?
&session->cliReassemblyList : &session->srvReassemblyList; &session->cliReassemblyList : &session->srvReassemblyList;
word32* expected = (session->flags.side == CYASSL_SERVER_END) ? word32* expected = (session->flags.side == WOLFSSL_SERVER_END) ?
&session->cliExpected : &session->srvExpected; &session->cliExpected : &session->srvExpected;
/* buffer is on receiving end */ /* 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->sslServer->buffers.inputBuffer.length :
&session->sslClient->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->sslServer->buffers.inputBuffer.buffer :
session->sslClient->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->sslServer->buffers.inputBuffer.bufferSize :
session->sslClient->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; session->sslServer : session->sslClient;
while (*front && ((*front)->begin == *expected) ) { 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 decoded = 0; /* bytes stored for user in data */
int notEnough; /* notEnough bytes yet flag */ int notEnough; /* notEnough bytes yet flag */
int decrypted = 0; /* was current msg decrypted */ 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; session->sslServer : session->sslClient;
doMessage: doMessage:
notEnough = 0; notEnough = 0;
@ -2687,9 +2687,9 @@ doMessage:
inRecordEnd = recordEnd; inRecordEnd = recordEnd;
/* decrypt if needed */ /* decrypt if needed */
if ((session->flags.side == CYASSL_SERVER_END && if ((session->flags.side == WOLFSSL_SERVER_END &&
session->flags.serverCipherOn) session->flags.serverCipherOn)
|| (session->flags.side == CYASSL_CLIENT_END && || (session->flags.side == WOLFSSL_CLIENT_END &&
session->flags.clientCipherOn)) { session->flags.clientCipherOn)) {
int ivAdvance = 0; /* TLSv1.1 advance amount */ int ivAdvance = 0; /* TLSv1.1 advance amount */
if (ssl->decrypt.setup != 1) { if (ssl->decrypt.setup != 1) {
@ -2737,7 +2737,7 @@ doPart:
} }
break; break;
case change_cipher_spec: case change_cipher_spec:
if (session->flags.side == CYASSL_SERVER_END) if (session->flags.side == WOLFSSL_SERVER_END)
session->flags.serverCipherOn = 1; session->flags.serverCipherOn = 1;
else else
session->flags.clientCipherOn = 1; session->flags.clientCipherOn = 1;
@ -2920,4 +2920,4 @@ int ssl_Trace(const char* traceFile, char* error)
#endif /* CYASSL_SNIFFER */ #endif /* WOLFSSL_SNIFFER */

3738
src/ssl.c

File diff suppressed because it is too large Load Diff

310
src/tls.c
View File

@ -2,14 +2,14 @@
* *
* Copyright (C) 2006-2014 wolfSSL Inc. * Copyright (C) 2006-2014 wolfSSL Inc.
* *
* This file is part of CyaSSL. * This file is part of wolfSSL.
* *
* CyaSSL is free software; you can redistribute it and/or modify * wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* CyaSSL is distributed in the hope that it will be useful, * wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
@ -20,18 +20,18 @@
*/ */
/* Name change compatibility layer */ /* Name change compatibility layer */
#include <cyassl/ssl.h> #include <wolfssl/ssl.h>
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
#endif #endif
#include <cyassl/ctaocrypt/settings.h> #include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/ssl.h> #include <wolfssl/ssl.h>
#include <cyassl/internal.h> #include <wolfssl/internal.h>
#include <cyassl/error-ssl.h> #include <wolfssl/error-ssl.h>
#include <cyassl/ctaocrypt/hmac.h> #include <wolfssl/wolfcrypt/hmac.h>
@ -48,7 +48,7 @@
#endif /* min */ #endif /* min */
#ifdef CYASSL_SHA384 #ifdef WOLFSSL_SHA384
#define P_HASH_MAX_SIZE SHA384_DIGEST_SIZE #define P_HASH_MAX_SIZE SHA384_DIGEST_SIZE
#else #else
#define P_HASH_MAX_SIZE SHA256_DIGEST_SIZE #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 i;
word32 idx = 0; word32 idx = 0;
int ret = 0; int ret = 0;
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
byte* previous; byte* previous;
byte* current; byte* current;
Hmac* hmac; Hmac* hmac;
@ -75,7 +75,7 @@ static int p_hash(byte* result, word32 resLen, const byte* secret,
Hmac hmac[1]; Hmac hmac[1];
#endif #endif
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
previous = (byte*)XMALLOC(P_HASH_MAX_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER); previous = (byte*)XMALLOC(P_HASH_MAX_SIZE, NULL, DYNAMIC_TYPE_TMP_BUFFER);
current = (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); 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; break;
#endif #endif
#ifdef CYASSL_SHA384 #ifdef WOLFSSL_SHA384
case sha384_mac: case sha384_mac:
hash = SHA384; hash = SHA384;
len = SHA384_DIGEST_SIZE; 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(current, 0, P_HASH_MAX_SIZE);
XMEMSET(hmac, 0, sizeof(Hmac)); XMEMSET(hmac, 0, sizeof(Hmac));
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
XFREE(previous, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(previous, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(current, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(current, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(hmac, 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; int ret = 0;
word32 half = (secLen + 1) / 2; word32 half = (secLen + 1) / 2;
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
byte* md5_half; byte* md5_half;
byte* sha_half; byte* sha_half;
byte* labelSeed; byte* labelSeed;
@ -217,7 +217,7 @@ static int doPRF(byte* digest, word32 digLen, const byte* secret,word32 secLen,
if (digLen > MAX_PRF_DIG) if (digLen > MAX_PRF_DIG)
return BUFFER_E; return BUFFER_E;
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
md5_half = (byte*)XMALLOC(MAX_PRF_HALF, NULL, DYNAMIC_TYPE_TMP_BUFFER); md5_half = (byte*)XMALLOC(MAX_PRF_HALF, NULL, DYNAMIC_TYPE_TMP_BUFFER);
sha_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); 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(md5_half, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(sha_half, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(sha_half, NULL, DYNAMIC_TYPE_TMP_BUFFER);
XFREE(labelSeed, 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; int ret = 0;
if (useAtLeastSha256) { if (useAtLeastSha256) {
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
byte* labelSeed; byte* labelSeed;
#else #else
byte labelSeed[MAX_PRF_LABSEED]; /* labLen + seedLen is real size */ 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) if (labLen + seedLen > MAX_PRF_LABSEED)
return BUFFER_E; return BUFFER_E;
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
labelSeed = (byte*)XMALLOC(MAX_PRF_LABSEED, NULL, labelSeed = (byte*)XMALLOC(MAX_PRF_LABSEED, NULL,
DYNAMIC_TYPE_TMP_BUFFER); DYNAMIC_TYPE_TMP_BUFFER);
if (labelSeed == NULL) 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, ret = p_hash(digest, digLen, secret, secLen, labelSeed,
labLen + seedLen, hash_type); labLen + seedLen, hash_type);
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
XFREE(labelSeed, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(labelSeed, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif #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 #define HSHASH_SZ SHA384_DIGEST_SIZE
#else #else
#define HSHASH_SZ FINISHED_SZ #define HSHASH_SZ FINISHED_SZ
#endif #endif
int BuildTlsFinished(CYASSL* ssl, Hashes* hashes, const byte* sender) int BuildTlsFinished(WOLFSSL* ssl, Hashes* hashes, const byte* sender)
{ {
const byte* side; const byte* side;
byte handshake_hash[HSHASH_SZ]; byte handshake_hash[HSHASH_SZ];
@ -346,7 +346,7 @@ int BuildTlsFinished(CYASSL* ssl, Hashes* hashes, const byte* sender)
hashSz = SHA256_DIGEST_SIZE; hashSz = SHA256_DIGEST_SIZE;
} }
#endif #endif
#ifdef CYASSL_SHA384 #ifdef WOLFSSL_SHA384
if (ssl->specs.mac_algorithm == sha384_mac) { if (ssl->specs.mac_algorithm == sha384_mac) {
int ret = Sha384Final(&ssl->hashSha384, handshake_hash); 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 */ /* 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* ms, word32 msLen,
const byte* sr, const byte* cr, const byte* sr, const byte* cr,
int tls1_2, int hash_type) 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 ret;
int length = 2 * ssl->specs.hash_size + int length = 2 * ssl->specs.hash_size +
2 * ssl->specs.key_size + 2 * ssl->specs.key_size +
2 * ssl->specs.iv_size; 2 * ssl->specs.iv_size;
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
byte* key_data; byte* key_data;
#else #else
byte key_data[MAX_PRF_DIG]; byte key_data[MAX_PRF_DIG];
#endif #endif
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
key_data = (byte*)XMALLOC(MAX_PRF_DIG, NULL, DYNAMIC_TYPE_TMP_BUFFER); key_data = (byte*)XMALLOC(MAX_PRF_DIG, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (key_data == NULL) { if (key_data == NULL) {
return MEMORY_E; return MEMORY_E;
} }
#endif #endif
ret = CyaSSL_DeriveTlsKeys(key_data, length, ret = wolfSSL_DeriveTlsKeys(key_data, length,
ssl->arrays->masterSecret, SECRET_LEN, ssl->arrays->masterSecret, SECRET_LEN,
ssl->arrays->serverRandom, ssl->arrays->clientRandom, ssl->arrays->serverRandom, ssl->arrays->clientRandom,
IsAtLeastTLSv1_2(ssl), ssl->specs.mac_algorithm); IsAtLeastTLSv1_2(ssl), ssl->specs.mac_algorithm);
if (ret == 0) if (ret == 0)
ret = StoreKeys(ssl, key_data); ret = StoreKeys(ssl, key_data);
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
XFREE(key_data, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(key_data, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif #endif
@ -458,7 +458,7 @@ int DeriveTlsKeys(CYASSL* ssl)
/* External facing wrapper so user can call as well, 0 on success */ /* 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* pms, word32 pmsLen,
const byte* cr, const byte* sr, const byte* cr, const byte* sr,
int tls1_2, int hash_type) 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; 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->preMasterSecret, ssl->arrays->preMasterSz,
ssl->arrays->clientRandom, ssl->arrays->serverRandom, ssl->arrays->clientRandom, ssl->arrays->serverRandom,
IsAtLeastTLSv1_2(ssl), ssl->specs.mac_algorithm); 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 /* Used by EAP-TLS and EAP-TTLS to derive keying material from
* the master_secret. */ * 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) const char* label)
{ {
int ret; int ret;
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
byte* seed; byte* seed;
#else #else
byte seed[SEED_LEN]; byte seed[SEED_LEN];
#endif #endif
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
seed = (byte*)XMALLOC(SEED_LEN, NULL, DYNAMIC_TYPE_TMP_BUFFER); seed = (byte*)XMALLOC(SEED_LEN, NULL, DYNAMIC_TYPE_TMP_BUFFER);
if (seed == NULL) if (seed == NULL)
return MEMORY_E; 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, (const byte *)label, (word32)strlen(label), seed, SEED_LEN,
IsAtLeastTLSv1_2(ssl), ssl->specs.mac_algorithm); IsAtLeastTLSv1_2(ssl), ssl->specs.mac_algorithm);
#ifdef CYASSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
XFREE(seed, NULL, DYNAMIC_TYPE_TMP_BUFFER); XFREE(seed, NULL, DYNAMIC_TYPE_TMP_BUFFER);
#endif #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 (ssl->options.dtls) {
if (verify) if (verify)
return ssl->keys.dtls_state.curSeq; /* explicit from peer */ 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) if (verify)
return ssl->keys.dtls_state.curEpoch; return ssl->keys.dtls_state.curEpoch;
@ -598,14 +598,14 @@ static INLINE word32 GetEpoch(CYASSL* ssl, int verify)
return ssl->keys.dtls_epoch; return ssl->keys.dtls_epoch;
} }
#endif /* CYASSL_DTLS */ #endif /* WOLFSSL_DTLS */
/*** end copy ***/ /*** end copy ***/
/* return HMAC digest type in CyaSSL format */ /* return HMAC digest type in wolfSSL format */
int CyaSSL_GetHmacType(CYASSL* ssl) int wolfSSL_GetHmacType(WOLFSSL* ssl)
{ {
if (ssl == NULL) if (ssl == NULL)
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
@ -623,7 +623,7 @@ int CyaSSL_GetHmacType(CYASSL* ssl)
return SHA256; return SHA256;
} }
#endif #endif
#ifdef CYASSL_SHA384 #ifdef WOLFSSL_SHA384
case sha384_mac: case sha384_mac:
{ {
return SHA384; 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) int verify)
{ {
if (ssl == NULL || inner == NULL) if (ssl == NULL || inner == NULL)
return BAD_FUNC_ARG; 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) if (ssl->options.dtls)
c16toa((word16)GetEpoch(ssl, verify), inner); c16toa((word16)GetEpoch(ssl, verify), inner);
#endif #endif
@ -673,12 +673,12 @@ int CyaSSL_SetTlsHmacInner(CYASSL* ssl, byte* inner, word32 sz, int content,
/* TLS type HMAC */ /* 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) int content, int verify)
{ {
Hmac hmac; Hmac hmac;
int ret; int ret;
byte myInner[CYASSL_TLS_HMAC_INNER_SZ]; byte myInner[WOLFSSL_TLS_HMAC_INNER_SZ];
if (ssl == NULL) if (ssl == NULL)
return BAD_FUNC_ARG; 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); ssl->fuzzerCb(ssl, in, sz, FUZZ_HMAC, ssl->fuzzerCtx);
#endif #endif
CyaSSL_SetTlsHmacInner(ssl, myInner, sz, content, verify); wolfSSL_SetTlsHmacInner(ssl, myInner, sz, content, verify);
ret = HmacSetKey(&hmac, CyaSSL_GetHmacType(ssl), ret = HmacSetKey(&hmac, wolfSSL_GetHmacType(ssl),
CyaSSL_GetMacSecret(ssl, verify), ssl->specs.hash_size); wolfSSL_GetMacSecret(ssl, verify), ssl->specs.hash_size);
if (ret != 0) if (ret != 0)
return ret; return ret;
ret = HmacUpdate(&hmac, myInner, sizeof(myInner)); 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. is assigned to be used by another extension.
Use this check value for the new extension and decrement Use this check value for the new extension and decrement
the check value by one. */ 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); TLSX *ext = TLSX_Find(ssl->extensions, type);
@ -800,7 +800,7 @@ static void TLSX_SNI_Free(SNI* sni)
{ {
if (sni) { if (sni) {
switch (sni->type) { switch (sni->type) {
case CYASSL_SNI_HOST_NAME: case WOLFSSL_SNI_HOST_NAME:
XFREE(sni->data.host_name, 0, DYNAMIC_TYPE_TLSX); XFREE(sni->data.host_name, 0, DYNAMIC_TYPE_TLSX);
break; break;
} }
@ -830,7 +830,7 @@ static int TLSX_SNI_Append(SNI** list, byte type, const void* data, word16 size)
return MEMORY_E; return MEMORY_E;
switch (type) { switch (type) {
case CYASSL_SNI_HOST_NAME: { case WOLFSSL_SNI_HOST_NAME: {
sni->data.host_name = XMALLOC(size + 1, 0, DYNAMIC_TYPE_TLSX); sni->data.host_name = XMALLOC(size + 1, 0, DYNAMIC_TYPE_TLSX);
if (sni->data.host_name) { 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->type = type;
sni->next = *list; sni->next = *list;
#ifndef NO_CYASSL_SERVER #ifndef NO_WOLFSSL_SERVER
sni->options = 0; sni->options = 0;
sni->status = CYASSL_SNI_NO_MATCH; sni->status = WOLFSSL_SNI_NO_MATCH;
#endif #endif
*list = sni; *list = sni;
@ -872,7 +872,7 @@ static word16 TLSX_SNI_GetSize(SNI* list)
length += ENUM_LEN + OPAQUE16_LEN; /* sni type + sni length */ length += ENUM_LEN + OPAQUE16_LEN; /* sni type + sni length */
switch (sni->type) { switch (sni->type) {
case CYASSL_SNI_HOST_NAME: case WOLFSSL_SNI_HOST_NAME:
length += XSTRLEN((char*)sni->data.host_name); length += XSTRLEN((char*)sni->data.host_name);
break; break;
} }
@ -893,7 +893,7 @@ static word16 TLSX_SNI_Write(SNI* list, byte* output)
output[offset++] = sni->type; /* sni type */ output[offset++] = sni->type; /* sni type */
switch (sni->type) { switch (sni->type) {
case CYASSL_SNI_HOST_NAME: case WOLFSSL_SNI_HOST_NAME:
length = XSTRLEN((char*)sni->data.host_name); length = XSTRLEN((char*)sni->data.host_name);
c16toa(length, output + offset); /* sni length */ c16toa(length, output + offset); /* sni length */
@ -921,7 +921,7 @@ static SNI* TLSX_SNI_Find(SNI *list, byte type)
return sni; return sni;
} }
#ifndef NO_CYASSL_SERVER #ifndef NO_WOLFSSL_SERVER
static void TLSX_SNI_SetStatus(TLSX* extensions, byte type, byte status) static void TLSX_SNI_SetStatus(TLSX* extensions, byte type, byte status)
{ {
TLSX* extension = TLSX_Find(extensions, SERVER_NAME_INDICATION); 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) { if (sni) {
sni->status = status; 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 #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) byte isRequest)
{ {
#ifndef NO_CYASSL_SERVER #ifndef NO_WOLFSSL_SERVER
word16 size = 0; word16 size = 0;
word16 offset = 0; word16 offset = 0;
#endif #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! return length ? BUFFER_ERROR : 0; /* SNI response must be empty!
Nothing else to do. */ Nothing else to do. */
#ifndef NO_CYASSL_SERVER #ifndef NO_WOLFSSL_SERVER
if (OPAQUE16_LEN > length) if (OPAQUE16_LEN > length)
return BUFFER_ERROR; return BUFFER_ERROR;
@ -996,21 +996,21 @@ static int TLSX_SNI_Parse(CYASSL* ssl, byte* input, word16 length,
} }
switch(type) { switch(type) {
case CYASSL_SNI_HOST_NAME: { case WOLFSSL_SNI_HOST_NAME: {
byte matched = (XSTRLEN(sni->data.host_name) == size) byte matched = (XSTRLEN(sni->data.host_name) == size)
&& (XSTRNCMP(sni->data.host_name, && (XSTRNCMP(sni->data.host_name,
(const char*)input + offset, size) == 0); (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, int r = TLSX_UseSNI(&ssl->extensions,
type, input + offset, size); type, input + offset, size);
if (r != SSL_SUCCESS) return r; /* throw error */ if (r != SSL_SUCCESS) return r; /* throw error */
TLSX_SNI_SetStatus(ssl->extensions, type, 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); SendAlert(ssl, alert_fatal, unrecognized_name);
return UNKNOWN_SNI_HOST_NAME_E; 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; return SSL_SUCCESS;
} }
#ifndef NO_CYASSL_SERVER #ifndef NO_WOLFSSL_SERVER
word16 TLSX_SNI_GetRequest(TLSX* extensions, byte type, void** data) word16 TLSX_SNI_GetRequest(TLSX* extensions, byte type, void** data)
{ {
TLSX* extension = TLSX_Find(extensions, SERVER_NAME_INDICATION); TLSX* extension = TLSX_Find(extensions, SERVER_NAME_INDICATION);
SNI* sni = TLSX_SNI_Find(extension ? extension->data : NULL, type); 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) { switch (sni->type) {
case CYASSL_SNI_HOST_NAME: case WOLFSSL_SNI_HOST_NAME:
*data = sni->data.host_name; *data = sni->data.host_name;
return XSTRLEN(*data); return XSTRLEN(*data);
} }
@ -1246,18 +1246,18 @@ static word16 TLSX_MFL_Write(byte* data, byte* output)
return ENUM_LEN; 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) byte isRequest)
{ {
if (length != ENUM_LEN) if (length != ENUM_LEN)
return BUFFER_ERROR; return BUFFER_ERROR;
switch (*input) { switch (*input) {
case CYASSL_MFL_2_9 : ssl->max_fragment = 512; break; case WOLFSSL_MFL_2_9 : ssl->max_fragment = 512; break;
case CYASSL_MFL_2_10: ssl->max_fragment = 1024; break; case WOLFSSL_MFL_2_10: ssl->max_fragment = 1024; break;
case CYASSL_MFL_2_11: ssl->max_fragment = 2048; break; case WOLFSSL_MFL_2_11: ssl->max_fragment = 2048; break;
case CYASSL_MFL_2_12: ssl->max_fragment = 4096; break; case WOLFSSL_MFL_2_12: ssl->max_fragment = 4096; break;
case CYASSL_MFL_2_13: ssl->max_fragment = 8192; break; case WOLFSSL_MFL_2_13: ssl->max_fragment = 8192; break;
default: default:
SendAlert(ssl, alert_fatal, illegal_parameter); 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; return UNKNOWN_MAX_FRAG_LEN_E;
} }
#ifndef NO_CYASSL_SERVER #ifndef NO_WOLFSSL_SERVER
if (isRequest) { if (isRequest) {
int r = TLSX_UseMaxFragment(&ssl->extensions, *input); int r = TLSX_UseMaxFragment(&ssl->extensions, *input);
@ -1286,7 +1286,7 @@ int TLSX_UseMaxFragment(TLSX** extensions, byte mfl)
if (extensions == NULL) if (extensions == NULL)
return BAD_FUNC_ARG; 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; return BAD_FUNC_ARG;
if ((data = XMALLOC(ENUM_LEN, 0, DYNAMIC_TYPE_TLSX)) == NULL) 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 #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) byte isRequest)
{ {
if (length != 0 || input == NULL) if (length != 0 || input == NULL)
return BUFFER_ERROR; return BUFFER_ERROR;
#ifndef NO_CYASSL_SERVER #ifndef NO_WOLFSSL_SERVER
if (isRequest) { if (isRequest) {
int r = TLSX_UseTruncatedHMAC(&ssl->extensions); int r = TLSX_UseTruncatedHMAC(&ssl->extensions);
@ -1397,9 +1397,9 @@ static int TLSX_EllipticCurve_Append(EllipticCurve** list, word16 name)
return 0; 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; int i;
@ -1447,10 +1447,10 @@ static word16 TLSX_EllipticCurve_Write(EllipticCurve* list, byte* output)
return OPAQUE16_LEN + length; return OPAQUE16_LEN + length;
} }
#endif /* NO_CYASSL_CLIENT */ #endif /* NO_WOLFSSL_CLIENT */
#ifndef NO_CYASSL_SERVER #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) byte isRequest)
{ {
word16 offset; word16 offset;
@ -1480,7 +1480,7 @@ static int TLSX_EllipticCurve_Parse(CYASSL* ssl, byte* input, word16 length,
return 0; 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* extension = (first == ECC_BYTE)
? TLSX_Find(ssl->extensions, ELLIPTIC_CURVES) ? TLSX_Find(ssl->extensions, ELLIPTIC_CURVES)
: NULL; : NULL;
@ -1499,12 +1499,12 @@ int TLSX_ValidateEllipticCurves(CYASSL* ssl, byte first, byte second) {
for (curve = extension->data; curve && !(sig && key); curve = curve->next) { for (curve = extension->data; curve && !(sig && key); curve = curve->next) {
switch (curve->name) { switch (curve->name) {
case CYASSL_ECC_SECP160R1: oid = ECC_160R1; octets = 20; break; case WOLFSSL_ECC_SECP160R1: oid = ECC_160R1; octets = 20; break;
case CYASSL_ECC_SECP192R1: oid = ECC_192R1; octets = 24; break; case WOLFSSL_ECC_SECP192R1: oid = ECC_192R1; octets = 24; break;
case CYASSL_ECC_SECP224R1: oid = ECC_224R1; octets = 28; break; case WOLFSSL_ECC_SECP224R1: oid = ECC_224R1; octets = 28; break;
case CYASSL_ECC_SECP256R1: oid = ECC_256R1; octets = 32; break; case WOLFSSL_ECC_SECP256R1: oid = ECC_256R1; octets = 32; break;
case CYASSL_ECC_SECP384R1: oid = ECC_384R1; octets = 48; break; case WOLFSSL_ECC_SECP384R1: oid = ECC_384R1; octets = 48; break;
case CYASSL_ECC_SECP521R1: oid = ECC_521R1; octets = 66; break; case WOLFSSL_ECC_SECP521R1: oid = ECC_521R1; octets = 66; break;
default: continue; /* unsupported curve */ default: continue; /* unsupported curve */
} }
@ -1575,7 +1575,7 @@ int TLSX_ValidateEllipticCurves(CYASSL* ssl, byte first, byte second) {
return sig && key; return sig && key;
} }
#endif /* NO_CYASSL_SERVER */ #endif /* NO_WOLFSSL_SERVER */
int TLSX_UseSupportedCurve(TLSX** extensions, word16 name) 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_FREE_ALL TLSX_EllipticCurve_FreeAll
#define EC_VALIDATE_REQUEST TLSX_EllipticCurve_ValidateRequest #define EC_VALIDATE_REQUEST TLSX_EllipticCurve_ValidateRequest
#ifndef NO_CYASSL_CLIENT #ifndef NO_WOLFSSL_CLIENT
#define EC_GET_SIZE TLSX_EllipticCurve_GetSize #define EC_GET_SIZE TLSX_EllipticCurve_GetSize
#define EC_WRITE TLSX_EllipticCurve_Write #define EC_WRITE TLSX_EllipticCurve_Write
#else #else
@ -1627,7 +1627,7 @@ int TLSX_UseSupportedCurve(TLSX** extensions, word16 name)
#define EC_WRITE(a, b) 0 #define EC_WRITE(a, b) 0
#endif #endif
#ifndef NO_CYASSL_SERVER #ifndef NO_WOLFSSL_SERVER
#define EC_PARSE TLSX_EllipticCurve_Parse #define EC_PARSE TLSX_EllipticCurve_Parse
#else #else
#define EC_PARSE(a, b, c, d) 0 #define EC_PARSE(a, b, c, d) 0
@ -1684,21 +1684,21 @@ static word16 TLSX_SecureRenegotiation_Write(SecureRenegotiation* data,
return offset; return offset;
} }
static int TLSX_SecureRenegotiation_Parse(CYASSL* ssl, byte* input, static int TLSX_SecureRenegotiation_Parse(WOLFSSL* ssl, byte* input,
word16 length, byte isRequest) word16 length, byte isRequest)
{ {
int ret = SECURE_RENEGOTIATION_E; int ret = SECURE_RENEGOTIATION_E;
if (length >= OPAQUE8_LEN) { if (length >= OPAQUE8_LEN) {
if (ssl->secure_renegotiation == NULL) { if (ssl->secure_renegotiation == NULL) {
#ifndef NO_CYASSL_SERVER #ifndef NO_WOLFSSL_SERVER
if (isRequest && *input == 0) { if (isRequest && *input == 0) {
ret = 0; /* don't reply, user didn't enable */ ret = 0; /* don't reply, user didn't enable */
} }
#endif #endif
} }
else if (isRequest) { else if (isRequest) {
#ifndef NO_CYASSL_SERVER #ifndef NO_WOLFSSL_SERVER
if (*input == TLS_FINISHED_SZ) { if (*input == TLS_FINISHED_SZ) {
/* TODO compare client_verify_data */ /* TODO compare client_verify_data */
ret = 0; ret = 0;
@ -1706,7 +1706,7 @@ static int TLSX_SecureRenegotiation_Parse(CYASSL* ssl, byte* input,
#endif #endif
} }
else { else {
#ifndef NO_CYASSL_CLIENT #ifndef NO_WOLFSSL_CLIENT
if (!ssl->secure_renegotiation->enabled) { if (!ssl->secure_renegotiation->enabled) {
if (*input == 0) { if (*input == 0) {
ssl->secure_renegotiation->enabled = 1; ssl->secure_renegotiation->enabled = 1;
@ -1767,7 +1767,7 @@ int TLSX_UseSecureRenegotiation(TLSX** extensions)
#ifdef HAVE_SESSION_TICKET #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); TLSX* extension = TLSX_Find(ssl->extensions, SESSION_TICKET);
SessionTicket* ticket = extension ? extension->data : NULL; 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) byte isRequest)
{ {
if (!isRequest) { if (!isRequest) {
@ -1818,7 +1818,7 @@ static int TLSX_SessionTicket_Parse(CYASSL* ssl, byte* input, word16 length,
return 0; return 0;
} }
CYASSL_LOCAL SessionTicket* TLSX_SessionTicket_Create(word32 lifetime, WOLFSSL_LOCAL SessionTicket* TLSX_SessionTicket_Create(word32 lifetime,
byte* data, word16 size) byte* data, word16 size)
{ {
SessionTicket* ticket = (SessionTicket*)XMALLOC(sizeof(SessionTicket), SessionTicket* ticket = (SessionTicket*)XMALLOC(sizeof(SessionTicket),
@ -1837,7 +1837,7 @@ CYASSL_LOCAL SessionTicket* TLSX_SessionTicket_Create(word32 lifetime,
return ticket; return ticket;
} }
CYASSL_LOCAL void TLSX_SessionTicket_Free(SessionTicket* ticket) WOLFSSL_LOCAL void TLSX_SessionTicket_Free(SessionTicket* ticket)
{ {
if (ticket) { if (ticket) {
XFREE(ticket->data, NULL, DYNAMIC_TYPE_TLSX); 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); 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; return offset;
} }
#ifndef NO_CYASSL_CLIENT #ifndef NO_WOLFSSL_CLIENT
word16 TLSX_GetRequestSize(CYASSL* ssl) word16 TLSX_GetRequestSize(WOLFSSL* ssl)
{ {
word16 length = 0; word16 length = 0;
@ -2063,7 +2063,7 @@ word16 TLSX_GetRequestSize(CYASSL* ssl)
return length; return length;
} }
word16 TLSX_WriteRequest(CYASSL* ssl, byte* output) word16 TLSX_WriteRequest(WOLFSSL* ssl, byte* output)
{ {
word16 offset = 0; word16 offset = 0;
@ -2109,11 +2109,11 @@ word16 TLSX_WriteRequest(CYASSL* ssl, byte* output)
return offset; 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; word16 length = 0;
byte semaphore[SEMAPHORE_SIZE] = {0}; byte semaphore[SEMAPHORE_SIZE] = {0};
@ -2129,7 +2129,7 @@ word16 TLSX_GetResponseSize(CYASSL* ssl)
return length; return length;
} }
word16 TLSX_WriteResponse(CYASSL *ssl, byte* output) word16 TLSX_WriteResponse(WOLFSSL *ssl, byte* output)
{ {
word16 offset = 0; word16 offset = 0;
@ -2147,9 +2147,9 @@ word16 TLSX_WriteResponse(CYASSL *ssl, byte* output)
return offset; 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) Suites *suites)
{ {
int ret = 0; int ret = 0;
@ -2176,37 +2176,37 @@ int TLSX_Parse(CYASSL* ssl, byte* input, word16 length, byte isRequest,
switch (type) { switch (type) {
case SERVER_NAME_INDICATION: case SERVER_NAME_INDICATION:
CYASSL_MSG("SNI extension received"); WOLFSSL_MSG("SNI extension received");
ret = SNI_PARSE(ssl, input + offset, size, isRequest); ret = SNI_PARSE(ssl, input + offset, size, isRequest);
break; break;
case MAX_FRAGMENT_LENGTH: 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); ret = MFL_PARSE(ssl, input + offset, size, isRequest);
break; break;
case TRUNCATED_HMAC: case TRUNCATED_HMAC:
CYASSL_MSG("Truncated HMAC extension received"); WOLFSSL_MSG("Truncated HMAC extension received");
ret = THM_PARSE(ssl, input + offset, size, isRequest); ret = THM_PARSE(ssl, input + offset, size, isRequest);
break; break;
case ELLIPTIC_CURVES: case ELLIPTIC_CURVES:
CYASSL_MSG("Elliptic Curves extension received"); WOLFSSL_MSG("Elliptic Curves extension received");
ret = EC_PARSE(ssl, input + offset, size, isRequest); ret = EC_PARSE(ssl, input + offset, size, isRequest);
break; break;
case SECURE_RENEGOTIATION: case SECURE_RENEGOTIATION:
CYASSL_MSG("Secure Renegotiation extension received"); WOLFSSL_MSG("Secure Renegotiation extension received");
ret = SCR_PARSE(ssl, input + offset, size, isRequest); ret = SCR_PARSE(ssl, input + offset, size, isRequest);
break; break;
case SESSION_TICKET: case SESSION_TICKET:
CYASSL_MSG("Session Ticket extension received"); WOLFSSL_MSG("Session Ticket extension received");
ret = STK_PARSE(ssl, input + offset, size, isRequest); ret = STK_PARSE(ssl, input + offset, size, isRequest);
break; break;
@ -2226,7 +2226,7 @@ int TLSX_Parse(CYASSL* ssl, byte* input, word16 length, byte isRequest,
HELLO_EXT_SIGALGO_MAX)); HELLO_EXT_SIGALGO_MAX));
} }
} else { } else {
CYASSL_MSG("Servers MUST NOT send SIG ALGO extension."); WOLFSSL_MSG("Servers MUST NOT send SIG ALGO extension.");
} }
break; break;
@ -2247,14 +2247,14 @@ int TLSX_Parse(CYASSL* ssl, byte* input, word16 length, byte isRequest,
#endif #endif
#ifndef NO_CYASSL_CLIENT #ifndef NO_WOLFSSL_CLIENT
#ifndef NO_OLD_TLS #ifndef NO_OLD_TLS
CYASSL_METHOD* CyaTLSv1_client_method(void) WOLFSSL_METHOD* wolfTLSv1_client_method(void)
{ {
CYASSL_METHOD* method = WOLFSSL_METHOD* method =
(CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0,
DYNAMIC_TYPE_METHOD); DYNAMIC_TYPE_METHOD);
if (method) if (method)
InitSSL_Method(method, MakeTLSv1()); 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 = WOLFSSL_METHOD* method =
(CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0,
DYNAMIC_TYPE_METHOD); DYNAMIC_TYPE_METHOD);
if (method) if (method)
InitSSL_Method(method, MakeTLSv1_1()); 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 */ #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 = WOLFSSL_METHOD* method =
(CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0,
DYNAMIC_TYPE_METHOD); DYNAMIC_TYPE_METHOD);
if (method) if (method)
InitSSL_Method(method, MakeTLSv1_2()); InitSSL_Method(method, MakeTLSv1_2());
@ -2289,10 +2289,10 @@ int TLSX_Parse(CYASSL* ssl, byte* input, word16 length, byte isRequest,
#endif #endif
CYASSL_METHOD* CyaSSLv23_client_method(void) WOLFSSL_METHOD* wolfSSLv23_client_method(void)
{ {
CYASSL_METHOD* method = WOLFSSL_METHOD* method =
(CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0,
DYNAMIC_TYPE_METHOD); DYNAMIC_TYPE_METHOD);
if (method) { if (method) {
#ifndef NO_SHA256 /* 1.2 requires SHA256 */ #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 #ifndef NO_OLD_TLS
CYASSL_METHOD* CyaTLSv1_server_method(void) WOLFSSL_METHOD* wolfTLSv1_server_method(void)
{ {
CYASSL_METHOD* method = WOLFSSL_METHOD* method =
(CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0,
DYNAMIC_TYPE_METHOD); DYNAMIC_TYPE_METHOD);
if (method) { if (method) {
InitSSL_Method(method, MakeTLSv1()); InitSSL_Method(method, MakeTLSv1());
method->side = CYASSL_SERVER_END; method->side = WOLFSSL_SERVER_END;
} }
return method; return method;
} }
CYASSL_METHOD* CyaTLSv1_1_server_method(void) WOLFSSL_METHOD* wolfTLSv1_1_server_method(void)
{ {
CYASSL_METHOD* method = WOLFSSL_METHOD* method =
(CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0,
DYNAMIC_TYPE_METHOD); DYNAMIC_TYPE_METHOD);
if (method) { if (method) {
InitSSL_Method(method, MakeTLSv1_1()); InitSSL_Method(method, MakeTLSv1_1());
method->side = CYASSL_SERVER_END; method->side = WOLFSSL_SERVER_END;
} }
return method; 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 */ #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 = WOLFSSL_METHOD* method =
(CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0,
DYNAMIC_TYPE_METHOD); DYNAMIC_TYPE_METHOD);
if (method) { if (method) {
InitSSL_Method(method, MakeTLSv1_2()); InitSSL_Method(method, MakeTLSv1_2());
method->side = CYASSL_SERVER_END; method->side = WOLFSSL_SERVER_END;
} }
return method; return method;
} }
@ -2360,10 +2360,10 @@ int TLSX_Parse(CYASSL* ssl, byte* input, word16 length, byte isRequest,
#endif #endif
CYASSL_METHOD* CyaSSLv23_server_method(void) WOLFSSL_METHOD* wolfSSLv23_server_method(void)
{ {
CYASSL_METHOD* method = WOLFSSL_METHOD* method =
(CYASSL_METHOD*) XMALLOC(sizeof(CYASSL_METHOD), 0, (WOLFSSL_METHOD*) XMALLOC(sizeof(WOLFSSL_METHOD), 0,
DYNAMIC_TYPE_METHOD); DYNAMIC_TYPE_METHOD);
if (method) { if (method) {
#ifndef NO_SHA256 /* 1.2 requires SHA256 */ #ifndef NO_SHA256 /* 1.2 requires SHA256 */
@ -2371,7 +2371,7 @@ int TLSX_Parse(CYASSL* ssl, byte* input, word16 length, byte isRequest,
#else #else
InitSSL_Method(method, MakeTLSv1_1()); InitSSL_Method(method, MakeTLSv1_1());
#endif #endif
method->side = CYASSL_SERVER_END; method->side = WOLFSSL_SERVER_END;
#ifndef NO_OLD_TLS #ifndef NO_OLD_TLS
method->downgrade = 1; method->downgrade = 1;
#endif /* !NO_OLD_TLS */ #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 */ #endif /* NO_TLS */

View File

@ -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) int CamelliaSetKey(Camellia* cam, const byte* key, word32 len, const byte* iv)
{ {

View File

@ -2,14 +2,14 @@
* *
* Copyright (C) 2006-2014 wolfSSL Inc. * Copyright (C) 2006-2014 wolfSSL Inc.
* *
* This file is part of CyaSSL. * This file is part of wolfSSL. (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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* CyaSSL is distributed in the hope that it will be useful, * wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
@ -23,16 +23,16 @@
#include <config.h> #include <config.h>
#endif #endif
#include <cyassl/ctaocrypt/settings.h> #include <wolfssl/wolfcrypt/settings.h>
#include <cyassl/ctaocrypt/error-crypt.h> #include <wolfssl/wolfcrypt/error-crypt.h>
#ifdef _MSC_VER #ifdef _MSC_VER
/* 4996 warning to use MS extensions e.g., strcpy_s instead of XSTRNCPY */ /* 4996 warning to use MS extensions e.g., strcpy_s instead of XSTRNCPY */
#pragma warning(disable: 4996) #pragma warning(disable: 4996)
#endif #endif
const char* CTaoCryptGetErrorString(int error) const char* wc_GetErrorString(int error)
{ {
#ifdef NO_ERROR_STRINGS #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);
} }

View File

@ -2,14 +2,14 @@
* *
* Copyright (C) 2006-2014 wolfSSL Inc. * Copyright (C) 2006-2014 wolfSSL Inc.
* *
* This file is part of CyaSSL. * This file is part of wolfSSL. (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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* CyaSSL is distributed in the hope that it will be useful, * wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
@ -19,14 +19,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
/* wolfssl_cyassl compatibility layer */ /* wolfssl_wolfssl compatibility layer */
#include <cyassl/ssl.h> #include <wolfssl/ssl.h>
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
#endif #endif
#include <cyassl/ctaocrypt/settings.h> #include <wolfssl/wolfcrypt/settings.h>
#ifdef XMALLOC_USER #ifdef XMALLOC_USER
#include <stdlib.h> /* we're using malloc / free direct here */ #include <stdlib.h> /* we're using malloc / free direct here */
@ -34,48 +34,48 @@
#ifndef NO_CRYPT_TEST #ifndef NO_CRYPT_TEST
#ifdef CYASSL_TEST_CERT #ifdef WOLFSSL_TEST_CERT
#include <cyassl/ctaocrypt/asn.h> #include <wolfssl/wolfcrypt/asn.h>
#else #else
#include <cyassl/ctaocrypt/asn_public.h> #include <wolfssl/wolfcrypt/asn_public.h>
#endif #endif
#include <cyassl/ctaocrypt/md2.h> #include <wolfssl/wolfcrypt/md2.h>
#include <cyassl/ctaocrypt/md5.h> #include <wolfssl/wolfcrypt/md5.h>
#include <cyassl/ctaocrypt/md4.h> #include <wolfssl/wolfcrypt/md4.h>
#include <cyassl/ctaocrypt/sha.h> #include <wolfssl/wolfcrypt/sha.h>
#include <cyassl/ctaocrypt/sha256.h> #include <wolfssl/wolfcrypt/sha256.h>
#include <cyassl/ctaocrypt/sha512.h> #include <wolfssl/wolfcrypt/sha512.h>
#include <cyassl/ctaocrypt/arc4.h> #include <wolfssl/wolfcrypt/arc4.h>
#include <cyassl/ctaocrypt/random.h> #include <wolfssl/wolfcrypt/random.h>
#include <cyassl/ctaocrypt/coding.h> #include <wolfssl/wolfcrypt/coding.h>
#include <cyassl/ctaocrypt/rsa.h> #include <wolfssl/wolfcrypt/rsa.h>
#include <cyassl/ctaocrypt/des3.h> #include <wolfssl/wolfcrypt/des3.h>
#include <cyassl/ctaocrypt/aes.h> #include <wolfssl/wolfcrypt/aes.h>
#include <cyassl/ctaocrypt/poly1305.h> #include <wolfssl/wolfcrypt/poly1305.h>
#include <cyassl/ctaocrypt/camellia.h> #include <wolfssl/wolfcrypt/camellia.h>
#include <cyassl/ctaocrypt/hmac.h> #include <wolfssl/wolfcrypt/hmac.h>
#include <cyassl/ctaocrypt/dh.h> #include <wolfssl/wolfcrypt/dh.h>
#include <cyassl/ctaocrypt/dsa.h> #include <wolfssl/wolfcrypt/dsa.h>
#include <cyassl/ctaocrypt/hc128.h> #include <wolfssl/wolfcrypt/hc128.h>
#include <cyassl/ctaocrypt/rabbit.h> #include <wolfssl/wolfcrypt/rabbit.h>
#include <cyassl/ctaocrypt/chacha.h> #include <wolfssl/wolfcrypt/chacha.h>
#include <cyassl/ctaocrypt/pwdbased.h> #include <wolfssl/wolfcrypt/pwdbased.h>
#include <cyassl/ctaocrypt/ripemd.h> #include <wolfssl/wolfcrypt/ripemd.h>
#include <cyassl/ctaocrypt/error-crypt.h> #include <wolfssl/wolfcrypt/error-crypt.h>
#ifdef HAVE_ECC #ifdef HAVE_ECC
#include <cyassl/ctaocrypt/ecc.h> #include <wolfssl/wolfcrypt/ecc.h>
#endif #endif
#ifdef HAVE_BLAKE2 #ifdef HAVE_BLAKE2
#include <cyassl/ctaocrypt/blake2.h> #include <wolfssl/wolfcrypt/blake2.h>
#endif #endif
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
#include <cyassl/ctaocrypt/compress.h> #include <wolfssl/wolfcrypt/compress.h>
#endif #endif
#ifdef HAVE_PKCS7 #ifdef HAVE_PKCS7
#include <cyassl/ctaocrypt/pkcs7.h> #include <wolfssl/wolfcrypt/pkcs7.h>
#endif #endif
#ifdef HAVE_FIPS #ifdef HAVE_FIPS
#include <cyassl/ctaocrypt/fips_test.h> #include <wolfssl/wolfcrypt/fips_test.h>
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
@ -84,29 +84,29 @@
#endif #endif
#ifdef OPENSSL_EXTRA #ifdef OPENSSL_EXTRA
#include <cyassl/openssl/evp.h> #include <wolfssl/openssl/evp.h>
#include <cyassl/openssl/rand.h> #include <wolfssl/openssl/rand.h>
#include <cyassl/openssl/hmac.h> #include <wolfssl/openssl/hmac.h>
#include <cyassl/openssl/des.h> #include <wolfssl/openssl/des.h>
#endif #endif
#if defined(USE_CERT_BUFFERS_1024) || defined(USE_CERT_BUFFERS_2048) #if defined(USE_CERT_BUFFERS_1024) || defined(USE_CERT_BUFFERS_2048)
/* include test cert and key buffers for use with NO_FILESYSTEM */ /* 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" #include "cert_data.h"
/* use certs_test.c for initial data, so other /* use certs_test.c for initial data, so other
commands can share the data. */ commands can share the data. */
#else #else
#include <cyassl/certs_test.h> #include <wolfssl/certs_test.h>
#endif #endif
#endif #endif
#if defined(CYASSL_MDK_ARM) #if defined(WOLFSSL_MDK_ARM)
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
extern FILE * CyaSSL_fopen(const char *fname, const char *mode) ; extern FILE * wolfSSL_fopen(const char *fname, const char *mode) ;
#define fopen CyaSSL_fopen #define fopen wolfSSL_fopen
#endif #endif
#ifdef HAVE_NTRU #ifdef HAVE_NTRU
@ -134,7 +134,7 @@
#define printf dc_log_printf #define printf dc_log_printf
#endif #endif
#include "ctaocrypt/test/test.h" #include "wolfcrypt/test/test.h"
typedef struct testVector { typedef struct testVector {
@ -219,7 +219,7 @@ typedef struct func_args {
static void myFipsCb(int ok, int err, const char* hash) static void myFipsCb(int ok, int err, const char* hash)
{ {
printf("in my Fips callback, ok = %d, err = %d\n", ok, err); 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); printf("hash = %s\n", hash);
if (err == IN_CORE_FIPS_E) { if (err == IN_CORE_FIPS_E) {
@ -231,7 +231,7 @@ static void myFipsCb(int ok, int err, const char* hash)
#endif /* HAVE_FIPS */ #endif /* HAVE_FIPS */
int ctaocrypt_test(void* args) int wolfcrypt_test(void* args)
{ {
int ret = 0; int ret = 0;
@ -260,7 +260,7 @@ int ctaocrypt_test(void* args)
printf( "MD5 test passed!\n"); printf( "MD5 test passed!\n");
#endif #endif
#ifdef CYASSL_MD2 #ifdef WOLFSSL_MD2
if ( (ret = md2_test()) != 0) if ( (ret = md2_test()) != 0)
return err_sys("MD2 test failed!\n", ret); return err_sys("MD2 test failed!\n", ret);
else else
@ -288,21 +288,21 @@ int ctaocrypt_test(void* args)
printf( "SHA-256 test passed!\n"); printf( "SHA-256 test passed!\n");
#endif #endif
#ifdef CYASSL_SHA384 #ifdef WOLFSSL_SHA384
if ( (ret = sha384_test()) != 0) if ( (ret = sha384_test()) != 0)
return err_sys("SHA-384 test failed!\n", ret); return err_sys("SHA-384 test failed!\n", ret);
else else
printf( "SHA-384 test passed!\n"); printf( "SHA-384 test passed!\n");
#endif #endif
#ifdef CYASSL_SHA512 #ifdef WOLFSSL_SHA512
if ( (ret = sha512_test()) != 0) if ( (ret = sha512_test()) != 0)
return err_sys("SHA-512 test failed!\n", ret); return err_sys("SHA-512 test failed!\n", ret);
else else
printf( "SHA-512 test passed!\n"); printf( "SHA-512 test passed!\n");
#endif #endif
#ifdef CYASSL_RIPEMD #ifdef WOLFSSL_RIPEMD
if ( (ret = ripemd_test()) != 0) if ( (ret = ripemd_test()) != 0)
return err_sys("RIPEMD test failed!\n", ret); return err_sys("RIPEMD test failed!\n", ret);
else else
@ -338,14 +338,14 @@ int ctaocrypt_test(void* args)
printf( "HMAC-SHA256 test passed!\n"); printf( "HMAC-SHA256 test passed!\n");
#endif #endif
#ifdef CYASSL_SHA384 #ifdef WOLFSSL_SHA384
if ( (ret = hmac_sha384_test()) != 0) if ( (ret = hmac_sha384_test()) != 0)
return err_sys("HMAC-SHA384 test failed!\n", ret); return err_sys("HMAC-SHA384 test failed!\n", ret);
else else
printf( "HMAC-SHA384 test passed!\n"); printf( "HMAC-SHA384 test passed!\n");
#endif #endif
#ifdef CYASSL_SHA512 #ifdef WOLFSSL_SHA512
if ( (ret = hmac_sha512_test()) != 0) if ( (ret = hmac_sha512_test()) != 0)
return err_sys("HMAC-SHA512 test failed!\n", ret); return err_sys("HMAC-SHA512 test failed!\n", ret);
else else
@ -574,7 +574,7 @@ static int OpenNitroxDevice(int dma_mode,int dev_id)
args.argc = argc; args.argc = argc;
args.argv = argv; args.argv = argv;
ctaocrypt_test(&args); wolfcrypt_test(&args);
#ifdef HAVE_CAVIUM #ifdef HAVE_CAVIUM
CspShutdown(CAVIUM_DEV_ID); CspShutdown(CAVIUM_DEV_ID);
@ -586,7 +586,7 @@ static int OpenNitroxDevice(int dma_mode,int dev_id)
#endif /* NO_MAIN_DRIVER */ #endif /* NO_MAIN_DRIVER */
#ifdef CYASSL_MD2 #ifdef WOLFSSL_MD2
int md2_test() int md2_test()
{ {
Md2 md2; Md2 md2;
@ -864,7 +864,7 @@ int sha_test(void)
#endif /* NO_SHA */ #endif /* NO_SHA */
#ifdef CYASSL_RIPEMD #ifdef WOLFSSL_RIPEMD
int ripemd_test(void) int ripemd_test(void)
{ {
RipeMd ripemd; RipeMd ripemd;
@ -917,7 +917,7 @@ int ripemd_test(void)
return 0; return 0;
} }
#endif /* CYASSL_RIPEMD */ #endif /* WOLFSSL_RIPEMD */
#ifdef HAVE_BLAKE2 #ifdef HAVE_BLAKE2
@ -1043,7 +1043,7 @@ int sha256_test(void)
#endif #endif
#ifdef CYASSL_SHA512 #ifdef WOLFSSL_SHA512
int sha512_test(void) int sha512_test(void)
{ {
Sha512 sha; Sha512 sha;
@ -1098,7 +1098,7 @@ int sha512_test(void)
#endif #endif
#ifdef CYASSL_SHA384 #ifdef WOLFSSL_SHA384
int sha384_test(void) int sha384_test(void)
{ {
Sha384 sha; Sha384 sha;
@ -1148,7 +1148,7 @@ int sha384_test(void)
return 0; return 0;
} }
#endif /* CYASSL_SHA384 */ #endif /* WOLFSSL_SHA384 */
#if !defined(NO_HMAC) && !defined(NO_MD5) #if !defined(NO_HMAC) && !defined(NO_MD5)
@ -1467,7 +1467,7 @@ int hmac_blake2b_test(void)
#endif #endif
#if !defined(NO_HMAC) && defined(CYASSL_SHA384) #if !defined(NO_HMAC) && defined(WOLFSSL_SHA384)
int hmac_sha384_test(void) int hmac_sha384_test(void)
{ {
Hmac hmac; Hmac hmac;
@ -1544,7 +1544,7 @@ int hmac_sha384_test(void)
#endif #endif
#if !defined(NO_HMAC) && defined(CYASSL_SHA512) #if !defined(NO_HMAC) && defined(WOLFSSL_SHA512)
int hmac_sha512_test(void) int hmac_sha512_test(void)
{ {
Hmac hmac; Hmac hmac;
@ -2147,7 +2147,7 @@ int aes_test(void)
AesFreeCavium(&enc); AesFreeCavium(&enc);
AesFreeCavium(&dec); AesFreeCavium(&dec);
#endif #endif
#ifdef CYASSL_AES_COUNTER #ifdef WOLFSSL_AES_COUNTER
{ {
const byte ctrKey[] = const byte ctrKey[] =
{ {
@ -2229,9 +2229,9 @@ int aes_test(void)
if (memcmp(cipher, oddCipher, 9)) if (memcmp(cipher, oddCipher, 9))
return -71; 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[] = const byte niPlain[] =
{ {
@ -2269,7 +2269,7 @@ int aes_test(void)
if (XMEMCMP(plain, niPlain, AES_BLOCK_SIZE) != 0) if (XMEMCMP(plain, niPlain, AES_BLOCK_SIZE) != 0)
return -20007; return -20007;
} }
#endif /* CYASSL_AESNI && CYASSL_AES_DIRECT */ #endif /* WOLFSSL_AESNI && WOLFSSL_AES_DIRECT */
return 0; return 0;
} }
@ -2968,7 +2968,7 @@ byte GetEntropy(ENTROPY_CMD cmd, byte* out)
#ifdef FREESCALE_MQX #ifdef FREESCALE_MQX
static const char* clientKey = "a:\\certs\\client-key.der"; static const char* clientKey = "a:\\certs\\client-key.der";
static const char* clientCert = "a:\\certs\\client-cert.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* caKeyFile = "a:\\certs\\ca-key.der";
static const char* caCertFile = "a:\\certs\\ca-cert.pem"; static const char* caCertFile = "a:\\certs\\ca-cert.pem";
#ifdef HAVE_ECC #ifdef HAVE_ECC
@ -2976,12 +2976,12 @@ byte GetEntropy(ENTROPY_CMD cmd, byte* out)
static const char* eccCaCertFile = "a:\\certs\\server-ecc.pem"; static const char* eccCaCertFile = "a:\\certs\\server-ecc.pem";
#endif #endif
#endif #endif
#elif defined(CYASSL_MKD_SHELL) #elif defined(WOLFSSL_MKD_SHELL)
static char* clientKey = "certs/client-key.der"; static char* clientKey = "certs/client-key.der";
static char* clientCert = "certs/client-cert.der"; static char* clientCert = "certs/client-cert.der";
void set_clientKey(char *key) { clientKey = key ; } void set_clientKey(char *key) { clientKey = key ; }
void set_clientCert(char *cert) { clientCert = cert ; } void set_clientCert(char *cert) { clientCert = cert ; }
#ifdef CYASSL_CERT_GEN #ifdef WOLFSSL_CERT_GEN
static char* caKeyFile = "certs/ca-key.der"; static char* caKeyFile = "certs/ca-key.der";
static char* caCertFile = "certs/ca-cert.pem"; static char* caCertFile = "certs/ca-cert.pem";
void set_caKeyFile (char * key) { caKeyFile = key ; } void set_caKeyFile (char * key) { caKeyFile = key ; }
@ -2996,7 +2996,7 @@ byte GetEntropy(ENTROPY_CMD cmd, byte* out)
#else #else
static const char* clientKey = "./certs/client-key.der"; static const char* clientKey = "./certs/client-key.der";
static const char* clientCert = "./certs/client-cert.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* caKeyFile = "./certs/ca-key.der";
static const char* caCertFile = "./certs/ca-cert.pem"; static const char* caCertFile = "./certs/ca-cert.pem";
#ifdef HAVE_ECC #ifdef HAVE_ECC
@ -3026,7 +3026,7 @@ int rsa_test(void)
#if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048) #if !defined(USE_CERT_BUFFERS_1024) && !defined(USE_CERT_BUFFERS_2048)
FILE* file, * file2; FILE* file, * file2;
#endif #endif
#ifdef CYASSL_TEST_CERT #ifdef WOLFSSL_TEST_CERT
DecodedCert cert; DecodedCert cert;
#endif #endif
@ -3045,7 +3045,7 @@ int rsa_test(void)
if (!file) { if (!file) {
err_sys("can't open ./certs/client-key.der, " 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); free(tmp);
return -40; return -40;
} }
@ -3082,7 +3082,7 @@ int rsa_test(void)
if (memcmp(plain, in, ret)) return -48; if (memcmp(plain, in, ret)) return -48;
#if defined(CYASSL_MDK_ARM) #if defined(WOLFSSL_MDK_ARM)
#define sizeof(s) strlen((char *)(s)) #define sizeof(s) strlen((char *)(s))
#endif #endif
@ -3105,7 +3105,7 @@ int rsa_test(void)
#undef sizeof #undef sizeof
#endif #endif
#ifdef CYASSL_TEST_CERT #ifdef WOLFSSL_TEST_CERT
InitDecodedCert(&cert, tmp, (word32)bytes, 0); InitDecodedCert(&cert, tmp, (word32)bytes, 0);
ret = ParseCert(&cert, CERT_TYPE, NO_VERIFY, 0); ret = ParseCert(&cert, CERT_TYPE, NO_VERIFY, 0);
@ -3117,7 +3117,7 @@ int rsa_test(void)
#endif #endif
#ifdef CYASSL_KEY_GEN #ifdef WOLFSSL_KEY_GEN
{ {
byte* der; byte* der;
byte* pem; byte* pem;
@ -3216,10 +3216,10 @@ int rsa_test(void)
free(pem); free(pem);
free(der); free(der);
} }
#endif /* CYASSL_KEY_GEN */ #endif /* WOLFSSL_KEY_GEN */
#ifdef CYASSL_CERT_GEN #ifdef WOLFSSL_CERT_GEN
/* self signed */ /* self signed */
{ {
Cert myCert; Cert myCert;
@ -3229,7 +3229,7 @@ int rsa_test(void)
FILE* pemFile; FILE* pemFile;
int certSz; int certSz;
int pemSz; int pemSz;
#ifdef CYASSL_TEST_CERT #ifdef WOLFSSL_TEST_CERT
DecodedCert decode; DecodedCert decode;
#endif #endif
@ -3261,7 +3261,7 @@ int rsa_test(void)
return -401; return -401;
} }
#ifdef CYASSL_TEST_CERT #ifdef WOLFSSL_TEST_CERT
InitDecodedCert(&decode, derCert, certSz, 0); InitDecodedCert(&decode, derCert, certSz, 0);
ret = ParseCert(&decode, CERT_TYPE, NO_VERIFY, 0); ret = ParseCert(&decode, CERT_TYPE, NO_VERIFY, 0);
if (ret != 0) { if (ret != 0) {
@ -3321,7 +3321,7 @@ int rsa_test(void)
size_t bytes3; size_t bytes3;
word32 idx3 = 0; word32 idx3 = 0;
FILE* file3 ; FILE* file3 ;
#ifdef CYASSL_TEST_CERT #ifdef WOLFSSL_TEST_CERT
DecodedCert decode; DecodedCert decode;
#endif #endif
@ -3395,7 +3395,7 @@ int rsa_test(void)
} }
#ifdef CYASSL_TEST_CERT #ifdef WOLFSSL_TEST_CERT
InitDecodedCert(&decode, derCert, certSz, 0); InitDecodedCert(&decode, derCert, certSz, 0);
ret = ParseCert(&decode, CERT_TYPE, NO_VERIFY, 0); ret = ParseCert(&decode, CERT_TYPE, NO_VERIFY, 0);
if (ret != 0) { if (ret != 0) {
@ -3464,7 +3464,7 @@ int rsa_test(void)
size_t bytes3; size_t bytes3;
word32 idx3 = 0; word32 idx3 = 0;
FILE* file3; FILE* file3;
#ifdef CYASSL_TEST_CERT #ifdef WOLFSSL_TEST_CERT
DecodedCert decode; DecodedCert decode;
#endif #endif
@ -3532,7 +3532,7 @@ int rsa_test(void)
return -5408; return -5408;
} }
#ifdef CYASSL_TEST_CERT #ifdef WOLFSSL_TEST_CERT
InitDecodedCert(&decode, derCert, certSz, 0); InitDecodedCert(&decode, derCert, certSz, 0);
ret = ParseCert(&decode, CERT_TYPE, NO_VERIFY, 0); ret = ParseCert(&decode, CERT_TYPE, NO_VERIFY, 0);
if (ret != 0) { if (ret != 0) {
@ -3601,7 +3601,7 @@ int rsa_test(void)
int certSz; int certSz;
int pemSz; int pemSz;
word32 idx3; word32 idx3;
#ifdef CYASSL_TEST_CERT #ifdef WOLFSSL_TEST_CERT
DecodedCert decode; DecodedCert decode;
#endif #endif
derCert = (byte*)malloc(FOURK_BUF); 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); InitDecodedCert(&decode, derCert, certSz, 0);
ret = ParseCert(&decode, CERT_TYPE, NO_VERIFY, 0); ret = ParseCert(&decode, CERT_TYPE, NO_VERIFY, 0);
if (ret != 0) { if (ret != 0) {
@ -3778,7 +3778,7 @@ int rsa_test(void)
free(derCert); free(derCert);
} }
#endif /* HAVE_NTRU */ #endif /* HAVE_NTRU */
#ifdef CYASSL_CERT_REQ #ifdef WOLFSSL_CERT_REQ
{ {
Cert req; Cert req;
byte* der; byte* der;
@ -3864,8 +3864,8 @@ int rsa_test(void)
free(pem); free(pem);
free(der); free(der);
} }
#endif /* CYASSL_CERT_REQ */ #endif /* WOLFSSL_CERT_REQ */
#endif /* CYASSL_CERT_GEN */ #endif /* WOLFSSL_CERT_GEN */
FreeRsaKey(&key); FreeRsaKey(&key);
#ifdef HAVE_CAVIUM #ifdef HAVE_CAVIUM
@ -4095,7 +4095,7 @@ int openssl_test(void)
if (memcmp(hash, d.output, SHA256_DIGEST_SIZE) != 0) if (memcmp(hash, d.output, SHA256_DIGEST_SIZE) != 0)
return -78; return -78;
#ifdef CYASSL_SHA384 #ifdef WOLFSSL_SHA384
e.input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhi" e.input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhi"
"jklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; "jklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu";
@ -4115,10 +4115,10 @@ int openssl_test(void)
if (memcmp(hash, e.output, SHA384_DIGEST_SIZE) != 0) if (memcmp(hash, e.output, SHA384_DIGEST_SIZE) != 0)
return -79; return -79;
#endif /* CYASSL_SHA384 */ #endif /* WOLFSSL_SHA384 */
#ifdef CYASSL_SHA512 #ifdef WOLFSSL_SHA512
f.input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhi" f.input = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhi"
"jklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"; "jklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu";
@ -4139,7 +4139,7 @@ int openssl_test(void)
if (memcmp(hash, f.output, SHA512_DIGEST_SIZE) != 0) if (memcmp(hash, f.output, SHA512_DIGEST_SIZE) != 0)
return -80; return -80;
#endif /* CYASSL_SHA512 */ #endif /* WOLFSSL_SHA512 */
if (RAND_bytes(hash, sizeof(hash)) != 1) 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; int derSz, pemSz;
byte der[FOURK_BUF]; byte der[FOURK_BUF];
@ -4705,7 +4705,7 @@ int ecc_test(void)
return -1029; return -1029;
} }
} }
#endif /* CYASSL_KEY_GEN */ #endif /* WOLFSSL_KEY_GEN */
ecc_free(&pubKey); ecc_free(&pubKey);
ecc_free(&userB); 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(cliCtx, srvSalt);
ret += ecc_ctx_set_peer_salt(srvCtx, cliSalt); ret += ecc_ctx_set_peer_salt(srvCtx, cliSalt);
ret += ecc_ctx_set_info(cliCtx, (byte*)"CyaSSL MSGE", 11); ret += ecc_ctx_set_info(cliCtx, (byte*)"wolfSSL MSGE", 11);
ret += ecc_ctx_set_info(srvCtx, (byte*)"CyaSSL MSGE", 11); ret += ecc_ctx_set_info(srvCtx, (byte*)"wolfSSL MSGE", 11);
if (ret != 0) if (ret != 0)
return -3008; return -3008;
@ -5009,7 +5009,7 @@ int pkcs7enveloped_test(void)
free(cert); free(cert);
free(privKey); free(privKey);
err_sys("can't open ./certs/client-cert.der, " 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; return -42;
} }
@ -5021,7 +5021,7 @@ int pkcs7enveloped_test(void)
free(cert); free(cert);
free(privKey); free(privKey);
err_sys("can't open ./certs/client-key.der, " 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; return -43;
} }
@ -5143,7 +5143,7 @@ int pkcs7signed_test(void)
free(keyDer); free(keyDer);
free(out); free(out);
err_sys("can't open ./certs/client-cert.der, " 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; return -44;
} }
certDerSz = (word32)fread(certDer, 1, FOURK_BUF, file); certDerSz = (word32)fread(certDer, 1, FOURK_BUF, file);
@ -5155,7 +5155,7 @@ int pkcs7signed_test(void)
free(keyDer); free(keyDer);
free(out); free(out);
err_sys("can't open ./certs/client-key.der, " 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; return -45;
} }
keyDerSz = (word32)fread(keyDer, 1, FOURK_BUF, file); keyDerSz = (word32)fread(keyDer, 1, FOURK_BUF, file);

View File

@ -20,10 +20,10 @@
*/ */
#ifndef CTAO_CRYPT_ERROR_H #ifndef WOLF_CRYPT_ERROR_H
#define CTAO_CRYPT_ERROR_H #define WOLF_CRYPT_ERROR_H
#include <cyassl/ctaocrypt/types.h> #include <wolfssl/wolfcrypt/types.h>
#ifdef __cplusplus #ifdef __cplusplus
@ -143,8 +143,8 @@ enum {
}; };
CYASSL_API void CTaoCryptErrorString(int err, char* buff); WOLFSSL_API void wc_ErrorString(int err, char* buff);
CYASSL_API const char* CTaoCryptGetErrorString(int error); WOLFSSL_API const char* wc_GetErrorString(int error);
#ifdef __cplusplus #ifdef __cplusplus