X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Futil%2Fcrypto_crc.c;h=ea50b636c0913e4fcf1761abf485db1e70366686;hb=72c8645af31896829b674b575c5375706f362a30;hp=bf8e058ad864b8ba242e19acacbcea4316464d9f;hpb=2df23abd0a1e5a67c3a2ae362fa2f4641f1ebe6d;p=oweals%2Fgnunet.git diff --git a/src/util/crypto_crc.c b/src/util/crypto_crc.c index bf8e058ad..ea50b636c 100644 --- a/src/util/crypto_crc.c +++ b/src/util/crypto_crc.c @@ -27,7 +27,6 @@ * @brief implementation of CRC16 and CRC32 * @author Christian Grothoff */ - #include "platform.h" #include "gnunet_common.h" #include "gnunet_crypto_lib.h" @@ -51,7 +50,7 @@ static uLong crc_table[256]; /* * This routine writes each crc_table entry exactly once, - * with the ccorrect final value. Thus, it is safe to call + * with the correct final value. Thus, it is safe to call * even on a table that someone else is using concurrently. */ static void @@ -125,14 +124,15 @@ GNUNET_CRYPTO_crc32_n (const void *buf, size_t len) uint32_t GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len) { - uint16_t *hdr = buf; + const uint16_t *hdr = buf; for (; len >= 2; len -= 2) sum += *(hdr++); if (len == 1) - sum += *((unsigned char *) hdr); + sum += (*hdr) & ntohs(0xFF00); return sum; } + /** * Convert results from GNUNET_CRYPTO_crc16_step to final crc16. * @@ -159,7 +159,7 @@ GNUNET_CRYPTO_crc16_finish (uint32_t sum) uint16_t GNUNET_CRYPTO_crc16_n (const void *buf, size_t len) { - uint16_t *hdr = buf; + const uint16_t *hdr = buf; uint32_t sum = GNUNET_CRYPTO_crc16_step (0, hdr, len); return GNUNET_CRYPTO_crc16_finish (sum);