🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.gentoo.dev
Article #237

[gentoo-dev] [PATCH 2/6] kernel-build.eclass: support PKCS#11 keys with OpenSSL 4

#237
From: David Seifert
Date: Tue, 01 Dec 2026 16:00
80 lines
4140 bytes
OpenSSL 4 dropped the ENGINE API. Use pkcs11-provider for the key checks
and ukify. ukify can only pass an engine to sbsign, so die early when
that combination would fail.

Signed-off-by: David Seifert <soap@gentoo.org>
---
 eclass/kernel-build.eclass | 37 ++++++++++++++++++++++++++++++++-----
 1 file changed, 32 insertions(+), 5 deletions(-)

diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass
index a66481aeeb5cc..f8e5abbca4a92 100644
--- a/eclass/kernel-build.eclass
+++ b/eclass/kernel-build.eclass
@@ -178,7 +178,12 @@ kernel-build_pkg_setup() {
 				openssl_args+=( -inform PEM -in "${MODULES_SIGN_KEY}" )
 			fi
 			if [[ ${MODULES_SIGN_KEY} == pkcs11:* ]]; then
-				openssl_args+=( -engine pkcs11 -keyform ENGINE -key "${MODULES_SIGN_KEY}" )
+				# OpenSSL 4 removed the ENGINE API
+				if has_version -b ">=dev-libs/openssl-4"; then
+					openssl_args+=( -provider default -provider pkcs11 -key "${MODULES_SIGN_KEY}" )
+				else
+					openssl_args+=( -engine pkcs11 -keyform ENGINE -key "${MODULES_SIGN_KEY}" )
+				fi
 			else
 				openssl_args+=( -keyform PEM -key "${MODULES_SIGN_KEY}" )
 			fi
@@ -196,6 +201,16 @@ kernel-build_pkg_setup() {
 		fi
 
 		if [[ ${KERNEL_IUSE_GENERIC_UKI} ]] && use generic-uki; then
+			# ukify can only pass an engine to sbsign, which
+			# sbsigntools-0.9.5_p1 replaced with providers
+			if use secureboot &&
+				[[ ${SECUREBOOT_SIGN_KEY} == pkcs11:* &&
+					${SECUREBOOT_SIGN_TOOL} == sbsign ]] &&
+				has_version -b ">=app-crypt/sbsigntools-0.9.5_p1"
+			then
+				die "USE=generic-uki with a PKCS#11 SECUREBOOT_SIGN_KEY requires SECUREBOOT_SIGN_TOOL=systemd-sbsign"
+			fi
+
 			if [[ -n ${MEASUREDBOOT_SIGN_KEY} ]]; then
 				if [[ -z ${MEASUREDBOOT_SIGN_CERT} ]]; then
 					ewarn "A MEASUREDBOOT_SIGN_KEY was specified but no MEASUREDBOOT_SIGN_CERT"
@@ -209,7 +224,12 @@ kernel-build_pkg_setup() {
 					-noout -nocert
 				)
 				if [[ ${MEASUREDBOOT_SIGN_KEY} == pkcs11:* ]]; then
-					openssl_args+=( -engine pkcs11 -keyform ENGINE -key "${MEASUREDBOOT_SIGN_KEY}" )
+					# OpenSSL 4 removed the ENGINE API
+					if has_version -b ">=dev-libs/openssl-4"; then
+						openssl_args+=( -provider default -provider pkcs11 -key "${MEASUREDBOOT_SIGN_KEY}" )
+					else
+						openssl_args+=( -engine pkcs11 -keyform ENGINE -key "${MEASUREDBOOT_SIGN_KEY}" )
+					fi
 				else
 					openssl_args+=( -keyform PEM -key "${MEASUREDBOOT_SIGN_KEY}" )
 				fi
@@ -682,9 +702,16 @@ kernel-build_src_install() {
 
 			if use secureboot; then
 				if [[ ${SECUREBOOT_SIGN_KEY} == pkcs11:* ]]; then
-					ukify_args+=(
-						--signing-engine="pkcs11"
-					)
+					# OpenSSL 4 removed the ENGINE API
+					if has_version -b ">=dev-libs/openssl-4"; then
+						ukify_args+=(
+							--signing-provider="pkcs11"
+						)
+					else
+						ukify_args+=(
+							--signing-engine="pkcs11"
+						)
+					fi
 				fi
 				# systemd-sbsign does not support --sign-kernel.
 				# Disable unconditionally since we know the kernel
-- 
2.56.1
Technical Details
Message-ID: <O5yqR-fmyc-9@gated-at.bofh.it>
Path: mbox-mo1.pugleaf.net!news-ams.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod
References: <O5yqR-fmyc-3@gated-at.bofh.it>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-ams.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod
From: David Seifert <soap@gentoo.org>
Newsgroups: linux.gentoo.dev
Subject: [gentoo-dev] [PATCH 2/6] kernel-build.eclass: support PKCS#11 keys with OpenSSL 4
Date: Tue, 01 Dec 2026 17:00:01 +0100
Message-ID: <O5yqR-fmyc-9@gated-at.bofh.it>
References: <O5yqR-fmyc-3@gated-at.bofh.it>
X-Mailer: git-send-email 2.56.1
List-ID: Gentoo Linux mail <gentoo-dev.gentoo.org>
Reply-To: gentoo-dev@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Approved: robomod@news.nic.it
Lines: 80
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Cc: David Seifert <soap@gentoo.org>
X-Original-Date: Tue,  1 Dec 2026 16:49:20 +0100
X-Original-Message-ID: <20261201154924.70252-2-soap@gentoo.org>
X-Original-References: <20261201154924.70252-1-soap@gentoo.org>