commit c0cec2ffd3d5f965413f56e93f89fabf81a2c3a0 Author: David Goulet dgoulet@ev0ke.net Date: Mon May 9 16:51:32 2016 -0400
prop250: change time_t to uint64_t
Signed-off-by: David Goulet dgoulet@ev0ke.net --- src/or/shared_random.c | 27 ++++++++++----------------- src/or/shared_random.h | 4 ++-- 2 files changed, 12 insertions(+), 19 deletions(-)
diff --git a/src/or/shared_random.c b/src/or/shared_random.c index e3fe1a9..f5f4ccf 100644 --- a/src/or/shared_random.c +++ b/src/or/shared_random.c @@ -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, diff --git a/src/or/shared_random.h b/src/or/shared_random.h index d52258c..15eed8a 100644 --- a/src/or/shared_random.h +++ b/src/or/shared_random.h @@ -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;
tor-commits@lists.torproject.org