Add Make file and fix identation

This commit is contained in:
Saksik Remy
2021-12-29 11:45:32 +08:00
parent 4fc2891d5a
commit d11e88298a
2 changed files with 87 additions and 14 deletions

View File

@ -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

View File

@ -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);