Skip to content

bluetooth: SM: Add security request packet #4732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions scapy/layers/bluetooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,11 @@ class SM_Signing_Information(Packet):
fields_desc = [StrFixedLenField("csrk", b'\x00' * 16, 16), ]


class SM_Security_Request(Packet):
name = "Security Request"
fields_desc = [BitField("auth_req", 0, 8), ]


class SM_Public_Key(Packet):
name = "Public Key"
fields_desc = [StrFixedLenField("key_x", b'\x00' * 32, 32),
Expand Down Expand Up @@ -2813,16 +2818,17 @@ class HCI_LE_Meta_Extended_Advertising_Reports(Packet):
bind_layers(ATT_Hdr, ATT_Handle_Value_Notification, opcode=0x1b)
bind_layers(ATT_Hdr, ATT_Handle_Value_Indication, opcode=0x1d)
bind_layers(L2CAP_Hdr, SM_Hdr, cid=6)
bind_layers(SM_Hdr, SM_Pairing_Request, sm_command=1)
bind_layers(SM_Hdr, SM_Pairing_Response, sm_command=2)
bind_layers(SM_Hdr, SM_Confirm, sm_command=3)
bind_layers(SM_Hdr, SM_Random, sm_command=4)
bind_layers(SM_Hdr, SM_Failed, sm_command=5)
bind_layers(SM_Hdr, SM_Encryption_Information, sm_command=6)
bind_layers(SM_Hdr, SM_Master_Identification, sm_command=7)
bind_layers(SM_Hdr, SM_Identity_Information, sm_command=8)
bind_layers(SM_Hdr, SM_Identity_Address_Information, sm_command=9)
bind_layers(SM_Hdr, SM_Pairing_Request, sm_command=0x01)
bind_layers(SM_Hdr, SM_Pairing_Response, sm_command=0x02)
bind_layers(SM_Hdr, SM_Confirm, sm_command=0x03)
bind_layers(SM_Hdr, SM_Random, sm_command=0x04)
bind_layers(SM_Hdr, SM_Failed, sm_command=0x05)
bind_layers(SM_Hdr, SM_Encryption_Information, sm_command=0x06)
bind_layers(SM_Hdr, SM_Master_Identification, sm_command=0x07)
bind_layers(SM_Hdr, SM_Identity_Information, sm_command=0x08)
bind_layers(SM_Hdr, SM_Identity_Address_Information, sm_command=0x09)
bind_layers(SM_Hdr, SM_Signing_Information, sm_command=0x0a)
bind_layers(SM_Hdr, SM_Security_Request, sm_command=0x0b)
bind_layers(SM_Hdr, SM_Public_Key, sm_command=0x0c)
bind_layers(SM_Hdr, SM_DHKey_Check, sm_command=0x0d)

Expand Down
6 changes: 6 additions & 0 deletions test/scapy/layers/bluetooth.uts
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,12 @@ pkt.handles[0].value == b'\x02\x03\x00\x00*'
pkt.handles[1].value == b'\x02\x05\x00\x01*'
pkt.handles[2].value == b'\x02\x07\x00\x04*'

= SM_Security_Request
pkt = HCI_Hdr(hex_bytes('0200260600020006000b0d'))
assert SM_Security_Request in pkt
assert pkt[SM_Security_Request].auth_req == 0x0d


= SM_Public_Key() tests

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