19
19
20
20
#include " ble/pal/GapTypes.h"
21
21
#include " ble/BLETypes.h"
22
- #include " ble/pal /SecurityDb.h"
22
+ #include " ble/generic /SecurityDb.h"
23
23
#include " platform/Callback.h"
24
24
#include " ble/pal/ConnectionEventMonitor.h"
25
25
#include " ble/pal/SigningEventMonitor.h"
@@ -37,8 +37,6 @@ class GenericSecurityManager : public SecurityManager,
37
37
public pal::ConnectionEventMonitor::EventHandler,
38
38
public pal::SigningEventMonitor::EventHandler {
39
39
public:
40
- typedef ble::pal::SecurityDistributionFlags_t SecurityDistributionFlags_t;
41
- typedef ble::pal::SecurityEntryKeys_t SecurityEntryKeys_t;
42
40
43
41
/* implements SecurityManager */
44
42
@@ -51,7 +49,8 @@ class GenericSecurityManager : public SecurityManager,
51
49
bool mitm = true ,
52
50
SecurityIOCapabilities_t iocaps = IO_CAPS_NONE,
53
51
const Passkey_t passkey = NULL ,
54
- bool signing = true
52
+ bool signing = true ,
53
+ const char * db_path = NULL
55
54
);
56
55
57
56
virtual ble_error_t reset ();
@@ -236,13 +235,12 @@ class GenericSecurityManager : public SecurityManager,
236
235
public:
237
236
GenericSecurityManager (
238
237
pal::SecurityManager &palImpl,
239
- pal::SecurityDb &dbImpl,
240
238
pal::ConnectionEventMonitor &connMonitorImpl,
241
239
pal::SigningEventMonitor &signingMonitorImpl
242
240
) : _pal(palImpl),
243
- _db (dbImpl),
244
241
_connection_monitor (connMonitorImpl),
245
242
_signing_monitor(signingMonitorImpl),
243
+ _db(NULL ),
246
244
_default_authentication(0 ),
247
245
_default_key_distribution(pal::KeyDistribution::KEY_DISTRIBUTION_ALL),
248
246
_pairing_authorisation_required(false ),
@@ -256,6 +254,10 @@ class GenericSecurityManager : public SecurityManager,
256
254
_oob_local_random[0 ] = 1 ;
257
255
}
258
256
257
+ ~GenericSecurityManager () {
258
+ delete _db;
259
+ }
260
+
259
261
// //////////////////////////////////////////////////////////////////////////
260
262
// Helper functions
261
263
//
@@ -308,7 +310,7 @@ class GenericSecurityManager : public SecurityManager,
308
310
* @param[in] entryKeys security entry containing keys.
309
311
*/
310
312
void enable_encryption_cb (
311
- pal:: SecurityDb::entry_handle_t entry,
313
+ SecurityDb::entry_handle_t entry,
312
314
const SecurityEntryKeys_t* entryKeys
313
315
);
314
316
@@ -319,32 +321,30 @@ class GenericSecurityManager : public SecurityManager,
319
321
* @param[in] entryKeys security entry containing keys.
320
322
*/
321
323
void set_ltk_cb (
322
- pal:: SecurityDb::entry_handle_t entry,
324
+ SecurityDb::entry_handle_t entry,
323
325
const SecurityEntryKeys_t* entryKeys
324
326
);
325
327
326
328
/* *
327
329
* Returns the CSRK for the connection. Called by the security db.
328
330
*
329
331
* @param[in] connectionHandle Handle to identify the connection.
330
- * @param[in] csrk connection signature resolving key.
332
+ * @param[in] signing connection signature resolving key and counter .
331
333
*/
332
334
void return_csrk_cb (
333
- pal::SecurityDb::entry_handle_t connection,
334
- const csrk_t *csrk,
335
- sign_count_t sign_counter
335
+ SecurityDb::entry_handle_t connection,
336
+ const SecurityEntrySigning_t *signing
336
337
);
337
338
338
339
/* *
339
340
* Set the peer CSRK for the connection. Called by the security db.
340
341
*
341
342
* @param[in] connectionHandle Handle to identify the connection.
342
- * @param[in] csrk connection signature resolving key.
343
+ * @param[in] signing connection signature resolving key and counter .
343
344
*/
344
345
void set_peer_csrk_cb (
345
- pal::SecurityDb::entry_handle_t connection,
346
- const csrk_t *csrk,
347
- sign_count_t sign_counter
346
+ SecurityDb::entry_handle_t connection,
347
+ const SecurityEntrySigning_t *signing
348
348
);
349
349
350
350
/* *
@@ -407,8 +407,8 @@ class GenericSecurityManager : public SecurityManager,
407
407
* @param identity The identity associated with the entry; may be NULL.
408
408
*/
409
409
void on_security_entry_retrieved (
410
- pal:: SecurityDb::entry_handle_t entry,
411
- const pal:: SecurityEntryIdentity_t* identity
410
+ SecurityDb::entry_handle_t entry,
411
+ const SecurityEntryIdentity_t* identity
412
412
);
413
413
414
414
/* *
@@ -421,12 +421,12 @@ class GenericSecurityManager : public SecurityManager,
421
421
* @param count Number of identities entries retrieved.
422
422
*/
423
423
void on_identity_list_retrieved (
424
- ble::ArrayView<pal:: SecurityEntryIdentity_t* >& identity_list,
424
+ ble::ArrayView<SecurityEntryIdentity_t>& identity_list,
425
425
size_t count
426
426
);
427
427
428
428
private:
429
- struct ControlBlock_t : public pal ::SecurityDistributionFlags_t {
429
+ struct ControlBlock_t {
430
430
ControlBlock_t ();
431
431
432
432
pal::KeyDistribution get_initiator_key_distribution () {
@@ -443,7 +443,7 @@ class GenericSecurityManager : public SecurityManager,
443
443
};
444
444
445
445
connection_handle_t connection;
446
- pal:: SecurityDb::entry_handle_t db_entry;
446
+ SecurityDb::entry_handle_t db_entry;
447
447
448
448
address_t local_address; /* *< address used for connection, possibly different from identity */
449
449
@@ -473,10 +473,11 @@ class GenericSecurityManager : public SecurityManager,
473
473
};
474
474
475
475
pal::SecurityManager &_pal;
476
- pal::SecurityDb &_db;
477
476
pal::ConnectionEventMonitor &_connection_monitor;
478
477
pal::SigningEventMonitor &_signing_monitor;
479
478
479
+ SecurityDb *_db;
480
+
480
481
/* OOB data */
481
482
address_t _oob_local_address;
482
483
address_t _oob_peer_address;
@@ -718,7 +719,7 @@ class GenericSecurityManager : public SecurityManager,
718
719
719
720
ControlBlock_t* get_control_block (const address_t &peer_address);
720
721
721
- ControlBlock_t* get_control_block (pal:: SecurityDb::entry_handle_t db_entry);
722
+ ControlBlock_t* get_control_block (SecurityDb::entry_handle_t db_entry);
722
723
723
724
void release_control_block (ControlBlock_t* entry);
724
725
};
0 commit comments