]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
prop250: change time_t to uint64_t
authorDavid Goulet <dgoulet@ev0ke.net>
Mon, 9 May 2016 20:51:32 +0000 (16:51 -0400)
committerDavid Goulet <dgoulet@torproject.org>
Fri, 1 Jul 2016 18:01:41 +0000 (14:01 -0400)
Signed-off-by: David Goulet <dgoulet@ev0ke.net>
src/or/shared_random.c
src/or/shared_random.h

index e3fe1a9e733020cbf5f2dbd43ac3858dc176ea1d..f5f4ccf9f5196896a0d87a1be9ab65d640dc603a 100644 (file)
@@ -144,18 +144,10 @@ commit_log(const sr_commit_t *commit)
   tor_assert(commit);
 
   log_debug(LD_DIR, "SR: Commit from %s", commit->rsa_identity_fpr);
-
-  if (commit->commit_ts >= 0) {
-    log_debug(LD_DIR, "SR: Commit: [TS: %ld] [Encoded: %s]",
-              commit->commit_ts, commit->encoded_commit);
-  }
-
-  if (commit->reveal_ts >= 0) {
-    log_debug(LD_DIR, "SR: Reveal: [TS: %ld] [Encoded: %s]",
-              commit->reveal_ts, safe_str(commit->encoded_reveal));
-  } else {
-    log_debug(LD_DIR, "SR: Reveal: UNKNOWN");
-  }
+  log_debug(LD_DIR, "SR: Commit: [TS: %" PRIu64 "] [Encoded: %s]",
+            commit->commit_ts, commit->encoded_commit);
+  log_debug(LD_DIR, "SR: Reveal: [TS: %" PRIu64 "] [Encoded: %s]",
+            commit->reveal_ts, safe_str(commit->encoded_reveal));
 }
 
 /* Make sure that the commitment and reveal information in <b>commit</b>
@@ -172,8 +164,9 @@ verify_commit_and_reveal(const sr_commit_t *commit)
 
   /* Check that the timestamps match. */
   if (commit->commit_ts != commit->reveal_ts) {
-    log_warn(LD_BUG, "SR: Commit timestamp %ld doesn't match reveal "
-                     "timestamp %ld", commit->commit_ts, commit->reveal_ts);
+    log_warn(LD_BUG, "SR: Commit timestamp %" PRIu64 " doesn't match reveal "
+                     "timestamp %" PRIu64, commit->commit_ts,
+             commit->reveal_ts);
     goto invalid;
   }
 
@@ -261,7 +254,7 @@ commit_decode(const char *encoded, sr_commit_t *commit)
   }
 
   /* First is the timestamp (8 bytes). */
-  commit->commit_ts = (time_t) tor_ntohll(get_uint64(b64_decoded));
+  commit->commit_ts = tor_ntohll(get_uint64(b64_decoded));
   offset += sizeof(uint64_t);
   /* Next is hashed reveal. */
   memcpy(commit->hashed_reveal, b64_decoded + offset,
@@ -313,7 +306,7 @@ reveal_decode(const char *encoded, sr_commit_t *commit)
     goto error;
   }
 
-  commit->reveal_ts = (time_t) tor_ntohll(get_uint64(b64_decoded));
+  commit->reveal_ts = tor_ntohll(get_uint64(b64_decoded));
   /* Copy the last part, the random value. */
   memcpy(commit->random_number, b64_decoded + 8,
          sizeof(commit->random_number));
@@ -371,7 +364,7 @@ commit_encode(const sr_commit_t *commit, char *dst, size_t len)
   tor_assert(dst);
 
   /* First is the timestamp (8 bytes). */
-  set_uint64(buf, tor_htonll((uint64_t) commit->commit_ts));
+  set_uint64(buf, tor_htonll(commit->commit_ts));
   offset += sizeof(uint64_t);
   /* and then the hashed reveal. */
   memcpy(buf + offset, commit->hashed_reveal,
index d52258c6e22d92dda1d3a8258907ed0b8cde8fa2..15eed8a25c17f6b0fca0e65dfe7abdbc862b41a9 100644 (file)
@@ -77,7 +77,7 @@ typedef struct sr_commit_t {
   /* Commitment information */
 
   /* Timestamp of reveal. Correspond to TIMESTAMP. */
-  time_t reveal_ts;
+  uint64_t reveal_ts;
   /* H(REVEAL) as found in COMMIT message. */
   char hashed_reveal[DIGEST256_LEN];
   /* Base64 encoded COMMIT. We use this to put it in our vote. */
@@ -90,7 +90,7 @@ typedef struct sr_commit_t {
    * avoiding possible information leaks of our PRNG. */
   uint8_t random_number[SR_RANDOM_NUMBER_LEN];
   /* Timestamp of commit. Correspond to TIMESTAMP. */
-  time_t commit_ts;
+  uint64_t commit_ts;
   /* This is the whole reveal message. We use it during verification */
   char encoded_reveal[SR_REVEAL_BASE64_LEN + 1];
 } sr_commit_t;