Skip to contentSkip to conversation

Add support for OpenSSL Provider API

PATCH In review Eddie Kovsky 6 participants 22 messages Oct 29 – Nov 20

lore
Share & tools
lore
#0 lore raw

v5 cover Add support for OpenSSL Provider API

The Engine API has been deprecated since the release of OpenSSL 3.0. End users have been advised to migrate to the new Provider interface. Several distributions have already removed support for engines, which is preventing U-Boot from being compiled in those environments.

This series adds support for the OpenSSL Provider API while continuing to support the existing Engine API on distros shipping older releases of OpenSSL. Build dependencies for local development and CI are also updated, while the final patch adds support for using hardware tokens with the Provider API.

The changes have been tested with the FIT signature verification vboot tests on Fedora 44, Debian 13, and RHEL 8 with OpenSSL 1.1.1. All 37 tests pass with both the legacy Engine library installed and with the Provider API.

---
Changes in v5:
- Fix Tested-by trailers
- Change error string in drain_openssl_errors()
- Additional testing on RHEL 8 with openssl 1.1.1
- Tested hardware token signing path with SoftHSM
v4: https://lore.kernel.org/u-boot/[email protected]/

Changes in v4:
- Add comment that @engine pointer is null when using pkcs11 provider
- Remove extra line break
- Add pkcs11-provider package to build dependencies
v3: https://lore.kernel.org/u-boot/[email protected]/

Changes in v3:
- Removed Kconfig option
- Changed macro symbol from CONFIG_OPENSSL_NO_DEPRECATED to USE_PKCS11_PROVIDER or USE_PKCS11_ENGINE
v2: https://lore.kernel.org/u-boot/[email protected]/

Changes in v2:
- Remove default for new Kconfig option
- Use #ifdef instead of IS_ENABLED macro
- Remove comment after #endif
- Remove unrelated checkpatch cleanup of 'sslErr' variable name
v1: https://lore.kernel.org/u-boot/[email protected]/
---

Eddie Kovsky (3):
Add support for OpenSSL Provider API
Add pkcs11-provider package to build dependencies
rsa: load a pkcs11 token key through OSSL_STORE in the provider path

 doc/build/gcc.rst       |   4 +-
 lib/aes/aes-encrypt.c   |   4 +-
 lib/rsa/rsa-sign.c      | 194 ++++++++++++++++++++++++++++++++++++++--
 tools/docker/Dockerfile |   1 +
 4 files changed, 195 insertions(+), 8 deletions(-)
Signature · 1 line
2.56.0
#1 lore raw

PATCH v5 1/3 Add support for OpenSSL Provider API

Add support for the Provider API while continuing to support the existing Engine API on distros shipping older releases of OpenSSL.

This is based on similar work contributed by Jan Stancek updating Linux to use the Provider interface.

commit 558bdc45dfb2669e1741384a0c80be9c82fa052c
Author: Jan Stancek <[email protected]>
Date: Fri Sep 20 19:52:48 2024 +0300

sign-file,extract-cert: use pkcs11 provider for OPENSSL MAJOR >= 3

---
 lib/aes/aes-encrypt.c |   4 +-
 lib/rsa/rsa-sign.c    | 102 +++++++++++++++++++++++++++++++++++++++---
 2 files changed, 100 insertions(+), 6 deletions(-)
lib/aes/aes-encrypt.c +3 -1
index def33a3b3248..0cb2221df800 100644
@@ -16,7 +16,9 @@
 #include <openssl/err.h>
 #include <openssl/ssl.h>
 #include <openssl/evp.h>
-#include <openssl/engine.h>
+#if !defined(OPENSSL_NO_ENGINE) && !defined(OPENSSL_NO_DEPRECATED_3_0)
+# include <openssl/engine.h>
+#endif
 #include <uboot_aes.h>
 
 #if OPENSSL_VERSION_NUMBER >= 0x10000000L
lib/rsa/rsa-sign.c +97 -5

234 lines not on this page · raw message

Signature · 1 line
2.56.0
#2 lore raw

Hi Eddie,

Quoted 1 line · Eddie Kovsky

Add support for OpenSSL Provider API

Please can you add a prefix, e.g. 'rsa: Add support for the OpenSSL Provider API' here? Also, the commit message says the Engine API is kept for older OpenSSL releases but doesn't say that engine support is dropped completely on OpenSSL 3.x, even though 3.x still has engines (deprecated, but present). This means 'mkimage -N' stops working there, so please can you say so in the commit message and explain why?

lib/aes/aes-encrypt.c line 18

Quoted 6 lines
lib/aes/aes-encrypt.c +3 -1
@@ -16,7 +16,9 @@
-#include <openssl/engine.h>
+#if !defined(OPENSSL_NO_ENGINE) && !defined(OPENSSL_NO_DEPRECATED_3_0)
+# include <openssl/engine.h>
+#endif

As far as I can see nothing in aes-encrypt.c uses the engine API, so you could just drop this include.

lib/rsa/rsa-sign.c line 27

Quoted 11 lines
lib/rsa/rsa-sign.c +9 -0
@@ -19,7 +19,47 @@
+#ifdef USE_PKCS11_PROVIDER
+#define ERR(cond, fmt, ...)				\
+	do {						\
+		bool __cond = (cond);			\
+		drain_openssl_errors(__LINE__, 0);	\
+		if (__cond) {				\
+			errx(1, fmt, ## __VA_ARGS__);	\
+		}					\
+	} while (0)

This comes from the Linux sign-file tool. That is a standalone program, so errx() is fine there. Here we are in library code called from mkimage, binman and so on, and the rest of the file reports failures by returning an error code. Please can you use rsa_err() and return an error instead? Then the ERR() macro, drain_openssl_errors() (whose 'silent' argument is always 0) and the <err.h> include can all go.

lib/rsa/rsa-sign.c static int rsa_pem_get_priv_key(const char *keydir, const char *name, · line 258

Quoted 10 lines
lib/rsa/rsa-sign.c +8 -0
@@ -207,13 +251,44 @@ static int rsa_pem_get_priv_key(const char *keydir, const char *name,
+#ifdef USE_PKCS11_PROVIDER
+	EVP_PKEY *private_key = NULL;
+	OSSL_STORE_CTX *store;
+
+	if (!OSSL_PROVIDER_try_load(NULL, "pkcs11", true))
+		ERR(1, "OSSL_PROVIDER_try_load(pkcs11)");
+	if (!OSSL_PROVIDER_try_load(NULL, "default", true))
+		ERR(1, "OSSL_PROVIDER_try_load(default)");

Hmmm, this path handles ordinary PEM key files, but it now needs the pkcs11 provider, and mkimage exits if that is missing. So anyone signing with a plain .key file on OpenSSL 3 now needs pkcs11-provider, which I suspect is why patch 2 adds it. As far as I know PEM_read_PrivateKey() is not deprecated in 3.x, so is any change needed here at all? I'd suggest keeping the existing PEM code for files and only using OSSL_STORE with the pkcs11 provider for a 'pkcs11:' URI, as patch 3 already does. What do you think?

lib/rsa/rsa-sign.c static int rsa_pem_get_priv_key(const char *keydir, const char *name, · line 272

Quoted 7 lines
lib/rsa/rsa-sign.c +7 -0
+	while (!OSSL_STORE_eof(store)) {
+		OSSL_STORE_INFO *info = OSSL_STORE_load(store);
+
+		if (!info) {
+			drain_openssl_errors(__LINE__, 0);
+			continue;
+		}

If OSSL_STORE_load() keeps failing before EOF, this loop never ends. Patch 3 checks OSSL_STORE_error() in its copy of this loop, and the same check is needed here.

lib/rsa/rsa-sign.c static int rsa_pem_get_priv_key(const char *keydir, const char *name, · line 292

Quoted 13 lines
lib/rsa/rsa-sign.c +11 -1
+	OSSL_STORE_close(store);
+
+	*evpp = private_key;
+#else
+	if (!PEM_read_PrivateKey(f, evpp, NULL, path)) {
+		rsa_err("Failure reading private key");
+		fclose(f);
+		return -EPROTO;
+	}
+	fclose(f);
-
+#endif
 	return 0;

There are two problems here. First, the provider path opens 'f' above but never closes it. Second, if no key is found the function returns 0 with *evpp set to NULL, so the caller goes on to sign with a NULL key. Please can you return -EPROTO in that case, as the PEM path does?

lib/rsa/rsa-sign.c int rsa_sign(struct image_sign_info *info, · line 567

Quoted 9 lines
lib/rsa/rsa-sign.c +2 -0
@@ -480,11 +561,13 @@ int rsa_sign(struct image_sign_info *info,
+#ifdef USE_PKCS11_ENGINE
 	if (info->engine_id) {
 		ret = rsa_engine_init(info->engine_id, &e);
 		if (ret)
 			return ret;
 	}
+#endif

On OpenSSL 3, -N is now silently ignored. If an engine is passed, mkimage should fail with a clear message rather than carry on, and rsa_add_verify_data() needs the same check.

Also, binman's testFitSignEngine() uses the dummy-rsa-engine, and the pkcs11 engine tests use softhsm2 with the engine. I suspect these fail on a 3.x host after this change. Please can you run 'binman test' and update the tests and the fit,engine documentation in tools/binman/etype/fit.py to match?

Quoted 13 lines

Add support for the Provider API while continuing to support the existing Engine API on distros shipping older releases of OpenSSL.

This is based on similar work contributed by Jan Stancek updating Linux to use the Provider interface.

commit 558bdc45dfb2669e1741384a0c80be9c82fa052c
Author: Jan Stancek <[email protected]>
Date: Fri Sep 20 19:52:48 2024 +0300

sign-file,extract-cert: use pkcs11 provider for OPENSSL MAJOR >= 3

Quoted 7 lines
 lib/aes/aes-encrypt.c |   4 +-
 lib/rsa/rsa-sign.c    | 102 +++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 100 insertions(+), 6 deletions(-)

Regards,
Simon

#3 lore raw
In reply to Eddie Kovsky

Hi Eddie,

Thanks for the follow-up.

This mail is only feedback for the "we need to fix the OpenSSL engine support breaking builds on OpenSSL 4.x (and some distros with engines disabled in OpenSSL 3.x) but keep OpenSSL engine support for other distros that still support it" part. I'll get to the "support for OpenSSL providers" part in other mails so we don't mix things up.

Patches 2 and 3 are not applicable to "unbreaking-build-on-openssl-4" part of this series, please keep them separate for a v6.

Quoted 25 lines · Eddie Kovsky

Add support for the Provider API while continuing to support the existing Engine API on distros shipping older releases of OpenSSL.

This is based on similar work contributed by Jan Stancek updating Linux to use the Provider interface.

commit 558bdc45dfb2669e1741384a0c80be9c82fa052c
Author: Jan Stancek <[email protected]>
Date: Fri Sep 20 19:52:48 2024 +0300

sign-file,extract-cert: use pkcs11 provider for OPENSSL MAJOR >= 3

---
  lib/aes/aes-encrypt.c |   4 +-
  lib/rsa/rsa-sign.c    | 102 +++++++++++++++++++++++++++++++++++++++---
  2 files changed, 100 insertions(+), 6 deletions(-)
lib/aes/aes-encrypt.c +0 -0
index def33a3b3248..0cb2221df800 100644

lib/aes/aes-encrypt.c line 21

Quoted 7 lines
lib/aes/aes-encrypt.c +3 -1
@@ -16,7 +16,9 @@
  #include <openssl/err.h>
  #include <openssl/ssl.h>
  #include <openssl/evp.h>
-#include <openssl/engine.h>
+#if !defined(OPENSSL_NO_ENGINE) && !defined(OPENSSL_NO_DEPRECATED_3_0)
+# include <openssl/engine.h>
+#endif

question: Considering there are no other changes in this file, is this include actually needed? Maybe all we need to do is to unconditionally remove the include (in a separate patch then, to highlight it really isn't needed and not related to unbreaking the build).

Quoted 8 lines
lib/aes/aes-encrypt.c +0 -0
  #include <uboot_aes.h>
 
  #if OPENSSL_VERSION_NUMBER >= 0x10000000L
lib/rsa/rsa-sign.c +0 -0
index 0e38c9e802fd..361ed0647bc6 100644

lib/rsa/rsa-sign.c line 27

Quoted 10 lines
lib/rsa/rsa-sign.c +6 -1
@@ -19,7 +19,47 @@
  #include <openssl/err.h>
  #include <openssl/ssl.h>
  #include <openssl/evp.h>
-#include <openssl/engine.h>
+#if OPENSSL_VERSION_MAJOR >= 3
+# define USE_PKCS11_PROVIDER
+# include <err.h>
+# include <openssl/provider.h>
+# include <openssl/store.h>
+#else

issue: remove for the "unbreaking-build-on-openssl-4" patch as that's provider-specific.

lib/rsa/rsa-sign.c line 33

Quoted 6 lines
lib/rsa/rsa-sign.c +6 -0
+# if !defined(OPENSSL_NO_ENGINE) && !defined(OPENSSL_NO_DEPRECATED_3_0)
+#  define USE_PKCS11_ENGINE
+#  include <openssl/engine.h>
+# endif
+#endif
+

issue: The ifdefery logic is incorrect. This will break distros that are running OpenSSL 3.x but still have engine support. Such is (was, when I reported back in May) the case for Debian Trixie (13) and ArchLinux (they still are both on OpenSSL 3.x). In any case, we still want to support old(er) distros. I could build this code fine on Fedora 44 with OpenSSL 3 and openssl-devel-engine installed, so it should still work the same way now.

So, we know for sure that OpenSSL 4.x doesn't support engine so that's an easy check. For earlier versions, it actually depends on whether OpenSSL is built with engine support and we are allowed to use it. From what I gathered looking at how Fedora handled the "built with engine supports but doesn't want to let you build new software with engines unless you have openssl-devel-engine package installed" part and how Debian allows it, I figured the following (which almost matches your #else).

#if OPENSSL_VERSION_NUMBER < 0x40000000L && !defined(OPENSSL_NO_ENGINE) && !defined(OPENSSL_NO_DEPRECATED_3_0)

# define OSSL_ENGINE_SUPPORTED
# include <openssl/engine.h>
#endif

issue: please rename USE_PKCS11_ENGINE, we actually support other engines so this is misleading and we technically could support both engines AND providers on OpenSSL 3.x. I can suggest OSSL_ENGINE_SUPPORTED.

Quoted 20 lines
lib/rsa/rsa-sign.c +20 -0
+#ifdef USE_PKCS11_PROVIDER
+#define ERR(cond, fmt, ...)				\
+	do {						\
+		bool __cond = (cond);			\
+		drain_openssl_errors(__LINE__, 0);	\
+		if (__cond) {				\
+			errx(1, fmt, ## __VA_ARGS__);	\
+		}					\
+	} while (0)
+
+static void drain_openssl_errors(int l, int silent)
+{
+	const char *file;
+	char buf[120];
+	int e, line;
+
+	if (ERR_peek_error() == 0)
+		return;
+	if (!silent)
+		fprintf(stderr, "At line:%d:\n", l);

lib/rsa/rsa-sign.c line 63

Quoted 10 lines
lib/rsa/rsa-sign.c +9 -0
+
+	while ((e = ERR_peek_error_line(&file, &line))) {
+		ERR_error_string(e, buf);
+		if (!silent)
+			fprintf(stderr, "- SSL %s: %s:%d\n", buf, file, line);
+		ERR_get_error();
+	}
+}
+#endif
 

issue: remove for the "unbreaking-build-on-openssl-4" patch as that's provider-specific.

lib/rsa/rsa-sign.c err_cert: · line 137

Quoted 8 lines
lib/rsa/rsa-sign.c +1 -1
  static int rsa_err(const char *msg)
  {
@@ -94,10 +134,11 @@ err_cert:
   *
   * @keydir:	Key prefix
   * @name	Name of key
- * @engine	Engine to use
+ * @engine	Engine to use or NULL when using pkcs11 provider

issue: unnecessary change for the "unbreaking-build-on-openssl-4" patch as that's provider-specific.

Quoted 10 lines
lib/rsa/rsa-sign.c +1 -0
   * @evpp	Returns EVP_PKEY object, or NULL on failure
   * Return: 0 if ok, -ve on error (in which case *evpp will be set to NULL)
   */
+#ifdef USE_PKCS11_ENGINE
  static int rsa_engine_get_pub_key(const char *keydir, const char *name,
  				  ENGINE *engine, EVP_PKEY **evpp)
  {
@@ -157,21 +198,24 @@ static int rsa_engine_get_pub_key(const char *keydir, const char *name,
 
  	return 0;

lib/rsa/rsa-sign.c static int rsa_engine_get_pub_key(const char *keydir, const char *name, · line 208

Quoted 10 lines
lib/rsa/rsa-sign.c +2 -1
  }
+#endif
 
  /**
   * rsa_get_pub_key() - read a public key
   *
   * @keydir:	Directory containing the key (PEM file) or key prefix (engine)
   * @name	Name of key file (will have a .crt extension)
- * @engine	Engine to use
+ * @engine	Engine to use or NULL when using pkcs11 provider

issue: unnecessary change for the "unbreaking-build-on-openssl-4" patch as that's provider-specific.

lib/rsa/rsa-sign.c static int rsa_engine_get_pub_key(const char *keydir, const char *name, · line 218

Quoted 10 lines
lib/rsa/rsa-sign.c +2 -0
   * @evpp	Returns EVP_PKEY object, or NULL on failure
   * Return: 0 if ok, -ve on error (in which case *evpp will be set to NULL)
   */
  static int rsa_get_pub_key(const char *keydir, const char *name,
  			   ENGINE *engine, EVP_PKEY **evpp)
  {
+#ifdef USE_PKCS11_ENGINE
  	if (engine)
  		return rsa_engine_get_pub_key(keydir, name, engine, evpp);
+#endif

issue: we should fail hard if the user requests to use engines but mkimage/rsa is built without engine support otherwise we may incorrectly sign/verify things with keys the user didn't expect. For context, I've actually managed to build an SPL without a pubkey and "verify" U-Boot FIT. Fortunately enough, I caught this before shipping an update to a secure-boot'ed device but the fewest surprises like those we have for the user, the better.

mkimage will still happily accept the -N argument which sets the engine parameter, even if engines aren't supported.

I think if you have a file key with the same name as in the engine, you'll then sign with the wrong key.

Think

mkimage -N myengine -g key

and you have a key.key in the local directory. If you compile with OpenSSL engines supported, you'll essentially use myengine:key, if not, you'll use key.key, without mkimage even notifying you by using the same command.

What I ended up doing is:

static int rsa_engine_get_pub_key(const char *keydir, const char *name,
ENGINE *engine, EVP_PKEY **evpp)
{
#ifdef OSSL_ENGINE_SUPPORTED
[same code as today]

#else
	fprintf(stderr, "rsa-sign compiled without engine support\n");
	return -ENOTSUP;

#endif
}

so we don't need to patch all callers of rsa_engine_get_pub_key() to handle engines being supported or not. The same logic can be applied to rsa_engine_get_priv_key(), rsa_engine_init(), rsa_engine_remove() and then you have to modify much less of the file since you don't have to patch every caller of the function (which you had to do because the function doesn't exist anymore in your implementation).

Quoted 28 lines
lib/rsa/rsa-sign.c +21 -0
  	return rsa_pem_get_pub_key(keydir, name, evpp);
  }
 
@@ -207,13 +251,44 @@ static int rsa_pem_get_priv_key(const char *keydir, const char *name,
  		return -ENOENT;
  	}
 
+#ifdef USE_PKCS11_PROVIDER
+	EVP_PKEY *private_key = NULL;
+	OSSL_STORE_CTX *store;
+
+	if (!OSSL_PROVIDER_try_load(NULL, "pkcs11", true))
+		ERR(1, "OSSL_PROVIDER_try_load(pkcs11)");
+	if (!OSSL_PROVIDER_try_load(NULL, "default", true))
+		ERR(1, "OSSL_PROVIDER_try_load(default)");
+
+	store = OSSL_STORE_open(path, NULL, NULL, NULL, NULL);
+	ERR(!store, "OSSL_STORE_open");
+
+	while (!OSSL_STORE_eof(store)) {
+		OSSL_STORE_INFO *info = OSSL_STORE_load(store);
+
+		if (!info) {
+			drain_openssl_errors(__LINE__, 0);
+			continue;
+		}
+		if (OSSL_STORE_INFO_get_type(info) == OSSL_STORE_INFO_PKEY) {
+			private_key = OSSL_STORE_INFO_get1_PKEY(info);

lib/rsa/rsa-sign.c static int rsa_pem_get_priv_key(const char *keydir, const char *name, · line 284

Quoted 10 lines
lib/rsa/rsa-sign.c +10 -0
+			ERR(!private_key, "OSSL_STORE_INFO_get1_PKEY");
+		}
+		OSSL_STORE_INFO_free(info);
+		if (private_key)
+			break;
+	}
+	OSSL_STORE_close(store);
+
+	*evpp = private_key;
+#else

issue: remove for the "unbreaking-build-on-openssl-4" patch as that's provider-specific.

Quoted 22 lines
lib/rsa/rsa-sign.c +2 -1
  	if (!PEM_read_PrivateKey(f, evpp, NULL, path)) {
  		rsa_err("Failure reading private key");
  		fclose(f);
  		return -EPROTO;
  	}
  	fclose(f);
-
+#endif
  	return 0;
  }
 
@@ -226,6 +301,7 @@ static int rsa_pem_get_priv_key(const char *keydir, const char *name,
   * @evpp	Returns EVP_PKEY object, or NULL on failure
   * Return: 0 if ok, -ve on error (in which case *evpp will be set to NULL)
   */
+#ifdef USE_PKCS11_ENGINE
  static int rsa_engine_get_priv_key(const char *keydir, const char *name,
  				   const char *keyfile,
  				   ENGINE *engine, EVP_PKEY **evpp)
@@ -293,22 +369,25 @@ static int rsa_engine_get_priv_key(const char *keydir, const char *name,
 
  	return 0;

lib/rsa/rsa-sign.c static int rsa_engine_get_priv_key(const char *keydir, const char *name, · line 379

Quoted 10 lines
lib/rsa/rsa-sign.c +2 -1
  }
+#endif
 
  /**
   * rsa_get_priv_key() - read a private key
   *
   * @keydir:	Directory containing the key (PEM file) or key prefix (engine)
   * @name	Name of key
- * @engine	Engine to use for signing
+ * @engine	Engine to use or NULL when using pkcs11 provider

issue: unnecessary change for the "unbreaking-build-on-openssl-4" patch as that's provider-specific.

chore: (not necessarily you, not necessarily now) we need to fix binman tests when engine support is disabled (e.g. tools/binman/test/fit/dummy-rsa-engine.c won't compile, and we shouldn't run engine-related tests in binman, and CST for NXP stuff doesn't (didn't at least) compile either).

Cheers,
Quentin

#4 lore raw

Hoi Quentin,

Quoted 1 line · Quentin Schulz

On 10/29/26 9:13 PM, Eddie Kovsky wrote:

[...]

Quoted 11 lines

lib/rsa/rsa-sign.c static int rsa_engine_get_pub_key(const char *keydir, const char *name, · line 218

Quoted 7 lines

static int rsa_get_pub_key(const char *keydir, const char *name,
ENGINE *engine, EVP_PKEY **evpp)
{

lib/rsa/rsa-sign.c +2 -0
+#ifdef USE_PKCS11_ENGINE
  	if (engine)
  		return rsa_engine_get_pub_key(keydir, name, engine, evpp);
+#endif

issue: we should fail hard if the user requests to use engines but mkimage/rsa is built without engine support otherwise we may incorrectly sign/verify things with keys the user didn't expect.

[...]

Quoted 7 lines

What I ended up doing is:

static int rsa_engine_get_pub_key(const char *keydir, const char *name,
ENGINE *engine, EVP_PKEY **evpp)
{
#ifdef OSSL_ENGINE_SUPPORTED
[same code as today]

Quoted 5 lines
#else
	fprintf(stderr, "rsa-sign compiled without engine support\n");
	return -ENOTSUP;

#endif
}

Checked on OpenSSL 4.1 with main (3cb2cbbc) plus this gating, no provider code:

- It builds, and signs with a key file.
- mkimage -N pkcs11 -k ...: "rsa-sign compiled without engine support", exit 1. Good.

[...]

Quoted 3 lines

lib/rsa/rsa-sign.c static int rsa_pem_get_priv_key(const char *keydir, const char *name, · line 252

Quoted 3 lines
lib/rsa/rsa-sign.c +0 -0
@@ -207,13 +251,44 @@ static int rsa_pem_get_priv_key(const char *keydir, const char *name,
  		return -ENOENT;
  	}

Without -N, the same hole is here. With the build fix only, mkimage -k "pkcs11:token=...;object=dev;pin-value=..." (key on a SoftHSM token) gets to fopen("pkcs11:.../dev.key"), which fails, so this returns -ENOENT. image-host.c ("We allow keys to be missing") turns that into exit 0; the signature node keeps only algo, key-name-hint and sign-images.

-k pkcs11: without -N is how 3/3 and your c3855b08 select a token key. Your branch closes this once providers land (fba37b81 drops the fopen(), b00da645 fails hard), but a build-fix-only 2027.01 has neither, so a pkcs11: keydir there gives an unsigned FIT and a green build.

We already hit this -ENOENT path once, via -N: v4 compiles the engine out and ignores -N, so our old "-N pkcs11 -k <uri without scheme>" call opened "<uri>/<hint>.key", exited 0, and only the bootloader caught the unsigned FIT. Our current "-k pkcs11:..." call is what a build-fix-only 2027.01 would break the same way.

Could the build fix also return -ENOTSUP for a pkcs11: keydir, like for -N?

Gruß,
Johannes

#5 lore raw

PATCH v5 2/3 Add pkcs11-provider package to build dependencies

In reply to Eddie Kovsky

This package is needed to use PKCS11 with OpenSSL >= 3.0.

---
 doc/build/gcc.rst       | 4 ++--
 tools/docker/Dockerfile | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)
doc/build/gcc.rst +2 -2
index 1fef718ceecb..29a6a632e7e3 100644
@@ -25,8 +25,8 @@ Depending on the build targets further packages maybe needed
 
     sudo apt-get install bc bison build-essential coccinelle \
       device-tree-compiler dfu-util efitools flex gdisk graphviz imagemagick \
-      libgnutls28-dev libguestfs-tools libncurses-dev \
-      libpython3-dev libsdl2-dev libssl-dev lz4 lzma lzma-alone openssl \
+      libgnutls28-dev libguestfs-tools libncurses-dev libpython3-dev \
+      libsdl2-dev libssl-dev lz4 lzma lzma-alone openssl pkcs11-provider \
       pkg-config python3 python3-asteval python3-coverage python3-filelock \
       python3-pkg-resources python3-pycryptodome python3-pyelftools \
       python3-pytest python3-pytest-xdist python3-sphinxcontrib.apidoc \
tools/docker/Dockerfile +1 -0
index 187320c26d59..109d6503d8cd 100644
@@ -122,6 +122,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
 	openssl \
 	picocom \
 	parted \
+	pkcs11-provider \
 	pkg-config \
 	python-is-python3 \
 	python3 \
Signature · 1 line
2.56.0
#6 lore raw

Re: [PATCH v5 2/3] Add pkcs11-provider package to build dependencies

Hi Eddie,

Quoted 3 lines · Eddie Kovsky

Add pkcs11-provider package to build dependencies

This package is needed to use PKCS11 with OpenSSL >= 3.0.

As I mentioned on patch 1, rsa_pem_get_priv_key() now loads the pkcs11 provider even for a plain .key file, and calls errx() if that fails. So on any OpenSSL 3 host without pkcs11-provider, all FIT signing in mkimage fails, the vboot tests included. Is that why this package is being added to the Docker image?

If so, I don't think it is right. Linux sign-file only loads the pkcs11 provider when the key name starts with 'pkcs11:'. If patch 1 does the same, only the token path (patch 3) needs pkcs11-provider, and this patch becomes optional tooling rather than a fix to keep CI working.

If it really must be required, this patch needs to come before patch 1 so the series stays bisectable, and the commit message should explain why.

doc/build/gcc.rst Depending on the build targets further packages maybe needed · line 29

Quoted 6 lines
doc/build/gcc.rst +2 -2
@@ -28,8 +28,8 @@ Depending on the build targets further packages maybe needed
-      libgnutls28-dev libguestfs-tools libncurses-dev \
-      libpython3-dev libsdl2-dev libssl-dev lz4 lzma lzma-alone openssl \
+      libgnutls28-dev libguestfs-tools libncurses-dev libpython3-dev \
+      libsdl2-dev libssl-dev lz4 lzma lzma-alone openssl pkcs11-provider \

This is a runtime dependency for signing with a hardware token, not a build dependency. I think it fits better in doc/usage/fit/signature.rst, which still only says that libp11 / the pkcs11 engine is needed. Please can you update that section to cover the provider for OpenSSL >= 3?

tools/docker/Dockerfile RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ · line 125

Quoted 6 lines
tools/docker/Dockerfile +1 -0
@@ -122,6 +122,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
 	openssl \
 	picocom \
 	parted \
+	pkcs11-provider \

The image is based on noble, which ships OpenSSL 3.0. After patch 1 the engine path is compiled out there, so libengine-pkcs11-openssl seems to be unused. It would be worth dropping it here unless something else still needs it.

Quoted 6 lines
 doc/build/gcc.rst       | 4 ++--
 tools/docker/Dockerfile | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

Regards,
Simon

#7 lore raw

PATCH v5 3/3 rsa: load a pkcs11 token key through OSSL_STORE in the provider path

In reply to Eddie Kovsky

From: Johannes Schneider <[email protected]>

The OpenSSL Provider API support routes FIT signing-key loading through OSSL_STORE on OpenSSL >= 3 (USE_PKCS11_PROVIDER), but only for key files:
rsa_pem_get_priv_key() fopen()s the path before OSSL_STORE_open(), so a pkcs11:
token URI fails with -ENOENT. The legacy engine path that handled tokens is compiled out on OpenSSL >= 3, so FIT signing with a token key silently produces an unsigned FIT (a configuration signature node with no value or hashed-strings).

Load a pkcs11: key URI in the provider path directly through OSSL_STORE and the pkcs11 provider: skip the fopen, append ";type=private" if absent. The PIN travels in the URI (pin-value=); MKIMAGE_SIGN_PIN is unaffected.

Assisted-by Claude:claude-opus-4-8
---
 lib/rsa/rsa-sign.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)
lib/rsa/rsa-sign.c +92 -0
index 361ed0647bc6..c39a2a11652f 100644
@@ -92,6 +92,52 @@ static int rsa_pem_get_pub_key(const char *keydir, const char *name, EVP_PKEY **
 		return -EINVAL;
 
 	*evpp = NULL;
+#ifdef USE_PKCS11_PROVIDER
+	/*
+	 * A pkcs11: token URI is not a file: load it via OSSL_STORE + the pkcs11
+	 * provider instead of fopen (PIN in the URI, pin-value=).
+	 */
+	if (keydir && !strncmp(keydir, "pkcs11:", 7)) {
+		char uri[1200];
+		OSSL_STORE_CTX *p11_store;
+		EVP_PKEY *p11_key = NULL;
+
+		if (strstr(keydir, "type="))
+			snprintf(uri, sizeof(uri), "%s", keydir);
+		else
+			snprintf(uri, sizeof(uri), "%s;type=public", keydir);
+
+		if (!OSSL_PROVIDER_try_load(NULL, "default", true))
+			ERR(1, "OSSL_PROVIDER_try_load(default)");
+		if (!OSSL_PROVIDER_try_load(NULL, "pkcs11", true))
+			ERR(1, "OSSL_PROVIDER_try_load(pkcs11)");
+
+		p11_store = OSSL_STORE_open(uri, NULL, NULL, NULL, NULL);
+		ERR(!p11_store, "OSSL_STORE_open(%s)", uri);
+		while (!OSSL_STORE_eof(p11_store)) {
+			OSSL_STORE_INFO *info = OSSL_STORE_load(p11_store);
+
+			if (!info) {
+				if (OSSL_STORE_error(p11_store))
+					break;
+				continue;
+			}
+			if (OSSL_STORE_INFO_get_type(info) == OSSL_STORE_INFO_PUBKEY)
+				p11_key = OSSL_STORE_INFO_get1_PUBKEY(info);
+			OSSL_STORE_INFO_free(info);
+			if (p11_key)
+				break;
+		}
+		OSSL_STORE_close(p11_store);
+		if (!p11_key) {
+			fprintf(stderr, "No public key found at '%s'\n", uri);
+			return -EPROTO;
+		}
+		*evpp = p11_key;
+		return 0;
+	}
+
+#endif
 	snprintf(path, sizeof(path), "%s/%s.crt", keydir, name);
 	f = fopen(path, "r");
 	if (!f) {
@@ -237,6 +283,52 @@ static int rsa_pem_get_priv_key(const char *keydir, const char *name,
 		return -EINVAL;
 
 	*evpp = NULL;
+
+#ifdef USE_PKCS11_PROVIDER
+	/*
+	 * A pkcs11: token URI is not a file: load it via OSSL_STORE + the pkcs11
+	 * provider instead of fopen (PIN in the URI, pin-value=).
+	 */
+	if (keydir && !strncmp(keydir, "pkcs11:", 7)) {
+		char uri[1200];
+		OSSL_STORE_CTX *p11_store;
+		EVP_PKEY *p11_key = NULL;
+
+		if (strstr(keydir, "type="))
+			snprintf(uri, sizeof(uri), "%s", keydir);
+		else
+			snprintf(uri, sizeof(uri), "%s;type=private", keydir);
+
+		if (!OSSL_PROVIDER_try_load(NULL, "default", true))
+			ERR(1, "OSSL_PROVIDER_try_load(default)");
+		if (!OSSL_PROVIDER_try_load(NULL, "pkcs11", true))
+			ERR(1, "OSSL_PROVIDER_try_load(pkcs11)");
+
+		p11_store = OSSL_STORE_open(uri, NULL, NULL, NULL, NULL);
+		ERR(!p11_store, "OSSL_STORE_open(%s)", uri);
+		while (!OSSL_STORE_eof(p11_store)) {
+			OSSL_STORE_INFO *info = OSSL_STORE_load(p11_store);
+
+			if (!info) {
+				if (OSSL_STORE_error(p11_store))
+					break;
+				continue;
+			}
+			if (OSSL_STORE_INFO_get_type(info) == OSSL_STORE_INFO_PKEY)
+				p11_key = OSSL_STORE_INFO_get1_PKEY(info);
+			OSSL_STORE_INFO_free(info);
+			if (p11_key)
+				break;
+		}
+		OSSL_STORE_close(p11_store);
+		if (!p11_key) {
+			fprintf(stderr, "No private key found at '%s'\n", uri);
+			return -EPROTO;
+		}
+		*evpp = p11_key;
+		return 0;
+	}
+#endif
 	if (keydir && name)
 		snprintf(path, sizeof(path), "%s/%s.key", keydir, name);
 	else if (keyfile)
Signature · 1 line
2.56.0
#8 lore raw

Re: [PATCH v5 3/3] rsa: load a pkcs11 token key through OSSL_STORE in the provider path

Hi Johannes,

Quoted 9 lines · Eddie Kovsky

rsa: load a pkcs11 token key through OSSL_STORE in the provider path

The OpenSSL Provider API support routes FIT signing-key loading through OSSL_STORE on OpenSSL >= 3 (USE_PKCS11_PROVIDER), but only for key files:
rsa_pem_get_priv_key() fopen()s the path before OSSL_STORE_open(), so a pkcs11:
token URI fails with -ENOENT. The legacy engine path that handled tokens is compiled out on OpenSSL >= 3, so FIT signing with a token key silently produces an unsigned FIT (a configuration signature node with no value or hashed-strings).

So as I understand it, this describes a regression from patch 1, so token signing is broken from patch 1 until this patch. Please can you fold this into patch 1, or put it before it, so the series stays bisectable?

Quoted 3 lines

Load a pkcs11: key URI in the provider path directly through OSSL_STORE and the pkcs11 provider: skip the fopen, append ";type=private" if absent. The PIN travels in the URI (pin-value=); MKIMAGE_SIGN_PIN is unaffected.

The patch also changes rsa_pem_get_pub_key() (used by -K), so please mention the public-key side too.

'MKIMAGE_SIGN_PIN is unaffected' reads as if the variable still works. With the provider, rsa_engine_init() is compiled out, so the variable is ignored and the PIN has to go on the command line, where it shows up in the process list and build logs. doc/usage/fit/signature.rst still documents MKIMAGE_SIGN_PIN and the engine key-id rules. Please can you update it to describe how this works with the provider?

Quoted 15 lines

Load a pkcs11: key URI in the provider path directly through OSSL_STORE and the pkcs11 provider: skip the fopen, append ";type=private" if absent. The PIN travels in the URI (pin-value=); MKIMAGE_SIGN_PIN is unaffected.

Assisted-by Claude:claude-opus-4-8
 lib/rsa/rsa-sign.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 92 insertions(+)

lib/rsa/rsa-sign.c static int rsa_pem_get_pub_key(const char *keydir, const char *name, EVP_PKEY ** · line 100

Quoted 9 lines
lib/rsa/rsa-sign.c +9 -0
@@ -92,6 +92,52 @@ static int rsa_pem_get_pub_key(const char *keydir, const char *name, EVP_PKEY **
+	if (keydir && !strncmp(keydir, "pkcs11:", 7)) {
+		char uri[1200];
+		OSSL_STORE_CTX *p11_store;
+		EVP_PKEY *p11_key = NULL;
+
+		if (strstr(keydir, "type="))
+			snprintf(uri, sizeof(uri), "%s", keydir);
+		else
+			snprintf(uri, sizeof(uri), "%s;type=public", keydir);

This ignores 'name' (the key-name-hint). When keydir has no 'object=' or 'id=', the engine path appends ';object=<key-name-hint>', as signature.rst documents. With this patch, the documented usage (-k pkcs11:token=... with key-name-hint set in the .its) loads the first key OpenSSL finds on the token. On a token with several keys that is likely the wrong one, and the image is signed with no error. Please can you build the URI the same way as rsa_engine_get_pub_key() and rsa_engine_get_priv_key() do?

It would also be worth handling a keydir without the 'pkcs11:' prefix when -N pkcs11 is given. At present that case falls through to fopen() and gets -ENOENT. image-host.c treats that as an allowed missing key, which gives the same unsigned FIT that the commit message describes.

lib/rsa/rsa-sign.c static int rsa_pem_get_priv_key(const char *keydir, const char *name, · line 291

Quoted 11 lines
lib/rsa/rsa-sign.c +9 -0
@@ -237,6 +283,52 @@ static int rsa_pem_get_priv_key(const char *keydir, const char *name,
+#ifdef USE_PKCS11_PROVIDER
+	/*
+	 * A pkcs11: token URI is not a file: load it via OSSL_STORE + the pkcs11
+	 * provider instead of fopen (PIN in the URI, pin-value=).
+	 */
+	if (keydir && !strncmp(keydir, "pkcs11:", 7)) {
+		char uri[1200];
+		OSSL_STORE_CTX *p11_store;
+		EVP_PKEY *p11_key = NULL;

This block is a copy of the public-key one, apart from 'type=' and the OSSL_STORE_INFO type. Patch 1 also has an OSSL_STORE_open()/load loop for files a few lines below. Please can you put this in a helper and use it in all three places? That would also keep the provider-loading order consistent: here 'default' is loaded before 'pkcs11', but patch 1 loads them the other way round.

Regards,
Simon

#9 lore raw
In reply to Eddie Kovsky

Hi Eddie,

Quoted 11 lines · Eddie Kovsky

The Engine API has been deprecated since the release of OpenSSL 3.0. End users have been advised to migrate to the new Provider interface. Several distributions have already removed support for engines, which is preventing U-Boot from being compiled in those environments.

This series adds support for the OpenSSL Provider API while continuing to support the existing Engine API on distros shipping older releases of OpenSSL. Build dependencies for local development and CI are also updated, while the final patch adds support for using hardware tokens with the Provider API.

Quoted 5 lines

The changes have been tested with the FIT signature verification vboot tests on Fedora 44, Debian 13, and RHEL 8 with OpenSSL 1.1.1. All 37 tests pass with both the legacy Engine library installed and with the Provider API.

I'm NACKing this series quickly because we are having pressure from multiple projects and Tom would like to see this fixed ASAP, and this version here should not be merged. From a cursory look a lot of feedback was ignored, possibly because I did too many rounds of reviews and it got difficult to follow. I'll therefore spend time next week to collect the reviews I made on v4 and that sill apply and post them condensed on this thread.

Please, we just need to fix the build issue for 2027.01. We don't need providers in 2027.01, just the ability to build on OpenSSL 4 and on distros with OpenSSL3 with engines disabled, without breaking OpenSSL engine support for other cases. If you get a patch to fix this, please send it whenever you can, I'll still collect the reviews from v4 and post it here. If you're not interested in doing that, lemme know and I'll take over this part and you can always test the patch(es) if you want to.

Cheers,
Quentin

#10 lore raw
Quoted 35 lines · Quentin Schulz

Hi Eddie,

Quoted 11 lines · Eddie Kovsky

The Engine API has been deprecated since the release of OpenSSL 3.0. End users have been advised to migrate to the new Provider interface. Several distributions have already removed support for engines, which is preventing U-Boot from being compiled in those environments.

This series adds support for the OpenSSL Provider API while continuing to support the existing Engine API on distros shipping older releases of OpenSSL. Build dependencies for local development and CI are also updated, while the final patch adds support for using hardware tokens with the Provider API.

Quoted 5 lines

The changes have been tested with the FIT signature verification vboot tests on Fedora 44, Debian 13, and RHEL 8 with OpenSSL 1.1.1. All 37 tests pass with both the legacy Engine library installed and with the Provider API.

I'm NACKing this series quickly because we are having pressure from multiple projects and Tom would like to see this fixed ASAP, and this version here should not be merged. From a cursory look a lot of feedback was ignored, possibly because I did too many rounds of reviews and it got difficult to follow. I'll therefore spend time next week to collect the reviews I made on v4 and that sill apply and post them condensed on this thread.

Please, we just need to fix the build issue for 2027.01. We don't need providers in 2027.01, just the ability to build on OpenSSL 4 and on distros with OpenSSL3 with engines disabled, without breaking OpenSSL engine support for other cases. If you get a patch to fix this, please send it whenever you can, I'll still collect the reviews from v4 and post it here. If you're not interested in doing that, lemme know and I'll take over this part and you can always test the patch(es) if you want to.

Quoted 3 lines

Cheers,
Quentin

Hi Quentin

I designed this change from the very beginning to maintain the existing code base and preserve backward compatibility for users of older OpenSSL releases who are still using the Engine API. We cannot add support for OpenSSL 3 or later without moving to the Provider API because of the way the OpenSSL project has changed their interface.

Both I and other reviewers have tested the proposed changes on different distributions using different OpenSSL releases. The build failure is resolved on OpenSSL >= 3, while building with the Engine API still works as expected. (The only obstacle we found was that signing with a hardware token key using Providers didn't work, partly because the existing code doesn't make the pkcs11 uri parsing available on all paths. But Johannes already proposed a solution that resolves that issue.)

What are your specific concerns about the code in this version of the patch series?

Eddie

#11 lore raw

Hi Eddie,

Quoted 40 lines · Eddie Kovsky
Quoted 35 lines · Quentin Schulz

Hi Eddie,

Quoted 11 lines · Eddie Kovsky

The Engine API has been deprecated since the release of OpenSSL 3.0. End users have been advised to migrate to the new Provider interface. Several distributions have already removed support for engines, which is preventing U-Boot from being compiled in those environments.

This series adds support for the OpenSSL Provider API while continuing to support the existing Engine API on distros shipping older releases of OpenSSL. Build dependencies for local development and CI are also updated, while the final patch adds support for using hardware tokens with the Provider API.

Quoted 5 lines

The changes have been tested with the FIT signature verification vboot tests on Fedora 44, Debian 13, and RHEL 8 with OpenSSL 1.1.1. All 37 tests pass with both the legacy Engine library installed and with the Provider API.

I'm NACKing this series quickly because we are having pressure from multiple projects and Tom would like to see this fixed ASAP, and this version here should not be merged. From a cursory look a lot of feedback was ignored, possibly because I did too many rounds of reviews and it got difficult to follow. I'll therefore spend time next week to collect the reviews I made on v4 and that sill apply and post them condensed on this thread.

Please, we just need to fix the build issue for 2027.01. We don't need providers in 2027.01, just the ability to build on OpenSSL 4 and on distros with OpenSSL3 with engines disabled, without breaking OpenSSL engine support for other cases. If you get a patch to fix this, please send it whenever you can, I'll still collect the reviews from v4 and post it here. If you're not interested in doing that, lemme know and I'll take over this part and you can always test the patch(es) if you want to.

Quoted 3 lines

Cheers,
Quentin

Quoted 8 lines

Hi Quentin

I designed this change from the very beginning to maintain the existing code base and preserve backward compatibility for users of older OpenSSL releases who are still using the Engine API. We cannot add support for OpenSSL 3 or later without moving to the Provider API because of the way the OpenSSL project has changed their interface.

That's not true, as already said in v4[1]. We currently support OpenSSL 3 and engines, and we actually test this in CI. You can test locally by running the following commands from your U-Boot git repo:

podman run -it --rm --security-opt label=disable --userns=keep-id:uid=1001,gid=1001 -w $PWD -v $PWD:$PWD docker.io/trini/u-boot-gitlab-ci-runner:noble-20251013-23Jan2026 python3 -m venv /tmp/venv;
. /tmp/venv/bin/activate;
pip install -r test/py/requirements.txt -r tools/binman/requirements.txt -r tools/buildman/requirements.txt -r tools/u_boot_pylib/requirements.txt -r scripts/dtc/pylibfdt/requirements.txt; export UBOOT_TRAVIS_BUILD_DIR=/tmp/tools-only;
export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt";
export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}";
./tools/buildman/buildman -T0 -o ${UBOOT_TRAVIS_BUILD_DIR} -w --board tools-only;
export TOOLPATH="--toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools --toolpath /opt/coreboot";
./tools/binman/binman ${TOOLPATH} tool -f missing;
for test in testFitSignEngineSimple testFitSignPKCS11Simple testFitSignPKCS11Object; do ./tools/binman/binman ${TOOLPATH} test $test; done

You'll see all engine tests pass.

Additionally, from my branch at https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commits/openssl-providers, I have tests for both OpenSSL engines and providers *at the same time*. Here[2] is the log where you can see none of the OpenSSL engine tests are skipped and only the PKCS11 provider tests are skipped. They are skipped because we don't have the proper package installed inside the container but I tested this locally months ago and they pass if the package is installed. If either the engines or providers weren't supported, you would get a skip with a given reason, see [3][4]. [5] shows that you can build both engine and provider support in lib/rsa/rsa-sign.c.

If what you said was true, we would have had a build issue when every distro moved to OpenSSL 3 when it was first released 5 years ago, which didn't happen.

[1] https://lore.kernel.org/u-boot/[email protected]/
[2] https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/jobs/79119/raw
[3] https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/blob/openssl-providers/tools/binman/ftest.py#L8339
[4] https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/blob/openssl-providers/tools/binman/ftest.py#L8719
[5] https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/blob/openssl-providers/lib/rsa/rsa-sign.c#L22-L33

Quoted 4 lines

Both I and other reviewers have tested the proposed changes on different distributions using different OpenSSL releases. The build failure is resolved on OpenSSL >= 3, while building with the Engine API still works as expected. (The only obstacle we found was that signing with a

Run the list of commands above with your patch series applied and you'll see it doesn't work.

Quoted 5 lines

hardware token key using Providers didn't work, partly because the existing code doesn't make the pkcs11 uri parsing available on all paths. But Johannes already proposed a solution that resolves that issue.)

I'll discuss the provider part later on, I would like us to focus on the OpenSSL engine build failure for distros where OpenSSL doesn't support it anymore (Fedora 44 without the ability to compile code using engines anymore unless openssl-devel-engine is installed, and every distro with OpenSSL 4) while still keeping OpenSSL engine support working when it is possible to support it (all other cases, including Fedora 44 with openssl-devel-engine installed).

Quoted 3 lines

What are your specific concerns about the code in this version of the patch series?

See review on patch 1 (posted a few minutes after you sent this mail here, unfortunate timing). But essentially, this breaks OpenSSL engine support on OpenSSL 3, which is something that is supported by OpenSSL and which we want to keep supporting.

Cheers,
Quentin

#12 lore raw
Quoted 76 lines · Quentin Schulz

Hi Eddie,

Quoted 40 lines · Eddie Kovsky
Quoted 35 lines · Quentin Schulz

Hi Eddie,

Quoted 11 lines · Eddie Kovsky

The Engine API has been deprecated since the release of OpenSSL 3.0. End users have been advised to migrate to the new Provider interface. Several distributions have already removed support for engines, which is preventing U-Boot from being compiled in those environments.

This series adds support for the OpenSSL Provider API while continuing to support the existing Engine API on distros shipping older releases of OpenSSL. Build dependencies for local development and CI are also updated, while the final patch adds support for using hardware tokens with the Provider API.

Quoted 5 lines

The changes have been tested with the FIT signature verification vboot tests on Fedora 44, Debian 13, and RHEL 8 with OpenSSL 1.1.1. All 37 tests pass with both the legacy Engine library installed and with the Provider API.

I'm NACKing this series quickly because we are having pressure from multiple projects and Tom would like to see this fixed ASAP, and this version here should not be merged. From a cursory look a lot of feedback was ignored, possibly because I did too many rounds of reviews and it got difficult to follow. I'll therefore spend time next week to collect the reviews I made on v4 and that sill apply and post them condensed on this thread.

Please, we just need to fix the build issue for 2027.01. We don't need providers in 2027.01, just the ability to build on OpenSSL 4 and on distros with OpenSSL3 with engines disabled, without breaking OpenSSL engine support for other cases. If you get a patch to fix this, please send it whenever you can, I'll still collect the reviews from v4 and post it here. If you're not interested in doing that, lemme know and I'll take over this part and you can always test the patch(es) if you want to.

Quoted 3 lines

Cheers,
Quentin

Quoted 8 lines

Hi Quentin

I designed this change from the very beginning to maintain the existing code base and preserve backward compatibility for users of older OpenSSL releases who are still using the Engine API. We cannot add support for OpenSSL 3 or later without moving to the Provider API because of the way the OpenSSL project has changed their interface.

That's not true, as already said in v4[1]. We currently support OpenSSL 3 and engines, and we actually test this in CI. You can test locally by running the following commands from your U-Boot git repo:

podman run -it --rm --security-opt label=disable --userns=keep-id:uid=1001,gid=1001 -w $PWD -v $PWD:$PWD docker.io/trini/u-boot-gitlab-ci-runner:noble-20251013-23Jan2026 python3 -m venv /tmp/venv;
. /tmp/venv/bin/activate;
pip install -r test/py/requirements.txt -r tools/binman/requirements.txt -r tools/buildman/requirements.txt -r tools/u_boot_pylib/requirements.txt -r scripts/dtc/pylibfdt/requirements.txt;
export UBOOT_TRAVIS_BUILD_DIR=/tmp/tools-only;
export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt"; export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}"; ./tools/buildman/buildman -T0 -o ${UBOOT_TRAVIS_BUILD_DIR} -w --board tools-only;
export TOOLPATH="--toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools --toolpath /opt/coreboot";
./tools/binman/binman ${TOOLPATH} tool -f missing;
for test in testFitSignEngineSimple testFitSignPKCS11Simple testFitSignPKCS11Object; do ./tools/binman/binman ${TOOLPATH} test $test; done

Quoted 2 lines

You'll see all engine tests pass.

I assume you are referring to my second sentence "We cannot add support for OpenSSL 3 or later without moving to the Provider API ..." I can see how that wording could be confusing.

OpenSSL 3 deprecated the Engine API but did not remove it. The Engine code is still present but not callable in v3 because the header files were removed to help prepare users to migrate to the new Provider API. And OpenSSL 4, which is gaining more adoption, removes the Engine API code entirely and only makes the Provider interface available.

Some distros, like Fedora, added an optional package to put the header files back alongside OpenSSL 3 so that projects (like U-Boot) which hadn't migrated to the new API would still build using Engines. I don't know what the base image of your container is or what release of OpenSSL it's using, but it's likely doing something similar to keep the symbols available. But as it stands right now, U-Boot will not compile in any environment that does not provide a bridge back to the Engine API.

I've found that the fastest test of which API is available in a particular environment is to (optionally) sprinkle some printfs throughout the lib/rsa/rsa-sign.c and then build the tools target. The build will succeed if the headers are available, but quickly fail otherwise:

❯ make tools
--->8
In file included from tools/generated/lib/rsa/rsa-sign.c:1:
./tools/../lib/rsa/rsa-sign.c: In function ‘rsa_engine_get_pub_key’:
./tools/../lib/rsa/rsa-sign.c:115:9: warning: ‘ENGINE_get_id’ is deprecated: ENGINE_get_id API symbol is removed. Define OPENSSL_ENGINE_STUBS to mask linker errors. [-Wdeprecated-declarations]
115 | engine_id = ENGINE_get_id(engine);
| ^~~~~~~~~

--->8
/usr/bin/ld.bfd: tools/generated/lib/rsa/rsa-sign.o: in function `rsa_engine_init.constprop.0':
rsa-sign.c:(.text+0x15): undefined reference to `ENGINE_load_builtin_engines'

To fix this build problem in an environment where the Engine API is not available (even if OpenSSL 3 is) we need to call the Provider API to replace the equivalent functionality. There is not another fix to the build failure unless you want to make a declaration that U-Boot is pinned to the Engine API as a build dependency.

I also want to emphasize that I have been careful to keep the existing Engine code as it is. The new code is there to support the Provider path. We collected at least one Tested-By trailer from a LibreSSL user early in review, and I recently found a way to test for regressions with OpenSSL 1.

Quoted 10 lines

Additionally, from my branch at https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commits/openssl-providers,
I have tests for both OpenSSL engines and providers *at the same time*.
Here[2] is the log where you can see none of the OpenSSL engine tests are
skipped and only the PKCS11 provider tests are skipped. They are skipped
because we don't have the proper package installed inside the container but
I tested this locally months ago and they pass if the package is installed.
If either the engines or providers weren't supported, you would get a skip
with a given reason, see [3][4]. [5] shows that you can build both engine
and provider support in lib/rsa/rsa-sign.c.

Quoted 4 lines

If what you said was true, we would have had a build issue when every distro moved to OpenSSL 3 when it was first released 5 years ago, which didn't happen.

That's correct, because as stated above OpenSSL 3 only deprecated the Engine API without removing it, and some distributions still made the headers available.

My second patch, along with the CI work Tom did earlier this year, addresses the missing package in the CI container.

Quoted 6 lines

[1] https://lore.kernel.org/u-boot/[email protected]/
[2] https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/jobs/79119/raw
[3] https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/blob/openssl-providers/tools/binman/ftest.py#L8339
[4] https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/blob/openssl-providers/tools/binman/ftest.py#L8719
[5] https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/blob/openssl-providers/lib/rsa/rsa-sign.c#L22-L33

Quoted 8 lines
Quoted 4 lines

Both I and other reviewers have tested the proposed changes on different distributions using different OpenSSL releases. The build failure is resolved on OpenSSL >= 3, while building with the Engine API still works as expected. (The only obstacle we found was that signing with a

Run the list of commands above with your patch series applied and you'll see it doesn't work.

What commands? You said the podman local test runner does succeed. If you have an example of a specific failure please include the complete output along with the commands and environment that reproduced it.

Quoted 6 lines
Quoted 5 lines

hardware token key using Providers didn't work, partly because the existing code doesn't make the pkcs11 uri parsing available on all paths. But Johannes already proposed a solution that resolves that issue.)

Quoted 8 lines

I'll discuss the provider part later on, I would like us to focus on the OpenSSL engine build failure for distros where OpenSSL doesn't support it anymore (Fedora 44 without the ability to compile code using engines anymore unless openssl-devel-engine is installed, and every distro with OpenSSL 4) while still keeping OpenSSL engine support working when it is possible to support it (all other cases, including Fedora 44 with openssl-devel-engine installed).

See my previous explanation.

Quoted 9 lines
Quoted 3 lines

What are your specific concerns about the code in this version of the patch series?

See review on patch 1 (posted a few minutes after you sent this mail here, unfortunate timing). But essentially, this breaks OpenSSL engine support on OpenSSL 3, which is something that is supported by OpenSSL and which we want to keep supporting.

As mentioned in my commit messages and earlier in my reply, I have been careful to preserve backward compatibility for users who may still be building U-Boot with the existing Engine code path. Your other email states my patch "will break" distros like Debian and Arch. I've been testing on Debian stable and not seen any problems. How did you determine that Engine support is broken?

Eddie

#13 lore raw
Quoted 102 lines · Eddie Kovsky
Quoted 8 lines · Quentin Schulz

Hi Eddie,

Quoted 5 lines · Eddie Kovsky
Quoted 4 lines · Quentin Schulz

Hi Eddie,

Quoted 1 line · Eddie Kovsky

The Engine API has been deprecated since the release of OpenSSL

3.0. End

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

users have been advised to migrate to the new Provider interface. Several distributions have already removed support for engines,

which is

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

preventing U-Boot from being compiled in those environments.

This series adds support for the OpenSSL Provider API while

continuing

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

to support the existing Engine API on distros shipping older

releases of

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

OpenSSL. Build dependencies for local development and CI are also updated, while the final patch adds support for using hardware

tokens

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

with the Provider API.

The changes have been tested with the FIT signature verification

vboot

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

tests on Fedora 44, Debian 13, and RHEL 8 with OpenSSL 1.1.1. All

37

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

tests pass with both the legacy Engine library installed and with

the

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

Provider API.

I'm NACKing this series quickly because we are having pressure from

multiple

Quoted 1 line
Quoted 1 line
Quoted 1 line

projects and Tom would like to see this fixed ASAP, and this version

here

Quoted 1 line
Quoted 1 line
Quoted 1 line

should not be merged. From a cursory look a lot of feedback was

ignored,

Quoted 1 line
Quoted 1 line
Quoted 1 line

possibly because I did too many rounds of reviews and it got

difficult to

Quoted 1 line
Quoted 1 line
Quoted 1 line

follow. I'll therefore spend time next week to collect the reviews I

made on

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

v4 and that sill apply and post them condensed on this thread.

Please, we just need to fix the build issue for 2027.01. We don't

need

Quoted 1 line
Quoted 1 line
Quoted 1 line

providers in 2027.01, just the ability to build on OpenSSL 4 and on

distros

Quoted 1 line
Quoted 1 line
Quoted 1 line

with OpenSSL3 with engines disabled, without breaking OpenSSL engine

support

Quoted 1 line
Quoted 1 line
Quoted 1 line

for other cases. If you get a patch to fix this, please send it

whenever you

Quoted 1 line
Quoted 1 line
Quoted 1 line

can, I'll still collect the reviews from v4 and post it here. If

you're not

Quoted 1 line
Quoted 1 line
Quoted 1 line

interested in doing that, lemme know and I'll take over this part

and you

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines

can always test the patch(es) if you want to.

Cheers,
Quentin

Hi Quentin

I designed this change from the very beginning to maintain the existing code base and preserve backward compatibility for users of older

OpenSSL

Quoted 2 lines
Quoted 2 lines

releases who are still using the Engine API. We cannot add support for OpenSSL 3 or later without moving to the Provider API because of the

way

Quoted 7 lines
Quoted 2 lines

the OpenSSL project has changed their interface.

That's not true, as already said in v4[1]. We currently support OpenSSL 3 and engines, and we actually test this in CI. You can test locally by running the following commands from your U-Boot git repo:

Quoted 6 lines

podman run -it --rm --security-opt label=disable --userns=keep-id:uid=1001,gid=1001 -w $PWD -v $PWD:$PWD docker.io/trini/u-boot-gitlab-ci-runner:noble-20251013-23Jan2026 python3 -m venv /tmp/venv;
. /tmp/venv/bin/activate;
pip install -r test/py/requirements.txt -r tools/binman/requirements.txt

-r

Quoted 14 lines

tools/buildman/requirements.txt -r tools/u_boot_pylib/requirements.txt -r scripts/dtc/pylibfdt/requirements.txt;
export UBOOT_TRAVIS_BUILD_DIR=/tmp/tools-only;
export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt"; export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}"; ./tools/buildman/buildman -T0 -o ${UBOOT_TRAVIS_BUILD_DIR} -w --board tools-only;
export TOOLPATH="--toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools --toolpath /opt/coreboot";
./tools/binman/binman ${TOOLPATH} tool -f missing;
for test in testFitSignEngineSimple testFitSignPKCS11Simple testFitSignPKCS11Object; do ./tools/binman/binman ${TOOLPATH} test $test; done

Quoted 2 lines

You'll see all engine tests pass.

Quoted 8 lines

I assume you are referring to my second sentence "We cannot add support for OpenSSL 3 or later without moving to the Provider API ..." I can see how that wording could be confusing.

OpenSSL 3 deprecated the Engine API but did not remove it. The Engine code is still present but not callable in v3 because the header files were removed to help prepare users to migrate to the new Provider API.

Are you sure that's not just what Red Hat did as part of migrating RHEL customers?

Quoted 145 lines

And OpenSSL 4, which is gaining more adoption, removes the Engine API code entirely and only makes the Provider interface available.

Some distros, like Fedora, added an optional package to put the header files back alongside OpenSSL 3 so that projects (like U-Boot) which hadn't migrated to the new API would still build using Engines. I don't know what the base image of your container is or what release of OpenSSL it's using, but it's likely doing something similar to keep the symbols available. But as it stands right now, U-Boot will not compile in any environment that does not provide a bridge back to the Engine API.

I've found that the fastest test of which API is available in a particular environment is to (optionally) sprinkle some printfs throughout the lib/rsa/rsa-sign.c and then build the tools target. The build
will succeed if the headers are available, but quickly fail otherwise:

❯ make tools
--->8
In file included from tools/generated/lib/rsa/rsa-sign.c:1:
./tools/../lib/rsa/rsa-sign.c: In function ‘rsa_engine_get_pub_key’:
./tools/../lib/rsa/rsa-sign.c:115:9: warning: ‘ENGINE_get_id’ is
deprecated: ENGINE_get_id API symbol is removed. Define OPENSSL_ENGINE_STUBS to mask linker errors. [-Wdeprecated-declarations]

    115 |         engine_id = ENGINE_get_id(engine);
        |         ^~~~~~~~~

--->8
/usr/bin/ld.bfd: tools/generated/lib/rsa/rsa-sign.o: in function
`rsa_engine_init.constprop.0':

    rsa-sign.c:(.text+0x15): undefined reference to

`ENGINE_load_builtin_engines'

To fix this build problem in an environment where the Engine API is not available (even if OpenSSL 3 is) we need to call the Provider API to replace the equivalent functionality. There is not another fix to the build failure unless you want to make a declaration that U-Boot is pinned to the Engine API as a build dependency.

I also want to emphasize that I have been careful to keep the existing Engine code as it is. The new code is there to support the Provider path. We collected at least one Tested-By trailer from a LibreSSL user early in review, and I recently found a way to test for regressions with OpenSSL 1.

Quoted 1 line

Additionally, from my branch at

https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commits/openssl-providers
,

Quoted 4 lines

I have tests for both OpenSSL engines and providers *at the same time*. Here[2] is the log where you can see none of the OpenSSL engine tests are skipped and only the PKCS11 provider tests are skipped. They are skipped because we don't have the proper package installed inside the container

but

Quoted 1 line

I tested this locally months ago and they pass if the package is

installed.

Quoted 1 line

If either the engines or providers weren't supported, you would get a

skip

Quoted 4 lines

with a given reason, see [3][4]. [5] shows that you can build both engine and provider support in lib/rsa/rsa-sign.c.

If what you said was true, we would have had a build issue when every

distro

Quoted 3 lines

moved to OpenSSL 3 when it was first released 5 years ago, which didn't happen.

That's correct, because as stated above OpenSSL 3 only deprecated the Engine API without removing it, and some distributions still made the headers available.

My second patch, along with the CI work Tom did earlier this year, addresses the missing package in the CI container.

Quoted 1 line

[1]

https://lore.kernel.org/u-boot/[email protected]/

Quoted 1 line

[2]

https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/jobs/79119/raw

Quoted 1 line

[3]

https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/blob/openssl-providers/tools/binman/ftest.py#L8339

Quoted 1 line

[4]

https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/blob/openssl-providers/tools/binman/ftest.py#L8719

Quoted 1 line

[5]

https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/blob/openssl-providers/lib/rsa/rsa-sign.c#L22-L33

Quoted 2 lines
Quoted 2 lines

Both I and other reviewers have tested the proposed changes on

different

Quoted 2 lines
Quoted 2 lines

distributions using different OpenSSL releases. The build failure is resolved on OpenSSL >= 3, while building with the Engine API still

works

Quoted 3 lines
Quoted 1 line

as expected. (The only obstacle we found was that signing with a

Run the list of commands above with your patch series applied and you'll

see

Quoted 2 lines

it doesn't work.

What commands? You said the podman local test runner does succeed. If you have an example of a specific failure please include the complete output along with the commands and environment that reproduced it.

Quoted 9 lines
Quoted 5 lines

hardware token key using Providers didn't work, partly because the existing code doesn't make the pkcs11 uri parsing available on all paths. But Johannes already proposed a solution that resolves that issue.)

I'll discuss the provider part later on, I would like us to focus on the OpenSSL engine build failure for distros where OpenSSL doesn't support it anymore (Fedora 44 without the ability to compile code using engines

anymore

Quoted 1 line

unless openssl-devel-engine is installed, and every distro with OpenSSL

4)

Quoted 2 lines

while still keeping OpenSSL engine support working when it is possible to support it (all other cases, including Fedora 44 with

openssl-devel-engine

Quoted 2 lines

installed).

See my previous explanation.

Quoted 5 lines
Quoted 3 lines

What are your specific concerns about the code in this version of the patch series?

See review on patch 1 (posted a few minutes after you sent this mail

here,

Quoted 1 line

unfortunate timing). But essentially, this breaks OpenSSL engine support

on

Quoted 1 line

OpenSSL 3, which is something that is supported by OpenSSL and which we

want

Quoted 2 lines

to keep supporting.

As mentioned in my commit messages and earlier in my reply, I have been careful to preserve backward compatibility for users who may still be building U-Boot with the existing Engine code path. Your other email states my patch "will break" distros like Debian and Arch. I've been testing on Debian stable and not seen any problems. How did you determine that Engine support is broken?

Eddie

#14 lore raw
Quoted 108 lines · Peter Robinson
Quoted 106 lines · Eddie Kovsky
Quoted 8 lines · Quentin Schulz

Hi Eddie,

Quoted 5 lines · Eddie Kovsky
Quoted 4 lines · Quentin Schulz

Hi Eddie,

Quoted 1 line · Eddie Kovsky

The Engine API has been deprecated since the release of OpenSSL

3.0. End

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

users have been advised to migrate to the new Provider interface. Several distributions have already removed support for engines,

which is

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

preventing U-Boot from being compiled in those environments.

This series adds support for the OpenSSL Provider API while

continuing

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

to support the existing Engine API on distros shipping older

releases of

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

OpenSSL. Build dependencies for local development and CI are also updated, while the final patch adds support for using hardware

tokens

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

with the Provider API.

The changes have been tested with the FIT signature verification

vboot

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

tests on Fedora 44, Debian 13, and RHEL 8 with OpenSSL 1.1.1. All

37

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

tests pass with both the legacy Engine library installed and with

the

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

Provider API.

I'm NACKing this series quickly because we are having pressure from

multiple

Quoted 1 line
Quoted 1 line
Quoted 1 line

projects and Tom would like to see this fixed ASAP, and this version

here

Quoted 1 line
Quoted 1 line
Quoted 1 line

should not be merged. From a cursory look a lot of feedback was

ignored,

Quoted 1 line
Quoted 1 line
Quoted 1 line

possibly because I did too many rounds of reviews and it got

difficult to

Quoted 1 line
Quoted 1 line
Quoted 1 line

follow. I'll therefore spend time next week to collect the reviews I

made on

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

v4 and that sill apply and post them condensed on this thread.

Please, we just need to fix the build issue for 2027.01. We don't

need

Quoted 1 line
Quoted 1 line
Quoted 1 line

providers in 2027.01, just the ability to build on OpenSSL 4 and on

distros

Quoted 1 line
Quoted 1 line
Quoted 1 line

with OpenSSL3 with engines disabled, without breaking OpenSSL engine

support

Quoted 1 line
Quoted 1 line
Quoted 1 line

for other cases. If you get a patch to fix this, please send it

whenever you

Quoted 1 line
Quoted 1 line
Quoted 1 line

can, I'll still collect the reviews from v4 and post it here. If

you're not

Quoted 1 line
Quoted 1 line
Quoted 1 line

interested in doing that, lemme know and I'll take over this part

and you

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines

can always test the patch(es) if you want to.

Cheers,
Quentin

Hi Quentin

I designed this change from the very beginning to maintain the existing code base and preserve backward compatibility for users of older

OpenSSL

Quoted 2 lines
Quoted 2 lines

releases who are still using the Engine API. We cannot add support for OpenSSL 3 or later without moving to the Provider API because of the

way

Quoted 7 lines
Quoted 2 lines

the OpenSSL project has changed their interface.

That's not true, as already said in v4[1]. We currently support OpenSSL 3 and engines, and we actually test this in CI. You can test locally by running the following commands from your U-Boot git repo:

Quoted 6 lines

podman run -it --rm --security-opt label=disable --userns=keep-id:uid=1001,gid=1001 -w $PWD -v $PWD:$PWD docker.io/trini/u-boot-gitlab-ci-runner:noble-20251013-23Jan2026 python3 -m venv /tmp/venv;
. /tmp/venv/bin/activate;
pip install -r test/py/requirements.txt -r tools/binman/requirements.txt

-r

Quoted 14 lines

tools/buildman/requirements.txt -r tools/u_boot_pylib/requirements.txt -r scripts/dtc/pylibfdt/requirements.txt;
export UBOOT_TRAVIS_BUILD_DIR=/tmp/tools-only;
export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt"; export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}"; ./tools/buildman/buildman -T0 -o ${UBOOT_TRAVIS_BUILD_DIR} -w --board tools-only;
export TOOLPATH="--toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools --toolpath /opt/coreboot";
./tools/binman/binman ${TOOLPATH} tool -f missing;
for test in testFitSignEngineSimple testFitSignPKCS11Simple testFitSignPKCS11Object; do ./tools/binman/binman ${TOOLPATH} test $test; done

Quoted 2 lines

You'll see all engine tests pass.

I assume you are referring to my second sentence "We cannot add support for OpenSSL 3 or later without moving to the Provider API ..." I can see how that wording could be confusing.

Quoted 9 lines
Quoted 4 lines

OpenSSL 3 deprecated the Engine API but did not remove it. The Engine code is still present but not callable in v3 because the header files were removed to help prepare users to migrate to the new Provider API.

Are you sure that's not just what Red Hat did as part of migrating RHEL customers?

Yes, sorry. I'm losing track of how each distro has managed the API transition. OpenSSL only turned deprecated symbols into compiler warnings, which are easy to ignore. Fedora went a step further by packaging the Engine symbols separately.

https://docs.openssl.org/master/man7/ossl-guide-migration/#upgrading-from-openssl-111

#15 lore raw
In reply to Eddie Kovsky

Hi Eddie,

Quoted 80 lines · Eddie Kovsky
Quoted 76 lines · Quentin Schulz

Hi Eddie,

Quoted 40 lines · Eddie Kovsky
Quoted 35 lines · Quentin Schulz

Hi Eddie,

Quoted 11 lines · Eddie Kovsky

The Engine API has been deprecated since the release of OpenSSL 3.0. End users have been advised to migrate to the new Provider interface. Several distributions have already removed support for engines, which is preventing U-Boot from being compiled in those environments.

This series adds support for the OpenSSL Provider API while continuing to support the existing Engine API on distros shipping older releases of OpenSSL. Build dependencies for local development and CI are also updated, while the final patch adds support for using hardware tokens with the Provider API.

Quoted 5 lines

The changes have been tested with the FIT signature verification vboot tests on Fedora 44, Debian 13, and RHEL 8 with OpenSSL 1.1.1. All 37 tests pass with both the legacy Engine library installed and with the Provider API.

I'm NACKing this series quickly because we are having pressure from multiple projects and Tom would like to see this fixed ASAP, and this version here should not be merged. From a cursory look a lot of feedback was ignored, possibly because I did too many rounds of reviews and it got difficult to follow. I'll therefore spend time next week to collect the reviews I made on v4 and that sill apply and post them condensed on this thread.

Please, we just need to fix the build issue for 2027.01. We don't need providers in 2027.01, just the ability to build on OpenSSL 4 and on distros with OpenSSL3 with engines disabled, without breaking OpenSSL engine support for other cases. If you get a patch to fix this, please send it whenever you can, I'll still collect the reviews from v4 and post it here. If you're not interested in doing that, lemme know and I'll take over this part and you can always test the patch(es) if you want to.

Quoted 3 lines

Cheers,
Quentin

Quoted 8 lines

Hi Quentin

I designed this change from the very beginning to maintain the existing code base and preserve backward compatibility for users of older OpenSSL releases who are still using the Engine API. We cannot add support for OpenSSL 3 or later without moving to the Provider API because of the way the OpenSSL project has changed their interface.

That's not true, as already said in v4[1]. We currently support OpenSSL 3 and engines, and we actually test this in CI. You can test locally by running the following commands from your U-Boot git repo:

podman run -it --rm --security-opt label=disable --userns=keep-id:uid=1001,gid=1001 -w $PWD -v $PWD:$PWD docker.io/trini/u-boot-gitlab-ci-runner:noble-20251013-23Jan2026 python3 -m venv /tmp/venv;
. /tmp/venv/bin/activate;
pip install -r test/py/requirements.txt -r tools/binman/requirements.txt -r tools/buildman/requirements.txt -r tools/u_boot_pylib/requirements.txt -r scripts/dtc/pylibfdt/requirements.txt;
export UBOOT_TRAVIS_BUILD_DIR=/tmp/tools-only;
export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt"; export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}"; ./tools/buildman/buildman -T0 -o ${UBOOT_TRAVIS_BUILD_DIR} -w --board tools-only;
export TOOLPATH="--toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools --toolpath /opt/coreboot";
./tools/binman/binman ${TOOLPATH} tool -f missing;
for test in testFitSignEngineSimple testFitSignPKCS11Simple testFitSignPKCS11Object; do ./tools/binman/binman ${TOOLPATH} test $test; done

Quoted 2 lines

You'll see all engine tests pass.

Quoted 7 lines

I assume you are referring to my second sentence "We cannot add support for OpenSSL 3 or later without moving to the Provider API ..." I can see how that wording could be confusing.

OpenSSL 3 deprecated the Engine API but did not remove it. The Engine code is still present but not callable in v3 because the header files were removed to help prepare users to migrate to the new Provider API.

The above is incorrect but has been discussed by Peter in a different thread so I won't reiterate here.

Quoted 8 lines

And OpenSSL 4, which is gaining more adoption, removes the Engine API code entirely and only makes the Provider interface available.

Some distros, like Fedora, added an optional package to put the header files back alongside OpenSSL 3 so that projects (like U-Boot) which hadn't migrated to the new API would still build using Engines. I don't know what the base image of your container is or what release of OpenSSL it's using, but it's likely doing something similar to keep the symbols

Once you know where to look, it's easy (I discovered this a few years ago and I'm not sure many people know about it): https://hub.docker.com/layers/trini/u-boot-gitlab-ci-runner/noble-20260113-23Jan2026/images/sha256-d5a14e5c0350a602e7730c9b3d85369b01dc940cd906900074e706c6d2018f91 lists the image layers and you can see 24.04 is used. You can also get this information locally with:

podman inspect docker.io/trini/u-boot-gitlab-ci-runner:noble-20251013-23Jan2026

Fortunately, you don't even need to go that far, you can simply look how Tom builds it, by looking at tools/docker/Dockerfile where you can see the FROM points to ubuntu:noble-20251013 (aka Ubuntu 24.04).

Running the container will happily tell you which version of OpenSSL is in there:

$ podman run -it --rm --security-opt label=disable --userns=keep-id:uid=1001,gid=1001 -w $PWD -v $PWD:$PWD docker.io/trini/u-boot-gitlab-ci-runner:noble-20251013-23Jan2026 openssl version
OpenSSL 3.0.13 30 Jan 2024 (Library: OpenSSL 3.0.13 30 Jan 2024)
Quoted 3 lines

available. But as it stands right now, U-Boot will not compile in any environment that does not provide a bridge back to the Engine API.

That's not true, CI passes fine with the binman tests to check you can sign FIT images with mkimage. See the logs I provided in my previous mail.

Quoted 13 lines

I've found that the fastest test of which API is available in a particular environment is to (optionally) sprinkle some printfs throughout the lib/rsa/rsa-sign.c and then build the tools target. The build will succeed if the headers are available, but quickly fail otherwise:

❯ make tools
--->8
In file included from tools/generated/lib/rsa/rsa-sign.c:1:
./tools/../lib/rsa/rsa-sign.c: In function ‘rsa_engine_get_pub_key’:
./tools/../lib/rsa/rsa-sign.c:115:9: warning: ‘ENGINE_get_id’ is deprecated: ENGINE_get_id API symbol is removed. Define OPENSSL_ENGINE_STUBS to mask linker errors. [-Wdeprecated-declarations]
115 | engine_id = ENGINE_get_id(engine);
| ^~~~~~~~~

Quoted 7 lines

--->8
/usr/bin/ld.bfd: tools/generated/lib/rsa/rsa-sign.o: in function `rsa_engine_init.constprop.0':
rsa-sign.c:(.text+0x15): undefined reference to `ENGINE_load_builtin_engines'

To fix this build problem in an environment where the Engine API is not available (even if OpenSSL 3 is) we need to call the Provider API to replace the equivalent functionality. There is not another fix to the

The equivalent functionality would be to use the Provider API to call OpenSSL engines via org.openssl.engine: prefix, otherwise you need to use a Provider, and that is not equivalent functionality. We do not want to support OpenSSL engines via the Provider API so the Provider API should only be used for supporting providers, which we don't need to fix the build issue against OpenSSL 4.x and OpenSSL 3.x on some distros (at least Fedora 44).

Quoted 3 lines

build failure unless you want to make a declaration that U-Boot is pinned to the Engine API as a build dependency.

These are the possible scenarios.

- OpenSSL 1.x without actual engine support. Typically, LibreSSL support. I'm assuming this works but I have not tested it. I believe they (LibreSSL) have stubs that do nothing (or fail) when calling the engine API but I'm not sure. Considering OpenSSL 1.0.2 documentation mentions engine, I'm betting the whole of OpenSSL 1.x supports engines.
- OpenSSL 1.x supports the Engine API. Engine support currently works. Must still work after your patch.
- Vanilla OpenSSL 3.x without the hack Fedora 44 is doing. Engine support currently works. Must still work after your patch.
- Fedora's OpenSSL 3.x hack. Engine support removed (and I'll note again that technically it is *NOT* removed but rather hidden or made cumbersome if you wil: they have just removed the ability to build engines locally by default, but you can very well use packaged engines in Fedora 44 without openssl-devel-engine). Build failure. Must build after your patch. Loss of ability to sign with a hardware token is fine, as it's already the current state. There's no need to support providers as that's totally unrelated to the build issue.
- OpenSSL 4.x. Build failure. Must build after your patch. Inability to sign with a hardware token is fine, as it's never been supported with that version of OpenSSL. There's no need to support providers as that's totally unrelated to the build issue.

You only need to remove engine support for the last two scenarios, simply because it's broken. We are not losing features or functionality, it never worked in the first place! However, you need to keep engine support for the two before that (and I don't know the state about the first one but people would have complained already if that was an issue since it's been a long long time (many more years than when Fedora 44 shipped their hack :) )). Provider API will be used for provider support, but we don't need this now.

Your patch is breaking scenario 3.

Quoted 6 lines

I also want to emphasize that I have been careful to keep the existing Engine code as it is. The new code is there to support the Provider path. We collected at least one Tested-By trailer from a LibreSSL user early in review, and I recently found a way to test for regressions with OpenSSL 1.

You can be careful and still make mistakes. Your patch is still removing engine support on OpenSSL 3.x, where it is actually supported and currently working (except on Fedora 44, which you're trying to fix).

Quoted 11 lines
Quoted 11 lines

Additionally, from my branch at https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commits/openssl-providers,
I have tests for both OpenSSL engines and providers *at the same time*.
Here[2] is the log where you can see none of the OpenSSL engine tests are
skipped and only the PKCS11 provider tests are skipped. They are skipped
because we don't have the proper package installed inside the container but
I tested this locally months ago and they pass if the package is installed.
If either the engines or providers weren't supported, you would get a skip
with a given reason, see [3][4]. [5] shows that you can build both engine
and provider support in lib/rsa/rsa-sign.c.

Quoted 9 lines
Quoted 4 lines

If what you said was true, we would have had a build issue when every distro moved to OpenSSL 3 when it was first released 5 years ago, which didn't happen.

That's correct, because as stated above OpenSSL 3 only deprecated the Engine API without removing it, and some distributions still made the headers available.

That is... correct. So I'm now getting very confused as to where the misunderstanding is.

Quoted 3 lines

My second patch, along with the CI work Tom did earlier this year, addresses the missing package in the CI container.

It is not missing. You are adding support for providers, then of course you need a package for testing providers. We don't need providers to fix the build issue with engines.

Quoted 11 lines
Quoted 11 lines

[1] https://lore.kernel.org/u-boot/[email protected]/
[2] https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/jobs/79119/raw
[3] https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/blob/openssl-providers/tools/binman/ftest.py#L8339
[4] https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/blob/openssl-providers/tools/binman/ftest.py#L8719
[5] https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/blob/openssl-providers/lib/rsa/rsa-sign.c#L22-L33

Quoted 4 lines

Both I and other reviewers have tested the proposed changes on different distributions using different OpenSSL releases. The build failure is resolved on OpenSSL >= 3, while building with the Engine API still works as expected. (The only obstacle we found was that signing with a

Quoted 5 lines
Quoted 3 lines

Run the list of commands above with your patch series applied and you'll see it doesn't work.

What commands? You said the podman local test runner does succeed. If

Apologies for the misunderstanding, when I wrote "run the following commands from your U-Boot git repo" I didn't mean with your patches applied, but rather from where the command should be run (see the $PWD in the command, which expects you to be mounting the root directory of the U-Boot git repository). It works on main. It works in my branch. It doesn't work with your patch applied.

Quoted 3 lines

you have an example of a specific failure please include the complete output along with the commands and environment that reproduced it.

I gave you the commands to run as well as logs from the CI and proofs of why the tests work in my branch where I have both OpenSSL engines AND OpenSSL providers supported at the same time. The OpenSSL engine support is *still* going through the engine API and not the provider API. Having OpenSSL engine support go through the provider API would require the org.openssl.engine: prefix, which you won't find in my branch.

I can work on a branch where there's no provider support at all, and which will build, use and test OpenSSL engines when possible (including with OpenSSL 3.x, except on Fedora 44 without openssl-devel-engine installed in which case the build will succeed and tests will be skipped as expected) if you don't believe me.

Quoted 27 lines
Quoted 6 lines
Quoted 5 lines

hardware token key using Providers didn't work, partly because the existing code doesn't make the pkcs11 uri parsing available on all paths. But Johannes already proposed a solution that resolves that issue.)

Quoted 8 lines

I'll discuss the provider part later on, I would like us to focus on the OpenSSL engine build failure for distros where OpenSSL doesn't support it anymore (Fedora 44 without the ability to compile code using engines anymore unless openssl-devel-engine is installed, and every distro with OpenSSL 4) while still keeping OpenSSL engine support working when it is possible to support it (all other cases, including Fedora 44 with openssl-devel-engine installed).

See my previous explanation.

Quoted 9 lines
Quoted 3 lines

What are your specific concerns about the code in this version of the patch series?

See review on patch 1 (posted a few minutes after you sent this mail here, unfortunate timing). But essentially, this breaks OpenSSL engine support on OpenSSL 3, which is something that is supported by OpenSSL and which we want to keep supporting.

Quoted 5 lines

As mentioned in my commit messages and earlier in my reply, I have been careful to preserve backward compatibility for users who may still be building U-Boot with the existing Engine code path. Your other email states my patch "will break" distros like Debian and Arch. I've been testing on Debian stable and not seen any problems. How did you

Did you test the OpenSSL *engine* in Debian stable or the hardware signing with mkimage using OpenSSL? I suspect you did the latter and were using the OpenSSL provider and not engine, in which case you're testing something we currently don't care about.

Quoted 2 lines

determine that Engine support is broken?

With the commands I provided in my previous mail, please give them a try.

Cheers,
Quentin

#16 lore raw
Quoted 195 lines · Quentin Schulz

Hi Eddie,

Quoted 80 lines · Eddie Kovsky
Quoted 76 lines · Quentin Schulz

Hi Eddie,

Quoted 40 lines · Eddie Kovsky
Quoted 35 lines · Quentin Schulz

Hi Eddie,

Quoted 11 lines · Eddie Kovsky

The Engine API has been deprecated since the release of OpenSSL 3.0. End users have been advised to migrate to the new Provider interface. Several distributions have already removed support for engines, which is preventing U-Boot from being compiled in those environments.

This series adds support for the OpenSSL Provider API while continuing to support the existing Engine API on distros shipping older releases of OpenSSL. Build dependencies for local development and CI are also updated, while the final patch adds support for using hardware tokens with the Provider API.

Quoted 5 lines

The changes have been tested with the FIT signature verification vboot tests on Fedora 44, Debian 13, and RHEL 8 with OpenSSL 1.1.1. All 37 tests pass with both the legacy Engine library installed and with the Provider API.

I'm NACKing this series quickly because we are having pressure from multiple projects and Tom would like to see this fixed ASAP, and this version here should not be merged. From a cursory look a lot of feedback was ignored, possibly because I did too many rounds of reviews and it got difficult to follow. I'll therefore spend time next week to collect the reviews I made on v4 and that sill apply and post them condensed on this thread.

Please, we just need to fix the build issue for 2027.01. We don't need providers in 2027.01, just the ability to build on OpenSSL 4 and on distros with OpenSSL3 with engines disabled, without breaking OpenSSL engine support for other cases. If you get a patch to fix this, please send it whenever you can, I'll still collect the reviews from v4 and post it here. If you're not interested in doing that, lemme know and I'll take over this part and you can always test the patch(es) if you want to.

Quoted 3 lines

Cheers,
Quentin

Quoted 8 lines

Hi Quentin

I designed this change from the very beginning to maintain the existing code base and preserve backward compatibility for users of older OpenSSL releases who are still using the Engine API. We cannot add support for OpenSSL 3 or later without moving to the Provider API because of the way the OpenSSL project has changed their interface.

That's not true, as already said in v4[1]. We currently support OpenSSL 3 and engines, and we actually test this in CI. You can test locally by running the following commands from your U-Boot git repo:

podman run -it --rm --security-opt label=disable --userns=keep-id:uid=1001,gid=1001 -w $PWD -v $PWD:$PWD docker.io/trini/u-boot-gitlab-ci-runner:noble-20251013-23Jan2026 python3 -m venv /tmp/venv;
. /tmp/venv/bin/activate;
pip install -r test/py/requirements.txt -r tools/binman/requirements.txt -r tools/buildman/requirements.txt -r tools/u_boot_pylib/requirements.txt -r scripts/dtc/pylibfdt/requirements.txt;
export UBOOT_TRAVIS_BUILD_DIR=/tmp/tools-only;
export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt"; export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}"; ./tools/buildman/buildman -T0 -o ${UBOOT_TRAVIS_BUILD_DIR} -w --board tools-only;
export TOOLPATH="--toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools --toolpath /opt/coreboot";
./tools/binman/binman ${TOOLPATH} tool -f missing;
for test in testFitSignEngineSimple testFitSignPKCS11Simple testFitSignPKCS11Object; do ./tools/binman/binman ${TOOLPATH} test $test; done

Quoted 2 lines

You'll see all engine tests pass.

Quoted 7 lines

I assume you are referring to my second sentence "We cannot add support for OpenSSL 3 or later without moving to the Provider API ..." I can see how that wording could be confusing.

OpenSSL 3 deprecated the Engine API but did not remove it. The Engine code is still present but not callable in v3 because the header files were removed to help prepare users to migrate to the new Provider API.

The above is incorrect but has been discussed by Peter in a different thread so I won't reiterate here.

Quoted 8 lines

And OpenSSL 4, which is gaining more adoption, removes the Engine API code entirely and only makes the Provider interface available.

Some distros, like Fedora, added an optional package to put the header files back alongside OpenSSL 3 so that projects (like U-Boot) which hadn't migrated to the new API would still build using Engines. I don't know what the base image of your container is or what release of OpenSSL it's using, but it's likely doing something similar to keep the symbols

Once you know where to look, it's easy (I discovered this a few years ago
and I'm not sure many people know about it): https://hub.docker.com/layers/trini/u-boot-gitlab-ci-runner/noble-20260113-23Jan2026/images/sha256-d5a14e5c0350a602e7730c9b3d85369b01dc940cd906900074e706c6d2018f91
lists the image layers and you can see 24.04 is used. You can also get this
information locally with:

podman inspect docker.io/trini/u-boot-gitlab-ci-runner:noble-20251013-23Jan2026

Fortunately, you don't even need to go that far, you can simply look how Tom builds it, by looking at tools/docker/Dockerfile where you can see the FROM points to ubuntu:noble-20251013 (aka Ubuntu 24.04).

Running the container will happily tell you which version of OpenSSL is in there:

$ podman run -it --rm --security-opt label=disable
--userns=keep-id:uid=1001,gid=1001 -w $PWD -v $PWD:$PWD
docker.io/trini/u-boot-gitlab-ci-runner:noble-20251013-23Jan2026 openssl
version
OpenSSL 3.0.13 30 Jan 2024 (Library: OpenSSL 3.0.13 30 Jan 2024)
Quoted 3 lines

available. But as it stands right now, U-Boot will not compile in any environment that does not provide a bridge back to the Engine API.

That's not true, CI passes fine with the binman tests to check you can sign FIT images with mkimage. See the logs I provided in my previous mail.

Quoted 13 lines

I've found that the fastest test of which API is available in a particular environment is to (optionally) sprinkle some printfs throughout the lib/rsa/rsa-sign.c and then build the tools target. The build will succeed if the headers are available, but quickly fail otherwise:

❯ make tools
--->8
In file included from tools/generated/lib/rsa/rsa-sign.c:1:
./tools/../lib/rsa/rsa-sign.c: In function ‘rsa_engine_get_pub_key’:
./tools/../lib/rsa/rsa-sign.c:115:9: warning: ‘ENGINE_get_id’ is deprecated: ENGINE_get_id API symbol is removed. Define OPENSSL_ENGINE_STUBS to mask linker errors. [-Wdeprecated-declarations]
115 | engine_id = ENGINE_get_id(engine);
| ^~~~~~~~~

Quoted 7 lines

--->8
/usr/bin/ld.bfd: tools/generated/lib/rsa/rsa-sign.o: in function `rsa_engine_init.constprop.0':
rsa-sign.c:(.text+0x15): undefined reference to `ENGINE_load_builtin_engines'

To fix this build problem in an environment where the Engine API is not available (even if OpenSSL 3 is) we need to call the Provider API to replace the equivalent functionality. There is not another fix to the

The equivalent functionality would be to use the Provider API to call OpenSSL engines via org.openssl.engine: prefix, otherwise you need to use a Provider, and that is not equivalent functionality. We do not want to support OpenSSL engines via the Provider API so the Provider API should only be used for supporting providers, which we don't need to fix the build issue against OpenSSL 4.x and OpenSSL 3.x on some distros (at least Fedora 44).

Quoted 3 lines

build failure unless you want to make a declaration that U-Boot is pinned to the Engine API as a build dependency.

These are the possible scenarios.

- OpenSSL 1.x without actual engine support. Typically, LibreSSL support. I'm assuming this works but I have not tested it. I believe they (LibreSSL) have stubs that do nothing (or fail) when calling the engine API but I'm not sure. Considering OpenSSL 1.0.2 documentation mentions engine, I'm betting the whole of OpenSSL 1.x supports engines.
- OpenSSL 1.x supports the Engine API. Engine support currently works. Must still work after your patch.
- Vanilla OpenSSL 3.x without the hack Fedora 44 is doing. Engine support currently works. Must still work after your patch.
- Fedora's OpenSSL 3.x hack. Engine support removed (and I'll note again that technically it is *NOT* removed but rather hidden or made cumbersome if you wil: they have just removed the ability to build engines locally by default, but you can very well use packaged engines in Fedora 44 without openssl-devel-engine). Build failure. Must build after your patch. Loss of ability to sign with a hardware token is fine, as it's already the current state. There's no need to support providers as that's totally unrelated to the build issue.
- OpenSSL 4.x. Build failure. Must build after your patch. Inability to sign with a hardware token is fine, as it's never been supported with that version of OpenSSL. There's no need to support providers as that's totally unrelated to the build issue.

You only need to remove engine support for the last two scenarios, simply because it's broken. We are not losing features or functionality, it never worked in the first place! However, you need to keep engine support for the two before that (and I don't know the state about the first one but people would have complained already if that was an issue since it's been a long long time (many more years than when Fedora 44 shipped their hack :) )). Provider API will be used for provider support, but we don't need this now.

Quoted 2 lines

Your patch is breaking scenario 3.

This is an upstream API change (and not a Fedora specific issue) that is effecting U-Boot users right now. That impact is only going to grow as OpenSSL 4 sees wider adoption.

But it has become clear to me that there is no version of this patch that will actually satisfy the U-Boot community. Therefore I will not be spending any more time working on it.

Eddie

#17 lore raw
Quoted 199 lines · Eddie Kovsky
Quoted 195 lines · Quentin Schulz

Hi Eddie,

Quoted 80 lines · Eddie Kovsky
Quoted 76 lines · Quentin Schulz

Hi Eddie,

Quoted 40 lines · Eddie Kovsky
Quoted 35 lines · Quentin Schulz

Hi Eddie,

Quoted 11 lines · Eddie Kovsky

The Engine API has been deprecated since the release of OpenSSL 3.0. End users have been advised to migrate to the new Provider interface. Several distributions have already removed support for engines, which is preventing U-Boot from being compiled in those environments.

This series adds support for the OpenSSL Provider API while continuing to support the existing Engine API on distros shipping older releases of OpenSSL. Build dependencies for local development and CI are also updated, while the final patch adds support for using hardware tokens with the Provider API.

Quoted 5 lines

The changes have been tested with the FIT signature verification vboot tests on Fedora 44, Debian 13, and RHEL 8 with OpenSSL 1.1.1. All 37 tests pass with both the legacy Engine library installed and with the Provider API.

I'm NACKing this series quickly because we are having pressure from multiple projects and Tom would like to see this fixed ASAP, and this version here should not be merged. From a cursory look a lot of feedback was ignored, possibly because I did too many rounds of reviews and it got difficult to follow. I'll therefore spend time next week to collect the reviews I made on v4 and that sill apply and post them condensed on this thread.

Please, we just need to fix the build issue for 2027.01. We don't need providers in 2027.01, just the ability to build on OpenSSL 4 and on distros with OpenSSL3 with engines disabled, without breaking OpenSSL engine support for other cases. If you get a patch to fix this, please send it whenever you can, I'll still collect the reviews from v4 and post it here. If you're not interested in doing that, lemme know and I'll take over this part and you can always test the patch(es) if you want to.

Quoted 3 lines

Cheers,
Quentin

Quoted 8 lines

Hi Quentin

I designed this change from the very beginning to maintain the existing code base and preserve backward compatibility for users of older OpenSSL releases who are still using the Engine API. We cannot add support for OpenSSL 3 or later without moving to the Provider API because of the way the OpenSSL project has changed their interface.

That's not true, as already said in v4[1]. We currently support OpenSSL 3 and engines, and we actually test this in CI. You can test locally by running the following commands from your U-Boot git repo:

podman run -it --rm --security-opt label=disable --userns=keep-id:uid=1001,gid=1001 -w $PWD -v $PWD:$PWD docker.io/trini/u-boot-gitlab-ci-runner:noble-20251013-23Jan2026 python3 -m venv /tmp/venv;
. /tmp/venv/bin/activate;
pip install -r test/py/requirements.txt -r tools/binman/requirements.txt -r tools/buildman/requirements.txt -r tools/u_boot_pylib/requirements.txt -r scripts/dtc/pylibfdt/requirements.txt;
export UBOOT_TRAVIS_BUILD_DIR=/tmp/tools-only;
export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt"; export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}"; ./tools/buildman/buildman -T0 -o ${UBOOT_TRAVIS_BUILD_DIR} -w --board tools-only;
export TOOLPATH="--toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools --toolpath /opt/coreboot";
./tools/binman/binman ${TOOLPATH} tool -f missing;
for test in testFitSignEngineSimple testFitSignPKCS11Simple testFitSignPKCS11Object; do ./tools/binman/binman ${TOOLPATH} test $test; done

Quoted 2 lines

You'll see all engine tests pass.

Quoted 7 lines

I assume you are referring to my second sentence "We cannot add support for OpenSSL 3 or later without moving to the Provider API ..." I can see how that wording could be confusing.

OpenSSL 3 deprecated the Engine API but did not remove it. The Engine code is still present but not callable in v3 because the header files were removed to help prepare users to migrate to the new Provider API.

The above is incorrect but has been discussed by Peter in a different thread so I won't reiterate here.

Quoted 8 lines

And OpenSSL 4, which is gaining more adoption, removes the Engine API code entirely and only makes the Provider interface available.

Some distros, like Fedora, added an optional package to put the header files back alongside OpenSSL 3 so that projects (like U-Boot) which hadn't migrated to the new API would still build using Engines. I don't know what the base image of your container is or what release of OpenSSL it's using, but it's likely doing something similar to keep the symbols

Once you know where to look, it's easy (I discovered this a few years ago
and I'm not sure many people know about it): https://hub.docker.com/layers/trini/u-boot-gitlab-ci-runner/noble-20260113-23Jan2026/images/sha256-d5a14e5c0350a602e7730c9b3d85369b01dc940cd906900074e706c6d2018f91
lists the image layers and you can see 24.04 is used. You can also get this
information locally with:

podman inspect docker.io/trini/u-boot-gitlab-ci-runner:noble-20251013-23Jan2026

Fortunately, you don't even need to go that far, you can simply look how Tom builds it, by looking at tools/docker/Dockerfile where you can see the FROM points to ubuntu:noble-20251013 (aka Ubuntu 24.04).

Running the container will happily tell you which version of OpenSSL is in there:

$ podman run -it --rm --security-opt label=disable
--userns=keep-id:uid=1001,gid=1001 -w $PWD -v $PWD:$PWD
docker.io/trini/u-boot-gitlab-ci-runner:noble-20251013-23Jan2026 openssl
version
OpenSSL 3.0.13 30 Jan 2024 (Library: OpenSSL 3.0.13 30 Jan 2024)
Quoted 3 lines

available. But as it stands right now, U-Boot will not compile in any environment that does not provide a bridge back to the Engine API.

That's not true, CI passes fine with the binman tests to check you can sign FIT images with mkimage. See the logs I provided in my previous mail.

Quoted 13 lines

I've found that the fastest test of which API is available in a particular environment is to (optionally) sprinkle some printfs throughout the lib/rsa/rsa-sign.c and then build the tools target. The build will succeed if the headers are available, but quickly fail otherwise:

❯ make tools
--->8
In file included from tools/generated/lib/rsa/rsa-sign.c:1:
./tools/../lib/rsa/rsa-sign.c: In function ‘rsa_engine_get_pub_key’:
./tools/../lib/rsa/rsa-sign.c:115:9: warning: ‘ENGINE_get_id’ is deprecated: ENGINE_get_id API symbol is removed. Define OPENSSL_ENGINE_STUBS to mask linker errors. [-Wdeprecated-declarations]
115 | engine_id = ENGINE_get_id(engine);
| ^~~~~~~~~

Quoted 7 lines

--->8
/usr/bin/ld.bfd: tools/generated/lib/rsa/rsa-sign.o: in function `rsa_engine_init.constprop.0':
rsa-sign.c:(.text+0x15): undefined reference to `ENGINE_load_builtin_engines'

To fix this build problem in an environment where the Engine API is not available (even if OpenSSL 3 is) we need to call the Provider API to replace the equivalent functionality. There is not another fix to the

The equivalent functionality would be to use the Provider API to call OpenSSL engines via org.openssl.engine: prefix, otherwise you need to use a Provider, and that is not equivalent functionality. We do not want to support OpenSSL engines via the Provider API so the Provider API should only be used for supporting providers, which we don't need to fix the build issue against OpenSSL 4.x and OpenSSL 3.x on some distros (at least Fedora 44).

Quoted 3 lines

build failure unless you want to make a declaration that U-Boot is pinned to the Engine API as a build dependency.

These are the possible scenarios.

- OpenSSL 1.x without actual engine support. Typically, LibreSSL support. I'm assuming this works but I have not tested it. I believe they (LibreSSL) have stubs that do nothing (or fail) when calling the engine API but I'm not sure. Considering OpenSSL 1.0.2 documentation mentions engine, I'm betting the whole of OpenSSL 1.x supports engines.
- OpenSSL 1.x supports the Engine API. Engine support currently works. Must still work after your patch.
- Vanilla OpenSSL 3.x without the hack Fedora 44 is doing. Engine support currently works. Must still work after your patch.
- Fedora's OpenSSL 3.x hack. Engine support removed (and I'll note again that technically it is *NOT* removed but rather hidden or made cumbersome if you wil: they have just removed the ability to build engines locally by default, but you can very well use packaged engines in Fedora 44 without openssl-devel-engine). Build failure. Must build after your patch. Loss of ability to sign with a hardware token is fine, as it's already the current state. There's no need to support providers as that's totally unrelated to the build issue.
- OpenSSL 4.x. Build failure. Must build after your patch. Inability to sign with a hardware token is fine, as it's never been supported with that version of OpenSSL. There's no need to support providers as that's totally unrelated to the build issue.

You only need to remove engine support for the last two scenarios, simply because it's broken. We are not losing features or functionality, it never worked in the first place! However, you need to keep engine support for the two before that (and I don't know the state about the first one but people would have complained already if that was an issue since it's been a long long time (many more years than when Fedora 44 shipped their hack :) )). Provider API will be used for provider support, but we don't need this now.

Quoted 2 lines

Your patch is breaking scenario 3.

Quoted 8 lines

This is an upstream API change (and not a Fedora specific issue) that is effecting U-Boot users right now. That impact is only going to grow as OpenSSL 4 sees wider adoption.

But it has become clear to me that there is no version of this patch that will actually satisfy the U-Boot community. Therefore I will not be spending any more time working on it.

I feel bad it's come to this Eddie, but I think Quentin has been clearly describing the problems with your approach, and not pointing it as a Fedora-specific issue.

Signature · 1 line
Tom
#18 lore raw
In reply to Eddie Kovsky

Hi Eddie,

Quoted 5 lines · Eddie Kovsky

This series adds support for the OpenSSL Provider API while continuing to support the existing Engine API on distros shipping older releases of OpenSSL. Build dependencies for local development and CI are also updated, while the final patch adds support for using hardware tokens with the Provider API.

One thing I'd like to check before this series goes in. The provider path does not accept the same command line as the engine path. -k must be the full 'pkcs11:' URI, the key-name-hint is ignored and -N is silently dropped (see my comments on patches 1 and 3). So the same mkimage command works on one host and fails on another, depending on the OpenSSL version. It would be worth keeping the existing command line working with the provider if you can.

Quoted 4 lines

The changes have been tested with the FIT signature verification vboot tests on Fedora 44, Debian 13, and RHEL 8 with OpenSSL 1.1.1. All 37 tests pass with both the legacy Engine library installed and with the Provider API.

Just to check, none of the vboot tests use an engine or a pkcs11 token? If that's right, these 30-odd tests only cover the PEM-file path, and nothing uses the pkcs11-provider package that the Dockerfile change adds to CI. Since you already tested with SoftHSM, please can you add a test which signs with a SoftHSM token? That would give the CI package a purpose and would have caught the gap between patches 1 and 3.

Regards,
Simon

#19 lore raw
Quoted 23 lines · Simon Glass

Hi Eddie,

Quoted 5 lines · Eddie Kovsky

This series adds support for the OpenSSL Provider API while continuing to support the existing Engine API on distros shipping older releases of OpenSSL. Build dependencies for local development and CI are also updated, while the final patch adds support for using hardware tokens with the Provider API.

One thing I'd like to check before this series goes in. The provider path does not accept the same command line as the engine path. -k must be the full 'pkcs11:' URI, the key-name-hint is ignored and -N is silently dropped (see my comments on patches 1 and 3). So the same mkimage command works on one host and fails on another, depending on the OpenSSL version. It would be worth keeping the existing command line working with the provider if you can.

Quoted 4 lines

The changes have been tested with the FIT signature verification vboot tests on Fedora 44, Debian 13, and RHEL 8 with OpenSSL 1.1.1. All 37 tests pass with both the legacy Engine library installed and with the Provider API.

Quoted 7 lines

Just to check, none of the vboot tests use an engine or a pkcs11 token? If that's right, these 30-odd tests only cover the PEM-file path, and nothing uses the pkcs11-provider package that the Dockerfile change adds to CI. Since you already tested with SoftHSM, please can you add a test which signs with a SoftHSM token? That would give the CI package a purpose and would have caught the gap between patches 1 and 3.

Can you please catch up on emails before replying with a bunch of feedback. Quentin has already replied stressing that we need to go with just fixing the build issues for now and dealing with all of the other stuff, of which he has already provided feedback, but will summarize again, as a follow-up.

Signature · 1 line
Tom
#20 lore raw
In reply to Simon Glass
Quoted 10 lines · Simon Glass

Hi Eddie,

Quoted 5 lines · Eddie Kovsky

This series adds support for the OpenSSL Provider API while continuing to support the existing Engine API on distros shipping older releases of OpenSSL. Build dependencies for local development and CI are also updated, while the final patch adds support for using hardware tokens with the Provider API.

Quoted 8 lines

One thing I'd like to check before this series goes in. The provider path does not accept the same command line as the engine path. -k must be the full 'pkcs11:' URI, the key-name-hint is ignored and -N is silently dropped (see my comments on patches 1 and 3). So the same mkimage command works on one host and fails on another, depending on the OpenSSL version. It would be worth keeping the existing command line working with the provider if you can.

I have not seen this happen when testing different versions of OpenSSL. I've been using the test suite to run the vboot tests, which drives mkimage. I've also been running mkimage directly to test hardware key signing and not seen any problems.

Quoted 5 lines
Quoted 4 lines

The changes have been tested with the FIT signature verification vboot tests on Fedora 44, Debian 13, and RHEL 8 with OpenSSL 1.1.1. All 37 tests pass with both the legacy Engine library installed and with the Provider API.

Quoted 7 lines

Just to check, none of the vboot tests use an engine or a pkcs11 token? If that's right, these 30-odd tests only cover the PEM-file path, and nothing uses the pkcs11-provider package that the Dockerfile change adds to CI. Since you already tested with SoftHSM, please can you add a test which signs with a SoftHSM token? That would give the CI package a purpose and would have caught the gap between patches 1 and 3.

The U-Boot documentation states that an easy way to test signing and verification is to use the vboot tests provided in the test suite. We did discover late in the review process that these tests do not exercise hardware key signing and that the existing pkcs11 uri parsing code was not available when using Providers. Without an actual hardware token I used SoftHSM to troubleshoot that issue.

However, I'm not certain it's viable to create an automated hardware token test (even using software emulation). Both the keys and token themselves generate unique identifiers. And the setup requires some user interaction which we may not be able to automate. I suspect those challenges are why we don't already have a hardware token test.

For reference, this is what the end result looks like with my series applied and after all of the manual configuration:

    $ sudo ./tools/mkimage -F -N pkcs11 -k "pkcs11:model=SoftHSM%20v2;manufacturer=SoftHSM%20project;serial=1255c2240187e29e;token=uboot-token;id=%01;object=uboot-key;pin-value=1234" -K mock.dtb -r fitImage
    Warning: configuration 'config-1/signature-1': 'sign-images' is ignored; all referenced images will be signed
    FIT description: Dummy FIT image for testing providers
    Created:         Mon Oct 26 14:08:58 2026
    Image 0 (kernel-1)
    Description:  Dummy Kernel
    Created:      Mon Oct 26 14:08:58 2026
    Type:         Kernel Image
    Compression:  Unknown Compression
    Data Size:    100 Bytes = 0.10 KiB = 0.00 MiB
    Architecture: ARM
    OS:           Linux
    Load Address: 0x80008000
    Entry Point:  0x80008000
    Hash algo:    sha256
    Hash value:   cd00e292c5970d3c5e2f0ffa5171e555bc46bfc4faddfb4a418b6840b86e79a3
    Default Configuration: 'config-1'
    Configuration 0 (config-1)
    Description:  Boot configuration
    Kernel:       kernel-1
    Sign algo:    sha256,rsa2048:dev
    Sign value:   5d66409984c25fccd5e28b6b148b0804c3dcb9abcf2ba1fb16a3fc26e15fcece69a7172ea59c90ec6e3d24735fa22bb3e1a37b85e93a3cece462fad8370ae80cd9a38626907a3cf7fd7ac48456395ea55bfac9892e29c99e39abb81c7bae971ed612534092db804fc31fe36e58c2271e4023deece17c504d2cf5cfaade4de5dd582ce9d25bc65264f2bcad56d20d9fa7671ad50018c32fd13601046f3489ded2bc483cc22ef45299b05cb3bc4968f5339f3b296da3d00621a3762e84df3c5c166265041921481271d68d505690cd18e87ec338eea0cbade2291a5b14556966e969c6d69bb67faddfd532aa90e14a9b714de9bb57294bb6816fc6493f4691c3ba
    Timestamp:    Wed Oct 28 10:36:43 2026
    Signature written to 'fitImage', node '/configurations/config-1/signature-1'
    Public key written to 'mock.dtb', node '/signature/key-dev'
#21 lore raw

Hi Eddie,

Quoted 45 lines · Eddie Kovsky
Quoted 10 lines · Simon Glass

Hi Eddie,

Quoted 5 lines · Eddie Kovsky

This series adds support for the OpenSSL Provider API while continuing to support the existing Engine API on distros shipping older releases of OpenSSL. Build dependencies for local development and CI are also updated, while the final patch adds support for using hardware tokens with the Provider API.

Quoted 8 lines

One thing I'd like to check before this series goes in. The provider path does not accept the same command line as the engine path. -k must be the full 'pkcs11:' URI, the key-name-hint is ignored and -N is silently dropped (see my comments on patches 1 and 3). So the same mkimage command works on one host and fails on another, depending on the OpenSSL version. It would be worth keeping the existing command line working with the provider if you can.

I have not seen this happen when testing different versions of OpenSSL. I've been using the test suite to run the vboot tests, which drives mkimage. I've also been running mkimage directly to test hardware key signing and not seen any problems.

Quoted 5 lines
Quoted 4 lines

The changes have been tested with the FIT signature verification vboot tests on Fedora 44, Debian 13, and RHEL 8 with OpenSSL 1.1.1. All 37 tests pass with both the legacy Engine library installed and with the Provider API.

Quoted 7 lines

Just to check, none of the vboot tests use an engine or a pkcs11 token? If that's right, these 30-odd tests only cover the PEM-file path, and nothing uses the pkcs11-provider package that the Dockerfile change adds to CI. Since you already tested with SoftHSM, please can you add a test which signs with a SoftHSM token? That would give the CI package a purpose and would have caught the gap between patches 1 and 3.

The U-Boot documentation states that an easy way to test signing and verification is to use the vboot tests provided in the test suite. We did discover late in the review process that these tests do not exercise hardware key signing and that the existing pkcs11 uri parsing code was not available when using Providers. Without an actual hardware token I used SoftHSM to troubleshoot that issue.

Quoted 6 lines

However, I'm not certain it's viable to create an automated hardware token test (even using software emulation). Both the keys and token themselves generate unique identifiers. And the setup requires some user interaction which we may not be able to automate. I suspect those challenges are why we don't already have a hardware token test.

We're currently abusing binman test suite to test mkimage signing, but we have actually already automated all this. Including with stable keys, and we verify the signature of the image generated by mkimage with SoftHSMv2 (engines currently, but I have tests for providers too). We should think about stopping to abuse the binman test suite for that and have this a proper mkimage test, since the midterm goal for binman is to have it in its own repo so other projects can use it. Then, it doesn't make sense to test mkimage produces valid images, we just need to make sure we call mkimage with the expected arguments and mock the rest. This is for later though, and we can still abuse the test suite for now so that things are properly tested in CI. Did we automate it incorrectly? Is there something we can improve? Is there anything preventing you from doing the same thing we've done with OpenSSL engines, but for providers, with SoftHSMv2?

Cheers,
Quentin