Add support for OpenSSL Provider API
PATCH v2 1/1 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.
The Kconfig option OPENSSL_NO_DEPRECATED introduces support for the Provider API while continuing to use 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
The changes have been tested with the FIT signature verification vboot tests on Fedora 42 and Debian 13. All 30 tests pass with both the legacy Engine library installed and with the Provider API.
---
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]/
--- lib/aes/aes-encrypt.c | 2 + lib/rsa/Kconfig | 7 ++++ lib/rsa/rsa-sign.c | 89 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+)
lib/aes/aes-encrypt.c +2 -0
@@ -16,7 +16,9 @@#include <openssl/err.h> #include <openssl/ssl.h> #include <openssl/evp.h> +#ifndef CONFIG_OPENSSL_NO_DEPRECATED #include <openssl/engine.h> +#endif #include <uboot_aes.h> #if OPENSSL_VERSION_NUMBER >=0x10000000L
lib/rsa/Kconfig +7 -0
@@ -20,6 +20,13 @@ config SPL_RSA bool "Use RSA Library within SPL" depends on SPL +config OPENSSL_NO_DEPRECATED + bool "Build U-Boot without support for OpenSSL Engine" + help + Add support for the OpenSSL Provider API, which is the officially + supported mechanism in OpenSSL 3.x and later releases for accessing + hardware and software cryptography. + config SPL_RSA_VERIFY bool depends on SPL_RSA
lib/rsa/rsa-sign.c +89 -0
207 lines not on this page · raw message
Signature · 1 line
2.51.0
Hi Eddie,
Quoted 7 lines · Eddie Kovsky
[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
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.
Which ones? How do I reproduce?
Quoted 1 line
The
KconfigoptionOPENSSL_NO_DEPRECATEDintroduces support for the
Please consider renaming this, OpenSSL itself uses OPENSSL_NO_DEPRECATED constants for many things. I would recommend simply renaming to OPENSSL_NO_ENGINE which is also the symbol OpenSSL is using. If there comes a time we have more OPENSSL_NO_ options, we can always have a "virtual" symbol called OPENSSL_NO_DEPRECATED which would select them all if one wanted for example.
Quoted 3 lines
Provider API while continuing to use the existing Engine API on distros shipping older releases of OpenSSL.
One can use org.openssl.engine: as prefix for provider arguments when one wants to use an engine still.
Quoted 7 lines
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
Quoted 6 lines
sign-file,extract-cert: use pkcs11 provider for OPENSSL MAJOR >= 3
The changes have been tested with the FIT signature verification vboot tests on Fedora 42 and Debian 13. All 30 tests pass with both the legacy Engine library installed and with the Provider API.
Are there actually tests using an OpenSSL engine? Because otherwise it's simply checking that local keys are still working... which isn't that much different from what we currently have with engines when not using engines.
I'm implementing FIT images signing with OpenSSL engines, and it'd be nice if we could have something that doesn't require changes to support providers (or if it does, not in a confusing manner for example).
https://lore.kernel.org/u-boot/[email protected]/T/#t for the v1, I'll soon (next hours or tomorrow) post a v2 and Cc you if you don't mind.
[...]
Quoted 5 lines
lib/rsa/Kconfig +0
-0
lib/rsa/Kconfig config SPL_RSA · line 29
Quoted 10 lines
lib/rsa/Kconfig +7
-0@@ -20,6 +20,13 @@ config SPL_RSA bool "Use RSA Library within SPL" depends on SPL +config OPENSSL_NO_DEPRECATED + bool "Build U-Boot without support for OpenSSL Engine" + help + Add support for the OpenSSL Provider API, which is the officially + supported mechanism in OpenSSL 3.x and later releases for accessing + hardware and software cryptography. +
mmmm Cannot we use providers for something else than RSA? In which case it's a bit odd to have it in lib/rsa/Kconfig (but I have no better suggestion).
Quoted 3 lines
lib/rsa/Kconfig +0
-0config SPL_RSA_VERIFY bool depends on SPL_RSA
[...]
Quoted 25 lines
lib/rsa/Kconfig +21
-0@@ -207,6 +247,37 @@ static int rsa_pem_get_priv_key(const char *keydir, const char *name, return -ENOENT; } +#ifdef CONFIG_OPENSSL_NO_DEPRECATED + 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/Kconfig static int rsa_pem_get_priv_key(const char *keydir, const char *name, · line 280
Quoted 10 lines
lib/rsa/Kconfig +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
Wondering if it really makes sense to have the provider API implemented as an #ifdef to save like 10 common lines between key-based and provider-based implems.
On another topic, my first reading of the code makes me a bit worried by the fact that there's seemingly no way to select whether we want to use a local key or a provider key. Also, I see "pkcs11" and "default" here, but how do I select which provider I want to use (e.g. my custom one). If I somehow manage to have a key named the same locally and in one or more providers, how do I make sure the proper one is selected? I'm wondering whether we should be reusing the engine parameter to select a provider?
I have 0 security or crypto background, don't hesitate to be verbose in your answer.
Cheers,
Quentin
Hi Quentin
Quoted 5 lines · Quentin Schulz
Hi Eddie,
Quoted 2 lines · Eddie Kovsky
[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
Quoted 8 lines
Quoted 5 lines
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.
Which ones? How do I reproduce?
As you are probably aware, OpenSSL deprecated the Engine API with the 3.0 release, and engines are likely to be removed entirely when OpenSSL 4.0 is released in 2026. [1][2]
[1] https://docs.openssl.org/3.0/man7/migration_guide/#engines-and-method-apis
[2] https://github.com/openssl/openssl/discussions/21832
I don't have a comprehensive list of all distros. Fedora, RHEL 10, Arch, and Debian 13 are all shipping OpenSSL 3.5. If you try to build U-Boot in those environments the compiler will not be able to resolve the engine API symbols and the build will fail.
Fedora is currently providing a bridge package openssl-devel-engine [3] to help make the API transition easier, but that is only a temporary solution. (I think Debian is currently doing something similar.)
[3] https://packages.fedoraproject.org/pkgs/openssl/openssl-devel-engine/
Quoted 9 lines
Quoted 1 line
The
KconfigoptionOPENSSL_NO_DEPRECATEDintroduces support for thePlease consider renaming this, OpenSSL itself uses
OPENSSL_NO_DEPRECATEDconstants for many things. I would recommend simply renaming toOPENSSL_NO_ENGINEwhich is also the symbol OpenSSL is using. If there comes a time we have moreOPENSSL_NO_options, we can always have a "virtual" symbol calledOPENSSL_NO_DEPRECATEDwhich would select them all if one wanted for example.
I did give some thought to using a different name because I don't like the double negative that comes from this construct:
#ifndef CONFIG_OPENSSL_NO_DEPRECATED
But I kept it because the name is advantageous precisely because it's already recognized by the OpenSSL API. OPENSSL_NO_DEPRECATED is a user-defined macro.[4] When combined with the OPENSSL_API_COMPAT macro, which is already defined in lib/rsa/rsa-sign.c, we can ensure that deprecated symbols won't be available in sections where OPENSSL_NO_DEPRECATED is defined.
[4] https://docs.openssl.org/3.0/man7/openssl_user_macros/
Quoted 7 lines
Quoted 3 lines
Provider API while continuing to use the existing Engine API on distros shipping older releases of OpenSSL.
One can use org.openssl.engine: as prefix for provider arguments when one wants to use an engine still.
Sorry, but it's not clear what you are referring to here.
Quoted 22 lines
Quoted 7 lines
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 +0300Quoted 6 lines
sign-file,extract-cert: use pkcs11 provider for OPENSSL MAJOR >= 3
The changes have been tested with the FIT signature verification vboot tests on Fedora 42 and Debian 13. All 30 tests pass with both the legacy Engine library installed and with the Provider API.
Are there actually tests using an OpenSSL engine? Because otherwise it's simply checking that local keys are still working... which isn't that much different from what we currently have with engines when not using engines.
I'm implementing FIT images signing with OpenSSL engines, and it'd be nice if we could have something that doesn't require changes to support providers (or if it does, not in a confusing manner for example).
Quoted 6 lines
https://lore.kernel.org/u-boot/[email protected]/T/#t
for the v1, I'll soon (next hours or tomorrow) post a v2 and Cc you if you don't mind.[...]
As mentioned above, the motivation for this patch is that the Engine API has already been deprecated. Projects that depend on OpenSSL will need to move to the new Provider API in order to continue to function.
The FIT Signature Verification tests I used to exercise both APIs are documented here.[5]
[5] https://docs.u-boot.org/en/latest/usage/fit/signature.html#u-boot-fit-signature-verification
Quoted 8 lines
Quoted 8 lines
lib/rsa/Kconfig +0
-0@@ -20,6 +20,13 @@ config SPL_RSA bool "Use RSA Library within SPL" depends on SPL
Quoted 11 lines
lib/rsa/Kconfig config SPL_RSA · line 29
Quoted 7 lines
lib/rsa/Kconfig +7
-0+config OPENSSL_NO_DEPRECATED + bool "Build U-Boot without support for OpenSSL Engine" + help + Add support for the OpenSSL Provider API, which is the officially + supported mechanism in OpenSSL 3.x and later releases for accessing + hardware and software cryptography. +mmmm Cannot we use providers for something else than RSA? In which case it's a bit odd to have it in
lib/rsa/Kconfig(but I have no better suggestion).
To the best of my knowledge, the only areas in the U-Boot source that are using the Engine API are the RSA and AES libraries. All other uses in U-Boot are clients of these two libraries.
Quoted 54 lines
Quoted 3 lines
lib/rsa/Kconfig +0
-0config SPL_RSA_VERIFY bool depends on SPL_RSA[...]
Quoted 25 lines
lib/rsa/Kconfig +21
-0@@ -207,6 +247,37 @@ static int rsa_pem_get_priv_key(const char *keydir, const char *name, return -ENOENT; } +#ifdef CONFIG_OPENSSL_NO_DEPRECATED + 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/Kconfig static int rsa_pem_get_priv_key(const char *keydir, const char *name, · line 280
Quoted 10 lines
lib/rsa/Kconfig +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; +#elseWondering if it really makes sense to have the provider API implemented as an #ifdef to save like 10 common lines between key-based and provider-based implems.
On another topic, my first reading of the code makes me a bit worried by the fact that there's seemingly no way to select whether we want to use a local key or a provider key. Also, I see "pkcs11" and "default" here, but how do I select which provider I want to use (e.g. my custom one). If I somehow manage to have a key named the same locally and in one or more providers, how do I make sure the proper one is selected? I'm wondering whether we should be reusing the engine parameter to select a provider?
Quoted 6 lines
I have 0 security or crypto background, don't hesitate to be verbose in your answer.
Cheers,
Quentin
It's not the prettiest code. But I'm trying to be very conservative in making these changes so that no one's workflow is disrupted. Developers should be able to build U-Boot with the latest OpenSSL without impacting developers who are in environments utilizing the Engine API. The goal here is to preserve feature parity between the two APIs. Adding support for custom Providers is outside the scope of this change, but could certainly be added later.
Eddie
Hi Eddie,
Thank you for working on this. It would be really nice if we could build U-Boot on more recent Linux distros without bridge packages such as openssl-devel-engine.
Quoted 48 lines · Eddie Kovsky
Hi Quentin
Quoted 5 lines · Quentin Schulz
Hi Eddie,
Quoted 2 lines · Eddie Kovsky
[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
Quoted 8 lines
Quoted 5 lines
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.
Which ones? How do I reproduce?
As you are probably aware, OpenSSL deprecated the Engine API with the 3.0 release, and engines are likely to be removed entirely when OpenSSL 4.0 is released in 2026. [1][2]
[1] https://docs.openssl.org/3.0/man7/migration_guide/#engines-and-method-apis
[2] https://github.com/openssl/openssl/discussions/21832I don't have a comprehensive list of all distros. Fedora, RHEL 10, Arch, and Debian 13 are all shipping OpenSSL 3.5. If you try to build U-Boot in those environments the compiler will not be able to resolve the engine API symbols and the build will fail.
Fedora is currently providing a bridge package openssl-devel-engine [3] to help make the API transition easier, but that is only a temporary solution. (I think Debian is currently doing something similar.)
[3] https://packages.fedoraproject.org/pkgs/openssl/openssl-devel-engine/
Quoted 9 lines
Quoted 1 line
The
KconfigoptionOPENSSL_NO_DEPRECATEDintroduces support for thePlease consider renaming this, OpenSSL itself uses
OPENSSL_NO_DEPRECATEDconstants for many things. I would recommend simply renaming toOPENSSL_NO_ENGINEwhich is also the symbol OpenSSL is using. If there comes a time we have moreOPENSSL_NO_options, we can always have a "virtual" symbol calledOPENSSL_NO_DEPRECATEDwhich would select them all if one wanted for example.I did give some thought to using a different name because I don't like the double negative that comes from this construct:
Quoted 8 lines
#ifndef CONFIG_OPENSSL_NO_DEPRECATEDBut I kept it because the name is advantageous precisely because it's already recognized by the OpenSSL API.
OPENSSL_NO_DEPRECATEDis a user-defined macro.[4] When combined with theOPENSSL_API_COMPATmacro, which is already defined inlib/rsa/rsa-sign.c, we can ensure that deprecated symbols won't be available in sections whereOPENSSL_NO_DEPRECATEDis defined.
I also don't linke this double negative.
As you already shared, Linux solved this via:
#if OPENSSL_VERSION_MAJOR >= 3
Why can't we have something similar?
See: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=558bdc45dfb2669e1741384a0c80be9c82fa052c
Quoted 137 lines
[4] https://docs.openssl.org/3.0/man7/openssl_user_macros/
Quoted 7 lines
Quoted 3 lines
Provider API while continuing to use the existing Engine API on distros shipping older releases of OpenSSL.
One can use org.openssl.engine: as prefix for provider arguments when one wants to use an engine still.
Sorry, but it's not clear what you are referring to here.
Quoted 22 lines
Quoted 7 lines
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 +0300Quoted 6 lines
sign-file,extract-cert: use pkcs11 provider for OPENSSL MAJOR >= 3
The changes have been tested with the FIT signature verification vboot tests on Fedora 42 and Debian 13. All 30 tests pass with both the legacy Engine library installed and with the Provider API.
Are there actually tests using an OpenSSL engine? Because otherwise it's simply checking that local keys are still working... which isn't that much different from what we currently have with engines when not using engines.
I'm implementing FIT images signing with OpenSSL engines, and it'd be nice if we could have something that doesn't require changes to support providers (or if it does, not in a confusing manner for example).
Quoted 6 lines
https://lore.kernel.org/u-boot/[email protected]/T/#t
for the v1, I'll soon (next hours or tomorrow) post a v2 and Cc you if you don't mind.[...]
As mentioned above, the motivation for this patch is that the Engine API has already been deprecated. Projects that depend on OpenSSL will need to move to the new Provider API in order to continue to function.
The FIT Signature Verification tests I used to exercise both APIs are documented here.[5]
[5] https://docs.u-boot.org/en/latest/usage/fit/signature.html#u-boot-fit-signature-verification
Quoted 8 lines
Quoted 8 lines
lib/rsa/Kconfig +0
-0@@ -20,6 +20,13 @@ config SPL_RSA bool "Use RSA Library within SPL" depends on SPLQuoted 11 lines
lib/rsa/Kconfig config SPL_RSA · line 29
Quoted 7 lines
lib/rsa/Kconfig +7
-0+config OPENSSL_NO_DEPRECATED + bool "Build U-Boot without support for OpenSSL Engine" + help + Add support for the OpenSSL Provider API, which is the officially + supported mechanism in OpenSSL 3.x and later releases for accessing + hardware and software cryptography. +mmmm Cannot we use providers for something else than RSA? In which case it's a bit odd to have it in
lib/rsa/Kconfig(but I have no better suggestion).To the best of my knowledge, the only areas in the U-Boot source that are using the Engine API are the RSA and AES libraries. All other uses in U-Boot are clients of these two libraries.
Quoted 54 lines
Quoted 3 lines
lib/rsa/Kconfig +0
-0config SPL_RSA_VERIFY bool depends on SPL_RSA[...]
Quoted 25 lines
lib/rsa/Kconfig +21
-0@@ -207,6 +247,37 @@ static int rsa_pem_get_priv_key(const char *keydir, const char *name, return -ENOENT; } +#ifdef CONFIG_OPENSSL_NO_DEPRECATED + 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/Kconfig static int rsa_pem_get_priv_key(const char *keydir, const char *name, · line 280
Quoted 10 lines
lib/rsa/Kconfig +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; +#elseWondering if it really makes sense to have the provider API implemented as an #ifdef to save like 10 common lines between key-based and provider-based implems.
On another topic, my first reading of the code makes me a bit worried by the fact that there's seemingly no way to select whether we want to use a local key or a provider key. Also, I see "pkcs11" and "default" here, but how do I select which provider I want to use (e.g. my custom one). If I somehow manage to have a key named the same locally and in one or more providers, how do I make sure the proper one is selected? I'm wondering whether we should be reusing the engine parameter to select a provider?
Quoted 6 lines
I have 0 security or crypto background, don't hesitate to be verbose in your answer.
Cheers,
Quentin
Quoted 7 lines
It's not the prettiest code. But I'm trying to be very conservative in making these changes so that no one's workflow is disrupted. Developers should be able to build U-Boot with the latest OpenSSL without impacting developers who are in environments utilizing the Engine API. The goal here is to preserve feature parity between the two APIs. Adding support for custom Providers is outside the scope of this change, but could certainly be added later.
I'd be in favor to drop CONFIG_OPENSSL_NO_DEPRECATED all together and just use "#if OPENSSL_VERSION_MAJOR >= 3".
Tom, or anyone else, is there a particular` reason for gating this in a Kconfig ?
The oldest Ubuntu version that seems supported (22.04) already has OpenSSL version 3:
$ podman run -it /bin/bash ubuntu:22.04 root@6dc347676b8a:~# apt update && apt install -y openssl root@6dc347676b8a:~# openssl version OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)
Quoted 2 lines
Eddie
Quoted 7 lines · Mattijs Korpershoek
Hi Eddie,
Thank you for working on this. It would be really nice if we could build U-Boot on more recent Linux distros without bridge packages such as openssl-devel-engine.
Quoted 8 lines
I also don't linke this double negative.
As you already shared, Linux solved this via:#if
OPENSSL_VERSION_MAJOR>= 3Why can't we have something similar?
See: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=558bdc45dfb2669e1741384a0c80be9c82fa052c
Hi Mattijs
Yes, we could also implement it this way with the extra USE_PKCS11_XXX symbol. Jan's original patch I based my work on does something similar, and I perhaps oversimplified it.
Quoted 151 lines
Quoted 137 lines
[4] https://docs.openssl.org/3.0/man7/openssl_user_macros/
Quoted 7 lines
Quoted 3 lines
Provider API while continuing to use the existing Engine API on distros shipping older releases of OpenSSL.
One can use org.openssl.engine: as prefix for provider arguments when one wants to use an engine still.
Sorry, but it's not clear what you are referring to here.
Quoted 22 lines
Quoted 7 lines
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 +0300Quoted 6 lines
sign-file,extract-cert: use pkcs11 provider for OPENSSL MAJOR >= 3
The changes have been tested with the FIT signature verification vboot tests on Fedora 42 and Debian 13. All 30 tests pass with both the legacy Engine library installed and with the Provider API.
Are there actually tests using an OpenSSL engine? Because otherwise it's simply checking that local keys are still working... which isn't that much different from what we currently have with engines when not using engines.
I'm implementing FIT images signing with OpenSSL engines, and it'd be nice if we could have something that doesn't require changes to support providers (or if it does, not in a confusing manner for example).
Quoted 6 lines
https://lore.kernel.org/u-boot/[email protected]/T/#t
for the v1, I'll soon (next hours or tomorrow) post a v2 and Cc you if you don't mind.[...]
As mentioned above, the motivation for this patch is that the Engine API has already been deprecated. Projects that depend on OpenSSL will need to move to the new Provider API in order to continue to function.
The FIT Signature Verification tests I used to exercise both APIs are documented here.[5]
[5] https://docs.u-boot.org/en/latest/usage/fit/signature.html#u-boot-fit-signature-verification
Quoted 8 lines
Quoted 8 lines
lib/rsa/Kconfig +0
-0@@ -20,6 +20,13 @@ config SPL_RSA bool "Use RSA Library within SPL" depends on SPLQuoted 11 lines
lib/rsa/Kconfig config SPL_RSA · line 29
Quoted 7 lines
lib/rsa/Kconfig +7
-0+config OPENSSL_NO_DEPRECATED + bool "Build U-Boot without support for OpenSSL Engine" + help + Add support for the OpenSSL Provider API, which is the officially + supported mechanism in OpenSSL 3.x and later releases for accessing + hardware and software cryptography. +mmmm Cannot we use providers for something else than RSA? In which case it's a bit odd to have it in
lib/rsa/Kconfig(but I have no better suggestion).To the best of my knowledge, the only areas in the U-Boot source that are using the Engine API are the RSA and AES libraries. All other uses in U-Boot are clients of these two libraries.
Quoted 54 lines
Quoted 3 lines
lib/rsa/Kconfig +0
-0config SPL_RSA_VERIFY bool depends on SPL_RSA[...]
Quoted 25 lines
lib/rsa/Kconfig +21
-0@@ -207,6 +247,37 @@ static int rsa_pem_get_priv_key(const char *keydir, const char *name, return -ENOENT; } +#ifdef CONFIG_OPENSSL_NO_DEPRECATED + 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/Kconfig static int rsa_pem_get_priv_key(const char *keydir, const char *name, · line 280
Quoted 10 lines
lib/rsa/Kconfig +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; +#elseWondering if it really makes sense to have the provider API implemented as an #ifdef to save like 10 common lines between key-based and provider-based implems.
On another topic, my first reading of the code makes me a bit worried by the fact that there's seemingly no way to select whether we want to use a local key or a provider key. Also, I see "pkcs11" and "default" here, but how do I select which provider I want to use (e.g. my custom one). If I somehow manage to have a key named the same locally and in one or more providers, how do I make sure the proper one is selected? I'm wondering whether we should be reusing the engine parameter to select a provider?
Quoted 6 lines
I have 0 security or crypto background, don't hesitate to be verbose in your answer.
Cheers,
QuentinQuoted 7 lines
It's not the prettiest code. But I'm trying to be very conservative in making these changes so that no one's workflow is disrupted. Developers should be able to build U-Boot with the latest OpenSSL without impacting developers who are in environments utilizing the Engine API. The goal here is to preserve feature parity between the two APIs. Adding support for custom Providers is outside the scope of this change, but could certainly be added later.
I'd be in favor to drop
CONFIG_OPENSSL_NO_DEPRECATEDall together and just use "#ifOPENSSL_VERSION_MAJOR>= 3".Tom, or anyone else, is there a particular` reason for gating this in a
Kconfig?
Quoted 8 lines
The oldest Ubuntu version that seems supported (22.04) already has OpenSSL version 3:
$ podman run -it /bin/bash ubuntu:22.04 root@6dc347676b8a:~# apt update && apt install -y openssl root@6dc347676b8a:~# openssl version OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)
I assumed that we would want this to be an explicit config option, but logically there is no reason that it has to be. I'd be happy to spin up a v3 if there's agreement that the Kconfig isn't needed.
Eddie
Quoted 17 lines · Eddie Kovsky
Quoted 7 lines · Mattijs Korpershoek
Hi Eddie,
Thank you for working on this. It would be really nice if we could build U-Boot on more recent Linux distros without bridge packages such as openssl-devel-engine.
Quoted 8 lines
I also don't linke this double negative.
As you already shared, Linux solved this via:#if
OPENSSL_VERSION_MAJOR>= 3Why can't we have something similar?
See: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=558bdc45dfb2669e1741384a0c80be9c82fa052c
Quoted 5 lines
Hi Mattijs
Yes, we could also implement it this way with the extra
USE_PKCS11_XXXsymbol. Jan's original patch I based my work on does something similar, and I perhaps oversimplified it.
In my experience, when porting things from the Linux kernel into U-Boot, we try to keep the code as similar as possible. This helps reducing maintainance burden.
Sometimes, we can't do that. In that case, we should explain why.
Do we have a strong reason for *not* reusing OPENSSL_VERSION_MAJOR with USE_PKCS11_XXX ?
[...]
Quoted 25 lines
Quoted 16 lines
Quoted 9 lines
Quoted 1 line
It's not the prettiest code. But I'm trying to be very conservative in making these changes so that no one's workflow is disrupted. Developers should be able to build U-Boot with the latest OpenSSL without impacting developers who are in environments utilizing the Engine API. The goal here is to preserve feature parity between the two APIs. Adding support for custom Providers is outside the scope of this change, but could certainly be added later.
I'd be in favor to drop
CONFIG_OPENSSL_NO_DEPRECATEDall together and just use "#ifOPENSSL_VERSION_MAJOR>= 3".Tom, or anyone else, is there a particular` reason for gating this in a
Kconfig?Quoted 8 lines
The oldest Ubuntu version that seems supported (22.04) already has OpenSSL version 3:
$ podman run -it /bin/bash ubuntu:22.04 root@6dc347676b8a:~# apt update && apt install -y openssl root@6dc347676b8a:~# openssl version OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)
Quoted 3 lines
I assumed that we would want this to be an explicit config option, but logically there is no reason that it has to be. I'd be happy to spin up a v3 if there's agreement that the
Kconfigisn't needed.
Tom, do you have an opinion on this? It seems you are listed as maintainer for this (THE REST).
Quoted 2 lines
Eddie
Quoted 61 lines · Mattijs Korpershoek
Quoted 17 lines · Eddie Kovsky
Quoted 7 lines · Mattijs Korpershoek
Hi Eddie,
Thank you for working on this. It would be really nice if we could build U-Boot on more recent Linux distros without bridge packages such as openssl-devel-engine.
Quoted 8 lines
I also don't linke this double negative.
As you already shared, Linux solved this via:#if
OPENSSL_VERSION_MAJOR>= 3Why can't we have something similar?
See: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=558bdc45dfb2669e1741384a0c80be9c82fa052cQuoted 5 lines
Hi Mattijs
Yes, we could also implement it this way with the extra
USE_PKCS11_XXXsymbol. Jan's original patch I based my work on does something similar, and I perhaps oversimplified it.In my experience, when porting things from the Linux kernel into U-Boot, we try to keep the code as similar as possible. This helps reducing maintainance burden.
Sometimes, we can't do that. In that case, we should explain why.
Do we have a strong reason for *not* reusing
OPENSSL_VERSION_MAJORwithUSE_PKCS11_XXX?[...]
Quoted 25 lines
Quoted 24 lines
Quoted 9 lines
Quoted 1 line
It's not the prettiest code. But I'm trying to be very conservative in making these changes so that no one's workflow is disrupted. Developers should be able to build U-Boot with the latest OpenSSL without impacting developers who are in environments utilizing the Engine API. The goal here is to preserve feature parity between the two APIs. Adding support for custom Providers is outside the scope of this change, but could certainly be added later.
I'd be in favor to drop
CONFIG_OPENSSL_NO_DEPRECATEDall together and just use "#ifOPENSSL_VERSION_MAJOR>= 3".Tom, or anyone else, is there a particular` reason for gating this in a
Kconfig?The oldest Ubuntu version that seems supported (22.04) already has OpenSSL version 3:
$ podman run -it /bin/bash ubuntu:22.04 root@6dc347676b8a:~# apt update && apt install -y openssl root@6dc347676b8a:~# openssl version OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)
Quoted 6 lines
Quoted 3 lines
I assumed that we would want this to be an explicit config option, but logically there is no reason that it has to be. I'd be happy to spin up a v3 if there's agreement that the
Kconfigisn't needed.Tom, do you have an opinion on this? It seems you are listed as maintainer for this (THE REST).
Yes, sorry, I think part of the question here is how it plays out with LibreSSL and other alternatives to openssl, which ends up being a Mark question.
Signature · 1 line
Tom
Quoted 66 lines · Tom Rini
Quoted 65 lines · Mattijs Korpershoek
Quoted 17 lines · Eddie Kovsky
Quoted 7 lines · Mattijs Korpershoek
Hi Eddie,
Thank you for working on this. It would be really nice if we could build U-Boot on more recent Linux distros without bridge packages such as openssl-devel-engine.
Quoted 8 lines
I also don't linke this double negative.
As you already shared, Linux solved this via:#if
OPENSSL_VERSION_MAJOR>= 3Why can't we have something similar?
See: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=558bdc45dfb2669e1741384a0c80be9c82fa052cQuoted 5 lines
Hi Mattijs
Yes, we could also implement it this way with the extra
USE_PKCS11_XXXsymbol. Jan's original patch I based my work on does something similar, and I perhaps oversimplified it.In my experience, when porting things from the Linux kernel into U-Boot, we try to keep the code as similar as possible. This helps reducing maintainance burden.
Sometimes, we can't do that. In that case, we should explain why.
Do we have a strong reason for *not* reusing
OPENSSL_VERSION_MAJORwithUSE_PKCS11_XXX?[...]
Quoted 28 lines
Quoted 16 lines
Quoted 9 lines
Quoted 1 line
It's not the prettiest code. But I'm trying to be very conservative in making these changes so that no one's workflow is disrupted. Developers should be able to build U-Boot with the latest OpenSSL without impacting developers who are in environments utilizing the Engine API. The goal here is to preserve feature parity between the two APIs. Adding support for custom Providers is outside the scope of this change, but could certainly be added later.
I'd be in favor to drop
CONFIG_OPENSSL_NO_DEPRECATEDall together and just use "#ifOPENSSL_VERSION_MAJOR>= 3".Tom, or anyone else, is there a particular` reason for gating this in a
Kconfig?Quoted 8 lines
The oldest Ubuntu version that seems supported (22.04) already has OpenSSL version 3:
$ podman run -it /bin/bash ubuntu:22.04 root@6dc347676b8a:~# apt update && apt install -y openssl root@6dc347676b8a:~# openssl version OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)I assumed that we would want this to be an explicit config option, but logically there is no reason that it has to be. I'd be happy to spin up a v3 if there's agreement that the
Kconfigisn't needed.
Quoted 9 lines
Quoted 2 lines
Tom, do you have an opinion on this? It seems you are listed as maintainer for this (THE REST).
Yes, sorry, I think part of the question here is how it plays out with LibreSSL and other alternatives to openssl, which ends up being a Mark question.
Signature · 1 line
Tom
I am being careful not to break backwards compatibility here. I've written the patch so that anyone who needs to continue using the Engine API can do so.
The LibreSSL project implements the OpenSSL 1.1 API, but does not support the OpenSSL 3 API, and to be the best of my knowledge does not intend to support the Provider interface. During the V1 discussion I did ask Mark to verify that my patch preserves backwards compatibility with LibreSSL as intended.
Tom, regarding the other question, would you prefer that I implement this using just #ifdefs without the Kconfig option?
Eddie
Quoted 81 lines · Eddie Kovsky
Quoted 66 lines · Tom Rini
Quoted 65 lines · Mattijs Korpershoek
Quoted 17 lines · Eddie Kovsky
Quoted 7 lines · Mattijs Korpershoek
Hi Eddie,
Thank you for working on this. It would be really nice if we could build U-Boot on more recent Linux distros without bridge packages such as openssl-devel-engine.
Quoted 8 lines
I also don't linke this double negative.
As you already shared, Linux solved this via:#if
OPENSSL_VERSION_MAJOR>= 3Why can't we have something similar?
See: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=558bdc45dfb2669e1741384a0c80be9c82fa052cQuoted 5 lines
Hi Mattijs
Yes, we could also implement it this way with the extra
USE_PKCS11_XXXsymbol. Jan's original patch I based my work on does something similar, and I perhaps oversimplified it.In my experience, when porting things from the Linux kernel into U-Boot, we try to keep the code as similar as possible. This helps reducing maintainance burden.
Sometimes, we can't do that. In that case, we should explain why.
Do we have a strong reason for *not* reusing
OPENSSL_VERSION_MAJORwithUSE_PKCS11_XXX?[...]
Quoted 28 lines
Quoted 16 lines
Quoted 9 lines
Quoted 1 line
It's not the prettiest code. But I'm trying to be very conservative in making these changes so that no one's workflow is disrupted. Developers should be able to build U-Boot with the latest OpenSSL without impacting developers who are in environments utilizing the Engine API. The goal here is to preserve feature parity between the two APIs. Adding support for custom Providers is outside the scope of this change, but could certainly be added later.
I'd be in favor to drop
CONFIG_OPENSSL_NO_DEPRECATEDall together and just use "#ifOPENSSL_VERSION_MAJOR>= 3".Tom, or anyone else, is there a particular` reason for gating this in a
Kconfig?Quoted 8 lines
The oldest Ubuntu version that seems supported (22.04) already has OpenSSL version 3:
$ podman run -it /bin/bash ubuntu:22.04 root@6dc347676b8a:~# apt update && apt install -y openssl root@6dc347676b8a:~# openssl version OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)I assumed that we would want this to be an explicit config option, but logically there is no reason that it has to be. I'd be happy to spin up a v3 if there's agreement that the
Kconfigisn't needed.Quoted 9 lines
Quoted 2 lines
Tom, do you have an opinion on this? It seems you are listed as maintainer for this (THE REST).
Yes, sorry, I think part of the question here is how it plays out with LibreSSL and other alternatives to openssl, which ends up being a Mark question.
Signature · 1 line
TomI am being careful not to break backwards compatibility here. I've written the patch so that anyone who needs to continue using the Engine API can do so.
Quoted 8 lines
The LibreSSL project implements the OpenSSL 1.1 API, but does not support the OpenSSL 3 API, and to be the best of my knowledge does not intend to support the Provider interface. During the V1 discussion I did ask Mark to verify that my patch preserves backwards compatibility with LibreSSL as intended.
Tom, regarding the other question, would you prefer that I implement this using just #ifdefs without the
Kconfigoption?
Yes, lets follow the kernel's example with just #ifdefs, thanks.
Signature · 1 line
Tom
Hi Eddie,
I'm only a couple of months late to the party :)
Quoted 21 lines · Eddie Kovsky
Hi Quentin
Quoted 5 lines · Quentin Schulz
Hi Eddie,
Quoted 2 lines · Eddie Kovsky
[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
Quoted 8 lines
Quoted 5 lines
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.
Which ones? How do I reproduce?
As you are probably aware, OpenSSL deprecated the Engine API with the 3.0 release, and engines are likely to be removed entirely when OpenSSL 4.0 is released in 2026. [1][2]
Quoted 8 lines
[1] https://docs.openssl.org/3.0/man7/migration_guide/#engines-and-method-apis
[2] https://github.com/openssl/openssl/discussions/21832I don't have a comprehensive list of all distros. Fedora, RHEL 10, Arch, and Debian 13 are all shipping OpenSSL 3.5. If you try to build U-Boot in those environments the compiler will not be able to resolve the engine API symbols and the build will fail.
That does not seem to be true.
host$ podman run -it --rm --security-opt label=disable --userns keep-id -w $PWD -v $PWD:$PWD docker.io/debian:trixie
host$ podman exec -it --user root --latest apt-get --update install -y build-essential make bison flex bc rsync kmod cpio libssl-dev gcc-aarch64-linux-gnu debhelper ncurses-dev python3-pyelftools python3-setuptools swig python3-dev container$ touch bl31.elf
container$ export BL31.elf
container$ make CROSS_COMPILE="aarch64-linux-gnu-" O=build/ringneck ringneck-px30_defconfig
container$ make CROSS_COMPILE="aarch64-linux-gnu-" O=build/ringneck -jnproc
You can then see that ./build/ringneck/tools/generated/lib/rsa/rsa-sign.o is built.
host$ podman run -it --rm --security-opt label=disable --userns keep-id -w $PWD -v $PWD:$PWD docker.io/archlinux/archlinux:latest
host$ podman exec -it --user root --latest pacman -Sy openssl swig python python-setuptools make gcc bison flex bc rsync kmod cpio python-pyelftools aarch64-linux-gnu-gcc container$ touch bl31.elf
container$ export BL31.elf
container$ make CROSS_COMPILE="aarch64-linux-gnu-" O=build/ringneck ringneck-px30_defconfig
container$ make CROSS_COMPILE="aarch64-linux-gnu-" O=build/ringneck -jnproc
You can then see that ./build/ringneck/tools/generated/lib/rsa/rsa-sign.o is built.
I'm also pretty sure OpenSSL is built with engine support in Fedora even without openssl-devel-engine since I could run the binman test suite using the openssl pkcs11 engine in Fedora without that package.
Some OpenSSL engines are available in the official package feeds:
$ dnf provides '/usr/lib64/engines-3/*' Updating and loading repositories: Repositories loaded. openssl-libs-1:3.5.5-2.fc44.x86_64 : A general purpose cryptography library with TLS implementation Repo : @System Matched From : Filename : /usr/lib64/engines-3/afalg.so Filename : /usr/lib64/engines-3/capi.so Filename : /usr/lib64/engines-3/loader_attic.so Filename : /usr/lib64/engines-3/padlock.so
openssl-pkcs11-0.4.13-4.fc44.x86_64 : A PKCS#11 engine for use with OpenSSL
Repo : @System
Matched From :
Filename : /usr/lib64/engines-3/libpkcs11.so
Filename : /usr/lib64/engines-3/pkcs11.so
openssl-gost-engine-3.0.3-11.fc44.x86_64 : A reference implementation of the Russian GOST crypto algorithms for OpenSSL
Repo : fedora
Matched From :
Filename : /usr/lib64/engines-3/README.gost
Filename : /usr/lib64/engines-3/gost.so
openssl-libs-1:3.5.5-1.fc44.x86_64 : A general purpose cryptography library with TLS implementation
Repo : fedora
Matched From :
Filename : /usr/lib64/engines-3/afalg.so
Filename : /usr/lib64/engines-3/capi.so
Filename : /usr/lib64/engines-3/loader_attic.so
Filename : /usr/lib64/engines-3/padlock.so
openssl-pkcs11-0.4.13-4.fc44.x86_64 : A PKCS#11 engine for use with OpenSSL
Repo : fedora
Matched From :
Filename : /usr/lib64/engines-3/libpkcs11.so
Filename : /usr/lib64/engines-3/pkcs11.so
p11-remote-0.3-23.fc44.x86_64 : Remoting of PKCS#11 modules across sessions
Repo : fedora
Matched From :
Filename : /usr/lib64/engines-3/libp11-kit-engine.so
tpm2-tss-engine-1.2.0-9.fc44.x86_64 : OpenSSL Engine for TPM2 devices using the tpm2-tss software stack
Repo : fedora
Matched From :
Filename : /usr/lib64/engines-3/libtpm2tss.so
Filename : /usr/lib64/engines-3/tpm2tss.so
openssl-libs-1:3.5.5-2.fc44.x86_64 : A general purpose cryptography library with TLS implementation
Repo : updates
Matched From :
Filename : /usr/lib64/engines-3/afalg.so
Filename : /usr/lib64/engines-3/capi.so
Filename : /usr/lib64/engines-3/loader_attic.so
Filename : /usr/lib64/engines-3/padlock.so
$ openssl engine dynamic -c pkcs11 (dynamic) Dynamic engine loading support (pkcs11) pkcs11 engine
So it seems the only thing Fedora (and RHEL and other Red Hat distros I guess) is doing is moving openssl/engine.h (and a few others) to a different package.
Note that Fedora modifies /usr/include/openssl/configuration-x86_64.h to add
# if !__has_include(<openssl/engine.h>) && !defined(OPENSSL_NO_ENGINE) # define OPENSSL_NO_ENGINE # endif
which is kinda odd since technically, OpenSSL is built with engine support, regardless of openssl/engine.h presence on your system. It does however prevent you from building a new engine. I'm honestly not sure what the intent is by moving this to a separate package? Fail everybody but provide a fallback until OpenSSL 4.x is packaged where the fallback won't be available anymore?
Note that OpenSSL 4.x still ships an engine.h, although with stubs (if OPENSSL_ENGINE_STUBS is defined).
Quoted 4 lines
Fedora is currently providing a bridge package openssl-devel-engine [3] to help make the API transition easier, but that is only a temporary solution. (I think Debian is currently doing something similar.)
Considering Debian happily compiles rsa-sign.o as well as the dummy RSA engine in tools/binman/test/fit with
gcc -lcrypto -lssl dummy-rsa-engine.c -fPIC -shared -o dummy-rsa-engine.so
I'm not sure that's true, do you have a source for that?
Quoted 30 lines
[3] https://packages.fedoraproject.org/pkgs/openssl/openssl-devel-engine/
Quoted 9 lines
Quoted 1 line
The
KconfigoptionOPENSSL_NO_DEPRECATEDintroduces support for thePlease consider renaming this, OpenSSL itself uses
OPENSSL_NO_DEPRECATEDconstants for many things. I would recommend simply renaming toOPENSSL_NO_ENGINEwhich is also the symbol OpenSSL is using. If there comes a time we have moreOPENSSL_NO_options, we can always have a "virtual" symbol calledOPENSSL_NO_DEPRECATEDwhich would select them all if one wanted for example.I did give some thought to using a different name because I don't like the double negative that comes from this construct:
#ifndef CONFIG_OPENSSL_NO_DEPRECATEDBut I kept it because the name is advantageous precisely because it's already recognized by the OpenSSL API.
OPENSSL_NO_DEPRECATEDis a user-defined macro.[4] When combined with theOPENSSL_API_COMPATmacro, which is already defined inlib/rsa/rsa-sign.c, we can ensure that deprecated symbols won't be available in sections whereOPENSSL_NO_DEPRECATEDis defined.[4] https://docs.openssl.org/3.0/man7/openssl_user_macros/
Quoted 4 lines
Quoted 3 lines
Provider API while continuing to use the existing Engine API on distros shipping older releases of OpenSSL.
Quoted 6 lines
Quoted 3 lines
One can use org.openssl.engine: as prefix for provider arguments when one wants to use an engine still.
Sorry, but it's not clear what you are referring to here.
I meant to say one can still use engines without using the engine API explicitly, by using org.openssl.engine:<engine>: scheme in OSSL_STORE_open() for example or when a key is requested on the openssl CLI.
Quoted 26 lines
Quoted 26 lines
Quoted 7 lines
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 +0300Quoted 6 lines
sign-file,extract-cert: use pkcs11 provider for OPENSSL MAJOR >= 3
The changes have been tested with the FIT signature verification vboot tests on Fedora 42 and Debian 13. All 30 tests pass with both the legacy Engine library installed and with the Provider API.
Are there actually tests using an OpenSSL engine? Because otherwise it's simply checking that local keys are still working... which isn't that much different from what we currently have with engines when not using engines.
I'm implementing FIT images signing with OpenSSL engines, and it'd be nice if we could have something that doesn't require changes to support providers (or if it does, not in a confusing manner for example).
https://lore.kernel.org/u-boot/[email protected]/T/#t
for the v1, I'll soon (next hours or tomorrow) post a v2 and Cc you if you don't mind.
Quoted 7 lines
Quoted 2 lines
[...]
As mentioned above, the motivation for this patch is that the Engine API has already been deprecated. Projects that depend on OpenSSL will need to move to the new Provider API in order to continue to function.
Yes. At the same time, OpenSSL 3.5 is supported until April 2030 so until we are a few years after that, we'll probably still need to support engines.
Quoted 5 lines
The FIT Signature Verification tests I used to exercise both APIs are documented here.[5]
[5] https://docs.u-boot.org/en/latest/usage/fit/signature.html#u-boot-fit-signature-verification
Did you follow https://docs.u-boot.org/en/latest/usage/fit/signature.html#hardware-signing-with-pkcs-11-or-with-hsm which I believe is the only section which uses an engine? Specifically, the last code snippet "Sign the fitImage with the hardware key:".
I don't think we have any test in ./test/py/test.py --bd sandbox --build -k vboot using engines (git grep -E 'pkcs11|engine' test/py doesn't return anything).
Cheers,
Quentin