Skip to content

Commit 5e78aa3

Browse files
committed
rename BLEPairing to BLESecurity
1 parent f604a2c commit 5e78aa3

File tree

4 files changed

+21
-22
lines changed

4 files changed

+21
-22
lines changed

libraries/Bluefruit52Lib/src/BLECentral.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ void BLECentral::_eventHandler(ble_evt_t* evt)
145145
bond_keys_t ltkey;
146146
if ( conn->loadBondKey(&ltkey) )
147147
{
148-
BLEPairing* secure = &Bluefruit.Pairing;
149-
secure->_encrypt(conn_hdl, &ltkey);
148+
Bluefruit.Pairing._encrypt(conn_hdl, &ltkey);
150149
}
151150
}
152151
break;

libraries/Bluefruit52Lib/src/BLEPairing.cpp renamed to libraries/Bluefruit52Lib/src/BLESecurity.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static void swap_endian(uint8_t data[], uint32_t nbytes)
6565
}
6666
}
6767

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)
6969
{
7070
bool matched = func(conn_hdl, passkey, match_request);
7171

@@ -76,15 +76,15 @@ static void _passkey_display_cabllack_dfr(BLEPairing::pair_passkey_cb_t func, ui
7676
}
7777
}
7878

79-
BLEPairing::BLEPairing(void)
79+
BLESecurity::BLESecurity(void)
8080
{
8181
_sec_param = _sec_param_default;
8282
_passkey_cb = NULL;
8383
_complete_cb = NULL;
8484
_secured_cb = NULL;
8585
}
8686

87-
bool BLEPairing::begin(void)
87+
bool BLESecurity::begin(void)
8888
{
8989
#ifdef NRF_CRYPTOCELL
9090
// Initalize Crypto lib for LESC (safe to call multiple times)
@@ -113,7 +113,7 @@ bool BLEPairing::begin(void)
113113
return true;
114114
}
115115

116-
void BLEPairing::setIOCaps(bool display, bool yes_no, bool keyboard)
116+
void BLESecurity::setIOCaps(bool display, bool yes_no, bool keyboard)
117117
{
118118
uint8_t io_caps = BLE_GAP_IO_CAPS_NONE;
119119

@@ -138,7 +138,7 @@ void BLEPairing::setIOCaps(bool display, bool yes_no, bool keyboard)
138138
_sec_param.io_caps = io_caps;
139139
}
140140

141-
void BLEPairing::setMITM(bool enabled)
141+
void BLESecurity::setMITM(bool enabled)
142142
{
143143
_sec_param.mitm = (enabled ? 1 : 0);
144144
}
@@ -149,7 +149,7 @@ void BLEPairing::setMITM(bool enabled)
149149
*
150150
* To check if it matches we recreate local AES Hash with IRK to compare with
151151
*/
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)
153153
{
154154
VERIFY(p_addr->addr_type == BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE);
155155

@@ -177,7 +177,7 @@ bool BLEPairing::resolveAddress(ble_gap_addr_t const * p_addr, ble_gap_irk_t con
177177
}
178178

179179
// Use Legacy SC static Passkey
180-
bool BLEPairing::setPIN(const char* pin)
180+
bool BLESecurity::setPIN(const char* pin)
181181
{
182182
VERIFY(pin && strlen(pin) == BLE_GAP_PASSKEY_LEN);
183183

@@ -197,7 +197,7 @@ bool BLEPairing::setPIN(const char* pin)
197197
}
198198

199199
// Pairing using LESC with peripheral display
200-
bool BLEPairing::setPasskeyCallback(pair_passkey_cb_t fp)
200+
bool BLESecurity::setPasskeyCallback(pair_passkey_cb_t fp)
201201
{
202202
_passkey_cb = fp;
203203

@@ -207,23 +207,23 @@ bool BLEPairing::setPasskeyCallback(pair_passkey_cb_t fp)
207207
return true;
208208
}
209209

210-
void BLEPairing::setCompleteCallback(pair_complete_cb_t fp)
210+
void BLESecurity::setCompleteCallback(pair_complete_cb_t fp)
211211
{
212212
_complete_cb = fp;
213213
}
214214

215-
void BLEPairing::setSecuredCallback(pair_secured_cb_t fp)
215+
void BLESecurity::setSecuredCallback(pair_secured_cb_t fp)
216216
{
217217
_secured_cb = fp;
218218
}
219219

220-
bool BLEPairing::_authenticate(uint16_t conn_hdl)
220+
bool BLESecurity::_authenticate(uint16_t conn_hdl)
221221
{
222222
VERIFY_STATUS(sd_ble_gap_authenticate(conn_hdl, &_sec_param ), false);
223223
return true;
224224
}
225225

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)
227227
{
228228
// LESC use own key, Legacy use peer key
229229
ble_gap_enc_key_t const* enc_key = ltkey->own_enc.enc_info.lesc ? &ltkey->own_enc : &ltkey->peer_enc;
@@ -249,7 +249,7 @@ bool BLEPairing::_encrypt(uint16_t conn_hdl, bond_keys_t const* ltkey)
249249
* 3. Connection is secured BLE_GAP_EVT_CONN_SEC_UPDATE
250250
*/
251251
//--------------------------------------------------------------------+
252-
void BLEPairing::_eventHandler(ble_evt_t* evt)
252+
void BLESecurity::_eventHandler(ble_evt_t* evt)
253253
{
254254
uint16_t const conn_hdl = evt->evt.common_evt.conn_handle;
255255
BLEConnection* conn = Bluefruit.Connection(conn_hdl);

libraries/Bluefruit52Lib/src/BLEPairing.h renamed to libraries/Bluefruit52Lib/src/BLESecurity.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
* THE SOFTWARE.
2323
*/
2424

25-
#ifndef BLEPAIRING_H_
26-
#define BLEPAIRING_H_
25+
#ifndef BLESECURITY_H_
26+
#define BLESECURITY_H_
2727

2828
#include "bluefruit_common.h"
2929
#include "utility/bonding.h"
@@ -32,14 +32,14 @@
3232
#include "Adafruit_nRFCrypto.h"
3333
#endif
3434

35-
class BLEPairing
35+
class BLESecurity
3636
{
3737
public:
3838
typedef bool (*pair_passkey_cb_t ) (uint16_t conn_hdl, uint8_t const passkey[6], bool match_request);
3939
typedef void (*pair_complete_cb_t) (uint16_t conn_hdl, uint8_t auth_status);
4040
typedef void (*pair_secured_cb_t) (uint16_t conn_hdl);
4141

42-
BLEPairing(void);
42+
BLESecurity(void);
4343

4444
bool begin(void);
4545

@@ -86,4 +86,4 @@ class BLEPairing
8686
pair_secured_cb_t _secured_cb;
8787
};
8888

89-
#endif /* BLEPAIRING_H_ */
89+
#endif /* BLESECURITY_H_ */

libraries/Bluefruit52Lib/src/bluefruit.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
#include "BLEDiscovery.h"
5656
#include "BLEConnection.h"
5757
#include "BLEGatt.h"
58-
#include "BLEPairing.h"
58+
#include "BLESecurity.h"
5959

6060
// Services
6161
#include "services/BLEDis.h"
@@ -111,7 +111,7 @@ class AdafruitBluefruit
111111
*------------------------------------------------------------------*/
112112
BLEPeriph Periph;
113113
BLECentral Central;
114-
BLEPairing Pairing;
114+
BLESecurity Pairing;
115115
BLEGatt Gatt;
116116

117117
BLEAdvertising Advertising;

0 commit comments

Comments
 (0)