[tor-commits] [stem/master] Parsing server descriptor's ntor-onion-key line
atagar at torproject.org
atagar at torproject.org
Sun Jan 6 02:03:23 UTC 2013
commit c78d9cda3ab5fc307264bce774187b6f4188f96d
Author: Damian Johnson <atagar at torproject.org>
Date: Sat Jan 5 18:01:49 2013 -0800
Parsing server descriptor's ntor-onion-key line
Parsing for the newly introduced 'ntor-onion-key' line. I'm not entirely clear
of the format that our users will want so checking with Nick and just parsing
the raw string.
---
stem/descriptor/server_descriptor.py | 6 ++++++
test/unit/descriptor/server_descriptor.py | 8 ++++++++
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py
index 17664bc..8f73cdd 100644
--- a/stem/descriptor/server_descriptor.py
+++ b/stem/descriptor/server_descriptor.py
@@ -68,6 +68,7 @@ SINGLE_FIELDS = (
"hidden-service-dir",
"protocols",
"allow-single-hop-exits",
+ "ntor-onion-key",
)
def parse_file(descriptor_file, validate = True):
@@ -585,6 +586,7 @@ class RelayDescriptor(ServerDescriptor):
<https://gitweb.torproject.org/torspec.git/blob/HEAD:/dir-spec.txt>`_)
:var str onion_key: **\*** key used to encrypt EXTEND cells
+ :var str ntor_onion_key: base64 key used to encrypt EXTEND in the ntor protocol
:var str signing_key: **\*** relay's long-term identity key
:var str signature: **\*** signature for this descriptor
@@ -593,6 +595,7 @@ class RelayDescriptor(ServerDescriptor):
def __init__(self, raw_contents, validate = True, annotations = None):
self.onion_key = None
+ self.ntor_onion_key = None
self.signing_key = None
self.signature = None
self._digest = None
@@ -738,6 +741,9 @@ class RelayDescriptor(ServerDescriptor):
self.onion_key = block_contents
del entries["onion-key"]
+ elif keyword == "ntor-onion-key":
+ self.ntor_onion_key = value
+ del entries["ntor-onion-key"]
elif keyword == "signing-key":
if validate and not block_contents:
raise ValueError("Signing key line must be followed by a public key: %s" % line)
diff --git a/test/unit/descriptor/server_descriptor.py b/test/unit/descriptor/server_descriptor.py
index 62eb033..0edf429 100644
--- a/test/unit/descriptor/server_descriptor.py
+++ b/test/unit/descriptor/server_descriptor.py
@@ -268,6 +268,14 @@ class TestServerDescriptor(unittest.TestCase):
desc = get_relay_server_descriptor({"ipv6-policy": "accept 22-23,53,80,110"})
self.assertEquals(expected, desc.exit_policy_v6)
+ def test_ntor_onion_key(self):
+ """
+ Checks a 'ntor-onion-key' line.
+ """
+
+ desc = get_relay_server_descriptor({"ntor-onion-key": "Od2Sj3UXFyDjwESLXk6fhatqW9z/oBL/vAKJ+tbDqUU="})
+ self.assertEquals("Od2Sj3UXFyDjwESLXk6fhatqW9z/oBL/vAKJ+tbDqUU=", desc.ntor_onion_key)
+
def test_minimal_bridge_descriptor(self):
"""
Basic sanity check that we can parse a descriptor with minimal attributes.
More information about the tor-commits
mailing list