Documentation
¶
Overview ¶
Package smp decodes the Bluetooth LE Security Manager Protocol (SMP, Core spec Vol 3 Part H) — the pairing-and-key-distribution layer carried on L2CAP CID 0x0006. SMP is where BLE security is established (or fails to be): the Pairing Request / Response exchange negotiates the pairing **method** and the keys to distribute, and the choice of method determines whether the link is protected against a man-in-the-middle. A captured SMP exchange is the recon headline for BLE-pairing security: it reveals each side's **IO capability**, whether **MITM protection** is requested, whether **LE Secure Connections** (vs the weaker Legacy pairing) is used, the **max encryption key size**, and which long-term / identity / signing keys are distributed — so it answers "is this pairing **Just Works** (no MITM protection, trivially interceptable) or authenticated?". It completes the project's Bluetooth-stack decode chain (bt_hci_decode → bt_l2cap_decode → here).
Wrap-vs-native judgement ¶
Native. An SMP PDU is a 1-byte code then a fixed body — the Pairing Request/Response is six bytes of bit-fields (IO cap, OOB, AuthReq, key size, two key-distribution masks); the key PDUs are fixed-length keys. A byte read + bit-field decode + small tables; stdlib only, no new go.mod dep.
Verifiable / no confidently-wrong output ¶
The SMP codes, the IO-capability values, the AuthReq bit-fields, the key-distribution flags and the Pairing-Failed reasons follow the Bluetooth Core specification (Vol 3 Part H) — deterministic and byte-checkable. The pairing-method note is derived only from the unambiguous AuthReq bits (MITM / Secure Connections) on the decoded PDU; the exact Legacy method (Just Works vs Passkey vs OOB) also depends on BOTH sides' IO capabilities, so the note states the single-PDU security posture (MITM requested or not, SC or Legacy) rather than over-claiming. The fixed-length key material (LTK / IRK / CSRK / Confirm / Random) is surfaced as raw hex.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result struct {
Code int `json:"code"`
CodeHex string `json:"code_hex"`
CodeName string `json:"code_name"`
// Pairing Request / Response (and, partly, Security Request)
IOCapability string `json:"io_capability,omitempty"`
OOBDataPresent *bool `json:"oob_data_present,omitempty"`
Bonding *bool `json:"bonding,omitempty"`
MITM *bool `json:"mitm_protection,omitempty"`
SecureConnections *bool `json:"secure_connections,omitempty"`
Keypress *bool `json:"keypress,omitempty"`
MaxKeySize *int `json:"max_encryption_key_size,omitempty"`
InitiatorKeyDist []string `json:"initiator_key_distribution,omitempty"`
ResponderKeyDist []string `json:"responder_key_distribution,omitempty"`
PairingPosture string `json:"pairing_security_posture,omitempty"`
// Pairing Failed
FailReason string `json:"fail_reason,omitempty"`
// Identity Address Information
AddressType string `json:"address_type,omitempty"`
Address string `json:"address,omitempty"`
PayloadHex string `json:"payload_hex,omitempty"`
Notes []string `json:"notes,omitempty"`
}
Result is the decoded view of an SMP PDU.