@@ -65,7 +65,7 @@ static void swap_endian(uint8_t data[], uint32_t nbytes)
65
65
}
66
66
}
67
67
68
- static void _passkey_display_cabllack_dfr (BLEPairing ::pair_passkey_cb_t func, uint16_t conn_hdl, uint8_t const passkey[6 ], bool match_request)
68
+ static void _passkey_display_cabllack_dfr (BLESecurity ::pair_passkey_cb_t func, uint16_t conn_hdl, uint8_t const passkey[6 ], bool match_request)
69
69
{
70
70
bool matched = func (conn_hdl, passkey, match_request);
71
71
@@ -76,15 +76,15 @@ static void _passkey_display_cabllack_dfr(BLEPairing::pair_passkey_cb_t func, ui
76
76
}
77
77
}
78
78
79
- BLEPairing::BLEPairing (void )
79
+ BLESecurity::BLESecurity (void )
80
80
{
81
81
_sec_param = _sec_param_default;
82
82
_passkey_cb = NULL ;
83
83
_complete_cb = NULL ;
84
84
_secured_cb = NULL ;
85
85
}
86
86
87
- bool BLEPairing ::begin (void )
87
+ bool BLESecurity ::begin (void )
88
88
{
89
89
#ifdef NRF_CRYPTOCELL
90
90
// Initalize Crypto lib for LESC (safe to call multiple times)
@@ -113,7 +113,7 @@ bool BLEPairing::begin(void)
113
113
return true ;
114
114
}
115
115
116
- void BLEPairing ::setIOCaps (bool display, bool yes_no, bool keyboard)
116
+ void BLESecurity ::setIOCaps (bool display, bool yes_no, bool keyboard)
117
117
{
118
118
uint8_t io_caps = BLE_GAP_IO_CAPS_NONE;
119
119
@@ -138,7 +138,7 @@ void BLEPairing::setIOCaps(bool display, bool yes_no, bool keyboard)
138
138
_sec_param.io_caps = io_caps;
139
139
}
140
140
141
- void BLEPairing ::setMITM (bool enabled)
141
+ void BLESecurity ::setMITM (bool enabled)
142
142
{
143
143
_sec_param.mitm = (enabled ? 1 : 0 );
144
144
}
@@ -149,7 +149,7 @@ void BLEPairing::setMITM(bool enabled)
149
149
*
150
150
* To check if it matches we recreate local AES Hash with IRK to compare with
151
151
*/
152
- bool BLEPairing ::resolveAddress (ble_gap_addr_t const * p_addr, ble_gap_irk_t const * irk)
152
+ bool BLESecurity ::resolveAddress (ble_gap_addr_t const * p_addr, ble_gap_irk_t const * irk)
153
153
{
154
154
VERIFY (p_addr->addr_type == BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE);
155
155
@@ -177,7 +177,7 @@ bool BLEPairing::resolveAddress(ble_gap_addr_t const * p_addr, ble_gap_irk_t con
177
177
}
178
178
179
179
// Use Legacy SC static Passkey
180
- bool BLEPairing ::setPIN (const char * pin)
180
+ bool BLESecurity ::setPIN (const char * pin)
181
181
{
182
182
VERIFY (pin && strlen (pin) == BLE_GAP_PASSKEY_LEN);
183
183
@@ -197,7 +197,7 @@ bool BLEPairing::setPIN(const char* pin)
197
197
}
198
198
199
199
// Pairing using LESC with peripheral display
200
- bool BLEPairing ::setPasskeyCallback (pair_passkey_cb_t fp)
200
+ bool BLESecurity ::setPasskeyCallback (pair_passkey_cb_t fp)
201
201
{
202
202
_passkey_cb = fp;
203
203
@@ -207,23 +207,23 @@ bool BLEPairing::setPasskeyCallback(pair_passkey_cb_t fp)
207
207
return true ;
208
208
}
209
209
210
- void BLEPairing ::setCompleteCallback (pair_complete_cb_t fp)
210
+ void BLESecurity ::setCompleteCallback (pair_complete_cb_t fp)
211
211
{
212
212
_complete_cb = fp;
213
213
}
214
214
215
- void BLEPairing ::setSecuredCallback (pair_secured_cb_t fp)
215
+ void BLESecurity ::setSecuredCallback (pair_secured_cb_t fp)
216
216
{
217
217
_secured_cb = fp;
218
218
}
219
219
220
- bool BLEPairing ::_authenticate (uint16_t conn_hdl)
220
+ bool BLESecurity ::_authenticate (uint16_t conn_hdl)
221
221
{
222
222
VERIFY_STATUS (sd_ble_gap_authenticate (conn_hdl, &_sec_param ), false );
223
223
return true ;
224
224
}
225
225
226
- bool BLEPairing ::_encrypt (uint16_t conn_hdl, bond_keys_t const * ltkey)
226
+ bool BLESecurity ::_encrypt (uint16_t conn_hdl, bond_keys_t const * ltkey)
227
227
{
228
228
// LESC use own key, Legacy use peer key
229
229
ble_gap_enc_key_t const * enc_key = ltkey->own_enc .enc_info .lesc ? <key->own_enc : <key->peer_enc ;
@@ -249,7 +249,7 @@ bool BLEPairing::_encrypt(uint16_t conn_hdl, bond_keys_t const* ltkey)
249
249
* 3. Connection is secured BLE_GAP_EVT_CONN_SEC_UPDATE
250
250
*/
251
251
// --------------------------------------------------------------------+
252
- void BLEPairing ::_eventHandler (ble_evt_t * evt)
252
+ void BLESecurity ::_eventHandler (ble_evt_t * evt)
253
253
{
254
254
uint16_t const conn_hdl = evt->evt .common_evt .conn_handle ;
255
255
BLEConnection* conn = Bluefruit.Connection (conn_hdl);
0 commit comments