commit e1e49342284f2826c8b669e3641a40dd8ff9d3a1
Author: Damian Johnson <[email protected]>
Date: Sat Sep 28 13:39:58 2019 -0700
Drop assertion statements
We don't use python assertions in Stem as they're largely useless. They
don't
get invoked unless explicitly enabled when invoking python, and most of
these
checks are redundant.
For example, checking for '---BEGIN ED25519 CERT---' in "cert_lines" is
already
done by _parse_key_block(). If any of these assertions are important they
should be integrated into descriptor validation - not an AssertionError.
---
stem/descriptor/hidden_service.py | 5 -----
stem/descriptor/hsv3_crypto.py | 3 ---
2 files changed, 8 deletions(-)
diff --git a/stem/descriptor/hidden_service.py
b/stem/descriptor/hidden_service.py
index fda5147b..802ca6c4 100644
--- a/stem/descriptor/hidden_service.py
+++ b/stem/descriptor/hidden_service.py
@@ -555,10 +555,7 @@ class
HiddenServiceDescriptorV3(BaseHiddenServiceDescriptor):
# and parses the internal descriptor content.
def _decrypt(self, onion_address):
- assert(self.signing_cert)
cert_lines = self.signing_cert.split('\n')
- assert(cert_lines[0] == '-----BEGIN ED25519 CERT-----' and cert_lines[-1]
== '-----END ED25519 CERT-----')
-
desc_signing_cert =
stem.descriptor.certificate.Ed25519Certificate.parse(''.join(cert_lines[1:-1]))
# Get crypto material.
@@ -576,8 +573,6 @@ class
HiddenServiceDescriptorV3(BaseHiddenServiceDescriptor):
identity_public_key =
stem.descriptor.hsv3_crypto.decode_address(onion_address)
identity_public_key_bytes =
identity_public_key.public_bytes(encoding=serialization.Encoding.Raw,
format=serialization.PublicFormat.Raw)
- assert(len(identity_public_key_bytes) == 32)
-
subcredential_bytes =
stem.descriptor.hsv3_crypto.get_subcredential(identity_public_key_bytes,
blinded_key_bytes)
outter_layer_plaintext =
stem.descriptor.hsv3_crypto.decrypt_outter_layer(self.superencrypted,
self.revision_counter, identity_public_key_bytes, blinded_key_bytes,
subcredential_bytes)
diff --git a/stem/descriptor/hsv3_crypto.py b/stem/descriptor/hsv3_crypto.py
index 5439771a..248eacec 100644
--- a/stem/descriptor/hsv3_crypto.py
+++ b/stem/descriptor/hsv3_crypto.py
@@ -63,7 +63,6 @@ def decode_address(onion_address_str):
# base32 decode the addr (convert to uppercase since that's what python
expects)
onion_address = base64.b32decode(onion_address.upper())
- assert(len(onion_address) == 35)
# extract pieces of information
pubkey = onion_address[:32]
@@ -245,8 +244,6 @@ def decrypt_outter_layer(superencrypted_blob_b64,
revision_counter, public_ident
# XXX Remove the BEGIN MESSSAGE around the thing
superencrypted_blob_b64_lines = superencrypted_blob_b64.split('\n')
- assert(superencrypted_blob_b64_lines[0] == '-----BEGIN MESSAGE-----')
- assert(superencrypted_blob_b64_lines[-1] == '-----END MESSAGE-----')
superencrypted_blob_b64 = ''.join(superencrypted_blob_b64_lines[1:-1])
print('====== Decrypting outter layer =======')
_______________________________________________
tor-commits mailing list
[email protected]
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits