uTasker: Add example client and server tasks
parent
d6741741a0
commit
bd756da613
|
@ -10,6 +10,14 @@ contains a Makefile as well as a simple tutorial on the given topic.
|
|||
|
||||
## Current Examples
|
||||
|
||||
#### utasker (uTasker wolfSSL Example Tasks)
|
||||
|
||||
This directory contains example uTasker client and server tasks that
|
||||
demonstrate using wolfSSL with the uTasker stack. These have been tested on
|
||||
the uTasker Simulator.
|
||||
|
||||
Please see the README.md in utasker/ for further usage and details.
|
||||
|
||||
#### android (Android NDK Examples)
|
||||
|
||||
This directory contains examples that demonstrate using wolfSSL and wolfSSLJNI
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
# Using wolfSSL with uTasker
|
||||
|
||||
This directory contains:
|
||||
|
||||
**wolfSSLClientTask.c** - Example wolfSSL uTasker Client Task
|
||||
**wolfSSLServerTask.c** - Example wolfSSL uTasker Server Task
|
||||
|
||||
|
||||
## Introduction
|
||||
|
||||
wolfSSL is happy to announce that the wolfSSL embedded SSL/TLS and wolfCrypt cryptography libraries have been ported to the uTasker operating system.
|
||||
|
||||
[uTasker](http://www.utasker.com/) is an operating system, stack, and collection of services designed for embedded devices. It includes an OS, filesystem, device drivers, and TCP/IP stack among other features. The uTasker package includes a device simulator, allowing developers to test and debug code faster than would be possible on physical hardware itself. Complete details on the uTasker stack can be found on the project website: http://www.utasker.com/.
|
||||
|
||||
This document describes the wolfSSL uTasker port and how to use wolfSSL in a uTasker-based project to secure socket connections. This document should act as a supplement to the [wolfSSL Manual](https://wolfssl.com/wolfSSL/Docs-wolfssl-manual-toc.html).
|
||||
|
||||
## Documentation
|
||||
|
||||
Documentation on using the [wolfSSL](https://www.wolfssl.com) embedded SSL/TLS library with uTasker can be found on the wolfSSL website here:
|
||||
|
||||
[Using wolfSSL with uTasker](https://wolfssl.com/wolfSSL/Docs-wolfssl-utasker.html)
|
||||
|
||||
## Support
|
||||
|
||||
Please contact wolfSSL at support@wolfssl.com with any questions or bug fixes.
|
||||
|
|
@ -0,0 +1,855 @@
|
|||
/****************************************************************************
|
||||
File Name : wolfSSLClientTask.c
|
||||
Author : wolfSSL Inc.
|
||||
Date Created : March 25, 2016
|
||||
Current Revision : 1.0
|
||||
Notes : This file contains a simple TLS client task with the goal
|
||||
of demonstrating how the wolfSSL embedded SSL/TLS library
|
||||
can be used with the uTasker stack. This client connects
|
||||
to a server over TLS (using raw TCP sockets), sends an
|
||||
HTTP GET message, reads the response, and closes
|
||||
the socket.
|
||||
|
||||
Copyright (C) wolfSSL, Inc. 2016
|
||||
*****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "wolfSSLClientTask.h"
|
||||
#include "wolfssl/wolfcrypt/settings.h"
|
||||
#include "wolfssl/wolfcrypt/aes.h"
|
||||
#include "wolfssl/wolfcrypt/rsa.h"
|
||||
#include "wolfssl/ssl.h"
|
||||
|
||||
#define TEST_TCP_PORT 0x80
|
||||
#define TEST_BUFFER_LENGTH 100
|
||||
#define MAX_TCP_LENGTH 1460
|
||||
#define RECV_BUFFER_LENGTH 1500
|
||||
|
||||
/* ---------------------------- STRUCTS / ENUMS ---------------------------- */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
clientInit = 0,
|
||||
clientCryptoTest = 1,
|
||||
clientIdle = 2,
|
||||
clientConnecting = 3,
|
||||
clientTLSInit = 4,
|
||||
clientTLSConnect = 5,
|
||||
clientTLSSend = 6,
|
||||
clientTLSRecv = 7,
|
||||
clientShutdown = 8,
|
||||
} clientStates;
|
||||
|
||||
|
||||
/* func_args from wolfCrypt test.h, so don't have to pull in other stuff */
|
||||
typedef struct func_args {
|
||||
int argc;
|
||||
char** argv;
|
||||
int return_code;
|
||||
} func_args;
|
||||
|
||||
|
||||
typedef struct stTCP_MESSAGE
|
||||
{
|
||||
TCP_HEADER tTCP_Header;
|
||||
unsigned char ucTCP_Message[MAX_TCP_LENGTH];
|
||||
} TCP_MESSAGE;
|
||||
|
||||
|
||||
/* wolfSSL send callback context struct */
|
||||
typedef struct stUTASKER_SENDCTX {
|
||||
TCP_MESSAGE* message; /* TCP frame to send */
|
||||
USOCKET* socket; /* socket pointer */
|
||||
unsigned int dataLen; /* length of data in message frame */
|
||||
unsigned char ackd; /* has ACK been received for data (0:1) */
|
||||
unsigned char flags; /* socket flags, ie: TCP_FLAG_PUSH */
|
||||
} UTASKER_SENDCTX;
|
||||
|
||||
|
||||
/* wolfSSL recv callback context struct */
|
||||
typedef struct stUTASKER_RECVCTX {
|
||||
USOCKET* socket; /* socket pointer */
|
||||
unsigned int used; /* bytes used in buffer */
|
||||
unsigned int offset; /* current offset in buffer, for processing */
|
||||
unsigned int bufLen; /* total size of buffer in bytes */
|
||||
unsigned char* buffer; /* recv data buffer */
|
||||
} UTASKER_RECVCTX;
|
||||
|
||||
/* ------------------------------- VARIABLES ------------------------------- */
|
||||
|
||||
static USOCKET client_socket = 0; /* client socket */
|
||||
static TCP_MESSAGE stMessage; /* structure to hold TCP frame */
|
||||
static UTASKER_SENDCTX sendCtx; /* wolfSSL send callback context */
|
||||
static UTASKER_RECVCTX recvCtx; /* wolfSSL recv callback context */
|
||||
static unsigned char ucRecvBuffer[RECV_BUFFER_LENGTH]; /* TCP recv buffer */
|
||||
static clientStates clientState = clientCryptoTest; /* TLS task state */
|
||||
|
||||
static WOLFSSL_CTX* sslCtx; /* wolfSSL context context */
|
||||
static WOLFSSL* ssl; /* wolfSSL session object */
|
||||
|
||||
/* server IP address and port */
|
||||
static unsigned char ucRemoteIP[IPV4_LENGTH] = { 93,184,216,34 };
|
||||
static unsigned int uiRemotePort = 443;
|
||||
|
||||
/* ------------------------------- PROTOTYPES ------------------------------ */
|
||||
|
||||
int CacheRecvBuffer(UTASKER_RECVCTX* ctx, unsigned char* data,
|
||||
unsigned short length);
|
||||
int ResetRecvBuffer(UTASKER_RECVCTX* ctx);
|
||||
|
||||
/* ---------------------------- SOCKET LISTENERS --------------------------- */
|
||||
|
||||
static int fnClientListener(USOCKET Socket, unsigned char ucEvent,
|
||||
unsigned char *ucIp_Data, unsigned short usPortLen)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
switch (ucEvent)
|
||||
{
|
||||
case TCP_EVENT_CONREQ:
|
||||
case TCP_EVENT_CONNECTED:
|
||||
fnDebugMsg("status: TCP_EVENT_CONNECTED\r\n");
|
||||
clientState = clientTLSInit;
|
||||
break;
|
||||
|
||||
case TCP_EVENT_ACK:
|
||||
fnDebugMsg("status: TCP_EVENT_ACK\r\n");
|
||||
/* ACK received, set ackd variable in CTX msg */
|
||||
sendCtx.ackd = 1;
|
||||
break;
|
||||
|
||||
case TCP_EVENT_ARP_RESOLUTION_FAILED:
|
||||
fnDebugMsg("status: TCP_EVENT_ARP_RESOLUTION_FAILED\r\n");
|
||||
break;
|
||||
|
||||
case TCP_EVENT_PARTIAL_ACK:
|
||||
fnDebugMsg("status: TCP_EVENT_PARTIAL_ACK\r\n");
|
||||
break;
|
||||
|
||||
case TCP_EVENT_REGENERATE:
|
||||
/* frame lost, need to resend last frame, use cached */
|
||||
fnDebugMsg("status: TCP_EVENT_REGENERATE\r\n");
|
||||
if (sendCtx.ackd == 0) {
|
||||
ret = fnSendTCP(*sendCtx.socket,
|
||||
(unsigned char*)&sendCtx.message->tTCP_Header,
|
||||
sendCtx.dataLen, sendCtx.flags);
|
||||
if (ret > 0) {
|
||||
return APP_SENT_DATA;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TCP_EVENT_DATA:
|
||||
/* data received from server */
|
||||
fnDebugMsg("status: TCP_EVENT_DATA\r\n");
|
||||
|
||||
/* copy data into our temp context buffer */
|
||||
if (CacheRecvBuffer(&recvCtx, ucIp_Data, usPortLen) < 0) {
|
||||
return APP_REJECT_DATA;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case TCP_EVENT_ABORT:
|
||||
case TCP_EVENT_CLOSE:
|
||||
case TCP_EVENT_CLOSED:
|
||||
/* server closed connection */
|
||||
fnDebugMsg("status: TCP_EVENT_CLOSE || TCP_EVENT_CLOSED\r\n");
|
||||
break;
|
||||
}
|
||||
return APP_ACCEPT;
|
||||
}
|
||||
|
||||
/* ---------------------------- HELPER FUNCTIONS --------------------------- */
|
||||
|
||||
/*
|
||||
* Copies received data into context buffer to be processed by app task.
|
||||
* Returns copied length on success, negative value on error.
|
||||
*/
|
||||
int CacheRecvBuffer(UTASKER_RECVCTX* ctx, unsigned char* data,
|
||||
unsigned short length)
|
||||
{
|
||||
if (ctx == NULL || ctx->buffer == NULL || data == NULL)
|
||||
return -1;
|
||||
|
||||
/* error if already in use, or too small */
|
||||
if (ctx->used > 0 || ctx->bufLen < length)
|
||||
return -1;
|
||||
|
||||
uMemcpy(ctx->buffer, data, length);
|
||||
ctx->used = length;
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
/* Resets the context buffer and sizes
|
||||
* Returns 0 on success, -1 on error */
|
||||
int ResetRecvBuffer(UTASKER_RECVCTX* ctx)
|
||||
{
|
||||
if (ctx == NULL)
|
||||
return -1;
|
||||
|
||||
uMemset(ctx->buffer, 0, ctx->bufLen);
|
||||
ctx->offset = 0;
|
||||
ctx->used = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------- wolfSSL SEND/RECV/VERIFY CALLBACKS ----------------- */
|
||||
|
||||
|
||||
/*
|
||||
* wolfSSL receive callback
|
||||
*
|
||||
* This function is called by wolfSSL whenever it needs to read data.
|
||||
* Returns number of bytes received, or negative error.
|
||||
* WOLFSSL_CBIO_ERR_WANT_READ should be returned if more data is
|
||||
* needed to be read and wolfSSL should call this function again.
|
||||
*/
|
||||
int UTasker_Receive(WOLFSSL* ssl, char* buf, int sz, void* ctx)
|
||||
{
|
||||
unsigned int copied = 0;
|
||||
UTASKER_RECVCTX* stCtx = (UTASKER_RECVCTX*)ctx;
|
||||
|
||||
if (stCtx == NULL || stCtx->buffer == NULL) {
|
||||
fnDebugMsg("UTasker_Receive invalid parameters\r\n");
|
||||
return WOLFSSL_CBIO_ERR_GENERAL;
|
||||
}
|
||||
|
||||
/* check for socket closed, if no data left return error */
|
||||
if ((fnGetTCP_state(*stCtx->socket) & TCP_STATE_CLOSED) &&
|
||||
(stCtx->used == 0)) {
|
||||
fnDebugMsg("uTasker_Receive socket closed\r\n");
|
||||
return WOLFSSL_CBIO_ERR_GENERAL;
|
||||
}
|
||||
|
||||
if (stCtx->used == 0) {
|
||||
return WOLFSSL_CBIO_ERR_WANT_READ;
|
||||
}
|
||||
|
||||
/* copy either desired sz or number of bytes free in buffer */
|
||||
copied = min((unsigned int)sz, stCtx->used - stCtx->offset);
|
||||
|
||||
uMemcpy(buf, stCtx->buffer + stCtx->offset, copied);
|
||||
stCtx->offset += copied;
|
||||
|
||||
if (stCtx->offset == stCtx->used) {
|
||||
/* packet has been drained, reset */
|
||||
stCtx->offset = 0;
|
||||
stCtx->used = 0;
|
||||
uMemset(stCtx->buffer, 0, stCtx->bufLen);
|
||||
}
|
||||
|
||||
return copied;
|
||||
}
|
||||
|
||||
/*
|
||||
* wolfSSL send callback
|
||||
*
|
||||
* This function is called by wolfSSL whenever it needs to send data.
|
||||
* Returns number of bytes sent, or negative error.
|
||||
* WOLFSSL_CBIO_ERR_WANT_WRITE should be returned if more data is
|
||||
* needed to be sent and wolfSSL should call this function again.
|
||||
*/
|
||||
int UTasker_Send(WOLFSSL* ssl, char* buf, int sz, void* ctx)
|
||||
{
|
||||
int ret, send;
|
||||
UTASKER_SENDCTX* stCtx = (UTASKER_SENDCTX*)ctx;
|
||||
|
||||
if (stCtx == NULL || stCtx->socket == NULL || stCtx->message == NULL) {
|
||||
fnDebugMsg("UTasker_Send, invalid parameters\r\n");
|
||||
return WOLFSSL_CBIO_ERR_GENERAL;
|
||||
}
|
||||
|
||||
/* return error if socket closed */
|
||||
if (fnGetTCP_state(*stCtx->socket) & TCP_STATE_CLOSED) {
|
||||
fnDebugMsg("uTasker_Receive socket closed\r\n");
|
||||
return WOLFSSL_CBIO_ERR_GENERAL;
|
||||
}
|
||||
|
||||
/* return WANT_WRITE if ACK has not been received for last frame */
|
||||
if (stCtx->dataLen != 0 && stCtx->ackd == 0) {
|
||||
return WOLFSSL_CBIO_ERR_WANT_WRITE;
|
||||
}
|
||||
|
||||
send = min(sz, MAX_TCP_LENGTH);
|
||||
uMemcpy(stCtx->message->ucTCP_Message, buf, send);
|
||||
stCtx->dataLen = send;
|
||||
|
||||
ret = fnSendTCP(*stCtx->socket,
|
||||
(unsigned char*)&stCtx->message->tTCP_Header,
|
||||
(unsigned short)send, stCtx->flags);
|
||||
|
||||
if (ret == NO_ARP_ENTRY) {
|
||||
/* dest address must be resolved, try again */
|
||||
return WOLFSSL_CBIO_ERR_WANT_WRITE;
|
||||
}
|
||||
else if (ret <= 0) {
|
||||
/* no data sent or socket error */
|
||||
return WOLFSSL_CBIO_ERR_GENERAL;
|
||||
}
|
||||
|
||||
stCtx->ackd = 0;
|
||||
|
||||
return (int)send;
|
||||
}
|
||||
|
||||
/*
|
||||
* wolfSSL verification callback
|
||||
*
|
||||
* This function is called when peer certificate verification
|
||||
* fails. The exact error code can be retrieved through
|
||||
* store->error. Returning "1" from this function will
|
||||
* allow the SSL/TLS handshake to continue as if verification
|
||||
* succeeded. Returning "1" here is not recommended.
|
||||
*/
|
||||
int myVerify(int preverify, WOLFSSL_X509_STORE_CTX* store)
|
||||
{
|
||||
(void)preverify;
|
||||
char buffer[80];
|
||||
|
||||
fnDebugMsg("In verification callback, error = \r\n");
|
||||
fnDebugDec(store->error, 0);
|
||||
fnDebugMsg(", ");
|
||||
fnDebugMsg(wolfSSL_ERR_error_string(store->error, buffer));
|
||||
fnDebugMsg("\r\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ------------------------------- APP TASK -------------------------------- */
|
||||
|
||||
|
||||
/*
|
||||
* wolfSSL client app task
|
||||
*/
|
||||
extern void fnTLSClientTask(TTASKTABLE *ptrTaskTable)
|
||||
{
|
||||
int ret, errorCode, msgSz = 0;
|
||||
char msg[64];
|
||||
char reply[1024];
|
||||
|
||||
/* run crypto tests */
|
||||
if (clientState == clientCryptoTest)
|
||||
{
|
||||
fnDebugMsg("Starting wolfSSL Client Task\r\n");
|
||||
|
||||
ret = WolfCryptTest();
|
||||
if (ret == 0) {
|
||||
fnDebugMsg("status: wolfCrypt Tests Passed!\r\n\r\n");
|
||||
clientState = clientInit;
|
||||
}
|
||||
else {
|
||||
fnDebugMsg("ERROR: wolfCrypt Tests Failed!\r\n\r\n");
|
||||
clientState = clientIdle;
|
||||
}
|
||||
}
|
||||
|
||||
/* init socket and app state */
|
||||
if (clientState == clientInit)
|
||||
{
|
||||
/* create socket */
|
||||
client_socket = fnGetTCP_Socket(TOS_MINIMISE_DELAY,
|
||||
TCP_DEFAULT_TIMEOUT,
|
||||
fnClientListener);
|
||||
if (client_socket >= 0) {
|
||||
fnDebugMsg("status: Created socket\r\n");
|
||||
clientState = clientConnecting;
|
||||
}
|
||||
}
|
||||
|
||||
/* connect socket */
|
||||
if (clientState == clientConnecting)
|
||||
{
|
||||
ret = fnTCP_Connect(client_socket, ucRemoteIP,
|
||||
uiRemotePort, 0, 0);
|
||||
|
||||
if (ret != client_socket) {
|
||||
fnDebugMsg("ERROR: fnTCP_Connect() failed\r\n");
|
||||
clientState = clientIdle;
|
||||
}
|
||||
else {
|
||||
fnDebugMsg("status: Socket connected\r\n");
|
||||
clientState = clientTLSInit;
|
||||
}
|
||||
}
|
||||
|
||||
/* set up SSL/TLS context */
|
||||
if (clientState == clientTLSInit)
|
||||
{
|
||||
/* for debug, compile wolfSSL with DEBUG_WOLFSSL defined */
|
||||
/* wolfSSL_Debugging_ON(); */
|
||||
|
||||
wolfSSL_Init();
|
||||
|
||||
/* create wolfSSL context */
|
||||
sslCtx = wolfSSL_CTX_new(wolfTLSv1_2_client_method());
|
||||
if (sslCtx == NULL) {
|
||||
fnDebugMsg("ERROR: wolfSSL_CTX_new() failed\r\n");
|
||||
clientState = clientShutdown;
|
||||
}
|
||||
else {
|
||||
fnDebugMsg("status: Created WOLFSSL_CTX\r\n");
|
||||
}
|
||||
|
||||
/* turn on peer verification, register callback */
|
||||
wolfSSL_CTX_set_verify(sslCtx, SSL_VERIFY_PEER, myVerify);
|
||||
fnDebugMsg("status: Enabled peer verification\r\n");
|
||||
|
||||
/* load root CA certificate to verify peer */
|
||||
ret = wolfSSL_CTX_load_verify_buffer(sslCtx, digicert_ca_2048,
|
||||
sizeof(digicert_ca_2048),
|
||||
SSL_FILETYPE_ASN1);
|
||||
if (ret != SSL_SUCCESS) {
|
||||
fnDebugMsg("ERROR: wolfSSL_CTX_load_verify_buffer\r\n");
|
||||
clientState = clientShutdown;
|
||||
}
|
||||
else {
|
||||
fnDebugMsg("status: Loaded trusted CA certificates\r\n");
|
||||
}
|
||||
|
||||
/* set up wolfSSL send/recv context details */
|
||||
sendCtx.socket = &client_socket;
|
||||
sendCtx.message = &stMessage;
|
||||
sendCtx.ackd = 0;
|
||||
sendCtx.dataLen = 0;
|
||||
sendCtx.flags = 0;
|
||||
recvCtx.socket = &client_socket;
|
||||
recvCtx.buffer = ucRecvBuffer;
|
||||
recvCtx.bufLen = sizeof(ucRecvBuffer);
|
||||
|
||||
/* register wolfSSL send/recv callbacks */
|
||||
wolfSSL_SetIOSend(sslCtx, UTasker_Send);
|
||||
wolfSSL_SetIORecv(sslCtx, UTasker_Receive);
|
||||
|
||||
/* create wolfSSL session */
|
||||
ssl = wolfSSL_new(sslCtx);
|
||||
if (ssl == NULL) {
|
||||
fnDebugMsg("ERROR: wolfSSL_new\r\n");
|
||||
clientState = clientShutdown;
|
||||
}
|
||||
else {
|
||||
fnDebugMsg("status: Created WOLFSSL session object\r\n");
|
||||
}
|
||||
|
||||
/* register wolfSSL read/write callback contexts */
|
||||
wolfSSL_SetIOReadCtx(ssl, &recvCtx);
|
||||
wolfSSL_SetIOWriteCtx(ssl, &sendCtx);
|
||||
|
||||
clientState = clientTLSConnect;
|
||||
}
|
||||
|
||||
/* perform SSL/TLS handshake with peer */
|
||||
if (clientState == clientTLSConnect)
|
||||
{
|
||||
ret = wolfSSL_connect(ssl);
|
||||
errorCode = wolfSSL_get_error(ssl, ret);
|
||||
if (ret != SSL_SUCCESS && (errorCode != SSL_ERROR_WANT_READ &&
|
||||
errorCode != SSL_ERROR_WANT_WRITE)) {
|
||||
fnDebugMsg("ERROR: wolfSSL_connect: ");
|
||||
errorCode = wolfSSL_get_error(ssl, ret);
|
||||
fnDebugDec(errorCode, DISPLAY_NEGATIVE);
|
||||
fnDebugMsg("\r\n");
|
||||
clientState = clientShutdown;
|
||||
}
|
||||
else if (ret == SSL_SUCCESS) {
|
||||
fnDebugMsg("wolfSSL_connect() ok, sending GET...\r\n");
|
||||
clientState = clientTLSSend;
|
||||
}
|
||||
}
|
||||
|
||||
/* send HTTP GET over SSL/TLS */
|
||||
if (clientState == clientTLSSend)
|
||||
{
|
||||
msgSz = 28;
|
||||
strncpy(msg, "GET /index.html HTTP/1.0\r\n\r\n", msgSz);
|
||||
ret = wolfSSL_write(ssl, msg, msgSz);
|
||||
errorCode = wolfSSL_get_error(ssl, ret);
|
||||
if (errorCode != SSL_ERROR_WANT_WRITE) {
|
||||
if (ret != msgSz) {
|
||||
fnDebugMsg("ERROR: wolfSSL_write() failed: ");
|
||||
errorCode = wolfSSL_get_error(ssl, ret);
|
||||
fnDebugDec(errorCode, DISPLAY_NEGATIVE);
|
||||
fnDebugMsg("\r\n");
|
||||
clientState = clientShutdown;
|
||||
}
|
||||
else {
|
||||
clientState = clientTLSRecv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* read server response */
|
||||
if (clientState == clientTLSRecv)
|
||||
{
|
||||
ret = wolfSSL_read(ssl, reply, sizeof(reply) - 1);
|
||||
errorCode = wolfSSL_get_error(ssl, ret);
|
||||
if (errorCode != SSL_ERROR_WANT_READ) {
|
||||
if (ret > 0) {
|
||||
fnDebugMsg("Server response: ");
|
||||
reply[ret] = 0;
|
||||
fnDebugMsg(reply);
|
||||
fnDebugMsg("\r\n");
|
||||
}
|
||||
else if (ret < 0) {
|
||||
fnDebugMsg("ERROR: wolfSSL_read() failed: ");
|
||||
errorCode = wolfSSL_get_error(ssl, ret);
|
||||
fnDebugDec(errorCode, DISPLAY_NEGATIVE);
|
||||
fnDebugMsg("\r\n");
|
||||
}
|
||||
clientState = clientShutdown;
|
||||
}
|
||||
}
|
||||
|
||||
/* free resources and shutdown */
|
||||
if (clientState == clientShutdown)
|
||||
{
|
||||
fnReleaseTCP_Socket(client_socket);
|
||||
wolfSSL_free(ssl);
|
||||
wolfSSL_CTX_free(sslCtx);
|
||||
wolfSSL_Cleanup();
|
||||
|
||||
fnDebugMsg("status: Released Resources\r\n");
|
||||
|
||||
clientState = clientIdle;
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------- wolfCrypt CRYPTO TESTS ------------------------ */
|
||||
|
||||
|
||||
int WolfCryptTest(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#if !defined(NO_BIG_INT)
|
||||
if (CheckCtcSettings() != 1) {
|
||||
fnDebugMsg("ERROR: Build vs runtime math mismatch\r\n");
|
||||
}
|
||||
|
||||
#ifdef USE_FAST_MATH
|
||||
if (CheckFastMathSettings() != 1) {
|
||||
fnDebugMsg("ERROR: Build vs runtime fastmath FP_MAX_BITS \
|
||||
mismatch\r\n");
|
||||
clientState = clientIdle;
|
||||
}
|
||||
#endif /* USE_FAST_MATH */
|
||||
#endif /* NO_BIG_INT */
|
||||
|
||||
#ifndef NO_MD5
|
||||
if ((ret = md5_test()) != 0)
|
||||
fnDebugMsg("MD5 test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("MD5 test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_MD2
|
||||
if ((ret = md2_test()) != 0)
|
||||
fnDebugMsg("MD2 test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("MD2 test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifndef NO_MD4
|
||||
if ((ret = md4_test()) != 0)
|
||||
fnDebugMsg("MD4 test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("MD4 test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifndef NO_SHA
|
||||
if ((ret = sha_test()) != 0)
|
||||
fnDebugMsg("SHA test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("SHA test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifndef NO_SHA256
|
||||
if ((ret = sha256_test()) != 0)
|
||||
fnDebugMsg("SHA-256 test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("SHA-256 test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_SHA384
|
||||
if ((ret = sha384_test()) != 0)
|
||||
fnDebugMsg("SHA-384 test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("SHA-384 test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_SHA512
|
||||
if ((ret = sha512_test()) != 0)
|
||||
fnDebugMsg("SHA-512 test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("SHA-512 test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_RIPEMD
|
||||
if ((ret = ripemd_test()) != 0)
|
||||
fnDebugMsg("RIPEMD test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("RIPEMD test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BLAKE2
|
||||
if ((ret = blake2b_test()) != 0)
|
||||
fnDebugMsg("BLAKE2b test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("BLAKE2b test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifndef NO_HMAC
|
||||
#ifndef NO_MD5
|
||||
if ((ret = hmac_md5_test()) != 0)
|
||||
fnDebugMsg("HMAC-MD5 test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("HMAC-MD5 test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifndef NO_SHA
|
||||
if ((ret = hmac_sha_test()) != 0)
|
||||
fnDebugMsg("HMAC-SHA test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("HMAC-SHA test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifndef NO_SHA256
|
||||
if ((ret = hmac_sha256_test()) != 0)
|
||||
fnDebugMsg("HMAC-SHA256 test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("HMAC-SHA256 test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_SHA384
|
||||
if ((ret = hmac_sha384_test()) != 0)
|
||||
fnDebugMsg("HMAC-SHA384 test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("HMAC-SHA384 test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_SHA512
|
||||
if ((ret = hmac_sha512_test()) != 0)
|
||||
fnDebugMsg("HMAC-SHA512 test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("HMAC-SHA512 test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BLAKE2
|
||||
if ((ret = hmac_blake2b_test()) != 0)
|
||||
fnDebugMsg("HMAC-BLAKE2 test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("HMAC-BLAKE2 test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_HKDF
|
||||
if ((ret = hkdf_test()) != 0)
|
||||
fnDebugMsg("HMAC-KDF test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("HMAC-KDF test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AESGCM
|
||||
if ((ret = gmac_test()) != 0)
|
||||
fnDebugMsg("GMAC test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("GMAC test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifndef NO_RC4
|
||||
if ((ret = arc4_test()) != 0)
|
||||
fnDebugMsg("ARC4 test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("ARC4 test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifndef NO_HC128
|
||||
if ((ret = hc128_test()) != 0)
|
||||
fnDebugMsg("HC-128 test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("HC-128 test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifndef NO_RABBIT
|
||||
if ((ret = rabbit_test()) != 0)
|
||||
fnDebugMsg("Rabbit test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("Rabbit test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHACHA
|
||||
if ((ret = chacha_test()) != 0)
|
||||
fnDebugMsg("Chacha test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("Chacha test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_POLY1305
|
||||
if ((ret = poly1305_test()) != 0)
|
||||
fnDebugMsg("POLY1305 test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("POLY1305 test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_CHACHA) && defined(HAVE_POLY1305)
|
||||
if ((ret = chacha20_poly1305_aead_test()) != 0)
|
||||
fnDebugMsg("ChaCha20-Poly1305 AEAD test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("ChaCha20-Poly1305 AEAD test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifndef NO_DES3
|
||||
if ((ret = des_test()) != 0)
|
||||
fnDebugMsg("DES test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("DES test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifndef NO_DES3
|
||||
if ((ret = des3_test()) != 0)
|
||||
fnDebugMsg("DES3 test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("DES3 test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifndef NO_AES
|
||||
if ((ret = aes_test()) != 0)
|
||||
fnDebugMsg("AES test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("AES test passed!\r\n");
|
||||
|
||||
#ifdef HAVE_AESGCM
|
||||
if ((ret = aesgcm_test()) != 0)
|
||||
fnDebugMsg("AES-GCM test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("AES-GCM test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AESCCM
|
||||
if ((ret = aesccm_test()) != 0)
|
||||
fnDebugMsg("AES-CCM test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("AES-CCM test passed!\r\n");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CAMELLIA
|
||||
if ((ret = camellia_test()) != 0)
|
||||
fnDebugMsg("CAMELLIA test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("CAMELLIA test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IDEA
|
||||
if ((ret = idea_test()) != 0)
|
||||
fnDebugMsg("IDEA test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("IDEA test passed!\r\n");
|
||||
#endif
|
||||
|
||||
if ((ret = random_test()) != 0)
|
||||
fnDebugMsg("RANDOM test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("RANDOM test passed!\r\n");
|
||||
|
||||
#ifndef NO_RSA
|
||||
if ((ret = rsa_test()) != 0)
|
||||
fnDebugMsg("RSA test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("RSA test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#if defined(WOLFSSL_CERT_EXT) && defined(WOLFSSL_TEST_CERT)
|
||||
if ((ret = certext_test()) != 0)
|
||||
fnDebugMsg("CERT EXT test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("CERT EXT test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifndef NO_DH
|
||||
if ((ret = dh_test()) != 0)
|
||||
fnDebugMsg("DH test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("DH test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifndef NO_DSA
|
||||
if ((ret = dsa_test()) != 0)
|
||||
fnDebugMsg("DSA test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("DSA test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef WOLFCRYPT_HAVE_SRP
|
||||
if ((ret = srp_test()) != 0)
|
||||
fnDebugMsg("SRP test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("SRP test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifndef NO_PWDBASED
|
||||
if ((ret = pwdbased_test()) != 0)
|
||||
fnDebugMsg("PWDBASED test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("PWDBASED test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef OPENSSL_EXTRA
|
||||
if ((ret = openssl_test()) != 0)
|
||||
fnDebugMsg("OPENSSL test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("OPENSSL test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ECC
|
||||
if ((ret = ecc_test()) != 0)
|
||||
fnDebugMsg("ECC test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("ECC test passed!\r\n");
|
||||
#ifdef HAVE_ECC_ENCRYPT
|
||||
if ((ret = ecc_encrypt_test()) != 0)
|
||||
fnDebugMsg("ECC Enc test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("ECC Enc test passed!\r\n");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CURVE25519
|
||||
if ((ret = curve25519_test()) != 0)
|
||||
fnDebugMsg("CURVE25519 test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("CURVE25519 test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ED25519
|
||||
if ((ret = ed25519_test()) != 0)
|
||||
fnDebugMsg("ED25519 test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("ED25519 test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
if ((ret = compress_test()) != 0)
|
||||
fnDebugMsg("COMPRESS test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("COMPRESS test passed!\r\n");
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PKCS7
|
||||
if ((ret = pkcs7enveloped_test()) != 0)
|
||||
fnDebugMsg("PKCS7enveloped test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("PKCS7enveloped test passed!\r\n");
|
||||
|
||||
if ((ret = pkcs7signed_test()) != 0)
|
||||
fnDebugMsg("PKCS7signed test failed!\r\n");
|
||||
else
|
||||
fnDebugMsg("PKCS7signed test passed!\r\n");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,187 @@
|
|||
/****************************************************************************
|
||||
File Name : wolfSSLClientTask.h
|
||||
Author : wolfSSL Inc.
|
||||
Date Created : March 25, 2016
|
||||
Current Revision : 1.0
|
||||
Notes : Header file for wolfSSLClientTask.c
|
||||
|
||||
Copyright (C) wolfSSL, Inc. 2016
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "wolfssl/wolfcrypt/settings.h"
|
||||
|
||||
/* CA certificate to verify example.com:443 */
|
||||
static const unsigned char digicert_ca_2048[] =
|
||||
{
|
||||
0x30, 0x82, 0x03, 0xC5, 0x30, 0x82, 0x02, 0xAD, 0xA0, 0x03,
|
||||
0x02, 0x01, 0x02, 0x02, 0x10, 0x02, 0xAC, 0x5C, 0x26, 0x6A,
|
||||
0x0B, 0x40, 0x9B, 0x8F, 0x0B, 0x79, 0xF2, 0xAE, 0x46, 0x25,
|
||||
0x77, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7,
|
||||
0x0D, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x6C, 0x31, 0x0B,
|
||||
0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55,
|
||||
0x53, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55, 0x04, 0x0A,
|
||||
0x13, 0x0C, 0x44, 0x69, 0x67, 0x69, 0x43, 0x65, 0x72, 0x74,
|
||||
0x20, 0x49, 0x6E, 0x63, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03,
|
||||
0x55, 0x04, 0x0B, 0x13, 0x10, 0x77, 0x77, 0x77, 0x2E, 0x64,
|
||||
0x69, 0x67, 0x69, 0x63, 0x65, 0x72, 0x74, 0x2E, 0x63, 0x6F,
|
||||
0x6D, 0x31, 0x2B, 0x30, 0x29, 0x06, 0x03, 0x55, 0x04, 0x03,
|
||||
0x13, 0x22, 0x44, 0x69, 0x67, 0x69, 0x43, 0x65, 0x72, 0x74,
|
||||
0x20, 0x48, 0x69, 0x67, 0x68, 0x20, 0x41, 0x73, 0x73, 0x75,
|
||||
0x72, 0x61, 0x6E, 0x63, 0x65, 0x20, 0x45, 0x56, 0x20, 0x52,
|
||||
0x6F, 0x6F, 0x74, 0x20, 0x43, 0x41, 0x30, 0x1E, 0x17, 0x0D,
|
||||
0x30, 0x36, 0x31, 0x31, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30,
|
||||
0x30, 0x30, 0x5A, 0x17, 0x0D, 0x33, 0x31, 0x31, 0x31, 0x31,
|
||||
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5A, 0x30, 0x6C,
|
||||
0x31, 0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13,
|
||||
0x02, 0x55, 0x53, 0x31, 0x15, 0x30, 0x13, 0x06, 0x03, 0x55,
|
||||
0x04, 0x0A, 0x13, 0x0C, 0x44, 0x69, 0x67, 0x69, 0x43, 0x65,
|
||||
0x72, 0x74, 0x20, 0x49, 0x6E, 0x63, 0x31, 0x19, 0x30, 0x17,
|
||||
0x06, 0x03, 0x55, 0x04, 0x0B, 0x13, 0x10, 0x77, 0x77, 0x77,
|
||||
0x2E, 0x64, 0x69, 0x67, 0x69, 0x63, 0x65, 0x72, 0x74, 0x2E,
|
||||
0x63, 0x6F, 0x6D, 0x31, 0x2B, 0x30, 0x29, 0x06, 0x03, 0x55,
|
||||
0x04, 0x03, 0x13, 0x22, 0x44, 0x69, 0x67, 0x69, 0x43, 0x65,
|
||||
0x72, 0x74, 0x20, 0x48, 0x69, 0x67, 0x68, 0x20, 0x41, 0x73,
|
||||
0x73, 0x75, 0x72, 0x61, 0x6E, 0x63, 0x65, 0x20, 0x45, 0x56,
|
||||
0x20, 0x52, 0x6F, 0x6F, 0x74, 0x20, 0x43, 0x41, 0x30, 0x82,
|
||||
0x01, 0x22, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86,
|
||||
0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x01,
|
||||
0x0F, 0x00, 0x30, 0x82, 0x01, 0x0A, 0x02, 0x82, 0x01, 0x01,
|
||||
0x00, 0xC6, 0xCC, 0xE5, 0x73, 0xE6, 0xFB, 0xD4, 0xBB, 0xE5,
|
||||
0x2D, 0x2D, 0x32, 0xA6, 0xDF, 0xE5, 0x81, 0x3F, 0xC9, 0xCD,
|
||||
0x25, 0x49, 0xB6, 0x71, 0x2A, 0xC3, 0xD5, 0x94, 0x34, 0x67,
|
||||
0xA2, 0x0A, 0x1C, 0xB0, 0x5F, 0x69, 0xA6, 0x40, 0xB1, 0xC4,
|
||||
0xB7, 0xB2, 0x8F, 0xD0, 0x98, 0xA4, 0xA9, 0x41, 0x59, 0x3A,
|
||||
0xD3, 0xDC, 0x94, 0xD6, 0x3C, 0xDB, 0x74, 0x38, 0xA4, 0x4A,
|
||||
0xCC, 0x4D, 0x25, 0x82, 0xF7, 0x4A, 0xA5, 0x53, 0x12, 0x38,
|
||||
0xEE, 0xF3, 0x49, 0x6D, 0x71, 0x91, 0x7E, 0x63, 0xB6, 0xAB,
|
||||
0xA6, 0x5F, 0xC3, 0xA4, 0x84, 0xF8, 0x4F, 0x62, 0x51, 0xBE,
|
||||
0xF8, 0xC5, 0xEC, 0xDB, 0x38, 0x92, 0xE3, 0x06, 0xE5, 0x08,
|
||||
0x91, 0x0C, 0xC4, 0x28, 0x41, 0x55, 0xFB, 0xCB, 0x5A, 0x89,
|
||||
0x15, 0x7E, 0x71, 0xE8, 0x35, 0xBF, 0x4D, 0x72, 0x09, 0x3D,
|
||||
0xBE, 0x3A, 0x38, 0x50, 0x5B, 0x77, 0x31, 0x1B, 0x8D, 0xB3,
|
||||
0xC7, 0x24, 0x45, 0x9A, 0xA7, 0xAC, 0x6D, 0x00, 0x14, 0x5A,
|
||||
0x04, 0xB7, 0xBA, 0x13, 0xEB, 0x51, 0x0A, 0x98, 0x41, 0x41,
|
||||
0x22, 0x4E, 0x65, 0x61, 0x87, 0x81, 0x41, 0x50, 0xA6, 0x79,
|
||||
0x5C, 0x89, 0xDE, 0x19, 0x4A, 0x57, 0xD5, 0x2E, 0xE6, 0x5D,
|
||||
0x1C, 0x53, 0x2C, 0x7E, 0x98, 0xCD, 0x1A, 0x06, 0x16, 0xA4,
|
||||
0x68, 0x73, 0xD0, 0x34, 0x04, 0x13, 0x5C, 0xA1, 0x71, 0xD3,
|
||||
0x5A, 0x7C, 0x55, 0xDB, 0x5E, 0x64, 0xE1, 0x37, 0x87, 0x30,
|
||||
0x56, 0x04, 0xE5, 0x11, 0xB4, 0x29, 0x80, 0x12, 0xF1, 0x79,
|
||||
0x39, 0x88, 0xA2, 0x02, 0x11, 0x7C, 0x27, 0x66, 0xB7, 0x88,
|
||||
0xB7, 0x78, 0xF2, 0xCA, 0x0A, 0xA8, 0x38, 0xAB, 0x0A, 0x64,
|
||||
0xC2, 0xBF, 0x66, 0x5D, 0x95, 0x84, 0xC1, 0xA1, 0x25, 0x1E,
|
||||
0x87, 0x5D, 0x1A, 0x50, 0x0B, 0x20, 0x12, 0xCC, 0x41, 0xBB,
|
||||
0x6E, 0x0B, 0x51, 0x38, 0xB8, 0x4B, 0xCB, 0x02, 0x03, 0x01,
|
||||
0x00, 0x01, 0xA3, 0x63, 0x30, 0x61, 0x30, 0x0E, 0x06, 0x03,
|
||||
0x55, 0x1D, 0x0F, 0x01, 0x01, 0xFF, 0x04, 0x04, 0x03, 0x02,
|
||||
0x01, 0x86, 0x30, 0x0F, 0x06, 0x03, 0x55, 0x1D, 0x13, 0x01,
|
||||
0x01, 0xFF, 0x04, 0x05, 0x30, 0x03, 0x01, 0x01, 0xFF, 0x30,
|
||||
0x1D, 0x06, 0x03, 0x55, 0x1D, 0x0E, 0x04, 0x16, 0x04, 0x14,
|
||||
0xB1, 0x3E, 0xC3, 0x69, 0x03, 0xF8, 0xBF, 0x47, 0x01, 0xD4,
|
||||
0x98, 0x26, 0x1A, 0x08, 0x02, 0xEF, 0x63, 0x64, 0x2B, 0xC3,
|
||||
0x30, 0x1F, 0x06, 0x03, 0x55, 0x1D, 0x23, 0x04, 0x18, 0x30,
|
||||
0x16, 0x80, 0x14, 0xB1, 0x3E, 0xC3, 0x69, 0x03, 0xF8, 0xBF,
|
||||
0x47, 0x01, 0xD4, 0x98, 0x26, 0x1A, 0x08, 0x02, 0xEF, 0x63,
|
||||
0x64, 0x2B, 0xC3, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48,
|
||||
0x86, 0xF7, 0x0D, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x82,
|
||||
0x01, 0x01, 0x00, 0x1C, 0x1A, 0x06, 0x97, 0xDC, 0xD7, 0x9C,
|
||||
0x9F, 0x3C, 0x88, 0x66, 0x06, 0x08, 0x57, 0x21, 0xDB, 0x21,
|
||||
0x47, 0xF8, 0x2A, 0x67, 0xAA, 0xBF, 0x18, 0x32, 0x76, 0x40,
|
||||
0x10, 0x57, 0xC1, 0x8A, 0xF3, 0x7A, 0xD9, 0x11, 0x65, 0x8E,
|
||||
0x35, 0xFA, 0x9E, 0xFC, 0x45, 0xB5, 0x9E, 0xD9, 0x4C, 0x31,
|
||||
0x4B, 0xB8, 0x91, 0xE8, 0x43, 0x2C, 0x8E, 0xB3, 0x78, 0xCE,
|
||||
0xDB, 0xE3, 0x53, 0x79, 0x71, 0xD6, 0xE5, 0x21, 0x94, 0x01,
|
||||
0xDA, 0x55, 0x87, 0x9A, 0x24, 0x64, 0xF6, 0x8A, 0x66, 0xCC,
|
||||
0xDE, 0x9C, 0x37, 0xCD, 0xA8, 0x34, 0xB1, 0x69, 0x9B, 0x23,
|
||||
0xC8, 0x9E, 0x78, 0x22, 0x2B, 0x70, 0x43, 0xE3, 0x55, 0x47,
|
||||
0x31, 0x61, 0x19, 0xEF, 0x58, 0xC5, 0x85, 0x2F, 0x4E, 0x30,
|
||||
0xF6, 0xA0, 0x31, 0x16, 0x23, 0xC8, 0xE7, 0xE2, 0x65, 0x16,
|
||||
0x33, 0xCB, 0xBF, 0x1A, 0x1B, 0xA0, 0x3D, 0xF8, 0xCA, 0x5E,
|
||||
0x8B, 0x31, 0x8B, 0x60, 0x08, 0x89, 0x2D, 0x0C, 0x06, 0x5C,
|
||||
0x52, 0xB7, 0xC4, 0xF9, 0x0A, 0x98, 0xD1, 0x15, 0x5F, 0x9F,
|
||||
0x12, 0xBE, 0x7C, 0x36, 0x63, 0x38, 0xBD, 0x44, 0xA4, 0x7F,
|
||||
0xE4, 0x26, 0x2B, 0x0A, 0xC4, 0x97, 0x69, 0x0D, 0xE9, 0x8C,
|
||||
0xE2, 0xC0, 0x10, 0x57, 0xB8, 0xC8, 0x76, 0x12, 0x91, 0x55,
|
||||
0xF2, 0x48, 0x69, 0xD8, 0xBC, 0x2A, 0x02, 0x5B, 0x0F, 0x44,
|
||||
0xD4, 0x20, 0x31, 0xDB, 0xF4, 0xBA, 0x70, 0x26, 0x5D, 0x90,
|
||||
0x60, 0x9E, 0xBC, 0x4B, 0x17, 0x09, 0x2F, 0xB4, 0xCB, 0x1E,
|
||||
0x43, 0x68, 0xC9, 0x07, 0x27, 0xC1, 0xD2, 0x5C, 0xF7, 0xEA,
|
||||
0x21, 0xB9, 0x68, 0x12, 0x9C, 0x3C, 0x9C, 0xBF, 0x9E, 0xFC,
|
||||
0x80, 0x5C, 0x9B, 0x63, 0xCD, 0xEC, 0x47, 0xAA, 0x25, 0x27,
|
||||
0x67, 0xA0, 0x37, 0xF3, 0x00, 0x82, 0x7D, 0x54, 0xD7, 0xA9,
|
||||
0xF8, 0xE9, 0x2E, 0x13, 0xA3, 0x77, 0xE8, 0x1F, 0x4A
|
||||
};
|
||||
|
||||
/* function prototypes */
|
||||
|
||||
int WolfCryptTest(void);
|
||||
|
||||
int md2_test(void);
|
||||
int md5_test(void);
|
||||
int md4_test(void);
|
||||
int sha_test(void);
|
||||
int sha256_test(void);
|
||||
int sha512_test(void);
|
||||
int sha384_test(void);
|
||||
int hmac_md5_test(void);
|
||||
int hmac_sha_test(void);
|
||||
int hmac_sha256_test(void);
|
||||
int hmac_sha384_test(void);
|
||||
int hmac_sha512_test(void);
|
||||
int hmac_blake2b_test(void);
|
||||
int hkdf_test(void);
|
||||
int arc4_test(void);
|
||||
int hc128_test(void);
|
||||
int rabbit_test(void);
|
||||
int chacha_test(void);
|
||||
int chacha20_poly1305_aead_test(void);
|
||||
int des_test(void);
|
||||
int des3_test(void);
|
||||
int aes_test(void);
|
||||
int poly1305_test(void);
|
||||
int aesgcm_test(void);
|
||||
int gmac_test(void);
|
||||
int aesccm_test(void);
|
||||
int camellia_test(void);
|
||||
int rsa_test(void);
|
||||
int dh_test(void);
|
||||
int dsa_test(void);
|
||||
int srp_test(void);
|
||||
int random_test(void);
|
||||
int pwdbased_test(void);
|
||||
int ripemd_test(void);
|
||||
int openssl_test(void); /* test mini api */
|
||||
int pbkdf1_test(void);
|
||||
int pkcs12_test(void);
|
||||
int pbkdf2_test(void);
|
||||
#ifdef HAVE_ECC
|
||||
int ecc_test(void);
|
||||
#ifdef HAVE_ECC_ENCRYPT
|
||||
int ecc_encrypt_test(void);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef HAVE_CURVE25519
|
||||
int curve25519_test(void);
|
||||
#endif
|
||||
#ifdef HAVE_ED25519
|
||||
int ed25519_test(void);
|
||||
#endif
|
||||
#ifdef HAVE_BLAKE2
|
||||
int blake2b_test(void);
|
||||
#endif
|
||||
#ifdef HAVE_LIBZ
|
||||
int compress_test(void);
|
||||
#endif
|
||||
#ifdef HAVE_PKCS7
|
||||
int pkcs7enveloped_test(void);
|
||||
int pkcs7signed_test(void);
|
||||
#endif
|
||||
#if defined(WOLFSSL_CERT_EXT) && defined(WOLFSSL_TEST_CERT)
|
||||
int certext_test(void);
|
||||
#endif
|
||||
#ifdef HAVE_IDEA
|
||||
int idea_test(void);
|
||||
#endif
|
||||
|
|
@ -0,0 +1,385 @@
|
|||
/****************************************************************************
|
||||
File Name : wolfSSLServerTask.c
|
||||
Author : wolfSSL Inc.
|
||||
Date Created : March 25, 2016
|
||||
Current Revision : 1.0
|
||||
Notes : This file contains a simple TLS server task with the goal
|
||||
of demonstrating how the wolfSSL embedded SSL/TLS library
|
||||
can be used with the uTasker stack. This server creates
|
||||
a TCP socket, sets the socket to listening mode, and
|
||||
when a connection is received negotiates an SSL/TLS
|
||||
session with the peer. It expects the peer to send a
|
||||
simple message (ex: 'hello wolfssl!'), sends a
|
||||
simple message back in return ('I hear you fa shizzle!'),
|
||||
closes the session and socket, then loops back around to
|
||||
listen for another connection.
|
||||
|
||||
Copyright (C) wolfSSL, Inc. 2016
|
||||
*****************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
#include "wolfSSLServerTask.h"
|
||||
#include "wolfssl/wolfcrypt/settings.h"
|
||||
#include "wolfssl/wolfcrypt/aes.h"
|
||||
#include "wolfssl/wolfcrypt/rsa.h"
|
||||
#include "wolfssl/ssl.h"
|
||||
|
||||
#define TEST_BUFFER_LENGTH 100
|
||||
#define MAX_TCP_LENGTH 1460
|
||||
#define RECV_BUFFER_LENGTH 1500
|
||||
|
||||
/* ---------------------------- STRUCTS / ENUMS ---------------------------- */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
serverInit = 0,
|
||||
serverSocketSetup = 1,
|
||||
serverIdle = 2,
|
||||
serverListening = 3,
|
||||
serverTLSInit = 4,
|
||||
serverTLSNew = 5,
|
||||
serverTLSAccept = 6,
|
||||
serverTLSSend = 7,
|
||||
serverTLSRecv = 8,
|
||||
serverShutdown = 9,
|
||||
} serverStates;
|
||||
|
||||
|
||||
/* func_args from wolfCrypt test.h, so don't have to pull in other stuff */
|
||||
typedef struct func_args {
|
||||
int argc;
|
||||
char** argv;
|
||||
int return_code;
|
||||
} func_args;
|
||||
|
||||
|
||||
typedef struct stTCP_MESSAGE
|
||||
{
|
||||
TCP_HEADER tTCP_Header;
|
||||
unsigned char ucTCP_Message[MAX_TCP_LENGTH];
|
||||
} TCP_MESSAGE;
|
||||
|
||||
|
||||
/* wolfSSL send callback context struct */
|
||||
typedef struct stUTASKER_SENDCTX {
|
||||
TCP_MESSAGE* message; /* TCP frame to send */
|
||||
USOCKET* socket; /* socket pointer */
|
||||
unsigned int dataLen; /* length of data in message frame */
|
||||
unsigned char ackd; /* has ACK been received for data (0:1) */
|
||||
unsigned char flags; /* socket flags, ie: TCP_FLAG_PUSH */
|
||||
} UTASKER_SENDCTX;
|
||||
|
||||
|
||||
/* wolfSSL recv callback context struct */
|
||||
typedef struct stUTASKER_RECVCTX {
|
||||
USOCKET* socket; /* socket pointer */
|
||||
unsigned int used; /* bytes used in buffer */
|
||||
unsigned int offset; /* current offset in buffer, for processing */
|
||||
unsigned int bufLen; /* total size of buffer in bytes */
|
||||
unsigned char* buffer; /* recv data buffer */
|
||||
} UTASKER_RECVCTX;
|
||||
|
||||
/* ------------------------------- VARIABLES ------------------------------- */
|
||||
|
||||
static USOCKET server_socket = 0; /* server socket */
|
||||
static TCP_MESSAGE stMessage; /* structure to hold TCP frame */
|
||||
static UTASKER_SENDCTX sendCtx; /* wolfSSL send callback context */
|
||||
static UTASKER_RECVCTX recvCtx; /* wolfSSL recv callback context */
|
||||
static unsigned char ucRecvBuffer[RECV_BUFFER_LENGTH]; /* TCP recv buffer */
|
||||
static serverStates serverState = serverInit; /* TLS task state */
|
||||
|
||||
static WOLFSSL_CTX* sslCtx; /* wolfSSL context context */
|
||||
static WOLFSSL* ssl; /* wolfSSL session object */
|
||||
|
||||
/* server port number */
|
||||
static unsigned int uiServerPort = 443;
|
||||
char input[80];
|
||||
int wantReadTimeout = 2; /* time out after 5 consecutive WANT_READ errors */
|
||||
int wantReadCounter = 0;
|
||||
|
||||
/* ------------------------------- PROTOTYPES ------------------------------ */
|
||||
|
||||
int CacheRecvBuffer(UTASKER_RECVCTX* ctx, unsigned char* data,
|
||||
unsigned short length);
|
||||
int ResetRecvBuffer(UTASKER_RECVCTX* ctx);
|
||||
int UTasker_Receive(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
||||
int UTasker_Send(WOLFSSL* ssl, char* buf, int sz, void* ctx);
|
||||
|
||||
/* ---------------------------- SOCKET LISTENERS --------------------------- */
|
||||
|
||||
static int fnServerListener(USOCKET Socket, unsigned char ucEvent,
|
||||
unsigned char *ucIp_Data, unsigned short usPortLen)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
switch (ucEvent)
|
||||
{
|
||||
case TCP_EVENT_CONREQ:
|
||||
case TCP_EVENT_CONNECTED:
|
||||
fnDebugMsg("status: TCP_EVENT_CONNECTED\r\n");
|
||||
serverState = serverTLSNew;
|
||||
break;
|
||||
|
||||
case TCP_EVENT_ACK:
|
||||
fnDebugMsg("status: TCP_EVENT_ACK\r\n");
|
||||
/* ACK received, set ackd variable in CTX msg */
|
||||
sendCtx.ackd = 1;
|
||||
break;
|
||||
|
||||
case TCP_EVENT_ARP_RESOLUTION_FAILED:
|
||||
fnDebugMsg("status: TCP_EVENT_ARP_RESOLUTION_FAILED\r\n");
|
||||
break;
|
||||
|
||||
case TCP_EVENT_PARTIAL_ACK:
|
||||
fnDebugMsg("status: TCP_EVENT_PARTIAL_ACK\r\n");
|
||||
break;
|
||||
|
||||
case TCP_EVENT_REGENERATE:
|
||||
/* frame lost, need to resend last frame, use cached */
|
||||
fnDebugMsg("status: TCP_EVENT_REGENERATE\r\n");
|
||||
if (sendCtx.ackd == 0) {
|
||||
ret = fnSendTCP(*sendCtx.socket,
|
||||
(unsigned char*)&sendCtx.message->tTCP_Header,
|
||||
sendCtx.dataLen, sendCtx.flags);
|
||||
if (ret > 0) {
|
||||
return APP_SENT_DATA;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TCP_EVENT_DATA:
|
||||
/* data received from client */
|
||||
fnDebugMsg("status: TCP_EVENT_DATA\r\n");
|
||||
|
||||
/* copy data into our temp context buffer */
|
||||
if (CacheRecvBuffer(&recvCtx, ucIp_Data, usPortLen) < 0) {
|
||||
return APP_REJECT_DATA;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case TCP_EVENT_ABORT:
|
||||
case TCP_EVENT_CLOSE:
|
||||
case TCP_EVENT_CLOSED:
|
||||
/* server closed connection */
|
||||
fnDebugMsg("status: TCP_EVENT_CLOSE || TCP_EVENT_CLOSED\r\n");
|
||||
serverState = serverShutdown;
|
||||
break;
|
||||
}
|
||||
return APP_ACCEPT;
|
||||
}
|
||||
|
||||
/* ------------------------------- APP TASK -------------------------------- */
|
||||
|
||||
|
||||
/*
|
||||
* wolfSSL server app task
|
||||
*/
|
||||
extern void fnTLSServerTask(TTASKTABLE *ptrTaskTable)
|
||||
{
|
||||
int ret, errorCode, msgSz = 0;
|
||||
char msg[64];
|
||||
|
||||
/* init socket and app state */
|
||||
if (serverState == serverInit)
|
||||
{
|
||||
fnDebugMsg("Starting wolfSSL Server Task\r\n");
|
||||
|
||||
/* run wolfCrypt tests */
|
||||
ret = WolfCryptTest();
|
||||
if (ret == 0) {
|
||||
fnDebugMsg("status: wolfCrypt Tests Passed!\r\n\r\n");
|
||||
serverState = serverTLSInit;
|
||||
}
|
||||
else {
|
||||
fnDebugMsg("ERROR: wolfCrypt Tests Failed!\r\n\r\n");
|
||||
serverState = serverIdle;
|
||||
}
|
||||
}
|
||||
|
||||
if (serverState == serverTLSInit)
|
||||
{
|
||||
/* for debug, compile wolfSSL with DEBUG_WOLFSSL defined */
|
||||
/* wolfSSL_Debugging_ON(); */
|
||||
|
||||
wolfSSL_Init();
|
||||
|
||||
/* create wolfSSL context */
|
||||
sslCtx = wolfSSL_CTX_new(wolfTLSv1_2_server_method());
|
||||
if (sslCtx == NULL) {
|
||||
fnDebugMsg("ERROR: wolfSSL_CTX_new() failed\r\n");
|
||||
serverState = serverShutdown;
|
||||
}
|
||||
else {
|
||||
fnDebugMsg("status: Created WOLFSSL_CTX\r\n");
|
||||
}
|
||||
|
||||
/* load server certificate */
|
||||
ret = wolfSSL_CTX_use_certificate_buffer(sslCtx, server_cert_der_2048,
|
||||
sizeof(server_cert_der_2048),
|
||||
SSL_FILETYPE_ASN1);
|
||||
if (ret != SSL_SUCCESS) {
|
||||
fnDebugMsg("ERROR: wolfSSL_CTX_use_certificate_chain_buffer\r\n");
|
||||
serverState = serverShutdown;
|
||||
}
|
||||
|
||||
/* load server private key */
|
||||
ret = wolfSSL_CTX_use_PrivateKey_buffer(sslCtx, server_key_der_2048,
|
||||
sizeof(server_key_der_2048),
|
||||
SSL_FILETYPE_ASN1);
|
||||
if (ret != SSL_SUCCESS) {
|
||||
fnDebugMsg("ERROR: wolfSSL_CTX_use_PrivateKey_buffer\r\n");
|
||||
serverState = serverShutdown;
|
||||
}
|
||||
|
||||
/* register wolfSSL send/recv callbacks */
|
||||
wolfSSL_SetIOSend(sslCtx, UTasker_Send);
|
||||
wolfSSL_SetIORecv(sslCtx, UTasker_Receive);
|
||||
|
||||
serverState = serverSocketSetup;
|
||||
}
|
||||
|
||||
/* crypto tests */
|
||||
if (serverState == serverSocketSetup)
|
||||
{
|
||||
/* create socket */
|
||||
server_socket = fnGetTCP_Socket(TOS_MINIMISE_DELAY,
|
||||
TCP_DEFAULT_TIMEOUT, fnServerListener);
|
||||
|
||||
if (server_socket >= 0) {
|
||||
|
||||
/* set socket listening */
|
||||
ret = fnTCP_Listen(server_socket, uiServerPort, 0);
|
||||
if (ret != server_socket) {
|
||||
fnDebugMsg("ERROR: fnTCP_Listen() failed\r\n");
|
||||
serverState = serverIdle;
|
||||
}
|
||||
else {
|
||||
fnDebugMsg("status: Socket listening for connection ...\r\n");
|
||||
serverState = serverListening;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (serverState == serverTLSNew)
|
||||
{
|
||||
/* create wolfSSL session */
|
||||
ssl = wolfSSL_new(sslCtx);
|
||||
if (ssl == NULL) {
|
||||
fnDebugMsg("ERROR: wolfSSL_new\r\n");
|
||||
serverState = serverShutdown;
|
||||
}
|
||||
else {
|
||||
fnDebugMsg("status: Created WOLFSSL session object\r\n");
|
||||
}
|
||||
|
||||
/* set up wolfSSL send/recv context details */
|
||||
sendCtx.socket = &server_socket;
|
||||
sendCtx.message = &stMessage;
|
||||
sendCtx.ackd = 0;
|
||||
sendCtx.dataLen = 0;
|
||||
sendCtx.flags = 0;
|
||||
recvCtx.socket = &server_socket;
|
||||
recvCtx.buffer = ucRecvBuffer;
|
||||
recvCtx.bufLen = sizeof(ucRecvBuffer);
|
||||
|
||||
/* register wolfSSL read/write callback contexts */
|
||||
wolfSSL_SetIOReadCtx(ssl, &recvCtx);
|
||||
wolfSSL_SetIOWriteCtx(ssl, &sendCtx);
|
||||
|
||||
serverState = serverTLSAccept;
|
||||
}
|
||||
|
||||
/* perform SSL/TLS handshake with peer */
|
||||
if (serverState == serverTLSAccept)
|
||||
{
|
||||
ret = wolfSSL_accept(ssl);
|
||||
errorCode = wolfSSL_get_error(ssl, ret);
|
||||
if (ret != SSL_SUCCESS && (errorCode != SSL_ERROR_WANT_READ &&
|
||||
errorCode != SSL_ERROR_WANT_WRITE)) {
|
||||
fnDebugMsg("ERROR: wolfSSL_accept: ");
|
||||
errorCode = wolfSSL_get_error(ssl, ret);
|
||||
fnDebugDec(errorCode, DISPLAY_NEGATIVE);
|
||||
fnDebugMsg("\r\n");
|
||||
serverState = serverShutdown;
|
||||
}
|
||||
else if (ret == SSL_SUCCESS) {
|
||||
fnDebugMsg("wolfSSL_accept() finished\r\n");
|
||||
fnDebugMsg("Client message: \r\n");
|
||||
serverState = serverTLSRecv;
|
||||
}
|
||||
}
|
||||
|
||||
/* read client message over SSL/TLS */
|
||||
if (serverState == serverTLSRecv)
|
||||
{
|
||||
ret = wolfSSL_read(ssl, input, sizeof(input)-1);
|
||||
if (ret > 0) {
|
||||
input[ret] = 0;
|
||||
fnDebugMsg(input);
|
||||
fnDebugMsg("\r\n");
|
||||
wantReadCounter = 0;
|
||||
}
|
||||
else if (ret < 0) {
|
||||
errorCode = wolfSSL_get_error(ssl, ret);
|
||||
if (errorCode == SSL_ERROR_WANT_READ && recvCtx.used == 0)
|
||||
{
|
||||
/* for simplicity, just time out after 5 consecutive
|
||||
empty read calls (adjusted using wantReadTimeout variable */
|
||||
if (wantReadCounter == wantReadTimeout)
|
||||
serverState = serverTLSSend;
|
||||
else
|
||||
wantReadCounter++;
|
||||
}
|
||||
else if (errorCode != SSL_ERROR_WANT_READ)
|
||||
{
|
||||
fnDebugMsg("ERROR: wolfSSL_read() failed: ");
|
||||
errorCode = wolfSSL_get_error(ssl, ret);
|
||||
fnDebugDec(errorCode, DISPLAY_NEGATIVE);
|
||||
fnDebugMsg("\r\n");
|
||||
serverState = serverShutdown;
|
||||
}
|
||||
}
|
||||
else {
|
||||
serverState = serverTLSSend;
|
||||
}
|
||||
}
|
||||
|
||||
/* send server response */
|
||||
if (serverState == serverTLSSend)
|
||||
{
|
||||
msgSz = 22;
|
||||
strncpy(msg, "I hear you fa shizzle!", msgSz);
|
||||
ret = wolfSSL_write(ssl, msg, msgSz);
|
||||
errorCode = wolfSSL_get_error(ssl, ret);
|
||||
if (errorCode != SSL_ERROR_WANT_WRITE) {
|
||||
if (ret != msgSz) {
|
||||
fnDebugMsg("ERROR: wolfSSL_write() failed: ");
|
||||
errorCode = wolfSSL_get_error(ssl, ret);
|
||||
fnDebugDec(errorCode, DISPLAY_NEGATIVE);
|
||||
fnDebugMsg("\r\n");
|
||||
}
|
||||
serverState = serverShutdown;
|
||||
}
|
||||
}
|
||||
|
||||
/* free resources and shutdown */
|
||||
if (serverState == serverShutdown)
|
||||
{
|
||||
/* release socket, SSL session */
|
||||
fnReleaseTCP_Socket(server_socket);
|
||||
wolfSSL_free(ssl);
|
||||
|
||||
/* reset wolfSSL receive context/buffer */
|
||||
ResetRecvBuffer(&recvCtx);
|
||||
|
||||
/* reset variables and buffers */
|
||||
uMemset(input, 0, sizeof(input));
|
||||
wantReadCounter = 0;
|
||||
|
||||
fnDebugMsg("status: Released Resources\r\n");
|
||||
|
||||
serverState = serverSocketSetup;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,340 @@
|
|||
/****************************************************************************
|
||||
File Name : wolfSSLServerTask.h
|
||||
Author : wolfSSL Inc.
|
||||
Date Created : March 25, 2016
|
||||
Current Revision : 1.0
|
||||
Notes : Header file for wolfSSLClientTask.c
|
||||
|
||||
Copyright (C) wolfSSL, Inc. 2016
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "wolfssl/wolfcrypt/settings.h"
|
||||
|
||||
/* ./certs/server-key.der, 2048-bit */
|
||||
static const unsigned char server_key_der_2048[] =
|
||||
{
|
||||
0x30, 0x82, 0x04, 0xA5, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01,
|
||||
0x01, 0x00, 0xC0, 0x95, 0x08, 0xE1, 0x57, 0x41, 0xF2, 0x71,
|
||||
0x6D, 0xB7, 0xD2, 0x45, 0x41, 0x27, 0x01, 0x65, 0xC6, 0x45,
|
||||
0xAE, 0xF2, 0xBC, 0x24, 0x30, 0xB8, 0x95, 0xCE, 0x2F, 0x4E,
|
||||
0xD6, 0xF6, 0x1C, 0x88, 0xBC, 0x7C, 0x9F, 0xFB, 0xA8, 0x67,
|
||||
0x7F, 0xFE, 0x5C, 0x9C, 0x51, 0x75, 0xF7, 0x8A, 0xCA, 0x07,
|
||||
0xE7, 0x35, 0x2F, 0x8F, 0xE1, 0xBD, 0x7B, 0xC0, 0x2F, 0x7C,
|
||||
0xAB, 0x64, 0xA8, 0x17, 0xFC, 0xCA, 0x5D, 0x7B, 0xBA, 0xE0,
|
||||
0x21, 0xE5, 0x72, 0x2E, 0x6F, 0x2E, 0x86, 0xD8, 0x95, 0x73,
|
||||
0xDA, 0xAC, 0x1B, 0x53, 0xB9, 0x5F, 0x3F, 0xD7, 0x19, 0x0D,
|
||||
0x25, 0x4F, 0xE1, 0x63, 0x63, 0x51, 0x8B, 0x0B, 0x64, 0x3F,
|
||||
0xAD, 0x43, 0xB8, 0xA5, 0x1C, 0x5C, 0x34, 0xB3, 0xAE, 0x00,
|
||||
0xA0, 0x63, 0xC5, 0xF6, 0x7F, 0x0B, 0x59, 0x68, 0x78, 0x73,
|
||||
0xA6, 0x8C, 0x18, 0xA9, 0x02, 0x6D, 0xAF, 0xC3, 0x19, 0x01,
|
||||
0x2E, 0xB8, 0x10, 0xE3, 0xC6, 0xCC, 0x40, 0xB4, 0x69, 0xA3,
|
||||
0x46, 0x33, 0x69, 0x87, 0x6E, 0xC4, 0xBB, 0x17, 0xA6, 0xF3,
|
||||
0xE8, 0xDD, 0xAD, 0x73, 0xBC, 0x7B, 0x2F, 0x21, 0xB5, 0xFD,
|
||||
0x66, 0x51, 0x0C, 0xBD, 0x54, 0xB3, 0xE1, 0x6D, 0x5F, 0x1C,
|
||||
0xBC, 0x23, 0x73, 0xD1, 0x09, 0x03, 0x89, 0x14, 0xD2, 0x10,
|
||||
0xB9, 0x64, 0xC3, 0x2A, 0xD0, 0xA1, 0x96, 0x4A, 0xBC, 0xE1,
|
||||
0xD4, 0x1A, 0x5B, 0xC7, 0xA0, 0xC0, 0xC1, 0x63, 0x78, 0x0F,
|
||||
0x44, 0x37, 0x30, 0x32, 0x96, 0x80, 0x32, 0x23, 0x95, 0xA1,
|
||||
0x77, 0xBA, 0x13, 0xD2, 0x97, 0x73, 0xE2, 0x5D, 0x25, 0xC9,
|
||||
0x6A, 0x0D, 0xC3, 0x39, 0x60, 0xA4, 0xB4, 0xB0, 0x69, 0x42,
|
||||
0x42, 0x09, 0xE9, 0xD8, 0x08, 0xBC, 0x33, 0x20, 0xB3, 0x58,
|
||||
0x22, 0xA7, 0xAA, 0xEB, 0xC4, 0xE1, 0xE6, 0x61, 0x83, 0xC5,
|
||||
0xD2, 0x96, 0xDF, 0xD9, 0xD0, 0x4F, 0xAD, 0xD7, 0x02, 0x03,
|
||||
0x01, 0x00, 0x01, 0x02, 0x82, 0x01, 0x01, 0x00, 0x9A, 0xD0,
|
||||
0x34, 0x0F, 0x52, 0x62, 0x05, 0x50, 0x01, 0xEF, 0x9F, 0xED,
|
||||
0x64, 0x6E, 0xC2, 0xC4, 0xDA, 0x1A, 0xF2, 0x84, 0xD7, 0x92,
|
||||
0x10, 0x48, 0x92, 0xC4, 0xE9, 0x6A, 0xEB, 0x8B, 0x75, 0x6C,
|
||||
0xC6, 0x79, 0x38, 0xF2, 0xC9, 0x72, 0x4A, 0x86, 0x64, 0x54,
|
||||
0x95, 0x77, 0xCB, 0xC3, 0x9A, 0x9D, 0xB7, 0xD4, 0x1D, 0xA4,
|
||||
0x00, 0xC8, 0x9E, 0x4E, 0xE4, 0xDD, 0xC7, 0xBA, 0x67, 0x16,
|
||||
0xC1, 0x74, 0xBC, 0xA9, 0xD6, 0x94, 0x8F, 0x2B, 0x30, 0x1A,
|
||||
0xFB, 0xED, 0xDF, 0x21, 0x05, 0x23, 0xD9, 0x4A, 0x39, 0xBD,
|
||||
0x98, 0x6B, 0x65, 0x9A, 0xB8, 0xDC, 0xC4, 0x7D, 0xEE, 0xA6,
|
||||
0x43, 0x15, 0x2E, 0x3D, 0xBE, 0x1D, 0x22, 0x60, 0x2A, 0x73,
|
||||
0x30, 0xD5, 0x3E, 0xD8, 0xA2, 0xAC, 0x86, 0x43, 0x2E, 0xC4,
|
||||
0xF5, 0x64, 0x5E, 0x3F, 0x89, 0x75, 0x0F, 0x11, 0xD8, 0x51,
|
||||
0x25, 0x4E, 0x9F, 0xD8, 0xAA, 0xA3, 0xCE, 0x60, 0xB3, 0xE2,
|
||||
0x8A, 0xD9, 0x7E, 0x1B, 0xF0, 0x64, 0xCA, 0x9A, 0x5B, 0x05,
|
||||
0x0B, 0x5B, 0xAA, 0xCB, 0xE5, 0xE3, 0x3F, 0x6E, 0x32, 0x22,
|
||||
0x05, 0xF3, 0xD0, 0xFA, 0xEF, 0x74, 0x52, 0x81, 0xE2, 0x5F,
|
||||
0x74, 0xD3, 0xBD, 0xFF, 0x31, 0x83, 0x45, 0x75, 0xFA, 0x63,
|
||||
0x7A, 0x97, 0x2E, 0xD6, 0xB6, 0x19, 0xC6, 0x92, 0x26, 0xE4,
|
||||
0x28, 0x06, 0x50, 0x50, 0x0E, 0x78, 0x2E, 0xA9, 0x78, 0x0D,
|
||||
0x14, 0x97, 0xB4, 0x12, 0xD8, 0x31, 0x40, 0xAB, 0xA1, 0x01,
|
||||
0x41, 0xC2, 0x30, 0xF8, 0x07, 0x5F, 0x16, 0xE4, 0x61, 0x77,
|
||||
0xD2, 0x60, 0xF2, 0x9F, 0x8D, 0xE8, 0xF4, 0xBA, 0xEB, 0x63,
|
||||
0xDE, 0x2A, 0x97, 0x81, 0xEF, 0x4C, 0x6C, 0xE6, 0x55, 0x34,
|
||||
0x51, 0x2B, 0x28, 0x34, 0xF4, 0x53, 0x1C, 0xC4, 0x58, 0x0A,
|
||||
0x3F, 0xBB, 0xAF, 0xB5, 0xF7, 0x4A, 0x85, 0x43, 0x2D, 0x3C,
|
||||
0xF1, 0x58, 0x58, 0x81, 0x02, 0x81, 0x81, 0x00, 0xF2, 0x2C,
|
||||
0x54, 0x76, 0x39, 0x23, 0x63, 0xC9, 0x10, 0x32, 0xB7, 0x93,
|
||||
0xAD, 0xAF, 0xBE, 0x19, 0x75, 0x96, 0x81, 0x64, 0xE6, 0xB5,
|
||||
0xB8, 0x89, 0x42, 0x41, 0xD1, 0x6D, 0xD0, 0x1C, 0x1B, 0xF8,
|
||||
0x1B, 0xAC, 0x69, 0xCB, 0x36, 0x3C, 0x64, 0x7D, 0xDC, 0xF4,
|
||||
0x19, 0xB8, 0xC3, 0x60, 0xB1, 0x57, 0x48, 0x5F, 0x52, 0x4F,
|
||||
0x59, 0x3A, 0x55, 0x7F, 0x32, 0xC0, 0x19, 0x43, 0x50, 0x3F,
|
||||
0xAE, 0xCE, 0x6F, 0x17, 0xF3, 0x0E, 0x9F, 0x40, 0xCA, 0x4E,
|
||||
0xAD, 0x15, 0x3B, 0xC9, 0x79, 0xE9, 0xC0, 0x59, 0x38, 0x73,
|
||||
0x70, 0x9C, 0x0A, 0x7C, 0xC9, 0x3A, 0x48, 0x32, 0xA7, 0xD8,
|
||||
0x49, 0x75, 0x0A, 0x85, 0xC2, 0xC2, 0xFD, 0x15, 0x73, 0xDA,
|
||||
0x99, 0x09, 0x2A, 0x69, 0x9A, 0x9F, 0x0A, 0x71, 0xBF, 0xB0,
|
||||
0x04, 0xA6, 0x8C, 0x7A, 0x5A, 0x6F, 0x48, 0x5A, 0x54, 0x3B,
|
||||
0xC6, 0xB1, 0x53, 0x17, 0xDF, 0xE7, 0x02, 0x81, 0x81, 0x00,
|
||||
0xCB, 0x93, 0xDE, 0x77, 0x15, 0x5D, 0xB7, 0x5C, 0x5C, 0x7C,
|
||||
0xD8, 0x90, 0xA9, 0x98, 0x2D, 0xD6, 0x69, 0x0E, 0x63, 0xB3,
|
||||
0xA3, 0xDC, 0xA6, 0xCC, 0x8B, 0x6A, 0xA4, 0xA2, 0x12, 0x8C,
|
||||
0x8E, 0x7B, 0x48, 0x2C, 0xB2, 0x4B, 0x37, 0xDC, 0x06, 0x18,
|
||||
0x7D, 0xEA, 0xFE, 0x76, 0xA1, 0xD4, 0xA1, 0xE9, 0x3F, 0x0D,
|
||||
0xCD, 0x1B, 0x5F, 0xAF, 0x5F, 0x9E, 0x96, 0x5B, 0x5B, 0x0F,
|
||||
0xA1, 0x7C, 0xAF, 0xB3, 0x9B, 0x90, 0xDB, 0x57, 0x73, 0x3A,
|
||||
0xED, 0xB0, 0x23, 0x44, 0xAE, 0x41, 0x4F, 0x1F, 0x07, 0x42,
|
||||
0x13, 0x23, 0x4C, 0xCB, 0xFA, 0xF4, 0x14, 0xA4, 0xD5, 0xF7,
|
||||
0x9E, 0x36, 0x7C, 0x5B, 0x9F, 0xA8, 0x3C, 0xC1, 0x85, 0x5F,
|
||||
0x74, 0xD2, 0x39, 0x2D, 0xFF, 0xD0, 0x84, 0xDF, 0xFB, 0xB3,
|
||||
0x20, 0x7A, 0x2E, 0x9B, 0x17, 0xAE, 0xE6, 0xBA, 0x0B, 0xAE,
|
||||
0x5F, 0x53, 0xA4, 0x52, 0xED, 0x1B, 0xC4, 0x91, 0x02, 0x81,
|
||||
0x81, 0x00, 0xEC, 0x98, 0xDA, 0xBB, 0xD5, 0xFE, 0xF9, 0x52,
|
||||
0x4A, 0x7D, 0x02, 0x55, 0x49, 0x6F, 0x55, 0x6E, 0x52, 0x2F,
|
||||
0x84, 0xA3, 0x2B, 0xB3, 0x86, 0x62, 0xB3, 0x54, 0xD2, 0x63,
|
||||
0x52, 0xDA, 0xE3, 0x88, 0x76, 0xA0, 0xEF, 0x8B, 0x15, 0xA5,
|
||||
0xD3, 0x18, 0x14, 0x72, 0x77, 0x5E, 0xC7, 0xA3, 0x04, 0x1F,
|
||||
0x9E, 0x19, 0x62, 0xB5, 0x1B, 0x1B, 0x9E, 0xC3, 0xF2, 0xB5,
|
||||
0x32, 0xF9, 0x4C, 0xC1, 0xAA, 0xEB, 0x0C, 0x26, 0x7D, 0xD4,
|
||||
0x5F, 0x4A, 0x51, 0x5C, 0xA4, 0x45, 0x06, 0x70, 0x44, 0xA7,
|
||||
0x56, 0xC0, 0xD4, 0x22, 0x14, 0x76, 0x9E, 0xD8, 0x63, 0x50,
|
||||
0x89, 0x90, 0xD3, 0xE2, 0xBF, 0x81, 0x95, 0x92, 0x31, 0x41,
|
||||
0x87, 0x39, 0x1A, 0x43, 0x0B, 0x18, 0xA5, 0x53, 0x1F, 0x39,
|
||||
0x1A, 0x5F, 0x1F, 0x43, 0xBC, 0x87, 0x6A, 0xDF, 0x6E, 0xD3,
|
||||
0x22, 0x00, 0xFE, 0x22, 0x98, 0x70, 0x4E, 0x1A, 0x19, 0x29,
|
||||
0x02, 0x81, 0x81, 0x00, 0x8A, 0x41, 0x56, 0x28, 0x51, 0x9E,
|
||||
0x5F, 0xD4, 0x9E, 0x0B, 0x3B, 0x98, 0xA3, 0x54, 0xF2, 0x6C,
|
||||
0x56, 0xD4, 0xAA, 0xE9, 0x69, 0x33, 0x85, 0x24, 0x0C, 0xDA,
|
||||
0xD4, 0x0C, 0x2D, 0xC4, 0xBF, 0x4F, 0x02, 0x69, 0x38, 0x7C,
|
||||
0xD4, 0xE6, 0xDC, 0x4C, 0xED, 0xD7, 0x16, 0x11, 0xC3, 0x3E,
|
||||
0x00, 0xE7, 0xC3, 0x26, 0xC0, 0x51, 0x02, 0xDE, 0xBB, 0x75,
|
||||
0x9C, 0x6F, 0x56, 0x9C, 0x7A, 0xF3, 0x8E, 0xEF, 0xCF, 0x8A,
|
||||
0xC5, 0x2B, 0xD2, 0xDA, 0x06, 0x6A, 0x44, 0xC9, 0x73, 0xFE,
|
||||
0x6E, 0x99, 0x87, 0xF8, 0x5B, 0xBE, 0xF1, 0x7C, 0xE6, 0x65,
|
||||
0xB5, 0x4F, 0x6C, 0xF0, 0xC9, 0xC5, 0xFF, 0x16, 0xCA, 0x8B,
|
||||
0x1B, 0x17, 0xE2, 0x58, 0x3D, 0xA2, 0x37, 0xAB, 0x01, 0xBC,
|
||||
0xBF, 0x40, 0xCE, 0x53, 0x8C, 0x8E, 0xED, 0xEF, 0xEE, 0x59,
|
||||
0x9D, 0xE0, 0x63, 0xE6, 0x7C, 0x5E, 0xF5, 0x8E, 0x4B, 0xF1,
|
||||
0x3B, 0xC1, 0x02, 0x81, 0x80, 0x4D, 0x45, 0xF9, 0x40, 0x8C,
|
||||
0xC5, 0x5B, 0xF4, 0x2A, 0x1A, 0x8A, 0xB4, 0xF2, 0x1C, 0xAC,
|
||||
0x6B, 0xE9, 0x0C, 0x56, 0x36, 0xB7, 0x4E, 0x72, 0x96, 0xD5,
|
||||
0xE5, 0x8A, 0xD2, 0xE2, 0xFF, 0xF1, 0xF1, 0x18, 0x13, 0x3D,
|
||||
0x86, 0x09, 0xB8, 0xD8, 0x76, 0xA7, 0xC9, 0x1C, 0x71, 0x52,
|
||||
0x94, 0x30, 0x43, 0xE0, 0xF1, 0x78, 0x74, 0xFD, 0x61, 0x1B,
|
||||
0x4C, 0x09, 0xCC, 0xE6, 0x68, 0x2A, 0x71, 0xAD, 0x1C, 0xDF,
|
||||
0x43, 0xBC, 0x56, 0xDB, 0xA5, 0xA4, 0xBE, 0x35, 0x70, 0xA4,
|
||||
0x5E, 0xCF, 0x4F, 0xFC, 0x00, 0x55, 0x99, 0x3A, 0x3D, 0x23,
|
||||
0xCF, 0x67, 0x5A, 0xF5, 0x22, 0xF8, 0xB5, 0x29, 0xD0, 0x44,
|
||||
0x11, 0xEB, 0x35, 0x2E, 0x46, 0xBE, 0xFD, 0x8E, 0x18, 0xB2,
|
||||
0x5F, 0xA8, 0xBF, 0x19, 0x32, 0xA1, 0xF5, 0xDC, 0x03, 0xE6,
|
||||
0x7C, 0x9A, 0x1F, 0x0C, 0x7C, 0xA9, 0xB0, 0x0E, 0x21, 0x37,
|
||||
0x3B, 0xF1, 0xB0
|
||||
};
|
||||
|
||||
/* ./certs/server-cert.der, 2048-bit */
|
||||
static const unsigned char server_cert_der_2048[] =
|
||||
{
|
||||
0x30, 0x82, 0x04, 0xD4, 0x30, 0x82, 0x03, 0xBC, 0xA0, 0x03,
|
||||
0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x30, 0x0D, 0x06, 0x09,
|
||||
0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B, 0x05,
|
||||
0x00, 0x30, 0x81, 0x94, 0x31, 0x0B, 0x30, 0x09, 0x06, 0x03,
|
||||
0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x10, 0x30,
|
||||
0x0E, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0C, 0x07, 0x4D, 0x6F,
|
||||
0x6E, 0x74, 0x61, 0x6E, 0x61, 0x31, 0x10, 0x30, 0x0E, 0x06,
|
||||
0x03, 0x55, 0x04, 0x07, 0x0C, 0x07, 0x42, 0x6F, 0x7A, 0x65,
|
||||
0x6D, 0x61, 0x6E, 0x31, 0x11, 0x30, 0x0F, 0x06, 0x03, 0x55,
|
||||
0x04, 0x0A, 0x0C, 0x08, 0x53, 0x61, 0x77, 0x74, 0x6F, 0x6F,
|
||||
0x74, 0x68, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55, 0x04,
|
||||
0x0B, 0x0C, 0x0A, 0x43, 0x6F, 0x6E, 0x73, 0x75, 0x6C, 0x74,
|
||||
0x69, 0x6E, 0x67, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55,
|
||||
0x04, 0x03, 0x0C, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x77, 0x6F,
|
||||
0x6C, 0x66, 0x73, 0x73, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x31,
|
||||
0x1F, 0x30, 0x1D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7,
|
||||
0x0D, 0x01, 0x09, 0x01, 0x16, 0x10, 0x69, 0x6E, 0x66, 0x6F,
|
||||
0x40, 0x77, 0x6F, 0x6C, 0x66, 0x73, 0x73, 0x6C, 0x2E, 0x63,
|
||||
0x6F, 0x6D, 0x30, 0x1E, 0x17, 0x0D, 0x31, 0x35, 0x31, 0x31,
|
||||
0x32, 0x33, 0x31, 0x32, 0x34, 0x39, 0x33, 0x37, 0x5A, 0x17,
|
||||
0x0D, 0x31, 0x38, 0x30, 0x38, 0x31, 0x39, 0x31, 0x32, 0x34,
|
||||
0x39, 0x33, 0x37, 0x5A, 0x30, 0x81, 0x90, 0x31, 0x0B, 0x30,
|
||||
0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53,
|
||||
0x31, 0x10, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x04, 0x08, 0x0C,
|
||||
0x07, 0x4D, 0x6F, 0x6E, 0x74, 0x61, 0x6E, 0x61, 0x31, 0x10,
|
||||
0x30, 0x0E, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0C, 0x07, 0x42,
|
||||
0x6F, 0x7A, 0x65, 0x6D, 0x61, 0x6E, 0x31, 0x10, 0x30, 0x0E,
|
||||
0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x07, 0x77, 0x6F, 0x6C,
|
||||
0x66, 0x53, 0x53, 0x4C, 0x31, 0x10, 0x30, 0x0E, 0x06, 0x03,
|
||||
0x55, 0x04, 0x0B, 0x0C, 0x07, 0x53, 0x75, 0x70, 0x70, 0x6F,
|
||||
0x72, 0x74, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04,
|
||||
0x03, 0x0C, 0x0F, 0x77, 0x77, 0x77, 0x2E, 0x77, 0x6F, 0x6C,
|
||||
0x66, 0x73, 0x73, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x31, 0x1F,
|
||||
0x30, 0x1D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D,
|
||||
0x01, 0x09, 0x01, 0x16, 0x10, 0x69, 0x6E, 0x66, 0x6F, 0x40,
|
||||
0x77, 0x6F, 0x6C, 0x66, 0x73, 0x73, 0x6C, 0x2E, 0x63, 0x6F,
|
||||
0x6D, 0x30, 0x82, 0x01, 0x22, 0x30, 0x0D, 0x06, 0x09, 0x2A,
|
||||
0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00,
|
||||
0x03, 0x82, 0x01, 0x0F, 0x00, 0x30, 0x82, 0x01, 0x0A, 0x02,
|
||||
0x82, 0x01, 0x01, 0x00, 0xC0, 0x95, 0x08, 0xE1, 0x57, 0x41,
|
||||
0xF2, 0x71, 0x6D, 0xB7, 0xD2, 0x45, 0x41, 0x27, 0x01, 0x65,
|
||||
0xC6, 0x45, 0xAE, 0xF2, 0xBC, 0x24, 0x30, 0xB8, 0x95, 0xCE,
|
||||
0x2F, 0x4E, 0xD6, 0xF6, 0x1C, 0x88, 0xBC, 0x7C, 0x9F, 0xFB,
|
||||
0xA8, 0x67, 0x7F, 0xFE, 0x5C, 0x9C, 0x51, 0x75, 0xF7, 0x8A,
|
||||
0xCA, 0x07, 0xE7, 0x35, 0x2F, 0x8F, 0xE1, 0xBD, 0x7B, 0xC0,
|
||||
0x2F, 0x7C, 0xAB, 0x64, 0xA8, 0x17, 0xFC, 0xCA, 0x5D, 0x7B,
|
||||
0xBA, 0xE0, 0x21, 0xE5, 0x72, 0x2E, 0x6F, 0x2E, 0x86, 0xD8,
|
||||
0x95, 0x73, 0xDA, 0xAC, 0x1B, 0x53, 0xB9, 0x5F, 0x3F, 0xD7,
|
||||
0x19, 0x0D, 0x25, 0x4F, 0xE1, 0x63, 0x63, 0x51, 0x8B, 0x0B,
|
||||
0x64, 0x3F, 0xAD, 0x43, 0xB8, 0xA5, 0x1C, 0x5C, 0x34, 0xB3,
|
||||
0xAE, 0x00, 0xA0, 0x63, 0xC5, 0xF6, 0x7F, 0x0B, 0x59, 0x68,
|
||||
0x78, 0x73, 0xA6, 0x8C, 0x18, 0xA9, 0x02, 0x6D, 0xAF, 0xC3,
|
||||
0x19, 0x01, 0x2E, 0xB8, 0x10, 0xE3, 0xC6, 0xCC, 0x40, 0xB4,
|
||||
0x69, 0xA3, 0x46, 0x33, 0x69, 0x87, 0x6E, 0xC4, 0xBB, 0x17,
|
||||
0xA6, 0xF3, 0xE8, 0xDD, 0xAD, 0x73, 0xBC, 0x7B, 0x2F, 0x21,
|
||||
0xB5, 0xFD, 0x66, 0x51, 0x0C, 0xBD, 0x54, 0xB3, 0xE1, 0x6D,
|
||||
0x5F, 0x1C, 0xBC, 0x23, 0x73, 0xD1, 0x09, 0x03, 0x89, 0x14,
|
||||
0xD2, 0x10, 0xB9, 0x64, 0xC3, 0x2A, 0xD0, 0xA1, 0x96, 0x4A,
|
||||
0xBC, 0xE1, 0xD4, 0x1A, 0x5B, 0xC7, 0xA0, 0xC0, 0xC1, 0x63,
|
||||
0x78, 0x0F, 0x44, 0x37, 0x30, 0x32, 0x96, 0x80, 0x32, 0x23,
|
||||
0x95, 0xA1, 0x77, 0xBA, 0x13, 0xD2, 0x97, 0x73, 0xE2, 0x5D,
|
||||
0x25, 0xC9, 0x6A, 0x0D, 0xC3, 0x39, 0x60, 0xA4, 0xB4, 0xB0,
|
||||
0x69, 0x42, 0x42, 0x09, 0xE9, 0xD8, 0x08, 0xBC, 0x33, 0x20,
|
||||
0xB3, 0x58, 0x22, 0xA7, 0xAA, 0xEB, 0xC4, 0xE1, 0xE6, 0x61,
|
||||
0x83, 0xC5, 0xD2, 0x96, 0xDF, 0xD9, 0xD0, 0x4F, 0xAD, 0xD7,
|
||||
0x02, 0x03, 0x01, 0x00, 0x01, 0xA3, 0x82, 0x01, 0x31, 0x30,
|
||||
0x82, 0x01, 0x2D, 0x30, 0x1D, 0x06, 0x03, 0x55, 0x1D, 0x0E,
|
||||
0x04, 0x16, 0x04, 0x14, 0xB3, 0x11, 0x32, 0xC9, 0x92, 0x98,
|
||||
0x84, 0xE2, 0xC9, 0xF8, 0xD0, 0x3B, 0x6E, 0x03, 0x42, 0xCA,
|
||||
0x1F, 0x0E, 0x8E, 0x3C, 0x30, 0x81, 0xC9, 0x06, 0x03, 0x55,
|
||||
0x1D, 0x23, 0x04, 0x81, 0xC1, 0x30, 0x81, 0xBE, 0x80, 0x14,
|
||||
0x27, 0x8E, 0x67, 0x11, 0x74, 0xC3, 0x26, 0x1D, 0x3F, 0xED,
|
||||
0x33, 0x63, 0xB3, 0xA4, 0xD8, 0x1D, 0x30, 0xE5, 0xE8, 0xD5,
|
||||
0xA1, 0x81, 0x9A, 0xA4, 0x81, 0x97, 0x30, 0x81, 0x94, 0x31,
|
||||
0x0B, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02,
|
||||
0x55, 0x53, 0x31, 0x10, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x04,
|
||||
0x08, 0x0C, 0x07, 0x4D, 0x6F, 0x6E, 0x74, 0x61, 0x6E, 0x61,
|
||||
0x31, 0x10, 0x30, 0x0E, 0x06, 0x03, 0x55, 0x04, 0x07, 0x0C,
|
||||
0x07, 0x42, 0x6F, 0x7A, 0x65, 0x6D, 0x61, 0x6E, 0x31, 0x11,
|
||||
0x30, 0x0F, 0x06, 0x03, 0x55, 0x04, 0x0A, 0x0C, 0x08, 0x53,
|
||||
0x61, 0x77, 0x74, 0x6F, 0x6F, 0x74, 0x68, 0x31, 0x13, 0x30,
|
||||
0x11, 0x06, 0x03, 0x55, 0x04, 0x0B, 0x0C, 0x0A, 0x43, 0x6F,
|
||||
0x6E, 0x73, 0x75, 0x6C, 0x74, 0x69, 0x6E, 0x67, 0x31, 0x18,
|
||||
0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x0F, 0x77,
|
||||
0x77, 0x77, 0x2E, 0x77, 0x6F, 0x6C, 0x66, 0x73, 0x73, 0x6C,
|
||||
0x2E, 0x63, 0x6F, 0x6D, 0x31, 0x1F, 0x30, 0x1D, 0x06, 0x09,
|
||||
0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x01, 0x16,
|
||||
0x10, 0x69, 0x6E, 0x66, 0x6F, 0x40, 0x77, 0x6F, 0x6C, 0x66,
|
||||
0x73, 0x73, 0x6C, 0x2E, 0x63, 0x6F, 0x6D, 0x82, 0x09, 0x00,
|
||||
0xA6, 0x66, 0x38, 0x49, 0x45, 0x9B, 0xDC, 0x81, 0x30, 0x0C,
|
||||
0x06, 0x03, 0x55, 0x1D, 0x13, 0x04, 0x05, 0x30, 0x03, 0x01,
|
||||
0x01, 0xFF, 0x30, 0x32, 0x06, 0x08, 0x2B, 0x06, 0x01, 0x05,
|
||||
0x05, 0x07, 0x01, 0x01, 0x04, 0x26, 0x30, 0x24, 0x30, 0x22,
|
||||
0x06, 0x08, 0x2B, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01,
|
||||
0x86, 0x16, 0x68, 0x74, 0x74, 0x70, 0x3A, 0x2F, 0x2F, 0x6C,
|
||||
0x6F, 0x63, 0x61, 0x6C, 0x68, 0x6F, 0x73, 0x74, 0x3A, 0x32,
|
||||
0x32, 0x32, 0x32, 0x32, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86,
|
||||
0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x0B, 0x05, 0x00, 0x03,
|
||||
0x82, 0x01, 0x01, 0x00, 0x71, 0x17, 0x8F, 0x6F, 0x7D, 0xD6,
|
||||
0x11, 0x01, 0x79, 0xAC, 0xE9, 0xC2, 0xFB, 0x71, 0x69, 0x6B,
|
||||
0x0C, 0x64, 0x91, 0xC1, 0x32, 0x8B, 0x9C, 0x62, 0x72, 0xB5,
|
||||
0x62, 0xBB, 0xF8, 0xCF, 0x6C, 0x27, 0xDF, 0xF0, 0x64, 0xD6,
|
||||
0x4A, 0x55, 0x4F, 0x7F, 0x4A, 0x8B, 0x7B, 0x80, 0x5B, 0x3C,
|
||||
0xA0, 0x31, 0xB0, 0x25, 0x92, 0x02, 0x02, 0x9C, 0x99, 0xA5,
|
||||
0x8E, 0x0C, 0x61, 0xEF, 0xB4, 0x1E, 0x01, 0x2E, 0x1C, 0xE9,
|
||||
0x9C, 0x59, 0x2D, 0xEF, 0x6E, 0x03, 0x4D, 0xF1, 0x59, 0xE5,
|
||||
0x5F, 0x69, 0x66, 0x5C, 0x0A, 0xE6, 0xCD, 0xF6, 0x74, 0x20,
|
||||
0x86, 0x4C, 0xF6, 0x8F, 0x22, 0x86, 0x68, 0x7E, 0xFE, 0x67,
|
||||
0x3F, 0x3D, 0x19, 0xB8, 0x61, 0xEF, 0xC5, 0xA5, 0x58, 0xA8,
|
||||
0x2A, 0xCE, 0xD3, 0x2C, 0xA7, 0x1B, 0xDD, 0xC8, 0x59, 0xC7,
|
||||
0xE7, 0xCF, 0x42, 0x42, 0xDB, 0xAF, 0xFE, 0x15, 0x82, 0xC9,
|
||||
0xE5, 0x53, 0xFA, 0xB4, 0x37, 0x55, 0x67, 0x47, 0x0F, 0xE7,
|
||||
0x24, 0x88, 0x14, 0xA3, 0x6C, 0xBE, 0x5F, 0x72, 0x05, 0x5F,
|
||||
0x56, 0x33, 0xAA, 0x7F, 0xAC, 0x2E, 0x10, 0x92, 0xB7, 0xA2,
|
||||
0xF9, 0xC1, 0x62, 0x0C, 0x3B, 0x0C, 0x69, 0x9A, 0x71, 0x15,
|
||||
0x11, 0xBC, 0x37, 0xBF, 0x8E, 0x23, 0x14, 0xC2, 0xB1, 0x0D,
|
||||
0xDF, 0x89, 0x45, 0x1E, 0xDF, 0x14, 0xE8, 0x95, 0x35, 0x88,
|
||||
0x27, 0xA8, 0xAB, 0xDD, 0x7C, 0x23, 0x3F, 0xBB, 0xFE, 0x4E,
|
||||
0x0E, 0xEA, 0xA6, 0xEE, 0xF5, 0x77, 0xFB, 0xAA, 0xB8, 0x28,
|
||||
0x33, 0xF9, 0x61, 0xB0, 0xD2, 0x79, 0x46, 0xA4, 0xBA, 0xA0,
|
||||
0x90, 0xC8, 0xE7, 0x96, 0x8F, 0x27, 0xE9, 0x1E, 0xD0, 0x92,
|
||||
0x43, 0xBB, 0x84, 0xC7, 0xF3, 0x28, 0x0C, 0x41, 0xAA, 0x77,
|
||||
0x39, 0x65, 0xAA, 0x0D, 0x02, 0xB0, 0xE0, 0x4D, 0xB1, 0x17,
|
||||
0x41, 0xC9, 0xF0, 0xD4, 0x47, 0x87, 0xFB, 0x0F, 0xF0, 0x40
|
||||
|
||||
};
|
||||
|
||||
/* function prototypes */
|
||||
|
||||
int WolfCryptTest(void);
|
||||
|
||||
int md2_test(void);
|
||||
int md5_test(void);
|
||||
int md4_test(void);
|
||||
int sha_test(void);
|
||||
int sha256_test(void);
|
||||
int sha512_test(void);
|
||||
int sha384_test(void);
|
||||
int hmac_md5_test(void);
|
||||
int hmac_sha_test(void);
|
||||
int hmac_sha256_test(void);
|
||||
int hmac_sha384_test(void);
|
||||
int hmac_sha512_test(void);
|
||||
int hmac_blake2b_test(void);
|
||||
int hkdf_test(void);
|
||||
int arc4_test(void);
|
||||
int hc128_test(void);
|
||||
int rabbit_test(void);
|
||||
int chacha_test(void);
|
||||
int chacha20_poly1305_aead_test(void);
|
||||
int des_test(void);
|
||||
int des3_test(void);
|
||||
int aes_test(void);
|
||||
int poly1305_test(void);
|
||||
int aesgcm_test(void);
|
||||
int gmac_test(void);
|
||||
int aesccm_test(void);
|
||||
int camellia_test(void);
|
||||
int rsa_test(void);
|
||||
int dh_test(void);
|
||||
int dsa_test(void);
|
||||
int srp_test(void);
|
||||
int random_test(void);
|
||||
int pwdbased_test(void);
|
||||
int ripemd_test(void);
|
||||
int openssl_test(void); /* test mini api */
|
||||
int pbkdf1_test(void);
|
||||
int pkcs12_test(void);
|
||||
int pbkdf2_test(void);
|
||||
#ifdef HAVE_ECC
|
||||
int ecc_test(void);
|
||||
#ifdef HAVE_ECC_ENCRYPT
|
||||
int ecc_encrypt_test(void);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef HAVE_CURVE25519
|
||||
int curve25519_test(void);
|
||||
#endif
|
||||
#ifdef HAVE_ED25519
|
||||
int ed25519_test(void);
|
||||
#endif
|
||||
#ifdef HAVE_BLAKE2
|
||||
int blake2b_test(void);
|
||||
#endif
|
||||
#ifdef HAVE_LIBZ
|
||||
int compress_test(void);
|
||||
#endif
|
||||
#ifdef HAVE_PKCS7
|
||||
int pkcs7enveloped_test(void);
|
||||
int pkcs7signed_test(void);
|
||||
#endif
|
||||
#if defined(WOLFSSL_CERT_EXT) && defined(WOLFSSL_TEST_CERT)
|
||||
int certext_test(void);
|
||||
#endif
|
||||
#ifdef HAVE_IDEA
|
||||
int idea_test(void);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue