]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - lib/crc32c.c
2 * Copied from Linux kernel crypto/crc32c.c
3 * Copyright (c) 2004 Cisco Systems, Inc.
4 * Copyright (c) 2008 Herbert Xu <herbert@gondor.apana.org.au>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
10 * SPDX-License-Identifier: GPL-2.0+
16 uint32_t crc32c_cal(uint32_t crc
, const char *data
, int length
,
17 uint32_t *crc32c_table
)
20 crc
= crc32c_table
[(u8
)(crc
^ *data
++)] ^ (crc
>> 8);
25 void crc32c_init(uint32_t *crc32c_table
, uint32_t pol
)
29 const uint32_t poly
= pol
; /* Bit-reflected CRC32C polynomial */
31 for (i
= 0; i
< 256; i
++) {
33 for (j
= 0; j
< 8; j
++)
34 v
= (v
>> 1) ^ ((v
& 1) ? poly
: 0);