From 2d67f462471cccfdacb5b4d525caddd068c6b180 Mon Sep 17 00:00:00 2001 From: David Garske Date: Fri, 25 Aug 2017 12:27:07 -0700 Subject: [PATCH] Minor cleanups for the GCC ARM example. Fixed build with DH enabled. Changed random.h to always make sure `CUSTOM_RAND_TYPE` is defined. Added TLS13 option to reference user_settings.h. --- IDE/GCC-ARM/Header/user_settings.h | 5 +++++ IDE/GCC-ARM/Makefile.common | 5 ++++- IDE/GCC-ARM/README.md | 13 ++++++++++--- IDE/GCC-ARM/Source/armtarget.c | 2 ++ wolfssl/wolfcrypt/random.h | 2 +- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/IDE/GCC-ARM/Header/user_settings.h b/IDE/GCC-ARM/Header/user_settings.h index 4629f5dca..03cc0371d 100755 --- a/IDE/GCC-ARM/Header/user_settings.h +++ b/IDE/GCC-ARM/Header/user_settings.h @@ -326,6 +326,11 @@ extern unsigned int custom_rand_generate(void); /* ------------------------------------------------------------------------- */ /* Enable Features */ /* ------------------------------------------------------------------------- */ +#if 0 + #undef WOLFSSL_TLS13 + #define WOLFSSL_TLS13 +#endif + #undef KEEP_PEER_CERT //#define KEEP_PEER_CERT diff --git a/IDE/GCC-ARM/Makefile.common b/IDE/GCC-ARM/Makefile.common index 7b0b2d533..fe7d454db 100755 --- a/IDE/GCC-ARM/Makefile.common +++ b/IDE/GCC-ARM/Makefile.common @@ -31,6 +31,9 @@ LDFLAGS = $(ARCHFLAGS) -Wl,--gc-sections --specs=nano.specs --specs=nosys.specs LDFLAGS += -Wl,-Map=$(BUILD_DIR)/$(BIN).map $(DBGFLAGS) LDFLAGS += -Wl,-ereset_handler +# Math lib for DH +LIBS = -lm + SRC_C += ./Source/armtarget.c SRC_C += $(wildcard ../../src/*.c ../../wolfcrypt/src/*.c ../../wolfcrypt/benchmark/*.c ../../wolfcrypt/test/*.c) FILENAMES_C = $(notdir $(SRC_C)) @@ -69,7 +72,7 @@ $(BUILD_DIR)/%.o: %.c $(BUILD_DIR)/$(BIN).elf: $(OBJS_ASM) $(OBJS_C) @echo "Linking ELF binary: $(notdir $@)" - $(CMD_ECHO) $(LD) $(LDFLAGS) -T$(SRC_LD) -o $@ $^ + $(CMD_ECHO) $(LD) $(LDFLAGS) -T$(SRC_LD) -o $@ $^ $(LIBS) @echo "Generating name list: $(BIN).sym" $(CMD_ECHO) $(NM) -n $@ > $(BUILD_DIR)/$(BIN).sym diff --git a/IDE/GCC-ARM/README.md b/IDE/GCC-ARM/README.md index 8737332a1..27e109e8a 100755 --- a/IDE/GCC-ARM/README.md +++ b/IDE/GCC-ARM/README.md @@ -4,8 +4,8 @@ * All library options are defined in `Header/user_settings.h`. * The memory map is located in the linker file in `linker.ld`. -* Entry point function is `reset_handler` in `retarget.c`. -* The RTC and RNG hardware interface needs implemented for real production applications in `retarget.c` +* Entry point function is `reset_handler` in `armtarget.c`. +* The RTC and RNG hardware interface needs implemented for real production applications in `armtarget.c` ## Building @@ -21,19 +21,26 @@ Example: text data bss dec hex filename 39155 2508 60 41723 a2fb ./Build/WolfCryptBench.elf + + text data bss dec hex filename + 70368 464 36 70868 114d4 ./Build/WolfSSLClient.elf ``` ## Performace Tuning Options * `DEBUG_WOLFSSL`: Undefine this to disable debug logging. +* `NO_ERROR_STRINGS`: Disables error strings to save code space. * `NO_INLINE`: Disabling inline function saves about 1KB, but is slower. * `WOLFSSL_SMALL_STACK`: Enables stack reduction techniques to allocate stack sections over 100 bytes from heap. * `USE_FAST_MATH`: Uses stack based math, which is faster than the heap based math. +* `ALT_ECC_SIZE`: If using fast math and RSA/DH you can define this to reduce your ECC memory consumption. +* `FP_MAX_BITS`: Is the maximum math size (key size * 2). Used only with `USE_FAST_MATH`. +* `ECC_TIMING_RESISTANT`: Enables timing resistance for ECC and uses slightly less memory. * `ECC_SHAMIR`: Doubles heap usage, but slightly faster * `RSA_LOW_MEM`: Half as much memory but twice as slow. Uses Non-CRT method for private key. AES GCM: `GCM_SMALL`, `GCM_WORD32` or `GCM_TABLE`: Tunes performance and flash/memory usage. * `CURVED25519_SMALL`: Enables small versions of Ed/Curve (FE/GE math). * `USE_SLOW_SHA`: Enables smaller/slower version of SHA. * `USE_SLOW_SHA2`: Over twice as small, but 50% slower -* `FP_MAX_BITS`: Is the maximum math size (key size * 2). Used only with `USE_FAST_MATH`. * `USE_CERT_BUFFERS_1024` or `USE_CERT_BUFFERS_2048`: Size of RSA certs / keys to test with. +* `BENCH_EMBEDDED`: Define this if using the wolfCrypt test/benchmark and using a low memory target. diff --git a/IDE/GCC-ARM/Source/armtarget.c b/IDE/GCC-ARM/Source/armtarget.c index 4f0d5c45d..c090f5a7e 100755 --- a/IDE/GCC-ARM/Source/armtarget.c +++ b/IDE/GCC-ARM/Source/armtarget.c @@ -20,6 +20,8 @@ */ #include "user_settings.h" +#include +#include /* for CUSTOM_RAND_TYPE */ #include #include diff --git a/wolfssl/wolfcrypt/random.h b/wolfssl/wolfcrypt/random.h index 13afbafb5..d286f0654 100644 --- a/wolfssl/wolfcrypt/random.h +++ b/wolfssl/wolfcrypt/random.h @@ -50,7 +50,7 @@ #endif -#if defined(CUSTOM_RAND_GENERATE) && !defined(CUSTOM_RAND_TYPE) +#if !defined(CUSTOM_RAND_TYPE) /* To maintain compatibility the default is byte */ #define CUSTOM_RAND_TYPE byte #endif