|
@@ -97,6 +97,7 @@
|
|
#include "router.h"
|
|
#include "router.h"
|
|
#include "routerlist.h"
|
|
#include "routerlist.h"
|
|
#include "shared_random_state.h"
|
|
#include "shared_random_state.h"
|
|
|
|
+#include "util.h"
|
|
|
|
|
|
|
|
|
|
static const char previous_srv_str[] = "shared-rand-previous-value";
|
|
static const char previous_srv_str[] = "shared-rand-previous-value";
|
|
@@ -461,8 +462,9 @@ get_vote_line_from_commit(const sr_commit_t *commit, sr_phase_t phase)
|
|
|
|
|
|
switch (phase) {
|
|
switch (phase) {
|
|
case SR_PHASE_COMMIT:
|
|
case SR_PHASE_COMMIT:
|
|
- tor_asprintf(&vote_line, "%s %s %s %s\n",
|
|
+ tor_asprintf(&vote_line, "%s %u %s %s %s\n",
|
|
commit_ns_str,
|
|
commit_ns_str,
|
|
|
|
+ SR_PROTO_VERSION,
|
|
crypto_digest_algorithm_get_name(commit->alg),
|
|
crypto_digest_algorithm_get_name(commit->alg),
|
|
sr_commit_get_rsa_fpr(commit),
|
|
sr_commit_get_rsa_fpr(commit),
|
|
commit->encoded_commit);
|
|
commit->encoded_commit);
|
|
@@ -475,8 +477,9 @@ get_vote_line_from_commit(const sr_commit_t *commit, sr_phase_t phase)
|
|
sizeof(commit->encoded_reveal))) {
|
|
sizeof(commit->encoded_reveal))) {
|
|
reveal_str = "";
|
|
reveal_str = "";
|
|
}
|
|
}
|
|
- tor_asprintf(&vote_line, "%s %s %s %s %s\n",
|
|
+ tor_asprintf(&vote_line, "%s %u %s %s %s %s\n",
|
|
commit_ns_str,
|
|
commit_ns_str,
|
|
|
|
+ SR_PROTO_VERSION,
|
|
crypto_digest_algorithm_get_name(commit->alg),
|
|
crypto_digest_algorithm_get_name(commit->alg),
|
|
sr_commit_get_rsa_fpr(commit),
|
|
sr_commit_get_rsa_fpr(commit),
|
|
commit->encoded_commit, reveal_str);
|
|
commit->encoded_commit, reveal_str);
|
|
@@ -1040,22 +1043,33 @@ sr_parse_srv(const smartlist_t *args)
|
|
* allocated commit object. NULL is returned on error.
|
|
* allocated commit object. NULL is returned on error.
|
|
*
|
|
*
|
|
* The commit's data is in <b>args</b> and the order matters very much:
|
|
* The commit's data is in <b>args</b> and the order matters very much:
|
|
- * algname, RSA fingerprint, commit value[, reveal value]
|
|
+ * version, algname, RSA fingerprint, commit value[, reveal value]
|
|
*/
|
|
*/
|
|
sr_commit_t *
|
|
sr_commit_t *
|
|
sr_parse_commit(const smartlist_t *args)
|
|
sr_parse_commit(const smartlist_t *args)
|
|
{
|
|
{
|
|
|
|
+ uint32_t version;
|
|
char *value, digest[DIGEST_LEN];
|
|
char *value, digest[DIGEST_LEN];
|
|
digest_algorithm_t alg;
|
|
digest_algorithm_t alg;
|
|
const char *rsa_identity_fpr;
|
|
const char *rsa_identity_fpr;
|
|
sr_commit_t *commit = NULL;
|
|
sr_commit_t *commit = NULL;
|
|
|
|
|
|
- if (smartlist_len(args) < 3) {
|
|
+ if (smartlist_len(args) < 4) {
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+
|
|
|
|
+ * version that commit was created. */
|
|
value = smartlist_get(args, 0);
|
|
value = smartlist_get(args, 0);
|
|
|
|
+ version = (uint32_t) tor_parse_ulong(value, 10, 1, UINT32_MAX, NULL, NULL);
|
|
|
|
+ if (version > SR_PROTO_VERSION) {
|
|
|
|
+ log_info(LD_DIR, "SR: Commit version %" PRIu32 " (%s) is not supported.",
|
|
|
|
+ version, escaped(value));
|
|
|
|
+ goto error;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ value = smartlist_get(args, 1);
|
|
alg = crypto_digest_algorithm_parse_name(value);
|
|
alg = crypto_digest_algorithm_parse_name(value);
|
|
if (alg != SR_DIGEST_ALG) {
|
|
if (alg != SR_DIGEST_ALG) {
|
|
log_warn(LD_BUG, "SR: Commit algorithm %s is not recognized.",
|
|
log_warn(LD_BUG, "SR: Commit algorithm %s is not recognized.",
|
|
@@ -1063,9 +1077,9 @@ sr_parse_commit(const smartlist_t *args)
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+
|
|
* digest value. */
|
|
* digest value. */
|
|
- rsa_identity_fpr = smartlist_get(args, 1);
|
|
+ rsa_identity_fpr = smartlist_get(args, 2);
|
|
if (base16_decode(digest, DIGEST_LEN, rsa_identity_fpr,
|
|
if (base16_decode(digest, DIGEST_LEN, rsa_identity_fpr,
|
|
HEX_DIGEST_LEN) < 0) {
|
|
HEX_DIGEST_LEN) < 0) {
|
|
log_warn(LD_DIR, "SR: RSA fingerprint '%s' not decodable",
|
|
log_warn(LD_DIR, "SR: RSA fingerprint '%s' not decodable",
|
|
@@ -1085,15 +1099,15 @@ sr_parse_commit(const smartlist_t *args)
|
|
|
|
|
|
commit = commit_new(digest);
|
|
commit = commit_new(digest);
|
|
|
|
|
|
-
|
|
+
|
|
- value = smartlist_get(args, 2);
|
|
+ value = smartlist_get(args, 3);
|
|
if (commit_decode(value, commit) < 0) {
|
|
if (commit_decode(value, commit) < 0) {
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+
|
|
- if (smartlist_len(args) > 3) {
|
|
+ if (smartlist_len(args) > 4) {
|
|
- value = smartlist_get(args, 3);
|
|
+ value = smartlist_get(args, 4);
|
|
if (reveal_decode(value, commit) < 0) {
|
|
if (reveal_decode(value, commit) < 0) {
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|