Skip to content
Snippets Groups Projects
Commit 1648cebe authored by ptangu01's avatar ptangu01
Browse files

mv CIPHER_WINDOW as global variable

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/trunk@1332 b32b6428-25c9-4566-ad07-03861ab6144f
parent 0aacefc5
Branches
No related tags found
No related merge requests found
......@@ -36,6 +36,8 @@ import binascii
logger=logging.getLogger(__name__)
# Time Window in seconds to avoid replay attacks
CIPHER_WINDOW=60*2
class MessageFactoryParserError(Exception):
......@@ -52,9 +54,6 @@ class MessageFactory():
- Apply security layer, Ciphering/De-Ciphering chacha20 poly1305
- Serialize/Deserialize data in JSON"""
# Time Window in seconds to avoid replay attacks
CIPHER_WINDOW = 60*2
def __init__(self,cipherKey):
self.setCipherKey(cipherKey)
......@@ -118,10 +117,10 @@ class MessageFactory():
# Replay attack, window fixed to CIPHER_WINDOW in seconds
currentTimestamp=buildTimestamp()[0] # test done only on seconds ...
if dataRx['timestamp'][0] < (currentTimestamp - self.CIPHER_WINDOW):
if dataRx['timestamp'][0] < (currentTimestamp - CIPHER_WINDOW):
raise MessageFactoryParserError("Potential replay attack, message too old")
if dataRx['timestamp'][0] > (currentTimestamp + self.CIPHER_WINDOW):
if dataRx['timestamp'][0] > (currentTimestamp + CIPHER_WINDOW):
raise MessageFactoryParserError("Potential replay attack, message too young")
# Payload De-Ciphering
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment