aboutsummaryrefslogtreecommitdiff
path: root/src/gnsrecord
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-18 13:36:08 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-18 13:36:08 +0000
commit6213cb8e7ebe6d85bbd8daa8942bfeab1dd9182e (patch)
tree468b73e5202c536eec1752860b787511ea676af3 /src/gnsrecord
parent37fea746be167772c7691c2e34dce04e71aac51f (diff)
downloadgnunet-6213cb8e7ebe6d85bbd8daa8942bfeab1dd9182e.tar.gz
gnunet-6213cb8e7ebe6d85bbd8daa8942bfeab1dd9182e.zip
-convert to absolute time instead of failing
Diffstat (limited to 'src/gnsrecord')
-rw-r--r--src/gnsrecord/gnsrecord_crypto.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/gnsrecord/gnsrecord_crypto.c b/src/gnsrecord/gnsrecord_crypto.c
index 336fb93c2..9dd5365f1 100644
--- a/src/gnsrecord/gnsrecord_crypto.c
+++ b/src/gnsrecord/gnsrecord_crypto.c
@@ -92,19 +92,25 @@ GNUNET_GNSRECORD_block_create (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
92 struct GNUNET_CRYPTO_EcdsaPrivateKey *dkey; 92 struct GNUNET_CRYPTO_EcdsaPrivateKey *dkey;
93 struct GNUNET_CRYPTO_SymmetricInitializationVector iv; 93 struct GNUNET_CRYPTO_SymmetricInitializationVector iv;
94 struct GNUNET_CRYPTO_SymmetricSessionKey skey; 94 struct GNUNET_CRYPTO_SymmetricSessionKey skey;
95 struct GNUNET_GNSRECORD_Data rdc[rd_count];
95 uint32_t rd_count_nbo; 96 uint32_t rd_count_nbo;
96 unsigned int i; 97 unsigned int i;
98 struct GNUNET_TIME_Absolute now;
97 99
98 if (payload_len > GNUNET_GNSRECORD_MAX_BLOCK_SIZE) 100 if (payload_len > GNUNET_GNSRECORD_MAX_BLOCK_SIZE)
99 return NULL; 101 return NULL;
100 /* sanity check */ 102 /* convert relative to absolute times */
103 now = GNUNET_TIME_absolute_get ();
101 for (i=0;i<rd_count;i++) 104 for (i=0;i<rd_count;i++)
105 {
106 rdc[i] = rd[i];
102 if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION)) 107 if (0 != (rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
103 { 108 {
104 /* encrypted blocks must never have relative expiration times, skip! */ 109 /* encrypted blocks must never have relative expiration times, convert! */
105 GNUNET_break (0); 110 rdc[i].flags ^= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
106 return NULL; 111 rdc[i].expiration_time += now.abs_value_us;
107 } 112 }
113 }
108 /* serialize */ 114 /* serialize */
109 rd_count_nbo = htonl (rd_count); 115 rd_count_nbo = htonl (rd_count);
110 memcpy (payload, &rd_count_nbo, sizeof (uint32_t)); 116 memcpy (payload, &rd_count_nbo, sizeof (uint32_t));