aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_crypto_lib.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-02 10:22:17 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-02 10:22:17 +0000
commitd583ad46d4babd962f362deac20fa5aa6cdce7c7 (patch)
tree8fde3e3464367443c8abef646c8943cd1376da85 /src/include/gnunet_crypto_lib.h
parent05c8fe96c4c909b56e3f9de77f887fc0941cb404 (diff)
downloadgnunet-d583ad46d4babd962f362deac20fa5aa6cdce7c7.tar.gz
gnunet-d583ad46d4babd962f362deac20fa5aa6cdce7c7.zip
adding crc16 to gnunet_crypto_lib.h
Diffstat (limited to 'src/include/gnunet_crypto_lib.h')
-rw-r--r--src/include/gnunet_crypto_lib.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index 76806d432..0be9611ba 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -233,6 +233,40 @@ struct GNUNET_CRYPTO_AuthKey
233void 233void
234GNUNET_CRYPTO_seed_weak_random (int32_t seed); 234GNUNET_CRYPTO_seed_weak_random (int32_t seed);
235 235
236
237/**
238 * Perform an incremental step in a CRC16 (for TCP/IP) calculation.
239 *
240 * @param sum current sum, initially 0
241 * @param hdr buffer to calculate CRC over (must be 16-bit aligned)
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)
244 */
245uint32_t
246GNUNET_CRYPTO_crc16_step (uint32_t sum, uint16_t * hdr, size_t len);
247
248
249/**
250 * Convert results from GNUNET_CRYPTO_crc16_step to final crc16.
251 *
252 * @param sum cummulative sum
253 * @return crc16 value
254 */
255uint16_t
256GNUNET_CRYPTO_crc16_finish (uint32_t sum);
257
258
259/**
260 * Calculate the checksum of a buffer in one step.
261 *
262 * @param hdr buffer to calculate CRC over (must be 16-bit aligned)
263 * @param len number of bytes in hdr, must be multiple of 2
264 * @return crc16 value
265 */
266uint16_t
267GNUNET_CRYPTO_crc16_n (uint16_t *hdr, size_t len);
268
269
236/** 270/**
237 * Compute the CRC32 checksum for the first len 271 * Compute the CRC32 checksum for the first len
238 * bytes of the buffer. 272 * bytes of the buffer.