aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--brandt.c66
-rw-r--r--brandt.h38
-rw-r--r--internals.h22
-rw-r--r--test_brandt.c9
4 files changed, 37 insertions, 98 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");
diff --git a/brandt.h b/brandt.h
index 6d68f0a..fab8ebf 100644
--- a/brandt.h
+++ b/brandt.h
@@ -126,13 +126,11 @@ BRANDT_init (struct GNUNET_CRYPTO_EccDlogContext *dlogctx);
/**
- * Verify an auction description blob and parse it's fields. See BRANDT_new()
+ * Parse an auction description data block. See BRANDT_new()
* for an explanation of the different auction description fields.
*
* @param[in] auction_desc The auction description blob published by the seller.
* @param[in] auction_desc_len Length of @a auction_desc in bytes.
- * @param[in] description The description text in application choosen format.
- * @param[in] description_len Length of @a description in bytes.
* @param[out] time_start Starting time of the auction. May be NULL.
* @param[out] time_round Maximum round time of the auction. May be NULL.
* @param[out] num_prices Amount of possible prices. May be NULL.
@@ -140,15 +138,13 @@ BRANDT_init (struct GNUNET_CRYPTO_EccDlogContext *dlogctx);
* @param[out] outcome_public Outcome setting. May be NULL.
*/
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);
/**
@@ -160,9 +156,10 @@ BRANDT_verify_desc (const void *auction_desc,
* @param[in] auction_closure Closure pointer representing the auction. This
* will not be touched by libbrandt itself. It is only passed to the callbacks.
* @param[in] auction_desc The auction information data published by the seller.
- * This is an opaque data structure. It will be parsed and checked by
- * BRANDT_join().
- * @param[in] auction_desc_len The length in bytes of the @a auction_desc
+ * This is opaque to the application. Its content will be parsed. The
+ * application MUST check the signature on this data block before passing it to
+ * libbrandt!
+ * @param[in] auction_desc_len The length in byte of the @a auction_desc
* structure.
* @return A pointer, which should only be remembered and passed to
* libbrandt functions when the client needs to refer to this auction. This is a
@@ -175,8 +172,6 @@ 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);
@@ -196,9 +191,10 @@ BRANDT_join (BRANDT_CbResult result,
* @param[in] result Pointer to the result callback function
* @param[in] auction_closure Closure pointer representing the auction. This
* will not be touched by libbrandt. It is only passed to the callbacks.
- * @param[out] auction_desc The auction information data a an opaque data
- * structure. It will be generated by BRANDT_new() and should be distributed to
- * all possibly interested bidders.
+ * @param[out] auction_desc The auction information data as an opaque data
+ * structure. It is generated by this function and should be distributed to
+ * all possibly interested bidders. The seller MUST sign this data block before
+ * publishing it!
* @param[out] auction_desc_len The length in bytes of the @a auction_desc
* structure. Will be filled by BRANDT_new().
* @param[in] num_prices The amount of possible valuations for the sold item(s).
@@ -223,8 +219,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,
diff --git a/internals.h b/internals.h
index 373c3d4..d6de9db 100644
--- a/internals.h
+++ b/internals.h
@@ -60,20 +60,10 @@ struct msg_head {
/**
- * This struct describes an auction and is always linked to a description buffer
- * of #description_len bytes of arbitrary data where the description of the item
- * to be sold is stored. This buffer should also contain information linking the
- * auction to the payment system (which exact prices do the k possibilities
- * refer to, payment system seller identity, …). All fields are stored in
+ * This struct describes the parameters of an auction. All fields are stored in
* network byte order.
- *
- * \todo: align to a multiple of 64bit
- * \todo: versionsnummer */
+ */
struct BRANDT_DescrP {
- /** Hash code over the remaining elements of this struct followed by the
- * description buffer of #description_len bytes */
- struct GNUNET_HashCode hash GNUNET_PACKED;
-
/** Starting time of the auction. Bidders have to join the auction via
* BRANDT_join until this time */
struct GNUNET_TIME_AbsoluteNBO time_start;
@@ -81,12 +71,6 @@ struct BRANDT_DescrP {
/** The maximum duration the participants have to complete each round. */
struct GNUNET_TIME_RelativeNBO time_round;
- /** The length of the description in bytes */
- uint32_t description_len GNUNET_PACKED;
-
- /** reserved for future use. Must be zeroed out. */
- uint32_t reserved1 GNUNET_PACKED;
-
/** The amount of possible prices */
uint16_t k GNUNET_PACKED;
@@ -99,7 +83,7 @@ struct BRANDT_DescrP {
uint16_t outcome_public GNUNET_PACKED;
/** reserved for future use. Must be zeroed out. */
- uint16_t reserved2 GNUNET_PACKED;
+ uint16_t reserved GNUNET_PACKED;
};
GNUNET_NETWORK_STRUCT_END
diff --git a/test_brandt.c b/test_brandt.c
index 1540583..9d91260 100644
--- a/test_brandt.c
+++ b/test_brandt.c
@@ -305,9 +305,8 @@ quit:
static void
run_auction (void *arg)
{
- const char description[] = "test description for test_auction";
- void *desc;
- size_t desc_len;
+ void *desc;
+ size_t desc_len;
tcase.ad[tcase.n] = BRANDT_new (&cb_result,
&cb_broadcast,
@@ -315,8 +314,6 @@ run_auction (void *arg)
&tcase.id[tcase.n],
&desc,
&desc_len,
- description,
- sizeof (description),
GNUNET_TIME_absolute_get (),
GNUNET_TIME_UNIT_MINUTES,
tcase.k, /* number of prizes */
@@ -336,8 +333,6 @@ run_auction (void *arg)
&tcase.id[i],
desc,
desc_len,
- description,
- sizeof (description),
tcase.bids[i]); /* bid */
if (!tcase.ad[i])
{