Skip to content

Commit 151b461

Browse files
committed
Merge branch 'master' of github.com:ColtonWilley/wolfProvider into wp_ecc_pub_params_fix
2 parents e1761e4 + c665e6c commit 151b461

File tree

16 files changed

+1072
-45
lines changed

16 files changed

+1072
-45
lines changed

.github/workflows/simple.yml

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,52 @@ concurrency:
1515

1616
jobs:
1717
make_check:
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 20
20+
1821
strategy:
1922
matrix:
20-
config: [
21-
# Add new configs here
22-
'',
23-
'OPENSSL_TAG=master',
24-
'WOLFSSL_TAG=master',
25-
'OPENSSL_TAG=master WOLFSSL_TAG=master',
26-
]
27-
name: make check
28-
runs-on: ubuntu-latest
29-
# This should be a safe limit for the tests to run.
30-
timeout-minutes: 10
23+
config:
24+
- ''
25+
- 'OPENSSL_TAG=master'
26+
- 'WOLFSSL_TAG=master'
27+
- 'OPENSSL_TAG=master WOLFSSL_TAG=master'
28+
force_fail:
29+
- ''
30+
- 'WOLFPROV_FORCE_FAIL=1'
31+
3132
steps:
3233
- uses: actions/checkout@v4
33-
name: Checkout wolfProvider
34+
name: Checkout repository
3435

35-
- name: Test wolfProvider
36+
- name: Run build and tests
3637
run: |
37-
${{ matrix.config }} ./scripts/build-wolfprovider.sh
38+
# Build first with matrix config
39+
${{ matrix.config }} ${{ matrix.force_fail }} ./scripts/build-wolfprovider.sh || BUILD_RESULT=$?
3840
39-
- name: Print errors
40-
if: ${{ failure() }}
41+
# Run all tests regardless of build result
42+
${{ matrix.force_fail }} ./scripts/cmd_test/do-cmd-tests.sh || TEST_RESULT=$?
43+
44+
# For force_fail, we expect failures (return 1)
45+
if [ -n "${{ matrix.force_fail }}" ]; then
46+
if [ $BUILD_RESULT -eq 0 ] || [ $TEST_RESULT -eq 0 ]; then
47+
echo "Build/Test unexpectedly succeeded with force fail enabled"
48+
exit 1 # failure was not seen when expected
49+
else
50+
echo "Build/Test failed as expected with force fail enabled"
51+
exit 0 # expected failure occurred
52+
fi
53+
else
54+
# Normal case - expect success
55+
if [ $BUILD_RESULT -ne 0 ] || [ $TEST_RESULT -ne 0 ]; then
56+
exit 1 # unexpected failure
57+
fi
58+
fi
59+
60+
- name: Print test logs
61+
if: always()
4162
run: |
4263
if [ -f test-suite.log ] ; then
4364
cat test-suite.log
4465
fi
66+

.github/workflows/socat.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,4 @@ jobs:
130130
./socat -V
131131
132132
# Run the tests with expected failures
133-
SOCAT=$GITHUB_WORKSPACE/socat-1.8.0.0/socat ./test.sh -t 0.5 --expect-fail 146,216,309,310,399,467,468,478,491,528
133+
SOCAT=$GITHUB_WORKSPACE/socat-1.8.0.0/socat ./test.sh -t 0.5 --expect-fail 36,64,146,214,216,217,309,310,386,399,402,403,459,460,467,468,475,478,491,492,528,529,530

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,17 @@ make check
123123
## Testing
124124

125125
### Unit Tests
126-
To run automated unit tests:
127126

127+
To run automated unit tests:
128128
* `make test`
129129

130+
### Command Tests
131+
132+
To run the command tests:
133+
* `./scripts/cmd_test/do-cmd-tests.sh`
134+
130135
### Integration Tests
131136

132137
To run the cipher suite testing:
133-
* ./scripts/test-wp-cs.sh
138+
* `./scripts/test-wp-cs.sh`
134139

configure.ac

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ AC_CONFIG_MACRO_DIR([m4])
1313

1414
dnl m4_include([m4/ax_check_openssl.m4])
1515
dnl m4_include([m4/ax_check_wolfssl.m4])
16+
m4_include([m4/hexversion.m4])
1617

1718
AM_INIT_AUTOMAKE([1.11 -Wall -Werror -Wno-portability foreign tar-ustar subdir-objects no-define color-tests])
1819
LT_INIT([disable-static pic-only])
@@ -130,6 +131,7 @@ CFLAGS="$CFLAGS $USER_C_EXTRA_FLAGS"
130131
AC_SUBST([AM_CPPFLAGS])
131132
AC_SUBST([AM_CFLAGS])
132133
AC_SUBST([AM_LDFLAGS])
134+
CREATE_HEX_VERSION
133135

134136
AC_CONFIG_FILES([Makefile
135137
include/wolfprovider/version.h

include/wolfprovider/version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
extern "C" {
2828
#endif
2929

30-
#define LIBWOLFPROV_VERSION_STRING "1.1.0-RC"
31-
#define LIBWOLFPROV_VERSION_HEX @HEX_VERSION@
30+
#define LIBWOLFPROV_VERSION_STRING "1.0.2"
31+
#define LIBWOLFPROV_VERSION_HEX 0x01000002
3232

3333
#ifdef __cplusplus
3434
}

m4/hexversion.m4

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
AC_DEFUN([CREATE_HEX_VERSION],[
2+
3+
HEX_VERSION=`echo $VERSION | sed 's|[\-a-z0-9]*$||' | \
4+
awk -F. '{printf "0x%0.2d%0.3d%0.3d", $[]1, $[]2, $[]3}'`
5+
AC_SUBST([HEX_VERSION])
6+
])

scripts/cmd_test/aes-cmd-test.sh

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#!/bin/bash
2+
3+
# Set up environment
4+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
5+
REPO_ROOT="$( cd "${SCRIPT_DIR}/../.." &> /dev/null && pwd )"
6+
UTILS_DIR="${REPO_ROOT}/scripts"
7+
export LOG_FILE="${SCRIPT_DIR}/aes-test.log"
8+
touch "$LOG_FILE"
9+
10+
# Source wolfProvider utilities
11+
source "${UTILS_DIR}/utils-general.sh"
12+
source "${UTILS_DIR}/utils-openssl.sh"
13+
source "${UTILS_DIR}/utils-wolfssl.sh"
14+
source "${UTILS_DIR}/utils-wolfprovider.sh"
15+
16+
# Initialize the environment
17+
init_wolfprov
18+
19+
# Fail flag
20+
FAIL=0
21+
22+
# Verify wolfProvider is properly loaded
23+
echo -e "\nVerifying wolfProvider configuration:"
24+
if ! $OPENSSL_BIN list -providers | grep -q "wolf"; then
25+
echo "[FAIL] wolfProvider not found in OpenSSL providers!"
26+
echo "Current provider list:"
27+
$OPENSSL_BIN list -providers
28+
FAIL=1
29+
else
30+
echo "[PASS] wolfProvider is properly configured"
31+
fi
32+
33+
# Print environment for verification
34+
echo "Environment variables:"
35+
echo "OPENSSL_MODULES: ${OPENSSL_MODULES}"
36+
echo "LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}"
37+
echo "OPENSSL_BIN: ${OPENSSL_BIN}"
38+
39+
# Create test data and output directories
40+
mkdir -p aes_outputs
41+
echo "This is test data for AES encryption testing." > test.txt
42+
43+
# Arrays for test configurations
44+
KEY_SIZES=("128" "192" "256")
45+
# Only include modes supported by wolfProvider
46+
MODES=("ecb" "cbc" "ctr" "cfb")
47+
48+
echo "=== Running AES Algorithm Comparisons ==="
49+
50+
# Run tests for each key size and mode
51+
for key_size in "${KEY_SIZES[@]}"; do
52+
for mode in "${MODES[@]}"; do
53+
echo -e "\n=== Testing AES-${key_size}-${mode} ==="
54+
55+
# Generate random key and IV
56+
key=$($OPENSSL_BIN rand -hex $((key_size/8)))
57+
iv=""
58+
if [ "$mode" != "ecb" ]; then
59+
iv="-iv $($OPENSSL_BIN rand -hex 16)"
60+
fi
61+
62+
# Output files
63+
enc_file="aes_outputs/aes${key_size}_${mode}.enc"
64+
dec_file="aes_outputs/aes${key_size}_${mode}.dec"
65+
66+
# Interop testing: Encrypt with default provider, decrypt with wolfProvider
67+
echo "Interop testing (encrypt with default, decrypt with wolfProvider):"
68+
69+
# Encryption with OpenSSL default provider
70+
if ! $OPENSSL_BIN enc -aes-${key_size}-${mode} -K $key $iv -provider default \
71+
-in test.txt -out "$enc_file" -p; then
72+
echo "[FAIL] Interop AES-${key_size}-${mode}: OpenSSL encrypt failed"
73+
FAIL=1
74+
fi
75+
76+
# Decryption with wolfProvider
77+
if ! $OPENSSL_BIN enc -aes-${key_size}-${mode} -K $key $iv -provider-path $WOLFPROV_PATH -provider libwolfprov \
78+
-in "$enc_file" -out "$dec_file" -d -p; then
79+
echo "[FAIL] Interop AES-${key_size}-${mode}: wolfProvider decrypt failed"
80+
FAIL=1
81+
fi
82+
83+
if [ $FAIL -eq 0 ]; then
84+
if cmp -s "test.txt" "$dec_file"; then
85+
echo "[PASS] Interop AES-${key_size}-${mode}: OpenSSL encrypt, wolfProvider decrypt"
86+
else
87+
echo "[FAIL] Interop AES-${key_size}-${mode}: OpenSSL encrypt, wolfProvider decrypt"
88+
FAIL=1
89+
fi
90+
else
91+
echo "[INFO] Cannot verify encryption/decryption - no key available"
92+
fi
93+
94+
# Interop testing: Encrypt with wolfProvider, decrypt with default provider
95+
echo "Interop testing (encrypt with wolfProvider, decrypt with default):"
96+
97+
# Encryption with wolfProvider
98+
if ! $OPENSSL_BIN enc -aes-${key_size}-${mode} -K $key $iv -provider-path $WOLFPROV_PATH -provider libwolfprov \
99+
-in test.txt -out "$enc_file" -p; then
100+
echo "[FAIL] Interop AES-${key_size}-${mode}: wolfProvider encrypt failed"
101+
FAIL=1
102+
fi
103+
104+
# Decryption with OpenSSL default provider
105+
if ! $OPENSSL_BIN enc -aes-${key_size}-${mode} -K $key $iv -provider default \
106+
-in "$enc_file" -out "$dec_file" -d -p; then
107+
echo "[FAIL] Interop AES-${key_size}-${mode}: OpenSSL decrypt failed"
108+
FAIL=1
109+
fi
110+
111+
if [ $FAIL -eq 0 ]; then
112+
if cmp -s "test.txt" "$dec_file"; then
113+
echo "[PASS] Interop AES-${key_size}-${mode}: wolfProvider encrypt, OpenSSL decrypt"
114+
else
115+
echo "[FAIL] Interop AES-${key_size}-${mode}: wolfProvider encrypt, OpenSSL decrypt"
116+
FAIL=1
117+
fi
118+
else
119+
echo "[INFO] Cannot verify encryption/decryption - no key available"
120+
fi
121+
done
122+
done
123+
124+
# Change end of script to check FAIL flag
125+
if [ $FAIL -eq 0 ]; then
126+
echo -e "\n=== All AES tests completed successfully ==="
127+
exit 0
128+
else
129+
echo -e "\n=== AES tests completed with failures ==="
130+
exit 1
131+
fi

scripts/cmd_test/do-cmd-tests.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/bash
2+
# do-cmd-tests.sh
3+
# Run all command-line tests for wolfProvider
4+
#
5+
# Copyright (C) 2006-2024 wolfSSL Inc.
6+
#
7+
# This file is part of wolfProvider.
8+
#
9+
# wolfProvider is free software; you can redistribute it and/or modify
10+
# it under the terms of the GNU General Public License as published by
11+
# the Free Software Foundation; either version 3 of the License, or
12+
# (at your option) any later version.
13+
#
14+
# wolfProvider is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
# GNU General Public License for more details.
18+
#
19+
# You should have received a copy of the GNU General Public License
20+
# along with this program; if not, write to the Free Software
21+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
22+
23+
# Get the directory where this script is located
24+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
25+
REPO_ROOT="$( cd "${SCRIPT_DIR}/../.." &> /dev/null && pwd )"
26+
UTILS_DIR="${REPO_ROOT}/scripts"
27+
28+
# Get the built versions
29+
if [ -d "${REPO_ROOT}/openssl-source" ] && [ -d "${REPO_ROOT}/wolfssl-source" ]; then
30+
# Get the actual versions that were built
31+
export OPENSSL_TAG=$(cd ${REPO_ROOT}/openssl-source &&
32+
(git describe --tags 2>/dev/null || git branch --show-current))
33+
export WOLFSSL_TAG=$(cd ${REPO_ROOT}/wolfssl-source &&
34+
(git describe --tags 2>/dev/null || git branch --show-current))
35+
else
36+
echo "[FAIL] OpenSSL or wolfSSL source directories not found"
37+
echo "Please run build-wolfprovider.sh first"
38+
exit 1
39+
fi
40+
41+
# Use the current version tags for testing
42+
export USE_CUR_TAG=1
43+
44+
# Source OpenSSL utilities and initialize OpenSSL
45+
source "${UTILS_DIR}/utils-openssl.sh"
46+
init_openssl
47+
48+
echo "=== Running wolfProvider Command-Line Tests ==="
49+
echo "Using OpenSSL version: ${OPENSSL_TAG}"
50+
echo "Using wolfSSL version: ${WOLFSSL_TAG}"
51+
52+
# Run the hash comparison test
53+
echo -e "\n=== Running Hash Comparison Test ==="
54+
"${REPO_ROOT}/scripts/cmd_test/hash-cmd-test.sh"
55+
HASH_RESULT=$?
56+
57+
# Run the AES comparison test
58+
echo -e "\n=== Running AES Comparison Test ==="
59+
"${REPO_ROOT}/scripts/cmd_test/aes-cmd-test.sh"
60+
AES_RESULT=$?
61+
62+
# Run the RSA key generation test
63+
echo -e "\n=== Running RSA Key Generation Test ==="
64+
"${REPO_ROOT}/scripts/cmd_test/rsa-cmd-test.sh"
65+
RSA_RESULT=$?
66+
67+
# Run the ECC key generation test
68+
echo -e "\n=== Running ECC Key Generation Test ==="
69+
"${REPO_ROOT}/scripts/cmd_test/ecc-cmd-test.sh"
70+
ECC_RESULT=$?
71+
72+
# Check results
73+
if [ $HASH_RESULT -eq 0 ] && [ $AES_RESULT -eq 0 ] && [ $RSA_RESULT -eq 0 ] && [ $ECC_RESULT -eq 0 ]; then
74+
echo -e "\n=== All Command-Line Tests Passed ==="
75+
exit 0
76+
else
77+
echo -e "\n=== Command-Line Tests Failed ==="
78+
echo "Hash Test Result: $HASH_RESULT (0=success)"
79+
echo "AES Test Result: $AES_RESULT (0=success)"
80+
echo "RSA Test Result: $RSA_RESULT (0=success)"
81+
echo "ECC Test Result: $ECC_RESULT (0=success)"
82+
exit 1
83+
fi

0 commit comments

Comments
 (0)