aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/namestore_common.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-03-09 14:14:01 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-03-09 14:14:01 +0000
commit5e828dc0248330d772913795257b3fda14fe9552 (patch)
tree362ecdb95dcb89c56a7f20d31b06efa7351fe8ba /src/namestore/namestore_common.c
parent780fdda9a42441ecf36482461ebd35e4ec5c7510 (diff)
downloadgnunet-5e828dc0248330d772913795257b3fda14fe9552.tar.gz
gnunet-5e828dc0248330d772913795257b3fda14fe9552.zip
- changes to signing verfifying: includes block expiration
Diffstat (limited to 'src/namestore/namestore_common.c')
-rw-r--r--src/namestore/namestore_common.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/namestore/namestore_common.c b/src/namestore/namestore_common.c
index 311388b14..b8236edf0 100644
--- a/src/namestore/namestore_common.c
+++ b/src/namestore/namestore_common.c
@@ -198,6 +198,7 @@ GNUNET_NAMESTORE_records_deserialize (size_t len,
198 * Sign name and records 198 * Sign name and records
199 * 199 *
200 * @param key the private key 200 * @param key the private key
201 * @param expire block expiration
201 * @param name the name 202 * @param name the name
202 * @param rd record data 203 * @param rd record data
203 * @param rd_count number of records 204 * @param rd_count number of records
@@ -206,14 +207,18 @@ GNUNET_NAMESTORE_records_deserialize (size_t len,
206 */ 207 */
207struct GNUNET_CRYPTO_RsaSignature * 208struct GNUNET_CRYPTO_RsaSignature *
208GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key, 209GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key,
210 struct GNUNET_TIME_Absolute expire,
209 const char *name, 211 const char *name,
210 const struct GNUNET_NAMESTORE_RecordData *rd, 212 const struct GNUNET_NAMESTORE_RecordData *rd,
211 unsigned int rd_count) 213 unsigned int rd_count)
212{ 214{
213 struct GNUNET_CRYPTO_RsaSignature *sig = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignature)); 215 struct GNUNET_CRYPTO_RsaSignature *sig = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignature));
214 struct GNUNET_CRYPTO_RsaSignaturePurpose *sig_purpose; 216 struct GNUNET_CRYPTO_RsaSignaturePurpose *sig_purpose;
217 struct GNUNET_TIME_AbsoluteNBO expire_nbo = GNUNET_TIME_absolute_hton(expire);
215 size_t rd_ser_len; 218 size_t rd_ser_len;
216 size_t name_len; 219 size_t name_len;
220
221 struct GNUNET_TIME_AbsoluteNBO *expire_tmp;
217 char * name_tmp; 222 char * name_tmp;
218 char * rd_tmp; 223 char * rd_tmp;
219 int res; 224 int res;
@@ -230,12 +235,13 @@ GNUNET_NAMESTORE_create_signature (const struct GNUNET_CRYPTO_RsaPrivateKey *key
230 char rd_ser[rd_ser_len]; 235 char rd_ser[rd_ser_len];
231 GNUNET_NAMESTORE_records_serialize(rd_count, rd, rd_ser_len, rd_ser); 236 GNUNET_NAMESTORE_records_serialize(rd_count, rd, rd_ser_len, rd_ser);
232 237
233 sig_purpose = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + rd_ser_len + name_len); 238 sig_purpose = GNUNET_malloc(sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) + sizeof (struct GNUNET_TIME_AbsoluteNBO) + rd_ser_len + name_len);
234
235 sig_purpose->size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose)+ rd_ser_len + name_len); 239 sig_purpose->size = htonl (sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose)+ rd_ser_len + name_len);
236 sig_purpose->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN); 240 sig_purpose->purpose = htonl (GNUNET_SIGNATURE_PURPOSE_GNS_RECORD_SIGN);
237 name_tmp = (char *) &sig_purpose[1]; 241 expire_tmp = (struct GNUNET_TIME_AbsoluteNBO *) &sig_purpose[1];
242 name_tmp = (char *) &expire_tmp[1];
238 rd_tmp = &name_tmp[name_len]; 243 rd_tmp = &name_tmp[name_len];
244 memcpy (expire_tmp, &expire_nbo, sizeof (struct GNUNET_TIME_AbsoluteNBO));
239 memcpy (name_tmp, name, name_len); 245 memcpy (name_tmp, name, name_len);
240 memcpy (rd_tmp, rd_ser, rd_ser_len); 246 memcpy (rd_tmp, rd_ser, rd_ser_len);
241 247