Skip to content

Commit 3358d3d

Browse files
authored
Merge pull request #183 from JacobBarthelmeh/fips
adjust tests for disable of DES with FIPS and add FIPS print out with…
2 parents 494013d + f7b440d commit 3358d3d

File tree

6 files changed

+94
-41
lines changed

6 files changed

+94
-41
lines changed

src/tools/clu_funcs.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,9 +1123,20 @@ void wolfCLU_stats(double start, int blockSize, int64_t blocks)
11231123
/* returns WOLFCLU_SUCCESS on success */
11241124
int wolfCLU_version(void)
11251125
{
1126+
#ifdef HAVE_FIPS
1127+
const char *isFIPS = " FIPS";
1128+
#else
1129+
const char *isFIPS = "";
1130+
#endif
1131+
11261132
WOLFCLU_LOG(WOLFCLU_L0, "You are using version %s of the wolfssl Command Line Utility."
11271133
, CLUWOLFSSL_VERSION_STRING);
1128-
WOLFCLU_LOG(WOLFCLU_L0, "Linked to wolfSSL version %s", LIBWOLFSSL_VERSION_STRING);
1134+
WOLFCLU_LOG(WOLFCLU_L0, "Linked to wolfSSL version %s%s",
1135+
LIBWOLFSSL_VERSION_STRING, isFIPS);
1136+
#ifdef HAVE_FIPS
1137+
WOLFCLU_LOG(WOLFCLU_L0, "In FIPS builds there are algorithm restrictions "
1138+
"such as use of DES");
1139+
#endif
11291140
return WOLFCLU_SUCCESS;
11301141
}
11311142

tests/pkcs/pkcs12-test.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ then
1212
exit 77
1313
fi
1414

15+
# Is this a FIPS build?
16+
if ./wolfssl -v 2>&1 | grep -q FIPS; then
17+
#return 77 to indicate to automake that the test was skipped
18+
exit 77
19+
fi
20+
1521
RESULT=`./wolfssl pkcs12 -nodes -passin pass:"wolfSSL test" -passout pass: -in ./certs/test-servercert.p12 2>&1`
1622
echo "$RESULT" | grep "Recompile wolfSSL with PKCS12 support"
1723
if [ $? == 0 ]; then

tests/pkcs/pkcs8-test.sh

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ then
1212
exit 77
1313
fi
1414

15+
# Is this a FIPS build?
16+
IS_FIPS=0
17+
if ./wolfssl -v 2>&1 | grep -q FIPS; then
18+
IS_FIPS=1
19+
fi
20+
1521
RESULT=`./wolfssl pkcs8 -in certs/server-keyEnc.pem -passin pass:yassl123 2>&1`
1622
echo "$RESULT" | grep "Recompile wolfSSL with PKCS8 support"
1723
if [ $? == 0 ]; then
@@ -37,9 +43,13 @@ run_fail() {
3743
fi
3844
}
3945

40-
run "pkcs8 -in certs/server-keyEnc.pem -passin pass:yassl123 -outform DER -out keyEnc.der"
41-
42-
run "pkcs8 -in keyEnc.der -inform DER -outform PEM -out key.pem"
46+
if [ ${IS_FIPS} != "1" ]; then
47+
# Can only decrypt server-keyEnc.pem using DES if not a FIPS build
48+
run "pkcs8 -in certs/server-keyEnc.pem -passin pass:yassl123 -outform DER -out keyEnc.der"
49+
run "pkcs8 -in keyEnc.der -inform DER -outform PEM -out key.pem"
50+
else
51+
run "pkcs8 -in certs/server-key.pem -outform PEM -out key.pem"
52+
fi
4353

4454
run "pkcs8 -in key.pem -topk8 -nocrypt"
4555

@@ -55,19 +65,21 @@ rm -rf pkcs1.pem
5565
rm -rf key.pem
5666
rm -rf keyEnc.der
5767

58-
#check stdin input
59-
RESULT=`cat certs/server-keyEnc.pem | ./wolfssl pkcs8 -passin pass:yassl123`
60-
echo $RESULT | grep "BEGIN PRIVATE"
61-
if [ $? != 0 ]; then
62-
echo "Couldn't parse PKCS8 from stdin"
63-
exit 99
64-
fi
68+
if [ ${IS_FIPS} != "1" ]; then
69+
#check stdin input
70+
RESULT=`cat certs/server-keyEnc.pem | ./wolfssl pkcs8 -passin pass:yassl123`
71+
echo $RESULT | grep "BEGIN PRIVATE"
72+
if [ $? != 0 ]; then
73+
echo "Couldn't parse PKCS8 from stdin"
74+
exit 99
75+
fi
6576

66-
run_fail "pkcs8 -in certs/server-cert.pem -passin pass:yassl123"
77+
run_fail "pkcs8 -in certs/server-cert.pem -passin pass:yassl123"
6778

68-
run_fail "pkcs8 -in certs/server-keyEnc.pem -passin pass:wrongPass"
79+
run_fail "pkcs8 -in certs/server-keyEnc.pem -passin pass:wrongPass"
6980

70-
run_fail "pkcs8 -in certs/server-keyEnc.pem -inform DER -passin pass:yassl123"
81+
run_fail "pkcs8 -in certs/server-keyEnc.pem -inform DER -passin pass:yassl123"
82+
fi
7183

7284
echo "Done"
7385
exit 0

tests/pkey/rsa-test.sh

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ then
1212
exit 77
1313
fi
1414

15+
# Is this a FIPS build?
16+
IS_FIPS=0
17+
if ./wolfssl -v 2>&1 | grep -q FIPS; then
18+
IS_FIPS=1
19+
fi
20+
1521
run() {
1622
if [ -z "$2" ]; then
1723
RESULT=`./wolfssl $1`
@@ -67,30 +73,35 @@ run_fail "rsa -in ./certs/server-key.pem -pubin"
6773

6874
# Test success cases for -RSAPublicKey_in
6975
run "rsa -in ./certs/server-keyPub.pem -RSAPublicKey_in"
70-
run "rsa -in ./certs/server-keyEnc.pem -passin pass:yassl123"
71-
run_fail "rsa -in ./certs/server-keyEnc.pem -passin pass:yassl12"
7276

73-
run "rsa -in ./certs/server-keyEnc.pem -passin pass:yassl123 -noout -modulus"
77+
if [ ${IS_FIPS} != "1" ]; then
78+
run "rsa -in ./certs/server-keyEnc.pem -passin pass:yassl123"
79+
run_fail "rsa -in ./certs/server-keyEnc.pem -passin pass:yassl12"
80+
81+
run "rsa -in ./certs/server-keyEnc.pem -passin pass:yassl123 -noout -modulus"
82+
fi
7483

7584
# Test success cases for -pubin
7685
run "rsa -in ./certs/server-keyPub.pem -pubin"
77-
run "rsa -in ./certs/server-keyEnc.pem -passin pass:yassl123"
78-
run_fail "rsa -in ./certs/server-keyEnc.pem -passin pass:yassl12"
86+
if [ ${IS_FIPS} != "1" ]; then
87+
run "rsa -in ./certs/server-keyEnc.pem -passin pass:yassl123"
88+
run_fail "rsa -in ./certs/server-keyEnc.pem -passin pass:yassl12"
7989

80-
run "rsa -in ./certs/server-keyEnc.pem -passin pass:yassl123 -noout -modulus"
90+
run "rsa -in ./certs/server-keyEnc.pem -passin pass:yassl123 -noout -modulus"
8191

82-
# Check that modulus was printed
83-
echo $RESULT | grep "Modulus"
84-
if [ $? != 0 ]; then
85-
echo "ERROR with -modulus option"
86-
exit 99
87-
fi
92+
# Check that modulus was printed
93+
echo $RESULT | grep "Modulus"
94+
if [ $? != 0 ]; then
95+
echo "ERROR with -modulus option"
96+
exit 99
97+
fi
8898

89-
# Check that key was not printed
90-
echo $RESULT | grep "BEGIN"
91-
if [ $? == 0 ]; then
92-
echo "ERROR found a key with -modulus option"
93-
exit 99
99+
# Check that key was not printed
100+
echo $RESULT | grep "BEGIN"
101+
if [ $? == 0 ]; then
102+
echo "ERROR found a key with -modulus option"
103+
exit 99
104+
fi
94105
fi
95106

96107
# Expexted result -RSAPublicKey_in

tests/x509/expect-purpose.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Certificate Purpose:
22
Any Extended Key Usage : YES
33
TLS Web Server Authentication : YES
4-
TLS Web Client Authentication : NO
4+
TLS Web Client Authentication : YES
55
OCSP Signing : YES
66
Email Protect : YES
77
Time Stamp Signing : YES

tests/x509/x509-req-test.sh

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ then
1212
exit 77
1313
fi
1414

15+
# Is this a FIPS build?
16+
IS_FIPS=0
17+
if ./wolfssl -v 2>&1 | grep -q FIPS; then
18+
IS_FIPS=1
19+
fi
20+
1521
run_success() {
1622
if [ -z "$2" ]; then
1723
RESULT=`./wolfssl $1`
@@ -218,13 +224,16 @@ if [ $? != 0 ]; then
218224
fi
219225
rm -f tmp.cert
220226

221-
run_success "req -new -newkey rsa:2048 -config ./test.conf -x509 -out tmp.cert -passout stdin" "long test password"
222-
echo $RESULT | grep "ENCRYPTED"
223-
if [ $? -ne 0 ]; then
224-
echo "no encrypted key found in result"
225-
exit 99
227+
228+
if [ ${IS_FIPS} != "1" ]; then
229+
run_success "req -new -newkey rsa:2048 -config ./test.conf -x509 -out tmp.cert -passout stdin" "long test password"
230+
echo $RESULT | grep "ENCRYPTED"
231+
if [ $? -ne 0 ]; then
232+
echo "no encrypted key found in result"
233+
exit 99
234+
fi
235+
rm -f tmp.cert
226236
fi
227-
rm -f tmp.cert
228237

229238
#testing hash and key algos
230239
run_success "req -new -days 3650 -rsa -key ./certs/server-key.pem -config ./test.conf -out tmp.cert -x509"
@@ -242,7 +251,9 @@ rm -f tmp.cert
242251
run_success "req -new -days 3650 -sha512 -key ./certs/server-key.pem -config ./test.conf -out tmp.cert -x509"
243252
rm -f tmp.cert
244253

245-
run_success "req -new -newkey rsa:2048 -keyout new-key.pem -config ./test.conf -x509 -out tmp.cert -passout stdin" "long test password"
254+
if [ ${IS_FIPS} != "1" ]; then
255+
run_success "req -new -newkey rsa:2048 -keyout new-key.pem -config ./test.conf -x509 -out tmp.cert -passout stdin" "long test password"
256+
fi
246257

247258
run_success "req -new -key ./certs/ca-key.pem -config ./test.conf -extensions v3_alt_req_full -out tmp.cert"
248259
run_success "req -in ./tmp.cert -noout -text"
@@ -252,9 +263,11 @@ if [ $? -ne 0 ]; then
252263
exit 99
253264
fi
254265

266+
if [ ${IS_FIPS} != "1" ]; then
255267
#test passout
256-
run_success "req -newkey rsa:2048 -keyout new-key.pem -config ./test.conf -out tmp.cert -passout pass:123456789wolfssl -outform pem -sha256"
257-
run_success "rsa -in new-key.pem -passin pass:123456789wolfssl"
268+
run_success "req -newkey rsa:2048 -keyout new-key.pem -config ./test.conf -out tmp.cert -passout pass:123456789wolfssl -outform pem -sha256"
269+
run_success "rsa -in new-key.pem -passin pass:123456789wolfssl"
270+
fi
258271

259272
run_success "req -new -x509 -key ./certs/ca-key.pem -config ./test-prompt.conf -out tmp.cert" "AA"
260273
run_fail "req -new -x509 -key ./certs/ca-key.pem -config ./test-prompt.conf -out tmp.cert" "LONG"

0 commit comments

Comments
 (0)