Skip to content

Commit 47f97a0

Browse files
committed
Add iperf workflow
1 parent f5d17bb commit 47f97a0

3 files changed

Lines changed: 166 additions & 0 deletions

File tree

.github/scripts/check-workflow-result.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,23 @@ if [ "$WOLFPROV_FORCE_FAIL" = "WOLFPROV_FORCE_FAIL=1" ]; then
255255
fi
256256
else
257257
echo "Error: liboauth2-test.log not found"
258+
fi
259+
# ----- IPERF -----
260+
elif [ "$TEST_SUITE" = "iperf" ]; then
261+
IPERF_TEST_LOG="iperf-test.log"
262+
if [ -f $IPERF_TEST_LOG ]; then
263+
read sender_gb receiver_gb < <(awk '/sender/ {s=$4} /receiver/ {r=$4} END{print s, r}' )
264+
265+
if [[ -z "$sender_gb" && -z "$receiver_gb" ]]; then
266+
echo "PASS: No data sent or received, as expected with force fail enabled"
267+
exit 0
268+
else
269+
echo "FAIL: Iperf tests unexpectedly succeeded with data sent or received"
270+
echo " Sent: $sender_gb GB, Received: $receiver_gb GB"
271+
exit 1
272+
fi
273+
else
274+
echo "Error: $IPERF_TEST_LOG not found"
258275
exit 1
259276
fi
260277
else

.github/workflows/iperf.yml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
name: iperf Tests
2+
3+
# START OF COMMON SECTION
4+
on:
5+
push:
6+
branches: [ 'master', 'main', 'release/**' ]
7+
pull_request:
8+
branches: [ '*' ]
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
# END OF COMMON SECTION
14+
15+
jobs:
16+
build_wolfprovider:
17+
uses: ./.github/workflows/build-wolfprovider.yml
18+
with:
19+
wolfssl_ref: ${{ matrix.wolfssl_ref }}
20+
openssl_ref: ${{ matrix.openssl_ref }}
21+
strategy:
22+
matrix:
23+
wolfssl_ref: [ 'master', 'v5.8.0-stable' ]
24+
openssl_ref: [ 'openssl-3.5.0' ]
25+
26+
test_iperf:
27+
runs-on: ubuntu-22.04
28+
needs: build_wolfprovider
29+
# This should be a safe limit for the tests to run.
30+
timeout-minutes: 20
31+
strategy:
32+
matrix:
33+
wolfssl_ref: [ 'master', 'v5.8.0-stable' ]
34+
openssl_ref: [ 'openssl-3.5.0' ]
35+
iperf_ref: [ 'master', '3.12' ]
36+
force_fail: ['WOLFPROV_FORCE_FAIL=1', '']
37+
steps:
38+
- name: Checkout wolfProvider
39+
uses: actions/checkout@v4
40+
41+
- name: Retrieving OpenSSL from cache
42+
uses: actions/cache/restore@v4
43+
id: openssl-cache
44+
with:
45+
path: |
46+
openssl-source
47+
openssl-install
48+
49+
key: ossl-depends-${{ matrix.openssl_ref }}-${{ github.sha }}
50+
fail-on-cache-miss: true
51+
52+
- name: Retrieving wolfSSL/wolfProvider from cache
53+
uses: actions/cache/restore@v4
54+
id: wolfprov-cache
55+
with:
56+
path: |
57+
wolfssl-source
58+
wolfssl-install
59+
wolfprov-install
60+
provider.conf
61+
62+
key: wolfprov-${{ matrix.wolfssl_ref }}-${{ github.sha }}
63+
fail-on-cache-miss: true
64+
65+
- name: Install dependencies
66+
run: |
67+
sudo apt-get update
68+
sudo apt-get install build-essential autoconf libtool pkg-config clang libc++-dev
69+
70+
- name: Checkout iperf
71+
uses: actions/checkout@v4
72+
with:
73+
repository: esnet/iperf
74+
ref: ${{ matrix.iperf_ref }}
75+
path: iperf
76+
77+
- name: Build iperf
78+
working-directory: iperf
79+
run: |
80+
# Configure with OpenSSL
81+
./configure --with-openssl=$GITHUB_WORKSPACE/openssl-install
82+
83+
# Build iperf
84+
make -j
85+
86+
- name: Generate RSA keys
87+
run: |
88+
export KEY_DIR=$GITHUB_WORKSPACE/test-keys
89+
mkdir -p $KEY_DIR
90+
cd $KEY_DIR
91+
# Generate RSA keys for iperf tests
92+
openssl genrsa -out rsa_private_unprotected.pem 2048
93+
openssl rsa -in rsa_private_unprotected.pem -out rsa_private.pem -aes256 -passout 'pass:password'
94+
openssl rsa -in rsa_private.pem -pubout -out rsa_public.pem -passin 'pass:password'
95+
# Create a credentials file for iperf
96+
# Username: mario, Password: rossi
97+
echo "mario,bf7a49a846d44b454a5d11e7acfaf13d138bbe0b7483aa3e050879700572709b" > credentials.csv
98+
99+
- name: Run tests
100+
working-directory: iperf
101+
run: |
102+
# Set up the environment for wolfProvider
103+
export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/wolfssl-install/lib:$GITHUB_WORKSPACE/openssl-install/lib64
104+
export OPENSSL_CONF=$GITHUB_WORKSPACE/provider.conf
105+
export OPENSSL_MODULES=$GITHUB_WORKSPACE/wolfprov-install/lib
106+
export ${{ matrix.force_fail }}
107+
export SHELL=/bin/bash
108+
109+
# Test variables for iperf
110+
export IPERF3_EXECUTABLE=$GITHUB_WORKSPACE/iperf/src/iperf3
111+
export IPERF3_TEST_INTERVAL=0.1
112+
export IPERF3_TEST_DURATION=10
113+
export IPERF3_TEST_LOG=iperf-test.log
114+
export IPERF3_USER=mario
115+
export IPERF3_PASSWORD=rossi
116+
export KEY_DIR=$GITHUB_WORKSPACE/test-keys
117+
118+
119+
# Verify IERF3_EXECUTABLE exists
120+
if [ -f "$IPERF3_EXECUTABLE" ]; then
121+
echo "iperf3 executable found: $IPERF3_EXECUTABLE"
122+
else
123+
echo "iperf3 executable not found: $IPERF3_EXECUTABLE"
124+
echo "PWD: $PWD"
125+
tree -L 2
126+
fi
127+
128+
# Verify OpenSSL loads wolfProvider to confirm configuration above
129+
# $GITHUB_WORKSPACE/openssl-install/bin/openssl list -providers | grep libwolfprov
130+
131+
# Verify iperf loads OpenSSL containing wolfProvider
132+
# ldd $IPERF3_EXECUTABLE | grep wolfProvider
133+
134+
# Launch the iperf server in the background
135+
$IPERF3_EXECUTABLE -s \
136+
--rsa-private-key-path $KEY_DIR/rsa_private_unprotected.pem \
137+
--authorized-users-path $KEY_DIR/credentials.csv &
138+
139+
# Run the client
140+
$IPERF3_EXECUTABLE -c localhost -i $IPERF3_TEST_INTERVAL -t $IPERF3_TEST_DURATION \
141+
--rsa-public-key-path $KEY_DIR/rsa_public.pem \
142+
--user $IPERF3_USER | tee $IPERF3_TEST_LOG \
143+
144+

src/wp_rsa_asym.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,11 @@ static int wp_rsaa_encrypt(wp_RsaAsymCtx* ctx, unsigned char* out,
312312
ctx->oaepHashType = WC_HASH_TYPE_SHA;
313313
ctx->mgf = WC_MGF1SHA1;
314314
}
315+
/* OpenSSL ignores the 'outSize' parameter and allows 0.
316+
* See rsa_encrypt() in providers/implementations/asymciphers/rsa_enc.c.
317+
* Meanwhile, wolfSSL does not allow this. As a workaround, assume
318+
* the 'out' buffer is properly sized for the given RSA key size. */
319+
outSize = wp_rsa_get_bits(ctx->rsa) / 8;
315320
rc = wc_RsaPublicEncrypt_ex(in, (word32)inLen, out, (word32)outSize,
316321
wp_rsa_get_key(ctx->rsa), &ctx->rng, WC_RSA_OAEP_PAD,
317322
ctx->oaepHashType, ctx->mgf, ctx->label, (word32)ctx->labelLen);

0 commit comments

Comments
 (0)