Skip to content

Commit 9eb464f

Browse files
committed
Add FIPS support for Debian package build
1 parent a27812e commit 9eb464f

File tree

9 files changed

+121
-46
lines changed

9 files changed

+121
-46
lines changed

.github/packages/debian-packages-20250731T171211Z-1-001.zip renamed to .github/packages/debian-wolfssl.tar.gz

28.6 MB
Binary file not shown.

.github/workflows/debian-package.yml

Lines changed: 55 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,22 @@ on:
55
branches: [ master ]
66
pull_request:
77
branches: [ '*' ]
8-
workflow_dispatch:
98

109
jobs:
11-
test-debian-package:
12-
runs-on: ubuntu-latest
13-
10+
bookworm:
11+
runs-on: ubuntu-22.04
12+
# Important: use Debian Bookworm for compatibility
13+
container:
14+
image: debian:bookworm # or debian:bookworm-slim
15+
env:
16+
DEBIAN_FRONTEND: noninteractive
1417
steps:
15-
- name: Checkout wolfProvider
16-
uses: actions/checkout@v4
17-
with:
18-
fetch-depth: 1
19-
- run: |
20-
# Fetch tags
21-
git fetch --tags
22-
# List all tags
23-
git tag -l
24-
2518
- name: Set up environment
2619
run: |
2720
# Update package lists
28-
sudo apt-get update
21+
apt-get update
2922
# Install build dependencies
30-
sudo apt-get install -y \
23+
apt-get install -y \
3124
build-essential \
3225
devscripts \
3326
debhelper \
@@ -44,27 +37,56 @@ jobs:
4437
fakeroot \
4538
equivs
4639
# Install additional tools for testing
47-
sudo apt-get install -y \
40+
apt-get install -y \
4841
expect \
4942
xxd
5043
51-
# TODO: this step rebuilds the package for the current architecture
52-
# we may be able to remove it if we can ensure the package supports
53-
# the architecture of the runner (most likely amd64)
54-
- name: Install custom wolfssl
44+
# Avoid "detected dubious ownership" warning
45+
- name: Ensure the working directory safe
46+
run: |
47+
git config --global --add safe.directory "$GITHUB_WORKSPACE"
48+
49+
- name: Checkout wolfProvider
50+
uses: actions/checkout@v4
51+
with:
52+
fetch-depth: 1
53+
- run: |
54+
# Fetch tags
55+
git fetch --tags
56+
# List all tags
57+
git tag -l
58+
59+
- name: Install wolfssl debian package
5560
run: |
5661
mkdir -p "$RUNNER_TEMP/wolfssl-pkg"
5762
cd "$RUNNER_TEMP/wolfssl-pkg"
58-
unzip $GITHUB_WORKSPACE/.github/packages/debian-packages-20250731T171211Z-1-001.zip
63+
64+
echo "Using standard wolfSSL package"
65+
tar -xvf $GITHUB_WORKSPACE/.github/packages/debian-wolfssl.tar.gz
66+
67+
# Get current architecture
68+
CURRENT_ARCH=$(dpkg --print-architecture)
69+
echo "Current architecture: $CURRENT_ARCH"
70+
71+
# Look for existing .deb files that match the current architecture
5972
cd debian-packages
60-
sudo dpkg-source -x wolfssl_5.8.2-1.dsc
61-
cd wolfssl-5.8.2
62-
sudo dpkg-buildpackage -b -us -uc
63-
sudo dpkg -i ../libwolfssl*.deb
73+
MATCHING_DEB_FILES=$(find . -name "*_${CURRENT_ARCH}.deb" -o -name "*_${CURRENT_ARCH}_*.deb" 2>/dev/null || true)
74+
75+
if [ -n "$MATCHING_DEB_FILES" ]; then
76+
echo "Found matching .deb files for architecture $CURRENT_ARCH:"
77+
echo "$MATCHING_DEB_FILES"
78+
echo "Installing existing .deb files..."
79+
dpkg -i $MATCHING_DEB_FILES
80+
else
81+
echo "No matching .deb files found for architecture $CURRENT_ARCH, rebuilding from source..."
82+
dpkg-source -x wolfssl*.dsc
83+
cd wolfssl*/
84+
dpkg-buildpackage -b -us -uc
85+
dpkg -i ../libwolfssl*.deb
86+
fi
6487
6588
- name: Build Debian package
6689
run: |
67-
# Run the build script
6890
# Bypass the warning prompt with 'yes Y'
6991
yes Y | ./scripts/build-wolfprovider.sh --debian
7092
@@ -83,7 +105,7 @@ jobs:
83105
fi
84106
85107
echo "Installing package: $PACKAGE_FILE and dependencies"
86-
sudo apt install -y ./"$PACKAGE_FILE"
108+
apt install -y ./"$PACKAGE_FILE"
87109
88110
# Verify installation
89111
echo "Package Installation Verification:"
@@ -99,7 +121,7 @@ jobs:
99121
echo "3. Temporarily disabling wolfprovider for default provider tests:"
100122
mkdir -p /tmp/openssl-test
101123
if [ -f $PROVIDER_CONF ]; then
102-
sudo mv $PROVIDER_CONF $PROVIDER_CONF_BACKUP
124+
mv $PROVIDER_CONF $PROVIDER_CONF_BACKUP
103125
echo " - Moved $PROVIDER_CONF to $PROVIDER_CONF_BACKUP"
104126
else
105127
echo "$PROVIDER_CONF not found!"
@@ -113,7 +135,7 @@ jobs:
113135
# Restore wolfprovider configuration
114136
echo "5. Restoring wolfprovider configuration:"
115137
if [ -f $PROVIDER_CONF_BACKUP ]; then
116-
sudo mv $PROVIDER_CONF_BACKUP $PROVIDER_CONF
138+
mv $PROVIDER_CONF_BACKUP $PROVIDER_CONF
117139
echo " - Restored $PROVIDER_CONF from $PROVIDER_CONF_BACKUP"
118140
fi
119141
@@ -122,7 +144,7 @@ jobs:
122144
- name: Uninstall package and verify cleanup
123145
run: |
124146
# Uninstall the package
125-
sudo apt-get remove --purge -y libwolfprov
147+
apt-get remove --purge -y libwolfprov
126148
127149
# Verify the package is removed
128150
if dpkg -l | grep -q libwolfprov; then
@@ -182,9 +204,9 @@ jobs:
182204
if: always()
183205
uses: actions/upload-artifact@v4
184206
with:
185-
name: debian-packages
207+
name: wolfprovider-debian-packages
186208
path: |
187209
${{ runner.temp }}/*.deb
188210
${{ runner.temp }}/*.dsc
189211
${{ runner.temp }}/*.tar.gz
190-
retention-days: 7
212+
retention-days: 7

debian/control

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ Build-Depends: debhelper (>= 12),
77
devscripts,
88
pkgconf,
99
openssl,
10-
libssl-dev,
1110
libwolfssl,
1211
libwolfssl-dev
1312

13+
1414
Package: libwolfprov
1515
Architecture: any
16-
Depends: ${shlibs:Depends}, ${misc:Depends}, libwolfssl, openssl
17-
Description: wolfProvider library for OpenSSL
16+
Depends: ${shlibs:Depends}, ${misc:Depends}, libssl3 (>= 3.0.3), libwolfssl (>= 5.8.2), openssl
17+
Provides: ${variant:provides}
18+
XB-Variant: ${variant}
19+
Description: wolfProvider library for OpenSSL — ${variant:desc}
1820
wolfProvider is a library that can be used as a Provider in OpenSSL.
1921
It provides cryptographic functionality through wolfSSL including:
2022
.

debian/rules

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,47 @@ DEB_HOST_MULTIARCH := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
88
# Destination directory for installation
99
DESTDIR=debian/tmp
1010

11+
# Grab the base version from debian/changelog
12+
BASEVER := $(shell dpkg-parsechangelog -SVersion)
13+
14+
# Check if FIPS build is requested
15+
WOLFSSL_ISFIPS?=0
16+
# Variant-specific metadata
17+
ifeq ($(WOLFSSL_ISFIPS),1)
18+
VARIANT := fips
19+
VARIANT_DESC := FIPS build
20+
VARIANT_PROVIDES := libwolfprov-fips
21+
VERSION := $(BASEVER)+fips
22+
FIPS_FLAG := --enable-fips
23+
PROVIDER_CONF := provider-fips.conf
24+
else
25+
VARIANT := non-fips
26+
VARIANT_DESC := non-FIPS build
27+
VARIANT_PROVIDES := libwolfprov-nonfips
28+
VERSION := $(BASEVER)
29+
PROVIDER_CONF := provider.conf
30+
FIPS_FLAG :=
31+
endif
32+
33+
# Override just the control-file generation to inject our values
34+
override_dh_gencontrol:
35+
dh_gencontrol -- \
36+
-v$(VERSION) \
37+
-Vvariant=$(VARIANT) \
38+
-Vvariant:desc="$(VARIANT_DESC)" \
39+
-Vvariant:provides="$(VARIANT_PROVIDES)"
40+
1141
override_dh_auto_configure:
12-
./autogen.sh
13-
./configure
42+
# None, handled below
1443

1544
override_dh_auto_build:
16-
make -j$(shell nproc)
45+
./scripts/build-wolfprovider.sh $(FIPS_FLAG)
1746

1847
override_dh_auto_install:
1948
# Install library
2049
install -d $(DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/ossl-modules
2150
install -m755 ./.libs/libwolfprov.so* \
2251
$(DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/ossl-modules/
23-
install -m755 ./.libs/libwolfprov.la* \
24-
$(DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)/ossl-modules/
2552

2653
# Install headers
2754
install -d $(DESTDIR)/usr/include/wolfprovider
@@ -30,7 +57,7 @@ override_dh_auto_install:
3057

3158
# Install provider config file
3259
install -d $(DESTDIR)/etc/ssl/openssl.cnf.d
33-
install -m644 ./provider.conf \
60+
install -m644 ./$(PROVIDER_CONF) \
3461
$(DESTDIR)/etc/ssl/openssl.cnf.d/wolfprovider.conf
3562

3663
override_dh_auto_clean:

scripts/build-debian.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ git archive --format=tar.gz --prefix="${TARBALL_PREFIX}/" \
110110

111111
# Step 10: Build package
112112
echo "⚙️ Building package..."
113-
debuild -us -uc
113+
WOLFSSL_ISFIPS=${WOLFSSL_ISFIPS:-0}
114+
debuild --set-envvar WOLFSSL_ISFIPS=${WOLFSSL_ISFIPS} -us -uc
114115

115116
echo "✅ Build completed for version $VERSION"

scripts/build-wolfprovider.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ show_help() {
1919
echo " --fips-check=TAG Choose a FIPS tag to clone. May require a version to be given by --fips-version"
2020
echo " --fips-version=VER Choose the wolfSSL FIPS version"
2121
echo " --debian Build a Debian package"
22+
echo " --debian --enable-fips Build a Debian package with FIPS support"
2223
echo " --quicktest Disable some tests for a faster testing suite"
2324
echo ""
2425
echo "Environment Variables:"
@@ -128,7 +129,7 @@ fi
128129

129130
if [ -n "$build_debian" ]; then
130131
echo "Building Debian package..."
131-
./scripts/build-debian.sh
132+
WOLFSSL_ISFIPS=${WOLFSSL_ISFIPS:-0} ./scripts/build-debian.sh
132133
exit $?
133134
fi
134135

scripts/cmd_test/ecc-cmd-test.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ test_sign_verify_pkeyutl() {
157157
fi
158158

159159
# Test 3: Cross-provider verification (default sign, wolf verify)
160-
echo "Current FAIL status: $FAIL"
161160
if [ $FAIL -eq 0 ]; then # only verify if previous tests passed
162161
use_wolf_provider
163162
echo "Test 3: Cross-provider verification (default sign, wolf verify)"

scripts/utils-wolfprovider.sh

100755100644
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,20 @@ source ${SCRIPT_DIR}/utils-general.sh
2525

2626
WOLFPROV_SOURCE_DIR=${SCRIPT_DIR}/..
2727
WOLFPROV_INSTALL_DIR=${SCRIPT_DIR}/../wolfprov-install
28-
WOLFPROV_CONFIG_OPTS=${WOLFPROV_CONFIG_OPTS:-"--with-openssl=${OPENSSL_INSTALL_DIR} --with-wolfssl=${WOLFSSL_INSTALL_DIR} --prefix=${WOLFPROV_INSTALL_DIR}"}
28+
WOLFPROV_WITH_WOLFSSL=--with-wolfssl=${WOLFSSL_INSTALL_DIR}
29+
30+
# Check if using system wolfSSL installation
31+
if command -v dpkg >/dev/null 2>&1; then
32+
if dpkg -l | grep -q "^ii.*libwolfssl[[:space:]]" && dpkg -l | grep -q "^ii.*libwolfssl-dev[[:space:]]"; then
33+
printf "\nSkipping wolfSSL installation - libwolfssl and libwolfssl-dev packages are already installed.\n"
34+
WOLFPROV_WITH_WOLFSSL=
35+
fi
36+
fi
37+
38+
WOLFPROV_CONFIG_OPTS=${WOLFPROV_CONFIG_OPTS:-"--with-openssl=${OPENSSL_INSTALL_DIR} ${WOLFPROV_WITH_WOLFSSL} --prefix=${WOLFPROV_INSTALL_DIR}"}
2939
WOLFPROV_CONFIG_CFLAGS=${WOLFPROV_CONFIG_CFLAGS:-''}
3040

41+
3142
if [ "${WOLFPROV_QUICKTEST}" = "1" ]; then
3243
WOLFPROV_CONFIG_CFLAGS="${WOLFPROV_CONFIG_CFLAGS} -DWOLFPROV_QUICKTEST"
3344
fi

scripts/utils-wolfssl.sh

100755100644
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,18 @@ clone_wolfssl() {
8888
}
8989

9090
install_wolfssl() {
91+
# Check if libwolfssl and libwolfssl-dev packages are already installed
92+
# This is allowed only for wolfSSL, but not for OpenSSL because we want to
93+
# use the custom OpenSSL built with wolfProvider.
94+
if command -v dpkg >/dev/null 2>&1; then
95+
if dpkg -l | grep -q "^ii.*libwolfssl[[:space:]]" && dpkg -l | grep -q "^ii.*libwolfssl-dev[[:space:]]"; then
96+
printf "\nSkipping wolfSSL installation - libwolfssl and libwolfssl-dev packages are already installed.\n"
97+
# Set WOLFSSL_INSTALL_DIR to system installation directory
98+
WOLFSSL_INSTALL_DIR="/usr"
99+
return 0
100+
fi
101+
fi
102+
91103
printf "\nInstalling wolfSSL ${WOLFSSL_TAG} ...\n"
92104
clone_wolfssl
93105
cd ${WOLFSSL_SOURCE_DIR}

0 commit comments

Comments
 (0)