aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_uri.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-08-11 22:17:14 +0000
committerChristian Grothoff <christian@grothoff.org>2013-08-11 22:17:14 +0000
commita373d56479f2b94028fd79f999094e0147256ca4 (patch)
tree05df2e8a5ece6fbcfa0858add5c135aa270d5779 /src/fs/fs_uri.c
parent91e71fcc1220782798e349b66853fda27f2cd108 (diff)
downloadgnunet-a373d56479f2b94028fd79f999094e0147256ca4.tar.gz
gnunet-a373d56479f2b94028fd79f999094e0147256ca4.zip
-round expiration times to full seconds
Diffstat (limited to 'src/fs/fs_uri.c')
-rw-r--r--src/fs/fs_uri.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c
index 6724dc625..72704828d 100644
--- a/src/fs/fs_uri.c
+++ b/src/fs/fs_uri.c
@@ -588,7 +588,7 @@ uri_loc_parse (const char *s, char **emsg)
588 SSCANF (&s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2], 588 SSCANF (&s[pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) * 2],
589 "%llu", &flen))) 589 "%llu", &flen)))
590 { 590 {
591 *emsg = GNUNET_strdup (_("SKS URI malformed")); 591 *emsg = GNUNET_strdup (_("LOC URI malformed"));
592 return NULL; 592 return NULL;
593 } 593 }
594 ass.fi.file_length = GNUNET_htonll (flen); 594 ass.fi.file_length = GNUNET_htonll (flen);
@@ -598,7 +598,7 @@ uri_loc_parse (const char *s, char **emsg)
598 npos++; 598 npos++;
599 if (s[npos] == '\0') 599 if (s[npos] == '\0')
600 { 600 {
601 *emsg = GNUNET_strdup (_("SKS URI malformed")); 601 *emsg = GNUNET_strdup (_("LOC URI malformed"));
602 goto ERR; 602 goto ERR;
603 } 603 }
604 npos++; 604 npos++;
@@ -608,7 +608,7 @@ uri_loc_parse (const char *s, char **emsg)
608 if (ret == -1) 608 if (ret == -1)
609 { 609 {
610 *emsg = 610 *emsg =
611 GNUNET_strdup (_("SKS URI malformed (could not decode public key)")); 611 GNUNET_strdup (_("LOC URI malformed (could not decode public key)"));
612 goto ERR; 612 goto ERR;
613 } 613 }
614 npos += ret; 614 npos += ret;
@@ -900,6 +900,7 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri,
900 struct GNUNET_CRYPTO_EccPublicKey my_public_key; 900 struct GNUNET_CRYPTO_EccPublicKey my_public_key;
901 char *keyfile; 901 char *keyfile;
902 struct LocUriAssembly ass; 902 struct LocUriAssembly ass;
903 struct GNUNET_TIME_Absolute et;
903 904
904 if (baseUri->type != GNUNET_FS_URI_CHK) 905 if (baseUri->type != GNUNET_FS_URI_CHK)
905 return NULL; 906 return NULL;
@@ -919,16 +920,18 @@ GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri,
919 return NULL; 920 return NULL;
920 } 921 }
921 GNUNET_free (keyfile); 922 GNUNET_free (keyfile);
923 /* we round expiration time to full seconds for SKS URIs */
924 et.abs_value_us = (expiration_time.abs_value_us / 1000000LL) * 1000000LL;
922 GNUNET_CRYPTO_ecc_key_get_public (my_private_key, &my_public_key); 925 GNUNET_CRYPTO_ecc_key_get_public (my_private_key, &my_public_key);
923 ass.purpose.size = htonl (sizeof (struct LocUriAssembly)); 926 ass.purpose.size = htonl (sizeof (struct LocUriAssembly));
924 ass.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT); 927 ass.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_PEER_PLACEMENT);
925 ass.exptime = GNUNET_TIME_absolute_hton (expiration_time); 928 ass.exptime = GNUNET_TIME_absolute_hton (et);
926 ass.fi = baseUri->data.chk; 929 ass.fi = baseUri->data.chk;
927 ass.peer = my_public_key; 930 ass.peer = my_public_key;
928 uri = GNUNET_new (struct GNUNET_FS_Uri); 931 uri = GNUNET_new (struct GNUNET_FS_Uri);
929 uri->type = GNUNET_FS_URI_LOC; 932 uri->type = GNUNET_FS_URI_LOC;
930 uri->data.loc.fi = baseUri->data.chk; 933 uri->data.loc.fi = baseUri->data.chk;
931 uri->data.loc.expirationTime = expiration_time; 934 uri->data.loc.expirationTime = et;
932 uri->data.loc.peer = my_public_key; 935 uri->data.loc.peer = my_public_key;
933 GNUNET_assert (GNUNET_OK == 936 GNUNET_assert (GNUNET_OK ==
934 GNUNET_CRYPTO_ecc_sign (my_private_key, &ass.purpose, 937 GNUNET_CRYPTO_ecc_sign (my_private_key, &ass.purpose,
@@ -2037,7 +2040,7 @@ uri_loc_to_string (const struct GNUNET_FS_Uri *uri)
2037 (unsigned long long) GNUNET_ntohll (uri->data.loc. 2040 (unsigned long long) GNUNET_ntohll (uri->data.loc.
2038 fi.file_length), peerId, 2041 fi.file_length), peerId,
2039 peerSig, 2042 peerSig,
2040 (unsigned long long) uri->data.loc.expirationTime.abs_value_us / 1000LL / 1000LL); 2043 (unsigned long long) uri->data.loc.expirationTime.abs_value_us / 1000000LL);
2041 GNUNET_free (peerSig); 2044 GNUNET_free (peerSig);
2042 GNUNET_free (peerId); 2045 GNUNET_free (peerId);
2043 return ret; 2046 return ret;