1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
#!/bin/bash
#
# aria_cmake_build_test.sh
#
# This is a test script for building wolfSSL examples with various settings
# for the ARIA Magic Crypto ciphers.
#
# See https://github.com/wolfSSL/wolfssl/pull/6400 and
# https://github.com/wolfSSL/wolfssl/pull/6600
#
# The basic steps for building:
#
# # set to your path
# export ARIA_DIR=/mnt/c/workspace/MagicCrypto
#
# mkdir -p out
# pushd out
# cmake .. -DWOLFSSL_ARIA=yes
# cmake --build .
#
# # View the available ciphers with:
# ./examples/client/client -e
#
# or with grep:
# ./examples/client/client -e | grep -i ARIA
#
# Note the OPENSSL_EXTRA and WOLF_CRYPTOCB macros may need to be defined
# in certain circumstances. The LD_LIBRARY_PATH=$ARIA_DIR may also be needed.
#
export ARIA_BUILD_DIR=./out_temp
export ARIA_ERROR_RM_FAIL=1
export ARIA_ERROR_MKDIR_FAIL=2
export ARIA_ERROR_CMAKE_FAIL=3
export ARIA_ERROR_BUILD_FAIL=4
export ARIA_ERROR_CLIENT_FAIL=5
export ARIA_ERROR_CIPHER_FAIL=6
export ARIA_ERROR_CONFIG_FAIL=7
#
# function build_aria_test()
#
build_aria_test() {
local EXPECTED_ERROR=$1 # First parameter; 0, 1, 2, etc
local EXPECTED_ARIA=$2 # Second parameter: typically "Y" or "N"
local BUILD_MESSAGE=$3 # Third parameter; "some message"
local BUILD_DIR=$4 # Fourth parameter: "./someDirectory"
local BUILD_OPTION=$5 # Fifth parameter. Optional: ""
echo "********************************************************************"
echo "Starting $BUILD_MESSAGE"
echo "********************************************************************"
if [[ -z "$BUILD_DIR" ]]; then
local BUILD_DIR=out
fi
echo "BUILD_DIR=$BUILD_DIR"
echo "BUILD_OPTION=$BUILD_OPTION"
# remove build directory
rm -rf $BUILD_DIR
if [ $? -eq 0 ]; then
echo "$BUILD_DIR removed."
else
echo "Failed to remove directory."
return $ARIA_ERROR_RM_FAIL
fi
# create a fresh directory
mkdir -p $BUILD_DIR
if [ $? -eq 0 ]; then
echo "$BUILD_DIR created."
else
echo "Failed to create directory $BUILD_DIR"
return $ARIA_ERROR_MKDIR_FAIL
fi
# change into build directory
pushd $BUILD_DIR
# initial cmake
echo "********************************************************************"
echo "CMake for $BUILD_MESSAGE"
if [ -z "$BUILD_OPTION" ]; then
echo "(No additional build options)"
else
echo "Using build option: $BUILD_OPTION"
fi
echo "********************************************************************"
cmake .. $BUILD_OPTION
if [ $? -eq 0 ]; then
echo "cmake successful."
else
echo "ERROR: cmake failed"
return $ARIA_ERROR_CMAKE_FAIL
fi
# build
echo "********************************************************************"
echo "Build for $BUILD_MESSAGE"
if [ -z "$BUILD_OPTION" ]; then
echo "(No additional build options)"
else
echo "Using build option: $BUILD_OPTION"
fi
echo "********************************************************************"
cmake --build .
if [ $? -eq 0 ]; then
echo "cmake build successful."
else
echo "ERROR: cmake build failed"
return $ARIA_ERROR_BUILD_FAIL
fi
# View the available ciphers with:
echo "checking wolfsl client ssl version numbers SSLv3(0) - TLS1.3(4):"
./examples/client/client -V
if [ $? -eq 0 ]; then
echo "Confirmed ./examples/client/client operational."
else
echo "ERROR ./examples/client/client error = $?"
return $ARIA_ERROR_CLIENT_FAIL
fi
# now see if we have ARIA ciphers
if ./examples/client/client -e | awk '/ARIA/{found=1} END{exit !found}'; then
if [ "$EXPECTED_ARIA" == "Y" ]; then
echo "Found ARIA ciphers as expected."
else
echo "ERROR: Found ARIA ciphers when NOT expected."
return $ARIA_ERROR_CIPHER_FAIL
fi
else
if [ "$EXPECTED_ARIA" == "N" ]; then
echo "No ARIA ciphers found as expected with ./examples/client/client -e"
else
echo "ERROR: No ARIA ciphers found, EXPECTED_ARIA parameter = \"$EXPECTED_ARIA\"; expected \"N\"."
return $ARIA_ERROR_CONFIG_FAIL
fi
fi
./examples/client/client -e
echo "Return to working directory."
popd
echo "********************************************************************"
echo "Completed $BUILD_MESSAGE"
echo "********************************************************************"
echo ""
}
set -e
# No ARIA Environment Variable
export ARIA_DIR=
export THIS_MESSAGE="No ARIA Environment Variable, ARIA not enabled."
build_aria_test 0 N "$THIS_MESSAGE" "$ARIA_BUILD_DIR"
export ARIA_DIR=
export THIS_MESSAGE="No ARIA Environment Variable, ARIA Enabled"
build_aria_test 0 Y "$THIS_MESSAGE" "$ARIA_BUILD_DIR" "-DWOLFSSL_ARIA=yes"
# ARIA Environment Variable with MagicCrypto in local user directory
export ARIA_DIR=~/MagicCrypto
export THIS_MESSAGE="ARIA Environment Variable with MagicCrypto in local user directory, ARIA not enabled."
build_aria_test 0 N "$THIS_MESSAGE" "$ARIA_BUILD_DIR"
export ARIA_DIR=~/MagicCrypto
export THIS_MESSAGE="ARIA Environment Variable with MagicCrypto in local user directory, ARIA Enabled"
build_aria_test 0 Y "$THIS_MESSAGE" "$ARIA_BUILD_DIR" "-DWOLFSSL_ARIA=yes"
# ARIA Environment Variable with MagicCrypto in wolfssl directory
export ARIA_DIR=~/MagicCrypto
export THIS_MESSAGE="ARIA Environment Variable with MagicCrypto in wolfssl directory, ARIA not enabled."
build_aria_test 0 N "$THIS_MESSAGE" "$ARIA_BUILD_DIR"
export ARIA_DIR=./MagicCrypto
export THIS_MESSAGE="ARIA Environment Variable with MagicCrypto in wolfssl, ARIA Enabled"
build_aria_test 0 Y "$THIS_MESSAGE" "$ARIA_BUILD_DIR" "-DWOLFSSL_ARIA=yes"
# ARIA Environment Variable with bad directory, ARIA not enabled so bad directory ignored
export ARIA_DIR=./UnknownDirectory
export THIS_MESSAGE="ARIA Environment Variable with bad directory, ARIA not enabled."
build_aria_test 0 N "$THIS_MESSAGE" "$ARIA_BUILD_DIR"
# ARIA Environment Variable with bad directory, ARIA enabled so bad directory should fail
set +e
export ARIA_DIR=./UnknownDirectory
export THIS_MESSAGE="ARIA Environment Variable with bad directory, ARIA Enabled"
build_aria_test $ARIA_ERROR_CMAKE_FAIL N "$THIS_MESSAGE" "$ARIA_BUILD_DIR" "-DWOLFSSL_ARIA=yes"
if [ $? -eq $ARIA_ERROR_CMAKE_FAIL ]; then
echo "Properly detected bad directory and failed as expected."
else
echo "Error: expected failure not detected."
exit 1
fi
echo "Done. aria_cmake_build_test completed successfully!"
exit 0
|