From 4ee9d0544692332a596e183d9ad9e4e0672c90a9 Mon Sep 17 00:00:00 2001 From: Peter Surda Date: Thu, 30 Nov 2017 20:08:14 +0100 Subject: [PATCH] Randomise key order during decryption - may help against timing/radio attacks --- src/class_objectProcessor.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/class_objectProcessor.py b/src/class_objectProcessor.py index ec2b32b9..21de6856 100644 --- a/src/class_objectProcessor.py +++ b/src/class_objectProcessor.py @@ -361,7 +361,7 @@ class objectProcessor(threading.Thread): # This is not an acknowledgement bound for me. See if it is a message # bound for me by trying to decrypt it with my private keys. - for key, cryptorObject in shared.myECCryptorObjects.items(): + for key, cryptorObject in sorted(shared.myECCryptorObjects.items(), key=lambda x: random.random()): try: if initialDecryptionSuccessful: # continue decryption attempts to avoid timing attacks cryptorObject.decrypt(data[readPosition:]) @@ -634,7 +634,7 @@ class objectProcessor(threading.Thread): """ signedData = data[8:readPosition] initialDecryptionSuccessful = False - for key, cryptorObject in shared.MyECSubscriptionCryptorObjects.items(): + for key, cryptorObject in sorted(shared.MyECSubscriptionCryptorObjects.items(), key=lambda x: random.random()): try: if initialDecryptionSuccessful: # continue decryption attempts to avoid timing attacks cryptorObject.decrypt(data[readPosition:])