Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
|
Storage for SMP keys including required connection parameter per local adapter and remote device. More...
#include <SMPKeyBin.hpp>
Public Member Functions | |
SMPKeyBin () | |
SMPKeyBin (BTRole localRole_, BDAddressAndType localAddress_, BDAddressAndType remoteAddress_, const BTSecurityLevel sec_level_, const SMPIOCapability io_cap_) | |
constexpr uint64_t | getCreationTime () const noexcept |
Returns the creation timestamp in seconds since Unix epoch. More... | |
constexpr const SMPSignatureResolvingKey & | getCSRKInit () const noexcept |
constexpr const SMPSignatureResolvingKey & | getCSRKResp () const noexcept |
std::string | getFileBasename () const noexcept |
Returns the base filename, see SMPKeyBin API doc for naming scheme. More... | |
std::string | getFilename (const std::string &path) const noexcept |
constexpr SMPIOCapability | getIOCap () const noexcept |
constexpr const SMPIdentityResolvingKey & | getIRKInit () const noexcept |
constexpr const SMPIdentityResolvingKey & | getIRKResp () const noexcept |
constexpr const SMPLinkKey & | getLKInit () const noexcept |
constexpr const SMPLinkKey & | getLKResp () const noexcept |
constexpr const BDAddressAndType & | getLocalAddrAndType () const noexcept |
Return the local adapter address. More... | |
constexpr BTRole | getLocalRole () const noexcept |
Return the local adapter BTRole. More... | |
constexpr const SMPLongTermKey & | getLTKInit () const noexcept |
constexpr const SMPLongTermKey & | getLTKResp () const noexcept |
constexpr const BDAddressAndType & | getRemoteAddrAndType () const noexcept |
Return the remote device address. More... | |
constexpr BTSecurityLevel | getSecLevel () const noexcept |
constexpr uint16_t | getSize () const noexcept |
constexpr bool | getVerbose () const noexcept |
constexpr uint16_t | getVersion () const noexcept |
constexpr bool | hasCSRKInit () const noexcept |
constexpr bool | hasCSRKResp () const noexcept |
constexpr bool | hasIRKInit () const noexcept |
constexpr bool | hasIRKResp () const noexcept |
constexpr bool | hasLKInit () const noexcept |
constexpr bool | hasLKResp () const noexcept |
constexpr bool | hasLTKInit () const noexcept |
constexpr bool | hasLTKResp () const noexcept |
constexpr bool | isSizeValid () const noexcept |
constexpr bool | isValid () const noexcept |
Returns true if. More... | |
constexpr bool | isVersionValid () const noexcept |
bool | read (const std::string &fname) |
bool | remove (const std::string &path) |
void | setCSRKInit (const SMPSignatureResolvingKey &v) noexcept |
void | setCSRKResp (const SMPSignatureResolvingKey &v) noexcept |
void | setIRKInit (const SMPIdentityResolvingKey &v) noexcept |
void | setIRKResp (const SMPIdentityResolvingKey &v) noexcept |
void | setLKInit (const SMPLinkKey &v) noexcept |
void | setLKResp (const SMPLinkKey &v) noexcept |
void | setLTKInit (const SMPLongTermKey &v) noexcept |
void | setLTKResp (const SMPLongTermKey &v) noexcept |
void | setVerbose (bool v) noexcept |
std::string | toString () const noexcept |
constexpr bool | uses_SC () const noexcept |
Return whether Secure Connection (SC) is being used via LTK keys. More... | |
bool | write (const std::string &path, const bool overwrite) const noexcept |
Static Public Member Functions | |
static SMPKeyBin | create (const BTDevice &device) |
Create a new SMPKeyBin instance based upon given BTDevice's BTSecurityLevel, SMPPairingState, PairingMode and LTK keys. More... | |
static bool | createAndWrite (const BTDevice &device, const std::string &path, const bool verbose_) |
Create a new SMPKeyBin instance on the fly based upon given BTDevice's BTSecurityLevel, SMPPairingState, PairingMode and LTK keys. More... | |
static std::string | getFileBasename (const BDAddressAndType &localAddress_, const BDAddressAndType &remoteAddress_) noexcept |
Returns the base filename, see SMPKeyBin API doc for naming scheme. More... | |
static std::string | getFilename (const std::string &path, const BDAddressAndType &localAddress_, const BDAddressAndType &remoteAddress_) noexcept |
static std::string | getFilename (const std::string &path, const BTDevice &remoteDevice) noexcept |
static SMPKeyBin | read (const std::string &fname, const bool verbose_) |
Create a new SMPKeyBin instance based upon stored file denoted by fname . More... | |
static SMPKeyBin | read (const std::string &path, const BTDevice &device, const bool verbose_) |
Create a new SMPKeyBin instance based upon the given BTDevice's matching filename, see SMPKeyBin API doc for filename naming scheme. More... | |
static std::vector< SMPKeyBin > | readAll (const std::string &dname, const bool verbose_) |
static std::vector< SMPKeyBin > | readAllForLocalAdapter (const BDAddressAndType &localAddress, const std::string &dname, const bool verbose_) |
static bool | remove (const std::string &path, const BDAddressAndType &localAddress_, const BDAddressAndType &remoteAddress_) |
static bool | remove (const std::string &path, const BTDevice &remoteDevice) |
Static Public Attributes | |
static constexpr const uint16_t | VERSION = (uint16_t)0b0101010101010101U + (uint16_t)6U |
Storage for SMP keys including required connection parameter per local adapter and remote device.
File format version 5.
Storage for a device's BDAddressAndType, its security connection setup BTSecurityLevel + SMPIOCapability and optionally the initiator and responder SMPLongTermKeyInfo (LTK), SMPSignatureResolvingKeyInfo (CSRK) and SMPLinkKeyInfo (LK) within one file.
Since the SMPLongTermKeyInfo (LTK), SMPSignatureResolvingKeyInfo (CSRK) and SMPLinkKeyInfo (LK) are optionally set depending on their availability per initiator and responder, implementation supports mixed mode for certain devices. E.g. LTK responder key only etc.
Data is stored in endian::little format, native to Bluetooth.
Filename as retrieved by SMPKeyBin::getFileBasename() has the following form bd_010203040506_C026DA01DAB11.key
:
'bd_'
prefix '010203040506'
local EUI48
local adapter address '_'
separator 'C026DA01DAB1'
remote EUI48
remote device address '1'
BDAddressType
'.key'
suffix
Definition at line 79 of file SMPKeyBin.hpp.
|
inline |
Definition at line 240 of file SMPKeyBin.hpp.
|
inline |
Definition at line 254 of file SMPKeyBin.hpp.
Create a new SMPKeyBin instance based upon given BTDevice's BTSecurityLevel, SMPPairingState, PairingMode and LTK keys.
Returned SMPKeyBin shall be tested if valid via SMPKeyBin::isValid(), whether the retrieved data from BTDevice is consistent and hence having BTDevice is a well connected state.
device | the BTDevice from which all required data is derived |
Definition at line 64 of file SMPKeyBin.cpp.
|
static |
Create a new SMPKeyBin instance on the fly based upon given BTDevice's BTSecurityLevel, SMPPairingState, PairingMode and LTK keys.
If valid, instance is stored to a file denoted by path
and BTDevice::getAddressAndType()
.
If BTDevice::getPairingMode() is PairingMode::PRE_PAIRED, an existing file will not be overwritten. Otherwise, a new key is assumed and an existing file shall be overwritten.
Method returns false
if resulting SMPKeyBin is not SMPKeyBin::isValid(). Otherwise, method returns the SMPKeyBin::write() result.
device | the BTDevice from which all required data is derived |
path | the path for the stored SMPKeyBin file. |
verbose_ | set to true to have detailed write processing logged to stderr, otherwise false |
true
if file has been successfully written, otherwise false
. Definition at line 111 of file SMPKeyBin.cpp.
|
inlinestatic |
Create a new SMPKeyBin instance based upon stored file denoted by fname
.
Returned SMPKeyBin shall be tested if valid via SMPKeyBin::isValid(), whether the read() operation was successful and data is consistent.
If file is invalid, it is removed.
fname | full path of the stored SMPKeyBin file. |
verbose_ | set to true to have detailed read processing logged to stderr, otherwise false |
Definition at line 209 of file SMPKeyBin.hpp.
|
inlinestatic |
Create a new SMPKeyBin instance based upon the given BTDevice's matching filename, see SMPKeyBin API doc for filename naming scheme.
Returned SMPKeyBin shall be tested if valid via SMPKeyBin::isValid(), whether the read() operation was successful and data is consistent.
If file is invalid, it is removed.
path | directory for the stored SMPKeyBin file. |
device | BTDevice used to derive the filename, see getFilename() |
verbose_ | set to true to have detailed read processing logged to stderr, otherwise false |
Definition at line 233 of file SMPKeyBin.hpp.
|
static |
|
static |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Definition at line 267 of file SMPKeyBin.hpp.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Definition at line 270 of file SMPKeyBin.hpp.
|
inlineconstexprnoexcept |
Returns the creation timestamp in seconds since Unix epoch.
Definition at line 273 of file SMPKeyBin.hpp.
|
inlineconstexprnoexcept |
Return the local adapter BTRole.
Definition at line 276 of file SMPKeyBin.hpp.
|
inlineconstexprnoexcept |
Return the local adapter address.
Definition at line 279 of file SMPKeyBin.hpp.
|
inlineconstexprnoexcept |
Return the remote device address.
Definition at line 282 of file SMPKeyBin.hpp.
|
inlineconstexprnoexcept |
Return whether Secure Connection (SC) is being used via LTK keys.
Definition at line 285 of file SMPKeyBin.hpp.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Definition at line 291 of file SMPKeyBin.hpp.
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Definition at line 298 of file SMPKeyBin.hpp.
|
inlineconstexprnoexcept |
Definition at line 299 of file SMPKeyBin.hpp.
|
inlineconstexprnoexcept |
Definition at line 300 of file SMPKeyBin.hpp.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
Definition at line 327 of file SMPKeyBin.hpp.
|
inlineconstexprnoexcept |
Definition at line 328 of file SMPKeyBin.hpp.
|
inlineconstexprnoexcept |
Definition at line 329 of file SMPKeyBin.hpp.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlineconstexprnoexcept |
Definition at line 353 of file SMPKeyBin.hpp.
|
inlineconstexprnoexcept |
Returns true
if.
isVersionValid() && isSizeValid() && not BTSecurityLevel::UNSET && not SMPIOCapability::UNSET && has valid LTK, if at all
Definition at line 364 of file SMPKeyBin.hpp.
|
noexcept |
|
noexcept |
Returns the base filename, see SMPKeyBin API doc for naming scheme.
Definition at line 226 of file SMPKeyBin.cpp.
|
staticnoexcept |
Returns the base filename, see SMPKeyBin API doc for naming scheme.
Definition at line 232 of file SMPKeyBin.cpp.
|
inlinestaticnoexcept |
|
staticnoexcept |
Definition at line 238 of file SMPKeyBin.cpp.
|
inlinestatic |
|
static |
Definition at line 242 of file SMPKeyBin.cpp.
|
inlinenoexcept |
Definition at line 403 of file SMPKeyBin.hpp.
|
inline |
Definition at line 406 of file SMPKeyBin.hpp.
|
noexcept |
bool SMPKeyBin::read | ( | const std::string & | fname | ) |
Definition at line 341 of file SMPKeyBin.cpp.
|
staticconstexpr |
Definition at line 81 of file SMPKeyBin.hpp.