Skip to content

Commit

Permalink
Fix IKEv2 critical bit set (#4647)
Browse files Browse the repository at this point in the history
* Fix critical bit set

Critical bit is set on the MSB

* Add unit test

---------

Co-authored-by: gpotter2 <[email protected]>
  • Loading branch information
dmaciejak and gpotter2 authored Feb 3, 2025
1 parent a444240 commit e16a18e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion scapy/contrib/ikev2.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ class IKEv2_Payload(_IKEv2_Packet):
name = "IKEv2 Payload"
fields_desc = [
ByteEnumField("next_payload", None, IKEv2PayloadTypes),
FlagsField("flags", 0, 8, ["critical"]),
FlagsField("flags", 0, 8, {0x80: "critical"}),
ShortField("length", None),
XStrLenField("load", "", length_from=lambda pkt: pkt.length - 4),
]
Expand Down
4 changes: 2 additions & 2 deletions test/contrib/ikev2.uts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ a[IKEv2_Transform].show()

= Build Ikev2 SA request packet

a = IKEv2(init_SPI="MySPI",exch_type=34)/IKEv2_SA(prop=IKEv2_Proposal())
assert raw(a) == b'MySPI\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00! "\x00\x00\x00\x00\x00\x00\x00\x00(\x00\x00\x00\x0c\x00\x00\x00\x08\x01\x01\x00\x00'
a = IKEv2(init_SPI="MySPI",exch_type=34)/IKEv2_SA(flags="critical", prop=IKEv2_Proposal())
assert raw(a) == b'MySPI\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00! "\x00\x00\x00\x00\x00\x00\x00\x00(\x00\x80\x00\x0c\x00\x00\x00\x08\x01\x01\x00\x00'

= Build advanced IKEv2

Expand Down

0 comments on commit e16a18e

Please sign in to comment.