]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
hash: Plumb crc8 into the hash functions
authorSimon Glass <sjg@chromium.org>
Sat, 7 Dec 2024 17:24:12 +0000 (10:24 -0700)
committerTom Rini <trini@konsulko.com>
Thu, 12 Dec 2024 22:35:24 +0000 (16:35 -0600)
Add an entry for crc8, with watchdog handling.

Signed-off-by: Simon Glass <sjg@chromium.org>
common/hash.c
include/u-boot/crc.h
lib/crc8.c

index db6925d6782e99094d75bcc26db2ff60e9a4b2be..5d389420effb7341f5544b85d9af495d5be7b5ee 100644 (file)
@@ -304,6 +304,14 @@ static struct hash_algo hash_algo[] = {
                .hash_update    = hash_update_crc16_ccitt,
                .hash_finish    = hash_finish_crc16_ccitt,
        },
+#if CONFIG_IS_ENABLED(CRC8)
+       {
+               .name           = "crc8",
+               .digest_size    = 1,
+               .chunk_size     = CHUNKSZ_CRC32,
+               .hash_func_ws   = crc8_wd_buf,
+       },
+#endif
 #if CONFIG_IS_ENABLED(CRC32)
        {
                .name           = "crc32",
index 5174bd7ac413e5567dfff71ec698d7c5bf6c3e7d..b2badaf6a9780321f3d869f303d5816b87062492 100644 (file)
@@ -25,6 +25,9 @@
  */
 unsigned int crc8(unsigned int crc_start, const unsigned char *vptr, int len);
 
+void crc8_wd_buf(const unsigned char *input, unsigned int len,
+                unsigned char output[1], unsigned int chunk_sz);
+
 /* lib/crc16.c - 16 bit CRC with polynomial x^16 + x^15 + x^2 + 1 */
 uint16_t crc16(uint16_t crc, const unsigned char *buffer, size_t len);
 
index 20d46d161472da092582c01c065e99c3cfae188f..811e19917b438cffa9d3469f0b0541f586d3de35 100644 (file)
@@ -32,3 +32,9 @@ unsigned int crc8(unsigned int crc, const unsigned char *vptr, int len)
 
        return crc;
 }
+
+void crc8_wd_buf(const unsigned char *input, unsigned int len,
+                unsigned char output[1], unsigned int chunk_sz)
+{
+       *output = crc8(0, input, len);
+}