Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
SMPKeyBin.hpp
Go to the documentation of this file.
1/*
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright (c) 2021 Gothel Software e.K.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25#ifndef SMPKEYBIN_HPP_
26#define SMPKEYBIN_HPP_
27
28#include <cstring>
29#include <string>
30#include <memory>
31#include <cstdint>
32
33#include "SMPTypes.hpp"
34#include "HCITypes.hpp"
35
36namespace direct_bt {
37
38class BTDevice; // forward
39class BTAdapter; // forward
40
41/** \addtogroup DBTUserAPI
42 *
43 * @{
44 */
45
46/**
47 * Storage for SMP keys including required connection parameter per local adapter and remote device.
48 *
49 * File format version 5.
50 *
51 * Storage for a device's BDAddressAndType, its security connection setup ::BTSecurityLevel + ::SMPIOCapability
52 * and optionally the initiator and responder SMPLongTermKeyInfo (LTK), SMPSignatureResolvingKeyInfo (CSRK)
53 * and SMPLinkKeyInfo (LK) within one file.
54 * <p>
55 * Since the SMPLongTermKeyInfo (LTK), SMPSignatureResolvingKeyInfo (CSRK)
56 * and SMPLinkKeyInfo (LK)
57 * are optionally set depending on their availability per initiator and responder,
58 * implementation supports mixed mode for certain devices.
59 * E.g. LTK responder key only etc.
60 * </p>
61 * <p>
62 * Data is stored in endian::little format, native to Bluetooth.
63 * </p>
64 * <p>
65 * Filename as retrieved by SMPKeyBin::getFileBasename()
66 * has the following form `bd_010203040506_C026DA01DAB11.key`:
67 * <ul>
68 * <li>{@code 'bd_'} prefix</li>
69 * <li>{@code '010203040506'} local {@link EUI48} local adapter address</li>
70 * <li>{@code '_'} separator</li>
71 * <li>{@code 'C026DA01DAB1'} remote {@link EUI48} remote device address</li>
72 * <li>{@code '1'} {@link BDAddressType}</li>
73 * <li>{@code '.key'} suffix</li>
74 * </li>
75 * </p>
76 * @see BTDevice::setSMPKeyBin()
77 * @see BTDevice::uploadKeys()
78 */
79class SMPKeyBin {
80 public:
81 constexpr static const uint16_t VERSION = (uint16_t)0b0101010101010101U + (uint16_t)6U; // bitpattern + version
82
83 private:
84 uint16_t version; // 2
85 uint16_t size; // 2
86 uint64_t ts_creation_sec; // 8
87 BTRole localRole; // 1
88 BDAddressAndType localAddress; // 7
89 BDAddressAndType remoteAddress; // 7
90 BTSecurityLevel sec_level; // 1
91 SMPIOCapability io_cap; // 1
92
93 SMPKeyType keys_init; // 1
94 SMPKeyType keys_resp; // 1 -> 31
95
96 SMPLongTermKey ltk_init; // 28 (optional)
97 SMPIdentityResolvingKey irk_init; // 23 (optional)
98 SMPSignatureResolvingKey csrk_init; // 17 (optional)
99 SMPLinkKey lk_init; // 19 (optional)
100
101 SMPLongTermKey ltk_resp; // 28 (optional)
102 SMPIdentityResolvingKey irk_resp; // 23 (optional)
103 SMPSignatureResolvingKey csrk_resp; // 17 (optional)
104 SMPLinkKey lk_resp; // 19 (optional)
105
106 constexpr static const int byte_size_max = 205;
107 constexpr static const int byte_size_min = 31;
108
109 bool verbose;
110
111 constexpr uint16_t calcSize() const {
112 uint16_t s = 0;
113 s += sizeof(version);
114 s += sizeof(size);
115 s += sizeof(ts_creation_sec);
116 s += sizeof(localRole);
117 s += sizeof(localAddress.address);
118 s += sizeof(localAddress.type);
119 s += sizeof(remoteAddress.address);
120 s += sizeof(remoteAddress.type);
121 s += sizeof(sec_level);
122 s += sizeof(io_cap);
123
124 s += sizeof(keys_init);
125 s += sizeof(keys_resp);
126
127 if( hasLTKInit() ) {
128 s += sizeof(ltk_init);
129 }
130 if( hasIRKInit() ) {
131 s += sizeof(irk_init);
132 }
133 if( hasCSRKInit() ) {
134 s += sizeof(csrk_init);
135 }
136 if( hasLKInit() ) {
137 s += sizeof(lk_init);
138 }
139
140 if( hasLTKResp() ) {
141 s += sizeof(ltk_resp);
142 }
143 if( hasIRKResp() ) {
144 s += sizeof(irk_resp);
145 }
146 if( hasCSRKResp() ) {
147 s += sizeof(csrk_resp);
148 }
149 if( hasLKResp() ) {
150 s += sizeof(lk_resp);
151 }
152 return s;
153 }
154
155 static bool remove_impl(const std::string& fname);
156
157 public:
158 /**
159 * Create a new SMPKeyBin instance based upon given BTDevice's
160 * BTSecurityLevel, SMPPairingState, PairingMode and LTK keys.
161 *
162 * Returned SMPKeyBin shall be tested if valid via SMPKeyBin::isValid(),
163 * whether the retrieved data from BTDevice is consistent and hence
164 * having BTDevice is a well connected state.
165 *
166 * @param device the BTDevice from which all required data is derived
167 * @return a valid SMPKeyBin instance if properly connected, otherwise an invalid instance.
168 * @see BTDevice
169 * @see isValid()
170 */
171 static SMPKeyBin create(const BTDevice& device);
172
173 /**
174 * Create a new SMPKeyBin instance on the fly based upon given BTDevice's
175 * BTSecurityLevel, SMPPairingState, PairingMode and LTK keys.
176 * If valid, instance is stored to a file denoted by `path` and `BTDevice::getAddressAndType()`.
177 *
178 * If BTDevice::getPairingMode() is PairingMode::PRE_PAIRED, an existing file will not be overwritten.
179 * Otherwise, a new key is assumed and an existing file shall be overwritten.
180 *
181 * Method returns `false` if resulting SMPKeyBin is not SMPKeyBin::isValid().
182 * Otherwise, method returns the SMPKeyBin::write() result.
183 *
184 * @param device the BTDevice from which all required data is derived
185 * @param path the path for the stored SMPKeyBin file.
186 * @param verbose_ set to true to have detailed write processing logged to stderr, otherwise false
187 * @return `true` if file has been successfully written, otherwise `false`.
188 * @see BTDevice
189 * @see Create()
190 * @see write()
191 * @see isValid()
192 */
193 static bool createAndWrite(const BTDevice& device, const std::string& path, const bool verbose_);
194
195 /**
196 * Create a new SMPKeyBin instance based upon stored file denoted by `fname`.
197 *
198 * Returned SMPKeyBin shall be tested if valid via SMPKeyBin::isValid(),
199 * whether the read() operation was successful and data is consistent.
200 *
201 * If file is invalid, it is removed.
202 *
203 * @param fname full path of the stored SMPKeyBin file.
204 * @param verbose_ set to true to have detailed read processing logged to stderr, otherwise false
205 * @return valid SMPKeyBin instance if file exist and read successfully, otherwise invalid SMPKeyBin instance.
206 * @see isValid()
207 * @see read()
208 */
209 static SMPKeyBin read(const std::string& fname, const bool verbose_) {
210 SMPKeyBin smpKeyBin;
211 smpKeyBin.setVerbose( verbose_ );
212 smpKeyBin.read( fname ); // read failure -> !isValid()
213 return smpKeyBin;
214 }
215
216 /**
217 * Create a new SMPKeyBin instance based upon the given BTDevice's matching filename,
218 * see SMPKeyBin API doc for filename naming scheme.
219 *
220 * Returned SMPKeyBin shall be tested if valid via SMPKeyBin::isValid(),
221 * whether the read() operation was successful and data is consistent.
222 *
223 * If file is invalid, it is removed.
224 *
225 * @param path directory for the stored SMPKeyBin file.
226 * @param device BTDevice used to derive the filename, see getFilename()
227 * @param verbose_ set to true to have detailed read processing logged to stderr, otherwise false
228 * @return valid SMPKeyBin instance if file exist and read successfully, otherwise invalid SMPKeyBin instance.
229 * @see getFilename()
230 * @see isValid()
231 * @see read()
232 */
233 static SMPKeyBin read(const std::string& path, const BTDevice& device, const bool verbose_) {
234 return read(getFilename(path, device), verbose_);
235 }
236
237 static std::vector<SMPKeyBin> readAll(const std::string& dname, const bool verbose_);
238 static std::vector<SMPKeyBin> readAllForLocalAdapter(const BDAddressAndType& localAddress, const std::string& dname, const bool verbose_);
239
240 SMPKeyBin(BTRole localRole_, BDAddressAndType localAddress_,
241 BDAddressAndType remoteAddress_,
242 const BTSecurityLevel sec_level_, const SMPIOCapability io_cap_)
243 : version(VERSION), size(0),
244 ts_creation_sec( jau::getWallClockSeconds() ),
245 localRole(localRole_),
246 localAddress(std::move(localAddress_)), remoteAddress(std::move(remoteAddress_)),
247 sec_level(sec_level_), io_cap(io_cap_),
248 keys_init(SMPKeyType::NONE), keys_resp(SMPKeyType::NONE),
249 ltk_init(), irk_init(), csrk_init(), lk_init(),
250 ltk_resp(), irk_resp(), csrk_resp(), lk_resp(),
251 verbose(false)
252 { size = calcSize(); }
253
255 : version(VERSION), size(0),
256 ts_creation_sec(0),
257 localRole(BTRole::None),
258 localAddress(), remoteAddress(),
259 sec_level(BTSecurityLevel::UNSET), io_cap(SMPIOCapability::UNSET),
260 keys_init(SMPKeyType::NONE), keys_resp(SMPKeyType::NONE),
261 ltk_init(), irk_init(), csrk_init(), lk_init(),
262 ltk_resp(), irk_resp(), csrk_resp(), lk_resp(),
263 verbose(false)
264 { size = calcSize(); }
265
266 constexpr bool isVersionValid() const noexcept { return VERSION==version; }
267 constexpr uint16_t getVersion() const noexcept { return version;}
268
269 constexpr bool isSizeValid() const noexcept { return calcSize() == size;}
270 constexpr uint16_t getSize() const noexcept { return size;}
271
272 /** Returns the creation timestamp in seconds since Unix epoch */
273 constexpr uint64_t getCreationTime() const noexcept { return ts_creation_sec; }
274
275 /** Return the local adapter BTRole. */
276 constexpr BTRole getLocalRole() const noexcept { return localRole; }
277
278 /** Return the local adapter address. */
279 constexpr const BDAddressAndType& getLocalAddrAndType() const noexcept { return localAddress; }
280
281 /** Return the remote device address. */
282 constexpr const BDAddressAndType& getRemoteAddrAndType() const noexcept { return remoteAddress; }
283
284 /** Return whether Secure Connection (SC) is being used via LTK keys. */
285 constexpr bool uses_SC() const noexcept {
288 }
289
290 constexpr BTSecurityLevel getSecLevel() const noexcept { return sec_level; }
291 constexpr SMPIOCapability getIOCap() const noexcept { return io_cap; }
292
293 constexpr bool hasLTKInit() const noexcept { return is_set(keys_init, SMPKeyType::ENC_KEY); }
294 constexpr bool hasIRKInit() const noexcept { return is_set(keys_init, SMPKeyType::ID_KEY); }
295 constexpr bool hasCSRKInit() const noexcept { return is_set(keys_init, SMPKeyType::SIGN_KEY); }
296 constexpr bool hasLKInit() const noexcept { return is_set(keys_init, SMPKeyType::LINK_KEY); }
297 constexpr const SMPLongTermKey& getLTKInit() const noexcept { return ltk_init; }
298 constexpr const SMPIdentityResolvingKey& getIRKInit() const noexcept { return irk_init; }
299 constexpr const SMPSignatureResolvingKey& getCSRKInit() const noexcept { return csrk_init; }
300 constexpr const SMPLinkKey& getLKInit() const noexcept { return lk_init; }
301 void setLTKInit(const SMPLongTermKey& v) noexcept {
302 ltk_init = v;
303 keys_init |= SMPKeyType::ENC_KEY;
304 size = calcSize();
305 }
306 void setIRKInit(const SMPIdentityResolvingKey& v) noexcept {
307 irk_init = v;
308 keys_init |= SMPKeyType::ID_KEY;
309 size = calcSize();
310 }
311 void setCSRKInit(const SMPSignatureResolvingKey& v) noexcept {
312 csrk_init = v;
313 keys_init |= SMPKeyType::SIGN_KEY;
314 size = calcSize();
315 }
316 void setLKInit(const SMPLinkKey& v) noexcept {
317 lk_init = v;
318 keys_init |= SMPKeyType::LINK_KEY;
319 size = calcSize();
320 }
321
322 constexpr bool hasLTKResp() const noexcept { return is_set(keys_resp, SMPKeyType::ENC_KEY); }
323 constexpr bool hasIRKResp() const noexcept { return is_set(keys_resp, SMPKeyType::ID_KEY); }
324 constexpr bool hasCSRKResp() const noexcept { return is_set(keys_resp, SMPKeyType::SIGN_KEY); }
325 constexpr bool hasLKResp() const noexcept { return is_set(keys_resp, SMPKeyType::LINK_KEY); }
326 constexpr const SMPLongTermKey& getLTKResp() const noexcept { return ltk_resp; }
327 constexpr const SMPIdentityResolvingKey& getIRKResp() const noexcept { return irk_resp; }
328 constexpr const SMPSignatureResolvingKey& getCSRKResp() const noexcept { return csrk_resp; }
329 constexpr const SMPLinkKey& getLKResp() const noexcept { return lk_resp; }
330 void setLTKResp(const SMPLongTermKey& v) noexcept {
331 ltk_resp = v;
332 keys_resp |= SMPKeyType::ENC_KEY;
333 size = calcSize();
334 }
335 void setIRKResp(const SMPIdentityResolvingKey& v) noexcept {
336 irk_resp = v;
337 keys_resp |= SMPKeyType::ID_KEY;
338 size = calcSize();
339 }
340 void setCSRKResp(const SMPSignatureResolvingKey& v) noexcept {
341 csrk_resp = v;
342 keys_resp |= SMPKeyType::SIGN_KEY;
343 size = calcSize();
344 }
345 void setLKResp(const SMPLinkKey& v) noexcept {
346 lk_resp = v;
347 keys_resp |= SMPKeyType::LINK_KEY;
348 size = calcSize();
349 }
350
351 void setVerbose(bool v) noexcept { verbose = v; }
352
353 constexpr bool getVerbose() const noexcept { return verbose; }
354
355 /**
356 * Returns `true` if
357 *
358 * isVersionValid() && isSizeValid() &&
359 * not BTSecurityLevel::UNSET &&
360 * not SMPIOCapability::UNSET &&
361 * has valid LTK, if at all
362 *
363 */
364 constexpr bool isValid() const noexcept {
365 // local_is_responder == true: responder's IRK info (LL slave), else the initiator's (LL master)
366 const bool local_is_responder = BTRole::Slave == localRole;
367 const BDAddressAndType& responderAddress = local_is_responder ? localAddress : remoteAddress;
368 const BDAddressAndType& initiatorAddress = local_is_responder ? remoteAddress : localAddress;
369
370 return isVersionValid() && isSizeValid() &&
371 BTSecurityLevel::UNSET != sec_level &&
372 SMPIOCapability::UNSET != io_cap &&
373 ( !hasLTKInit() || ltk_init.isValid() ) &&
374 ( !hasLTKResp() || ltk_resp.isValid() ) &&
375 ( !hasLKInit() || lk_init.isValid() ) &&
376 ( !hasLKResp() || lk_resp.isValid() ) &&
377 ( !hasIRKInit() || irk_init.id_address == initiatorAddress.address ) &&
378 ( !hasIRKResp() || irk_resp.id_address == responderAddress.address );
379 }
380
381 std::string toString() const noexcept;
382
383 /**
384 * Returns the base filename, see SMPKeyBin API doc for naming scheme.
385 */
386 std::string getFileBasename() const noexcept;
387
388 /**
389 * Returns the base filename, see SMPKeyBin API doc for naming scheme.
390 */
391 static std::string getFileBasename(const BDAddressAndType& localAddress_, const BDAddressAndType& remoteAddress_) noexcept;
392
393 static std::string getFilename(const std::string& path, const BDAddressAndType& localAddress_, const BDAddressAndType& remoteAddress_) noexcept {
394 return path + "/" + getFileBasename(localAddress_, remoteAddress_);
395 }
396 static std::string getFilename(const std::string& path, const BTDevice& remoteDevice) noexcept ;
397
398 static bool remove(const std::string& path, const BDAddressAndType& localAddress_, const BDAddressAndType& remoteAddress_) {
399 return remove_impl( getFilename(path, localAddress_, remoteAddress_) );
400 }
401 static bool remove(const std::string& path, const BTDevice& remoteDevice);
402
403 std::string getFilename(const std::string& path) const noexcept {
404 return getFilename(path, localAddress, remoteAddress);
405 }
406 bool remove(const std::string& path) {
407 return remove_impl( getFilename(path) );
408 }
409
410 bool write(const std::string& path, const bool overwrite) const noexcept;
411
412 bool read(const std::string& fname);
413};
414
415/**@}*/
416
417} // namespace direct_bt
418
419#endif /* SMPKEYBIN_HPP_ */
Unique Bluetooth EUI48 address and BDAddressType tuple.
Definition: BTAddress.hpp:175
BTDevice represents one remote Bluetooth device.
Definition: BTDevice.hpp:81
Storage for SMP keys including required connection parameter per local adapter and remote device.
Definition: SMPKeyBin.hpp:79
constexpr bool hasLKInit() const noexcept
Definition: SMPKeyBin.hpp:296
static std::string getFilename(const std::string &path, const BDAddressAndType &localAddress_, const BDAddressAndType &remoteAddress_) noexcept
Definition: SMPKeyBin.hpp:393
constexpr const SMPLinkKey & getLKResp() const noexcept
Definition: SMPKeyBin.hpp:329
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,...
Definition: SMPKeyBin.hpp:233
constexpr bool getVerbose() const noexcept
Definition: SMPKeyBin.hpp:353
void setLTKResp(const SMPLongTermKey &v) noexcept
Definition: SMPKeyBin.hpp:330
static std::vector< SMPKeyBin > readAll(const std::string &dname, const bool verbose_)
Definition: SMPKeyBin.cpp:125
constexpr bool hasLTKInit() const noexcept
Definition: SMPKeyBin.hpp:293
void setLKResp(const SMPLinkKey &v) noexcept
Definition: SMPKeyBin.hpp:345
static std::vector< SMPKeyBin > readAllForLocalAdapter(const BDAddressAndType &localAddress, const std::string &dname, const bool verbose_)
Definition: SMPKeyBin.cpp:137
std::string toString() const noexcept
Definition: SMPKeyBin.cpp:148
constexpr const SMPSignatureResolvingKey & getCSRKInit() const noexcept
Definition: SMPKeyBin.hpp:299
constexpr bool hasIRKInit() const noexcept
Definition: SMPKeyBin.hpp:294
constexpr uint64_t getCreationTime() const noexcept
Returns the creation timestamp in seconds since Unix epoch.
Definition: SMPKeyBin.hpp:273
constexpr bool isValid() const noexcept
Returns true if.
Definition: SMPKeyBin.hpp:364
void setVerbose(bool v) noexcept
Definition: SMPKeyBin.hpp:351
constexpr const SMPIdentityResolvingKey & getIRKResp() const noexcept
Definition: SMPKeyBin.hpp:327
constexpr SMPIOCapability getIOCap() const noexcept
Definition: SMPKeyBin.hpp:291
static SMPKeyBin create(const BTDevice &device)
Create a new SMPKeyBin instance based upon given BTDevice's BTSecurityLevel, SMPPairingState,...
Definition: SMPKeyBin.cpp:64
void setCSRKInit(const SMPSignatureResolvingKey &v) noexcept
Definition: SMPKeyBin.hpp:311
static bool remove(const std::string &path, const BDAddressAndType &localAddress_, const BDAddressAndType &remoteAddress_)
Definition: SMPKeyBin.hpp:398
constexpr uint16_t getSize() const noexcept
Definition: SMPKeyBin.hpp:270
void setIRKResp(const SMPIdentityResolvingKey &v) noexcept
Definition: SMPKeyBin.hpp:335
void setIRKInit(const SMPIdentityResolvingKey &v) noexcept
Definition: SMPKeyBin.hpp:306
constexpr bool uses_SC() const noexcept
Return whether Secure Connection (SC) is being used via LTK keys.
Definition: SMPKeyBin.hpp:285
constexpr bool hasLKResp() const noexcept
Definition: SMPKeyBin.hpp:325
constexpr bool hasLTKResp() const noexcept
Definition: SMPKeyBin.hpp:322
void setCSRKResp(const SMPSignatureResolvingKey &v) noexcept
Definition: SMPKeyBin.hpp:340
static constexpr const uint16_t VERSION
Definition: SMPKeyBin.hpp:81
constexpr bool hasCSRKInit() const noexcept
Definition: SMPKeyBin.hpp:295
constexpr bool isSizeValid() const noexcept
Definition: SMPKeyBin.hpp:269
bool write(const std::string &path, const bool overwrite) const noexcept
Definition: SMPKeyBin.cpp:246
void setLTKInit(const SMPLongTermKey &v) noexcept
Definition: SMPKeyBin.hpp:301
SMPKeyBin(BTRole localRole_, BDAddressAndType localAddress_, BDAddressAndType remoteAddress_, const BTSecurityLevel sec_level_, const SMPIOCapability io_cap_)
Definition: SMPKeyBin.hpp:240
std::string getFilename(const std::string &path) const noexcept
Definition: SMPKeyBin.hpp:403
std::string getFileBasename() const noexcept
Returns the base filename, see SMPKeyBin API doc for naming scheme.
Definition: SMPKeyBin.cpp:226
bool remove(const std::string &path)
Definition: SMPKeyBin.hpp:406
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,...
Definition: SMPKeyBin.cpp:111
constexpr const SMPLongTermKey & getLTKResp() const noexcept
Definition: SMPKeyBin.hpp:326
static SMPKeyBin read(const std::string &fname, const bool verbose_)
Create a new SMPKeyBin instance based upon stored file denoted by fname.
Definition: SMPKeyBin.hpp:209
constexpr const SMPIdentityResolvingKey & getIRKInit() const noexcept
Definition: SMPKeyBin.hpp:298
constexpr const BDAddressAndType & getLocalAddrAndType() const noexcept
Return the local adapter address.
Definition: SMPKeyBin.hpp:279
void setLKInit(const SMPLinkKey &v) noexcept
Definition: SMPKeyBin.hpp:316
constexpr const SMPLongTermKey & getLTKInit() const noexcept
Definition: SMPKeyBin.hpp:297
constexpr const BDAddressAndType & getRemoteAddrAndType() const noexcept
Return the remote device address.
Definition: SMPKeyBin.hpp:282
constexpr uint16_t getVersion() const noexcept
Definition: SMPKeyBin.hpp:267
constexpr BTRole getLocalRole() const noexcept
Return the local adapter BTRole.
Definition: SMPKeyBin.hpp:276
constexpr BTSecurityLevel getSecLevel() const noexcept
Definition: SMPKeyBin.hpp:290
constexpr bool isVersionValid() const noexcept
Definition: SMPKeyBin.hpp:266
constexpr bool hasIRKResp() const noexcept
Definition: SMPKeyBin.hpp:323
constexpr bool hasCSRKResp() const noexcept
Definition: SMPKeyBin.hpp:324
constexpr const SMPLinkKey & getLKInit() const noexcept
Definition: SMPKeyBin.hpp:300
constexpr const SMPSignatureResolvingKey & getCSRKResp() const noexcept
Definition: SMPKeyBin.hpp:328
SMPKeyType
SMP Key Type for Distribution, indicates keys distributed in the Transport Specific Key Distribution ...
Definition: SMPTypes.hpp:415
SMPIOCapability
Vol 3, Part H, 2.3.2 IO capabilities.
Definition: SMPTypes.hpp:209
@ LINK_KEY
SMP on the LE transport: Indicate that the device would like to derive the Link Key from the LTK.
@ SIGN_KEY
Indicates that the device shall distribute CSRK using the Signing Information command.
@ ENC_KEY
LE legacy pairing: Indicates device shall distribute LTK using the Encryption Information command,...
@ ID_KEY
Indicates that the device shall distribute IRK using the Identity Information command followed by its...
@ UNSET
Denoting unset value, i.e.
BTRole
Bluetooth roles from the perspective of the link layer (connection initiator).
Definition: BTTypes0.hpp:69
BTSecurityLevel
Bluetooth Security Level.
Definition: BTTypes0.hpp:267
constexpr bool is_set(const LE_Features mask, const LE_Features bit) noexcept
Definition: BTTypes0.hpp:219
@ None
Undefined role.
@ Slave
Slave or peripheral role, advertising and waiting for connections to accept.
@ UNSET
Security Level not set, value 0.
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
Definition: backtrace.hpp:32
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...
Definition: basic_types.cpp:71
STL namespace.
SMP Identity Resolving Key, used for platform agnostic persistence.
Definition: SMPTypes.hpp:636
EUI48 id_address
Identity Address for the IRK.
Definition: SMPTypes.hpp:636
Local SMP Link Key, used for platform agnostic persistence, mapping to platform specific MgmtLoadLink...
Definition: SMPTypes.hpp:824
constexpr bool isValid() const noexcept
Definition: SMPTypes.hpp:824
SMP Long Term Key, used for platform agnostic persistence.
Definition: SMPTypes.hpp:552
constexpr bool isValid() const noexcept
Definition: SMPTypes.hpp:552
@ SC
Secure Connection used.
Property properties
SMPLongTermKey::Property bit mask.
Definition: SMPTypes.hpp:552
SMP Signature Resolving Key, used for platform agnostic persistence.
Definition: SMPTypes.hpp:712