diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2021-03-11 22:58:55 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-03-18 16:00:10 +0000 |
commit | 9fbcb24c53e5322044e5d71456d1fc0256b2e225 (patch) | |
tree | 0d9ea1d26a78a9d5680bbfe1bc027034d8f55d2a /include | |
parent | 3d3f2316b7d2f060d4f8c919a2c82326f8651af3 (diff) | |
download | chrome-ec-9fbcb24c53e5322044e5d71456d1fc0256b2e225.tar.gz |
crc32: Add crc32_hash and crc32_ctx_hash
This patch adds crc32_hash and crc32_ctx_hash, which compute CRC32
of data in arbitrary length using an internal context and an external
context, respectively.
BUG=None
BRANCH=None
TEST=make run-crc
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Change-Id: I08729528fba6b1350bbb8387c048025f72496b2d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2757097
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/crc.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/include/crc.h b/include/crc.h index 511a7cdb9b..b899ca965e 100644 --- a/include/crc.h +++ b/include/crc.h @@ -18,6 +18,14 @@ void crc32_init(void); +/** + * Calculate CRC32 of data in arbitrary length. + * + * @param buf Data for CRC32 to be calculated for. + * @param size Size of <buf> in bytes. + */ +void crc32_hash(const void *buf, int size); + void crc32_hash32(uint32_t val); void crc32_hash16(uint16_t val); @@ -28,6 +36,15 @@ uint32_t crc32_result(void); void crc32_ctx_init(uint32_t *ctx); +/** + * Calculate CRC32 of data in arbitrary length using given context. + * + * @param crc CRC32 context. + * @param buf Data for CRC32 to be calculated for. + * @param size Size of <buf> in bytes. + */ +void crc32_ctx_hash(uint32_t *crc, const void *buf, int size); + void crc32_ctx_hash32(uint32_t *ctx, uint32_t val); void crc32_ctx_hash16(uint32_t *ctx, uint16_t val); |