-
Notifications
You must be signed in to change notification settings - Fork 206
134 lines (122 loc) · 5.5 KB
/
Copy pathcsharp.yml
File metadata and controls
134 lines (122 loc) · 5.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: CSharp
on:
push:
paths:
- 'CSharp/**'
- '.github/workflows/csharp.yml'
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
# No cron: nightly.yml calls this, so the whole nightly is ONE run
# and therefore one triage writer. See nightly.yml's header.
workflow_call:
inputs:
caller_run_id:
description: 'run id of the calling workflow; keeps a called run in its own concurrency group'
type: string
default: ''
workflow_dispatch:
# Hardcode this workflow's OWN name: github.workflow is the CALLER's in a called
# workflow, so keying on it put all 12 targets in one group -- and GitHub cancels
# the previously-pending run in a group, so only the last target survived.
concurrency:
group: ${{ inputs.caller_run_id && format('csharp-call-{0}', inputs.caller_run_id) || format('csharp-{0}', github.ref) }}
cancel-in-progress: ${{ !inputs.caller_run_id }}
permissions:
contents: read
jobs:
resolve:
uses: ./.github/workflows/_resolve-wolfssl.yml
with:
stable_count: 1
csharp:
needs: resolve
name: Run / csharp (${{ matrix.example }}) wolfSSL ${{ matrix.wolfssl_ref }}
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
wolfssl_ref: ${{ fromJson(needs.resolve.outputs.refs_json) }}
# both server variants play the same client; full paths so the
# coverage gate can see which dirs this job builds
example:
- CSharp/wolfSSL-TLS-pq-Server
- CSharp/wolfSSL-TLS-pq-ServerThreaded
timeout-minutes: 25
steps:
- uses: actions/checkout@v5
- name: Install mono
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends mono-complete >/dev/null
# The .csproj targets .NET Framework v4.8 and references wolfSSL's own
# wolfSSL_CSharp.csproj, so it cannot be built here. wolfSSL's mono.yml
# compiles the wrapper .cs directly with mcs instead; do the same.
- name: Build wolfSSL with the C# wrapper's user_settings.h
run: |
set -euo pipefail
git clone -q --depth 1 --branch '${{ matrix.wolfssl_ref }}' \
https://github.com/wolfSSL/wolfssl /tmp/wolfssl
cd /tmp/wolfssl
# wrapper/CSharp/user_settings.h already enables ML-KEM, ML-DSA and
# SHAKE, which is what the pq examples need
./autogen.sh >/dev/null 2>&1
./configure --enable-usersettings --enable-static --enable-shared \
CPPFLAGS=-I/tmp/wolfssl/wrapper/CSharp >/dev/null
make -j"$(nproc)" >/dev/null
sudo make install >/dev/null
sudo ldconfig
# A green build proves nothing if the wrapper silently lost the PQ API the
# examples call, so assert the exact symbols rather than trusting configure.
- name: Verify the wrapper still exposes the PQ API
run: |
set -euo pipefail
W=/tmp/wolfssl/wrapper/CSharp/wolfSSL_CSharp
grep -q 'WOLFSSL_ML_KEM_1024' "$W/wolfSSL.cs" \
|| { echo "FAIL: NamedGroup.WOLFSSL_ML_KEM_1024 gone from the wrapper"; exit 1; }
grep -q 'public static int UseKeyShare' "$W/wolfSSL.cs" \
|| { echo "FAIL: UseKeyShare() gone from the wrapper"; exit 1; }
echo "verified: WOLFSSL_ML_KEM_1024 + UseKeyShare present"
# wolfssl.setPath() returns a RELATIVE ../../certs/, so the exes must run
# from CSharp/<project>/ for it to land on this repo's mldsa87 chain.
# Building them anywhere else silently resolves to the wrong certs.
- name: Compile the pair with mcs
run: |
set -euo pipefail
W=/tmp/wolfssl/wrapper/CSharp/wolfSSL_CSharp
mcs "$W/wolfSSL.cs" "$W/X509.cs" \
'${{ matrix.example }}'/*.cs \
-OUT:'${{ matrix.example }}/server.exe'
mcs "$W/wolfCrypt.cs" "$W/wolfSSL.cs" "$W/X509.cs" \
CSharp/wolfSSL-TLS-pq-Client/wolfSSL-TLS-Client.cs \
-OUT:CSharp/wolfSSL-TLS-pq-Client/client.exe
for d in '${{ matrix.example }}' CSharp/wolfSSL-TLS-pq-Client; do
cp /usr/local/lib/libwolfssl.so "$d/wolfssl.dll"
cp /usr/local/lib/libwolfssl.so "$d/libwolfssl.so"
done
- name: Run the ML-KEM-1024 / ML-DSA-87 handshake
env:
LD_LIBRARY_PATH: /usr/local/lib
run: |
set -euo pipefail
( cd '${{ matrix.example }}' && timeout 30s mono server.exe ) \
> server.log 2>&1 &
for _ in $(seq 1 100); do
ss -tln | grep -q ':11111 ' && break
sleep 0.1
done
ss -tln | grep -q ':11111 ' \
|| { echo "FAIL: server never listened on 11111"; cat server.log; exit 1; }
rc=0
( cd CSharp/wolfSSL-TLS-pq-Client && timeout 30s mono client.exe ) \
> client.log 2>&1 || rc=$?
if [ "$rc" -ne 0 ]; then
echo "FAIL: client exited $rc"; echo "--- client:"; cat client.log
echo "--- server:"; cat server.log; exit 1
fi
# exit 0 alone does not prove a handshake, so assert on the negotiated
# session the way wolfSSL's own mono.yml does
grep -q 'SSL version is' client.log && grep -q 'SSL cipher suite is' client.log \
|| { echo "FAIL: no TLS session reported"; echo "--- client:"; cat client.log
echo "--- server:"; cat server.log; exit 1; }
echo "verified: PQ TLS 1.3 handshake"
grep -E 'SSL version is|SSL cipher suite is' client.log