[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [chutney/master] Added function in TorNet.py to make chutney check for relay microdescriptors before verifying
commit 7d42052b903e04b77c2c3355955a78d32ed0e4c0
Author: ANURADHAJHA99 <anuradha750871@xxxxxxxxx>
Date: Tue Mar 17 23:48:09 2020 +0530
Added function in TorNet.py to make chutney check for relay microdescriptors before verifying
---
lib/chutney/TorNet.py | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/lib/chutney/TorNet.py b/lib/chutney/TorNet.py
index 697025e..1c24053 100644
--- a/lib/chutney/TorNet.py
+++ b/lib/chutney/TorNet.py
@@ -22,6 +22,7 @@ import signal
import subprocess
import sys
import time
+import base64
from chutney.Debug import debug_flag, debug
@@ -684,9 +685,10 @@ class LocalNodeBuilder(NodeBuilder):
self._genAuthorityKey()
if self._env['relay']:
self._genRouterKey()
+ self._setEd25519Id()
if self._env['hs']:
self._makeHiddenServiceDir()
-
+
def config(self, net):
"""Called to configure a node: creates a torrc file for it."""
self._createTorrcFile()
@@ -780,7 +782,32 @@ class LocalNodeBuilder(NodeBuilder):
.format(repr(" ".join(cmdline)), repr(stdouterr)))
sys.exit(1)
self._env['fingerprint'] = fingerprint
-
+
+ def _setEd25519Id(self):
+ """Read the ed25519 identity key for this router, and set up the 'ed25519-id' entry in the Environ"""
+ datadir = self._env['dir']
+ key_file = os.path.join(datadir, 'keys', "ed25519_master_id_public_key")
+ EXPECTED_ED25519_FILE_SIZE = 64
+ CURRENT_FILE_SIZE = os.stat(key_file).st_size
+ if not os.path.exists(key_file):
+ print("File {} does not exist. Are you running a very old tor version?".format(key_file))
+ return
+ elif CURRENT_FILE_SIZE != EXPECTED_ED25519_FILE_SIZE:
+ raise ValueError("The current size of the file is {} bytes, which is not matching the expected value of {} bytes".format(CURRENT_FILE_SIZE, EXPECTED_ED25519_FILE_SIZE))
+ else:
+ with open(key_file, 'rb') as f:
+ ED25519_KEY_POSITION = 32
+ f.seek(ED25519_KEY_POSITION)
+ rest_file = f.read()
+ encoded_value = base64.b64encode(rest_file)
+ ed25519_id = encoded_value.decode('utf-8').replace('=', '')
+ EXPECTED_ED25519_BASE64_KEY_SIZE = 43
+ CURRENT_ED25519_BASE64_KEY_SIZE = len(ed25519_id)
+ if CURRENT_ED25519_BASE64_KEY_SIZE != EXPECTED_ED25519_BASE64_KEY_SIZE:
+ raise ValueError("The current length of the key is {}, which is not matching the expected length of {}".format(CURRENT_ED25519_BASE64_KEY_SIZE, EXPECTED_ED25519_BASE64_KEY_SIZE))
+ else:
+ self._env['ed25519-id'] = ed25519_id
+
def _getAltAuthLines(self, hasbridgeauth=False):
"""Return a combination of AlternateDirAuthority,
and AlternateBridgeAuthority lines for
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits