|
| 1 | +# Building wolfEngine |
| 2 | + |
| 3 | +## Getting wolfEngine Source Code |
| 4 | + |
| 5 | +The most recent version of wolfEngine can be obtained directly from wolfSSL Inc. Contact [[email protected]](mailto:[email protected]) for more information. |
| 6 | + |
| 7 | +## wolfEngine Package Structure |
| 8 | + |
| 9 | +The general wolfEngine package is structured as follows: |
| 10 | + |
| 11 | +``` |
| 12 | +certs/ (Test certificates and keys, used with unit tests) |
| 13 | +engine.conf (Example OpenSSL config file using wolfEngine) |
| 14 | +include/ |
| 15 | + wolfengine/ (wolfEngine header files) |
| 16 | +openssl_patches/ |
| 17 | + 1.0.2h/tests/ (patches for OpenSSL 1.0.2h test apps) |
| 18 | + 1.1.1b/tests/ (patches for OpenSSL 1.1.1b test apps) |
| 19 | +scripts/ (wolfEngine test scripts) |
| 20 | +src/ (wolfEngine source files) |
| 21 | +test/ (wolfEngine test files) |
| 22 | +user_settings.h (EXAMPLE user_settings.h) |
| 23 | +``` |
| 24 | +## OpenSSL Version Caveats |
| 25 | + |
| 26 | +Depending on the version of OpenSSL being used with wolfEngine, there are several algorithms support caveats, including: |
| 27 | + |
| 28 | +- SHA-3 support is only available with OpenSSL versions 1.1.1+ |
| 29 | +- EC_KEY_METHOD is only available with OpenSSL versions 1.1.1+ |
| 30 | + |
| 31 | +## Building on *nix |
| 32 | + |
| 33 | +### Building OpenSSL |
| 34 | + |
| 35 | +A pre-installed version of OpenSSL may be used with wolfEngine (barring algorithm caveats above), or OpenSSL can be recompiled for use with wolfEngine. General instructions for compiling OpenSSL on *nix-like platforms will be similar to the following. For complete and comprehensive OpenSSL build instructions, reference the OpenSSL INSTALL file and documentation. |
| 36 | +``` |
| 37 | +git clone https://github.com/openssl/openssl.git |
| 38 | +cd openssl |
| 39 | +./config no-fips -shared |
| 40 | +make |
| 41 | +sudo make install |
| 42 | +``` |
| 43 | + |
| 44 | +### Building wolfSSL |
| 45 | + |
| 46 | +If using a FIPS-validated version of wolfSSL with wolfEngine, follow the build instructions provided with your specific FIPS validated source bundle and Security Policy. In addition to the correct “--enable-fips” configure option, wolfEngine will need wolfSSL to be compiled with “ **WOLFSSL_PUBLIC_MP** ” defined. For example, building the “wolfCrypt Linux FIPSv2” bundle on Linux: |
| 47 | +``` |
| 48 | +cd wolfssl-X.X.X-commercial-fips-linuxv |
| 49 | +./configure **--enable-fips=v2 CFLAGS=”-DWOLFSSL_PUBLIC_MP”** |
| 50 | +make |
| 51 | +./wolfcrypt/test/testwolfcrypt |
| 52 | +< modify fips_test.c using verifyCore hash output from testwolfcrypt |
| 53 | +> |
| 54 | +make |
| 55 | +./wolfcrypt/test/testwolfcrypt |
| 56 | +< all algorithms should PASS > |
| 57 | +sudo make install |
| 58 | +``` |
| 59 | + |
| 60 | +To build non-FIPS wolfSSL for use with wolfEngine: |
| 61 | +``` |
| 62 | +cd wolfssl-X.X.X |
| 63 | +
|
| 64 | +./configure --enable-cmac --enable-keygen --enable-sha --enable-des |
| 65 | +--enable-aesctr --enable-aesccm --enable-x963kdf |
| 66 | +CPPFLAGS="-DHAVE_AES_ECB -DWOLFSSL_AES_DIRECT -DWC_RSA_NO_PADDING |
| 67 | +-DWOLFSSL_PUBLIC_MP -DECC_MIN_KEY_SZ=192 -DWOLFSSL_PSS_LONG_SALT |
| 68 | +-DWOLFSSL_PSS_SALT_LEN_DISCOVER" |
| 69 | +
|
| 70 | +make |
| 71 | +sudo make install |
| 72 | +``` |
| 73 | + |
| 74 | +If cloning wolfSSL from GitHub, you will need to run the `autogen.sh` script before running `./configure`. This will generate the configure script: |
| 75 | +``` |
| 76 | +./autogen.sh |
| 77 | +``` |
| 78 | + |
| 79 | +### Building wolfEngine |
| 80 | +When building wolfEngine on Linux or other *nix-like systems, use the autoconf system. To configure and compile wolfEngine run the following two commands from the wolfEngine root directory: |
| 81 | +``` |
| 82 | +./configure |
| 83 | +make |
| 84 | +``` |
| 85 | + |
| 86 | +If building wolfEngine from GitHub, run autogen.sh before running configure: |
| 87 | +``` |
| 88 | +./autogen.sh |
| 89 | +``` |
| 90 | + |
| 91 | +Any number of build options can be appended to ./configure. For a list of available build options, please reference the “Build Options” section below or run the following command to see a list of available build options to pass to the ./configure script: |
| 92 | +``` |
| 93 | +./configure --help |
| 94 | +``` |
| 95 | + |
| 96 | +wolfEngine will use the system default OpenSSL library installation unless changed with the “--with-openssl” configure option: |
| 97 | +``` |
| 98 | +./configure --with-openssl=/usr/local/ssl |
| 99 | +``` |
| 100 | + |
| 101 | +The custom OpenSSL installation location may also need to be added to your library search path. On Linux, `LD_LIBRARY_PATH` is used: |
| 102 | +``` |
| 103 | +export LD_LIBRARY_PATH=/usr/local/ssl:$LD_LIBRARY_PATH |
| 104 | +``` |
| 105 | + |
| 106 | +To build then install wolfEngine, run: |
| 107 | +``` |
| 108 | +make |
| 109 | +make install |
| 110 | +``` |
| 111 | + |
| 112 | +You may need superuser privileges to install, in which case precede the command with sudo: |
| 113 | +``` |
| 114 | +sudo make install |
| 115 | +``` |
| 116 | + |
| 117 | +To test the build, run the built-in tests from the root wolfEngine directory: |
| 118 | +``` |
| 119 | +./test/unit.test |
| 120 | +``` |
| 121 | + |
| 122 | +Or use autoconf to run the tests: |
| 123 | +``` |
| 124 | +make check |
| 125 | +``` |
| 126 | + |
| 127 | +If you get an error like `error while loading shared libraries: libssl.so.3` then the library cannot be found. Use the `LD_LIBRARY_PATH` environment variable as described in the section above. |
| 128 | + |
| 129 | +## Building on WinCE |
| 130 | + |
| 131 | +For full wolfEngine compatibility, ensure you have the following flags in your `user_settings.h` file for wolfCrypt: |
| 132 | +``` |
| 133 | +#define WOLFSSL_CMAC |
| 134 | +#define WOLFSSL_KEY_GEN |
| 135 | +#undef NO_SHA |
| 136 | +#undef NO_DES |
| 137 | +#define WOLFSSL_AES_COUNTER |
| 138 | +#define HAVE_AESCCM |
| 139 | +#define HAVE_AES_ECB |
| 140 | +#define WOLFSSL_AES_DIRECT |
| 141 | +#define WC_RSA_NO_PADDING |
| 142 | +#define WOLFSSL_PUBLIC_MP |
| 143 | +#define ECC_MIN_KEY_SZ=192 |
| 144 | +``` |
| 145 | + |
| 146 | +Add wolfEngine flags to your `user_settings.h` file depending on which algorithms and features you want to use. You can find a list of wolfEngine user settings flags in the `user_settings.h` file in wolfEngine’s directory. |
| 147 | + |
| 148 | +Build wcecompat, wolfCrypt and OpenSSL for Windows CE, and keep track of their paths. |
| 149 | + |
| 150 | +In the wolfEngine directory, open the sources file and change the OpenSSL, wolfCrypt, and `user_settings.h` paths to the directories you are using. You will need to update the paths in the INCLUDES and TARGETLIBS sections. |
| 151 | + |
| 152 | +Load the wolfEngine project in Visual Studio. Include either `bench.c`, or `unit.h` and `unit.c` depending on if you want to run the benchmark or unit tests. |
| 153 | + |
| 154 | +Build the project, and you will end up with a wolfEngine.exe executable. You can run this executable with ` --help` to see a full list of options. You may need to run it with the `--static` flag to use wolfEngine as a static engine. |
| 155 | + |
| 156 | +## Build Options (./configure Options) |
| 157 | + |
| 158 | +The following are options which may be appended to the `./configure` script to customize how the wolfEngine library is built. |
| 159 | + |
| 160 | +By default, wolfEngine only builds a shared library, with building of a static library disabled. This speeds up build times by a factor of two. Either mode can be explicitly disabled or enabled if desired. |
| 161 | + |
| 162 | +| Option | Default Value | Description | |
| 163 | +| :--------- | :---------------: | :-------------- | |
| 164 | +| --enable-static | **Disabled** | Build static libraries | |
| 165 | +| --enable-shared | Enabled | Build shared libraries | |
| 166 | +| --enable-debug | **Disabled** | Enable wolfEngine debugging support | |
| 167 | +| --enable-coverage | **Disabled** | Build to generate code coverage stats | |
| 168 | +| --enable-usersettings | **Disabled** | Use your own user_settings.h and do not add Makefile CFLAGS | |
| 169 | +| --enable-dynamic-engine | Enabled | Enable loading wolfEngine as a dynamic engine | |
| 170 | +| --enable-singlethreaded | **Disabled** | Enable wolfEngine single threaded | |
| 171 | +| --enable-digest | Enabled | Enable use of wc_Hash API for digesting data | |
| 172 | +| --enable-sha | Enabled | Enable SHA-1 | |
| 173 | +| --enable-sha224 | Enabled | Enable SHA2-224 | |
| 174 | +| --enable-sha256 | Enabled | Enable SHA2-256 | |
| 175 | +| --enable-sha384 | Enabled | Enable SHA2-384 | |
| 176 | +| --enable-sha512 | Enabled | Enable SHA2-512 | |
| 177 | +| --enable-sha3 | Enabled | Enable SHA3 | |
| 178 | +| --enable-sha3-224 | Enabled | Enable SHA3-224 | |
| 179 | +| --enable-sha3-256 | Enabled | Enable SHA3-256 | |
| 180 | +| --enable-sha3-384 | Enabled | Enable SHA3-384 | |
| 181 | +| --enable-sha3-512 | Enabled | Enable SHA3-512 | |
| 182 | +| --enable-cmac | Enabled | Enable CMAC | |
| 183 | +| --enable-hmac | Enabled | Enable HMAC | |
| 184 | +| --enable-des3cbc| Enabled | Enable 3DES-CBC | |
| 185 | +| --enable-aesecb | Enabled | Enable AES-ECB | |
| 186 | +| --enable-aescbc | Enabled | Enable AES-CBC | |
| 187 | +| --enable-aesctr | Enabled | Enable AES-CTR | |
| 188 | +| --enable-aesgcm | **Disabled** | Enable AES-GCM | |
| 189 | +| --enable-aesccm | **Disabled** | Enable AES-CCM | |
| 190 | +| --enable-rand | Enabled | Enable RAND | |
| 191 | +| --enable-rsa | Enabled | Enable RSA | |
| 192 | +| --enable-dh | Enabled | Enable DH | |
| 193 | +| --enable-evp-pkey | Enabled | Enable EVP_PKEY APIs | |
| 194 | +| --enable-ecc | Enabled | Enable ECC | |
| 195 | +| --enable-ec-key | Enabled | Enable ECC using EC_KEY | |
| 196 | +| --enable-ecdsa | Enabled | Enable ECDSA | |
| 197 | +| --enable-ecdh | Enabled | Enable ECDH | |
| 198 | +| --enable-eckg | Enabled | Enable EC Key Generation | |
| 199 | +| --enable-p192 | Enabled | Enable EC Curve P-192 | |
| 200 | +| --enable-p224 | Enabled | Enable EC Curve P-224 | |
| 201 | +| --enable-p256 | Enabled | Enable EC Curve P-256 | |
| 202 | +| --enable-p384 | Enabled | Enable EC Curve P-384 | |
| 203 | +| --enable-p521 | Enabled | Enable EC Curve P-521 | |
| 204 | +| --with-openssl=DIR | | OpenSSL installation location to link against. If not set, use the system default library and include paths. | |
| 205 | + |
| 206 | +## Build Defines |
| 207 | + |
| 208 | +wolfEngine exposes several preprocessor defines that allow users to configure how wolfEngine is built. These are described in the table below. |
| 209 | + |
| 210 | +| Define | Description | |
| 211 | +| :---------------------------------------------- | :-------------- | |
| 212 | +| WOLFENGINE_DEBUG | Build wolfEngine with debug symbols, optimization level, and debug logging. | |
| 213 | +| WE_NO_DYNAMIC_ENGINE | Do not build wolfEngine with dynamic engine support. Dynamic engines are ones that can be loaded into OpenSSL at runtime. | |
| 214 | +| WE_SINGLE_THREADED | Build wolfEngine in single-threaded mode. This removes the need for locking around global resources used internally. | |
| 215 | +| WE_USE_HASH | Enable digest algorithms using the wc_Hash API. | |
| 216 | +| WE_HAVE_SHA1 | Enable SHA-1 digest algorithm. | |
| 217 | +| WE_HAVE_SHA224 | Enable SHA-2 digest algorithm with digest size 224. | |
| 218 | +| WE_HAVE_SHA256 | Enable SHA-2 digest algorithm with digest size 256. | |
| 219 | +| WE_HAVE_SHA384 | Enable SHA-2 digest algorithm with digest size 384. | |
| 220 | +| WE_HAVE_SHA512| Enable SHA-2 digest algorithm with digest size 512. | |
| 221 | +| WE_SHA1_DIRECT | Enable the SHA-1 digest algorithm using the wc_Sha API. Incompatible with WE_USE_HASH. | |
| 222 | +| WE_SHA224_DIRECT | Enable the SHA-2 224 digest algorithm using the wc_Sha224 API. Incompatible with WE_USE_HASH. | |
| 223 | +| WE_SHA256_DIRECT | Enable the SHA-2 256 digest algorithm using the wc_Sha256 API. Incompatible with WE_USE_HASH. | |
| 224 | +| WE_HAVE_SHA3_224 | Enable SHA-3 digest algorithm with digest size 224. Not available in OpenSSL 1.0.2. | |
| 225 | +| WE_HAVE_SHA3_256 | Enable SHA-3 digest algorithm with digest size 256. Not available in OpenSSL 1.0.2. | |
| 226 | +| WE_HAVE_SHA3_384 | Enable SHA-3 digest algorithm with digest size 384. Not available in OpenSSL 1.0.2. | |
| 227 | +| WE_HAVE_SHA3_512 | Enable SHA-3 digest algorithm with digest size 512. Not available in OpenSSL 1.0.2. | |
| 228 | +| WE_HAVE_EVP_PKEY | Enable functionality that uses the EVP_PKEY API. This includes things like RSA, DH, etc. | |
| 229 | +| WE_HAVE_CMAC | Enable CMAC algorithm. | |
| 230 | +| WE_HAVE_HMAC | Enable HMAC algorithm. | |
| 231 | +| WE_HAVE_DES3CBC | Enable DES3-CBC algorithm. | |
| 232 | +|WE_HAVE_AESECB | Enable AES algorithm with ECB mode. | |
| 233 | +| WE_HAVE_AESCBC | Enable AES algorithm with CBC mode. | |
| 234 | +| WE_HAVE_AESCTR | Enable AES algorithm with countee mode. | |
| 235 | +| WE_HAVE_AESGCM | Enable AES algorithm with GCM mode. | |
| 236 | +| WE_HAVE_AESCCM |Enable AES algorithm with CCM mode. | |
| 237 | +| WE_HAVE_RANDOM | Enable wolfCrypt random implementation. | |
| 238 | +| WE_HAVE_RSA | Enable RSA operations (e.g. sign, verify, key generation, etc.). | |
| 239 | +| WE_HAVE_DH | Enable Diffie-Hellman operations (e.g. key generation, shared secret computation, etc.). | |
| 240 | +| WE_HAVE_ECC | Enable support for elliptic curve cryptography. | |
| 241 | +| WE_HAVE_EC_KEY | Enable support for EC_KEY_METHOD. Not available in OpenSSL 1.0.2. | |
| 242 | +| WE_HAVE_ECDSA | Enable ECDSA algorithm. | |
| 243 | +| WE_HAVE_ECDH | Enable EC Diffie-Hellman operations. | |
| 244 | +| WE_HAVE_ECKEYGEN | Enable EC key generation. | |
| 245 | +| WE_HAVE_EC_P192 | Enable EC curve P192. | |
| 246 | +| WE_HAVE_EC_P224 | Enable EC curve P224. | |
| 247 | +| WE_HAVE_EC_P256 | Enable EC curve P256. | |
| 248 | +| WE_HAVE_EC_P384 | Enable EC curve P384. | |
| 249 | +| WE_HAVE_EC_P512 | Enable EC curve P512. | |
| 250 | +| WE_HAVE_DIGEST | Compile code in benchmark program and unit tests for use with digest algorithms. | |
| 251 | +| WOLFENGINE_USER_SETTINGS | Read user-specified defines from user_settings.h. | |
| 252 | + |
0 commit comments