aboutsummaryrefslogtreecommitdiff
path: root/brandt.c
diff options
context:
space:
mode:
authorMarkus Teich <markus.teich@stusta.mhn.de>2016-11-23 23:20:25 +0100
committerMarkus Teich <markus.teich@stusta.mhn.de>2016-11-23 23:26:01 +0100
commitf4932d94c07d7c0dd9992b6b2d5b562b567d49b0 (patch)
tree22fb1dee0c28a54957513d8fe09655c26a31b1c8 /brandt.c
parentb0042a588a932883a8f03e58ffe930c6eb795d48 (diff)
remove unnecessary description handling and hashing.
The hash is not needed since the sellers application is required to sign the description and the bidders application is required to check the signature. Since the arbitrary description used by the application was only used inside this hash, it can be removed as well.
Diffstat (limited to 'brandt.c')
-rw-r--r--brandt.c66
1 files changed, 16 insertions, 50 deletions
diff --git a/brandt.c b/brandt.c
index 5d134cc..5a75eda 100644
--- a/brandt.c
+++ b/brandt.c
@@ -174,8 +174,6 @@ BRANDT_new (BRANDT_CbResult result,
void *auction_closure,
void **auction_desc,
size_t *auction_desc_len,
- const void *description,
- uint32_t description_len,
struct GNUNET_TIME_Absolute time_start,
struct GNUNET_TIME_Relative time_round,
uint16_t num_prices,
@@ -184,7 +182,6 @@ BRANDT_new (BRANDT_CbResult result,
{
struct BRANDT_Auction *ret;
struct BRANDT_DescrP *desc;
- struct GNUNET_HashContext *hc;
struct GNUNET_TIME_Relative until_start;
if (0 == num_prices)
@@ -193,18 +190,9 @@ BRANDT_new (BRANDT_CbResult result,
desc = GNUNET_new (struct BRANDT_DescrP);
desc->time_start = GNUNET_TIME_absolute_hton (time_start);
desc->time_round = GNUNET_TIME_relative_hton (time_round);
- desc->description_len = htonl (description_len);
desc->k = htons (num_prices);
desc->m = htons (m);
desc->outcome_public = htons (outcome_public);
- hc = GNUNET_CRYPTO_hash_context_start ();
- GNUNET_CRYPTO_hash_context_read (hc,
- &desc->time_start,
- sizeof (*desc) - sizeof (desc->hash));
- GNUNET_CRYPTO_hash_context_read (hc,
- description,
- description_len);
- GNUNET_CRYPTO_hash_context_finish (hc, &desc->hash);
ret = GNUNET_new (struct BRANDT_Auction);
ret->time_start = time_start;
@@ -236,20 +224,16 @@ BRANDT_new (BRANDT_CbResult result,
int
-BRANDT_verify_desc (const void *auction_desc,
- size_t auction_desc_len,
- const void *description,
- uint32_t description_len,
- struct GNUNET_TIME_Absolute *time_start,
- struct GNUNET_TIME_Relative *time_round,
- uint16_t *num_prices,
- uint16_t *m,
- uint16_t *outcome_public)
+BRANDT_parse_desc (const void *auction_desc,
+ size_t auction_desc_len,
+ struct GNUNET_TIME_Absolute *time_start,
+ struct GNUNET_TIME_Relative *time_round,
+ uint16_t *num_prices,
+ uint16_t *m,
+ uint16_t *outcome_public)
{
const struct BRANDT_DescrP *desc = auction_desc;
const uint32_t zero = 0;
- struct GNUNET_HashContext *hc = GNUNET_CRYPTO_hash_context_start ();
- struct GNUNET_HashCode computed_hash;
if (sizeof (struct BRANDT_DescrP) != auction_desc_len)
{
@@ -257,23 +241,9 @@ BRANDT_verify_desc (const void *auction_desc,
return -1;
}
- GNUNET_CRYPTO_hash_context_read (hc,
- &desc->time_start,
- sizeof (*desc) - sizeof (desc->hash));
- GNUNET_CRYPTO_hash_context_read (hc,
- description,
- description_len);
- GNUNET_CRYPTO_hash_context_finish (hc, &computed_hash);
- if (0 != memcmp (&desc->hash, &computed_hash, sizeof (computed_hash)))
+ if (0 != memcmp (&desc->reserved, &zero, sizeof (desc->reserved)))
{
- weprintf ("auction description hash does not match");
- return -1;
- }
-
- if (0 != memcmp (&desc->reserved1, &zero, sizeof (desc->reserved1)) ||
- 0 != memcmp (&desc->reserved2, &zero, sizeof (desc->reserved2)))
- {
- weprintf ("unknown auction description format");
+ weprintf ("reserved field in auction description must be zero");
return -1;
}
@@ -299,21 +269,17 @@ BRANDT_join (BRANDT_CbResult result,
void *auction_closure,
const void *auction_desc,
size_t auction_desc_len,
- const void *description,
- uint32_t description_len,
uint16_t bid)
{
struct BRANDT_Auction *ret = GNUNET_new (struct BRANDT_Auction);
- if (0 != BRANDT_verify_desc (auction_desc,
- auction_desc_len,
- description,
- description_len,
- &ret->time_start,
- &ret->time_round,
- &ret->k,
- &ret->m,
- &ret->outcome_public))
+ if (0 != BRANDT_parse_desc (auction_desc,
+ auction_desc_len,
+ &ret->time_start,
+ &ret->time_round,
+ &ret->k,
+ &ret->m,
+ &ret->outcome_public))
{
GNUNET_free (ret);
weprintf ("failed to parse auction description blob");