@@ -26,11 +26,13 @@ class TestType(Enum):
26
26
2. EXCESS_GARBAGE - Disconnection happens when > MAX_GARBAGE_LEN bytes garbage is sent
27
27
3. WRONG_GARBAGE_TERMINATOR - Disconnection happens when incorrect garbage terminator is sent
28
28
4. WRONG_GARBAGE - Disconnection happens when garbage bytes that is sent is different from what the peer receives
29
+ 5. SEND_NO_AAD - Disconnection happens when AAD of first encrypted packet after the garbage terminator is not filled
29
30
"""
30
31
EARLY_KEY_RESPONSE = 0
31
32
EXCESS_GARBAGE = 1
32
33
WRONG_GARBAGE_TERMINATOR = 2
33
34
WRONG_GARBAGE = 3
35
+ SEND_NO_AAD = 4
34
36
35
37
36
38
class TestEncryptedP2PState (EncryptedP2PState ):
@@ -87,8 +89,9 @@ def initiate_v2_handshake(self):
87
89
return super ().initiate_v2_handshake ()
88
90
89
91
def complete_handshake (self , response ):
90
- """Add option for sending wrong garbage terminator
91
- when TestType = (WRONG_GARBAGE_TERMINATOR)"""
92
+ """Add option for sending wrong garbage terminator, not filling first encrypted packet after garbage terminator
93
+ with AAD
94
+ when TestType = (WRONG_GARBAGE_TERMINATOR, SEND_NO_AAD)"""
92
95
ellswift_theirs = self .received_prefix + response .read (64 - len (self .received_prefix ))
93
96
# return b"" if we need to receive more bytes
94
97
if len (ellswift_theirs ) != 64 :
@@ -101,6 +104,8 @@ def complete_handshake(self, response):
101
104
102
105
if self .test_type == TestType .WRONG_GARBAGE_TERMINATOR :
103
106
msg_to_send = random_bitflip (msg_to_send )
107
+ elif self .test_type == TestType .SEND_NO_AAD :
108
+ aad = b''
104
109
105
110
# Optionally send decoy packets after garbage terminator.
106
111
for decoy_content_len in [random .randint (1 , 100 ) for _ in range (random .randint (0 , 10 ))]:
@@ -170,6 +175,7 @@ def test_v2disconnection(self):
170
175
["V2 transport error: missing garbage terminator, peer=1" ], # EXCESS_GARBAGE
171
176
["version handshake timeout peer=2" ], # WRONG_GARBAGE_TERMINATOR
172
177
["V2 transport error: packet decryption failure" ], # WRONG_GARBAGE
178
+ ["V2 transport error: packet decryption failure" ], # SEND_NO_AAD
173
179
]
174
180
for test_type in TestType :
175
181
if test_type == TestType .EARLY_KEY_RESPONSE :
0 commit comments