aboutsummaryrefslogtreecommitdiff
path: root/src/namestore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-06-20 23:22:32 +0000
committerChristian Grothoff <christian@grothoff.org>2012-06-20 23:22:32 +0000
commite615a940e0a60823c040f1df2ba4977018692d28 (patch)
tree304718572444b71c256cf4c71d7043c412ad90f1 /src/namestore
parentaac68f1b5bef4240e42f9c5c2040195db07478b7 (diff)
downloadgnunet-e615a940e0a60823c040f1df2ba4977018692d28.tar.gz
gnunet-e615a940e0a60823c040f1df2ba4977018692d28.zip
-fixing namestore signature bug; all that was needed was to force packing on the struct
Diffstat (limited to 'src/namestore')
-rw-r--r--src/namestore/namestore_common.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/namestore/namestore_common.c b/src/namestore/namestore_common.c
index a56192c5a..996259b51 100644
--- a/src/namestore/namestore_common.c
+++ b/src/namestore/namestore_common.c
@@ -37,6 +37,7 @@
37 37
38#define LOG(kind,...) GNUNET_log_from (kind, "gns-api",__VA_ARGS__) 38#define LOG(kind,...) GNUNET_log_from (kind, "gns-api",__VA_ARGS__)
39 39
40GNUNET_NETWORK_STRUCT_BEGIN
40 41
41/** 42/**
42 * Internal format of a record in the serialized form. 43 * Internal format of a record in the serialized form.
@@ -48,25 +49,27 @@ struct NetworkRecord
48 * Expiration time for the DNS record; relative or absolute depends 49 * Expiration time for the DNS record; relative or absolute depends
49 * on 'flags', network byte order. 50 * on 'flags', network byte order.
50 */ 51 */
51 uint64_t expiration_time; 52 uint64_t expiration_time GNUNET_PACKED;
52 53
53 /** 54 /**
54 * Number of bytes in 'data', network byte order. 55 * Number of bytes in 'data', network byte order.
55 */ 56 */
56 uint32_t data_size; 57 uint32_t data_size GNUNET_PACKED;
57 58
58 /** 59 /**
59 * Type of the GNS/DNS record, network byte order. 60 * Type of the GNS/DNS record, network byte order.
60 */ 61 */
61 uint32_t record_type; 62 uint32_t record_type GNUNET_PACKED;
62 63
63 /** 64 /**
64 * Flags for the record, network byte order. 65 * Flags for the record, network byte order.
65 */ 66 */
66 uint32_t flags; 67 uint32_t flags GNUNET_PACKED;
67 68
68}; 69};
69 70
71GNUNET_NETWORK_STRUCT_END
72
70 73
71/** 74/**
72 * Convert a short hash to a string (for printing debug messages). 75 * Convert a short hash to a string (for printing debug messages).
@@ -245,33 +248,35 @@ GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key
245 char * name_tmp; 248 char * name_tmp;
246 char * rd_tmp; 249 char * rd_tmp;
247 int res; 250 int res;
251 uint32_t sig_len;
248 252
249 if (NULL == name) 253 if (NULL == name)
250 { 254 {
251 GNUNET_break (0); 255 GNUNET_break (0);
252 return NULL; 256 return NULL;
253 } 257 }
254 sig = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignature)); 258 sig = GNUNET_malloc (sizeof (struct GNUNET_CRYPTO_RsaSignature));
255 name_len = strlen (name) + 1; 259 name_len = strlen (name) + 1;
256 expire_nbo = GNUNET_TIME_absolute_hton(expire); 260 expire_nbo = GNUNET_TIME_absolute_hton (expire);
257 rd_ser_len = GNUNET_NAMESTORE_records_get_size(rd_count, rd); 261 rd_ser_len = GNUNET_NAMESTORE_records_get_size (rd_count, rd);
258 { 262 {
259 char rd_ser[rd_ser_len]; 263 char rd_ser[rd_ser_len];
260 264
261 GNUNET_NAMESTORE_records_serialize(rd_count, rd, rd_ser_len, rd_ser); 265 GNUNET_assert (rd_ser_len ==
262 sig_purpose = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + rd_ser_len + name_len); 266 GNUNET_NAMESTORE_records_serialize (rd_count, rd, rd_ser_len, rd_ser));
263 sig_purpose->size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose)+ rd_ser_len + name_len); 267 sig_len = sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + rd_ser_len + name_len;
268 sig_purpose = GNUNET_malloc (sig_len);
269 sig_purpose->size = htonl (sig_len);
264 sig_purpose->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN); 270 sig_purpose->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN);
265 expire_tmp = (struct GNUNET_TIME_AbsoluteNBO *) &sig_purpose[1]; 271 expire_tmp = (struct GNUNET_TIME_AbsoluteNBO *) &sig_purpose[1];
266 name_tmp = (char *) &expire_tmp[1];
267 rd_tmp = &name_tmp[name_len];
268 memcpy (expire_tmp, &expire_nbo, sizeof (struct GNUNET_TIME_AbsoluteNBO)); 272 memcpy (expire_tmp, &expire_nbo, sizeof (struct GNUNET_TIME_AbsoluteNBO));
273 name_tmp = (char *) &expire_tmp[1];
269 memcpy (name_tmp, name, name_len); 274 memcpy (name_tmp, name, name_len);
275 rd_tmp = &name_tmp[name_len];
270 memcpy (rd_tmp, rd_ser, rd_ser_len); 276 memcpy (rd_tmp, rd_ser, rd_ser_len);
277 res = GNUNET_CRYPTO_rsa_sign (key, sig_purpose, sig);
278 GNUNET_free (sig_purpose);
271 } 279 }
272 res = GNUNET_CRYPTO_rsa_sign (key, sig_purpose, sig);
273 GNUNET_free (sig_purpose);
274
275 if (GNUNET_OK != res) 280 if (GNUNET_OK != res)
276 { 281 {
277 GNUNET_break (0); 282 GNUNET_break (0);