[tor-commits] [stem/master] Provide digest values when mismatching

atagar at torproject.org atagar at torproject.org
Sun Oct 6 02:07:34 UTC 2019


commit 18237dea28cdf53e337d0cd120bd788d9d333e2f
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Sep 22 15:44:11 2019 -0700

    Provide digest values when mismatching
    
    Did I bugger something up? George's unit test fails for me with...
    
      ======================================================================
      ERROR: test_for_decrypt
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/home/atagar/Desktop/stem/test/unit/descriptor/hidden_service_v3.py", line 57, in test_for_decrypt
          desc._decrypt('sltib6sxkuxh2scmtuvd5w2g7pahnzkovefxpo4e4ptnkzl5kkq5h2ad.onion')
        File "/home/atagar/Desktop/stem/stem/descriptor/hidden_service.py", line 576, in _decrypt
          identity_public_key = stem.descriptor.hsv3_crypto.decode_address(onion_address)
        File "/home/atagar/Desktop/stem/stem/descriptor/hsv3_crypto.py", line 76, in decode_address
          raise ValueError('Bad checksum (expected %s but was %s)' % (binascii.hexlify(checksum), binascii.hexlify(my_checksum)))
      ValueError: Bad checksum (expected d3e8 but was c658fff6a9b3ba2e151d237641e9b50c74a93dc33a3dc149136b4e402ed79800)
    
      ----------------------------------------------------------------------
    
    Checking with him on irc.
---
 stem/descriptor/hsv3_crypto.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/stem/descriptor/hsv3_crypto.py b/stem/descriptor/hsv3_crypto.py
index 67ab2762..7c641363 100644
--- a/stem/descriptor/hsv3_crypto.py
+++ b/stem/descriptor/hsv3_crypto.py
@@ -73,7 +73,7 @@ def decode_address(onion_address_str):
   my_checksum = hashlib.sha3_256(my_checksum_body).digest()
 
   if (checksum != my_checksum[:2]):
-    raise ValueError('Bad checksum')
+    raise ValueError('Bad checksum (expected %s but was %s)' % (binascii.hexlify(checksum), binascii.hexlify(my_checksum)))
 
   return Ed25519PublicKey.from_public_bytes(pubkey)
 





More information about the tor-commits mailing list