36
36
#include " ble/SecurityManager.h"
37
37
38
38
namespace ble {
39
+ namespace impl {
39
40
40
- class BLEInstanceBase ;
41
+ // class BLEInstanceBase;
41
42
42
43
class SecurityManager :
43
- public ble::interface::SecurityManager,
44
44
public ble::PalSecurityManagerEventHandler,
45
45
public ble::PalConnectionMonitorEventHandler,
46
- public ble::PalSigningMonitorEventHandler
47
- {
46
+ public ble::PalSigningMonitorEventHandler {
48
47
friend class ble ::PalConnectionMonitorEventHandler;
49
- friend BLEInstanceBase;
48
+
49
+ friend ::ble::BLEInstanceBase;
50
50
friend PalGenericAccessService;
51
51
friend PalSecurityManager;
52
52
53
+ using SecurityIOCapabilities_t = ble::SecurityManager::SecurityIOCapabilities_t;
54
+ using SecurityMode_t = ble::SecurityManager::SecurityMode_t;
55
+ using SecurityManagerShutdownCallback_t = ble::SecurityManager::SecurityManagerShutdownCallback_t;
56
+ using SecurityManagerShutdownCallbackChain_t = ble::SecurityManager::SecurityManagerShutdownCallbackChain_t;
57
+ using EventHandler = ble::SecurityManager::EventHandler;
58
+ using Passkey_t = ble::SecurityManager::Passkey_t ;
59
+
60
+ static auto constexpr IO_CAPS_NONE = ble::SecurityManager::IO_CAPS_NONE;
61
+
53
62
public:
54
63
// //////////////////////////////////////////////////////////////////////////
55
64
// SM lifecycle management
56
65
//
57
66
58
67
ble_error_t init (
59
- bool enableBonding = true ,
60
- bool requireMITM = true ,
61
- SecurityIOCapabilities_t iocaps = IO_CAPS_NONE,
62
- const Passkey_t passkey = NULL ,
63
- bool signing = true ,
64
- const char *dbFilepath = NULL
68
+ bool enableBonding = true ,
69
+ bool requireMITM = true ,
70
+ SecurityIOCapabilities_t iocaps = IO_CAPS_NONE,
71
+ const Passkey_t passkey = NULL ,
72
+ bool signing = true ,
73
+ const char *dbFilepath = NULL
65
74
);
66
75
67
76
ble_error_t setDatabaseFilepath (const char *dbFilepath = NULL );
@@ -115,6 +124,7 @@ class SecurityManager :
115
124
#if BLE_FEATURE_SIGNING
116
125
117
126
ble_error_t enableSigning (ble::connection_handle_t connectionHandle, bool enabled = true );
127
+
118
128
#endif // BLE_FEATURE_SIGNING
119
129
120
130
ble_error_t setHintFutureRoleReversal (bool enable = true );
@@ -156,7 +166,11 @@ class SecurityManager :
156
166
157
167
ble_error_t legacyPairingOobReceived (const ble::address_t *address, const ble::oob_tk_t *tk);
158
168
159
- ble_error_t oobReceived (const ble::address_t *address, const ble::oob_lesc_value_t *random, const ble::oob_confirm_t *confirm);
169
+ ble_error_t oobReceived (
170
+ const ble::address_t *address,
171
+ const ble::oob_lesc_value_t *random,
172
+ const ble::oob_confirm_t *confirm
173
+ );
160
174
161
175
// //////////////////////////////////////////////////////////////////////////
162
176
// Keys
@@ -175,14 +189,14 @@ class SecurityManager :
175
189
/* Event callback handlers. */
176
190
public:
177
191
178
- void onShutdown (const SecurityManagerShutdownCallback_t& callback);
192
+ void onShutdown (const SecurityManagerShutdownCallback_t & callback);
179
193
180
- template <typename T>
194
+ template <typename T>
181
195
void onShutdown (T *objPtr, void (T::*memberPtr)(const SecurityManager *));
182
196
183
- SecurityManagerShutdownCallbackChain_t& onShutdown ();
197
+ SecurityManagerShutdownCallbackChain_t & onShutdown ();
184
198
185
- void setSecurityManagerEventHandler (EventHandler* handler);
199
+ void setSecurityManagerEventHandler (EventHandler * handler);
186
200
187
201
/* ===================================================================== */
188
202
/* private implementation follows */
@@ -433,7 +447,8 @@ class SecurityManager :
433
447
private:
434
448
/* Disallow copy and assignment. */
435
449
SecurityManager (const SecurityManager &);
436
- SecurityManager& operator =(const SecurityManager &);
450
+
451
+ SecurityManager &operator =(const SecurityManager &);
437
452
438
453
SecurityManager (
439
454
PalSecurityManager &palImpl,
@@ -493,12 +508,12 @@ class SecurityManager :
493
508
494
509
void enable_encryption_cb (
495
510
ble::SecurityDb::entry_handle_t entry,
496
- const SecurityEntryKeys_t* entryKeys
511
+ const SecurityEntryKeys_t * entryKeys
497
512
);
498
513
499
514
void set_ltk_cb (
500
515
SecurityDb::entry_handle_t entry,
501
- const SecurityEntryKeys_t* entryKeys
516
+ const SecurityEntryKeys_t * entryKeys
502
517
);
503
518
504
519
void return_csrk_cb (
@@ -536,28 +551,35 @@ class SecurityManager :
536
551
537
552
void on_security_entry_retrieved (
538
553
SecurityDb::entry_handle_t entry,
539
- const SecurityEntryIdentity_t* identity
554
+ const SecurityEntryIdentity_t * identity
540
555
);
541
556
542
557
void on_identity_list_retrieved (
543
- Span<SecurityEntryIdentity_t>& identity_list,
558
+ Span<SecurityEntryIdentity_t> & identity_list,
544
559
size_t count
545
560
);
546
561
547
562
private:
548
563
struct ControlBlock_t {
549
564
ControlBlock_t ();
550
565
551
- KeyDistribution get_initiator_key_distribution () {
566
+ KeyDistribution get_initiator_key_distribution ()
567
+ {
552
568
return KeyDistribution (initiator_key_distribution);
553
569
};
554
- KeyDistribution get_responder_key_distribution () {
570
+
571
+ KeyDistribution get_responder_key_distribution ()
572
+ {
555
573
return KeyDistribution (responder_key_distribution);
556
574
};
557
- void set_initiator_key_distribution (KeyDistribution mask) {
575
+
576
+ void set_initiator_key_distribution (KeyDistribution mask)
577
+ {
558
578
initiator_key_distribution = mask.value ();
559
579
};
560
- void set_responder_key_distribution (KeyDistribution mask) {
580
+
581
+ void set_responder_key_distribution (KeyDistribution mask)
582
+ {
561
583
responder_key_distribution = mask.value ();
562
584
};
563
585
@@ -567,46 +589,46 @@ class SecurityManager :
567
589
address_t local_address; /* *< address used for connection, possibly different from identity */
568
590
569
591
private:
570
- uint8_t initiator_key_distribution:4 ;
571
- uint8_t responder_key_distribution:4 ;
592
+ uint8_t initiator_key_distribution: 4 ;
593
+ uint8_t responder_key_distribution: 4 ;
572
594
public:
573
- uint8_t connected:1 ;
574
- uint8_t authenticated:1 ; /* *< have we turned encryption on during this connection */
575
- uint8_t is_master:1 ;
595
+ uint8_t connected: 1 ;
596
+ uint8_t authenticated: 1 ; /* *< have we turned encryption on during this connection */
597
+ uint8_t is_master: 1 ;
576
598
577
- uint8_t encryption_requested:1 ;
578
- uint8_t encryption_failed:1 ;
579
- uint8_t encrypted:1 ;
580
- uint8_t signing_requested:1 ;
581
- uint8_t signing_override_default:1 ;
599
+ uint8_t encryption_requested: 1 ;
600
+ uint8_t encryption_failed: 1 ;
601
+ uint8_t encrypted: 1 ;
602
+ uint8_t signing_requested: 1 ;
603
+ uint8_t signing_override_default: 1 ;
582
604
583
- uint8_t mitm_requested:1 ;
584
- uint8_t mitm_performed:1 ; /* *< keys exchange will have MITM protection */
605
+ uint8_t mitm_requested: 1 ;
606
+ uint8_t mitm_performed: 1 ; /* *< keys exchange will have MITM protection */
585
607
586
- uint8_t attempt_oob:1 ;
587
- uint8_t oob_mitm_protection:1 ;
588
- uint8_t oob_present:1 ;
589
- uint8_t legacy_pairing_oob_request_pending:1 ;
608
+ uint8_t attempt_oob: 1 ;
609
+ uint8_t oob_mitm_protection: 1 ;
610
+ uint8_t oob_present: 1 ;
611
+ uint8_t legacy_pairing_oob_request_pending: 1 ;
590
612
591
- uint8_t csrk_failures:2 ;
613
+ uint8_t csrk_failures: 2 ;
592
614
};
593
615
594
616
/* list management */
595
617
596
- ControlBlock_t* acquire_control_block (connection_handle_t connection);
618
+ ControlBlock_t * acquire_control_block (connection_handle_t connection);
597
619
598
- ControlBlock_t* get_control_block (connection_handle_t connection);
620
+ ControlBlock_t * get_control_block (connection_handle_t connection);
599
621
600
- ControlBlock_t* get_control_block (const address_t &peer_address);
622
+ ControlBlock_t * get_control_block (const address_t &peer_address);
601
623
602
- ControlBlock_t* get_control_block (SecurityDb::entry_handle_t db_entry);
624
+ ControlBlock_t * get_control_block (SecurityDb::entry_handle_t db_entry);
603
625
604
- void release_control_block (ControlBlock_t* entry);
626
+ void release_control_block (ControlBlock_t * entry);
605
627
606
628
private:
607
629
SecurityManagerShutdownCallbackChain_t shutdownCallChain;
608
- EventHandler* eventHandler;
609
- EventHandler defaultEventHandler;
630
+ EventHandler * eventHandler;
631
+ EventHandler defaultEventHandler;
610
632
611
633
PalSecurityManager &_pal;
612
634
PalConnectionMonitor &_connection_monitor;
@@ -634,6 +656,7 @@ class SecurityManager :
634
656
ControlBlock_t _control_blocks[MAX_CONTROL_BLOCKS];
635
657
};
636
658
659
+ } // namespace impl
637
660
} // ble
638
661
639
662
#endif /* IMPL_SECURITY_MANAGER_H_*/
0 commit comments