aboutsummaryrefslogtreecommitdiff
path: root/src/util/crypto_crc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/crypto_crc.c')
-rw-r--r--src/util/crypto_crc.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/util/crypto_crc.c b/src/util/crypto_crc.c
index a2ffdb543..9328f2b84 100644
--- a/src/util/crypto_crc.c
+++ b/src/util/crypto_crc.c
@@ -27,8 +27,9 @@
27 * @brief implementation of CRC16 and CRC32 27 * @brief implementation of CRC16 and CRC32
28 * @author Christian Grothoff 28 * @author Christian Grothoff
29 */ 29 */
30
30#include "platform.h" 31#include "platform.h"
31#include "gnunet_crypto_lib.h" 32#include "gnunet_util_lib.h"
32 33
33#define LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-crc", __VA_ARGS__) 34#define LOG(kind, ...) GNUNET_log_from (kind, "util-crypto-crc", __VA_ARGS__)
34 35
@@ -56,18 +57,17 @@ static void
56crc_init () 57crc_init ()
57{ 58{
58 static int once; 59 static int once;
59 unsigned int i, j;
60 GNUNET_uLong h = 1; 60 GNUNET_uLong h = 1;
61 61
62 if (once) 62 if (once)
63 return; 63 return;
64 once = 1; 64 once = 1;
65 crc_table[0] = 0; 65 crc_table[0] = 0;
66 for (i = 128; i; i >>= 1) 66 for (unsigned int i = 128; i; i >>= 1)
67 { 67 {
68 h = (h >> 1) ^ ((h & 1) ? POLYNOMIAL : 0); 68 h = (h >> 1) ^ ((h & 1) ? POLYNOMIAL : 0);
69 /* h is now crc_table[i] */ 69 /* h is now crc_table[i] */
70 for (j = 0; j < 256; j += 2 * i) 70 for (unsigned int j = 0; j < 256; j += 2 * i)
71 crc_table[i + j] = crc_table[j] ^ h; 71 crc_table[i + j] = crc_table[j] ^ h;
72 } 72 }
73} 73}
@@ -84,7 +84,7 @@ crc_init ()
84 * property of detecting all burst errors of length 32 bits or less. 84 * property of detecting all burst errors of length 32 bits or less.
85 */ 85 */
86static GNUNET_uLong 86static GNUNET_uLong
87crc32 (GNUNET_uLong crc, const char *buf, size_t len) 87gn_crc32 (GNUNET_uLong crc, const char *buf, size_t len)
88{ 88{
89 crc_init (); 89 crc_init ();
90 GNUNET_assert (crc_table[255] != 0); 90 GNUNET_assert (crc_table[255] != 0);
@@ -100,8 +100,8 @@ GNUNET_CRYPTO_crc32_n (const void *buf, size_t len)
100{ 100{
101 GNUNET_uLong crc; 101 GNUNET_uLong crc;
102 102
103 crc = crc32 (0L, Z_NULL, 0); 103 crc = gn_crc32 (0L, Z_NULL, 0);
104 crc = crc32 (crc, (char *) buf, len); 104 crc = gn_crc32 (crc, (char *) buf, len);
105 return crc; 105 return crc;
106} 106}
107 107