summaryrefslogtreecommitdiff
path: root/src/or/shared_random.h
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2016-05-03 10:57:49 -0400
committerDavid Goulet <dgoulet@torproject.org>2016-07-01 13:23:27 -0400
commit5b183328fdd4bf81a3a38afe88d2766e61773fb9 (patch)
treeab21de7b641144ce46392f9cb38892d8dbf5c807 /src/or/shared_random.h
parentb3b4ffce2e23bfb6a2af374cd8bfa5981628a342 (diff)
downloadtor-5b183328fdd4bf81a3a38afe88d2766e61773fb9.tar.gz
tor-5b183328fdd4bf81a3a38afe88d2766e61773fb9.zip
prop250: Add commit and SR values generation code
This adds the logic of commit and SR values generation. Furthermore, the concept of a protocol run is added that is commit is generated at the right time as well as SR values which are also rotated before a new protocol run. Signed-off-by: George Kadianakis <desnacked@riseup.net> Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/shared_random.h')
-rw-r--r--src/or/shared_random.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/or/shared_random.h b/src/or/shared_random.h
index 447de0c4b5..878bfbff45 100644
--- a/src/or/shared_random.h
+++ b/src/or/shared_random.h
@@ -42,6 +42,11 @@
* Formula is taken from base64_encode_size. This adds up to 56 bytes. */
#define SR_REVEAL_BASE64_LEN \
(((SR_REVEAL_LEN - 1) / 3) * 4 + 4)
+/* Length of base64 encoded shared random value. It's 32 bytes long so 44
+ * bytes from the base64_encode_size formula. That includes the '='
+ * character at the end. */
+#define SR_SRV_VALUE_BASE64_LEN \
+ (((DIGEST256_LEN - 1) / 3) * 4 + 4)
/* Protocol phase. */
typedef enum {
@@ -97,18 +102,27 @@ typedef struct sr_commit_t {
int sr_init(int save_to_disk);
void sr_save_and_cleanup(void);
void sr_commit_free(sr_commit_t *commit);
+void sr_srv_encode(char *dst, const sr_srv_t *srv);
/* Private methods (only used by shared_random_state.c): */
sr_commit_t *sr_parse_commit(const smartlist_t *args);
sr_srv_t *sr_parse_srv(const smartlist_t *args);
+void sr_compute_srv(void);
+sr_commit_t *sr_generate_our_commit(time_t timestamp,
+ const authority_cert_t *my_rsa_cert);
#ifdef SHARED_RANDOM_PRIVATE
+/* Encode */
+STATIC int reveal_encode(const sr_commit_t *commit, char *dst, size_t len);
+STATIC int commit_encode(const sr_commit_t *commit, char *dst, size_t len);
/* Decode. */
STATIC int commit_decode(const char *encoded, sr_commit_t *commit);
STATIC int reveal_decode(const char *encoded, sr_commit_t *commit);
+STATIC int commit_has_reveal_value(const sr_commit_t *commit);
+
#endif /* SHARED_RANDOM_PRIVATE */
#endif /* TOR_SHARED_RANDOM_H */