Direct-BT
2.3.1
Direct-BT - Direct Bluetooth Programming.
|
Go to the documentation of this file.
25 #ifndef SMPKEYBIN_HPP_
26 #define SMPKEYBIN_HPP_
64 constexpr
static const uint16_t
VERSION = (uint16_t)0b0101010101010101U + (uint16_t)2U;
69 uint64_t ts_creation_sec;
87 constexpr uint16_t calcSize()
const {
91 s +=
sizeof(ts_creation_sec);
92 s +=
sizeof(addrAndType.
address);
93 s +=
sizeof(addrAndType.
type);
94 s +=
sizeof(sec_level);
97 s +=
sizeof(keys_init);
98 s +=
sizeof(keys_resp);
101 s +=
sizeof(ltk_init);
104 s +=
sizeof(csrk_init);
108 s +=
sizeof(ltk_resp);
111 s +=
sizeof(csrk_resp);
116 static bool remove_impl(
const std::string& fname);
153 static bool createAndWrite(
const BTDevice& device,
const std::string& path,
const bool overwrite,
const bool verbose_);
172 smpKeyBin.
read( fname );
203 addrAndType(addrAndType_), sec_level(sec_level_), io_cap(io_cap_),
205 ltk_init(), csrk_init(), ltk_resp(), csrk_resp(),
207 { size = calcSize(); }
214 ltk_init(), csrk_init(), ltk_resp(), csrk_resp(),
216 { size = calcSize(); }
219 constexpr uint16_t
getVersion() const noexcept {
return version;}
221 constexpr
bool isSizeValid() const noexcept {
return calcSize() == size;}
222 constexpr uint16_t
getSize() const noexcept {
return size;}
280 std::string
toString() const noexcept;
297 return remove_impl(
getFilename(path, addrAndType_));
300 bool write(
const std::string& fname,
const bool overwrite)
const noexcept;
302 bool read(
const std::string& fname);
@ UNSET
Denoting unset value, i.e.
HCIStatusCode apply(BTDevice &device) const noexcept
If this instance isValid() and initiator or responder LTK available, i.e.
static SMPKeyBin read(const std::string &fname, const bool verbose_)
Create a new SMPKeyBin instance based upon stored file denoted by fname.
void setCSRKResp(const SMPSignatureResolvingKeyInfo &v) noexcept
SMPKeyType
SMP Key Type for Distribution, indicates keys distributed in the Transport Specific Key Distribution ...
void setCSRKInit(const SMPSignatureResolvingKeyInfo &v) noexcept
constexpr SMPIOCapability getIOCap() const noexcept
bool write(const std::string &fname, const bool overwrite) const noexcept
static std::string getFilename(const std::string &path, const BDAddressAndType &addrAndType_)
@ SIGN_KEY
Indicates that the device shall distribute CSRK using the Signing Information command.
void setVerbose(bool v) noexcept
BTSecurityLevel
Bluetooth Security Level.
constexpr bool hasLTKResp() const noexcept
HCIStatusCode
BT Core Spec v5.2: Vol 1, Part F Controller Error Codes: 1.3 List of Error Codes.
std::string getFileBasename() const noexcept
Returns the base filename, see SMPKeyBin API doc for naming scheme.
constexpr bool hasCSRKInit() const noexcept
@ ENC_KEY
LE legacy pairing: Indicates device shall distribute LTK using the Encryption Information command,...
constexpr bool isVersionValid() const noexcept
constexpr static const uint16_t VERSION
uint64_t getWallClockSeconds() noexcept
Returns current wall-clock system time of day in seconds since Unix Epoch 00:00:00 UTC on 1 January 1...
static SMPKeyBin create(const BTDevice &device)
Create a new SMPKeyBin instance based upon given BTDevice's BTSecurityLevel, SMPPairingState,...
SMP Signature Resolving Key Info, used for platform agnostic persistence.
constexpr const BDAddressAndType & getAddrAndType() const noexcept
@ UNSET
Security Level not set, value 0.
constexpr BTSecurityLevel getSecLevel() const noexcept
Storage for SMP keys including the required connection parameter.
void setLTKInit(const SMPLongTermKeyInfo &v) noexcept
std::string toString() const noexcept
static HCIStatusCode readAndApply(const std::string &path, BTDevice &device, const BTSecurityLevel minSecLevel, const bool verbose_)
Create a new SMPKeyBin instance on the fly based upon stored file denoted by path and BTDevice::getAd...
SMPKeyBin(const BDAddressAndType &addrAndType_, const BTSecurityLevel sec_level_, const SMPIOCapability io_cap_)
void setLTKResp(const SMPLongTermKeyInfo &v) noexcept
SMPIOCapability
Vol 3, Part H, 2.3.2 IO capabilities.
constexpr bool hasLTKInit() const noexcept
constexpr const SMPLongTermKeyInfo & getLTKResp() const noexcept
constexpr const SMPSignatureResolvingKeyInfo & getCSRKResp() const noexcept
static bool remove(const std::string &path, const BDAddressAndType &addrAndType_)
constexpr bool hasCSRKResp() const noexcept
static bool createAndWrite(const BTDevice &device, const std::string &path, const bool overwrite, const bool verbose_)
Create a new SMPKeyBin instance on the fly based upon given BTDevice's BTSecurityLevel,...
constexpr uint16_t getVersion() const noexcept
constexpr bool isValid() const noexcept
Returns true if.
constexpr const SMPSignatureResolvingKeyInfo & getCSRKInit() const noexcept
constexpr uint16_t getSize() const noexcept
constexpr bool isSizeValid() const noexcept
Unique Bluetooth EUI48 address and BDAddressType tuple.
constexpr bool isValid() const noexcept
constexpr const SMPLongTermKeyInfo & getLTKInit() const noexcept
constexpr uint64_t getCreationTime() const noexcept
Returns the creation timestamp in seconds since Unix epoch.
SMP Long Term Key Info, used for platform agnostic persistence.