aboutsummaryrefslogtreecommitdiff
path: root/src/or/rendcommon.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@ev0ke.net>2015-04-21 14:04:39 -0400
committerDavid Goulet <dgoulet@ev0ke.net>2015-04-22 09:28:20 -0400
commit6f5f38a0bc60d3be9b6cf02e29b9065869cf6af8 (patch)
tree991881106ef6f00304891d767272288c379e9a00 /src/or/rendcommon.c
parenta4585405d6e103b9a48a1401321477ea08fa2ad1 (diff)
downloadtor-6f5f38a0bc60d3be9b6cf02e29b9065869cf6af8.tar.gz
tor-6f5f38a0bc60d3be9b6cf02e29b9065869cf6af8.zip
Add function to validate HS descriptor ID
Signed-off-by: David Goulet <dgoulet@ev0ke.net>
Diffstat (limited to 'src/or/rendcommon.c')
-rw-r--r--src/or/rendcommon.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c
index 95d16f1362..49827459be 100644
--- a/src/or/rendcommon.c
+++ b/src/or/rendcommon.c
@@ -919,6 +919,24 @@ rend_valid_service_id(const char *query)
return 1;
}
+/** Return true iff <b>query</b> is a syntactically valid descriptor ID.
+ * (as generated by rend_get_descriptor_id_bytes). */
+int
+rend_valid_descriptor_id(const char *query)
+{
+ if (strlen(query) != REND_DESC_ID_V2_LEN_BASE32) {
+ goto invalid;
+ }
+ if (strspn(query, BASE32_CHARS) != REND_DESC_ID_V2_LEN_BASE32) {
+ goto invalid;
+ }
+
+ return 1;
+
+invalid:
+ return 0;
+}
+
/** Lookup in the client cache the given service ID <b>query</b> for
* <b>version</b>.
*