mirror of https://github.com/wolfSSL/wolfssl.git
minor fixes
parent
12d3f94c98
commit
1a291870a3
|
@ -24,7 +24,8 @@ endif
|
||||||
|
|
||||||
OBJS:=$(WOLFSSL_BUILD)/main.o $(WOLFSSL_BUILD)/client-tls13.o
|
OBJS:=$(WOLFSSL_BUILD)/main.o $(WOLFSSL_BUILD)/client-tls13.o
|
||||||
|
|
||||||
.PHONY: all clean help
|
default: all
|
||||||
|
.PHONY: all clean help
|
||||||
|
|
||||||
define run-help =
|
define run-help =
|
||||||
echo "Run 'make TARGET* OPTION*'"
|
echo "Run 'make TARGET* OPTION*'"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* client-tls13.c
|
/* client-tls13.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
* Copyright (C) 2006-2022 wolfSSL Inc.
|
||||||
*
|
*
|
||||||
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
||||||
*
|
*
|
||||||
|
@ -20,33 +20,24 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* C Standard Library */
|
/* C Standard Library */
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* POSIX Library */
|
/* POSIX Library */
|
||||||
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* wolfSSL Library */
|
/* wolfSSL Library */
|
||||||
|
|
||||||
#include <wolfssl/options.h>
|
#include <wolfssl/options.h>
|
||||||
#include <wolfssl/ssl.h>
|
#include <wolfssl/ssl.h>
|
||||||
#include <wolfssl/wolfio.h>
|
#include <wolfssl/wolfio.h>
|
||||||
#include <wolfssl/wolfcrypt/port/iotsafe/iotsafe.h>
|
#include <wolfssl/wolfcrypt/port/iotsafe/iotsafe.h>
|
||||||
#include <wolfssl/error-ssl.h>
|
#include <wolfssl/error-ssl.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* IoTSAFE Certificate slots */
|
/* IoTSAFE Certificate slots */
|
||||||
|
|
||||||
/* File Slot '02' is pre-provisioned with
|
/* File Slot '02' is pre-provisioned with
|
||||||
|
@ -84,21 +75,16 @@
|
||||||
#define PEER_CERT_ID 0x05
|
#define PEER_CERT_ID 0x05
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Function Declarations */
|
/* Function Declarations */
|
||||||
|
extern int client_loop(const char *peer_ip, const char *peer_name,
|
||||||
extern int client_loop(const char *peer_ip, const char *peer_name, const char *peer_port, const char *temperature);
|
const char *peer_port, const char *temperature);
|
||||||
|
|
||||||
#if defined(USE_SECRET_CALLBACK)
|
#if defined(USE_SECRET_CALLBACK)
|
||||||
|
static int Tls13SecretCallback(WOLFSSL* ssl, int id, const unsigned char* secret,
|
||||||
static int Tls13SecretCallback(WOLFSSL* ssl, int id, const unsigned char* secret, int secretSz, void* ctx);
|
int secretSz, void* ctx);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Function Definitions */
|
/* Function Definitions */
|
||||||
|
|
||||||
#if defined(USE_SECRET_CALLBACK)
|
#if defined(USE_SECRET_CALLBACK)
|
||||||
|
|
||||||
#ifndef WOLFSSL_SSLKEYLOGFILE_OUTPUT
|
#ifndef WOLFSSL_SSLKEYLOGFILE_OUTPUT
|
||||||
|
@ -157,12 +143,10 @@ static int Tls13SecretCallback(WOLFSSL* ssl, int id, const unsigned char* secret
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* USE_SECRET_CALLBACK */
|
#endif /* USE_SECRET_CALLBACK */
|
||||||
|
|
||||||
|
int client_loop(const char *peer_ip, const char *peer_name,
|
||||||
|
const char *peer_port, const char *temperature)
|
||||||
int client_loop(const char *peer_ip, const char *peer_name, const char *peer_port, const char *temperature)
|
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* main.c
|
/* main.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2020 wolfSSL Inc.
|
* Copyright (C) 2006-2022 wolfSSL Inc.
|
||||||
*
|
*
|
||||||
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
* This file is part of wolfSSL. (formerly known as CyaSSL)
|
||||||
*
|
*
|
||||||
|
@ -24,15 +24,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* C Standard Library */
|
/* C Standard Library */
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* POSIX Library */
|
/* POSIX Library */
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -40,40 +36,32 @@
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* wolfSSL Library */
|
/* wolfSSL Library */
|
||||||
|
|
||||||
#include <wolfssl/options.h>
|
#include <wolfssl/options.h>
|
||||||
#include <wolfssl/wolfcrypt/settings.h>
|
#include <wolfssl/wolfcrypt/settings.h>
|
||||||
#include <wolfssl/ssl.h>
|
#include <wolfssl/ssl.h>
|
||||||
#include <wolfssl/wolfcrypt/random.h>
|
#include <wolfssl/wolfcrypt/random.h>
|
||||||
#include <wolfssl/wolfcrypt/port/iotsafe/iotsafe.h>
|
#include <wolfssl/wolfcrypt/port/iotsafe/iotsafe.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Variable Declarations */
|
/* Variable Declarations */
|
||||||
|
|
||||||
static int serial_fd = -1;
|
static int serial_fd = -1;
|
||||||
|
|
||||||
/* Function Declarations */
|
/* Function Declarations */
|
||||||
|
extern int client_loop(const char *peer_ip, const char *peer_name,
|
||||||
extern int client_loop(const char *peer_ip, const char *peer_name, const char *peer_port, const char *temperature);
|
const char *peer_port, const char *temperature);
|
||||||
|
#ifdef DEBUG_UART_IO
|
||||||
static void print_buffer_hex(const char *buf, int len);
|
static void print_buffer_hex(const char *buf, int len);
|
||||||
static void print_buffer_char(const char *buf, int len);
|
static void print_buffer_char(const char *buf, int len);
|
||||||
|
#endif
|
||||||
static int usart_init(const char *dev_name, int *fd);
|
static int usart_init(const char *dev_name, int *fd);
|
||||||
static int usart_clean(int fd);
|
static int usart_clean(int fd);
|
||||||
static int usart_read(char *buf, int len);
|
static int usart_read(char *buf, int len);
|
||||||
static int usart_write(const char *buf, int len);
|
static int usart_write(const char *buf, int len);
|
||||||
|
|
||||||
static void show_usage(const char *program);
|
static void show_usage(const char *program);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Function Definitions */
|
/* Function Definitions */
|
||||||
|
#ifdef DEBUG_UART_IO
|
||||||
static void print_buffer_hex(const char *buf, int len)
|
static void print_buffer_hex(const char *buf, int len)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
|
@ -85,6 +73,7 @@ static void print_buffer_char(const char *buf, int len)
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
printf("%c", *(buf++));
|
printf("%c", *(buf++));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int usart_init(const char *dev_name, int *fd)
|
static int usart_init(const char *dev_name, int *fd)
|
||||||
{
|
{
|
||||||
|
@ -134,21 +123,18 @@ static int usart_read(char *buf, int len)
|
||||||
char c;
|
char c;
|
||||||
memset(buf, 0, len);
|
memset(buf, 0, len);
|
||||||
|
|
||||||
|
/* Read 1 byte at one time until *buf is full or a POSIX read error like
|
||||||
/* Read 1 byte at one time until *buf is full or a POSIX read error like timeout occurs. */
|
* timeout occurs. */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ret = read(serial_fd, &c, 1U);
|
ret = read(serial_fd, &c, 1U);
|
||||||
if (ret > 0)
|
if (ret > 0) {
|
||||||
{
|
|
||||||
buf[i++] = c;
|
buf[i++] = c;
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (i < len && ret > 0);
|
} while (i < len && ret > 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef DEBUG_UART_IO
|
#ifdef DEBUG_UART_IO
|
||||||
printf("UART Read Actual : %d bytes\n", i);
|
printf("UART Read Actual : %d bytes\n", i);
|
||||||
#ifdef DEBUG_UART_IO_EXTRA_VERBOSE
|
#ifdef DEBUG_UART_IO_EXTRA_VERBOSE
|
||||||
|
@ -196,7 +182,8 @@ static int usart_write(const char *buf, int len)
|
||||||
static void show_usage(const char *program)
|
static void show_usage(const char *program)
|
||||||
{
|
{
|
||||||
printf("\nUsage:\n");
|
printf("\nUsage:\n");
|
||||||
printf("\t%s -ip SERVER_IP_ADDRESS -h SERVER_HOST_NAME -p PORT_NUMBER -t TEMPERATURE -d DEVICE_FILE_PATH\n", program);
|
printf("\t%s -ip SERVER_IP_ADDRESS -h SERVER_HOST_NAME -p PORT_NUMBER "
|
||||||
|
"-t TEMPERATURE -d DEVICE_FILE_PATH\n", program);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("\t-ip <server IPv4 address eg: 127.0.0.1>\n");
|
printf("\t-ip <server IPv4 address eg: 127.0.0.1>\n");
|
||||||
printf("\t-h <server name eg: xxx.amazon.com>\n");
|
printf("\t-h <server name eg: xxx.amazon.com>\n");
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* iotsafe.c
|
/* iotsafe.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2021 wolfSSL Inc.
|
* Copyright (C) 2006-2022 wolfSSL Inc.
|
||||||
*
|
*
|
||||||
* This file is part of wolfSSL.
|
* This file is part of wolfSSL.
|
||||||
*
|
*
|
||||||
|
@ -241,7 +241,7 @@ static int iotsafe_cmd_add_tlv_ex(char *cmd, byte tag, uint16_t len,
|
||||||
char *len_csim_str = (cmd + AT_CSIM_CMD_SIZE - 5);
|
char *len_csim_str = (cmd + AT_CSIM_CMD_SIZE - 5);
|
||||||
word32 cmdlen;
|
word32 cmdlen;
|
||||||
|
|
||||||
cmdlen = XSTRLEN(cmd);
|
cmdlen = (word32)XSTRLEN(cmd);
|
||||||
if (cmdlen < AT_CSIM_CMD_SIZE) {
|
if (cmdlen < AT_CSIM_CMD_SIZE) {
|
||||||
return BAD_FUNC_ARG;
|
return BAD_FUNC_ARG;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue