diff options
author | Markus Teich <markus.teich@stusta.mhn.de> | 2016-11-23 23:20:25 +0100 |
---|---|---|
committer | Markus Teich <markus.teich@stusta.mhn.de> | 2016-11-23 23:26:01 +0100 |
commit | f4932d94c07d7c0dd9992b6b2d5b562b567d49b0 (patch) | |
tree | 22fb1dee0c28a54957513d8fe09655c26a31b1c8 /brandt.c | |
parent | b0042a588a932883a8f03e58ffe930c6eb795d48 (diff) | |
download | libbrandt-f4932d94c07d7c0dd9992b6b2d5b562b567d49b0.tar.gz libbrandt-f4932d94c07d7c0dd9992b6b2d5b562b567d49b0.zip |
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.c | 66 |
1 files changed, 16 insertions, 50 deletions
@@ -174,8 +174,6 @@ BRANDT_new (BRANDT_CbResult result, | |||
174 | void *auction_closure, | 174 | void *auction_closure, |
175 | void **auction_desc, | 175 | void **auction_desc, |
176 | size_t *auction_desc_len, | 176 | size_t *auction_desc_len, |
177 | const void *description, | ||
178 | uint32_t description_len, | ||
179 | struct GNUNET_TIME_Absolute time_start, | 177 | struct GNUNET_TIME_Absolute time_start, |
180 | struct GNUNET_TIME_Relative time_round, | 178 | struct GNUNET_TIME_Relative time_round, |
181 | uint16_t num_prices, | 179 | uint16_t num_prices, |
@@ -184,7 +182,6 @@ BRANDT_new (BRANDT_CbResult result, | |||
184 | { | 182 | { |
185 | struct BRANDT_Auction *ret; | 183 | struct BRANDT_Auction *ret; |
186 | struct BRANDT_DescrP *desc; | 184 | struct BRANDT_DescrP *desc; |
187 | struct GNUNET_HashContext *hc; | ||
188 | struct GNUNET_TIME_Relative until_start; | 185 | struct GNUNET_TIME_Relative until_start; |
189 | 186 | ||
190 | if (0 == num_prices) | 187 | if (0 == num_prices) |
@@ -193,18 +190,9 @@ BRANDT_new (BRANDT_CbResult result, | |||
193 | desc = GNUNET_new (struct BRANDT_DescrP); | 190 | desc = GNUNET_new (struct BRANDT_DescrP); |
194 | desc->time_start = GNUNET_TIME_absolute_hton (time_start); | 191 | desc->time_start = GNUNET_TIME_absolute_hton (time_start); |
195 | desc->time_round = GNUNET_TIME_relative_hton (time_round); | 192 | desc->time_round = GNUNET_TIME_relative_hton (time_round); |
196 | desc->description_len = htonl (description_len); | ||
197 | desc->k = htons (num_prices); | 193 | desc->k = htons (num_prices); |
198 | desc->m = htons (m); | 194 | desc->m = htons (m); |
199 | desc->outcome_public = htons (outcome_public); | 195 | desc->outcome_public = htons (outcome_public); |
200 | hc = GNUNET_CRYPTO_hash_context_start (); | ||
201 | GNUNET_CRYPTO_hash_context_read (hc, | ||
202 | &desc->time_start, | ||
203 | sizeof (*desc) - sizeof (desc->hash)); | ||
204 | GNUNET_CRYPTO_hash_context_read (hc, | ||
205 | description, | ||
206 | description_len); | ||
207 | GNUNET_CRYPTO_hash_context_finish (hc, &desc->hash); | ||
208 | 196 | ||
209 | ret = GNUNET_new (struct BRANDT_Auction); | 197 | ret = GNUNET_new (struct BRANDT_Auction); |
210 | ret->time_start = time_start; | 198 | ret->time_start = time_start; |
@@ -236,20 +224,16 @@ BRANDT_new (BRANDT_CbResult result, | |||
236 | 224 | ||
237 | 225 | ||
238 | int | 226 | int |
239 | BRANDT_verify_desc (const void *auction_desc, | 227 | BRANDT_parse_desc (const void *auction_desc, |
240 | size_t auction_desc_len, | 228 | size_t auction_desc_len, |
241 | const void *description, | 229 | struct GNUNET_TIME_Absolute *time_start, |
242 | uint32_t description_len, | 230 | struct GNUNET_TIME_Relative *time_round, |
243 | struct GNUNET_TIME_Absolute *time_start, | 231 | uint16_t *num_prices, |
244 | struct GNUNET_TIME_Relative *time_round, | 232 | uint16_t *m, |
245 | uint16_t *num_prices, | 233 | uint16_t *outcome_public) |
246 | uint16_t *m, | ||
247 | uint16_t *outcome_public) | ||
248 | { | 234 | { |
249 | const struct BRANDT_DescrP *desc = auction_desc; | 235 | const struct BRANDT_DescrP *desc = auction_desc; |
250 | const uint32_t zero = 0; | 236 | const uint32_t zero = 0; |
251 | struct GNUNET_HashContext *hc = GNUNET_CRYPTO_hash_context_start (); | ||
252 | struct GNUNET_HashCode computed_hash; | ||
253 | 237 | ||
254 | if (sizeof (struct BRANDT_DescrP) != auction_desc_len) | 238 | if (sizeof (struct BRANDT_DescrP) != auction_desc_len) |
255 | { | 239 | { |
@@ -257,23 +241,9 @@ BRANDT_verify_desc (const void *auction_desc, | |||
257 | return -1; | 241 | return -1; |
258 | } | 242 | } |
259 | 243 | ||
260 | GNUNET_CRYPTO_hash_context_read (hc, | 244 | if (0 != memcmp (&desc->reserved, &zero, sizeof (desc->reserved))) |
261 | &desc->time_start, | ||
262 | sizeof (*desc) - sizeof (desc->hash)); | ||
263 | GNUNET_CRYPTO_hash_context_read (hc, | ||
264 | description, | ||
265 | description_len); | ||
266 | GNUNET_CRYPTO_hash_context_finish (hc, &computed_hash); | ||
267 | if (0 != memcmp (&desc->hash, &computed_hash, sizeof (computed_hash))) | ||
268 | { | 245 | { |
269 | weprintf ("auction description hash does not match"); | 246 | weprintf ("reserved field in auction description must be zero"); |
270 | return -1; | ||
271 | } | ||
272 | |||
273 | if (0 != memcmp (&desc->reserved1, &zero, sizeof (desc->reserved1)) || | ||
274 | 0 != memcmp (&desc->reserved2, &zero, sizeof (desc->reserved2))) | ||
275 | { | ||
276 | weprintf ("unknown auction description format"); | ||
277 | return -1; | 247 | return -1; |
278 | } | 248 | } |
279 | 249 | ||
@@ -299,21 +269,17 @@ BRANDT_join (BRANDT_CbResult result, | |||
299 | void *auction_closure, | 269 | void *auction_closure, |
300 | const void *auction_desc, | 270 | const void *auction_desc, |
301 | size_t auction_desc_len, | 271 | size_t auction_desc_len, |
302 | const void *description, | ||
303 | uint32_t description_len, | ||
304 | uint16_t bid) | 272 | uint16_t bid) |
305 | { | 273 | { |
306 | struct BRANDT_Auction *ret = GNUNET_new (struct BRANDT_Auction); | 274 | struct BRANDT_Auction *ret = GNUNET_new (struct BRANDT_Auction); |
307 | 275 | ||
308 | if (0 != BRANDT_verify_desc (auction_desc, | 276 | if (0 != BRANDT_parse_desc (auction_desc, |
309 | auction_desc_len, | 277 | auction_desc_len, |
310 | description, | 278 | &ret->time_start, |
311 | description_len, | 279 | &ret->time_round, |
312 | &ret->time_start, | 280 | &ret->k, |
313 | &ret->time_round, | 281 | &ret->m, |
314 | &ret->k, | 282 | &ret->outcome_public)) |
315 | &ret->m, | ||
316 | &ret->outcome_public)) | ||
317 | { | 283 | { |
318 | GNUNET_free (ret); | 284 | GNUNET_free (ret); |
319 | weprintf ("failed to parse auction description blob"); | 285 | weprintf ("failed to parse auction description blob"); |