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.
This commit is contained in:
parent
b0042a588a
commit
f4932d94c0
42
brandt.c
42
brandt.c
@ -174,8 +174,6 @@ BRANDT_new (BRANDT_CbResult result,
|
|||||||
void *auction_closure,
|
void *auction_closure,
|
||||||
void **auction_desc,
|
void **auction_desc,
|
||||||
size_t *auction_desc_len,
|
size_t *auction_desc_len,
|
||||||
const void *description,
|
|
||||||
uint32_t description_len,
|
|
||||||
struct GNUNET_TIME_Absolute time_start,
|
struct GNUNET_TIME_Absolute time_start,
|
||||||
struct GNUNET_TIME_Relative time_round,
|
struct GNUNET_TIME_Relative time_round,
|
||||||
uint16_t num_prices,
|
uint16_t num_prices,
|
||||||
@ -184,7 +182,6 @@ BRANDT_new (BRANDT_CbResult result,
|
|||||||
{
|
{
|
||||||
struct BRANDT_Auction *ret;
|
struct BRANDT_Auction *ret;
|
||||||
struct BRANDT_DescrP *desc;
|
struct BRANDT_DescrP *desc;
|
||||||
struct GNUNET_HashContext *hc;
|
|
||||||
struct GNUNET_TIME_Relative until_start;
|
struct GNUNET_TIME_Relative until_start;
|
||||||
|
|
||||||
if (0 == num_prices)
|
if (0 == num_prices)
|
||||||
@ -193,18 +190,9 @@ BRANDT_new (BRANDT_CbResult result,
|
|||||||
desc = GNUNET_new (struct BRANDT_DescrP);
|
desc = GNUNET_new (struct BRANDT_DescrP);
|
||||||
desc->time_start = GNUNET_TIME_absolute_hton (time_start);
|
desc->time_start = GNUNET_TIME_absolute_hton (time_start);
|
||||||
desc->time_round = GNUNET_TIME_relative_hton (time_round);
|
desc->time_round = GNUNET_TIME_relative_hton (time_round);
|
||||||
desc->description_len = htonl (description_len);
|
|
||||||
desc->k = htons (num_prices);
|
desc->k = htons (num_prices);
|
||||||
desc->m = htons (m);
|
desc->m = htons (m);
|
||||||
desc->outcome_public = htons (outcome_public);
|
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 = GNUNET_new (struct BRANDT_Auction);
|
||||||
ret->time_start = time_start;
|
ret->time_start = time_start;
|
||||||
@ -236,10 +224,8 @@ BRANDT_new (BRANDT_CbResult result,
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
BRANDT_verify_desc (const void *auction_desc,
|
BRANDT_parse_desc (const void *auction_desc,
|
||||||
size_t auction_desc_len,
|
size_t auction_desc_len,
|
||||||
const void *description,
|
|
||||||
uint32_t description_len,
|
|
||||||
struct GNUNET_TIME_Absolute *time_start,
|
struct GNUNET_TIME_Absolute *time_start,
|
||||||
struct GNUNET_TIME_Relative *time_round,
|
struct GNUNET_TIME_Relative *time_round,
|
||||||
uint16_t *num_prices,
|
uint16_t *num_prices,
|
||||||
@ -248,8 +234,6 @@ BRANDT_verify_desc (const void *auction_desc,
|
|||||||
{
|
{
|
||||||
const struct BRANDT_DescrP *desc = auction_desc;
|
const struct BRANDT_DescrP *desc = auction_desc;
|
||||||
const uint32_t zero = 0;
|
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)
|
if (sizeof (struct BRANDT_DescrP) != auction_desc_len)
|
||||||
{
|
{
|
||||||
@ -257,23 +241,9 @@ BRANDT_verify_desc (const void *auction_desc,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
GNUNET_CRYPTO_hash_context_read (hc,
|
if (0 != memcmp (&desc->reserved, &zero, sizeof (desc->reserved)))
|
||||||
&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)))
|
|
||||||
{
|
{
|
||||||
weprintf ("auction description hash does not match");
|
weprintf ("reserved field in auction description must be zero");
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 != memcmp (&desc->reserved1, &zero, sizeof (desc->reserved1)) ||
|
|
||||||
0 != memcmp (&desc->reserved2, &zero, sizeof (desc->reserved2)))
|
|
||||||
{
|
|
||||||
weprintf ("unknown auction description format");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,16 +269,12 @@ BRANDT_join (BRANDT_CbResult result,
|
|||||||
void *auction_closure,
|
void *auction_closure,
|
||||||
const void *auction_desc,
|
const void *auction_desc,
|
||||||
size_t auction_desc_len,
|
size_t auction_desc_len,
|
||||||
const void *description,
|
|
||||||
uint32_t description_len,
|
|
||||||
uint16_t bid)
|
uint16_t bid)
|
||||||
{
|
{
|
||||||
struct BRANDT_Auction *ret = GNUNET_new (struct BRANDT_Auction);
|
struct BRANDT_Auction *ret = GNUNET_new (struct BRANDT_Auction);
|
||||||
|
|
||||||
if (0 != BRANDT_verify_desc (auction_desc,
|
if (0 != BRANDT_parse_desc (auction_desc,
|
||||||
auction_desc_len,
|
auction_desc_len,
|
||||||
description,
|
|
||||||
description_len,
|
|
||||||
&ret->time_start,
|
&ret->time_start,
|
||||||
&ret->time_round,
|
&ret->time_round,
|
||||||
&ret->k,
|
&ret->k,
|
||||||
|
26
brandt.h
26
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.
|
* 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 The auction description blob published by the seller.
|
||||||
* @param[in] auction_desc_len Length of @a auction_desc in bytes.
|
* @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_start Starting time of the auction. May be NULL.
|
||||||
* @param[out] time_round Maximum round 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.
|
* @param[out] num_prices Amount of possible prices. May be NULL.
|
||||||
@ -140,10 +138,8 @@ BRANDT_init (struct GNUNET_CRYPTO_EccDlogContext *dlogctx);
|
|||||||
* @param[out] outcome_public Outcome setting. May be NULL.
|
* @param[out] outcome_public Outcome setting. May be NULL.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
BRANDT_verify_desc (const void *auction_desc,
|
BRANDT_parse_desc (const void *auction_desc,
|
||||||
size_t auction_desc_len,
|
size_t auction_desc_len,
|
||||||
const void *description,
|
|
||||||
uint32_t description_len,
|
|
||||||
struct GNUNET_TIME_Absolute *time_start,
|
struct GNUNET_TIME_Absolute *time_start,
|
||||||
struct GNUNET_TIME_Relative *time_round,
|
struct GNUNET_TIME_Relative *time_round,
|
||||||
uint16_t *num_prices,
|
uint16_t *num_prices,
|
||||||
@ -160,9 +156,10 @@ BRANDT_verify_desc (const void *auction_desc,
|
|||||||
* @param[in] auction_closure Closure pointer representing the auction. This
|
* @param[in] auction_closure Closure pointer representing the auction. This
|
||||||
* will not be touched by libbrandt itself. It is only passed to the callbacks.
|
* 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.
|
* @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
|
* This is opaque to the application. Its content will be parsed. The
|
||||||
* BRANDT_join().
|
* application MUST check the signature on this data block before passing it to
|
||||||
* @param[in] auction_desc_len The length in bytes of the @a auction_desc
|
* libbrandt!
|
||||||
|
* @param[in] auction_desc_len The length in byte of the @a auction_desc
|
||||||
* structure.
|
* structure.
|
||||||
* @return A pointer, which should only be remembered and passed to
|
* @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
|
* 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,
|
void *auction_closure,
|
||||||
const void *auction_desc,
|
const void *auction_desc,
|
||||||
size_t auction_desc_len,
|
size_t auction_desc_len,
|
||||||
const void *description,
|
|
||||||
uint32_t description_len,
|
|
||||||
uint16_t bid);
|
uint16_t bid);
|
||||||
|
|
||||||
|
|
||||||
@ -196,9 +191,10 @@ BRANDT_join (BRANDT_CbResult result,
|
|||||||
* @param[in] result Pointer to the result callback function
|
* @param[in] result Pointer to the result callback function
|
||||||
* @param[in] auction_closure Closure pointer representing the auction. This
|
* @param[in] auction_closure Closure pointer representing the auction. This
|
||||||
* will not be touched by libbrandt. It is only passed to the callbacks.
|
* 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
|
* @param[out] auction_desc The auction information data as an opaque data
|
||||||
* structure. It will be generated by BRANDT_new() and should be distributed to
|
* structure. It is generated by this function and should be distributed to
|
||||||
* all possibly interested bidders.
|
* 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
|
* @param[out] auction_desc_len The length in bytes of the @a auction_desc
|
||||||
* structure. Will be filled by BRANDT_new().
|
* structure. Will be filled by BRANDT_new().
|
||||||
* @param[in] num_prices The amount of possible valuations for the sold item(s).
|
* @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_closure,
|
||||||
void **auction_desc,
|
void **auction_desc,
|
||||||
size_t *auction_desc_len,
|
size_t *auction_desc_len,
|
||||||
const void *description,
|
|
||||||
uint32_t description_len,
|
|
||||||
struct GNUNET_TIME_Absolute time_start,
|
struct GNUNET_TIME_Absolute time_start,
|
||||||
struct GNUNET_TIME_Relative time_round,
|
struct GNUNET_TIME_Relative time_round,
|
||||||
uint16_t num_prices,
|
uint16_t num_prices,
|
||||||
|
22
internals.h
22
internals.h
@ -60,20 +60,10 @@ struct msg_head {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This struct describes an auction and is always linked to a description buffer
|
* This struct describes the parameters of an auction. All fields are stored in
|
||||||
* 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
|
|
||||||
* network byte order.
|
* network byte order.
|
||||||
*
|
*/
|
||||||
* \todo: align to a multiple of 64bit
|
|
||||||
* \todo: versionsnummer */
|
|
||||||
struct BRANDT_DescrP {
|
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
|
/** Starting time of the auction. Bidders have to join the auction via
|
||||||
* BRANDT_join until this time */
|
* BRANDT_join until this time */
|
||||||
struct GNUNET_TIME_AbsoluteNBO time_start;
|
struct GNUNET_TIME_AbsoluteNBO time_start;
|
||||||
@ -81,12 +71,6 @@ struct BRANDT_DescrP {
|
|||||||
/** The maximum duration the participants have to complete each round. */
|
/** The maximum duration the participants have to complete each round. */
|
||||||
struct GNUNET_TIME_RelativeNBO time_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 */
|
/** The amount of possible prices */
|
||||||
uint16_t k GNUNET_PACKED;
|
uint16_t k GNUNET_PACKED;
|
||||||
|
|
||||||
@ -99,7 +83,7 @@ struct BRANDT_DescrP {
|
|||||||
uint16_t outcome_public GNUNET_PACKED;
|
uint16_t outcome_public GNUNET_PACKED;
|
||||||
|
|
||||||
/** reserved for future use. Must be zeroed out. */
|
/** reserved for future use. Must be zeroed out. */
|
||||||
uint16_t reserved2 GNUNET_PACKED;
|
uint16_t reserved GNUNET_PACKED;
|
||||||
};
|
};
|
||||||
|
|
||||||
GNUNET_NETWORK_STRUCT_END
|
GNUNET_NETWORK_STRUCT_END
|
||||||
|
@ -305,7 +305,6 @@ quit:
|
|||||||
static void
|
static void
|
||||||
run_auction (void *arg)
|
run_auction (void *arg)
|
||||||
{
|
{
|
||||||
const char description[] = "test description for test_auction";
|
|
||||||
void *desc;
|
void *desc;
|
||||||
size_t desc_len;
|
size_t desc_len;
|
||||||
|
|
||||||
@ -315,8 +314,6 @@ run_auction (void *arg)
|
|||||||
&tcase.id[tcase.n],
|
&tcase.id[tcase.n],
|
||||||
&desc,
|
&desc,
|
||||||
&desc_len,
|
&desc_len,
|
||||||
description,
|
|
||||||
sizeof (description),
|
|
||||||
GNUNET_TIME_absolute_get (),
|
GNUNET_TIME_absolute_get (),
|
||||||
GNUNET_TIME_UNIT_MINUTES,
|
GNUNET_TIME_UNIT_MINUTES,
|
||||||
tcase.k, /* number of prizes */
|
tcase.k, /* number of prizes */
|
||||||
@ -336,8 +333,6 @@ run_auction (void *arg)
|
|||||||
&tcase.id[i],
|
&tcase.id[i],
|
||||||
desc,
|
desc,
|
||||||
desc_len,
|
desc_len,
|
||||||
description,
|
|
||||||
sizeof (description),
|
|
||||||
tcase.bids[i]); /* bid */
|
tcase.bids[i]); /* bid */
|
||||||
if (!tcase.ad[i])
|
if (!tcase.ad[i])
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user