Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
Macros | Functions | Variables
SMPTypes.cpp File Reference
#include <cstring>
#include <string>
#include <memory>
#include <cstdint>
#include <vector>
#include <cstdio>
#include <jau/debug.hpp>
#include "SMPTypes.hpp"
#include "SMPCrypto.hpp"
Include dependency graph for SMPTypes.cpp:

Go to the source code of this file.

Macros

#define APPEND_BITSTR(U, V, M)   append_bitstr(out, M, U::V, #V, comma);
 
#define CASE_TO_STRING_IOCAP(V)   case SMPIOCapability::V: return #V;
 
#define CASE_TO_STRING_OPCODE(V)   case Opcode::V: return #V;
 
#define CASE_TO_STRING_PAIRSTATE(V)   case SMPPairingState::V: return #V;
 
#define CASE_TO_STRING_TYPECODE(V)   case TypeCode::V: return #V;
 
#define CSRKPROP_ENUM(X, M)
 
#define IOCAP_ENUM(X)
 
#define IRKPROP_ENUM(X, M)
 
#define KEYDISTFMT_ENUM(X, M)
 
#define LTKPROP_ENUM(X, M)
 
#define OPCODE_ENUM(X)
 
#define PAIRSTATE_ENUM(X)
 
#define PM_JUST__WORKS   PairingMode::JUST_WORKS
 Mapping SMPIOCapability from initiator and responder to PairingMode. More...
 
#define PM_NUMCOMP_ANY   PairingMode::NUMERIC_COMPARE_ini
 
#define PM_NUMCOMP_INI   PairingMode::NUMERIC_COMPARE_ini
 
#define PM_NUMCOMP_RES   PairingMode::NUMERIC_COMPARE_res
 
#define PM_PASSKEY_ALL   PairingMode::PASSKEY_ENTRY_ini
 
#define PM_PASSKEY_INI   PairingMode::PASSKEY_ENTRY_ini
 
#define PM_PASSKEY_RES   PairingMode::PASSKEY_ENTRY_res
 
#define SMP_LINKKEYTYPE_ENUM(X)
 
#define SMP_LINKKEYTYPE_TO_STRING(V)   case SMPLinkKey::KeyType::V: return #V;
 
#define TYPECODE_ENUM(X)
 

Functions

template<typename T >
static void append_bitstr (std::string &out, T mask, T bit, const std::string &bitstr, bool &comma)
 

Variables

static const PairingMode legacy_pairing [5][5]
 
static const PairingMode seccon_pairing [5][5]
 

Macro Definition Documentation

◆ APPEND_BITSTR

#define APPEND_BITSTR (   U,
  V,
 
)    append_bitstr(out, M, U::V, #V, comma);

Definition at line 47 of file SMPTypes.cpp.

◆ PAIRSTATE_ENUM

#define PAIRSTATE_ENUM (   X)
Value:
X(NONE) \
X(FAILED) \
X(REQUESTED_BY_RESPONDER) \
X(FEATURE_EXCHANGE_STARTED) \
X(FEATURE_EXCHANGE_COMPLETED) \
X(PASSKEY_EXPECTED) \
X(NUMERIC_COMPARE_EXPECTED) \
X(PASSKEY_NOTIFY) \
X(OOB_EXPECTED) \
X(KEY_DISTRIBUTION) \
X(COMPLETED)

Definition at line 49 of file SMPTypes.cpp.

◆ CASE_TO_STRING_PAIRSTATE

#define CASE_TO_STRING_PAIRSTATE (   V)    case SMPPairingState::V: return #V;

Definition at line 62 of file SMPTypes.cpp.

◆ IOCAP_ENUM

#define IOCAP_ENUM (   X)
Value:
X(DISPLAY_ONLY) \
X(DISPLAY_YES_NO) \
X(KEYBOARD_ONLY) \
X(NO_INPUT_NO_OUTPUT) \
X(KEYBOARD_DISPLAY) \
X(UNSET)

Definition at line 80 of file SMPTypes.cpp.

◆ CASE_TO_STRING_IOCAP

#define CASE_TO_STRING_IOCAP (   V)    case SMPIOCapability::V: return #V;

Definition at line 88 of file SMPTypes.cpp.

◆ PM_JUST__WORKS

#define PM_JUST__WORKS   PairingMode::JUST_WORKS

Mapping SMPIOCapability from initiator and responder to PairingMode.

Notable, the following is deduced from BT Core Spec v5.2: Vol 3, Part H (SM): 2.3.5.1 Selecting key generation method Table 2.8 and differs a little from BlueZ smp.c implementation.

Index values, using SMPIOCapabilities as follows: DISPLAY_ONLY = 0x00, DISPLAY_YES_NO = 0x01, KEYBOARD_ONLY = 0x02, NO_INPUT_NO_OUTPUT = 0x03, KEYBOARD_DISPLAY = 0x04

Definition at line 218 of file SMPTypes.cpp.

◆ PM_PASSKEY_INI

#define PM_PASSKEY_INI   PairingMode::PASSKEY_ENTRY_ini

Definition at line 219 of file SMPTypes.cpp.

◆ PM_PASSKEY_RES

#define PM_PASSKEY_RES   PairingMode::PASSKEY_ENTRY_res

Definition at line 220 of file SMPTypes.cpp.

◆ PM_PASSKEY_ALL

#define PM_PASSKEY_ALL   PairingMode::PASSKEY_ENTRY_ini

Definition at line 221 of file SMPTypes.cpp.

◆ PM_NUMCOMP_INI

#define PM_NUMCOMP_INI   PairingMode::NUMERIC_COMPARE_ini

Definition at line 222 of file SMPTypes.cpp.

◆ PM_NUMCOMP_RES

#define PM_NUMCOMP_RES   PairingMode::NUMERIC_COMPARE_res

Definition at line 223 of file SMPTypes.cpp.

◆ PM_NUMCOMP_ANY

#define PM_NUMCOMP_ANY   PairingMode::NUMERIC_COMPARE_ini

Definition at line 224 of file SMPTypes.cpp.

◆ KEYDISTFMT_ENUM

#define KEYDISTFMT_ENUM (   X,
 
)
Value:
X(SMPKeyType,ENC_KEY,M) \
X(SMPKeyType,ID_KEY,M) \
X(SMPKeyType,SIGN_KEY,M) \
X(SMPKeyType,LINK_KEY,M) \
X(SMPKeyType,RFU_1,M) \
X(SMPKeyType,RFU_2,M) \
X(SMPKeyType,RFU_3,M) \
X(SMPKeyType,RFU_4,M)
SMPKeyType
SMP Key Type for Distribution, indicates keys distributed in the Transport Specific Key Distribution ...
Definition: SMPTypes.hpp:415

Definition at line 263 of file SMPTypes.cpp.

◆ LTKPROP_ENUM

#define LTKPROP_ENUM (   X,
 
)
Value:

Definition at line 281 of file SMPTypes.cpp.

◆ IRKPROP_ENUM

#define IRKPROP_ENUM (   X,
 
)

◆ CSRKPROP_ENUM

#define CSRKPROP_ENUM (   X,
 
)

◆ SMP_LINKKEYTYPE_ENUM

#define SMP_LINKKEYTYPE_ENUM (   X)
Value:
X(COMBI) \
X(LOCAL_UNIT) \
X(REMOTE_UNIT) \
X(DBG_COMBI) \
X(UNAUTH_COMBI_P192) \
X(AUTH_COMBI_P192) \
X(CHANGED_COMBI) \
X(UNAUTH_COMBI_P256) \
X(AUTH_COMBI_P256) \
X(NONE)

Definition at line 338 of file SMPTypes.cpp.

◆ SMP_LINKKEYTYPE_TO_STRING

#define SMP_LINKKEYTYPE_TO_STRING (   V)    case SMPLinkKey::KeyType::V: return #V;

Definition at line 350 of file SMPTypes.cpp.

◆ OPCODE_ENUM

#define OPCODE_ENUM (   X)
Value:
X(UNDEFINED) \
X(PAIRING_REQUEST) \
X(PAIRING_RESPONSE) \
X(PAIRING_CONFIRM) \
X(PAIRING_RANDOM) \
X(PAIRING_FAILED) \
X(ENCRYPTION_INFORMATION) \
X(MASTER_IDENTIFICATION) \
X(IDENTITY_INFORMATION) \
X(IDENTITY_ADDRESS_INFORMATION) \
X(SIGNING_INFORMATION) \
X(SECURITY_REQUEST) \
X(PAIRING_PUBLIC_KEY) \
X(PAIRING_DHKEY_CHECK) \
X(PAIRING_KEYPRESS_NOTIFICATION)

Definition at line 360 of file SMPTypes.cpp.

◆ CASE_TO_STRING_OPCODE

#define CASE_TO_STRING_OPCODE (   V)    case Opcode::V: return #V;

Definition at line 377 of file SMPTypes.cpp.

◆ TYPECODE_ENUM

#define TYPECODE_ENUM (   X)
Value:
X(PASSKEY_ENTRY_STARTED) \
X(PASSKEY_DIGIT_ENTERED) \
X(PASSKEY_DIGIT_ERASED) \
X(PASSKEY_CLEARED) \
X(PASSKEY_ENTRY_COMPLETED)

Definition at line 409 of file SMPTypes.cpp.

◆ CASE_TO_STRING_TYPECODE

#define CASE_TO_STRING_TYPECODE (   V)    case TypeCode::V: return #V;

Definition at line 416 of file SMPTypes.cpp.

Function Documentation

◆ append_bitstr()

template<typename T >
static void append_bitstr ( std::string &  out,
mask,
bit,
const std::string &  bitstr,
bool &  comma 
)
static

Definition at line 41 of file SMPTypes.cpp.

Variable Documentation

◆ legacy_pairing

const PairingMode legacy_pairing[5][5]
static
Initial value:

Definition at line 226 of file SMPTypes.cpp.

◆ seccon_pairing

const PairingMode seccon_pairing[5][5]
static