From 078b2e289469064640ec8958d2f46c5467cf3c6e Mon Sep 17 00:00:00 2001 From: Alex Cato Date: Tue, 28 May 2019 13:27:44 +0200 Subject: [PATCH] Message-signature-verification: also accept lowercase hostid as valid. The hostid upper/lowercase seems can be different depending on how someone connects to an IRC server (via TOR, clearnet, etc.). This leads to message signature verification failures, if the receiving counterparty has a differently capitalized id. --- jmclient/jmclient/client_protocol.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jmclient/jmclient/client_protocol.py b/jmclient/jmclient/client_protocol.py index 904c3ab..60f7c2a 100644 --- a/jmclient/jmclient/client_protocol.py +++ b/jmclient/jmclient/client_protocol.py @@ -110,8 +110,10 @@ class JMClientProtocol(amp.AMP): hashlen, max_encoded, hostid): verif_result = True if not btc.ecdsa_verify(str(msg), sig, pubkey): - jlog.debug("nick signature verification failed, ignoring: " + str(nick)) - verif_result = False + # workaround for hostid, which sometimes is lowercase-only for some IRC connections + if not btc.ecdsa_verify(str(msg[:-len(hostid)] + hostid.lower()), sig, pubkey): + jlog.debug("nick signature verification failed, ignoring: " + str(nick)) + verif_result = False #check that nick matches hash of pubkey nick_pkh_raw = btc.bin_sha256(pubkey)[:hashlen] nick_stripped = nick[2:2 + max_encoded]