diff options
Diffstat (limited to 'src/lib/util/test_crypto_cs.c')
-rw-r--r-- | src/lib/util/test_crypto_cs.c | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/src/lib/util/test_crypto_cs.c b/src/lib/util/test_crypto_cs.c index 5b3aac778..ee68db72f 100644 --- a/src/lib/util/test_crypto_cs.c +++ b/src/lib/util/test_crypto_cs.c | |||
@@ -216,7 +216,7 @@ test_calc_blindedc (const struct GNUNET_CRYPTO_CsBlindingSecret bs[2], | |||
216 | const void *msg, | 216 | const void *msg, |
217 | size_t msg_len, | 217 | size_t msg_len, |
218 | struct GNUNET_CRYPTO_CsC blinded_cs[2], | 218 | struct GNUNET_CRYPTO_CsC blinded_cs[2], |
219 | struct GNUNET_CRYPTO_CsRPublic blinded_r_pub[2]) | 219 | struct GNUNET_CRYPTO_CSPublicRPairP *blinded_r_pub) |
220 | { | 220 | { |
221 | /* TEST 1 | 221 | /* TEST 1 |
222 | * Check that the blinded c's and blinded r's | 222 | * Check that the blinded c's and blinded r's |
@@ -227,10 +227,8 @@ test_calc_blindedc (const struct GNUNET_CRYPTO_CsBlindingSecret bs[2], | |||
227 | &blinded_cs[0], | 227 | &blinded_cs[0], |
228 | sizeof(struct GNUNET_CRYPTO_CsC) * 2); | 228 | sizeof(struct GNUNET_CRYPTO_CsC) * 2); |
229 | 229 | ||
230 | struct GNUNET_CRYPTO_CsRPublic other_blinded_r_pub[2]; | 230 | struct GNUNET_CRYPTO_CSPublicRPairP other_blinded_pub; |
231 | memcpy (&other_blinded_r_pub[0], | 231 | other_blinded_pub = *blinded_r_pub; |
232 | &blinded_r_pub[0], | ||
233 | sizeof(struct GNUNET_CRYPTO_CsRPublic) * 2); | ||
234 | 232 | ||
235 | GNUNET_CRYPTO_cs_calc_blinded_c (bs, | 233 | GNUNET_CRYPTO_cs_calc_blinded_c (bs, |
236 | r_pub, | 234 | r_pub, |
@@ -243,9 +241,9 @@ test_calc_blindedc (const struct GNUNET_CRYPTO_CsBlindingSecret bs[2], | |||
243 | GNUNET_assert (0 != memcmp (&other_blinded_c[0], | 241 | GNUNET_assert (0 != memcmp (&other_blinded_c[0], |
244 | &blinded_cs[0], | 242 | &blinded_cs[0], |
245 | sizeof(struct GNUNET_CRYPTO_CsC) * 2)); | 243 | sizeof(struct GNUNET_CRYPTO_CsC) * 2)); |
246 | GNUNET_assert (0 != memcmp (&other_blinded_r_pub[0], | 244 | GNUNET_assert (0 != |
247 | &blinded_r_pub[0], | 245 | GNUNET_memcmp (&other_blinded_pub, |
248 | sizeof(struct GNUNET_CRYPTO_CsRPublic) * 2)); | 246 | blinded_r_pub)); |
249 | 247 | ||
250 | /* TEST 2 | 248 | /* TEST 2 |
251 | * Check if R' - aG -bX = R for b = 0 | 249 | * Check if R' - aG -bX = R for b = 0 |
@@ -270,7 +268,7 @@ test_calc_blindedc (const struct GNUNET_CRYPTO_CsBlindingSecret bs[2], | |||
270 | GNUNET_assert (0 == | 268 | GNUNET_assert (0 == |
271 | crypto_core_ed25519_sub ( | 269 | crypto_core_ed25519_sub ( |
272 | r_min_aG.y, | 270 | r_min_aG.y, |
273 | blinded_r_pub[b].point.y, | 271 | blinded_r_pub->r_pub[b].point.y, |
274 | aG.y)); | 272 | aG.y)); |
275 | GNUNET_assert (0 == crypto_core_ed25519_sub ( | 273 | GNUNET_assert (0 == crypto_core_ed25519_sub ( |
276 | res.point.y, | 274 | res.point.y, |
@@ -289,10 +287,10 @@ test_calc_blindedc (const struct GNUNET_CRYPTO_CsBlindingSecret bs[2], | |||
289 | */ | 287 | */ |
290 | GNUNET_assert (1 == | 288 | GNUNET_assert (1 == |
291 | crypto_core_ed25519_is_valid_point ( | 289 | crypto_core_ed25519_is_valid_point ( |
292 | blinded_r_pub[0].point.y)); | 290 | blinded_r_pub->r_pub[0].point.y)); |
293 | GNUNET_assert (1 == | 291 | GNUNET_assert (1 == |
294 | crypto_core_ed25519_is_valid_point ( | 292 | crypto_core_ed25519_is_valid_point ( |
295 | blinded_r_pub[1].point.y)); | 293 | blinded_r_pub->r_pub[1].point.y)); |
296 | 294 | ||
297 | /* TEST 4 | 295 | /* TEST 4 |
298 | * Check if function gives the same result for the same input. | 296 | * Check if function gives the same result for the same input. |
@@ -300,9 +298,7 @@ test_calc_blindedc (const struct GNUNET_CRYPTO_CsBlindingSecret bs[2], | |||
300 | memcpy (&other_blinded_c[0], | 298 | memcpy (&other_blinded_c[0], |
301 | &blinded_cs[0], | 299 | &blinded_cs[0], |
302 | sizeof(struct GNUNET_CRYPTO_CsC) * 2); | 300 | sizeof(struct GNUNET_CRYPTO_CsC) * 2); |
303 | memcpy (&other_blinded_r_pub[0], | 301 | other_blinded_pub = *blinded_r_pub; |
304 | &blinded_r_pub[0], | ||
305 | sizeof(struct GNUNET_CRYPTO_CsRPublic) * 2); | ||
306 | 302 | ||
307 | for (unsigned int i = 0; i<ITER; i++) | 303 | for (unsigned int i = 0; i<ITER; i++) |
308 | { | 304 | { |
@@ -313,12 +309,13 @@ test_calc_blindedc (const struct GNUNET_CRYPTO_CsBlindingSecret bs[2], | |||
313 | msg_len, | 309 | msg_len, |
314 | blinded_cs, | 310 | blinded_cs, |
315 | blinded_r_pub); | 311 | blinded_r_pub); |
316 | GNUNET_assert (0 == memcmp (&other_blinded_c[0], | 312 | GNUNET_assert (0 == |
317 | &blinded_cs[0], | 313 | memcmp (&other_blinded_c[0], |
318 | sizeof(struct GNUNET_CRYPTO_CsC) * 2)); | 314 | &blinded_cs[0], |
319 | GNUNET_assert (0 == memcmp (&other_blinded_r_pub[0], | 315 | sizeof(struct GNUNET_CRYPTO_CsC) * 2)); |
320 | &blinded_r_pub[0], | 316 | GNUNET_assert (0 == |
321 | sizeof(struct GNUNET_CRYPTO_CsRPublic) * 2)); | 317 | GNUNET_memcmp (&other_blinded_pub, |
318 | blinded_r_pub)); | ||
322 | } | 319 | } |
323 | } | 320 | } |
324 | 321 | ||
@@ -563,12 +560,12 @@ main (int argc, | |||
563 | // calculate blinded c's | 560 | // calculate blinded c's |
564 | struct GNUNET_CRYPTO_CsBlindedMessage bm; | 561 | struct GNUNET_CRYPTO_CsBlindedMessage bm; |
565 | struct GNUNET_CRYPTO_CsC blinded_cs[2]; | 562 | struct GNUNET_CRYPTO_CsC blinded_cs[2]; |
566 | struct GNUNET_CRYPTO_CsRPublic blinded_r_pubs[2]; | 563 | struct GNUNET_CRYPTO_CSPublicRPairP blinded_r_pubs; |
567 | 564 | ||
568 | memset (blinded_cs, | 565 | memset (blinded_cs, |
569 | 42, | 566 | 42, |
570 | sizeof (blinded_cs)); | 567 | sizeof (blinded_cs)); |
571 | memset (blinded_r_pubs, | 568 | memset (&blinded_r_pubs, |
572 | 42, | 569 | 42, |
573 | sizeof (blinded_r_pubs)); | 570 | sizeof (blinded_r_pubs)); |
574 | test_calc_blindedc (blindingsecrets, | 571 | test_calc_blindedc (blindingsecrets, |
@@ -577,7 +574,7 @@ main (int argc, | |||
577 | message, | 574 | message, |
578 | message_len, | 575 | message_len, |
579 | blinded_cs, | 576 | blinded_cs, |
580 | blinded_r_pubs); | 577 | &blinded_r_pubs); |
581 | 578 | ||
582 | // ---------- actions performed by signer | 579 | // ---------- actions performed by signer |
583 | // sign blinded c's and get b and s in return | 580 | // sign blinded c's and get b and s in return |
@@ -614,7 +611,7 @@ main (int argc, | |||
614 | 611 | ||
615 | // verify unblinded signature | 612 | // verify unblinded signature |
616 | struct GNUNET_CRYPTO_CsSignature signature; | 613 | struct GNUNET_CRYPTO_CsSignature signature; |
617 | signature.r_point = blinded_r_pubs[blinded_s.b]; | 614 | signature.r_point = blinded_r_pubs.r_pub[blinded_s.b]; |
618 | signature.s_scalar = sig_scalar; | 615 | signature.s_scalar = sig_scalar; |
619 | test_verify (&signature, | 616 | test_verify (&signature, |
620 | &pub, | 617 | &pub, |