diff options
-rw-r--r-- | src/include/gnunet_crypto_lib.h | 8 | ||||
-rw-r--r-- | src/util/crypto_crc.c | 10 |
2 files changed, 10 insertions, 8 deletions
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); | |||
238 | * Perform an incremental step in a CRC16 (for TCP/IP) calculation. | 238 | * Perform an incremental step in a CRC16 (for TCP/IP) calculation. |
239 | * | 239 | * |
240 | * @param sum current sum, initially 0 | 240 | * @param sum current sum, initially 0 |
241 | * @param hdr buffer to calculate CRC over (must be 16-bit aligned) | 241 | * @param buf buffer to calculate CRC over (must be 16-bit aligned) |
242 | * @param len number of bytes in hdr, must be multiple of 2 | 242 | * @param len number of bytes in hdr, must be multiple of 2 |
243 | * @return updated crc sum (must be subjected to GNUNET_CRYPTO_crc16_finish to get actual crc16) | 243 | * @return updated crc sum (must be subjected to GNUNET_CRYPTO_crc16_finish to get actual crc16) |
244 | */ | 244 | */ |
245 | uint32_t | 245 | uint32_t |
246 | GNUNET_CRYPTO_crc16_step (uint32_t sum, uint16_t * hdr, size_t len); | 246 | GNUNET_CRYPTO_crc16_step (uint32_t sum, const void *buf, size_t len); |
247 | 247 | ||
248 | 248 | ||
249 | /** | 249 | /** |
@@ -259,12 +259,12 @@ GNUNET_CRYPTO_crc16_finish (uint32_t sum); | |||
259 | /** | 259 | /** |
260 | * Calculate the checksum of a buffer in one step. | 260 | * Calculate the checksum of a buffer in one step. |
261 | * | 261 | * |
262 | * @param hdr buffer to calculate CRC over (must be 16-bit aligned) | 262 | * @param buf buffer to calculate CRC over (must be 16-bit aligned) |
263 | * @param len number of bytes in hdr, must be multiple of 2 | 263 | * @param len number of bytes in hdr, must be multiple of 2 |
264 | * @return crc16 value | 264 | * @return crc16 value |
265 | */ | 265 | */ |
266 | uint16_t | 266 | uint16_t |
267 | GNUNET_CRYPTO_crc16_n (uint16_t *hdr, size_t len); | 267 | GNUNET_CRYPTO_crc16_n (const void *buf, size_t len); |
268 | 268 | ||
269 | 269 | ||
270 | /** | 270 | /** |
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 | */ |
125 | uint32_t | 125 | uint32_t |
126 | GNUNET_CRYPTO_crc16_step (uint32_t sum, uint16_t * hdr, size_t len) | 126 | GNUNET_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 | */ |
158 | uint16_t | 159 | uint16_t |
159 | GNUNET_CRYPTO_crc16_n (uint16_t *hdr, size_t len) | 160 | GNUNET_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); |