[tor-commits] [stem/master] Stub hidden service descriptor v3
atagar at torproject.org
atagar at torproject.org
Sun Aug 25 00:20:44 UTC 2019
commit 26ed95d4b09505fa1320b0e8de0cc271776fe95d
Author: Damian Johnson <atagar at torproject.org>
Date: Thu Aug 22 15:55:46 2019 -0700
Stub hidden service descriptor v3
Doesn't do anything yet - just getting the class and such wired up.
---
stem/descriptor/__init__.py | 13 +-
stem/descriptor/hidden_service.py | 32 +++-
test/settings.cfg | 1 +
test/unit/descriptor/data/hidden_service_v3 | 223 ++++++++++++++++++++++++++++
test/unit/descriptor/hidden_service_v2.py | 26 ++--
test/unit/descriptor/hidden_service_v3.py | 19 +++
6 files changed, 288 insertions(+), 26 deletions(-)
diff --git a/stem/descriptor/__init__.py b/stem/descriptor/__init__.py
index 9415454c..1b5e53bc 100644
--- a/stem/descriptor/__init__.py
+++ b/stem/descriptor/__init__.py
@@ -532,18 +532,19 @@ def _parse_metrics_file(descriptor_type, major_version, minor_version, descripto
for desc in stem.descriptor.networkstatus._parse_file(descriptor_file, document_type, validate = validate, document_handler = document_handler, **kwargs):
yield desc
elif descriptor_type == stem.descriptor.tordnsel.TorDNSEL.TYPE_ANNOTATION_NAME and major_version == 1:
- document_type = stem.descriptor.tordnsel.TorDNSEL
-
for desc in stem.descriptor.tordnsel._parse_file(descriptor_file, validate = validate, **kwargs):
yield desc
elif descriptor_type == stem.descriptor.hidden_service.HiddenServiceDescriptorV2.TYPE_ANNOTATION_NAME and major_version == 1:
- document_type = stem.descriptor.hidden_service.HiddenServiceDescriptorV2
+ desc_type = stem.descriptor.hidden_service.HiddenServiceDescriptorV2
- for desc in stem.descriptor.hidden_service._parse_file(descriptor_file, validate = validate, **kwargs):
+ for desc in stem.descriptor.hidden_service._parse_file(descriptor_file, desc_type, validate = validate, **kwargs):
yield desc
- elif descriptor_type == stem.descriptor.bandwidth_file.BandwidthFile.TYPE_ANNOTATION_NAME and major_version == 1:
- document_type = stem.descriptor.bandwidth_file.BandwidthFile
+ elif descriptor_type == stem.descriptor.hidden_service.HiddenServiceDescriptorV3.TYPE_ANNOTATION_NAME and major_version == 1:
+ desc_type = stem.descriptor.hidden_service.HiddenServiceDescriptorV3
+ for desc in stem.descriptor.hidden_service._parse_file(descriptor_file, desc_type, validate = validate, **kwargs):
+ yield desc
+ elif descriptor_type == stem.descriptor.bandwidth_file.BandwidthFile.TYPE_ANNOTATION_NAME and major_version == 1:
for desc in stem.descriptor.bandwidth_file._parse_file(descriptor_file, validate = validate, **kwargs):
yield desc
else:
diff --git a/stem/descriptor/hidden_service.py b/stem/descriptor/hidden_service.py
index ab5699f6..1ed100ef 100644
--- a/stem/descriptor/hidden_service.py
+++ b/stem/descriptor/hidden_service.py
@@ -17,7 +17,8 @@ These are only available through the Controller's
::
BaseHiddenServiceDescriptor - Common parent for hidden service descriptors
- +- HiddenServiceDescriptorV2 - Version 2 hidden service descriptor
+ |- HiddenServiceDescriptorV2 - Version 2 hidden service descriptor
+ +- HiddenServiceDescriptorV3 - Version 3 hidden service descriptor
.. versionadded:: 1.4.0
"""
@@ -103,11 +104,12 @@ class DecryptionFailure(Exception):
"""
-def _parse_file(descriptor_file, validate = False, **kwargs):
+def _parse_file(descriptor_file, desc_type = None, validate = False, **kwargs):
"""
Iterates over the hidden service descriptors in a file.
:param file descriptor_file: file with descriptor content
+ :param class desc_type: BaseHiddenServiceDescriptor subclass
:param bool validate: checks the validity of the descriptor's content if
**True**, skips these checks otherwise
:param dict kwargs: additional arguments for the descriptor constructor
@@ -120,18 +122,24 @@ def _parse_file(descriptor_file, validate = False, **kwargs):
* **IOError** if the file can't be read
"""
+ if desc_type is None:
+ desc_type = HiddenServiceDescriptorV2
+
+ # Hidden service v3 ends with a signature line, whereas v2 has a pgp style
+ # block following it.
+
while True:
descriptor_content = _read_until_keywords('signature', descriptor_file)
- # we've reached the 'signature', now include the pgp style block
- block_end_prefix = PGP_BLOCK_END.split(' ', 1)[0]
- descriptor_content += _read_until_keywords(block_end_prefix, descriptor_file, True)
+ if desc_type == HiddenServiceDescriptorV2:
+ block_end_prefix = PGP_BLOCK_END.split(' ', 1)[0]
+ descriptor_content += _read_until_keywords(block_end_prefix, descriptor_file, True)
if descriptor_content:
if descriptor_content[0].startswith(b'@type'):
descriptor_content = descriptor_content[1:]
- yield HiddenServiceDescriptorV2(bytes.join(b'', descriptor_content), validate, **kwargs)
+ yield desc_type(bytes.join(b'', descriptor_content), validate, **kwargs)
else:
break # done parsing file
@@ -194,7 +202,7 @@ class BaseHiddenServiceDescriptor(Descriptor):
class HiddenServiceDescriptorV2(BaseHiddenServiceDescriptor):
"""
- Hidden service descriptor.
+ Version 2 hidden service descriptor.
:var str descriptor_id: **\\*** identifier for this descriptor, this is a base32 hash of several fields
:var int version: **\\*** hidden service descriptor version
@@ -452,6 +460,16 @@ class HiddenServiceDescriptorV2(BaseHiddenServiceDescriptor):
return introduction_points
+class HiddenServiceDescriptorV3(BaseHiddenServiceDescriptor):
+ """
+ Version 3 hidden service descriptor.
+ """
+
+ # TODO: requested this @type on https://trac.torproject.org/projects/tor/ticket/31481
+
+ TYPE_ANNOTATION_NAME = 'hidden-service-descriptor-3'
+
+
# TODO: drop this alias in stem 2.x
HiddenServiceDescriptor = HiddenServiceDescriptorV2
diff --git a/test/settings.cfg b/test/settings.cfg
index 2e6b29dd..1b971bb4 100644
--- a/test/settings.cfg
+++ b/test/settings.cfg
@@ -259,6 +259,7 @@ test.unit_tests
|test.unit.descriptor.networkstatus.document_v3.TestNetworkStatusDocument
|test.unit.descriptor.networkstatus.bridge_document.TestBridgeNetworkStatusDocument
|test.unit.descriptor.hidden_service_v2.TestHiddenServiceDescriptorV2
+|test.unit.descriptor.hidden_service_v3.TestHiddenServiceDescriptorV3
|test.unit.descriptor.certificate.TestEd25519Certificate
|test.unit.descriptor.bandwidth_file.TestBandwidthFile
|test.unit.exit_policy.rule.TestExitPolicyRule
diff --git a/test/unit/descriptor/data/hidden_service_v3 b/test/unit/descriptor/data/hidden_service_v3
new file mode 100644
index 00000000..c67ae292
--- /dev/null
+++ b/test/unit/descriptor/data/hidden_service_v3
@@ -0,0 +1,223 @@
+hs-descriptor 3
+descriptor-lifetime 180
+descriptor-signing-key-cert
+-----BEGIN ED25519 CERT-----
+AQgABqKwAQVql1QZETyEwJjg+Cv6f2w/cp+c3juj01NPBaJqihboAQAgBACx+FKK
+oDrFE1+ztSxzN8sApKOb5UuDtoe/E03DxZU5+r/K5AV6G0hYn21V7Xbu2pZHvIkT
+2oVY4hypWNJE58eFBRFRzBA0J2h0GyFs1pIuRh5QDJuxB5j92V0aRCNZFgM=
+-----END ED25519 CERT-----
+revision-counter 15
+superencrypted
+-----BEGIN MESSAGE-----
+YV7v2WFW+QMHk8n36V/crqdVafq55cNAH26jALNEHex0GmgcvXqJovpHQj3+yKQn
+LysSkEV9JW0deXY8RKsq18c6uZnSnbHCRnFgptac/YfTzOBnt/q6eav4zGwiGJjm
+jt5DLXDO6ONI/AxGaPZoV+ol1h+Ku1zodTCFEO+mbi14x9Xc7YnXhR9nliDJCml9
+/dSHJj4YrdBIZjMQA0vidh6BbwGMuVGVtw9oVMg1uhZDjbJCrG7Q7afWmlMyG3rJ
+qaAKGNMoFvD2QWaiDCMK/zNzMX7n3yMFPxOW95Vd1YwgSFwLxsQ3pWAsVUKWAbZU
+G8nnbzgVvTdO1Z+j8fabMksHPGBNvGiHN+GB0cBvtL4eU9+bTmU90RsrGtVmH35K
+XNVu66VtRITFk9uKnDpxhkH0h1hHGep3X29aK6yAnNfL8QCoyUieYK2pncIdom6C
+wgnvF3Rd/d49Lv9z1Qa1Wm0vSrTG7bjAY7rVM8w3ZFE1lH8Y6cMSKubuQvMOE5NN
+D1FlL6Jd8FjYPZ9MkkDItBapGWFwMC0su/W/+eBrXsNZriMqqqaKl+pHvo3W9H45
+hy7/nkl9WmhNrwAjdur7ouNLRniSEGxin8RHk4pRScqoo7ujFOUl5A7nGHckgumJ
+O1dTwPwc/d/cFVHdFY5UEOv0YpGoMORox48Y3n4leeGAssMdoU4PmNI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oTDjPjjLftQNJNoCCvfdjLm
+1DyYDzcryYhhYy1sbO0CSkZXyLgxW/F1bsRsUsgNE3UNITSbO89+PgD+9nkmHOY9
+9cGTg/u0Os8S3MZ3I3ifdig61NOi7iqYvH9bD+FVVv7xbm6Y7MVTF0t1Ecod72I0
+usMPytqLsZg2WXj4ikmGug==
+-----END MESSAGE-----
+signature wdc7ffr+dPZJ/mIQ1l4WYqNABcmsm6SHW/NL3M3wG7bjjqOJWoPR5TimUXxH52n5Zk0Gc7hl/hz3YYmAx5MvAg
diff --git a/test/unit/descriptor/hidden_service_v2.py b/test/unit/descriptor/hidden_service_v2.py
index 8442376b..ac64fa19 100644
--- a/test/unit/descriptor/hidden_service_v2.py
+++ b/test/unit/descriptor/hidden_service_v2.py
@@ -1,5 +1,5 @@
"""
-Unit tests for stem.descriptor.hidden_service.
+Unit tests for stem.descriptor.hidden_service for version 2.
"""
import datetime
@@ -250,27 +250,27 @@ class TestHiddenServiceDescriptorV2(unittest.TestCase):
Parse duckduckgo's descriptor.
"""
- descriptor_file = open(get_resource('hidden_service_duckduckgo'), 'rb')
- desc = next(stem.descriptor.parse_file(descriptor_file, 'hidden-service-descriptor 1.0', validate = True))
- self._assert_matches_duckduckgo(desc)
+ with open(get_resource('hidden_service_duckduckgo'), 'rb') as descriptor_file:
+ desc = next(stem.descriptor.parse_file(descriptor_file, 'hidden-service-descriptor 1.0', validate = True))
+ self._assert_matches_duckduckgo(desc)
def test_for_duckduckgo_without_validation(self):
"""
Parse duckduckgo's descriptor
"""
- descriptor_file = open(get_resource('hidden_service_duckduckgo'), 'rb')
- desc = next(stem.descriptor.parse_file(descriptor_file, 'hidden-service-descriptor 1.0', validate = False))
- self._assert_matches_duckduckgo(desc)
+ with open(get_resource('hidden_service_duckduckgo'), 'rb') as descriptor_file:
+ desc = next(stem.descriptor.parse_file(descriptor_file, 'hidden-service-descriptor 1.0', validate = False))
+ self._assert_matches_duckduckgo(desc)
def test_for_facebook(self):
"""
Parse facebook's descriptor.
"""
- descriptor_file = open(get_resource('hidden_service_facebook'), 'rb')
+ with open(get_resource('hidden_service_facebook'), 'rb') as descriptor_file:
+ desc = next(stem.descriptor.parse_file(descriptor_file, 'hidden-service-descriptor 1.0', validate = True))
- desc = next(stem.descriptor.parse_file(descriptor_file, 'hidden-service-descriptor 1.0', validate = True))
self.assertEqual('utjk4arxqg6s6zzo7n6cjnq6ot34udhr', desc.descriptor_id)
self.assertEqual(2, desc.version)
self.assertEqual('6355jaerje3bqozopwq2qmpf4iviizdn', desc.secret_id_part)
@@ -287,9 +287,9 @@ class TestHiddenServiceDescriptorV2(unittest.TestCase):
Parse a descriptor with introduction-points encrypted with basic auth.
"""
- descriptor_file = open(get_resource('hidden_service_basic_auth'), 'rb')
+ with open(get_resource('hidden_service_basic_auth'), 'rb') as descriptor_file:
+ desc = next(stem.descriptor.parse_file(descriptor_file, 'hidden-service-descriptor 1.0', validate = True))
- desc = next(stem.descriptor.parse_file(descriptor_file, 'hidden-service-descriptor 1.0', validate = True))
self.assertEqual('yfmvdrkdbyquyqk5vygyeylgj2qmrvrd', desc.descriptor_id)
self.assertEqual(2, desc.version)
self.assertEqual('fluw7z3s5cghuuirq3imh5jjj5ljips6', desc.secret_id_part)
@@ -334,9 +334,9 @@ class TestHiddenServiceDescriptorV2(unittest.TestCase):
Parse a descriptor with introduction-points encrypted with stealth auth.
"""
- descriptor_file = open(get_resource('hidden_service_stealth_auth'), 'rb')
+ with open(get_resource('hidden_service_stealth_auth'), 'rb') as descriptor_file:
+ desc = next(stem.descriptor.parse_file(descriptor_file, 'hidden-service-descriptor 1.0', validate = True))
- desc = next(stem.descriptor.parse_file(descriptor_file, 'hidden-service-descriptor 1.0', validate = True))
self.assertEqual('ubf3xeibzlfil6s4larq6y5peup2z3oj', desc.descriptor_id)
self.assertEqual(2, desc.version)
self.assertEqual('jczvydhzetbpdiylj3d5nsnjvaigs7xm', desc.secret_id_part)
diff --git a/test/unit/descriptor/hidden_service_v3.py b/test/unit/descriptor/hidden_service_v3.py
new file mode 100644
index 00000000..757c1944
--- /dev/null
+++ b/test/unit/descriptor/hidden_service_v3.py
@@ -0,0 +1,19 @@
+"""
+Unit tests for stem.descriptor.hidden_service for version 3.
+"""
+
+import unittest
+
+import stem.descriptor
+
+from test.unit.descriptor import get_resource
+
+
+class TestHiddenServiceDescriptorV3(unittest.TestCase):
+ def test_stub(self):
+ # TODO: replace with actual field assertions as the class gets implemented
+
+ with open(get_resource('hidden_service_v3'), 'rb') as descriptor_file:
+ desc = next(stem.descriptor.parse_file(descriptor_file, 'hidden-service-descriptor-3 1.0', validate = True))
+
+ self.assertTrue('hs-descriptor 3' in str(desc))
More information about the tor-commits
mailing list