Skip to content

Commit 1770150

Browse files
bluetooth: SM: Add security request packet
1 parent 0648c0d commit 1770150

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

scapy/layers/bluetooth.py

+16-9
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,12 @@ class SM_Signing_Information(Packet):
919919
fields_desc = [StrFixedLenField("csrk", b'\x00' * 16, 16), ]
920920

921921

922+
class SM_Security_Request(Packet):
923+
name = "Security Request"
924+
fields_desc = [
925+
BitField("auth_req", 0, 8)
926+
]
927+
922928
class SM_Public_Key(Packet):
923929
name = "Public Key"
924930
fields_desc = [StrFixedLenField("key_x", b'\x00' * 32, 32),
@@ -2813,16 +2819,17 @@ class HCI_LE_Meta_Extended_Advertising_Reports(Packet):
28132819
bind_layers(ATT_Hdr, ATT_Handle_Value_Notification, opcode=0x1b)
28142820
bind_layers(ATT_Hdr, ATT_Handle_Value_Indication, opcode=0x1d)
28152821
bind_layers(L2CAP_Hdr, SM_Hdr, cid=6)
2816-
bind_layers(SM_Hdr, SM_Pairing_Request, sm_command=1)
2817-
bind_layers(SM_Hdr, SM_Pairing_Response, sm_command=2)
2818-
bind_layers(SM_Hdr, SM_Confirm, sm_command=3)
2819-
bind_layers(SM_Hdr, SM_Random, sm_command=4)
2820-
bind_layers(SM_Hdr, SM_Failed, sm_command=5)
2821-
bind_layers(SM_Hdr, SM_Encryption_Information, sm_command=6)
2822-
bind_layers(SM_Hdr, SM_Master_Identification, sm_command=7)
2823-
bind_layers(SM_Hdr, SM_Identity_Information, sm_command=8)
2824-
bind_layers(SM_Hdr, SM_Identity_Address_Information, sm_command=9)
2822+
bind_layers(SM_Hdr, SM_Pairing_Request, sm_command=0x01)
2823+
bind_layers(SM_Hdr, SM_Pairing_Response, sm_command=0x02)
2824+
bind_layers(SM_Hdr, SM_Confirm, sm_command=0x03)
2825+
bind_layers(SM_Hdr, SM_Random, sm_command=0x04)
2826+
bind_layers(SM_Hdr, SM_Failed, sm_command=0x05)
2827+
bind_layers(SM_Hdr, SM_Encryption_Information, sm_command=0x06)
2828+
bind_layers(SM_Hdr, SM_Master_Identification, sm_command=0x07)
2829+
bind_layers(SM_Hdr, SM_Identity_Information, sm_command=0x08)
2830+
bind_layers(SM_Hdr, SM_Identity_Address_Information, sm_command=0x09)
28252831
bind_layers(SM_Hdr, SM_Signing_Information, sm_command=0x0a)
2832+
bind_layers(SM_Hdr, SM_Security_Request, sm_command=0x0b)
28262833
bind_layers(SM_Hdr, SM_Public_Key, sm_command=0x0c)
28272834
bind_layers(SM_Hdr, SM_DHKey_Check, sm_command=0x0d)
28282835

test/scapy/layers/bluetooth.uts

+6
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,12 @@ pkt.handles[0].value == b'\x02\x03\x00\x00*'
791791
pkt.handles[1].value == b'\x02\x05\x00\x01*'
792792
pkt.handles[2].value == b'\x02\x07\x00\x04*'
793793

794+
= SM_Security_Request
795+
pkt = HCI_Hdr(hex_bytes('0200260600020006000b0d'))
796+
assert SM_Security_Request in pkt
797+
assert pkt[SM_Security_Request].auth_req == 0x0d
798+
799+
794800
= SM_Public_Key() tests
795801

796802
r = raw(SM_Hdr()/SM_Public_Key(key_x="sca", key_y="py"))

0 commit comments

Comments
 (0)