diff options
author | Markus Teich <markus.teich@stusta.mhn.de> | 2016-12-02 09:34:25 +0100 |
---|---|---|
committer | Markus Teich <markus.teich@stusta.mhn.de> | 2016-12-02 09:34:25 +0100 |
commit | 56b43dab7ff80acc4cd0e7ad3057abd5e6bad680 (patch) | |
tree | 74b6a5f1ff6f8994582926112b4102574784f524 /crypto.c | |
parent | aee7167739e666ea94c3b68c58a0f7aa1ede238e (diff) | |
download | libbrandt-56b43dab7ff80acc4cd0e7ad3057abd5e6bad680.tar.gz libbrandt-56b43dab7ff80acc4cd0e7ad3057abd5e6bad680.zip |
migrate to GNUNET_log
Diffstat (limited to 'crypto.c')
-rw-r--r-- | crypto.c | 53 |
1 files changed, 37 insertions, 16 deletions
@@ -219,7 +219,9 @@ ec_point_cmp (const gcry_mpi_point_t a, const gcry_mpi_point_t b) | |||
219 | brandt_assert (a && b); | 219 | brandt_assert (a && b); |
220 | if (!ax || !bx || !ay || !by) | 220 | if (!ax || !bx || !ay || !by) |
221 | { | 221 | { |
222 | weprintf ("could not init point in point_cmp"); | 222 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, |
223 | "libbrandt", | ||
224 | "could not init point in point_cmp\n"); | ||
223 | return 1; | 225 | return 1; |
224 | } | 226 | } |
225 | 227 | ||
@@ -410,8 +412,10 @@ smc_init1 (uint16_t size1) | |||
410 | { | 412 | { |
411 | if (NULL == (ret[i] = gcry_mpi_point_new (0))) | 413 | if (NULL == (ret[i] = gcry_mpi_point_new (0))) |
412 | { | 414 | { |
413 | weprintf ("could not init point in 1 dimensional array. " | 415 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, |
414 | "out of memory?"); | 416 | "libbrandt", |
417 | "could not init point in 1 dimensional array. " | ||
418 | "out of memory?\n"); | ||
415 | smc_free1 (ret, size1); | 419 | smc_free1 (ret, size1); |
416 | return NULL; | 420 | return NULL; |
417 | } | 421 | } |
@@ -464,8 +468,11 @@ smc_init2 (uint16_t size1, uint16_t size2) | |||
464 | { | 468 | { |
465 | if (NULL == (ret[i][j] = gcry_mpi_point_new (0))) | 469 | if (NULL == (ret[i][j] = gcry_mpi_point_new (0))) |
466 | { | 470 | { |
467 | weprintf ("could not init point in 2 dimensional array. " | 471 | GNUNET_log_from ( |
468 | "out of memory?"); | 472 | GNUNET_ERROR_TYPE_ERROR, |
473 | "libbrandt", | ||
474 | "could not init point in 2 dimensional array. " | ||
475 | "out of memory?\n"); | ||
469 | smc_free2 (ret, size1, size2); | 476 | smc_free2 (ret, size1, size2); |
470 | GNUNET_assert (0); | 477 | GNUNET_assert (0); |
471 | } | 478 | } |
@@ -527,8 +534,11 @@ smc_init3 (uint16_t size1, uint16_t size2, uint16_t size3) | |||
527 | { | 534 | { |
528 | if (NULL == (ret[i][j][k] = gcry_mpi_point_new (0))) | 535 | if (NULL == (ret[i][j][k] = gcry_mpi_point_new (0))) |
529 | { | 536 | { |
530 | weprintf ("could not init point in 2 dimensional array. " | 537 | GNUNET_log_from ( |
531 | "out of memory?"); | 538 | GNUNET_ERROR_TYPE_ERROR, |
539 | "libbrandt", | ||
540 | "could not init point in 2 dimensional array. " | ||
541 | "out of memory?\n"); | ||
532 | smc_free3 (ret, size1, size2, size3); | 542 | smc_free3 (ret, size1, size2, size3); |
533 | GNUNET_assert (0); | 543 | GNUNET_assert (0); |
534 | } | 544 | } |
@@ -651,7 +661,9 @@ smc_recv_keyshare (struct BRANDT_Auction *ad, | |||
651 | 661 | ||
652 | if (buflen != (sizeof (struct ec_mpi) + sizeof (*proof1))) | 662 | if (buflen != (sizeof (struct ec_mpi) + sizeof (*proof1))) |
653 | { | 663 | { |
654 | weprintf ("wrong size of received key share"); | 664 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, |
665 | "libbrandt", | ||
666 | "wrong size of received key share\n"); | ||
655 | goto quit; | 667 | goto quit; |
656 | } | 668 | } |
657 | 669 | ||
@@ -659,7 +671,9 @@ smc_recv_keyshare (struct BRANDT_Auction *ad, | |||
659 | ec_point_parse (y, (struct ec_mpi *)buf); | 671 | ec_point_parse (y, (struct ec_mpi *)buf); |
660 | if (smc_zkp_dl_check (y, proof1)) | 672 | if (smc_zkp_dl_check (y, proof1)) |
661 | { | 673 | { |
662 | weprintf ("wrong zkp1 for public key share received"); | 674 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, |
675 | "libbrandt", | ||
676 | "wrong zkp1 for public key share received\n"); | ||
663 | goto quit; | 677 | goto quit; |
664 | } | 678 | } |
665 | 679 | ||
@@ -785,7 +799,9 @@ smc_recv_encrypted_bid (struct BRANDT_Auction *ad, | |||
785 | (0 < ad->m ? 2 : 1) * sizeof (struct proof_2dle)) || | 799 | (0 < ad->m ? 2 : 1) * sizeof (struct proof_2dle)) || |
786 | NULL == (ct = smc_init2 (2, ad->k))) | 800 | NULL == (ct = smc_init2 (2, ad->k))) |
787 | { | 801 | { |
788 | weprintf ("wrong size of received encrypted bid"); | 802 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, |
803 | "libbrandt", | ||
804 | "wrong size of received encrypted bid\n"); | ||
789 | goto quit; | 805 | goto quit; |
790 | } | 806 | } |
791 | 807 | ||
@@ -801,7 +817,9 @@ smc_recv_encrypted_bid (struct BRANDT_Auction *ad, | |||
801 | proof3 = (struct proof_0og *)(cur + 2 * sizeof (struct ec_mpi)); | 817 | proof3 = (struct proof_0og *)(cur + 2 * sizeof (struct ec_mpi)); |
802 | if (smc_zkp_0og_check (ad->Y, ct[0][j], ct[1][j], proof3)) | 818 | if (smc_zkp_0og_check (ad->Y, ct[0][j], ct[1][j], proof3)) |
803 | { | 819 | { |
804 | weprintf ("wrong zkp3 for alpha, beta received"); | 820 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, |
821 | "libbrandt", | ||
822 | "wrong zkp3 for alpha, beta received\n"); | ||
805 | goto quit; | 823 | goto quit; |
806 | } | 824 | } |
807 | gcry_mpi_ec_add (alpha_sum, alpha_sum, ct[0][j], ec_ctx); | 825 | gcry_mpi_ec_add (alpha_sum, alpha_sum, ct[0][j], ec_ctx); |
@@ -825,7 +843,9 @@ smc_recv_encrypted_bid (struct BRANDT_Auction *ad, | |||
825 | ec_gen, | 843 | ec_gen, |
826 | (struct proof_2dle *)cur)) | 844 | (struct proof_2dle *)cur)) |
827 | { | 845 | { |
828 | weprintf ("wrong zkp2 for alpha, beta received"); | 846 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, |
847 | "libbrandt", | ||
848 | "wrong zkp2 for alpha, beta received\n"); | ||
829 | goto quit; | 849 | goto quit; |
830 | } | 850 | } |
831 | 851 | ||
@@ -841,8 +861,11 @@ smc_recv_encrypted_bid (struct BRANDT_Auction *ad, | |||
841 | ec_gen, | 861 | ec_gen, |
842 | (struct proof_2dle *)cur)) | 862 | (struct proof_2dle *)cur)) |
843 | { | 863 | { |
844 | weprintf ("wrong second zkp2 for alpha, beta received. " | 864 | GNUNET_log_from ( |
845 | "bid not allowed for this user in M+1st price auctions."); | 865 | GNUNET_ERROR_TYPE_WARNING, |
866 | "libbrandt", | ||
867 | "wrong second zkp2 for alpha, beta received. " | ||
868 | "bid not allowed for this user in M+1st price auctions.\n"); | ||
846 | goto quit; | 869 | goto quit; |
847 | } | 870 | } |
848 | } | 871 | } |
@@ -1381,7 +1404,5 @@ smc_zkp_0og_check (const gcry_mpi_point_t y, | |||
1381 | gcry_mpi_point_release (right); | 1404 | gcry_mpi_point_release (right); |
1382 | gcry_mpi_point_release (tmp); | 1405 | gcry_mpi_point_release (tmp); |
1383 | 1406 | ||
1384 | if (ret) | ||
1385 | weprintf ("ret: 0x%x", ret); | ||
1386 | return ret; | 1407 | return ret; |
1387 | } | 1408 | } |