aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_crypto_hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/test_crypto_hash.c')
-rw-r--r--src/util/test_crypto_hash.c70
1 files changed, 0 insertions, 70 deletions
diff --git a/src/util/test_crypto_hash.c b/src/util/test_crypto_hash.c
index 1fddcfba8..8241676da 100644
--- a/src/util/test_crypto_hash.c
+++ b/src/util/test_crypto_hash.c
@@ -134,76 +134,6 @@ test_arithmetic (void)
134 GNUNET_CRYPTO_hash_count_leading_zeros (&h1)); 134 GNUNET_CRYPTO_hash_count_leading_zeros (&h1));
135 GNUNET_assert (512 - 42 - 1 == 135 GNUNET_assert (512 - 42 - 1 ==
136 GNUNET_CRYPTO_hash_count_tailing_zeros (&h1)); 136 GNUNET_CRYPTO_hash_count_tailing_zeros (&h1));
137 memset (&h1,
138 0,
139 sizeof (h1));
140 memset (&h2,
141 0,
142 sizeof (h2));
143 h1.bits[3] = htonl (0x00800011); /* 3*32 + 8 Bits identical */
144 h2.bits[3] = htonl (0x00000101); /* residual delta: 0x000220.. (+1 bit)*/
145 /* Note: XOR: 0x00800110 */
146 h1.bits[4] = htonl (0x14144141);
147 h2.bits[4] = htonl (0x28288282); /* residual delta: 0x3C3CC3.. */
148 /* Note: XOR: 0x3C3CC3C3 */
149 /* Note: XOR<<1: 0x78798786 */
150 GNUNET_assert (104 ==
151 GNUNET_CRYPTO_hash_count_leading_zeros (&h1));
152 GNUNET_CRYPTO_hash_xor (&h1,
153 &h2,
154 &s);
155 GNUNET_assert (104 ==
156 GNUNET_CRYPTO_hash_count_leading_zeros (&s));
157 GNUNET_assert (0x0002207879878600LLU ==
158 GNUNET_CRYPTO_hash_bucket_distance (&s,
159 104));
160
161 memset (&h1,
162 0,
163 sizeof (h1));
164 memset (&h2,
165 0,
166 sizeof (h2));
167 h1.bits[4] = htonl (0x00000001); /* 5*32 - 1 Bits identical */
168 h2.bits[4] = htonl (0x00000000);
169 /* Note: XOR: 0x00000001 */
170 h1.bits[5] = htonl (0x14144141);
171 h2.bits[5] = htonl (0x28288282);
172 /* Note: XOR: 0x3C3CC3C3 */
173 GNUNET_assert (159 ==
174 GNUNET_CRYPTO_hash_count_leading_zeros (&h1));
175 GNUNET_CRYPTO_hash_xor (&h1,
176 &h2,
177 &s);
178 GNUNET_assert (159 ==
179 GNUNET_CRYPTO_hash_count_leading_zeros (&s));
180 GNUNET_assert (0x3C3CC3C300000000 ==
181 GNUNET_CRYPTO_hash_bucket_distance (&s,
182 159));
183
184 memset (&h1,
185 0,
186 sizeof (h1));
187 memset (&h2,
188 0,
189 sizeof (h2));
190 h1.bits[14] = htonl (0x00000001); /* 15*32 - 1 Bits identical */
191 h2.bits[14] = htonl (0x00000000);
192 /* Note: XOR: 0x00000001 */
193 h1.bits[15] = htonl (0x14144141);
194 h2.bits[15] = htonl (0x28288282);
195 /* Note: XOR: 0x3C3CC3C3 */
196 GNUNET_assert (479 ==
197 GNUNET_CRYPTO_hash_count_leading_zeros (&h1));
198 GNUNET_CRYPTO_hash_xor (&h1,
199 &h2,
200 &s);
201 GNUNET_assert (479 ==
202 GNUNET_CRYPTO_hash_count_leading_zeros (&s));
203 GNUNET_assert (0x3C3CC3C300000000 ==
204 GNUNET_CRYPTO_hash_bucket_distance (&s,
205 479));
206
207 return 0; 137 return 0;
208} 138}
209 139