From d11e88298a2f834896849b71be995b0400d2149c Mon Sep 17 00:00:00 2001 From: Saksik Remy Date: Wed, 29 Dec 2021 11:45:32 +0800 Subject: [PATCH] Add Make file and fix identation --- IDE/iotsafe-raspberrypi/Makefile | 72 ++++++++++++++++++++++++++++ wolfcrypt/src/port/iotsafe/iotsafe.c | 29 +++++------ 2 files changed, 87 insertions(+), 14 deletions(-) create mode 100644 IDE/iotsafe-raspberrypi/Makefile diff --git a/IDE/iotsafe-raspberrypi/Makefile b/IDE/iotsafe-raspberrypi/Makefile new file mode 100644 index 000000000..667cb061a --- /dev/null +++ b/IDE/iotsafe-raspberrypi/Makefile @@ -0,0 +1,72 @@ +CFLAGS := -g -ggdb -Wall -Wextra -std=c11 +CINCS := -I. -I/usr/local/wolfssl +CLIBS := -L/usr/local/lib +CDEPS := -lc -lg -lm -lwolfssl + +ENABLE_DEBUG_UART_IO := off +ENABLE_DEBUG_UART_IO_EXTRA := off +ENABLE_SECRET_CALLBACK := off + +ifeq ($(ENABLE_DEBUG_UART_IO), on) + CFLAGS+=-DDEBUG_UART_IO +endif + +ifeq ($(ENABLE_DEBUG_UART_IO_EXTRA), on) + CFLAGS+=-DDEBUG_UART_IO -DDEBUG_UART_IO_EXTRA_VERBOSE +endif + +ifeq ($(ENABLE_SECRET_CALLBACK), on) + CFLAGS+=-DUSE_SECRET_CALLBACK +endif + +OBJS:=main.o client-tls13.o + +.PHONY: all clean help + +define run-help = +echo "Run 'make TARGET* OPTION*'" +echo "" +echo "TARGET (specify 0 or more):" +echo " all (default target)" +echo " Build main.bin executable" +echo " main.bin" +echo " Build main.bin executable" +echo " main.o" +echo " Build main.o" +echo " client-tls13.o" +echo " Build client-tls13.o" +echo " clean" +echo " Clean *.o and *.bin" +echo " help" +echo " This help" +echo "" +echo "OPTION (specify 0 or more):" +echo " ENABLE_DEBUG_UART_IO=on|off (default off)" +echo " Enable printing ASCII characters sent and received by the UART" +echo " ENABLE_DEBUG_UART_IO_EXTRA=on|off (default off)" +echo " Enable more printing hex characters sent and received by the UART" +echo " Setting this on implicitly sets ENABLE_DEBUG_UART_IO=on" +echo " ENABLE_SECRET_CALLBACK=on|off (default off)" +echo " Enable secret callback for TLS 1.3 handshaking, which can be useful for wireshark sniffing" +echo "" +echo "Example:" +echo " make all ENABLE_DEBUG_UART_IO_EXTRA=on" +echo "" +endef + +help: + @$(run-help) + +all: main.bin + +main.bin: $(OBJS) + $(CC) $(CFLAGS) $(CINCS) $(CLIBS) -o $@ $^ $(CDEPS) + +main.o: main.c + $(CC) $(CFLAGS) $(CINCS) $(CLIBS) -c -o $@ $^ $(CDEPS) + +client-tls13.o: client-tls13.c + $(CC) $(CFLAGS) $(CINCS) $(CLIBS) -c -o $@ $^ $(CDEPS) + +clean: + rm -f *.o *.bin diff --git a/wolfcrypt/src/port/iotsafe/iotsafe.c b/wolfcrypt/src/port/iotsafe/iotsafe.c index 6b3f8e5e2..5c18cdaba 100644 --- a/wolfcrypt/src/port/iotsafe/iotsafe.c +++ b/wolfcrypt/src/port/iotsafe/iotsafe.c @@ -727,31 +727,32 @@ static int iotsafe_hkdf_extract(byte* prk, const byte* salt, word32 saltLen, char *resp; uint16_t hash_algo = 0; int len; + uint16_t hash_algo_be = 0; WOLFSSL_MSG("Enter iotsafe_hkdf_extract"); switch (digest) { #ifndef NO_SHA256 case WC_SHA256: - hash_algo = (uint16_t)1; - if (ikmLen == 0) { - len = WC_SHA256_DIGEST_SIZE; - } + hash_algo = (uint16_t)1; + if (ikmLen == 0) { + len = WC_SHA256_DIGEST_SIZE; + } break; #endif #ifdef WOLFSSL_SHA384 case WC_SHA384: - hash_algo = (uint16_t)2; - if (ikmLen == 0) { - len = WC_SHA384_DIGEST_SIZE; - } - break; + hash_algo = (uint16_t)2; + if (ikmLen == 0) { + len = WC_SHA384_DIGEST_SIZE; + } + break; #endif #ifdef WOLFSSL_TLS13_SHA512 case WC_SHA512: - hash_algo = (uint16_t)4; - if (ikmLen == 0) { - len = WC_SHA512_DIGEST_SIZE; - } + hash_algo = (uint16_t)4; + if (ikmLen == 0) { + len = WC_SHA512_DIGEST_SIZE; + } break; #endif default: @@ -777,7 +778,7 @@ static int iotsafe_hkdf_extract(byte* prk, const byte* salt, word32 saltLen, printf("\nhash: %d\n", digest); #endif - uint16_t hash_algo_be = XHTONS(hash_algo); + hash_algo_be = XHTONS(hash_algo); iotsafe_cmd_start(csim_cmd, IOTSAFE_CLASS, IOTSAFE_INS_HKDF_EXTRACT, 0, 0); iotsafe_cmd_add_tlv(csim_cmd, IOTSAFE_TAG_SECRET, ikmLen, ikm);