From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] crypto: crc32: add big endian CRC implementation
Date: Mon, 13 Dec 2021 23:17:45 +0100 [thread overview]
Message-ID: <20211213221745.GH6003@pengutronix.de> (raw)
In-Reply-To: <20211209105832.3518384-1-a.fatoum@pengutronix.de>
On Thu, Dec 09, 2021 at 11:58:32AM +0100, Ahmad Fatoum wrote:
> This implementation is a straight copy of the tableless
> implementation inside Linux' lib/crc32.c
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> crypto/crc32.c | 12 ++++++++++++
> include/crc.h | 1 +
> 2 files changed, 13 insertions(+)
Applied, thanks
Sascha
>
> diff --git a/crypto/crc32.c b/crypto/crc32.c
> index 232c023adb88..998cbc9de297 100644
> --- a/crypto/crc32.c
> +++ b/crypto/crc32.c
> @@ -187,6 +187,18 @@ STATIC uint32_t crc32_no_comp(uint32_t crc, const void *_buf, unsigned int len)
> return crc;
> }
>
> +STATIC uint32_t crc32_be(uint32_t crc, const void *_buf, unsigned int len)
> +{
> + const unsigned char *buf = _buf;
> + int i;
> + while (len--) {
> + crc ^= *buf++ << 24;
> + for (i = 0; i < 8; i++)
> + crc = (crc << 1) ^ ((crc & 0x80000000) ? 0x04c11db7 : 0);
> + }
> + return crc;
> +}
> +
> STATIC int file_crc(char *filename, ulong start, ulong size, ulong *crc,
> ulong *total)
> {
> diff --git a/include/crc.h b/include/crc.h
> index eb972705c21a..a5204aaabb9c 100644
> --- a/include/crc.h
> +++ b/include/crc.h
> @@ -36,6 +36,7 @@ static inline u16 crc_itu_t_byte(u16 crc, const u8 data)
> #endif
>
> uint32_t crc32(uint32_t, const void *, unsigned int);
> +uint32_t crc32_be(uint32_t, const void *, unsigned int);
> uint32_t crc32_no_comp(uint32_t, const void *, unsigned int);
> int file_crc(char *filename, unsigned long start, unsigned long size,
> unsigned long *crc, unsigned long *total);
> --
> 2.30.2
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
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 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2021-12-13 22:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-09 10:58 Ahmad Fatoum
2021-12-13 22:17 ` Sascha Hauer [this message]
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=20211213221745.GH6003@pengutronix.de \
--to=sha@pengutronix.de \
--cc=a.fatoum@pengutronix.de \
--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