Skip to content

Commit 40eb265

Browse files
authored
Merge pull request #179 from haydenroche5/visual_studio_improvements
2 parents 7db0c35 + 8523257 commit 40eb265

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+2164
-1155
lines changed

README.md

Lines changed: 3 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -150,114 +150,10 @@ as described earlier.
150150
See the scripts directory for integration tests with other applications (e.g.
151151
OpenSSH, stunnel, etc.).
152152

153-
## Building on Windows
153+
## Windows
154154

155-
The `wolfEngine.sln` solution supplied in the root of the wolfEngine project
156-
expects the following directory structure:
157-
158-
```
159-
.
160-
├── openssl
161-
├── wolfEngine
162-
└── wolfssl
163-
```
164-
165-
### OpenSSL
166-
167-
Follow the instructions in the OpenSSL `INSTALL` file. The list of commands to
168-
run are:
169-
```
170-
$ perl Configure { VC-WIN32 | VC-WIN64A | VC-WIN64I | VC-CE }
171-
$ nmake clean # This command needs to be run if OpenSSL has previously been
172-
built in this directory with a different configuration.
173-
$ nmake
174-
```
175-
176-
### wolfSSL
177-
178-
Compile wolfSSL using one of the solution projects available in the
179-
project (`wolfssl.sln` or `wolfssl64.sln`). The following is a list of defines
180-
that are generated when using the configure script. You do not need to turn all
181-
of them on but this list will provide full functionality. For ease of use, it is
182-
recommended to add the desired defines to the `user_settings.h` file used in
183-
the chosen wolfSSL Visual Studio solution. Please make sure to update the
184-
defines in the wolfEngine `user_settings.h` file to match the defines used to
185-
compile wolfSSL.
186-
187-
```
188-
/* Settings generated by the configure script when compiling for wolfEngine */
189-
#define HAVE_AES_ECB
190-
#define WC_RSA_NO_PADDING
191-
#define WOLFSSL_PUBLIC_MP
192-
#define ECC_MIN_KEY_SZ 192
193-
#define WOLFSSL_PSS_LONG_SALT
194-
#define WOLFSSL_PSS_SALT_LEN_DISCOVER
195-
#define WOLFSSL_TLS13
196-
#define HAVE_TLS_EXTENSIONS
197-
#define HAVE_SUPPORTED_CURVES
198-
#define HAVE_FFDHE_2048
199-
#define HAVE_THREAD_LS
200-
#define TFM_TIMING_RESISTANT
201-
#define ECC_TIMING_RESISTANT
202-
#define WC_RSA_BLINDING
203-
#define HAVE_AESCCM
204-
#define WOLFSSL_AES_COUNTER
205-
#define WOLFSSL_AES_DIRECT
206-
#define WOLFSSL_SHA224
207-
#define WOLFSSL_SHA512
208-
#define WOLFSSL_SHA384
209-
#define WOLFSSL_KEY_GEN
210-
#define HAVE_HKDF
211-
#define HAVE_X963_KDF
212-
#define NO_DSA
213-
#define HAVE_ECC
214-
#define TFM_ECC256
215-
#define ECC_SHAMIR
216-
#define WC_RSA_PSS
217-
#define WOLFSSL_BASE64_ENCODE
218-
#define NO_RC4
219-
#define WOLFSSL_CMAC
220-
#define NO_HC128
221-
#define NO_RABBIT
222-
#define WOLFSSL_SHA3
223-
#define WOLFSSL_SHAKE256
224-
#define HAVE_POLY1305
225-
#define HAVE_ONE_TIME_AUTH
226-
#define HAVE_CHACHA
227-
#define HAVE_HASHDRBG
228-
#define HAVE_EXTENDED_MASTER
229-
#define HAVE_ENCRYPT_THEN_MAC
230-
#define NO_PSK
231-
#define NO_MD4
232-
#define NO_PWDBASED
233-
#define USE_FAST_MATH
234-
#define WC_NO_ASYNC_THREADING
235-
#define HAVE_DH_DEFAULT_PARAMS
236-
#define GCM_TABLE_4BIT
237-
#define HAVE_AESGCM
238-
#define HAVE_WC_INTROSPECTION
239-
#define OPENSSL_COEXIST
240-
#define NO_OLD_RNGNAME
241-
#define NO_OLD_WC_NAMES
242-
#define NO_OLD_SSL_NAMES
243-
#define NO_OLD_SHA_NAMES
244-
#define NO_OLD_MD5_NAME
245-
```
246-
247-
### wolfEngine
248-
249-
It is enough to compile the wolfEngine solution to generate the DLL file.
250-
Please make sure that you have updated the `user_settings.h` header to match
251-
the defines used to compile wolfSSL. The `test` project in the wolfEngine
252-
solution compiles an executable file that is dynamically linked to the
253-
wolfEngine and OpenSSL libraries. The `test` solution copies the OpenSSL DLL
254-
files into the output directory. If you want to skip this step and use system
255-
supplied versions of OpenSSL, delete the command under:
256-
257-
```
258-
test Properties -> Configuration Properties -> Build Events -> Post-Build Event
259-
-> Command Line
260-
```
155+
Refer to `windows/README.md` for instructions for building wolfEngine using
156+
Visual Studio.
261157

262158
## Examples
263159

test/test.vcxproj

Lines changed: 0 additions & 381 deletions
This file was deleted.

test/test.vcxproj.filters

Lines changed: 0 additions & 106 deletions
This file was deleted.

test/test.vcxproj.user

Lines changed: 0 additions & 47 deletions
This file was deleted.

windows/README.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Building on Windows
2+
3+
wolfEngine has Visual Studio support for FIPS 140-2, FIPS Ready, and non-FIPS
4+
builds. All expect the following directory structure:
5+
6+
```
7+
.
8+
├── openssl
9+
├── wolfEngine
10+
└── wolfssl
11+
```
12+
13+
The build will not work unless the directories are named as above.
14+
15+
## OpenSSL
16+
17+
Follow the instructions in the OpenSSL `INSTALL` file. The list of commands to
18+
run are:
19+
20+
```
21+
$ perl Configure { VC-WIN32 | VC-WIN64A | VC-WIN64I | VC-CE }
22+
$ nmake clean # This command needs to be run if OpenSSL has previously been
23+
built in this directory with a different configuration.
24+
$ nmake
25+
```
26+
27+
## wolfSSL
28+
29+
The wolfSSL FIPS module performs an integrity check over the code and read only
30+
data contents of itself during the FIPS self-test. This requires that the
31+
module be assembled in a specific order, with the object files wolfcrypt_first.o
32+
and wolfcrypt_last.o marking the beginning and end of the FIPS module,
33+
respectively. The only way we have found to reliably ensure this ordering on
34+
Windows is by building wolfSSL as a DLL. As such, even static builds of
35+
wolfEngine (i.e. the "Debug" and "Release" configurations) will use wolfSSL as a
36+
DLL. All wolfEngine Visual Studio configurations also use OpenSSL as a DLL.
37+
38+
### FIPS 140-2
39+
40+
First, replace the contents of `IDE\WIN10\user_settings.h` in wolfSSL with the
41+
contents of `windows\fips_140_2\user_settings.h` from wolfEngine. Then, compile
42+
wolfSSL using `IDE\WIN10\wolfssl-fips.sln`.
43+
44+
### FIPS Ready
45+
46+
First, replace the contents of `IDE\WIN10\user_settings.h` in wolfSSL with the
47+
contents of `windows\fips_ready\user_settings.h` from wolfEngine. Then, compile
48+
wolfSSL using `IDE\WIN10\wolfssl-fips.sln`.
49+
50+
### Non-FIPS
51+
52+
First, replace the contents of `IDE\WIN\user_settings.h` in wolfSSL with the
53+
contents of `windows\non_fips\user_settings.h` from wolfEngine. Then, compile
54+
wolfSSL using `wolfssl64.sln`.
55+
56+
## wolfEngine
57+
58+
The wolfEngine "test" project copies the OpenSSL and wolfSSL DLLs into the test
59+
output directory. If you want to skip the OpenSSL step and use system supplied
60+
versions of OpenSSL, delete the OpenSSL DLL copy command under the test
61+
project's properties:
62+
63+
```
64+
Properties -> Configuration Properties -> Build Events -> Post-Build Event ->
65+
Command Line
66+
```
67+
68+
There is currently no official support for using OpenSSL as a static library
69+
with wolfEngine.
70+
71+
### FIPS 140-2
72+
73+
Build wolfEngine using `windows\wolfEngine.sln`. Select one of the 4 FIPS 140-2
74+
configurations (e.g. DLL Debug FIPS 140-2). Run the test suite by right-clicking
75+
on the "test" project in the Solution Explorer > Debug > Start New Instance. You
76+
are likely to encounter this error message:
77+
78+
```
79+
in FIPS callback, ok = 0, err = -203
80+
message = In Core Integrity check FIPS error
81+
hash = 550122FD59F12AFA94F1B0D95AB361FF03E3EB8708C68974C36D6571524B675C
82+
In core integrity hash check failure, copy above hash
83+
into verifyCore[] in wolfSSL's (NOT wolfEngine) fips_test.c and rebuild
84+
ERR: Failed to find engine!
85+
```
86+
87+
As mentioned earlier, part of wolfSSL's FIPS self-test is an integrity check
88+
of the FIPS module. At startup, the self-test computes an HMAC of the code and
89+
read-only data of the FIPS module and compares the result to an expected value
90+
compiled into the library. If these don't match, the FIPS module enters an error
91+
state and cannot be used. The wolfEngine test program will print the above error
92+
message in this case. If this happens, you should take the hash value printed
93+
out and replace the `verifyCore` value in wolfSSL's `wolfcrypt\src\fips_test.c`
94+
with it. Rebuild wolfSSL, rebuild wolfEngine, and run the wolfEngine tests
95+
again. The integrity check should pass this time.
96+
97+
### FIPS Ready
98+
99+
Build wolfEngine using `windows\wolfEngine.sln`. Select one of the 4 FIPS Ready
100+
configurations (e.g. DLL Debug FIPS Ready). Run the test suite by right-clicking
101+
on the "test" project in the Solution Explorer > Debug > Start New Instance. The
102+
FIPS self-test noted above for FIPS 140-2 applies to FIPS Ready, too, so you
103+
will need to update the expected hash value accordingly.
104+
105+
### Non-FIPS
106+
107+
Build wolfEngine using `windows\wolfEngine.sln`. Select one of the 4 non-FIPS
108+
configurations (e.g. DLL Debug Non-FIPS) Run the test suite by right-clicking on
109+
the "test" project in the Solution Explorer > Debug > Start New Instance.
110+
111+
# Development
112+
113+
The build options for the various configurations are all held in property sheets
114+
in the `windows\props\` directory. If you need to add a new build option (e.g.
115+
a macro or compiler option), you should add it to the most general property
116+
sheet possible. For example, if you are adding a compiler option that should be
117+
applied to all debug configurations, add it to debug.props. If you are adding a
118+
macro that should only be applied when building the test project with wolfSSL
119+
FIPS (Ready or 140-2) and a debug configuration, add it to
120+
debug_fips_test.props. Do NOT add properties directly to wolfEngine.vcxproj or
121+
test.vcxproj unless absolutely necessary, but this will likely never be the
122+
case.

0 commit comments

Comments
 (0)