From: Christian Grothoff Date: Thu, 5 Jan 2012 20:18:50 +0000 (+0000) Subject: fix crc16 prototypes X-Git-Tag: initial-import-from-subversion-38251~15409 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2df23abd0a1e5a67c3a2ae362fa2f4641f1ebe6d;p=oweals%2Fgnunet.git fix crc16 prototypes --- diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index 0be9611ba..75aabe75f 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h @@ -238,12 +238,12 @@ GNUNET_CRYPTO_seed_weak_random (int32_t seed); * Perform an incremental step in a CRC16 (for TCP/IP) calculation. * * @param sum current sum, initially 0 - * @param hdr buffer to calculate CRC over (must be 16-bit aligned) + * @param buf buffer to calculate CRC over (must be 16-bit aligned) * @param len number of bytes in hdr, must be multiple of 2 * @return updated crc sum (must be subjected to GNUNET_CRYPTO_crc16_finish to get actual crc16) */ uint32_t -GNUNET_CRYPTO_crc16_step (uint32_t sum, uint16_t * hdr, size_t len); +GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len); /** @@ -259,12 +259,12 @@ GNUNET_CRYPTO_crc16_finish (uint32_t sum); /** * Calculate the checksum of a buffer in one step. * - * @param hdr buffer to calculate CRC over (must be 16-bit aligned) + * @param buf buffer to calculate CRC over (must be 16-bit aligned) * @param len number of bytes in hdr, must be multiple of 2 * @return crc16 value */ uint16_t -GNUNET_CRYPTO_crc16_n (uint16_t *hdr, size_t len); +GNUNET_CRYPTO_crc16_n (const void *buf, size_t len); /** diff --git a/src/util/crypto_crc.c b/src/util/crypto_crc.c index c6cd83a74..bf8e058ad 100644 --- a/src/util/crypto_crc.c +++ b/src/util/crypto_crc.c @@ -118,13 +118,14 @@ GNUNET_CRYPTO_crc32_n (const void *buf, size_t len) * Perform an incremental step in a CRC16 (for TCP/IP) calculation. * * @param sum current sum, initially 0 - * @param hdr buffer to calculate CRC over (must be 16-bit aligned) + * @param buf buffer to calculate CRC over (must be 16-bit aligned) * @param len number of bytes in hdr, must be multiple of 2 * @return updated crc sum (must be subjected to GNUNET_CRYPTO_crc16_finish to get actual crc16) */ uint32_t -GNUNET_CRYPTO_crc16_step (uint32_t sum, uint16_t * hdr, size_t len) +GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len) { + uint16_t *hdr = buf; for (; len >= 2; len -= 2) sum += *(hdr++); if (len == 1) @@ -151,13 +152,14 @@ GNUNET_CRYPTO_crc16_finish (uint32_t sum) /** * Calculate the checksum of a buffer in one step. * - * @param hdr buffer to calculate CRC over (must be 16-bit aligned) + * @param buf buffer to calculate CRC over (must be 16-bit aligned) * @param len number of bytes in hdr, must be multiple of 2 * @return crc16 value */ uint16_t -GNUNET_CRYPTO_crc16_n (uint16_t *hdr, size_t len) +GNUNET_CRYPTO_crc16_n (const void *buf, size_t len) { + uint16_t *hdr = buf; uint32_t sum = GNUNET_CRYPTO_crc16_step (0, hdr, len); return GNUNET_CRYPTO_crc16_finish (sum);