forked from wolfSSL/wolfssl
-
Notifications
You must be signed in to change notification settings - Fork 1
198 lines (183 loc) · 8.15 KB
/
Copy pathafalg.yml
File metadata and controls
198 lines (183 loc) · 8.15 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
name: AF_ALG Tests
# START OF COMMON SECTION
on:
push:
branches: [ 'release/**' ]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches: [ '*' ]
# Weekday-morning cron (10:00 UTC) seeds the master-scoped ccache that PR runs
# restore: re-runs --build-only (compile only, no tests) on the
# default branch. PR runs are read-only (see ccache-setup).
schedule:
- cron: '2 10 * * 1-5'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
# END OF COMMON SECTION
jobs:
# The Linux AF_ALG port (wolfcrypt/src/port/af_alg/) offloads AES and SHA-256
# to the kernel crypto API over AF_ALG sockets. Note that Docker's default
# seccomp profile blocks socket(AF_ALG).
#
# Both configs build on one runner via .github/scripts/parallel-make-check.py
# (see os-check.yml for the full pattern): each builds in its own out-of-tree
# ("VPATH") build directory off one checkout/autogen, on a pool of one-per-CPU
# worker threads, longest first.
make_check:
name: make check
if: ${{ (github.repository_owner == 'wolfssl') && (github.event_name != 'pull_request' || github.event.pull_request.draft == false) }}
runs-on: ubuntu-24.04
# Generous for a cold ccache; warm reruns finish in a fraction.
timeout-minutes: 20
steps:
- uses: actions/checkout@v5
name: Checkout wolfSSL
- name: Install dependencies
uses: ./.github/actions/install-apt-deps
with:
packages: autoconf automake libtool build-essential bubblewrap
ghcr-debs-tag: ubuntu-24.04-minimal
# Ubuntu 24.04 can restrict unprivileged user namespaces via AppArmor,
# which would stop the test scripts from re-execing under
# bwrap --unshare-net (their port-isolation mechanism).
- name: Allow unprivileged user namespaces (for bwrap)
run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 || true
# The socket families the port binds through (algif_hash, algif_skcipher,
# algif_aead) are loadable modules, normally autoloaded on bind() via
# their module aliases. On the -azure kernels the hosted runners boot,
# algif_aead is not in the installed linux-modules-azure package, and
# Ubuntu's generated blacklist neutralizes it with an
# "install algif_aead /bin/false" rule -- which defeats the bind-time
# autoload too, so aead/gcm(aes) is unreachable until it is loaded by
# hand. The underlying cipher is not the problem: gcm(aes) is already
# registered by aesni_intel.
#
# --ignore-install skips that /bin/false rule; linux-modules-extra
# supplies the .ko if the base package really lacks it (that package is
# often absent from the mirrors for the runner's exact kernel revision,
# so it is a best-effort second try, not a dependency). Failures stay
# non-fatal here: the probe below is what turns a missing algorithm into
# a red check, and it names the algorithm when it does.
- name: Load AF_ALG kernel modules
run: |
uname -r
missing=
for m in algif_hash algif_skcipher algif_aead gcm; do
if sudo modprobe --ignore-install "$m"; then
echo "modprobe $m: ok"
else
echo "modprobe $m: not loadable, will retry after modules-extra"
missing="$missing $m"
fi
done
if [ -n "$missing" ]; then
grep -rn 'algif_' /etc/modprobe.d /lib/modprobe.d || true
sudo apt-get update -qq || true
sudo apt-get install -y "linux-modules-extra-$(uname -r)" || true
for m in $missing; do
if sudo modprobe --ignore-install "$m"; then
echo "modprobe $m: ok after modules-extra"
else
echo "modprobe $m: still not loadable"
fi
done
fi
echo '--- registered AES/SHA-256 algorithms (name/driver) ---'
awk '/^name/ { n = $3 } /^driver/ { print n "\t" $3 }' /proc/crypto \
| grep -E 'aes|sha256' | sort -u || true
# Preflight: bind every (type, name) pair wolfcrypt/src/port/af_alg/ uses,
# so a runner image without one of them fails here with the missing
# algorithm named, rather than deep inside testwolfcrypt. Deliberately a
# hard failure and not a skip: a green check that exercised no AF_ALG code
# would be worse than a red one. The set mirrors afalg_hash.c (sha256) and
# afalg_aes.c (cbc/ecb/ctr/gcm); extend it when the port grows an
# algorithm.
- name: Verify the kernel provides the algorithms the port needs
run: |
cat > "$RUNNER_TEMP/afalg-probe.c" <<'EOF'
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <linux/if_alg.h>
static const char* types[] = {
"hash", "skcipher", "skcipher", "skcipher", "aead"
};
static const char* names[] = {
"sha256", "cbc(aes)", "ecb(aes)", "ctr(aes)", "gcm(aes)"
};
int main(void)
{
struct sockaddr_alg sa;
size_t i;
int fd;
int missing = 0;
for (i = 0; i < sizeof(types) / sizeof(types[0]); i++) {
fd = socket(AF_ALG, SOCK_SEQPACKET, 0);
if (fd < 0) {
printf("::error::socket(AF_ALG) unavailable on this kernel\n");
return 1;
}
memset(&sa, 0, sizeof(sa));
sa.salg_family = AF_ALG;
strncpy((char*)sa.salg_type, types[i], sizeof(sa.salg_type) - 1);
strncpy((char*)sa.salg_name, names[i], sizeof(sa.salg_name) - 1);
if (bind(fd, (struct sockaddr*)&sa, sizeof(sa)) < 0) {
printf("::error::kernel is missing %s/%s\n", types[i], names[i]);
missing = 1;
}
else {
printf("ok: %s/%s\n", types[i], names[i]);
}
close(fd);
}
return missing;
}
EOF
gcc -Wall -Werror -o "$RUNNER_TEMP/afalg-probe" "$RUNNER_TEMP/afalg-probe.c"
"$RUNNER_TEMP/afalg-probe"
# ccache via the cross-platform composite; the script passes the
# compiler to configure as CC="ccache gcc" (or a per-config "cc").
- name: Set up ccache
uses: ./.github/actions/ccache-setup
with:
workflow-id: afalg
read-only: ${{ github.event_name == 'pull_request' }}
max-size: 100M
- name: Build all configs (parallel, out-of-tree)
run: |
cat > "$RUNNER_TEMP/afalg-configs.json" <<'EOF'
[
{"name": "defaults-afalg", "minutes": 2,
"configure": ["--enable-afalg"],
"cflags": "-pedantic -Wdeclaration-after-statement -Wnull-dereference -Wno-overlength-strings"},
{"name": "all-afalg", "minutes": 5,
"configure": ["--enable-all", "--enable-testcert", "--enable-acert",
"--enable-dtls13", "--enable-dtls-mtu", "--enable-dtls-frag-ch",
"--enable-dtlscid", "--enable-quic", "--enable-afalg",
"--disable-srtp", "--disable-sha224", "--disable-hashflags",
"--disable-cryptocb", "--disable-aesgcm-stream"],
"cflags": "-pedantic -Wdeclaration-after-statement -Wnull-dereference -Wno-overlength-strings"}
]
EOF
.github/scripts/parallel-make-check.py \
${{ github.event_name == 'schedule' && '--build-only' || '' }} \
--private-dir=certs \
"$RUNNER_TEMP/afalg-configs.json"
- name: ccache stats
if: always()
run: ccache -s || true
- name: Upload logs on failure
if: failure()
uses: actions/upload-artifact@v6
with:
retention-days: 7
name: afalg-logs
path: |
build-*/make-check.log
build-*/test-suite.log
build-*/config.log
if-no-files-found: ignore