aboutsummaryrefslogtreecommitdiff
path: root/brandt.c
diff options
context:
space:
mode:
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");