README.md
1# Example Project for GCC ARM
2
3This example is for Cortex M series, but can be adopted for other architectures.
4
5## Design
6
7* All library options are defined in `Header/user_settings.h`.
8* The memory map is located in the linker file in `linker.ld`.
9* Entry point function is `reset_handler` in `armtarget.c`.
10* The RTC and RNG hardware interface needs implemented for real production applications in `armtarget.c`
11
12## Building
13
141. Make sure you have `gcc-arm-none-eabi` installed.
152. Modify the `Makefile.common`:
16 * Use correct toolchain path `TOOLCHAIN`.
17 * Use correct architecture 'ARCHFLAGS'. See [GCC ARM Options](https://gcc.gnu.org/onlinedocs/gcc-4.7.3/gcc/ARM-Options.html) `-mcpu=name`.
18 * Confirm memory map in linker.ld matches your flash/ram or comment out `SRC_LD = -T./linker.ld` in Makefile.common.
193. Use `make` to build the static library (libwolfssl.a), wolfCrypt test/benchmark and wolfSSL TLS client targets as `.elf` and `.hex` in `/Build`.
20
21
22## Building for Raspberry Pi
23
24Example `Makefile.common` changes for Raspberry Pi with Cortex-A53:
25
261. In Makefile.common change `ARCHFLAGS` to `-mcpu=cortex-a53 -mthumb`.
272. Comment out `SRC_LD`, since custom memory map is not applicable.
283. Clear `TOOLCHAIN`, so it will use default `gcc`. Set `TOOLCHAIN = `
294. Comment out `LDFLAGS += --specs=nano.specs` and `LDFLAGS += --specs=nosys.specs` to nosys and nano.
30
31Note: To comment out a line in a Makefile use place `#` in front of line.
32
33## Building for FIPS
34
351. Request evaluation from wolfSSL by emailing fips@wolfss.com.
362. Modify user_settings.h so section for `HAVE_FIPS` is enabled.
373. Use `make`.
384. Run the wolfCrypt test `./Build/WolfCryptTest.elf` to generate the FIPS boundary HASH
39
40Example:
41
42```
43$ Crypt Test
44error test passed!
45base64 test passed!
46base16 test passed!
47asn test passed!
48in my Fips callback, ok = 0, err = -203
49message = In Core Integrity check FIPS error
50hash = F607C7B983D1D283590448A56381DE460F1E83CB02584F4D77B7F2C583A8F5CD
51In core integrity hash check failure, copy above hash
52into verifyCore[] in fips_test.c and rebuild
53SHA test failed!
54 error = -1802
55Crypt Test: Return code -1
56```
57
585. Update the `../../wolfcrypt/src/fips_test.c` array `static const char verifyCore[] = {}` with the correct core hash check.
596. Build again using `make`.
607. Run the wolfCrypt test.
61
62## Building with configure
63
64The configure script in the main project directory can perform a cross-compile
65build with the the gcc-arm-none-eabi tools. Assuming the tools are installed in
66your executable path:
67
68```
69$ ./configure \
70 --host=arm-non-eabi \
71 CC=arm-none-eabi-gcc \
72 AR=arm-none-eabi-ar \
73 STRIP=arm-none-eabi-strip \
74 RANLIB=arm-none-eabi-ranlib \
75 --prefix=/path/to/build/wolfssl-arm \
76 CFLAGS="-march=armv8-a --specs=nosys.specs \
77 -DHAVE_PK_CALLBACKS -DWOLFSSL_USER_IO -DNO_WRITEV" \
78 --disable-filesystem --enable-fastmath \
79 --disable-shared
80$ make
81$ make install
82```
83
84If you are building for a 32-bit architecture, add `-DTIME_T_NOT_64BIT` to the
85list of CFLAGS.
86
87## Example Build Output
88
89```
90make clean && make
91
92 text data bss dec hex filename
93 50076 2508 44 52628 cd94 ./Build/WolfCryptTest.elf
94
95 text data bss dec hex filename
96 39155 2508 60 41723 a2fb ./Build/WolfCryptBench.elf
97
98 text data bss dec hex filename
99 70368 464 36 70868 114d4 ./Build/WolfSSLClient.elf
100```
101
102## Performance Tuning Options
103
104These settings are located in `Header/user_settings.h`.
105
106* `DEBUG_WOLFSSL`: Undefine this to disable debug logging.
107* `NO_ERROR_STRINGS`: Disables error strings to save code space.
108* `NO_INLINE`: Disabling inline function saves about 1KB, but is slower.
109* `WOLFSSL_SMALL_STACK`: Enables stack reduction techniques to allocate stack sections over 100 bytes from heap.
110* `USE_FAST_MATH`: Uses stack based math, which is faster than the heap based math.
111* `ALT_ECC_SIZE`: If using fast math and RSA/DH you can define this to reduce your ECC memory consumption.
112* `FP_MAX_BITS`: Is the maximum math size (key size * 2). Used only with `USE_FAST_MATH`.
113* `ECC_TIMING_RESISTANT`: Enables timing resistance for ECC and uses slightly less memory.
114* `ECC_SHAMIR`: Doubles heap usage, but slightly faster
115* `RSA_LOW_MEM`: Half as much memory but twice as slow. Uses Non-CRT method for private key.
116* AES GCM: `GCM_SMALL`, `GCM_WORD32` or `GCM_TABLE`: Tunes performance and flash/memory usage.
117* `CURVED25519_SMALL`: Enables small versions of Ed/Curve (FE/GE math).
118* `USE_SLOW_SHA`: Enables smaller/slower version of SHA.
119* `USE_SLOW_SHA256`: About 2k smaller and about 25% slower
120* `USE_SLOW_SHA512`: Over twice as small, but 50% slower
121* `USE_CERT_BUFFERS_1024` or `USE_CERT_BUFFERS_2048`: Size of RSA certs / keys to test with.
122* `BENCH_EMBEDDED`: Define this if using the wolfCrypt test/benchmark and using a low memory target.
123* `ECC_USER_CURVES`: Allows user to define curve sizes to enable. Default is 256-bit on. To enable others use `HAVE_ECC192`, `HAVE_ECC224`, etc....
124* `TFM_ARM`, `TFM_SSE2`, `TFM_AVR32`, `TFM_PPC32`, `TFM_MIPS`, `TFM_X86` or `TFM_X86_64`: These are assembly optimizations available with USE_FAST_MATH.
125* Single Precision Math for ARM: See `WOLFSSL_SP`. Optimized math for ARM performance of specific RSA, DH and ECC algorithms.
126