mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Antony Pavlov <antonynpavlov@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2 2/4] pbl: export pbl_barebox_verify
Date: Sun, 21 Aug 2022 15:29:24 +0200	[thread overview]
Message-ID: <fcc6251e-f404-bd6a-78e3-62be7912c996@pengutronix.de> (raw)
In-Reply-To: <20220820190707.85c705e47fdca88824d2fcbe@gmail.com>

Hi Antony,

On 20.08.22 18:07, Antony Pavlov wrote:
> On Thu, 18 Aug 2022 07:04:45 +0200
> Ahmad Fatoum <a.fatoum@pengutronix.de> wrote:
> 
> Hi!
> 
> It looks like the commit 5dba4f6b3d3 ("pbl: export pbl_barebox_verify") from the next branch
> breaks the socfpga-xload-2_defconfig config build.

Thanks. Just sent a fixup.

> 
> Here are the error messages:
> 
> crypto/digest.c:78:5: warning: no previous prototype for ‘digest_algo_register’ [-Wmissing-prototypes]
>    78 | int digest_algo_register(struct digest_algo *d)
>       |     ^~~~~~~~~~~~~~~~~~~~
> crypto/digest.c:98:6: warning: no previous prototype for ‘digest_algo_unregister’ [-Wmissing-prototypes]
>    98 | void digest_algo_unregister(struct digest_algo *d)
>       |      ^~~~~~~~~~~~~~~~~~~~~~
> crypto/digest.c:150:6: warning: no previous prototype for ‘digest_algo_prints’ [-Wmissing-prototypes]
>   150 | void digest_algo_prints(const char *prefix)
>       |      ^~~~~~~~~~~~~~~~~~
> crypto/digest.c:162:16: error: redefinition of ‘digest_alloc’
>   162 | struct digest *digest_alloc(const char *name)
>       |                ^~~~~~~~~~~~
> In file included from crypto/digest.c:17:
> include/digest.h:99:30: note: previous definition of ‘digest_alloc’ with type ‘struct digest *(const char *)’
>    99 | static inline struct digest *digest_alloc(const char *name)
>       |                              ^~~~~~~~~~~~
> crypto/digest.c:183:16: error: redefinition of ‘digest_alloc_by_algo’
>   183 | struct digest *digest_alloc_by_algo(enum hash_algo hash_algo)
>       |                ^~~~~~~~~~~~~~~~~~~~
> include/digest.h:104:30: note: previous definition of ‘digest_alloc_by_algo’ with type ‘struct digest *(enum hash_algo)’
>   104 | static inline struct digest *digest_alloc_by_algo(enum hash_algo algo)
>       |                              ^~~~~~~~~~~~~~~~~~~~
> crypto/digest.c:204:6: error: redefinition of ‘digest_free’
>   204 | void digest_free(struct digest *d)
>       |      ^~~~~~~~~~~
> include/digest.h:109:20: note: previous definition of ‘digest_free’ with type ‘void(struct digest *)’
>   109 | static inline void digest_free(struct digest *d)
>       |                    ^~~~~~~~~~~
> crypto/digest.c:259:5: warning: no previous prototype for ‘digest_file_window’ [-Wmissing-prototypes]
>   259 | int digest_file_window(struct digest *d, const char *filename,
>       |     ^~~~~~~~~~~~~~~~~~
> crypto/digest.c:291:5: warning: no previous prototype for ‘digest_file’ [-Wmissing-prototypes]
>   291 | int digest_file(struct digest *d, const char *filename,
>       |     ^~~~~~~~~~~
> crypto/digest.c:304:5: warning: no previous prototype for ‘digest_file_by_name’ [-Wmissing-prototypes]
>   304 | int digest_file_by_name(const char *algo, const char *filename,
>       |     ^~~~~~~~~~~~~~~~~~~
> make[1]: *** [/home/antony/barebox/scripts/Makefile.build:137: crypto/digest.pbl.o] Error 1
> make: *** [Makefile:953: crypto] Error 2
> make: *** Waiting for unfinished jobs....
> 
> 
> 
> 
>> There's no downside to always build the digest verification code in PBL
>> and export pbl_barebox_verify to access it. This allows board code to
>> use the function for verifying other firmware blobs and
>> CONFIG_PBL_VERIFY_PIGGY=y will remain to enable the verification at
>> barebox proper extraction time. Code not using it will have the function
>> sections garbage collected by the linker, so no functional change.
>>
>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>> ---
>> v1 -> v2:
>>   - no change
>> ---
>>  crypto/Makefile | 3 +--
>>  include/pbl.h   | 3 +++
>>  pbl/decomp.c    | 6 +++---
>>  3 files changed, 7 insertions(+), 5 deletions(-)
>>
>> diff --git a/crypto/Makefile b/crypto/Makefile
>> index 762d7e543be4..22035d4f69ee 100644
>> --- a/crypto/Makefile
>> +++ b/crypto/Makefile
>> @@ -10,8 +10,7 @@ obj-$(CONFIG_DIGEST_MD5_GENERIC)	+= md5.o
>>  obj-$(CONFIG_DIGEST_SHA1_GENERIC)	+= sha1.o
>>  obj-$(CONFIG_DIGEST_SHA224_GENERIC)	+= sha2.o
>>  obj-$(CONFIG_DIGEST_SHA256_GENERIC)	+= sha2.o
>> -pbl-$(CONFIG_PBL_VERIFY_PIGGY)		+= sha2.o
>> -pbl-$(CONFIG_PBL_VERIFY_PIGGY)		+= digest.o
>> +pbl-y					+= sha2.o digest.o
>>  obj-$(CONFIG_DIGEST_SHA384_GENERIC)	+= sha4.o
>>  obj-$(CONFIG_DIGEST_SHA512_GENERIC)	+= sha4.o
>>  obj-y	+= memneq.o
>> diff --git a/include/pbl.h b/include/pbl.h
>> index 0dc23c72dcf5..7dc4fa309257 100644
>> --- a/include/pbl.h
>> +++ b/include/pbl.h
>> @@ -30,4 +30,7 @@ const void *
>>  fdt_device_get_match_data(const void *fdt, const char *nodepath,
>>  			  const struct fdt_device_id ids[]);
>>  
>> +int pbl_barebox_verify(const void *compressed_start, unsigned int len,
>> +		       const void *hash, unsigned int hash_len);
>> +
>>  #endif /* __PBL_H__ */
>> diff --git a/pbl/decomp.c b/pbl/decomp.c
>> index 1e0ef81ada00..553895bac5e8 100644
>> --- a/pbl/decomp.c
>> +++ b/pbl/decomp.c
>> @@ -54,14 +54,14 @@ static void noinline errorfn(char *error)
>>  extern unsigned char sha_sum[];
>>  extern unsigned char sha_sum_end[];
>>  
>> -static int pbl_barebox_verify(void *compressed_start, unsigned int len, void *hash,
>> -			      unsigned int hash_len)
>> +int pbl_barebox_verify(const void *compressed_start, unsigned int len,
>> +		       const void *hash, unsigned int hash_len)
>>  {
>>  	struct sha256_state sha_state = { 0 };
>>  	struct digest d = { .ctx = &sha_state };
>>  	char computed_hash[SHA256_DIGEST_SIZE];
>>  	int i;
>> -	char *char_hash = hash;
>> +	const char *char_hash = hash;
>>  
>>  	if (hash_len != SHA256_DIGEST_SIZE)
>>  		return -1;
>> -- 
>> 2.30.2
>>
>>
> 
> 


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



  reply	other threads:[~2022-08-21 13:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-18  5:04 [PATCH v2 1/4] kbuild: make sha256sum command available generally Ahmad Fatoum
2022-08-18  5:04 ` [PATCH v2 2/4] pbl: export pbl_barebox_verify Ahmad Fatoum
2022-08-20 16:07   ` Antony Pavlov
2022-08-21 13:29     ` Ahmad Fatoum [this message]
2022-08-18  5:04 ` [PATCH v2 3/4] firmware: add external firmware PBL support Ahmad Fatoum
2022-08-18  5:04 ` [PATCH v2 4/4] pbl: replace __piggydata_end with __image_end Ahmad Fatoum
2022-08-19  7:31 ` [PATCH v2 1/4] kbuild: make sha256sum command available generally Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fcc6251e-f404-bd6a-78e3-62be7912c996@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=antonynpavlov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox