@@ -1185,17 +1185,20 @@ class Dot11EltRSN(Dot11Elt):
11851185 AKMSuite ,
11861186 count_from = lambda p : p .nb_akm_suites
11871187 ),
1188- BitField ("mfp_capable" , 0 , 1 ),
1189- BitField ("mfp_required" , 0 , 1 ),
1188+ BitField ("mfp_capable" , 1 , 1 ),
1189+ BitField ("mfp_required" , 1 , 1 ),
11901190 BitField ("gtksa_replay_counter" , 0 , 2 ),
11911191 BitField ("ptksa_replay_counter" , 0 , 2 ),
11921192 BitField ("no_pairwise" , 0 , 1 ),
11931193 BitField ("pre_auth" , 0 , 1 ),
11941194 BitField ("reserved" , 0 , 8 ),
1195+ # Theorically we could use mfp_capable/mfp_required to know if those
1196+ # fields are present, but some implementations poorly implement it.
1197+ # In practice, do as wireshark: guess using offset.
11951198 ConditionalField (
1196- PacketField ("pmkids" , None , PMKIDListPacket ),
1199+ PacketField ("pmkids" , PMKIDListPacket () , PMKIDListPacket ),
11971200 lambda pkt : (
1198- 0 if pkt .len is None else
1201+ True if pkt .len is None else
11991202 pkt .len - (
12001203 12 +
12011204 (pkt .nb_pairwise_cipher_suites or 0 ) * 4 +
@@ -1206,7 +1209,15 @@ class Dot11EltRSN(Dot11Elt):
12061209 ConditionalField (
12071210 PacketField ("group_management_cipher_suite" ,
12081211 RSNCipherSuite (cipher = 0x6 ), RSNCipherSuite ),
1209- lambda pkt : pkt .mfp_capable == 1
1212+ lambda pkt : (
1213+ True if pkt .len is None else
1214+ pkt .len - (
1215+ 12 +
1216+ (pkt .nb_pairwise_cipher_suites or 0 ) * 4 +
1217+ (pkt .nb_akm_suites or 0 ) * 4 +
1218+ (pkt .pmkids and pkt .pmkids .nb_pmkids or 0 ) * 16
1219+ ) >= 2
1220+ )
12101221 )
12111222 ]
12121223
0 commit comments