Fix host tools build without LIBCRYPTO support
cover Fix host tools build without LIBCRYPTO support
A target-independent configuration exists to enable/disable crypto feature when building the host tools. But the crypto-free build is broken.
Paul-Erwan Rio (2):
tools: kwbimage: disable secure boot build without LIBCRYPTO support
tools: fix build without LIBCRYPTO support
include/image.h | 2 +- tools/Kconfig | 1 + tools/fit_image.c | 2 +- tools/image-host.c | 2 ++ tools/kwbimage.c | 18 ++++++++++++++++++ tools/mkimage.c | 5 +++-- 6 files changed, 26 insertions(+), 4 deletions(-)
Signature · 1 line
2.39.0
PATCH 1/2 tools: kwbimage: disable secure boot build without LIBCRYPTO support
The secure boot features cannot be built without 'LIBCRYPTO' enabled. This kind of reverts some of <b4f3cc2c42d97967a3a3c8796c340f6b07ecccac> changes.
---
tools/kwbimage.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
tools/kwbimage.c +18 -0
@@ -19,6 +19,7 @@#include <stdint.h> #include "kwbimage.h" +#if CONFIG_IS_ENABLED (LIBCRYPTO )#include <openssl/bn.h> #include <openssl/rsa.h> #include <openssl/pem.h>
@@ -44,6 +45,7 @@ void EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)EVP_MD_CTX_reset (ctx); }#endif +#endif /* fls - find last (most-significant) bit set in 4-bit integer */ static inline int fls4 (int num)
@@ -62,7 +64,9 @@ static inline int fls4(int num)static struct image_cfg_element *image_cfg;static int cfgn; +#if CONFIG_IS_ENABLED (LIBCRYPTO )static int verbose_mode; +#endif struct boot_mode {unsigned int id;
@@ -278,6 +282,7 @@ image_count_options(unsigned int optiontype)return count; } +#if CONFIG_IS_ENABLED (LIBCRYPTO )static int image_get_csk_index (void ) {struct image_cfg_element *e;
@@ -299,6 +304,7 @@ static bool image_get_spezialized_img(void) return e->sec_specialized_img; } +#endif static int image_get_bootfrom (void ) {
@@ -432,6 +438,7 @@ static uint8_t baudrate_to_option(unsigned int baudrate) } } +#if CONFIG_IS_ENABLED (LIBCRYPTO )static void kwb_msg (const char *fmt, ...) {if (verbose_mode) {
@@ -926,6 +933,7 @@ static int kwb_dump_fuse_cmds(struct secure_hdr_v1 *sec_hdr) done: return ret; } +#endif static size_t image_headersz_align (size_t headersz,uint8_t blockid) {
@@ -1079,11 +1087,13 @@ static size_t image_headersz_v1(int *hasext)*/ headersz =sizeof (struct main_hdr_v1 ); +#if CONFIG_IS_ENABLED (LIBCRYPTO )if (image_get_csk_index () >=0 ) { headersz +=sizeof (struct secure_hdr_v1 );if (hasext) *hasext =1 ; } +#endif cpu_sheeva =image_is_cpu_sheeva ();
@@ -1270,6 +1280,7 @@ err_close:return -1 ; } +#if CONFIG_IS_ENABLED (LIBCRYPTO )static int export_pub_kak_hash (RSA *kak,struct secure_hdr_v1 *secure_hdr) {FILE *hashf;
@@ -1382,6 +1393,7 @@ static int add_secure_header_v1(struct image_tool_params *params, uint8_t *ptr,return 0 ; } +#endif static void finish_register_set_header_v1(uint8_t **cur, uint8_t **next_ext, struct register_set_hdr_v1 *register_set_hdr,
@@ -1406,7 +1418,9 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,struct main_hdr_v1 *main_hdr;struct opt_hdr_v1 *ohdr;struct register_set_hdr_v1 *register_set_hdr; +#if CONFIG_IS_ENABLED (LIBCRYPTO )struct secure_hdr_v1 *secure_hdr =NULL ; +#endif size_t headersz;uint8_t *image, *cur;int hasext =0 ;
@@ -1491,6 +1505,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,if (main_hdr->blockid ==IBR_HDR_PEX_ID ) main_hdr->srcaddr =cpu_to_le32 (0xFFFFFFFF ); +#if CONFIG_IS_ENABLED (LIBCRYPTO )if (image_get_csk_index () >=0 ) {/* * only reserve the space here; we fill the header later since
@@ -1501,6 +1516,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, *next_ext =1 ; next_ext = &secure_hdr->next; } +#endif datai =0 ;for (cfgi =0 ; cfgi < cfgn; cfgi++) {
@@ -1552,9 +1568,11 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, &datai, delay); } +#if CONFIG_IS_ENABLED (LIBCRYPTO )if (secure_hdr &&add_secure_header_v1 (params, ptr, payloadsz + headersz, headersz, image, secure_hdr))return NULL ; +#endif *imagesz = headersz;
Signature · 1 line
2.39.0
Re: [PATCH v1 1/2] tools: kwbimage: disable secure boot build without LIBCRYPTO support
Quoted 143 lines · On Saturday 21 January 2023 16:47:41 Paul-Erwan Rio wrote:
The secure boot features cannot be built without 'LIBCRYPTO' enabled. This kind of reverts some of <
b4f3cc2c42d97967a3a3c8796c340f6b07ecccac> changes.Signed-off-by Paul-Erwan Rio <[email protected]>---
tools/kwbimage.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)tools/kwbimage.c +18
-0@@ -19,6 +19,7 @@#include <stdint.h> #include "kwbimage.h" +#if CONFIG_IS_ENABLED (LIBCRYPTO )#include <openssl/bn.h> #include <openssl/rsa.h> #include <openssl/pem.h> @@ -44,6 +45,7 @@ void EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)EVP_MD_CTX_reset (ctx); }#endif +#endif /* fls - find last (most-significant) bit set in 4-bit integer */ static inline int fls4 (int num)@@ -62,7 +64,9 @@ static inline int fls4(int num)static struct image_cfg_element *image_cfg;static int cfgn; +#if CONFIG_IS_ENABLED (LIBCRYPTO )static int verbose_mode; +#endif struct boot_mode {unsigned int id;@@ -278,6 +282,7 @@ image_count_options(unsigned int optiontype)return count; } +#if CONFIG_IS_ENABLED (LIBCRYPTO )static int image_get_csk_index (void ) {struct image_cfg_element *e;@@ -299,6 +304,7 @@ static bool image_get_spezialized_img(void) return e->sec_specialized_img; } +#endif static int image_get_bootfrom (void ) {@@ -432,6 +438,7 @@ static uint8_t baudrate_to_option(unsigned int baudrate) } } +#if CONFIG_IS_ENABLED (LIBCRYPTO )static void kwb_msg (const char *fmt, ...) {if (verbose_mode) {@@ -926,6 +933,7 @@ static int kwb_dump_fuse_cmds(struct secure_hdr_v1 *sec_hdr) done: return ret; } +#endif static size_t image_headersz_align (size_t headersz,uint8_t blockid) {@@ -1079,11 +1087,13 @@ static size_t image_headersz_v1(int *hasext)*/ headersz =sizeof (struct main_hdr_v1 ); +#if CONFIG_IS_ENABLED (LIBCRYPTO )if (image_get_csk_index () >=0 ) { headersz +=sizeof (struct secure_hdr_v1 );if (hasext) *hasext =1 ; } +#endif cpu_sheeva =image_is_cpu_sheeva ();@@ -1270,6 +1280,7 @@ err_close:return -1 ; } +#if CONFIG_IS_ENABLED (LIBCRYPTO )static int export_pub_kak_hash (RSA *kak,struct secure_hdr_v1 *secure_hdr) {FILE *hashf;@@ -1382,6 +1393,7 @@ static int add_secure_header_v1(struct image_tool_params *params, uint8_t *ptr,return 0 ; } +#endif static void finish_register_set_header_v1(uint8_t **cur, uint8_t **next_ext, struct register_set_hdr_v1 *register_set_hdr,@@ -1406,7 +1418,9 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,struct main_hdr_v1 *main_hdr;struct opt_hdr_v1 *ohdr;struct register_set_hdr_v1 *register_set_hdr; +#if CONFIG_IS_ENABLED (LIBCRYPTO )struct secure_hdr_v1 *secure_hdr =NULL ; +#endif size_t headersz;uint8_t *image, *cur;int hasext =0 ;@@ -1491,6 +1505,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,if (main_hdr->blockid ==IBR_HDR_PEX_ID ) main_hdr->srcaddr =cpu_to_le32 (0xFFFFFFFF ); +#if CONFIG_IS_ENABLED (LIBCRYPTO )if (image_get_csk_index () >=0 ) {/* * only reserve the space here; we fill the header later since @@ -1501,6 +1516,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, *next_ext =1 ; next_ext = &secure_hdr->next; } +#endif datai =0 ;for (cfgi =0 ; cfgi < cfgn; cfgi++) {@@ -1552,9 +1568,11 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, &datai, delay); } +#if CONFIG_IS_ENABLED (LIBCRYPTO )if (secure_hdr &&add_secure_header_v1 (params, ptr, payloadsz + headersz, headersz, image, secure_hdr))return NULL ; +#endif *imagesz = headersz;Signature · 1 line
2.39.0
This is entirely wrong change as it completely skips processing of some command lone or config file options. It can lead to generating of broken images by mkimage without any notice by user or any automated CI testing. You really cannot randomly disable or comment some of functions which are currently called.
Re: [PATCH v1 1/2] tools: kwbimage: disable secure boot build without LIBCRYPTO support
Quoted 142 lines · Pali Rohar
Quoted 140 lines · On Saturday 21 January 2023 16:47:41 Paul-Erwan Rio wrote:
The secure boot features cannot be built without 'LIBCRYPTO' enabled. This kind of reverts some of <
b4f3cc2c42d97967a3a3c8796c340f6b07ecccac> changes.Signed-off-by Paul-Erwan Rio <[email protected]>---
tools/kwbimage.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)tools/kwbimage.c +18
-0@@ -19,6 +19,7 @@#include <stdint.h> #include "kwbimage.h" +#if CONFIG_IS_ENABLED (LIBCRYPTO )#include <openssl/bn.h> #include <openssl/rsa.h> #include <openssl/pem.h> @@ -44,6 +45,7 @@ void EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)EVP_MD_CTX_reset (ctx); }#endif +#endif /* fls - find last (most-significant) bit set in 4-bit integer */ static inline int fls4 (int num)@@ -62,7 +64,9 @@ static inline int fls4(int num)static struct image_cfg_element *image_cfg;static int cfgn; +#if CONFIG_IS_ENABLED (LIBCRYPTO )static int verbose_mode; +#endif struct boot_mode {unsigned int id;@@ -278,6 +282,7 @@ image_count_options(unsigned int optiontype)return count; } +#if CONFIG_IS_ENABLED (LIBCRYPTO )static int image_get_csk_index (void ) {struct image_cfg_element *e;@@ -299,6 +304,7 @@ static bool image_get_spezialized_img(void) return e->sec_specialized_img; } +#endif static int image_get_bootfrom (void ) {@@ -432,6 +438,7 @@ static uint8_t baudrate_to_option(unsigned int baudrate) } } +#if CONFIG_IS_ENABLED (LIBCRYPTO )static void kwb_msg (const char *fmt, ...) {if (verbose_mode) {@@ -926,6 +933,7 @@ static int kwb_dump_fuse_cmds(struct secure_hdr_v1 *sec_hdr) done: return ret; } +#endif static size_t image_headersz_align (size_t headersz,uint8_t blockid) {@@ -1079,11 +1087,13 @@ static size_t image_headersz_v1(int *hasext)*/ headersz =sizeof (struct main_hdr_v1 ); +#if CONFIG_IS_ENABLED (LIBCRYPTO )if (image_get_csk_index () >=0 ) { headersz +=sizeof (struct secure_hdr_v1 );if (hasext) *hasext =1 ; } +#endif cpu_sheeva =image_is_cpu_sheeva ();@@ -1270,6 +1280,7 @@ err_close:return -1 ; } +#if CONFIG_IS_ENABLED (LIBCRYPTO )static int export_pub_kak_hash (RSA *kak,struct secure_hdr_v1 *secure_hdr) {FILE *hashf;@@ -1382,6 +1393,7 @@ static int add_secure_header_v1(struct image_tool_params *params, uint8_t *ptr,return 0 ; } +#endif static void finish_register_set_header_v1(uint8_t **cur, uint8_t **next_ext, struct register_set_hdr_v1 *register_set_hdr,@@ -1406,7 +1418,9 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,struct main_hdr_v1 *main_hdr;struct opt_hdr_v1 *ohdr;struct register_set_hdr_v1 *register_set_hdr; +#if CONFIG_IS_ENABLED (LIBCRYPTO )struct secure_hdr_v1 *secure_hdr =NULL ; +#endif size_t headersz;uint8_t *image, *cur;int hasext =0 ;@@ -1491,6 +1505,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,if (main_hdr->blockid ==IBR_HDR_PEX_ID ) main_hdr->srcaddr =cpu_to_le32 (0xFFFFFFFF ); +#if CONFIG_IS_ENABLED (LIBCRYPTO )if (image_get_csk_index () >=0 ) {/* * only reserve the space here; we fill the header later since @@ -1501,6 +1516,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, *next_ext =1 ; next_ext = &secure_hdr->next; } +#endif datai =0 ;for (cfgi =0 ; cfgi < cfgn; cfgi++) {@@ -1552,9 +1568,11 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, &datai, delay); } +#if CONFIG_IS_ENABLED (LIBCRYPTO )if (secure_hdr &&add_secure_header_v1 (params, ptr, payloadsz + headersz, headersz, image, secure_hdr))return NULL ; +#endif *imagesz = headersz;
Quoted 9 lines
Quoted 3 lines
--
2.39.0This is entirely wrong change as it completely skips processing of some command lone or config file options. It can lead to generating of broken images by mkimage without any notice by user or any automated CI testing. You really cannot randomly disable or comment some of functions which are currently called.
Hello,
That is true, especially since I do not know how to test my changes regarding kwbimage. But I do not really randomly disable some functions.
I looked at the commit that introduced the issue:
Date: Fri Jul 23 11:14:13 2021 +0200
tools: kwbimage: Do not hide usage of secure header under CONFIG_ARMADA_38X commit b4f3cc2c42d97967a3a3c8796c340f6b07eccca upstream
And reverted its change. But instead of hiding the secure header usage under the previous CONFIG_ARMADA_38X config, I used the the config that really shows the issue: CONFIG_TOOLS_LIBCRYPTO.
Regards,
Re: [PATCH v1 1/2] tools: kwbimage: disable secure boot build without LIBCRYPTO support
Quoted 163 lines · On Saturday 21 January 2023 17:08:42 Paul-Erwan RIO wrote:
Quoted 142 lines · Pali Rohar
Quoted 140 lines · On Saturday 21 January 2023 16:47:41 Paul-Erwan Rio wrote:
The secure boot features cannot be built without 'LIBCRYPTO' enabled. This kind of reverts some of <
b4f3cc2c42d97967a3a3c8796c340f6b07ecccac> changes.Signed-off-by Paul-Erwan Rio <[email protected]>---
tools/kwbimage.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)tools/kwbimage.c +18
-0@@ -19,6 +19,7 @@#include <stdint.h> #include "kwbimage.h" +#if CONFIG_IS_ENABLED (LIBCRYPTO )#include <openssl/bn.h> #include <openssl/rsa.h> #include <openssl/pem.h> @@ -44,6 +45,7 @@ void EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)EVP_MD_CTX_reset (ctx); }#endif +#endif /* fls - find last (most-significant) bit set in 4-bit integer */ static inline int fls4 (int num)@@ -62,7 +64,9 @@ static inline int fls4(int num)static struct image_cfg_element *image_cfg;static int cfgn; +#if CONFIG_IS_ENABLED (LIBCRYPTO )static int verbose_mode; +#endif struct boot_mode {unsigned int id;@@ -278,6 +282,7 @@ image_count_options(unsigned int optiontype)return count; } +#if CONFIG_IS_ENABLED (LIBCRYPTO )static int image_get_csk_index (void ) {struct image_cfg_element *e;@@ -299,6 +304,7 @@ static bool image_get_spezialized_img(void) return e->sec_specialized_img; } +#endif static int image_get_bootfrom (void ) {@@ -432,6 +438,7 @@ static uint8_t baudrate_to_option(unsigned int baudrate) } } +#if CONFIG_IS_ENABLED (LIBCRYPTO )static void kwb_msg (const char *fmt, ...) {if (verbose_mode) {@@ -926,6 +933,7 @@ static int kwb_dump_fuse_cmds(struct secure_hdr_v1 *sec_hdr) done: return ret; } +#endif static size_t image_headersz_align (size_t headersz,uint8_t blockid) {@@ -1079,11 +1087,13 @@ static size_t image_headersz_v1(int *hasext)*/ headersz =sizeof (struct main_hdr_v1 ); +#if CONFIG_IS_ENABLED (LIBCRYPTO )if (image_get_csk_index () >=0 ) { headersz +=sizeof (struct secure_hdr_v1 );if (hasext) *hasext =1 ; } +#endif cpu_sheeva =image_is_cpu_sheeva ();@@ -1270,6 +1280,7 @@ err_close:return -1 ; } +#if CONFIG_IS_ENABLED (LIBCRYPTO )static int export_pub_kak_hash (RSA *kak,struct secure_hdr_v1 *secure_hdr) {FILE *hashf;@@ -1382,6 +1393,7 @@ static int add_secure_header_v1(struct image_tool_params *params, uint8_t *ptr,return 0 ; } +#endif static void finish_register_set_header_v1(uint8_t **cur, uint8_t **next_ext, struct register_set_hdr_v1 *register_set_hdr,@@ -1406,7 +1418,9 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,struct main_hdr_v1 *main_hdr;struct opt_hdr_v1 *ohdr;struct register_set_hdr_v1 *register_set_hdr; +#if CONFIG_IS_ENABLED (LIBCRYPTO )struct secure_hdr_v1 *secure_hdr =NULL ; +#endif size_t headersz;uint8_t *image, *cur;int hasext =0 ;@@ -1491,6 +1505,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,if (main_hdr->blockid ==IBR_HDR_PEX_ID ) main_hdr->srcaddr =cpu_to_le32 (0xFFFFFFFF ); +#if CONFIG_IS_ENABLED (LIBCRYPTO )if (image_get_csk_index () >=0 ) {/* * only reserve the space here; we fill the header later since @@ -1501,6 +1516,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, *next_ext =1 ; next_ext = &secure_hdr->next; } +#endif datai =0 ;for (cfgi =0 ; cfgi < cfgn; cfgi++) {@@ -1552,9 +1568,11 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, &datai, delay); } +#if CONFIG_IS_ENABLED (LIBCRYPTO )if (secure_hdr &&add_secure_header_v1 (params, ptr, payloadsz + headersz, headersz, image, secure_hdr))return NULL ; +#endif *imagesz = headersz;Quoted 9 lines
Quoted 3 lines
--
2.39.0This is entirely wrong change as it completely skips processing of some command lone or config file options. It can lead to generating of broken images by mkimage without any notice by user or any automated CI testing. You really cannot randomly disable or comment some of functions which are currently called.
Hello,
That is true, especially since I do not know how to test my changes regarding kwbimage. But I do not really randomly disable some functions.
I looked at the commit that introduced the issue:Date: Fri Jul 23 11:14:13 2021 +0200
tools: kwbimage: Do not hide usage of secure header underCONFIG_ARMADA_38Xcommitb4f3cc2c42d97967a3a3c8796c340f6b07ecccaupstream
Quoted 5 lines
And reverted its change. But instead of hiding the secure header usage under the previous
CONFIG_ARMADA_38Xconfig, I used the the config that really shows the issue:CONFIG_TOOLS_LIBCRYPTO.Regards,
And that is wrong. You cannot disable calling of some functions which has to be called based on some settings (e.g. cmdline or config file).
mkimage parses command line options from argv[] and from config file and based on these options it generates output file.
Look at the proposed change. What you have done is that you have randomly disabled calling of some functions which was previously called based on the options specified in mkimage argv[].
mkimage works like any other tool, based on the cmdline supplied in the argv[] it calls specific functions which affects generated output file.
And not calling of some functions which were previously called cause generating of different - broken output file (because it would not match supplied command line options).
Re: [PATCH v1 1/2] tools: kwbimage: disable secure boot build without LIBCRYPTO support
Quoted 181 lines · Pali Rohar
Quoted 163 lines · On Saturday 21 January 2023 17:08:42 Paul-Erwan RIO wrote:
Quoted 142 lines · Pali Rohar
Quoted 140 lines · On Saturday 21 January 2023 16:47:41 Paul-Erwan Rio wrote:
The secure boot features cannot be built without 'LIBCRYPTO' enabled. This kind of reverts some of <
b4f3cc2c42d97967a3a3c8796c340f6b07ecccac> changes.Signed-off-by Paul-Erwan Rio <[email protected]>---
tools/kwbimage.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)tools/kwbimage.c +18
-0@@ -19,6 +19,7 @@#include <stdint.h> #include "kwbimage.h" +#if CONFIG_IS_ENABLED (LIBCRYPTO )#include <openssl/bn.h> #include <openssl/rsa.h> #include <openssl/pem.h> @@ -44,6 +45,7 @@ void EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)EVP_MD_CTX_reset (ctx); }#endif +#endif /* fls - find last (most-significant) bit set in 4-bit integer */ static inline int fls4 (int num)@@ -62,7 +64,9 @@ static inline int fls4(int num)static struct image_cfg_element *image_cfg;static int cfgn; +#if CONFIG_IS_ENABLED (LIBCRYPTO )static int verbose_mode; +#endif struct boot_mode {unsigned int id;@@ -278,6 +282,7 @@ image_count_options(unsigned int optiontype)return count; } +#if CONFIG_IS_ENABLED (LIBCRYPTO )static int image_get_csk_index (void ) {struct image_cfg_element *e;@@ -299,6 +304,7 @@ static bool image_get_spezialized_img(void) return e->sec_specialized_img; } +#endif static int image_get_bootfrom (void ) {@@ -432,6 +438,7 @@ static uint8_t baudrate_to_option(unsigned int baudrate) } } +#if CONFIG_IS_ENABLED (LIBCRYPTO )static void kwb_msg (const char *fmt, ...) {if (verbose_mode) {@@ -926,6 +933,7 @@ static int kwb_dump_fuse_cmds(struct secure_hdr_v1 *sec_hdr) done: return ret; } +#endif static size_t image_headersz_align (size_t headersz,uint8_t blockid) {@@ -1079,11 +1087,13 @@ static size_t image_headersz_v1(int *hasext)*/ headersz =sizeof (struct main_hdr_v1 ); +#if CONFIG_IS_ENABLED (LIBCRYPTO )if (image_get_csk_index () >=0 ) { headersz +=sizeof (struct secure_hdr_v1 );if (hasext) *hasext =1 ; } +#endif cpu_sheeva =image_is_cpu_sheeva ();@@ -1270,6 +1280,7 @@ err_close:return -1 ; } +#if CONFIG_IS_ENABLED (LIBCRYPTO )static int export_pub_kak_hash (RSA *kak,struct secure_hdr_v1 *secure_hdr) {FILE *hashf;@@ -1382,6 +1393,7 @@ static int add_secure_header_v1(struct image_tool_params *params, uint8_t *ptr,return 0 ; } +#endif static void finish_register_set_header_v1(uint8_t **cur, uint8_t **next_ext, struct register_set_hdr_v1 *register_set_hdr,@@ -1406,7 +1418,9 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,struct main_hdr_v1 *main_hdr;struct opt_hdr_v1 *ohdr;struct register_set_hdr_v1 *register_set_hdr; +#if CONFIG_IS_ENABLED (LIBCRYPTO )struct secure_hdr_v1 *secure_hdr =NULL ; +#endif size_t headersz;uint8_t *image, *cur;int hasext =0 ;@@ -1491,6 +1505,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,if (main_hdr->blockid ==IBR_HDR_PEX_ID ) main_hdr->srcaddr =cpu_to_le32 (0xFFFFFFFF ); +#if CONFIG_IS_ENABLED (LIBCRYPTO )if (image_get_csk_index () >=0 ) {/* * only reserve the space here; we fill the header later since @@ -1501,6 +1516,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, *next_ext =1 ; next_ext = &secure_hdr->next; } +#endif datai =0 ;for (cfgi =0 ; cfgi < cfgn; cfgi++) {@@ -1552,9 +1568,11 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, &datai, delay); } +#if CONFIG_IS_ENABLED (LIBCRYPTO )if (secure_hdr &&add_secure_header_v1 (params, ptr, payloadsz + headersz, headersz, image, secure_hdr))return NULL ; +#endif *imagesz = headersz;Quoted 9 lines
Quoted 3 lines
--
2.39.0This is entirely wrong change as it completely skips processing of some command lone or config file options. It can lead to generating of broken images by mkimage without any notice by user or any automated CI testing. You really cannot randomly disable or comment some of functions which are currently called.
Hello,
That is true, especially since I do not know how to test my changes regarding kwbimage. But I do not really randomly disable some functions.
I looked at the commit that introduced the issue:Date: Fri Jul 23 11:14:13 2021 +0200
tools: kwbimage: Do not hide usage of secure header underCONFIG_ARMADA_38Xcommitb4f3cc2c42d97967a3a3c8796c340f6b07ecccaupstreamQuoted 5 lines
And reverted its change. But instead of hiding the secure header usage under the previous
CONFIG_ARMADA_38Xconfig, I used the the config that really shows the issue:CONFIG_TOOLS_LIBCRYPTO.Regards,
And that is wrong. You cannot disable calling of some functions which has to be called based on some settings (e.g. cmdline or config file).
mkimage parses command line options from argv[] and from config file and based on these options it generates output file.
Look at the proposed change. What you have done is that you have randomly disabled calling of some functions which was previously called based on the options specified in mkimage argv[].
Quoted 6 lines
mkimage works like any other tool, based on the cmdline supplied in the argv[] it calls specific functions which affects generated output file.
And not calling of some functions which were previously called cause generating of different - broken output file (because it would not match supplied command line options).
So, if I understand you correctly, the right way to do it would be to prevent the user to call the very functions that need OpenSSL crypto features (and output some kind of warning/error) when LIBCRYPTO support is disabled ? So that the user could not even attempt to create kwbimage v1 with secure header (in this particular case), instead of having a broken output file like you said.
Re: [PATCH v1 1/2] tools: kwbimage: disable secure boot build without LIBCRYPTO support
Quoted 189 lines · On Saturday 21 January 2023 17:31:15 Paul-Erwan RIO wrote:
Quoted 181 lines · Pali Rohar
Quoted 163 lines · On Saturday 21 January 2023 17:08:42 Paul-Erwan RIO wrote:
Quoted 142 lines · Pali Rohar
Quoted 140 lines · On Saturday 21 January 2023 16:47:41 Paul-Erwan Rio wrote:
The secure boot features cannot be built without 'LIBCRYPTO' enabled. This kind of reverts some of <
b4f3cc2c42d97967a3a3c8796c340f6b07ecccac> changes.Signed-off-by Paul-Erwan Rio <[email protected]>---
tools/kwbimage.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)tools/kwbimage.c +18
-0@@ -19,6 +19,7 @@#include <stdint.h> #include "kwbimage.h" +#if CONFIG_IS_ENABLED (LIBCRYPTO )#include <openssl/bn.h> #include <openssl/rsa.h> #include <openssl/pem.h> @@ -44,6 +45,7 @@ void EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)EVP_MD_CTX_reset (ctx); }#endif +#endif /* fls - find last (most-significant) bit set in 4-bit integer */ static inline int fls4 (int num)@@ -62,7 +64,9 @@ static inline int fls4(int num)static struct image_cfg_element *image_cfg;static int cfgn; +#if CONFIG_IS_ENABLED (LIBCRYPTO )static int verbose_mode; +#endif struct boot_mode {unsigned int id;@@ -278,6 +282,7 @@ image_count_options(unsigned int optiontype)return count; } +#if CONFIG_IS_ENABLED (LIBCRYPTO )static int image_get_csk_index (void ) {struct image_cfg_element *e;@@ -299,6 +304,7 @@ static bool image_get_spezialized_img(void) return e->sec_specialized_img; } +#endif static int image_get_bootfrom (void ) {@@ -432,6 +438,7 @@ static uint8_t baudrate_to_option(unsigned int baudrate) } } +#if CONFIG_IS_ENABLED (LIBCRYPTO )static void kwb_msg (const char *fmt, ...) {if (verbose_mode) {@@ -926,6 +933,7 @@ static int kwb_dump_fuse_cmds(struct secure_hdr_v1 *sec_hdr) done: return ret; } +#endif static size_t image_headersz_align (size_t headersz,uint8_t blockid) {@@ -1079,11 +1087,13 @@ static size_t image_headersz_v1(int *hasext)*/ headersz =sizeof (struct main_hdr_v1 ); +#if CONFIG_IS_ENABLED (LIBCRYPTO )if (image_get_csk_index () >=0 ) { headersz +=sizeof (struct secure_hdr_v1 );if (hasext) *hasext =1 ; } +#endif cpu_sheeva =image_is_cpu_sheeva ();@@ -1270,6 +1280,7 @@ err_close:return -1 ; } +#if CONFIG_IS_ENABLED (LIBCRYPTO )static int export_pub_kak_hash (RSA *kak,struct secure_hdr_v1 *secure_hdr) {FILE *hashf;@@ -1382,6 +1393,7 @@ static int add_secure_header_v1(struct image_tool_params *params, uint8_t *ptr,return 0 ; } +#endif static void finish_register_set_header_v1(uint8_t **cur, uint8_t **next_ext, struct register_set_hdr_v1 *register_set_hdr,@@ -1406,7 +1418,9 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,struct main_hdr_v1 *main_hdr;struct opt_hdr_v1 *ohdr;struct register_set_hdr_v1 *register_set_hdr; +#if CONFIG_IS_ENABLED (LIBCRYPTO )struct secure_hdr_v1 *secure_hdr =NULL ; +#endif size_t headersz;uint8_t *image, *cur;int hasext =0 ;@@ -1491,6 +1505,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,if (main_hdr->blockid ==IBR_HDR_PEX_ID ) main_hdr->srcaddr =cpu_to_le32 (0xFFFFFFFF ); +#if CONFIG_IS_ENABLED (LIBCRYPTO )if (image_get_csk_index () >=0 ) {/* * only reserve the space here; we fill the header later since @@ -1501,6 +1516,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, *next_ext =1 ; next_ext = &secure_hdr->next; } +#endif datai =0 ;for (cfgi =0 ; cfgi < cfgn; cfgi++) {@@ -1552,9 +1568,11 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, &datai, delay); } +#if CONFIG_IS_ENABLED (LIBCRYPTO )if (secure_hdr &&add_secure_header_v1 (params, ptr, payloadsz + headersz, headersz, image, secure_hdr))return NULL ; +#endif *imagesz = headersz;Quoted 9 lines
Quoted 3 lines
--
2.39.0This is entirely wrong change as it completely skips processing of some command lone or config file options. It can lead to generating of broken images by mkimage without any notice by user or any automated CI testing. You really cannot randomly disable or comment some of functions which are currently called.
Hello,
That is true, especially since I do not know how to test my changes regarding kwbimage. But I do not really randomly disable some functions.
I looked at the commit that introduced the issue:Date: Fri Jul 23 11:14:13 2021 +0200
tools: kwbimage: Do not hide usage of secure header underCONFIG_ARMADA_38Xcommitb4f3cc2c42d97967a3a3c8796c340f6b07ecccaupstreamQuoted 5 lines
And reverted its change. But instead of hiding the secure header usage under the previous
CONFIG_ARMADA_38Xconfig, I used the the config that really shows the issue:CONFIG_TOOLS_LIBCRYPTO.Regards,
And that is wrong. You cannot disable calling of some functions which has to be called based on some settings (e.g. cmdline or config file).
mkimage parses command line options from argv[] and from config file and based on these options it generates output file.
Look at the proposed change. What you have done is that you have randomly disabled calling of some functions which was previously called based on the options specified in mkimage argv[].
Quoted 6 lines
mkimage works like any other tool, based on the cmdline supplied in the argv[] it calls specific functions which affects generated output file.
And not calling of some functions which were previously called cause generating of different - broken output file (because it would not match supplied command line options).
Quoted 6 lines
So, if I understand you correctly, the right way to do it would be to prevent the user to call the very functions that need OpenSSL crypto features (and output some kind of warning/error) when LIBCRYPTO support is disabled ? So that the user could not even attempt to create kwbimage v1 with secure header (in this particular case), instead of having a broken output file like you said.
Of course, u-boot (and also any other) tools must not generate broken output files. I thought that this is pretty obvious.
Re: [PATCH v1 1/2] tools: kwbimage: disable secure boot build without LIBCRYPTO support
Quoted 198 lines · Pali Rohar
Quoted 189 lines · On Saturday 21 January 2023 17:31:15 Paul-Erwan RIO wrote:
Quoted 181 lines · Pali Rohar
Quoted 163 lines · On Saturday 21 January 2023 17:08:42 Paul-Erwan RIO wrote:
Quoted 142 lines · Pali Rohar
Quoted 140 lines · On Saturday 21 January 2023 16:47:41 Paul-Erwan Rio wrote:
The secure boot features cannot be built without 'LIBCRYPTO' enabled. This kind of reverts some of <
b4f3cc2c42d97967a3a3c8796c340f6b07ecccac> changes.Signed-off-by Paul-Erwan Rio <[email protected]>---
tools/kwbimage.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)tools/kwbimage.c +18
-0@@ -19,6 +19,7 @@#include <stdint.h> #include "kwbimage.h" +#if CONFIG_IS_ENABLED (LIBCRYPTO )#include <openssl/bn.h> #include <openssl/rsa.h> #include <openssl/pem.h> @@ -44,6 +45,7 @@ void EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)EVP_MD_CTX_reset (ctx); }#endif +#endif /* fls - find last (most-significant) bit set in 4-bit integer */ static inline int fls4 (int num)@@ -62,7 +64,9 @@ static inline int fls4(int num)static struct image_cfg_element *image_cfg;static int cfgn; +#if CONFIG_IS_ENABLED (LIBCRYPTO )static int verbose_mode; +#endif struct boot_mode {unsigned int id;@@ -278,6 +282,7 @@ image_count_options(unsigned int optiontype)return count; } +#if CONFIG_IS_ENABLED (LIBCRYPTO )static int image_get_csk_index (void ) {struct image_cfg_element *e;@@ -299,6 +304,7 @@ static bool image_get_spezialized_img(void) return e->sec_specialized_img; } +#endif static int image_get_bootfrom (void ) {@@ -432,6 +438,7 @@ static uint8_t baudrate_to_option(unsigned int baudrate) } } +#if CONFIG_IS_ENABLED (LIBCRYPTO )static void kwb_msg (const char *fmt, ...) {if (verbose_mode) {@@ -926,6 +933,7 @@ static int kwb_dump_fuse_cmds(struct secure_hdr_v1 *sec_hdr) done: return ret; } +#endif static size_t image_headersz_align (size_t headersz,uint8_t blockid) {@@ -1079,11 +1087,13 @@ static size_t image_headersz_v1(int *hasext)*/ headersz =sizeof (struct main_hdr_v1 ); +#if CONFIG_IS_ENABLED (LIBCRYPTO )if (image_get_csk_index () >=0 ) { headersz +=sizeof (struct secure_hdr_v1 );if (hasext) *hasext =1 ; } +#endif cpu_sheeva =image_is_cpu_sheeva ();@@ -1270,6 +1280,7 @@ err_close:return -1 ; } +#if CONFIG_IS_ENABLED (LIBCRYPTO )static int export_pub_kak_hash (RSA *kak,struct secure_hdr_v1 *secure_hdr) {FILE *hashf;@@ -1382,6 +1393,7 @@ static int add_secure_header_v1(struct image_tool_params *params, uint8_t *ptr,return 0 ; } +#endif static void finish_register_set_header_v1(uint8_t **cur, uint8_t **next_ext, struct register_set_hdr_v1 *register_set_hdr,@@ -1406,7 +1418,9 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,struct main_hdr_v1 *main_hdr;struct opt_hdr_v1 *ohdr;struct register_set_hdr_v1 *register_set_hdr; +#if CONFIG_IS_ENABLED (LIBCRYPTO )struct secure_hdr_v1 *secure_hdr =NULL ; +#endif size_t headersz;uint8_t *image, *cur;int hasext =0 ;@@ -1491,6 +1505,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params,if (main_hdr->blockid ==IBR_HDR_PEX_ID ) main_hdr->srcaddr =cpu_to_le32 (0xFFFFFFFF ); +#if CONFIG_IS_ENABLED (LIBCRYPTO )if (image_get_csk_index () >=0 ) {/* * only reserve the space here; we fill the header later since @@ -1501,6 +1516,7 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, *next_ext =1 ; next_ext = &secure_hdr->next; } +#endif datai =0 ;for (cfgi =0 ; cfgi < cfgn; cfgi++) {@@ -1552,9 +1568,11 @@ static void *image_create_v1(size_t *imagesz, struct image_tool_params *params, &datai, delay); } +#if CONFIG_IS_ENABLED (LIBCRYPTO )if (secure_hdr &&add_secure_header_v1 (params, ptr, payloadsz + headersz, headersz, image, secure_hdr))return NULL ; +#endif *imagesz = headersz;Quoted 9 lines
Quoted 3 lines
--
2.39.0This is entirely wrong change as it completely skips processing of some command lone or config file options. It can lead to generating of broken images by mkimage without any notice by user or any automated CI testing. You really cannot randomly disable or comment some of functions which are currently called.
Hello,
That is true, especially since I do not know how to test my changes regarding kwbimage. But I do not really randomly disable some functions.
I looked at the commit that introduced the issue:Date: Fri Jul 23 11:14:13 2021 +0200
tools: kwbimage: Do not hide usage of secure header underCONFIG_ARMADA_38Xcommitb4f3cc2c42d97967a3a3c8796c340f6b07ecccaupstreamQuoted 5 lines
And reverted its change. But instead of hiding the secure header usage under the previous
CONFIG_ARMADA_38Xconfig, I used the the config that really shows the issue:CONFIG_TOOLS_LIBCRYPTO.Regards,
And that is wrong. You cannot disable calling of some functions which has to be called based on some settings (e.g. cmdline or config file).
mkimage parses command line options from argv[] and from config file and based on these options it generates output file.
Look at the proposed change. What you have done is that you have randomly disabled calling of some functions which was previously called based on the options specified in mkimage argv[].
Quoted 6 lines
mkimage works like any other tool, based on the cmdline supplied in the argv[] it calls specific functions which affects generated output file.
And not calling of some functions which were previously called cause generating of different - broken output file (because it would not match supplied command line options).
Quoted 6 lines
So, if I understand you correctly, the right way to do it would be to prevent the user to call the very functions that need OpenSSL crypto features (and output some kind of warning/error) when LIBCRYPTO support is disabled ? So that the user could not even attempt to create kwbimage v1 with secure header (in this particular case), instead of having a broken output file like you said.
Quoted 2 lines
Of course, u-boot (and also any other) tools must not generate broken output files. I thought that this is pretty obvious.
Understood. Then I will need to rework this a lot, and I will re-submit it again when it is ready.
Thanks for your time.
PATCH 2/2 tools: fix build without LIBCRYPTO support
In reply to Paul-Erwan RioCommit <cb9faa6f98ae56d70d59505dad290dd3d381cb7b> introduced a target-independent configuration to build crypto features in host tools.
But since commit <2c21256b27d70b5950bd059330cdab027fb6ab7e>, the build without OpenSSL is broken, due to FIT signature/encryption features. Add missing conditional compilation tokens to fix this.
---
include/image.h | 2 +- tools/Kconfig | 1 + tools/fit_image.c | 2 +- tools/image-host.c | 2 ++ tools/mkimage.c | 5 +++-- 5 files changed, 8 insertions(+), 4 deletions(-)
include/image.h +1 -1
@@ -1388,7 +1388,7 @@ int calculate_hash(const void *data, int data_len, const char *algo,* device */ #if defined(USE_HOSTCC ) -# if defined(CONFIG_FIT_SIGNATURE ) +# if CONFIG_IS_ENABLED (FIT_SIGNATURE )# define IMAGE_ENABLE_SIGN 1# define FIT_IMAGE_ENABLE_VERIFY 1# include <openssl/evp.h>
tools/Kconfig +1 -0
@@ -46,6 +46,7 @@ config TOOLS_FIT_RSASSA_PSS Support the rsassa-pss signature scheme in the tools builds config TOOLS_FIT_SIGNATURE + depends on TOOLS_LIBCRYPTO def_bool y help Enable signature verification of FIT uImages in the tools builds
tools/fit_image.c +1 -1
@@ -61,7 +61,7 @@ static int fit_add_file_data(struct image_tool_params *params, size_t size_inc, ret =fit_set_timestamp (ptr,0 , time); } -if (!ret) +if (CONFIG_IS_ENABLED (FIT_SIGNATURE ) && !ret) ret =fit_pre_load_data (params->keydir, dest_blob, ptr);if (!ret) {
tools/image-host.c +2 -0
@@ -1119,6 +1119,7 @@ static int fit_config_add_verification_data(const char *keydir,return 0 ; } +#if CONFIG_IS_ENABLED (FIT_SIGNATURE )/* * 0) open file (open) * 1) read certificate (PEM_read_X509)
@@ -1227,6 +1228,7 @@ int fit_pre_load_data(const char *keydir, void *keydest, void *fit) out:return ret; } +#endif int fit_cipher_data(const char *keydir, void *keydest, void *fit, const char *comment, int require_keys,
tools/mkimage.c +3 -2
@@ -115,7 +115,7 @@ static void usage(const char *msg)" -B => align size in hex for FIT structure and header\n" " -b => append the device tree binary to the FIT\n" " -t => update the timestamp in the FIT\n"); -#ifdef CONFIG_FIT_SIGNATURE +#if CONFIG_IS_ENABLED (FIT_SIGNATURE )fprintf (stderr,"Signing / verified boot options: [-k keydir] [-K dtb] [ -c <comment>] [-p addr] [-r] [-N engine]\n" " -k => set directory containing private keys\n"
@@ -130,8 +130,9 @@ static void usage(const char *msg) " -o => algorithm to use for signing\n");#else fprintf (stderr, -"Signing / verified boot not supported (CONFIG_FIT_SIGNATURE undefined)\n" ); +"Signing / verified boot not supported (CONFIG_TOOLS_FIT_SIGNATURE undefined)\n" );#endif +fprintf (stderr," %s -V ==> print version information and exit\n" , params.cmdname);fprintf (stderr,"Use '-T list' to see a list of available image types\n" );
Signature · 1 line
2.39.0
Re: [PATCH v1 2/2] tools: fix build without LIBCRYPTO support
Quoted 9 lines · Paul-Erwan Rio
Commit <
cb9faa6f98ae56d70d59505dad290dd3d381cb7b> introduced a target-independent configuration to build crypto features in host tools.But since commit <
2c21256b27d70b5950bd059330cdab027fb6ab7e>, the build without OpenSSL is broken, due to FIT signature/encryption features. Add missing conditional compilation tokens to fix this.Signed-off-by Paul-Erwan Rio <[email protected]>
Quoted 8 lines
---
include/image.h | 2 +- tools/Kconfig | 1 + tools/fit_image.c | 2 +- tools/image-host.c | 2 ++ tools/mkimage.c | 5 +++-- 5 files changed, 8 insertions(+), 4 deletions(-)
If we really want to avoid this sort of thing we should add a test in .gitlab
buildman -a ~CONFIG_TOOLS_FIT_SIGNATURE tools-only
or similar
Re: [PATCH v1 2/2] tools: fix build without LIBCRYPTO support
In reply to Paul-Erwan RioHello,
Am Samstag, 21. Januar 2023, 16:47:42 CET schrieb Paul-Erwan Rio:
Quoted 8 lines
Commit <
cb9faa6f98ae56d70d59505dad290dd3d381cb7b> introduced a target-independent configuration to build crypto features in host tools.But since commit <
2c21256b27d70b5950bd059330cdab027fb6ab7e>, the build without OpenSSL is broken, due to FIT signature/encryption features. Add missing conditional compilation tokens to fix this.Signed-off-by Paul-Erwan Rio <[email protected]>
I applied your patch to my v2023.10 based tree and it fails to build (just using one board as example here, it is not the only one failing).
% buildman -o ~/build/u-boot/buildman -Pr -a '~CONFIG_TOOLS_LIBCRYPTO' sama5d27_som1_ek_mmc Building current source for 2 boards (2 threads, 8 jobs per thread)
arm: + sama5d27_som1_ek_mmc1
+tools/image-host.c:17:10: fatal error: openssl/pem.h: Datei oder Verzeichnis nicht gefunden
+ 17 | #include <openssl/pem.h>
+ | ^~~~~~~~~~~~~~~
+compilation terminated.
+make[2]: *** [scripts/Makefile.host:112: tools/image-host.o] Fehler 1 +make[1]: *** [Makefile:1857: tools] Fehler 2
+make: *** [Makefile:177: sub-make] Error 2
arm: + sama5d27_som1_ek_mmc
+tools/image-host.c:17:10: fatal error: openssl/pem.h: Datei oder Verzeichnis nicht gefunden
+ 17 | #include <openssl/pem.h>
+ | ^~~~~~~~~~~~~~~
+compilation terminated.
+make[2]: *** [scripts/Makefile.host:112: tools/image-host.o] Fehler 1 +make[1]: *** [Makefile:1857: tools] Fehler 2
+make: *** [Makefile:177: sub-make] Error 2
0 0 2 /2 sama5d27_som1_ek_mmc
Completed: 2 total built, 2 newly), duration 0:00:01, rate 2.00
Same if I apply the whole series to master (this time with english locale):
% buildman -o ~/build/u-boot/buildman -Pr -a '~CONFIG_TOOLS_LIBCRYPTO' sama5d27_som1_ek_mmc
Building current source for 2 boards (2 threads, 8 jobs per thread)
arm: + sama5d27_som1_ek_mmc
+tools/image-host.c:17:10: fatal error: openssl/pem.h: No such file or directory
+ 17 | #include <openssl/pem.h>
+ | ^~~~~~~~~~~~~~~
+compilation terminated.
+make[2]: *** [scripts/Makefile.host:112: tools/image-host.o] Error 1
+make[1]: *** [Makefile:1858: tools] Error 2
+make: *** [Makefile:177: sub-make] Error 2
arm: + sama5d27_som1_ek_mmc1
+tools/image-host.c:17:10: fatal error: openssl/pem.h: No such file or directory
+ 17 | #include <openssl/pem.h>
+ | ^~~~~~~~~~~~~~~
+compilation terminated.
+make[2]: *** [scripts/Makefile.host:112: tools/image-host.o] Error 1
+make[1]: *** [Makefile:1858: tools] Error 2
+make: *** [Makefile:177: sub-make] Error 2
0 0 2 /2 sama5d27_som1_ek_mmc1
Completed: 2 total built, 2 newly), duration 0:00:01, rate 2.00Did you have time to look into this again? Or maybe did you sent an updated series I overlooked?
Greets
Alex
Quoted 72 lines
---
include/image.h | 2 +- tools/Kconfig | 1 + tools/fit_image.c | 2 +- tools/image-host.c | 2 ++ tools/mkimage.c | 5 +++-- 5 files changed, 8 insertions(+), 4 deletions(-)include/image.h +0
-0@@ -1388,7 +1388,7 @@ int calculate_hash(const void *data, int data_len,const char *algo, * device
*/
#ifdefined(USE_HOSTCC)include/image.h +1
-1-# if defined(CONFIG_FIT_SIGNATURE ) +# if CONFIG_IS_ENABLED (FIT_SIGNATURE )# define IMAGE_ENABLE_SIGN 1# define FIT_IMAGE_ENABLE_VERIFY 1# include <openssl/evp.h> tools/Kconfig +1
-0@@ -46,6 +46,7 @@ config TOOLS_FIT_RSASSA_PSS Support the rsassa-pss signature scheme in the tools builds config TOOLS_FIT_SIGNATURE + depends on TOOLS_LIBCRYPTO def_bool y help Enable signature verification of FIT uImages in the tools buildstools/fit_image.c +1
-1@@ -61,7 +61,7 @@ static int fit_add_file_data(struct image_tool_params *params, size_t size_inc, ret = fit_set_timestamp(ptr, 0, time); } -if (!ret) +if (CONFIG_IS_ENABLED (FIT_SIGNATURE ) && !ret) ret =fit_pre_load_data (params->keydir, dest_blob, ptr);if (!ret) {tools/image-host.c +2
-0@@ -1119,6 +1119,7 @@ static int fit_config_add_verification_data(const char *keydir, return 0; } +#if CONFIG_IS_ENABLED (FIT_SIGNATURE )/* * 0) open file (open) * 1) read certificate (PEM_read_X509) @@ -1227,6 +1228,7 @@ int fit_pre_load_data(const char *keydir, void *keydest, void *fit) out:return ret; } +#endif int fit_cipher_data(const char *keydir, void *keydest, void *fit, const char *comment, int require_keys,tools/mkimage.c +0
-0
tools/mkimage.c static void usage(const char *msg) · line 115
Quoted 1 line
tools/mkimage.c +0
-0@@ -115,7 +115,7 @@ static void usage(const char *msg) " -B => align size in hex for FIT structure and
header\n"
tools/mkimage.c static void usage(const char *msg) · line 116
Quoted 1 line
tools/mkimage.c +0
-0" -b => append the device tree binary to the
FIT\n"
tools/mkimage.c static void usage(const char *msg)
Quoted 5 lines
tools/mkimage.c +1
-1" -t => update the timestamp in the FIT\n"); -#ifdef CONFIG_FIT_SIGNATURE +#if CONFIG_IS_ENABLED (FIT_SIGNATURE ) fprintf(stderr, "Signing / verified boot options: [-k keydir] [-K dtb] [
-c <comment>]
tools/mkimage.c static void usage(const char *msg) · line 133
Quoted 7 lines
[-p addr] [-r] [-N engine]\n" " -k => set directory containing
private keys\n"tools/mkimage.c +0
-1@@ -130,8 +130,9 @@ static void usage(const char *msg) " -o => algorithm to use for signing\n");#else fprintf(stderr, - "Signing / verified boot not supported
(CONFIG_FIT_SIGNATURE
tools/mkimage.c
Quoted 4 lines
undefined)\n"); + "Signing / verified boot not supported
(CONFIG_TOOLS_FIT_SIGNATUREundefined)\n"); #endiftools/mkimage.c +1
-0+ fprintf(stderr, " %s -V ==> print version information and
exit\n",
tools/mkimage.c
Quoted 2 lines
tools/mkimage.c +0
-0params.cmdname); fprintf(stderr, "Use '-T list' to see a list of available image
types\n");