aboutsummaryrefslogtreecommitdiff
path: root/src/core/or/sendme.h
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2019-05-07 09:44:10 -0400
committerNick Mathewson <nickm@torproject.org>2019-05-22 11:47:20 -0400
commit44265dd6716887b997bb03d2db1641efd7ae9c19 (patch)
tree35c6f54c71deb7442f8d489c4e7b4f6a5d00a093 /src/core/or/sendme.h
parent69e0d5bfc7d52f223d686bcd87f629f01b03561a (diff)
downloadtor-44265dd6716887b997bb03d2db1641efd7ae9c19.tar.gz
tor-44265dd6716887b997bb03d2db1641efd7ae9c19.zip
sendme: Never fallback to v0 if unknown version
There was a missing cell version check against our max supported version. In other words, we do not fallback to v0 anymore in case we do know the SENDME version. We can either handle it or not, never fallback to the unauthenticated version in order to avoid gaming the authenticated logic. Add a unit tests making sure we properly test that and also test that we can always handle the default emit and accepted versions. Fixes #30428 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/core/or/sendme.h')
-rw-r--r--src/core/or/sendme.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/core/or/sendme.h b/src/core/or/sendme.h
index 2fb73f76d9..a71891996b 100644
--- a/src/core/or/sendme.h
+++ b/src/core/or/sendme.h
@@ -45,6 +45,20 @@ bool sendme_circuit_cell_is_next(int window);
/* Private section starts. */
#ifdef SENDME_PRIVATE
+/* The maximum supported version. Above that value, the cell can't be
+ * recognized as a valid SENDME. */
+#define SENDME_MAX_SUPPORTED_VERSION 1
+
+/* The cell version constants for when emitting a cell. */
+#define SENDME_EMIT_MIN_VERSION_DEFAULT 0
+#define SENDME_EMIT_MIN_VERSION_MIN 0
+#define SENDME_EMIT_MIN_VERSION_MAX UINT8_MAX
+
+/* The cell version constants for when accepting a cell. */
+#define SENDME_ACCEPT_MIN_VERSION_DEFAULT 0
+#define SENDME_ACCEPT_MIN_VERSION_MIN 0
+#define SENDME_ACCEPT_MIN_VERSION_MAX UINT8_MAX
+
/*
* Unit tests declaractions.
*/
@@ -53,7 +67,7 @@ bool sendme_circuit_cell_is_next(int window);
STATIC int get_emit_min_version(void);
STATIC int get_accept_min_version(void);
-STATIC bool cell_version_is_valid(uint8_t cell_version);
+STATIC bool cell_version_can_be_handled(uint8_t cell_version);
STATIC ssize_t build_cell_payload_v1(const uint8_t *cell_digest,
uint8_t *payload);