[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Move digest contants into base descriptor module
commit 10b6ce3fc5b129dbe30714ba1c63f2b2e190bb7f
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Mon Jun 19 12:31:00 2017 -0700
Move digest contants into base descriptor module
Ah. On reflection we already used these a little for signature validation.
---
stem/descriptor/__init__.py | 8 ++++++--
stem/descriptor/server_descriptor.py | 7 +++----
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/stem/descriptor/__init__.py b/stem/descriptor/__init__.py
index 82b71d5..e18dfd2 100644
--- a/stem/descriptor/__init__.py
+++ b/stem/descriptor/__init__.py
@@ -81,6 +81,10 @@ PGP_BLOCK_START = re.compile('^-----BEGIN ([%s%s]+)-----$' % (KEYWORD_CHAR, WHIT
PGP_BLOCK_END = '-----END %s-----'
EMPTY_COLLECTION = ([], {}, set())
+DIGEST_TYPE_INFO = b'\x00\x01'
+DIGEST_PADDING = b'\xFF'
+DIGEST_SEPARATOR = b'\x00'
+
CRYPTO_BLOB = """
MIGJAoGBAJv5IIWQ+WDWYUdyA/0L8qbIkEVH/cwryZWoIaPAzINfrw1WfNZGtBmg
skFtXhOHHqTRN4GPPrZsAIUOQGzQtGb66IQgT4tO/pj+P6QmSCCdTfhvGfgTCsC+
@@ -720,7 +724,7 @@ class Descriptor(object):
############################################################################
try:
- if decrypted_bytes.index(b'\x00\x01') != 0:
+ if decrypted_bytes.index(DIGEST_TYPE_INFO) != 0:
raise ValueError('Verification failed, identifier missing')
except ValueError:
raise ValueError('Verification failed, malformed data')
@@ -729,7 +733,7 @@ class Descriptor(object):
identifier_offset = 2
# find the separator
- seperator_index = decrypted_bytes.index(b'\x00', identifier_offset)
+ seperator_index = decrypted_bytes.index(DIGEST_SEPARATOR, identifier_offset)
except ValueError:
raise ValueError('Verification failed, seperator not found')
diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py
index 2ff42e7..30599a8 100644
--- a/stem/descriptor/server_descriptor.py
+++ b/stem/descriptor/server_descriptor.py
@@ -52,6 +52,9 @@ from stem.util import str_type
from stem.descriptor import (
CRYPTO_BLOB,
PGP_BLOCK_END,
+ DIGEST_TYPE_INFO,
+ DIGEST_PADDING,
+ DIGEST_SEPARATOR,
Descriptor,
_descriptor_content,
_descriptor_components,
@@ -76,10 +79,6 @@ except ImportError:
SigningKey = collections.namedtuple('SigningKey', ['public', 'private', 'descriptor_signing_key'])
-DIGEST_TYPE_INFO = b'\x00\x01'
-DIGEST_PADDING = b'\xFF'
-DIGEST_SEPARATOR = b'\x00'
-
# relay descriptors must have exactly one of the following
REQUIRED_FIELDS = (
'router',
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits