Skip to content

Commit 0e50adc

Browse files
authored
Merge pull request #148 from haydenroche5/misc
Make various improvements.
2 parents a4fa058 + 434f2f8 commit 0e50adc

File tree

7 files changed

+81
-89
lines changed

7 files changed

+81
-89
lines changed

bench.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ BENCH_ALG bench_alg[] = {
11401140
};
11411141
#define BENCH_ALG_COUNT (int)(sizeof(bench_alg) / sizeof(*bench_alg))
11421142

1143-
static void usage()
1143+
static void usage(void)
11441144
{
11451145
printf("\n");
11461146
printf("Usage: bench [options]\n");

engine.conf

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# This is an example of how to use the OpenSSL configuration file to instruct
2+
# OpenSSL to use wolfEngine.
3+
14
openssl_conf = openssl_init
25

36
[openssl_init]
@@ -7,9 +10,11 @@ engines = engine_section
710
wolfSSL = wolfssl_section
811

912
[wolfssl_section]
10-
engine_id = wolfSSL
13+
# If using OpenSSL <= 1.0.2, change engine_id to wolfengine (drop the "lib").
14+
engine_id = libwolfengine
1115
dynamic_path = .libs/libwolfengine.so
12-
init = 0
13-
# Only enable when debugging application - produces large amounts of output
14-
#enable_debug = 1
15-
16+
init = 1
17+
# Use wolfEngine as the default for all algorithms it provides.
18+
default_algorithms = ALL
19+
# Only enable when debugging application - produces large amounts of output.
20+
enable_debug = 1

scripts/interop-tests.sh

Lines changed: 57 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -13,191 +13,179 @@
1313
FAILED=0
1414

1515
if [ -z "${WOLFSSL_DIR}" ] && [ ! -z "${WOLFSSL_INSTALL}" ]; then
16-
printf "WOLFSSL_DIR env needs set to location of wolfSSL\n"
16+
printf "WOLFSSL_DIR environment variable needs to be set to location of\n"
17+
printf "wolfSSL source code.\n"
1718
exit 1
1819
fi
1920

20-
printf "Running wolfEngine cipher suite tests against OpenSSL version 1.1.1b\n"
21-
printf "and OpenSSL version 1.0.2h.\n\n"
22-
21+
printf "Running wolfSSL + OpenSSL (w/ wolfEngine) interoperability tests using\n"
22+
printf "OpenSSL versions 1.1.1 and 1.0.2.\n\n"
2323

2424
PWD=`pwd`
25-
if [ -z ${LOGILE} ]; then
25+
if [ -z ${LOGFILE} ]; then
2626
LOGFILE=${PWD}/log.txt
27+
printf "Using default log file: $LOGFILE.\n\n"
2728
fi
2829
OPENSSL_1_0_2_RES=${PWD}/openssl_1_0_2.res
2930
OPENSSL_1_1_1_RES=${PWD}/openssl_1_1_1.res
3031

31-
32-
33-
printf "Setting up ...\n"
32+
printf "Setting up...\n"
3433
if [ -z "${OPENSSL_1_1_1_INSTALL}" ]; then
35-
printf "\tOPENSSL_1_1_1_INSTALL not set, cloning it..."
34+
printf "\tOPENSSL_1_1_1_INSTALL not set, installing OpenSSL 1.1.1b..."
3635
git clone --depth=1 -b OpenSSL_1_1_1b [email protected]:openssl/openssl.git openssl-1_1_1b &> $LOGFILE
3736
OPENSSL_1_1_1_INSTALL=$PWD/openssl-1_1_1b-install
3837

39-
#Build the library
40-
printf " Building OpenSSL 1.1.1b..."
4138
cd openssl-1_1_1b
4239
./config shared --prefix=$OPENSSL_1_1_1_INSTALL &> $LOGFILE
4340
if [ $? != 0 ]; then
44-
printf "config failed\n"
41+
printf "config failed.\n"
4542
exit 1
4643
fi
4744

4845
make install &> $LOGFILE
4946
if [ $? != 0 ]; then
50-
printf "make failed\n"
47+
printf "make install failed.\n"
5148
exit 1
5249
fi
53-
printf "done\n"
50+
printf "installed.\n"
5451
cd ..
5552
else
56-
printf "\tUsing OpenSSL 1.1.1 installed at $OPENSSL_1_1_1_INSTALL\n"
53+
printf "\tUsing OpenSSL 1.1.1 installed at $OPENSSL_1_1_1_INSTALL.\n"
5754
fi
5855

5956
if [ -z "${OPENSSL_1_0_2_INSTALL}" ]; then
60-
printf "\tOPENSSL_1_0_2_INSTALL not set, cloning it..."
57+
printf "\tOPENSSL_1_0_2_INSTALL not set, installing OpenSSSL 1.0.2h..."
6158
git clone --depth=1 -b OpenSSL_1_0_2h [email protected]:openssl/openssl.git openssl-1_0_2h &> $LOGFILE
6259
OPENSSL_1_0_2_INSTALL=${PWD}/openssl-1_0_2h-install
6360

64-
#Build the library
65-
printf " Building OpenSSL 1.0.2h..."
6661
cd openssl-1_0_2h
6762
./config shared --prefix=$OPENSSL_1_0_2_INSTALL &> $LOGFILE
6863
if [ $? != 0 ]; then
69-
printf "config failed\n"
64+
printf "config failed.\n"
7065
exit 1
7166
fi
7267

7368
make install &> $LOGFILE
7469
if [ $? != 0 ]; then
75-
printf "make failed\n"
70+
printf "make install failed.\n"
7671
exit 1
7772
fi
78-
printf "done\n"
73+
printf "installed.\n"
7974
cd ..
8075
else
81-
printf "\tUsing OpenSSL 1.0.2 installed at $OPENSSL_1_0_2_INSTALL\n"
76+
printf "\tUsing OpenSSL 1.0.2 installed at $OPENSSL_1_0_2_INSTALL.\n"
8277
fi
8378

84-
8579
if [ -z "${WOLFSSL_INSTALL}" ]; then
86-
printf "\tWOLFSSL_INSTALL not set, cloning it..."
80+
printf "\tWOLFSSL_INSTALL not set, installing wolfSSL..."
8781
git clone --depth=1 [email protected]:wolfssl/wolfssl.git &> $LOGFILE
8882
WOLFSSL_INSTALL=$PWD/wolfssl-install
8983

90-
#Build the library
91-
printf " Building wolfSSL..."
9284
cd wolfssl
9385
./autogen.sh &> /dev/null
94-
./configure --enable-cmac --enable-keygen --enable-sha --enable-des3 --enable-aesctr --enable-aesccm CPPFLAGS='-DHAVE_AES_ECB -DWOLFSSL_AES_DIRECT -DWC_RSA_NO_PADDING -DWOLFSSL_PUBLIC_MP -DECC_MIN_KEY_SZ=192' --prefix=$WOLFSSL_INSTALL ${EXTRA_WOLFSSL_OPTIONS} &> $LOGFILE
86+
./configure --enable-cmac --enable-keygen --enable-sha --enable-des3 --enable-aesctr --enable-aesccm --enable-x963kdf CPPFLAGS="-DHAVE_AES_ECB -DWOLFSSL_AES_DIRECT -DWC_RSA_NO_PADDING -DWOLFSSL_PUBLIC_MP -DECC_MIN_KEY_SZ=192 -DWOLFSSL_PSS_LONG_SALT -DWOLFSSL_PSS_SALT_LEN_DISCOVER" --prefix=$WOLFSSL_INSTALL ${EXTRA_WOLFSSL_OPTIONS} &> $LOGFILE
9587
if [ $? != 0 ]; then
96-
printf "config failed\n"
88+
printf "config failed.\n"
9789
exit 1
9890
fi
9991

10092
make install &> $LOGFILE
10193
if [ $? != 0 ]; then
102-
printf "make failed\n"
94+
printf "make install failed.\n"
10395
exit 1
10496
fi
10597

10698
cd ..
10799
WOLFSSL_DIR=${PWD}/wolfssl
108-
printf "done\n"
100+
printf "installed.\n"
109101

110102
else
111-
printf "\tUsing wolfSSL installed at $WOLFSSL_INSTALL\n"
103+
printf "\tUsing wolfSSL installed at $WOLFSSL_INSTALL.\n"
112104
fi
113105
export LD_LIBRARY_PATH="$WOLFSSL_INSTALL/lib:$LD_LIBRARY_PATH"
114106

115-
116107
if [ -z "${WOLFENGINE_1_1_1_INSTALL}" ]; then
117-
printf "\tWOLENGINE_1_1_1_INSTALL not set, cloning it..."
108+
printf "\tWOLFENGINE_1_1_1_INSTALL not set, installing wolfEngine with OpenSSL 1.1.1..."
118109
git clone --depth=1 [email protected]:wolfssl/wolfEngine.git &> $LOGFILE
119110
WOLFENGINE_1_1_1_INSTALL=$PWD/wolfengine-1_1_1-install
120111

121-
#Build the library
122-
printf " Building wolfEngine..."
123112
cd wolfEngine
124113
./autogen.sh &> /dev/null
125-
./configure CPPFLAGS=-I${WOLFSSL_INSTALL}/include --with-openssl=$OPENSSL_1_1_1_INSTALL --prefix=$WOLFENGINE_1_1_1_INSTALL &> $LOGFILE
114+
./configure --with-wolfssl=$WOLFSSL_INSTALL --with-openssl=$OPENSSL_1_1_1_INSTALL --prefix=$WOLFENGINE_1_1_1_INSTALL &> $LOGFILE
126115
if [ $? != 0 ]; then
127-
printf "config failed\n"
116+
printf "config failed.\n"
128117
exit 1
129118
fi
130119

131120
make install &> $LOGFILE
132121
if [ $? != 0 ]; then
133-
printf "make failed\n"
122+
printf "make install failed.\n"
134123
exit 1
135124
fi
136-
printf "done\n"
125+
printf "installed.\n"
137126
cd ..
138-
139127
else
140-
printf "\tUsing wolfEngine 1.1.1 installed at $WOLFENGINE_1_1_1_INSTALL\n"
128+
printf "\tUsing wolfEngine with OpenSSL 1.1.1 installed at $WOLFENGINE_1_1_1_INSTALL.\n"
141129
fi
142130

143-
144131
if [ -z "${WOLFENGINE_1_0_2_INSTALL}" ]; then
145-
printf "\tWOLENGINE_1_0_2_INSTALL not set, cloning it..."
146-
git clone --depth=1 [email protected]:wolfssl/wolfEngine.git &> $LOGFILE
132+
printf "\tWOLFENGINE_1_0_2_INSTALL not set, installing wolfEngine with OpenSSL 1.0.2..."
133+
# We only need to clone the wolfEngine repo if it wasn't previously cloned
134+
# in the step above.
135+
if [ ! -d "wolfEngine" ]; then
136+
git clone --depth=1 [email protected]:wolfssl/wolfEngine.git &> $LOGFILE
137+
fi
147138
WOLFENGINE_1_0_2_INSTALL=$PWD/wolfengine-1_0_2-install
148139

149-
#Build the library
150-
printf " Building wolfEngine..."
151140
cd wolfEngine
152141
./autogen.sh &> /dev/null
153-
./configure CPPFLAGS=-I${WOLFSSL_INSTALL}/include --with-openssl=$OPENSSL_1_0_2_INSTALL --prefix=$WOLFENGINE_1_0_2_INSTALL &> $LOGFILE
142+
./configure --with-wolfssl=$WOLFSSL_INSTALL --with-openssl=$OPENSSL_1_0_2_INSTALL --prefix=$WOLFENGINE_1_0_2_INSTALL &> $LOGFILE
154143
if [ $? != 0 ]; then
155-
printf "config failed\n"
144+
printf "config failed.\n"
156145
exit 1
157146
fi
158147

159148
make install &> $LOGFILE
160149
if [ $? != 0 ]; then
161-
printf "make failed\n"
150+
printf "make install failed.\n"
162151
exit 1
163152
fi
164-
printf "done\n"
153+
printf "installed.\n"
165154
cd ..
166155

167156
else
168-
printf "\tUsing wolfEngine 1.0.2 installed at $WOLFENGINE_1_0_2_INSTALL\n"
157+
printf "\tUsing wolfEngine with OpenSSL 1.0.2 installed at $WOLFENGINE_1_0_2_INSTALL.\n"
169158
fi
170159

171-
printf "Done with setup\n\n"
160+
printf "Done with setup.\n\n"
172161

173162
printf "Running interop tests...\n"
174163

175-
# run the existing wolfSSL openssl interop tests using wolfEngine
164+
# Run the existing wolfSSL OpenSSL interop tests using wolfEngine.
176165
cd $WOLFSSL_DIR
177166
export WOLFSSL_OPENSSL_TEST=1
178167
printf "\tTesting with OpenSSL version 1.1.1..."
179168
export OPENSSL_ENGINES=${WOLFENGINE_1_1_1_INSTALL}/lib
180-
export OPENSSL_ENGINE_ID="libwolfengine"
181169
export LD_LIBRARY_PATH=${OPENSSL_1_1_1_INSTALL}/lib
182170
export OPENSSL=${OPENSSL_1_1_1_INSTALL}/bin/openssl
183171

184172
# check the engine can be found and used before running tests
185173
$OPENSSL engine -tt libwolfengine &> $LOGFILE
186174
if [ $? != 0 ]; then
187-
printf "not able to load engine\n"
175+
printf "not able to load engine.\n"
188176
printf "$OPENSSL engine -tt libwolfengine\n"
189177
FAILED=1
190178
else
191-
grep "available" $LOGFILE
179+
grep "available" $LOGFILE &> /dev/null
192180
if [ $? != 0 ]; then
193-
printf "engine not available\n"
181+
printf "engine not available.\n"
194182
else
195183
./scripts/openssl.test &> ${OPENSSL_1_1_1_RES}
196184
grep "Success\!" ${OPENSSL_1_1_1_RES} &> /dev/null
197185
if [ $? == 0 ]; then
198-
printf "ok\n"
186+
printf "ok.\n"
199187
else
200-
printf "failed\n"
188+
printf "failed.\n"
201189
cat ${OPENSSL_1_1_1_RES}
202190
FAILED=1
203191
fi
@@ -208,39 +196,38 @@ printf "\tTesting with OpenSSL version 1.0.2..."
208196
export OPENSSL_ENGINES=${WOLFENGINE_1_0_2_INSTALL}/lib
209197
export LD_LIBRARY_PATH=${OPENSSL_1_0_2_INSTALL}/lib
210198
export OPENSSL=${OPENSSL_1_0_2_INSTALL}/bin/openssl
211-
export OPENSSL_ENGINE_ID="wolfengine"
212199

213200
# check the engine can be found and used before running tests
214201
$OPENSSL engine -tt wolfengine &> $LOGFILE
215202
if [ $? != 0 ]; then
216-
printf "not able to load engine\n"
203+
printf "not able to load engine.\n"
217204
printf "$OPENSSL engine -tt wolfengine\n"
218205
FAILED=1
219206
else
220-
grep "available" $LOGFILE
207+
grep "available" $LOGFILE &> /dev/null
221208
if [ $? != 0 ]; then
222-
printf "engine not available\n"
209+
printf "engine not available.\n"
223210
else
224211
./scripts/openssl.test &> ${OPENSSL_1_0_2_RES}
225212
grep "Success\!" ${OPENSSL_1_0_2_RES} &> /dev/null
226213
if [ $? == 0 ]; then
227-
printf "ok\n"
214+
printf "ok.\n"
228215
else
229-
printf "failed\n"
216+
printf "failed.\n"
230217
cat ${OPENSSL_1_0_2_RES}
231218
FAILED=1
232219
fi
233220
fi
234221
fi
235222

236-
printf "Finished\n"
237-
printf "Results stored in the files:\n\t${OPENSL_1_1_1_RES}\n"
223+
printf "Finished tests.\n"
224+
printf "Results stored in the files:\n\t${OPENSSL_1_1_1_RES}\n"
238225
printf "\t${OPENSSL_1_0_2_RES}\n"
239226

240-
241227
if [ $FAILED == 1 ]; then
242-
printf "Fail...\n"
228+
printf "Failed.\n"
243229
exit 1
244230
fi
245-
printf "Success\n"
231+
232+
printf "Succeeded.\n"
246233
exit 0

src/we_internal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ wolfSSL_Mutex* we_rng_mutex = &we_global_rng_mutex;
165165
*
166166
* @returns 1 on success and 0 on failure.
167167
*/
168-
static int we_init_random()
168+
static int we_init_random(void)
169169
{
170170
int ret = 1;
171171
int rc;
@@ -201,7 +201,7 @@ static int we_init_random()
201201
/**
202202
* Free the global random number generator object.
203203
*/
204-
static void we_final_random()
204+
static void we_final_random(void)
205205
{
206206
WOLFENGINE_ENTER(WE_LOG_ENGINE, "we_final_random");
207207

test/test_pbe.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static int test_pbe_sha1_des3_pbkdf1_op(const unsigned char *in, size_t inLen,
214214
sizeof(pbeParamPbe), in, inLen, out, outLen, enc_dec);
215215
}
216216

217-
static int test_pbe_sha1_des3_pbkdf1()
217+
static int test_pbe_sha1_des3_pbkdf1(void)
218218
{
219219
int err;
220220
unsigned char pbeEnc[sizeof(pbeData) + 8];
@@ -257,7 +257,7 @@ static int test_pbe_pbes2_aes128_cbc_op(const unsigned char *in, size_t inLen,
257257
sizeof(pbeParamPbes2Aes128Cbc), in, inLen, out, outLen, enc_dec);
258258
}
259259

260-
static int test_pbe_pbes2_aes128_cbc()
260+
static int test_pbe_pbes2_aes128_cbc(void)
261261
{
262262
int err;
263263
unsigned char pbeEnc[sizeof(pbeData) + 16];
@@ -300,7 +300,7 @@ static int test_pbe_pbes2_aes256_cbc_op(const unsigned char *in, size_t inLen,
300300
sizeof(pbeParamPbes2Aes256Cbc), in, inLen, out, outLen, enc_dec);
301301
}
302302

303-
static int test_pbe_pbes2_aes256_cbc()
303+
static int test_pbe_pbes2_aes256_cbc(void)
304304
{
305305
int err;
306306
unsigned char pbeEnc[sizeof(pbeData) + 16];

test/test_rand.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#ifdef WE_HAVE_RANDOM
2525

26-
static int test_random_api()
26+
static int test_random_api(void)
2727
{
2828
int err;
2929
unsigned char buf[128];

0 commit comments

Comments
 (0)