aboutsummaryrefslogtreecommitdiff
path: root/src/util/crypto_crc.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-05 20:18:50 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-05 20:18:50 +0000
commit2df23abd0a1e5a67c3a2ae362fa2f4641f1ebe6d (patch)
treeb0e721667ef6d4aa0c53c39d5ce01be26209ee9f /src/util/crypto_crc.c
parentfca364b9a6259f8e802ca118d069eecacf625064 (diff)
downloadgnunet-2df23abd0a1e5a67c3a2ae362fa2f4641f1ebe6d.tar.gz
gnunet-2df23abd0a1e5a67c3a2ae362fa2f4641f1ebe6d.zip
fix crc16 prototypes
Diffstat (limited to 'src/util/crypto_crc.c')
-rw-r--r--src/util/crypto_crc.c10
1 files changed, 6 insertions, 4 deletions
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)
118 * Perform an incremental step in a CRC16 (for TCP/IP) calculation. 118 * Perform an incremental step in a CRC16 (for TCP/IP) calculation.
119 * 119 *
120 * @param sum current sum, initially 0 120 * @param sum current sum, initially 0
121 * @param hdr buffer to calculate CRC over (must be 16-bit aligned) 121 * @param buf buffer to calculate CRC over (must be 16-bit aligned)
122 * @param len number of bytes in hdr, must be multiple of 2 122 * @param len number of bytes in hdr, must be multiple of 2
123 * @return updated crc sum (must be subjected to GNUNET_CRYPTO_crc16_finish to get actual crc16) 123 * @return updated crc sum (must be subjected to GNUNET_CRYPTO_crc16_finish to get actual crc16)
124 */ 124 */
125uint32_t 125uint32_t
126GNUNET_CRYPTO_crc16_step (uint32_t sum, uint16_t * hdr, size_t len) 126GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len)
127{ 127{
128 uint16_t *hdr = buf;
128 for (; len >= 2; len -= 2) 129 for (; len >= 2; len -= 2)
129 sum += *(hdr++); 130 sum += *(hdr++);
130 if (len == 1) 131 if (len == 1)
@@ -151,13 +152,14 @@ GNUNET_CRYPTO_crc16_finish (uint32_t sum)
151/** 152/**
152 * Calculate the checksum of a buffer in one step. 153 * Calculate the checksum of a buffer in one step.
153 * 154 *
154 * @param hdr buffer to calculate CRC over (must be 16-bit aligned) 155 * @param buf buffer to calculate CRC over (must be 16-bit aligned)
155 * @param len number of bytes in hdr, must be multiple of 2 156 * @param len number of bytes in hdr, must be multiple of 2
156 * @return crc16 value 157 * @return crc16 value
157 */ 158 */
158uint16_t 159uint16_t
159GNUNET_CRYPTO_crc16_n (uint16_t *hdr, size_t len) 160GNUNET_CRYPTO_crc16_n (const void *buf, size_t len)
160{ 161{
162 uint16_t *hdr = buf;
161 uint32_t sum = GNUNET_CRYPTO_crc16_step (0, hdr, len); 163 uint32_t sum = GNUNET_CRYPTO_crc16_step (0, hdr, len);
162 164
163 return GNUNET_CRYPTO_crc16_finish (sum); 165 return GNUNET_CRYPTO_crc16_finish (sum);