Skip to content

Commit e9df2a6

Browse files
committed
Rebase for wP command line integration
1 parent e78adc0 commit e9df2a6

File tree

10 files changed

+874
-44
lines changed

10 files changed

+874
-44
lines changed

.github/workflows/simple.yml

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,41 @@ 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 Tests
3637
run: |
37-
${{ matrix.config }} ./scripts/build-wolfprovider.sh
38+
${{ matrix.config }} ${{ matrix.force_fail }} ./scripts/build-wolfprovider.sh || {
39+
if [ -n "${{ matrix.force_fail }}" ]; then
40+
cp test-suite.log test-suite-force-fail.log || true
41+
echo "Test failed as expected with force fail enabled"
42+
exit 0 # failure was expected (force fail)
43+
else
44+
exit 1 # failure was unexpected (normal test)
45+
fi
46+
}
47+
if [ -z "${{ matrix.force_fail }}" ]; then
48+
./scripts/cmd_test/do-cmd-tests.sh
49+
fi
50+
id: run_tests
3851

39-
- name: Print errors
40-
if: ${{ failure() }}
52+
- name: Print test logs
53+
if: always()
4154
run: |
42-
if [ -f test-suite.log ] ; then
43-
cat test-suite.log
44-
fi
55+
[ -f test-suite.log ] && cat test-suite.log

.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

scripts/cmd_test/aes-cmd-test.sh

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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+
# Verify wolfProvider is properly loaded
20+
echo -e "\nVerifying wolfProvider configuration:"
21+
if ! $OPENSSL_BIN list -providers | grep -q "wolf"; then
22+
echo "[FAIL] wolfProvider not found in OpenSSL providers!"
23+
echo "Current provider list:"
24+
$OPENSSL_BIN list -providers
25+
exit 1
26+
fi
27+
echo "[PASS] wolfProvider is properly configured"
28+
29+
# Print environment for verification
30+
echo "Environment variables:"
31+
echo "OPENSSL_MODULES: ${OPENSSL_MODULES}"
32+
echo "LD_LIBRARY_PATH: ${LD_LIBRARY_PATH}"
33+
echo "OPENSSL_BIN: ${OPENSSL_BIN}"
34+
35+
# Create test data and output directories
36+
mkdir -p aes_outputs
37+
echo "This is test data for AES encryption testing." > test.txt
38+
39+
# Arrays for test configurations
40+
KEY_SIZES=("128" "192" "256")
41+
# Only include modes supported by wolfProvider
42+
MODES=("ecb" "cbc" "ctr" "cfb")
43+
44+
45+
echo "=== Running AES Algorithm Comparisons ==="
46+
47+
# Run tests for each key size and mode
48+
for key_size in "${KEY_SIZES[@]}"; do
49+
for mode in "${MODES[@]}"; do
50+
echo -e "\n=== Testing AES-${key_size}-${mode} ==="
51+
52+
# Generate random key and IV
53+
key=$($OPENSSL_BIN rand -hex $((key_size/8)))
54+
iv=""
55+
if [ "$mode" != "ecb" ]; then
56+
iv="-iv $($OPENSSL_BIN rand -hex 16)"
57+
fi
58+
59+
# Output files
60+
enc_file="aes_outputs/aes${key_size}_${mode}.enc"
61+
dec_file="aes_outputs/aes${key_size}_${mode}.dec"
62+
63+
# Interop testing: Encrypt with default provider, decrypt with wolfProvider
64+
echo "Interop testing (encrypt with default, decrypt with wolfProvider):"
65+
66+
# Encryption with OpenSSL default provider
67+
$OPENSSL_BIN enc -aes-${key_size}-${mode} -K $key $iv -provider default \
68+
-in test.txt -out "$enc_file" -p
69+
70+
# Decryption with wolfProvider
71+
$OPENSSL_BIN enc -aes-${key_size}-${mode} -K $key $iv -provider-path $WOLFPROV_PATH -provider libwolfprov \
72+
-in "$enc_file" -out "$dec_file" -d -p
73+
74+
if cmp -s "test.txt" "$dec_file"; then
75+
echo "[PASS] Interop AES-${key_size}-${mode}: OpenSSL encrypt, wolfProvider decrypt"
76+
else
77+
echo "[FAIL] Interop AES-${key_size}-${mode}: OpenSSL encrypt, wolfProvider decrypt"
78+
exit 1
79+
fi
80+
81+
# Interop testing: Encrypt with wolfProvider, decrypt with default provider
82+
echo "Interop testing (encrypt with wolfProvider, decrypt with default):"
83+
84+
# Encryption with wolfProvider
85+
$OPENSSL_BIN enc -aes-${key_size}-${mode} -K $key $iv -provider-path $WOLFPROV_PATH -provider libwolfprov \
86+
-in test.txt -out "$enc_file" -p
87+
88+
# Decryption with OpenSSL default provider
89+
$OPENSSL_BIN enc -aes-${key_size}-${mode} -K $key $iv -provider default \
90+
-in "$enc_file" -out "$dec_file" -d -p
91+
92+
if cmp -s "test.txt" "$dec_file"; then
93+
echo "[PASS] Interop AES-${key_size}-${mode}: wolfProvider encrypt, OpenSSL decrypt"
94+
else
95+
echo "[FAIL] Interop AES-${key_size}-${mode}: wolfProvider encrypt, OpenSSL decrypt"
96+
exit 1
97+
fi
98+
done
99+
done
100+
101+
# End of AES testing
102+
103+
echo -e "\n=== All AES tests completed successfully ==="
104+
exit 0

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)