diff options
Diffstat (limited to 'src/include/gnunet_crypto_lib.h')
-rw-r--r-- | src/include/gnunet_crypto_lib.h | 34 |
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 | |||
233 | void | 233 | void |
234 | GNUNET_CRYPTO_seed_weak_random (int32_t seed); | 234 | GNUNET_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 | */ | ||
245 | uint32_t | ||
246 | GNUNET_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 | */ | ||
255 | uint16_t | ||
256 | GNUNET_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 | */ | ||
266 | uint16_t | ||
267 | GNUNET_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. |