diff options
author | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-09-05 13:23:47 +0000 |
---|---|---|
committer | Christian Fuchs <christian.fuchs@cfuchs.net> | 2013-09-05 13:23:47 +0000 |
commit | 6e1476e6cbd3d55af76f25f063c308a028457393 (patch) | |
tree | 8d7d1a18ed037d4a87cb74fa840578c4d8b9b605 /src/scalarproduct | |
parent | 55401c568a7644b64032bff774e330fdadfaf35d (diff) | |
download | gnunet-6e1476e6cbd3d55af76f25f063c308a028457393.tar.gz gnunet-6e1476e6cbd3d55af76f25f063c308a028457393.zip |
service no longer asserts if it can not convert the result of a computation for the client, but just signals an error
errors are signaled as negative result with zero-length product. Bob determines his computation succeeded if he gets zero-length and zero as sign
Diffstat (limited to 'src/scalarproduct')
-rw-r--r-- | src/scalarproduct/gnunet-service-scalarproduct.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/scalarproduct/gnunet-service-scalarproduct.c b/src/scalarproduct/gnunet-service-scalarproduct.c index e54e9bfdf..5b97fdc7a 100644 --- a/src/scalarproduct/gnunet-service-scalarproduct.c +++ b/src/scalarproduct/gnunet-service-scalarproduct.c | |||
@@ -778,6 +778,7 @@ prepare_client_end_notification (void * cls, | |||
778 | msg->header.size = htons (sizeof (struct GNUNET_SCALARPRODUCT_client_response)); | 778 | msg->header.size = htons (sizeof (struct GNUNET_SCALARPRODUCT_client_response)); |
779 | // 0 size and the first char in the product is 0, which should never be zero if encoding is used. | 779 | // 0 size and the first char in the product is 0, which should never be zero if encoding is used. |
780 | msg->product_length = htonl (0); | 780 | msg->product_length = htonl (0); |
781 | msg->range = 1; | ||
781 | 782 | ||
782 | msg_obj = GNUNET_new (struct MessageObject); | 783 | msg_obj = GNUNET_new (struct MessageObject); |
783 | msg_obj->msg = &msg->header; | 784 | msg_obj->msg = &msg->header; |
@@ -1692,7 +1693,8 @@ prepare_client_response (void *cls, | |||
1692 | size_t product_length = 0; | 1693 | size_t product_length = 0; |
1693 | uint16_t msg_length = 0; | 1694 | uint16_t msg_length = 0; |
1694 | struct MessageObject * msg_obj; | 1695 | struct MessageObject * msg_obj; |
1695 | int8_t range = 0; | 1696 | int8_t range = -1; |
1697 | gcry_error_t rc; | ||
1696 | int sign; | 1698 | int sign; |
1697 | 1699 | ||
1698 | GNUNET_CONTAINER_DLL_remove (tasklist_head, tasklist_tail, task); | 1700 | GNUNET_CONTAINER_DLL_remove (tasklist_head, tasklist_tail, task); |
@@ -1705,24 +1707,29 @@ prepare_client_response (void *cls, | |||
1705 | sign = gcry_mpi_cmp_ui(session->product, 0); | 1707 | sign = gcry_mpi_cmp_ui(session->product, 0); |
1706 | // libgcrypt can not handle a print of a negative number | 1708 | // libgcrypt can not handle a print of a negative number |
1707 | if (0 > sign){ | 1709 | if (0 > sign){ |
1708 | range = -1; | ||
1709 | gcry_mpi_sub(value, value, session->product); | 1710 | gcry_mpi_sub(value, value, session->product); |
1710 | } | 1711 | } |
1711 | else if(0 < sign){ | 1712 | else if(0 < sign){ |
1712 | range = 1; | 1713 | range = 1; |
1713 | gcry_mpi_add(value, value, session->product); | 1714 | gcry_mpi_add(value, value, session->product); |
1714 | } | 1715 | } |
1716 | else | ||
1717 | range = 0; | ||
1715 | 1718 | ||
1716 | // get representation as string | 1719 | // get representation as string |
1717 | // unfortunately libgcrypt is too stupid to implement print-support in | 1720 | // unfortunately libgcrypt is too stupid to implement print-support in |
1718 | // signed GCRYMPI_FMT_STD format, and simply asserts in that case. | 1721 | // signed GCRYMPI_FMT_STD format, and simply asserts in that case. |
1719 | // here is the associated sourcecode: | 1722 | // here is the associated sourcecode: |
1720 | // if (a->sign) return gcry_error (GPG_ERR_INTERNAL); /* Can't handle it yet. */ | 1723 | // if (a->sign) return gcry_error (GPG_ERR_INTERNAL); /* Can't handle it yet. */ |
1721 | if (range) | 1724 | if (range |
1722 | GNUNET_assert ( ! gcry_mpi_aprint (GCRYMPI_FMT_USG, // FIXME: just log (& survive!) | 1725 | && (0 != (rc = gcry_mpi_aprint (GCRYMPI_FMT_USG, |
1723 | &product_exported, | 1726 | &product_exported, |
1724 | &product_length, | 1727 | &product_length, |
1725 | session->product)); | 1728 | session->product)))){ |
1729 | LOG_GCRY(GNUNET_ERROR_TYPE_ERROR, "gcry_mpi_scan", rc); | ||
1730 | product_length = 0; | ||
1731 | range = -1; // signal error with product-length = 0 and range = -1 | ||
1732 | } | ||
1726 | 1733 | ||
1727 | gcry_mpi_release (session->product); | 1734 | gcry_mpi_release (session->product); |
1728 | session->product = NULL; | 1735 | session->product = NULL; |