Skip to content

Commit 50dea8f

Browse files
committed
Update the async examples and add CI for it.
1 parent 79602b0 commit 50dea8f

8 files changed

Lines changed: 809 additions & 289 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Async Examples
2+
3+
on:
4+
push:
5+
branches: [ 'master', 'main', 'release/**' ]
6+
pull_request:
7+
branches: [ '*' ]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
async_examples:
15+
if: github.repository_owner == 'wolfssl'
16+
runs-on: ubuntu-24.04
17+
timeout-minutes: 10
18+
steps:
19+
- uses: actions/checkout@v4
20+
name: Checkout wolfSSL
21+
22+
- name: Build async examples (no configure)
23+
run: |
24+
make -C examples/async clean
25+
make -C examples/async
26+
27+
- name: Run async examples (ECC + X25519)
28+
run: |
29+
set -euo pipefail
30+
run_pair() {
31+
local mode="$1"
32+
./examples/async/async_server --"$mode" > "/tmp/async_server_${mode}.log" 2>&1 &
33+
local pid=$!
34+
sleep 1
35+
./examples/async/async_client --"$mode" 127.0.0.1 11111 > "/tmp/async_client_${mode}.log" 2>&1
36+
local rc=$?
37+
kill "$pid" >/dev/null 2>&1 || true
38+
wait "$pid" >/dev/null 2>&1 || true
39+
return "$rc"
40+
}
41+
run_pair ecc
42+
run_pair x25519
43+
44+
- name: Print async logs
45+
if: ${{ failure() }}
46+
run: |
47+
for f in /tmp/async_server_*.log /tmp/async_client_*.log; do
48+
if [ -f "$f" ]; then
49+
echo "==> $f"
50+
cat "$f"
51+
fi
52+
done

examples/async/Makefile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
CC ?= gcc
2+
AR ?= ar
3+
RM ?= rm -f
4+
5+
WOLFSSL_TOP ?= $(abspath ../..)
6+
OBJDIR ?= build
7+
8+
CFLAGS ?= -O0 -g
9+
CFLAGS += -I.
10+
CFLAGS += -I$(WOLFSSL_TOP)
11+
CFLAGS += -I$(WOLFSSL_TOP)/wolfssl
12+
CFLAGS += -I$(WOLFSSL_TOP)/wolfssl/wolfcrypt
13+
CFLAGS += -DWOLFSSL_USER_SETTINGS
14+
CFLAGS += -DUSE_CERT_BUFFERS_256
15+
16+
LDFLAGS ?=
17+
LDLIBS ?=
18+
19+
TARGETS = async_client async_server
20+
21+
WOLFSSL_SRC := $(wildcard $(WOLFSSL_TOP)/src/*.c)
22+
WOLFCRYPT_SRC := $(wildcard $(WOLFSSL_TOP)/wolfcrypt/src/*.c)
23+
LOCAL_SRC := async_client.c async_server.c
24+
25+
WOLFSSL_OBJS := $(patsubst $(WOLFSSL_TOP)/%, $(OBJDIR)/%, $(WOLFSSL_SRC:.c=.o))
26+
WOLFCRYPT_OBJS := $(patsubst $(WOLFSSL_TOP)/%, $(OBJDIR)/%, $(WOLFCRYPT_SRC:.c=.o))
27+
LOCAL_OBJS := $(patsubst %.c, $(OBJDIR)/%.o, $(LOCAL_SRC))
28+
29+
OBJS := $(LOCAL_OBJS) $(WOLFSSL_OBJS) $(WOLFCRYPT_OBJS)
30+
31+
all: $(TARGETS)
32+
33+
$(TARGETS): %: $(OBJDIR)/%.o $(WOLFSSL_OBJS) $(WOLFCRYPT_OBJS)
34+
$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
35+
36+
$(OBJDIR)/%.o: %.c user_settings.h
37+
@mkdir -p $(dir $@)
38+
$(CC) $(CFLAGS) -c $< -o $@
39+
40+
$(OBJDIR)/%.o: $(WOLFSSL_TOP)/%.c
41+
@mkdir -p $(dir $@)
42+
$(CC) $(CFLAGS) -c $< -o $@
43+
44+
clean:
45+
$(RM) -r $(OBJDIR) $(TARGETS)

examples/async/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ Tested with:
1515
* `./configure --enable-asynccrypt --enable-pkcallbacks --disable-rsa --enable-ecc`
1616

1717
```
18-
make
19-
./examples/async/async_server
20-
./examples/async/async_client 127.0.0.1
18+
make -C examples/async
19+
./examples/async/async_server --ecc
20+
./examples/async/async_client --ecc 127.0.0.1 11111
21+
./examples/async/async_client --x25519 ecc256.badssl.com 443
2122
```
2223

2324
## Asynchronous Cryptography Design

0 commit comments

Comments
 (0)