Skip to content

Commit 1e1769b

Browse files
authored
Merge pull request #260 from ColtonWilley/wp_replace_default
Initial option to replace openssl default provider
2 parents 944195b + c8fa541 commit 1e1769b

28 files changed

+1348
-23
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Replace Default 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+
replace_default_test:
17+
name: Replace Default Test
18+
runs-on: ubuntu-22.04
19+
timeout-minutes: 30
20+
strategy:
21+
matrix:
22+
# Test both standard and replace-default builds
23+
replace_default: ['', '--replace-default']
24+
# Test with stable versions
25+
wolfssl_ref: ['v5.8.0-stable']
26+
openssl_ref: ['openssl-3.5.0']
27+
steps:
28+
- name: Checkout wolfProvider
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 1
32+
33+
- name: Build wolfProvider ${{ matrix.replace_default && 'with replace-default' || 'standard' }}
34+
run: |
35+
OPENSSL_TAG=${{ matrix.openssl_ref }} \
36+
WOLFSSL_TAG=${{ matrix.wolfssl_ref }} \
37+
./scripts/build-wolfprovider.sh ${{ matrix.replace_default }}
38+
39+
- name: Run standalone test suite
40+
run: |
41+
./test/standalone/runners/run_standalone_tests.sh
42+
43+
- name: Print errors on failure
44+
if: ${{ failure() }}
45+
run: |
46+
# Build failure log
47+
if [ -f scripts/build-release.log ]; then
48+
echo "=== Build log (last 50 lines) ==="
49+
tail -n 50 scripts/build-release.log
50+
fi
51+
52+
# Test suite failure log
53+
if [ -f test-suite.log ]; then
54+
echo "=== Test suite log ==="
55+
cat test-suite.log
56+
fi
57+
58+
# Standalone test failures
59+
if [ -d test/standalone/runners/test_results ]; then
60+
for log in test/standalone/runners/test_results/*.log; do
61+
if [ -f "$log" ]; then
62+
echo "=== $log ==="
63+
cat "$log"
64+
fi
65+
done
66+
fi

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,30 @@
6161
/wolfprov-install/
6262
/artifacts
6363

64+
# Default stub autotools files
65+
default_stub/ar-lib
66+
default_stub/compile
67+
default_stub/config.guess
68+
default_stub/config.sub
69+
default_stub/depcomp
70+
default_stub/install-sh
71+
default_stub/ltmain.sh
72+
default_stub/missing
73+
74+
# Build install directories
75+
*-install/
76+
77+
# Libtool archive files
78+
*.la
79+
80+
# Test artifacts in subdirectories
81+
test/**/*.log
82+
test/**/*.test
83+
test/**/*.trs
84+
test/**/*.o
85+
test/**/.deps/
86+
test/**/.dirstamp
87+
6488
IDE/Android/android-ndk-r26b/
6589
IDE/Android/openssl-source/
6690
IDE/Android/openssl-install/

Makefile.am

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
SUFFIXES =
2+
SUFFIXES =
33
TESTS =
44
noinst_PROGRAMS =
55
noinst_HEADERS =
@@ -14,6 +14,15 @@ AM_CPPFLAGS = -I$(top_srcdir)/include
1414

1515
lib_LTLIBRARIES = libwolfprov.la
1616

17+
# Conditionally build libdefault.so when --replace-default is enabled
18+
if BUILD_REPLACE_DEFAULT
19+
# Install libdefault.la directly to OpenSSL lib directory
20+
openssldir = $(OPENSSL_LIB_DIR)
21+
openssl_LTLIBRARIES = libdefault.la
22+
libdefault_la_SOURCES = src/wp_default_replace.c
23+
libdefault_la_LIBADD = libwolfprov.la
24+
endif
25+
1726
EXTRA_DIST+=ChangeLog.md
1827
EXTRA_DIST+=README.md
1928
EXTRA_DIST+=IDE

configure.ac

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,26 @@ AS_IF([ test "x$ENABLED_SINGLETHREADED" = "xno" ],[
123123
])
124124
])
125125

126+
# Replace default provider
127+
AC_ARG_ENABLE([replace-default],
128+
[AS_HELP_STRING([--enable-replace-default],[Build real libdefault.so from wp_default_replace.c (default: disabled).])],
129+
[ ENABLED_REPLACE_DEFAULT=$enableval ],
130+
[ ENABLED_REPLACE_DEFAULT=no ]
131+
)
126132

127-
133+
AM_CONDITIONAL([BUILD_REPLACE_DEFAULT], [test "x$ENABLED_REPLACE_DEFAULT" = "xyes"])
134+
135+
# Set OpenSSL lib directory for installing libdefault.so
136+
if test "x$ENABLED_REPLACE_DEFAULT" = "xyes"; then
137+
if test -d "$OPENSSL_INSTALL_DIR/lib64"; then
138+
OPENSSL_LIB_DIR="$OPENSSL_INSTALL_DIR/lib64"
139+
elif test -d "$OPENSSL_INSTALL_DIR/lib"; then
140+
OPENSSL_LIB_DIR="$OPENSSL_INSTALL_DIR/lib"
141+
else
142+
OPENSSL_LIB_DIR="$OPENSSL_INSTALL_DIR/lib"
143+
fi
144+
fi
145+
AC_SUBST([OPENSSL_LIB_DIR])
128146

129147

130148
AX_HARDEN_CC_COMPILER_FLAGS
@@ -170,6 +188,7 @@ echo
170188
echo " Features "
171189
echo " * User settings: $ENABLED_USERSETTINGS"
172190
echo " * Dynamic provider: $ENABLED_DYNAMIC_PROVIDER"
191+
echo " * Replace default: $ENABLED_REPLACE_DEFAULT"
173192
echo ""
174193
echo "---"
175194

default_stub/.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Makefile
2+
Makefile.in
3+
.deps/
4+
.libs/
5+
*.la
6+
*.lo
7+
*.o
8+
aclocal.m4
9+
autom4te.cache/
10+
config.log
11+
config.status
12+
configure
13+
libtool
14+
*.so
15+
*.so.*

default_stub/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lib_LTLIBRARIES = libdefault.la
2+
libdefault_la_SOURCES = wp_default_stub.c

default_stub/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# libdefault - Default Provider Stub Library
2+
3+
Minimal autotools build for a stub version of the default provider.
4+
5+
## Building
6+
7+
```bash
8+
# Generate build system
9+
./autogen.sh
10+
11+
# Configure and build
12+
./configure
13+
make
14+
15+
# Clean build artifacts
16+
make clean
17+
```
18+
19+
## Output
20+
21+
The build produces `libdefault.so` in the `.libs/` directory.

default_stub/autogen.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
autoreconf -fiv

default_stub/configure.ac

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
AC_INIT([libdefault], [1.0], [support@wolfssl.com])
2+
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
3+
AC_PROG_CC
4+
AM_PROG_AR
5+
LT_INIT
6+
AC_CONFIG_FILES([Makefile])
7+
AC_OUTPUT

default_stub/wp_default_stub.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (C) 2006-2024 wolfSSL Inc.
3+
*
4+
* This file is part of wolfProvider.
5+
*
6+
* wolfProvider is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* wolfProvider is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with wolfProvider. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
#include <openssl/provider.h>
21+
22+
/* Prototype of public function that initializes the wolfSSL provider. */
23+
OSSL_provider_init_fn wolfssl_provider_init;
24+
25+
/* Prototype for the wolfprov_provider_init function */
26+
int wolfprov_provider_init(const OSSL_CORE_HANDLE* handle,
27+
const OSSL_DISPATCH* in,
28+
const OSSL_DISPATCH** out,
29+
void** provCtx);
30+
31+
/*
32+
* Provider implementation stub
33+
*/
34+
int wolfprov_provider_init(const OSSL_CORE_HANDLE* handle,
35+
const OSSL_DISPATCH* in,
36+
const OSSL_DISPATCH** out,
37+
void** provCtx)
38+
{
39+
return 0;
40+
}

0 commit comments

Comments
 (0)