[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Randomize created microdescriptor fields



commit 0cd2e12a31cccd62dd134aff43f1529208ec0422
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Wed Jun 28 11:03:56 2017 -0700

    Randomize created microdescriptor fields
---
 stem/descriptor/microdescriptor.py      | 10 ++++------
 test/unit/descriptor/microdescriptor.py |  1 -
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/stem/descriptor/microdescriptor.py b/stem/descriptor/microdescriptor.py
index 3990720..1cd1ce6 100644
--- a/stem/descriptor/microdescriptor.py
+++ b/stem/descriptor/microdescriptor.py
@@ -69,7 +69,6 @@ import hashlib
 import stem.exit_policy
 
 from stem.descriptor import (
-  CRYPTO_BLOB,
   Descriptor,
   _descriptor_content,
   _descriptor_components,
@@ -78,6 +77,7 @@ from stem.descriptor import (
   _parse_simple_line,
   _parse_protocol_line,
   _parse_key_block,
+  _random_crypto_blob,
 )
 
 from stem.descriptor.router_status_entry import (
@@ -104,10 +104,6 @@ SINGLE_FIELDS = (
   'pr',
 )
 
-MICRODESCRIPTOR = (
-  ('onion-key', '\n-----BEGIN RSA PUBLIC KEY-----%s-----END RSA PUBLIC KEY-----' % CRYPTO_BLOB),
-)
-
 
 def _parse_file(descriptor_file, validate = False, **kwargs):
   """
@@ -267,7 +263,9 @@ class Microdescriptor(Descriptor):
     if sign:
       raise NotImplementedError('Signing of %s not implemented' % cls.__name__)
 
-    return _descriptor_content(attr, exclude, sign, MICRODESCRIPTOR)
+    return _descriptor_content(attr, exclude, sign, (
+      ('onion-key', _random_crypto_blob('RSA PUBLIC KEY')),
+    ))
 
   def __init__(self, raw_contents, validate = False, annotations = None):
     super(Microdescriptor, self).__init__(raw_contents, lazy_load = not validate)
diff --git a/test/unit/descriptor/microdescriptor.py b/test/unit/descriptor/microdescriptor.py
index 0de947f..aab9ab4 100644
--- a/test/unit/descriptor/microdescriptor.py
+++ b/test/unit/descriptor/microdescriptor.py
@@ -83,7 +83,6 @@ class TestMicrodescriptor(unittest.TestCase):
 
     desc = Microdescriptor.create()
 
-    self.assertTrue(stem.descriptor.CRYPTO_BLOB in desc.onion_key)
     self.assertEqual(None, desc.ntor_onion_key)
     self.assertEqual([], desc.or_addresses)
     self.assertEqual([], desc.family)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits