Fix FIPS package issues
* Fixes 7z extraction issues, mostly around using password when the password has already been stripped out * Fixes autoreconf and configure issues with the FIPS package * Fixes wolfcrypttest and wolfcryptbenchmark not being isntalled with FIPS when they are selectedpull/117/head
parent
182a7bee36
commit
ebfc6619cb
|
|
@ -74,6 +74,7 @@ COMMERCIAL_BUNDLE_TARGET ?= "${WORKDIR}"
|
|||
python do_commercial_extract() {
|
||||
import os
|
||||
import bb
|
||||
import bb.process
|
||||
|
||||
bundle_dir = d.getVar('COMMERCIAL_BUNDLE_DIR')
|
||||
bundle_name = d.getVar('COMMERCIAL_BUNDLE_NAME')
|
||||
|
|
@ -102,13 +103,23 @@ python do_commercial_extract() {
|
|||
if ret != 0:
|
||||
bb.fatal(f"Failed to copy bundle to {target_dir}")
|
||||
|
||||
# Locate 7zip binary from native sysroot or host
|
||||
path = d.getVar('PATH')
|
||||
seven_zip = bb.utils.which(path, '7za') or bb.utils.which(path, '7z')
|
||||
|
||||
if not seven_zip:
|
||||
bb.fatal("Failed to find either '7za' or '7z' in PATH.\n"
|
||||
"Ensure p7zip-native is available or install p7zip on the build host.")
|
||||
|
||||
# Extract with password
|
||||
cmd = f'7za x "{target_dir}/{bundle_name}.7z" -p"{bundle_pass}" -o"{target_dir}" -aoa'
|
||||
ret = os.system(cmd)
|
||||
|
||||
if ret != 0:
|
||||
bb.fatal(f"Failed to extract bundle. Check password and bundle integrity.")
|
||||
|
||||
cmd = [seven_zip, 'x', f"{target_dir}/{bundle_name}.7z", f"-p{bundle_pass}",
|
||||
f"-o{target_dir}", '-aoa']
|
||||
|
||||
try:
|
||||
bb.process.run(cmd)
|
||||
except bb.process.ExecutionError as exc:
|
||||
bb.fatal("Failed to extract bundle. Check password and bundle integrity.\n" + str(exc))
|
||||
|
||||
bb.plain("Commercial bundle extracted successfully")
|
||||
}
|
||||
|
||||
|
|
@ -120,6 +131,30 @@ python __anonymous() {
|
|||
enabled = d.getVar('COMMERCIAL_BUNDLE_ENABLED')
|
||||
if enabled == "1":
|
||||
d.appendVar('DEPENDS', ' p7zip-native')
|
||||
d.appendVarFlag('do_commercial_extract', 'depends', ' p7zip-native:do_populate_sysroot')
|
||||
opts = d.getVar('CONFIGUREOPTS') or ''
|
||||
import shlex
|
||||
tokens = shlex.split(opts)
|
||||
tokens = [t for t in tokens if not t.startswith('--with-libtool-sysroot=')]
|
||||
d.setVar('CONFIGUREOPTS', ' '.join(tokens))
|
||||
}
|
||||
|
||||
# Skip autoreconf for commercial bundles and rely on bundled configure script
|
||||
do_configure() {
|
||||
if [ "${COMMERCIAL_BUNDLE_ENABLED}" = "1" ]; then
|
||||
bbnote "Commercial bundle detected, skipping autoreconf and running bundled configure"
|
||||
if [ ! -f "${S}/stamp-h.in" ] && grep -q "AC_CONFIG_FILES(\\[stamp-h\\]" "${S}/configure.ac"; then
|
||||
bbnote "stamp-h.in missing; generating stub for preconfigured commercial source"
|
||||
echo "timestamp" > "${S}/stamp-h.in"
|
||||
fi
|
||||
if [ -e "${CONFIGURE_SCRIPT}" ]; then
|
||||
oe_runconf
|
||||
else
|
||||
bbfatal "configure script not found at ${CONFIGURE_SCRIPT}"
|
||||
fi
|
||||
else
|
||||
autotools_do_configure
|
||||
fi
|
||||
}
|
||||
|
||||
# Task to create stub autogen.sh for commercial bundles
|
||||
|
|
@ -142,4 +177,4 @@ do_commercial_stub_autogen() {
|
|||
}
|
||||
|
||||
# Add task after commercial_extract, before configure
|
||||
addtask commercial_stub_autogen after do_commercial_extract before do_configure
|
||||
addtask commercial_stub_autogen after do_commercial_extract before do_configure
|
||||
|
|
|
|||
|
|
@ -1,27 +1,19 @@
|
|||
# Configuration to enable wolfcryptbenchmark support in wolfssl
|
||||
EXTRA_OECONF += "--enable-crypttests"
|
||||
|
||||
WOLFCRYPT_BENCHMARK_DIR = "${B}/wolfcrypt/benchmark/.libs"
|
||||
WOLFCRYPT_BENCHMARK = "benchmark"
|
||||
WOLFCRYPT_BENCHMARK_YOCTO = "wolfcryptbenchmark"
|
||||
WOLFCRYPT_INSTALL_DIR = "${D}${bindir}"
|
||||
|
||||
python () {
|
||||
# Get the environment variables WOLFCRYPT_BENCHMARK_DIR, WOLFCRYPT_BENCHMARK,
|
||||
# WOLFCRYPT_BENCHMARK_YOCTO, and WOLFCRYPT_INSTALL_DIR
|
||||
wolfcrypt_benchmark_dir = d.getVar('WOLFCRYPT_BENCHMARK_DIR', True)
|
||||
wolfcrypt_benchmark = d.getVar('WOLFCRYPT_BENCHMARK', True)
|
||||
wolfcrypt_benchmark_yocto = d.getVar('WOLFCRYPT_BENCHMARK_YOCTO', True)
|
||||
wolfcrypt_install_dir = d.getVar('WOLFCRYPT_INSTALL_DIR', True)
|
||||
files_var = 'FILES:' + d.getVar('PN')
|
||||
d.appendVar(files_var, ' ${bindir}/wolfcryptbenchmark')
|
||||
}
|
||||
|
||||
bbnote = 'bbnote "Installing wolfCrypt Benchmarks"\n'
|
||||
installDir = 'install -m 0755 -d "%s"\n' % (wolfcrypt_install_dir)
|
||||
cpBenchmark = 'cp "%s/%s" "%s/%s"\n' % (wolfcrypt_benchmark_dir, wolfcrypt_benchmark, wolfcrypt_install_dir, wolfcrypt_benchmark_yocto)
|
||||
do_install:append() {
|
||||
bbnote "Installing wolfCrypt Benchmarks"
|
||||
if [ ! -x "${B}/wolfcrypt/benchmark/.libs/benchmark" ]; then
|
||||
bbwarn "wolfCrypt benchmark binary missing at ${B}/wolfcrypt/benchmark/.libs/benchmark"
|
||||
return
|
||||
fi
|
||||
|
||||
d.appendVar('do_install', bbnote)
|
||||
d.appendVar('do_install', installDir)
|
||||
d.appendVar('do_install', cpBenchmark)
|
||||
install -Dm0755 "${B}/wolfcrypt/benchmark/.libs/benchmark" "${D}${bindir}/wolfcryptbenchmark"
|
||||
}
|
||||
|
||||
TARGET_CFLAGS += "-DUSE_CERT_BUFFERS_2048 -DUSE_CERT_BUFFERS_256 -DBENCH_EMBEDDED"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,27 +1,19 @@
|
|||
# Configuration to enable wolfcrypttest support in wolfssl
|
||||
EXTRA_OECONF += "--enable-crypttests"
|
||||
|
||||
WOLFCRYPT_TEST_DIR = "${B}/wolfcrypt/test/.libs"
|
||||
WOLFCRYPT_TEST = "testwolfcrypt"
|
||||
WOLFCRYPT_TEST_YOCTO = "wolfcrypttest"
|
||||
WOLFCRYPT_INSTALL_DIR = "${D}${bindir}"
|
||||
|
||||
python () {
|
||||
# Get the environment variables WOLFCRYPT_TEST_DIR, WOLFCRYPT_TEST,
|
||||
# WOLFCRYPT_TEST_YOCTO, and WOLFCRYPT_INSTALL_DIR
|
||||
wolfcrypt_test_dir = d.getVar('WOLFCRYPT_TEST_DIR', True)
|
||||
wolfcrypt_test = d.getVar('WOLFCRYPT_TEST', True)
|
||||
wolfcrypt_test_yocto = d.getVar('WOLFCRYPT_TEST_YOCTO', True)
|
||||
wolfcrypt_install_dir = d.getVar('WOLFCRYPT_INSTALL_DIR', True)
|
||||
files_var = 'FILES:' + d.getVar('PN')
|
||||
d.appendVar(files_var, ' ${bindir}/wolfcrypttest')
|
||||
}
|
||||
|
||||
bbnote = 'bbnote "Installing wolfCrypt Tests"\n'
|
||||
installDir = 'install -m 0755 -d "%s"\n' % (wolfcrypt_install_dir)
|
||||
cpTest = 'cp "%s/%s" "%s/%s"\n' % (wolfcrypt_test_dir, wolfcrypt_test, wolfcrypt_install_dir, wolfcrypt_test_yocto)
|
||||
do_install:append() {
|
||||
bbnote "Installing wolfCrypt Tests"
|
||||
if [ ! -x "${B}/wolfcrypt/test/.libs/testwolfcrypt" ]; then
|
||||
bbwarn "wolfCrypt test binary missing at ${B}/wolfcrypt/test/.libs/testwolfcrypt"
|
||||
return
|
||||
fi
|
||||
|
||||
d.appendVar('do_install', bbnote)
|
||||
d.appendVar('do_install', installDir)
|
||||
d.appendVar('do_install', cpTest)
|
||||
install -Dm0755 "${B}/wolfcrypt/test/.libs/testwolfcrypt" "${D}${bindir}/wolfcrypttest"
|
||||
}
|
||||
|
||||
TARGET_CFLAGS += "-DUSE_CERT_BUFFERS_2048 -DUSE_CERT_BUFFERS_256 -DWOLFSSL_RSA_KEY_CHECK -DNO_WRITE_TEMP_FILES"
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
# Conditionally configure wolfssl-fips with wolfcryptbenchmark support
|
||||
# Mirrors the non-FIPS helper so benchmarks ride along when enabled.
|
||||
|
||||
inherit wolfssl-helper
|
||||
|
||||
python __anonymous() {
|
||||
wolfssl_conditional_require(d, 'wolfcryptbenchmark', 'inc/wolfcryptbenchmark/wolfssl-enable-wolfcryptbenchmark.inc')
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
# Conditionally configure wolfssl-fips with wolfcrypttest support
|
||||
# Matches the wolfssl variant so FIPS builds get the same helpers.
|
||||
|
||||
inherit wolfssl-helper
|
||||
|
||||
python __anonymous() {
|
||||
wolfssl_conditional_require(d, 'wolfcrypttest', 'inc/wolfcrypttest/wolfssl-enable-wolfcrypttest.inc')
|
||||
}
|
||||
Loading…
Reference in New Issue