From 5086a839eef6cbabaf465a0acedc4a8a82a5013d Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Thu, 26 Apr 2018 21:14:31 -0500 Subject: [PATCH] signed blocks related crashes fixed hopefully --- onionr/communicator.py | 1 - onionr/onionrcrypto.py | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/onionr/communicator.py b/onionr/communicator.py index a2b8fb9f..8f5c7e36 100755 --- a/onionr/communicator.py +++ b/onionr/communicator.py @@ -277,7 +277,6 @@ class OnionrCommunicate: pass else: creator = self._utils.getPeerByHashId(blockMetadata['id']) - logger.debug('Proccess blocks: verifying signature by ' + creator) if self._core._crypto.edVerify(blockContent.split(b'}')[1], creator, blockMetadata['sig'], encodedData=True): self._core.updateBlockInfo(i, 'sig', 'true') else: diff --git a/onionr/onionrcrypto.py b/onionr/onionrcrypto.py index b631d20b..df429099 100644 --- a/onionr/onionrcrypto.py +++ b/onionr/onionrcrypto.py @@ -44,7 +44,11 @@ class OnionrCrypto: def edVerify(self, data, key, sig, encodedData=True): '''Verify signed data (combined in nacl) to an ed25519 key''' - key = nacl.signing.VerifyKey(key=key, encoder=nacl.encoding.Base32Encoder) + try: + key = nacl.signing.VerifyKey(key=key, encoder=nacl.encoding.Base32Encoder) + except nacl.bindings.crypto_sign_PUBLICKEYBYTES: + logger.warn('Signature by unknown key (cannot reverse hash)') + return False retData = False sig = base64.b64decode(sig) try: @@ -56,6 +60,7 @@ class OnionrCrypto: retData = key.verify(data, sig) # .encode() is not the same as nacl.encoding except nacl.exceptions.BadSignatureError: pass + else: try: retData = key.verify(data, sig)