|
@@ -688,37 +688,6 @@ rend_get_service_id(crypto_pk_t *pk, char *out)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-/** Determines whether <b>a</b> is in the interval of <b>b</b> (excluded) and
|
|
|
- * <b>c</b> (included) in a circular digest ring; returns 1 if this is the
|
|
|
- * case, and 0 otherwise.
|
|
|
- */
|
|
|
-int
|
|
|
-rend_id_is_in_interval(const char *a, const char *b, const char *c)
|
|
|
-{
|
|
|
- int a_b, b_c, c_a;
|
|
|
- tor_assert(a);
|
|
|
- tor_assert(b);
|
|
|
- tor_assert(c);
|
|
|
-
|
|
|
- /* There are five cases in which a is outside the interval ]b,c]: */
|
|
|
- a_b = tor_memcmp(a,b,DIGEST_LEN);
|
|
|
- if (a_b == 0)
|
|
|
- return 0; /* 1. a == b (b is excluded) */
|
|
|
- b_c = tor_memcmp(b,c,DIGEST_LEN);
|
|
|
- if (b_c == 0)
|
|
|
- return 0; /* 2. b == c (interval is empty) */
|
|
|
- else if (a_b <= 0 && b_c < 0)
|
|
|
- return 0; /* 3. a b c */
|
|
|
- c_a = tor_memcmp(c,a,DIGEST_LEN);
|
|
|
- if (c_a < 0 && a_b <= 0)
|
|
|
- return 0; /* 4. c a b */
|
|
|
- else if (b_c < 0 && c_a < 0)
|
|
|
- return 0; /* 5. b c a */
|
|
|
-
|
|
|
- /* In the other cases (a c b; b a c; c b a), a is inside the interval. */
|
|
|
- return 1;
|
|
|
-}
|
|
|
-
|
|
|
/** Return true iff <b>query</b> is a syntactically valid service ID (as
|
|
|
* generated by rend_get_service_id). */
|
|
|
int
|