From 3204c6b833902b1296ade01b1e35b468f5ebc60d Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Mon, 24 Jun 2013 17:29:04 -0400 Subject: [PATCH] added new variable: doTimingAttackMitigation --- src/class_receiveDataThread.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/class_receiveDataThread.py b/src/class_receiveDataThread.py index 0c12f8f6..544dbb82 100644 --- a/src/class_receiveDataThread.py +++ b/src/class_receiveDataThread.py @@ -1,3 +1,5 @@ +doTimingAttackMitigation = False + import time import threading import shared @@ -413,7 +415,7 @@ class receiveDataThread(threading.Thread): sleepTime = lengthOfTimeWeShouldUseToProcessThisMessage - \ (time.time() - self.messageProcessingStartTime) - if sleepTime > 0: + if sleepTime > 0 and doTimingAttackMitigation: shared.printLock.acquire() print 'Timing attack mitigation: Sleeping for', sleepTime, 'seconds.' shared.printLock.release() @@ -792,7 +794,7 @@ class receiveDataThread(threading.Thread): sleepTime = lengthOfTimeWeShouldUseToProcessThisMessage - \ (time.time() - self.messageProcessingStartTime) - if sleepTime > 0: + if sleepTime > 0 and doTimingAttackMitigation: shared.printLock.acquire() print 'Timing attack mitigation: Sleeping for', sleepTime, 'seconds.' shared.printLock.release() @@ -1190,7 +1192,7 @@ class receiveDataThread(threading.Thread): lengthOfTimeWeShouldUseToProcessThisMessage = .2 sleepTime = lengthOfTimeWeShouldUseToProcessThisMessage - \ (time.time() - self.pubkeyProcessingStartTime) - if sleepTime > 0: + if sleepTime > 0 and doTimingAttackMitigation: shared.printLock.acquire() print 'Timing attack mitigation: Sleeping for', sleepTime, 'seconds.' shared.printLock.release() @@ -1428,7 +1430,7 @@ class receiveDataThread(threading.Thread): shared.myAddressesByHash[requestedHash], 'lastpubkeysendtime')) except: lastPubkeySendTime = 0 - if lastPubkeySendTime < time.time() - shared.lengthOfTimeToHoldOnToAllPubkeys: # If the last time we sent our pubkey was 28 days ago + if lastPubkeySendTime < time.time() - shared.lengthOfTimeToHoldOnToAllPubkeys: # If the last time we sent our pubkey was at least 28 days ago... shared.printLock.acquire() print 'Found getpubkey-requested-hash in my list of EC hashes. Telling Worker thread to do the POW for a pubkey message and send it out.' shared.printLock.release()