Added missing `string.h` for `strcasestr`.
parent
b9b85d8efb
commit
894059f675
|
@ -23,6 +23,11 @@
|
|||
#define BTLE_MSG_MAX_SIZE 1024
|
||||
#define BTLE_BLOCK_SIZE 16
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <string.h> /* for strcasestr */
|
||||
|
||||
#define EXIT_STRING "EXIT"
|
||||
|
||||
typedef enum {
|
||||
BTLE_PKT_TYPE_NULL,
|
||||
BTLE_PKT_TYPE_KEY,
|
||||
|
|
|
@ -19,17 +19,19 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "../btle-sim.h"
|
||||
|
||||
#ifndef WOLFSSL_USER_SETTINGS
|
||||
#include <wolfssl/options.h>
|
||||
#endif
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
#include <wolfssl/wolfcrypt/wc_port.h>
|
||||
#include <wolfssl/wolfcrypt/ecc.h>
|
||||
#include "../btle-sim.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int ret;
|
||||
int ret = 0;
|
||||
#ifdef HAVE_ECC_ENCRYPT
|
||||
WC_RNG rng;
|
||||
ecEncCtx* cliCtx = NULL;
|
||||
void* devCtx = NULL;
|
||||
|
@ -153,7 +155,10 @@ int main(int argc, char** argv)
|
|||
/* get message to send */
|
||||
printf("Enter text to send:\n");
|
||||
plainSz = sizeof(plain)-1;
|
||||
fgets((char*)plain, plainSz, stdin);
|
||||
if (fgets((char*)plain, plainSz, stdin) == NULL) {
|
||||
printf("stdin get failed\n");
|
||||
goto cleanup;
|
||||
}
|
||||
plainSz = strlen((char*)plain);
|
||||
/* pad message at 16 bytes for AES block size */
|
||||
ret = btle_msg_pad(plain, (int*)&plainSz, devCtx);
|
||||
|
@ -196,7 +201,7 @@ int main(int argc, char** argv)
|
|||
printf("Recv %d: %s\n", plainSz, plain);
|
||||
|
||||
/* check for exit flag */
|
||||
if (strcasestr((char*)plain, "EXIT")) {
|
||||
if (strcasestr((char*)plain, EXIT_STRING)) {
|
||||
printf("Exit, closing connection\n");
|
||||
break;
|
||||
}
|
||||
|
@ -216,5 +221,8 @@ cleanup:
|
|||
|
||||
wolfCrypt_Cleanup();
|
||||
|
||||
#else
|
||||
printf("Please compile wolfSSL with --enable-eccencrypt or HAVE_ECC_ENCRYPT\n");
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -19,17 +19,19 @@
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "../btle-sim.h"
|
||||
|
||||
#ifndef WOLFSSL_USER_SETTINGS
|
||||
#include <wolfssl/options.h>
|
||||
#endif
|
||||
#include <wolfssl/wolfcrypt/settings.h>
|
||||
#include <wolfssl/wolfcrypt/wc_port.h>
|
||||
#include <wolfssl/wolfcrypt/ecc.h>
|
||||
#include "../btle-sim.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int ret;
|
||||
int ret = 0;
|
||||
#ifdef HAVE_ECC_ENCRYPT
|
||||
WC_RNG rng;
|
||||
ecEncCtx* srvCtx = NULL;
|
||||
void* devCtx = NULL;
|
||||
|
@ -189,7 +191,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
/* check for exit flag */
|
||||
if (strcasestr((char*)plain, "EXIT")) {
|
||||
if (strcasestr((char*)plain, EXIT_STRING)) {
|
||||
printf("Exit, closing connection\n");
|
||||
break;
|
||||
}
|
||||
|
@ -208,6 +210,8 @@ cleanup:
|
|||
btle_close(devCtx);
|
||||
|
||||
wolfCrypt_Cleanup();
|
||||
|
||||
#else
|
||||
printf("Please compile wolfSSL with --enable-eccencrypt or HAVE_ECC_ENCRYPT\n");
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
* Example TLSv1.3 client over BTLE
|
||||
*/
|
||||
|
||||
#include "../btle-sim.h"
|
||||
|
||||
#ifndef WOLFSSL_USER_SETTINGS
|
||||
#include <wolfssl/options.h>
|
||||
|
@ -31,8 +32,6 @@
|
|||
#include <wolfssl/ssl.h>
|
||||
#include <wolfssl/wolfcrypt/wc_port.h>
|
||||
|
||||
#include "../btle-sim.h"
|
||||
|
||||
#define CERT_FILE "../../certs/client-cert.pem"
|
||||
#define KEY_FILE "../../certs/client-key.pem"
|
||||
#define CA_FILE "../../certs/ca-cert.pem"
|
||||
|
@ -171,7 +170,10 @@ int main(int argc, char** argv)
|
|||
printf("Enter text to send:\n");
|
||||
|
||||
plainSz = sizeof(plain)-1;
|
||||
fgets((char*)plain, plainSz, stdin);
|
||||
if (fgets((char*)plain, plainSz, stdin) == NULL) {
|
||||
printf("stdin get failed\n");
|
||||
goto done;
|
||||
}
|
||||
plainSz = strlen((char*)plain);
|
||||
|
||||
do {
|
||||
|
@ -187,7 +189,7 @@ int main(int argc, char** argv)
|
|||
printf("Read (%d): %s\n", ret, plain);
|
||||
|
||||
/* check for exit flag */
|
||||
if (strcasestr((char*)plain, "EXIT")) {
|
||||
if (strcasestr((char*)plain, EXIT_STRING)) {
|
||||
printf("Exit, closing connection\n");
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
* Example TLS v1.3 server over BTLE
|
||||
*/
|
||||
|
||||
#include "../btle-sim.h"
|
||||
|
||||
#ifndef WOLFSSL_USER_SETTINGS
|
||||
#include <wolfssl/options.h>
|
||||
|
@ -31,8 +32,6 @@
|
|||
#include <wolfssl/ssl.h>
|
||||
#include <wolfssl/wolfcrypt/wc_port.h>
|
||||
|
||||
#include "../btle-sim.h"
|
||||
|
||||
#define CERT_FILE "../../certs/server-cert.pem"
|
||||
#define KEY_FILE "../../certs/server-key.pem"
|
||||
#define CA_FILE "../../certs/client-cert.pem"
|
||||
|
@ -178,7 +177,7 @@ int main(int argc, char** argv)
|
|||
printf("Sent (%d): %s\n", ret, echoBuffer);
|
||||
|
||||
/* check for exit flag */
|
||||
if (strcasestr((char*)echoBuffer, "EXIT")) {
|
||||
if (strcasestr((char*)echoBuffer, EXIT_STRING)) {
|
||||
printf("Exit, closing connection\n");
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue