commit
b5382f0e19
|
@ -115,7 +115,7 @@ make
|
||||||
|
|
||||||
This directory contains examples for securing a Bluetooth Low Energy Link (BTLE).
|
This directory contains examples for securing a Bluetooth Low Energy Link (BTLE).
|
||||||
BTLE packets are small and throughput is low, so these examples demonstrate a way
|
BTLE packets are small and throughput is low, so these examples demonstrate a way
|
||||||
to exchange data securley without BTLE pariing.
|
to exchange data securely without BTLE pairing.
|
||||||
|
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
/* Wolfssl_Enclave.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||||
|
*
|
||||||
|
* This file is part of wolfSSL.
|
||||||
|
*
|
||||||
|
* wolfSSL is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* wolfSSL is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h> /* vsnprintf */
|
#include <stdio.h> /* vsnprintf */
|
||||||
|
|
||||||
|
@ -7,7 +28,7 @@
|
||||||
|
|
||||||
|
|
||||||
#if defined(XMALLOC_USER) || defined(XMALLOC_OVERRIDE)
|
#if defined(XMALLOC_USER) || defined(XMALLOC_OVERRIDE)
|
||||||
#warning verfication of heap hint pointers needed when overriding default malloc/free
|
#warning verification of heap hint pointers needed when overriding default malloc/free
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -158,7 +179,7 @@ long enc_wolfTLSv1_2_server_method(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* returns method releated to id */
|
/* returns method related to id */
|
||||||
static WOLFSSL_METHOD* GetMethod(long id)
|
static WOLFSSL_METHOD* GetMethod(long id)
|
||||||
{
|
{
|
||||||
switch (id) {
|
switch (id) {
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
/* Wolfssl_Enclave.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||||
|
*
|
||||||
|
* This file is part of wolfSSL.
|
||||||
|
*
|
||||||
|
* wolfSSL is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* wolfSSL is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef _BENCHMARK_ENCLAVE_H_
|
#ifndef _BENCHMARK_ENCLAVE_H_
|
||||||
#define _BENCHMARK_ENCLAVE_H_
|
#define _BENCHMARK_ENCLAVE_H_
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "client-tls.h"
|
#include "client-tls.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -44,7 +45,7 @@ int client_connect(sgx_enclave_id_t id)
|
||||||
long ssl;
|
long ssl;
|
||||||
|
|
||||||
|
|
||||||
/* data to send to the server, data recieved from the server */
|
/* data to send to the server, data received from the server */
|
||||||
char sendBuff[] = "Hello WolfSSL!";
|
char sendBuff[] = "Hello WolfSSL!";
|
||||||
char rcvBuff[MAXDATASIZE] = {0};
|
char rcvBuff[MAXDATASIZE] = {0};
|
||||||
|
|
||||||
|
@ -155,7 +156,7 @@ int client_connect(sgx_enclave_id_t id)
|
||||||
printf("Read error. Error: %i\n", ret);
|
printf("Read error. Error: %i\n", ret);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
printf("Recieved: \t%s\n", rcvBuff);
|
printf("Received: \t%s\n", rcvBuff);
|
||||||
|
|
||||||
/* frees all data before client termination */
|
/* frees all data before client termination */
|
||||||
enc_wolfSSL_free(id, ssl);
|
enc_wolfSSL_free(id, ssl);
|
||||||
|
|
|
@ -112,7 +112,7 @@ int server_connect(sgx_enclave_id_t id)
|
||||||
|
|
||||||
/* Initialize the server address struct with zeros */
|
/* Initialize the server address struct with zeros */
|
||||||
memset(&servAddr, 0, sizeof(servAddr));
|
memset(&servAddr, 0, sizeof(servAddr));
|
||||||
/* Fill in the server address */
|
/* Fill in the server address */
|
||||||
servAddr.sin_family = AF_INET; /* using IPv4 */
|
servAddr.sin_family = AF_INET; /* using IPv4 */
|
||||||
servAddr.sin_port = htons(DEFAULT_PORT); /* on DEFAULT_PORT */
|
servAddr.sin_port = htons(DEFAULT_PORT); /* on DEFAULT_PORT */
|
||||||
servAddr.sin_addr.s_addr = INADDR_ANY; /* from anywhere */
|
servAddr.sin_addr.s_addr = INADDR_ANY; /* from anywhere */
|
||||||
|
|
|
@ -106,7 +106,7 @@ int main(int argc, char** argv)
|
||||||
printf("wc_ecc_export_x963 failed %d\n", ret);
|
printf("wc_ecc_export_x963 failed %d\n", ret);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
/* TODO: Server should hash and sign this public key with a trust ceritifcate (already exchanged) */
|
/* TODO: Server should hash and sign this public key with a trust certificate (already exchanged) */
|
||||||
/* ECC signature is about 65 bytes */
|
/* ECC signature is about 65 bytes */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ public key and subject name information.
|
||||||
|
|
||||||
## Compiling and Running the Example
|
## Compiling and Running the Example
|
||||||
|
|
||||||
To compile, first build wolfSSL with the OpenSSL compatibilty layer enabled:
|
To compile, first build wolfSSL with the OpenSSL compatibility layer enabled:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ cd wolfssl-X.X.X
|
$ cd wolfssl-X.X.X
|
||||||
|
|
|
@ -67,7 +67,7 @@ int main(void)
|
||||||
printf("Failed to decode public key from pubKeyTmp, abort!\n");
|
printf("Failed to decode public key from pubKeyTmp, abort!\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
printf("Succesfully decoded public key\n");
|
printf("Successfully decoded public key\n");
|
||||||
|
|
||||||
printf("PUBLIC KEY:\n");
|
printf("PUBLIC KEY:\n");
|
||||||
for (i = 0; i < pubKeyTmp->pkey_sz; i++) {
|
for (i = 0; i < pubKeyTmp->pkey_sz; i++) {
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
/* certgen_example.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||||
|
*
|
||||||
|
* This file is part of wolfSSL.
|
||||||
|
*
|
||||||
|
* wolfSSL is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* wolfSSL is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <wolfssl/options.h>
|
#include <wolfssl/options.h>
|
||||||
#include <wolfssl/wolfcrypt/settings.h>
|
#include <wolfssl/wolfcrypt/settings.h>
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
/* certgen_with_altnames.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||||
|
*
|
||||||
|
* This file is part of wolfSSL.
|
||||||
|
*
|
||||||
|
* wolfSSL is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* wolfSSL is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <wolfssl/options.h>
|
#include <wolfssl/options.h>
|
||||||
#include <wolfssl/wolfcrypt/settings.h>
|
#include <wolfssl/wolfcrypt/settings.h>
|
||||||
|
@ -144,7 +165,7 @@ int main(void) {
|
||||||
|
|
||||||
/* Add some alt names to our cert: */
|
/* Add some alt names to our cert: */
|
||||||
char myAltNames[] = {
|
char myAltNames[] = {
|
||||||
/* SEQUENCE (1 element with 3 segements. Entire length is 41
|
/* SEQUENCE (1 element with 3 segments. Entire length is 41
|
||||||
* (0x29 in hex))
|
* (0x29 in hex))
|
||||||
*/
|
*/
|
||||||
0x30, 0x29,
|
0x30, 0x29,
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
/* csr_w_ed25519_example.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||||
|
*
|
||||||
|
* This file is part of wolfSSL.
|
||||||
|
*
|
||||||
|
* wolfSSL is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* wolfSSL is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||||
|
*/
|
||||||
|
|
||||||
#include <wolfssl/options.h>
|
#include <wolfssl/options.h>
|
||||||
#include <wolfssl/wolfcrypt/settings.h>
|
#include <wolfssl/wolfcrypt/settings.h>
|
||||||
#include <wolfssl/wolfcrypt/ed25519.h>
|
#include <wolfssl/wolfcrypt/ed25519.h>
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#define SALT_SIZE 8
|
#define SALT_SIZE 8
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Makes a cryptographically secure key by stretMDMching a user entered key
|
* Makes a cryptographically secure key by stretching a user entered key
|
||||||
*/
|
*/
|
||||||
int GenerateKey(RNG* rng, byte* key, int size, byte* salt, int pad)
|
int GenerateKey(RNG* rng, byte* key, int size, byte* salt, int pad)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,52 +1,54 @@
|
||||||
This is an example to demonstrate how the custom IO callbacks can be used to</br>
|
# Custom IO Callback Example
|
||||||
facilitate a TLS connection using any medium. Here we chose the medium: "File System".</br>
|
|
||||||
|
|
||||||
Other mediums might be: </br>
|
This is an example to demonstrate how the custom IO callbacks can be used to
|
||||||
USB Serial connection </br>
|
facilitate a TLS connection using any medium. Here we chose the medium: "File System".
|
||||||
Bluetooth </br>
|
|
||||||
RFID </br>
|
Other transports might be:
|
||||||
Wifi </br>
|
* USB Serial connection
|
||||||
Ethernet </br>
|
* Bluetooth
|
||||||
</br>
|
* RFID
|
||||||
Just to name a few.</br>
|
* Wifi
|
||||||
</br>
|
* Ethernet
|
||||||
These examples use the wolfSSL Custom IO Callbacks to read and write to the file</br>
|
|
||||||
system and perform a successful handshake.</br>
|
These examples use the wolfSSL Custom IO Callbacks to read and write to the file
|
||||||
</br>
|
system and perform a successful handshake.
|
||||||
The configuration used for these examples was:</br>
|
|
||||||
./configure --enable-debug</br>
|
The configuration used for these examples:
|
||||||
</br>
|
|
||||||
Debug was enabled in case a user wishes to use the verbose flag to see what is</br>
|
`./configure --enable-debug`
|
||||||
happening in real time:</br>
|
|
||||||
</br>
|
Debug was enabled in case a user wishes to use the verbose flag to see what is
|
||||||
Usage examples:</br>
|
happening in real time:
|
||||||
</br>
|
|
||||||
From the file-server directory:</br>
|
Usage examples:
|
||||||
./start-server</br>
|
|
||||||
./start-server -v</br>
|
From the file-server directory:
|
||||||
./start-server -verbose</br>
|
./start-server
|
||||||
</br>
|
./start-server -v
|
||||||
From the file-client directory:</br>
|
./start-server -verbose
|
||||||
./start-client</br>
|
|
||||||
./start-client -v</br>
|
From the file-client directory:
|
||||||
./start-client -verbose</br>
|
./start-client
|
||||||
</br>
|
./start-client -v
|
||||||
(-v and -verbose accomplish the same thing)</br>
|
./start-client -verbose
|
||||||
</br>
|
|
||||||
</br>
|
(-v and -verbose accomplish the same thing)
|
||||||
SCRIPTS: The scripts provided attempt to make testing easier.</br>
|
|
||||||
</br>
|
## SCRIPTS
|
||||||
file-server/check.sh</br>
|
|
||||||
- starts the server in a background shell and runs the client </br>
|
The scripts provided attempt to make testing easier.
|
||||||
</br>
|
|
||||||
USAGE:</br>
|
* file-server/check.sh
|
||||||
./check.sh</br>
|
- starts the server in a background shell and runs the client
|
||||||
./check.sh -v</br>
|
|
||||||
./check.sh -verbose</br>
|
USAGE:
|
||||||
</br>
|
./check.sh
|
||||||
file-client/clean-io-files.sh</br>
|
./check.sh -v
|
||||||
- If something happens and there is leftover junk in the io files run this</br>
|
./check.sh -verbose
|
||||||
script to quickly cleanup before next round of testing.</br>
|
|
||||||
USAGE:</br>
|
* file-client/clean-io-files.sh
|
||||||
./clean-io-files.sh</br>
|
- If something happens and there is leftover junk in the io files run this
|
||||||
</br>
|
script to quickly cleanup before next round of testing.
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
./clean-io-files.sh
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||||
*
|
*
|
||||||
* EXAMPLE DEFINIITON:
|
* EXAMPLE DEFINITION:
|
||||||
*
|
*
|
||||||
* Instead of using sockets we will show how it is possible
|
* Instead of using sockets we will show how it is possible
|
||||||
* to deliver TLS handshake and packet exchange through the use of
|
* to deliver TLS handshake and packet exchange through the use of
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||||
*
|
*
|
||||||
* EXAMPLE DEFINIITON:
|
* EXAMPLE DEFINITION:
|
||||||
*
|
*
|
||||||
* Instead of using sockets we will show how it is possible
|
* Instead of using sockets we will show how it is possible
|
||||||
* to deliver TLS handshake and packet exchange through the use of
|
* to deliver TLS handshake and packet exchange through the use of
|
||||||
|
@ -241,7 +241,7 @@ int main(int argc, char** argv)
|
||||||
printf("Server send successful\n");
|
printf("Server send successful\n");
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
printf("Unkown error occured, shutting down\n");
|
printf("Unkown error occurred, shutting down\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* client-dtls.c
|
* client-dtls-ipv6.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||||
*
|
*
|
||||||
|
|
|
@ -178,7 +178,7 @@ int main (int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret != SSL_SUCCESS) {
|
if (ret != SSL_SUCCESS) {
|
||||||
printf("SSL_connectrfailed with");
|
printf("SSL_connect failed with");
|
||||||
}
|
}
|
||||||
/* */
|
/* */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* server-dtls.c
|
/* server-dtls-ipv6.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2015 wolfSSL Inc.
|
* Copyright (C) 2006-2015 wolfSSL Inc.
|
||||||
*
|
*
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
int sockfd; /* Initialize our socket */
|
int sockfd; /* Initialize our socket */
|
||||||
int recvLen; /* number of bytes recieved */
|
int recvLen; /* number of bytes received */
|
||||||
int msgNum = 0; /* number of msg received */
|
int msgNum = 0; /* number of msg received */
|
||||||
unsigned char buf[MSGLEN]; /* the incoming message */
|
unsigned char buf[MSGLEN]; /* the incoming message */
|
||||||
struct sockaddr_in servAddr; /* our server's address */
|
struct sockaddr_in servAddr; /* our server's address */
|
||||||
|
|
|
@ -104,7 +104,7 @@ static void check_ret(char* call, int ret)
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
printf("Not compiled in: Must build wolfSSL using ./confgiure --enable-opensslextra or ./configure CFLAGS=-DWOLFSSL_TEST_CERT\n");
|
printf("Not compiled in: Must build wolfSSL using ./configure --enable-opensslextra or ./configure CFLAGS=-DWOLFSSL_TEST_CERT\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ int main(void)
|
||||||
|
|
||||||
fp = fopen("./" XSTRINGIFY(TEST_ECC_KEY_CURVE) ".der", "wb");
|
fp = fopen("./" XSTRINGIFY(TEST_ECC_KEY_CURVE) ".der", "wb");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
printf("Error openening %s for write\n",
|
printf("Error opening %s for write\n",
|
||||||
"./" XSTRINGIFY(TEST_ECC_KEY_CURVE) ".der");
|
"./" XSTRINGIFY(TEST_ECC_KEY_CURVE) ".der");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ int main(void)
|
||||||
|
|
||||||
fp = fopen("./" XSTRINGIFY(TEST_ECC_KEY_CURVE) ".pem", "wb");
|
fp = fopen("./" XSTRINGIFY(TEST_ECC_KEY_CURVE) ".pem", "wb");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
printf("Error openening %s for write\n",
|
printf("Error opening %s for write\n",
|
||||||
"./" XSTRINGIFY(TEST_ECC_KEY_CURVE) ".pem");
|
"./" XSTRINGIFY(TEST_ECC_KEY_CURVE) ".pem");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ int main(void)
|
||||||
|
|
||||||
fp = fopen("./" XSTRINGIFY(TEST_ECC_KEY_CURVE) "_pub.der", "wb");
|
fp = fopen("./" XSTRINGIFY(TEST_ECC_KEY_CURVE) "_pub.der", "wb");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
printf("Error openening %s for write\n",
|
printf("Error opening %s for write\n",
|
||||||
"./" XSTRINGIFY(TEST_ECC_KEY_CURVE) "_pub.der");
|
"./" XSTRINGIFY(TEST_ECC_KEY_CURVE) "_pub.der");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ int main(void)
|
||||||
|
|
||||||
fp = fopen("./" XSTRINGIFY(TEST_ECC_KEY_CURVE) "_pub.pem", "wb");
|
fp = fopen("./" XSTRINGIFY(TEST_ECC_KEY_CURVE) "_pub.pem", "wb");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
printf("Error openening %s for write\n",
|
printf("Error opening %s for write\n",
|
||||||
"./" XSTRINGIFY(TEST_ECC_KEY_CURVE) "_pub.pem");
|
"./" XSTRINGIFY(TEST_ECC_KEY_CURVE) "_pub.pem");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
/* ecdh_gen_secret.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||||
|
*
|
||||||
|
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
||||||
|
*
|
||||||
|
* wolfSSL is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* wolfSSL is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <wolfssl/options.h>
|
#include <wolfssl/options.h>
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
/* gen_key_files.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||||
|
*
|
||||||
|
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
||||||
|
*
|
||||||
|
* wolfSSL is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* wolfSSL is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <wolfssl/options.h>
|
#include <wolfssl/options.h>
|
||||||
#include <wolfssl/wolfcrypt/ed25519.h>
|
#include <wolfssl/wolfcrypt/ed25519.h>
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
/* sign_and_verify.c
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||||
|
*
|
||||||
|
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
||||||
|
*
|
||||||
|
* wolfSSL is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* wolfSSL is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <wolfssl/options.h>
|
#include <wolfssl/options.h>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* rsa-pss.c
|
/* rsa-nb.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
* Copyright (C) 2006-2020 wolfSSL Inc.
|
||||||
*
|
*
|
||||||
|
|
|
@ -51,7 +51,7 @@ static int client_init(Srp** srp)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calcuate the client's public key */
|
/* Calculate the client's public key */
|
||||||
static int client_calc_public(Srp* srp, const char* username, char* password,
|
static int client_calc_public(Srp* srp, const char* username, char* password,
|
||||||
byte* salt, word32 saltSz, byte* pubKey,
|
byte* salt, word32 saltSz, byte* pubKey,
|
||||||
word32* pubKeySz)
|
word32* pubKeySz)
|
||||||
|
@ -115,7 +115,7 @@ static int server_init(Srp** srp)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calcuate the server's public key */
|
/* Calculate the server's public key */
|
||||||
static int server_calc_public(Srp* srp, const char* username, byte* salt,
|
static int server_calc_public(Srp* srp, const char* username, byte* salt,
|
||||||
word32 saltSz, byte* verifier, word32 vSz,
|
word32 saltSz, byte* verifier, word32 vSz,
|
||||||
byte* pubKey, word32* pubKeySz)
|
byte* pubKey, word32* pubKeySz)
|
||||||
|
|
|
@ -265,7 +265,7 @@ Session resumption allows a client/server pair to re-use previously generated cr
|
||||||
3. Change all calls from write() or send() to wolfSSL_write(), in the simple server
|
3. Change all calls from write() or send() to wolfSSL_write(), in the simple server
|
||||||
``write(sockfd, sendline, strlen(sendline))`` becomes ``wolfSSL_write(ssl, sendline, strlen(sendline))``
|
``write(sockfd, sendline, strlen(sendline))`` becomes ``wolfSSL_write(ssl, sendline, strlen(sendline))``
|
||||||
|
|
||||||
4. Run the wolfSSL method to initalize wolfSSL
|
4. Run the wolfSSL method to initialize wolfSSL
|
||||||
``wolfSSL_Init()``
|
``wolfSSL_Init()``
|
||||||
|
|
||||||
5. Create a ctx pointer that contains a server method using the following process. The server method wolfSSLv23_server_method()
|
5. Create a ctx pointer that contains a server method using the following process. The server method wolfSSLv23_server_method()
|
||||||
|
|
|
@ -225,7 +225,7 @@ int main(int argc, char **argv)
|
||||||
/* set up pre shared keys */
|
/* set up pre shared keys */
|
||||||
wolfSSL_CTX_set_psk_client_callback(ctx, My_Psk_Client_Cb);
|
wolfSSL_CTX_set_psk_client_callback(ctx, My_Psk_Client_Cb);
|
||||||
|
|
||||||
/* creat wolfssl object after each tcp connct */
|
/* creat wolfssl object after each tcp connect */
|
||||||
if ( (ssl = wolfSSL_new(ctx)) == NULL) {
|
if ( (ssl = wolfSSL_new(ctx)) == NULL) {
|
||||||
fprintf(stderr, "wolfSSL_new error.\n");
|
fprintf(stderr, "wolfSSL_new error.\n");
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
|
@ -111,7 +111,7 @@ int main(int argc, char **argv)
|
||||||
/* set up pre shared keys */
|
/* set up pre shared keys */
|
||||||
wolfSSL_CTX_set_psk_client_callback(ctx, My_Psk_Client_Cb);
|
wolfSSL_CTX_set_psk_client_callback(ctx, My_Psk_Client_Cb);
|
||||||
|
|
||||||
/* creat wolfssl object after each tcp connct */
|
/* creat wolfssl object after each tcp connect */
|
||||||
if ( (ssl = wolfSSL_new(ctx)) == NULL) {
|
if ( (ssl = wolfSSL_new(ctx)) == NULL) {
|
||||||
fprintf(stderr, "wolfSSL_new error.\n");
|
fprintf(stderr, "wolfSSL_new error.\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* this function will send the inputted string to the server and then
|
* this function will send the inputted string to the server and then
|
||||||
* recieve the string from the server outputing it to the termial
|
* receive the string from the server outputing it to the terminal
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
|
|
@ -31,7 +31,7 @@ ED25519 directory contains:
|
||||||
formatted files.
|
formatted files.
|
||||||
|
|
||||||
2. genkeybuffers.pl - a perl script to write the header file "test_keys.h" using
|
2. genkeybuffers.pl - a perl script to write the header file "test_keys.h" using
|
||||||
the .der formatted files output from applicaton "gen_key_files.c"
|
the .der formatted files output from application "gen_key_files.c"
|
||||||
|
|
||||||
3. App "sign_and_verify.c" to use the "test_keys.h" header file buffers for
|
3. App "sign_and_verify.c" to use the "test_keys.h" header file buffers for
|
||||||
importing the public and private keys. App will then sign a msg with the
|
importing the public and private keys. App will then sign a msg with the
|
||||||
|
|
|
@ -9,7 +9,7 @@ connection, but modified to utilize wolfSSL to establish a TLS 1.2 connection.
|
||||||
In general, the naming convention of these files mean that if a file is named
|
In general, the naming convention of these files mean that if a file is named
|
||||||
in the form `X-Y.c`, then it's a copy of `X.c` intended to demonstrate Y. The
|
in the form `X-Y.c`, then it's a copy of `X.c` intended to demonstrate Y. The
|
||||||
exceptions being `server-tls.c` and `client-tls.c`, as noted above.
|
exceptions being `server-tls.c` and `client-tls.c`, as noted above.
|
||||||
Furthermore, the files is formated such that using a diff tool such as
|
Furthermore, the files is formatted such that using a diff tool such as
|
||||||
`vimdiff` to compare `X-Y.c` to `X.c` should highlight only the relevant
|
`vimdiff` to compare `X-Y.c` to `X.c` should highlight only the relevant
|
||||||
changes required to convert `X.c` into `X-Y.c`
|
changes required to convert `X.c` into `X-Y.c`
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ socket [...]" block, add these lines:
|
||||||
servAddr.sin_addr.s_addr = INADDR_ANY; /* from anywhere */
|
servAddr.sin_addr.s_addr = INADDR_ANY; /* from anywhere */
|
||||||
```
|
```
|
||||||
|
|
||||||
That "Initialize the sever address sturuct wit zeros" step is not strictly
|
That "Initialize the server address struct wit zeros" step is not strictly
|
||||||
necessary, but it's usually a good idea, and it doesn't complicate the example
|
necessary, but it's usually a good idea, and it doesn't complicate the example
|
||||||
too much.
|
too much.
|
||||||
|
|
||||||
|
@ -500,7 +500,7 @@ Now we can fill out the address of the server we want to connect to. After the
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Once more, this is quite similar to server code. This time, hovewer, rather
|
Once more, this is quite similar to server code. This time, however, rather
|
||||||
than setting `servAddr.sin_addr.s_addr` to `INADDR_ANY`, we're going to make a
|
than setting `servAddr.sin_addr.s_addr` to `INADDR_ANY`, we're going to make a
|
||||||
call to `inet_pton()` to read `argv[1]` as an IPv4 address and assign it to the
|
call to `inet_pton()` to read `argv[1]` as an IPv4 address and assign it to the
|
||||||
right place in `servAddr`. If `argv[1]` is well formed, `inet_pton()` will
|
right place in `servAddr`. If `argv[1]` is well formed, `inet_pton()` will
|
||||||
|
@ -1053,7 +1053,7 @@ with zeros" block is a good place. After this, add these lines:
|
||||||
|
|
||||||
And just like that wolfSSL will use our functions to send and receive data. Now
|
And just like that wolfSSL will use our functions to send and receive data. Now
|
||||||
when this program is run we should see a number of "my\_OISend: sent" and
|
when this program is run we should see a number of "my\_OISend: sent" and
|
||||||
"my\_IORecv: recieved" lines in our output.
|
"my\_IORecv: received" lines in our output.
|
||||||
|
|
||||||
#### <a name="run-callback">Running</a>
|
#### <a name="run-callback">Running</a>
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ const char* cert = "../certs/ca-cert.pem";
|
||||||
*/
|
*/
|
||||||
int ClientGreet(int sock, WOLFSSL* ssl)
|
int ClientGreet(int sock, WOLFSSL* ssl)
|
||||||
{
|
{
|
||||||
/* data to send to the server, data recieved from the server */
|
/* data to send to the server, data received from the server */
|
||||||
char sendBuff[MAXDATASIZE], rcvBuff[MAXDATASIZE] = {0};
|
char sendBuff[MAXDATASIZE], rcvBuff[MAXDATASIZE] = {0};
|
||||||
int ret = 0; /* variable for error checking */
|
int ret = 0; /* variable for error checking */
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ int ClientGreet(int sock, WOLFSSL* ssl)
|
||||||
printf("Read error. Error: %i\n", ret);
|
printf("Read error. Error: %i\n", ret);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
printf("Recieved: \t%s\n", rcvBuff);
|
printf("Received: \t%s\n", rcvBuff);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -85,9 +85,9 @@ static void CaCb(unsigned char* der, int sz, int type)
|
||||||
int ret;
|
int ret;
|
||||||
int sz = sizeof(serial);
|
int sz = sizeof(serial);
|
||||||
|
|
||||||
WOLFSSL_X509_NAME* issureName = wolfSSL_X509_get_issuer_name(x509);
|
WOLFSSL_X509_NAME* issuerName = wolfSSL_X509_get_issuer_name(x509);
|
||||||
WOLFSSL_X509_NAME* subjectName = wolfSSL_X509_get_subject_name(x509);
|
WOLFSSL_X509_NAME* subjectName = wolfSSL_X509_get_subject_name(x509);
|
||||||
issuer = wolfSSL_X509_NAME_oneline(issureName, 0, 0);
|
issuer = wolfSSL_X509_NAME_oneline(issuerName, 0, 0);
|
||||||
subject = wolfSSL_X509_NAME_oneline(subjectName, 0, 0);
|
subject = wolfSSL_X509_NAME_oneline(subjectName, 0, 0);
|
||||||
|
|
||||||
printf("\tIssuer : %s\n\tSubject: %s\n", issuer, subject);
|
printf("\tIssuer : %s\n\tSubject: %s\n", issuer, subject);
|
||||||
|
@ -131,7 +131,7 @@ int Security(int sock)
|
||||||
|
|
||||||
wolfSSL_Init(); /* initialize wolfSSL */
|
wolfSSL_Init(); /* initialize wolfSSL */
|
||||||
|
|
||||||
/* create and initiLize WOLFSSL_CTX structure */
|
/* create and initialize WOLFSSL_CTX structure */
|
||||||
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method())) == NULL) {
|
if ((ctx = wolfSSL_CTX_new(wolfTLSv1_2_client_method())) == NULL) {
|
||||||
printf("SSL_CTX_new error.\n");
|
printf("SSL_CTX_new error.\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
|
@ -114,7 +114,7 @@ typedef struct SSLConnCtx {
|
||||||
/* Total time handling resumed connections. */
|
/* Total time handling resumed connections. */
|
||||||
double resumeTime;
|
double resumeTime;
|
||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||||
/* Total time handling aynchronous operations. */
|
/* Total time handling asynchronous operations. */
|
||||||
double asyncTime;
|
double asyncTime;
|
||||||
#endif
|
#endif
|
||||||
/* Total time handling reading. */
|
/* Total time handling reading. */
|
||||||
|
@ -738,7 +738,7 @@ static void WolfSSLCtx_Final(WOLFSSL_CTX* ctx)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a socket to talf to server on and connect.
|
/* Create a socket to talk to server on and connect.
|
||||||
*
|
*
|
||||||
* port The port the server is listening on.
|
* port The port the server is listening on.
|
||||||
* socketfd The connected socket.
|
* socketfd The connected socket.
|
||||||
|
|
|
@ -117,7 +117,7 @@ typedef struct SSLConn_CTX {
|
||||||
/* Total time handling accept - resumed connections. */
|
/* Total time handling accept - resumed connections. */
|
||||||
double resumeTime;
|
double resumeTime;
|
||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||||
/* Total time handling aynchronous operations. */
|
/* Total time handling asynchronous operations. */
|
||||||
double asyncTime;
|
double asyncTime;
|
||||||
#endif
|
#endif
|
||||||
/* Total time handling reading. */
|
/* Total time handling reading. */
|
||||||
|
|
|
@ -134,7 +134,7 @@ typedef struct SSLConn_CTX {
|
||||||
/* Total time handling accepts - resumed connections. */
|
/* Total time handling accepts - resumed connections. */
|
||||||
double resumeTime;
|
double resumeTime;
|
||||||
#ifdef WOLFSSL_ASYNC_CRYPT
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
||||||
/* Total time handling aynchronous operations. */
|
/* Total time handling asynchronous operations. */
|
||||||
double asyncTime;
|
double asyncTime;
|
||||||
#endif
|
#endif
|
||||||
/* Total time handling reading. */
|
/* Total time handling reading. */
|
||||||
|
@ -1228,7 +1228,7 @@ int main(int argc, char* argv[])
|
||||||
for (i = 0; i < numThreads; i++) {
|
for (i = 0; i < numThreads; i++) {
|
||||||
if (pthread_create(&sslConnCtx->threadData[i].thread_id, NULL,
|
if (pthread_create(&sslConnCtx->threadData[i].thread_id, NULL,
|
||||||
ThreadHandler, &sslConnCtx->threadData[i]) < 0) {
|
ThreadHandler, &sslConnCtx->threadData[i]) < 0) {
|
||||||
perror("ERRROR: could not create thread");
|
perror("ERROR: could not create thread");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1249,4 +1249,3 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue