btoob

package
v0.543.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package btoob decodes Bluetooth Out-Of-Band (OOB) pairing records — the "tap-to-pair" payload carried by an NFC handover tag and the Bluetooth Secure Simple Pairing OOB data block.

Two MIME types carry these records in an NDEF message:

  • application/vnd.bluetooth.ep.oob — BR/EDR ("Easy Pairing"): a 2-byte little-endian OOB Data Length (counting itself) + a 6-byte little-endian Bluetooth Device Address (BD_ADDR), followed by optional EIR attributes (the same (length, AD-type, data) grammar as a BLE advertisement).
  • application/vnd.bluetooth.le.oob — Bluetooth LE: a bare sequence of AD structures, including the LE Bluetooth Device Address (0x1B) and LE Role (0x1C) that an LE pairing needs.

Decoding such a record recovers the peer's Bluetooth address, device class / role, local name, and the Secure-Simple-Pairing OOB key material (hash C / randomizer R, or the LE SC confirmation/random values) that a tag offers for an authenticated tap-to-pair exchange.

Wrap-vs-native: native. The EIR/AD walk is already implemented in internal/ble (DecodeGAPBytes); this package adds only the thin BR/EDR framing header (length + BD_ADDR) and routes both variants through that shared walker. No third-party dependency is warranted. The BR/EDR framing and the LE Role / device-address value formats are taken from the Bluetooth Core Specification Supplement Part A and the NFC Forum "Bluetooth Secure Simple Pairing Using NFC" application document, as implemented in the ndeflib reference library — verified, not recalled.

Deferred: the OOB key material (Simple Pairing Hash C-192/256 0x0E/0x1D, Randomizer R 0x0F/0x1E, LE SC Confirmation 0x22 / Random 0x23, Security Manager TK 0x10) is surfaced as raw hex via the EIR walker — it is opaque key bytes, not a structure to interpret. Full Class-of-Device minor/service-class tables are device-major specific and left raw beyond the Major Device Class.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	// Variant is "br_edr" or "le".
	Variant string `json:"variant"`
	// DeviceAddress is the mandatory BD_ADDR for a BR/EDR record
	// (MSB-first display form). Empty for an LE record, whose
	// address travels as the LE Bluetooth Device Address AD type.
	DeviceAddress string `json:"device_address,omitempty"`
	// OOBDataLength is the declared BR/EDR OOB Data Length field
	// (counts itself); nil for an LE record.
	OOBDataLength *int `json:"oob_data_length,omitempty"`
	// EIR is the decoded EIR / AD-structure block.
	EIR *ble.GAPAdvertisement `json:"eir,omitempty"`
	// Notes collects non-fatal observations.
	Notes []string `json:"notes,omitempty"`
}

Result is a decoded Bluetooth OOB record.

func DecodeBREDR

func DecodeBREDR(b []byte) (*Result, error)

DecodeBREDR decodes a BR/EDR ("Easy Pairing") OOB record: 2-byte little-endian OOB Data Length + 6-byte little-endian BD_ADDR + optional EIR.

func DecodeHex

func DecodeHex(variant, hexStr string) (*Result, error)

DecodeHex decodes a hex-encoded OOB record. variant selects the framing: "le" / "ble" for application/vnd.bluetooth.le.oob, anything else ("br_edr", "bredr", "ep", "") for the BR/EDR Easy Pairing record.

func DecodeLE

func DecodeLE(b []byte) (*Result, error)

DecodeLE decodes a Bluetooth LE OOB record: a bare sequence of AD structures.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL