[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240611031408.GB2557@sol.localdomain>
Date: Mon, 10 Jun 2024 20:14:08 -0700
From: Eric Biggers <ebiggers@...nel.org>
To: kamlesh@...com
Cc: herbert@...dor.apana.org.au, kristo@...nel.org, will@...nel.org,
akpm@...ux-foundation.org, davem@...emloft.net,
mcoquelin.stm32@...il.com, alexandre.torgue@...s.st.com,
robh@...nel.org, krzysztof.kozlowski+dt@...aro.org,
conor+dt@...nel.org, vigneshr@...com, catalin.marinas@....com,
linux-kernel@...r.kernel.org, linux-crypto@...r.kernel.org,
linux-stm32@...md-mailman.stormreply.com,
linux-arm-kernel@...ts.infradead.org, devicetree@...r.kernel.org
Subject: Re: [PATCH v3 1/6] lib: add ISO 3309 model crc64
On Thu, May 30, 2024 at 05:54:23PM +0530, kamlesh@...com wrote:
> diff --git a/lib/crc64.c b/lib/crc64.c
> index 61ae8dfb6a1c..40369dd26812 100644
> --- a/lib/crc64.c
> +++ b/lib/crc64.c
> @@ -22,6 +22,11 @@
> * x^24 + x^23 + x^22 + x^21 + x^19 + x^17 + x^13 + x^12 + x^10 + x^9 +
> * x^7 + x^4 + x + 1
> *
> + * crc64iso3309table[256] table is from the ISO-3309:1991 specification
> + * polynomial defined as,
> + *
> + * x^64 + x^4 + x^3 + x + 1
> + *
> * crc64rocksoft[256] table is from the Rocksoft specification polynomial
> * defined as,
> *
> @@ -63,6 +68,28 @@ u64 __pure crc64_be(u64 crc, const void *p, size_t len)
> }
> EXPORT_SYMBOL_GPL(crc64_be);
>
> +/**
> + * crc64_iso3309_generic - Calculate bitwise ISO3309 CRC64
> + * @crc: seed value for computation. 0 for a new CRC calculation, or the
> + * previous crc64 value if computing incrementally.
> + * @p: pointer to buffer over which CRC64 is run
> + * @len: length of buffer @p
> + */
> +u64 __pure crc64_iso3309_generic(u64 crc, const void *p, size_t len)
> +{
> + size_t i, t;
> +
> + const unsigned char *_p = p;
> +
> + for (i = 0; i < len; i++) {
> + t = ((crc >> 56) ^ (*_p++)) & 0xFF;
> + crc = crc64iso3309table[t] ^ (crc << 8);
> + }
> +
> + return crc;
> +}
> +EXPORT_SYMBOL_GPL(crc64_iso3309_generic);
Putting this in lib/ seems premature, given that this is only used by
crypto/crc64_iso3309_generic.c.
- Eric
Powered by blists - more mailing lists