Commit 3d378b7 1 parent b8c255f commit 3d378b7 Copy full SHA for 3d378b7
File tree 1 file changed +6
-0
lines changed
1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ class AEAD(IntEnum):
31
31
class DeserializeError (ValueError ):
32
32
pass
33
33
34
+ class MessageLimitReachedError (ValueError ):
35
+ pass
34
36
35
37
# CURVE to (KEM ID, KDF ID, HASH)
36
38
_Curve_Config = {
@@ -136,6 +138,8 @@ def __init__(self,
136
138
sender_key )
137
139
138
140
self ._sequence = 0
141
+ self ._max_sequence = (1 << (8 * self ._Nn )) - 1
142
+
139
143
self ._key , \
140
144
self ._base_nonce , \
141
145
self ._export_secret = self ._key_schedule (shared_secret ,
@@ -295,6 +299,8 @@ def _new_cipher(self):
295
299
cipher = ChaCha20_Poly1305 .new (key = self ._key , nonce = nonce )
296
300
else :
297
301
raise ValueError (f"Unknown AEAD cipher ID { self ._aead_id :#x} " )
302
+ if self ._sequence >= self ._max_sequence :
303
+ raise MessageLimitReachedError ()
298
304
self ._sequence += 1
299
305
return cipher
300
306
You can’t perform that action at this time.
0 commit comments