diff options
author | Simon Glass <sjg@chromium.org> | 2013-02-24 20:30:22 +0000 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2013-02-28 19:09:23 -0800 |
commit | d20a40de9db07de1f1f06a79a4da1cdda5379b75 (patch) | |
tree | 6d1952a17439f0ffa0fb09882f7a3df2a0e917e1 /lib | |
parent | d5b76673a5dfe0b5250baea3c36cdfa7a9fd5230 (diff) |
Roll crc32 into hash infrastructure
Add the CRC32 algorithm to the list of available hashes, and make
the crc32 command use hash_command(). Add a new crc32_wd_buf() to
make this possible, which puts its result in a buffer rather than
returning it as a 32-bit value.
Note: For some boards the hash command is not enabled, neither
are sha1, sha256 or the verify option. In this case the full
hash implementation adds about 500 bytes of overhead. So as a
special case, we use #ifdef to select very simple bahaviour in
that case. The justification for this is that it is currently
a very common case (virtually all boards enable crc32 but only
some enable more advanced features).
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/crc32.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/crc32.c b/lib/crc32.c index 27335a3ed90..76205da4f30 100644 --- a/lib/crc32.c +++ b/lib/crc32.c @@ -249,3 +249,12 @@ uint32_t ZEXPORT crc32_wd (uint32_t crc, return crc; } + +void crc32_wd_buf(const unsigned char *input, unsigned int ilen, + unsigned char *output, unsigned int chunk_sz) +{ + uint32_t crc; + + crc = crc32_wd(0, input, ilen, chunk_sz); + memcpy(output, &crc, sizeof(crc)); +} |