Skip to content

Commit ee7d0b4

Browse files
committed
Fix EAPOL_KEY
1 parent 42115bf commit ee7d0b4

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

scapy/layers/eap.py

+12-15
Original file line numberDiff line numberDiff line change
@@ -441,33 +441,30 @@ class EAPOL_KEY(Packet):
441441
fields_desc = [
442442
ByteEnumField("key_descriptor_type", 1, {1: "RC4", 2: "RSN"}),
443443
# Key Information
444+
BitField("res2", 0, 2),
445+
BitField("smk_message", 0, 1),
446+
BitField("encrypted_key_data", 0, 1),
447+
BitField("request", 0, 1),
448+
BitField("error", 0, 1),
449+
BitField("secure", 0, 1),
450+
BitField("has_key_mic", 1, 1),
451+
BitField("key_ack", 0, 1),
452+
BitField("install", 0, 1),
453+
BitField("res", 0, 2),
454+
BitEnumField("key_type", 0, 1, {0: "Group/SMK", 1: "Pairwise"}),
444455
BitEnumField("key_descriptor_type_version", 0, 3, {
445456
1: "HMAC-MD5+ARC4",
446457
2: "HMAC-SHA1-128+AES-128",
447458
3: "AES-128-CMAC+AES-128",
448459
}),
449-
BitEnumField("key_type", 0, 1, {0: "Group/SMK", 1: "Pairwise"}),
450-
BitField("res", 0, 2),
451-
BitField("install", 0, 1),
452-
BitField("key_ack", 0, 1),
453-
BitField("has_key_mic", 1, 1),
454-
BitField("secure", 0, 1),
455-
BitField("error", 0, 1),
456-
BitField("request", 0, 1),
457-
BitField("encrypted_key_data", 0, 1),
458-
BitField("smk_message", 0, 1),
459-
BitField("res2", 0, 2),
460460
#
461461
LenField("len", None, "H"),
462462
LongField("key_replay_counter", 0),
463463
XStrFixedLenField("key_nonce", "", 32),
464464
XStrFixedLenField("key_iv", "", 16),
465465
XStrFixedLenField("key_rsc", "", 8),
466466
XStrFixedLenField("key_id", "", 8),
467-
ConditionalField(
468-
XStrFixedLenField("key_mic", "", 16), # XXX size can be 24
469-
lambda pkt: pkt.has_key_mic
470-
),
467+
XStrFixedLenField("key_mic", "", 16), # XXX size can be 24
471468
LenField("key_length", None, "H"),
472469
XStrLenField("key", "",
473470
length_from=lambda pkt: pkt.key_length)

test/scapy/layers/eap.uts

+4-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ assert eapol.haslayer(EAP_FAST)
6060
s = b'\x08\x02:\x01\x00\xc0\xcab\xa4\xf6\x00"k\xfbI+\x00"k\xfbI+\xa0[\xaa\xaa\x03\x00\x00\x00\x88\x8e\x02\x03\x00u\x02\x00\x8a\x00\x10\x00\x00\x00\x00\x00\x00\x00\x04\x95X{I5\':3\x8f\x90\xb1I\xae\x1f\xd7-"\x82\x1e\\$\xefC=\x83\x97?M\xd6\xdf>\x9b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x16\xdd\x14\x00\x0f\xac\x04\x03\xca?d\xca\xed\xdd\xef\xf69;\xefX\xd4\x97w'
6161
wifi = Dot11(s)
6262
assert wifi[EAPOL].key_descriptor_type == 2
63-
assert wifi[EAPOL].key_type == 0
64-
assert wifi[EAPOL].has_key_mic == 1
65-
assert wifi[EAPOL].encrypted_key_data == 1
63+
assert wifi[EAPOL].encrypted_key_data == 0
64+
assert wifi[EAPOL].key_ack == 1
65+
assert wifi[EAPOL].key_type == 1
66+
assert wifi[EAPOL].key_descriptor_type_version == 2
6667
assert wifi[EAPOL].key_replay_counter == 4
6768
assert wifi[EAPOL].key_mic == b"\x00" * 16
6869
assert wifi[EAPOL].key_length == 22

0 commit comments

Comments
 (0)