correct naming for private members

pull/6188/head
paul-szczepanek-arm 2018-01-23 15:36:57 +00:00
parent 92965baaa8
commit c476fceba3
1 changed files with 100 additions and 98 deletions

View File

@ -53,20 +53,20 @@ public:
const Passkey_t passkey = NULL, const Passkey_t passkey = NULL,
bool signing = true bool signing = true
) { ) {
db.restore(); _db.restore();
pal.set_io_capability((io_capability_t::type) iocaps); _pal.set_io_capability((io_capability_t::type) iocaps);
pal.set_display_passkey(PasskeyAsci::to_num(passkey)); _pal.set_display_passkey(PasskeyAsci::to_num(passkey));
legacy_pairing_allowed = true; _legacy_pairing_allowed = true;
bool secure_connections; bool secure_connections;
pal.get_secure_connections_support(secure_connections); _pal.get_secure_connections_support(secure_connections);
default_authentication.set_bondable(bondable); _default_authentication.set_bondable(bondable);
default_authentication.set_mitm(mitm); _default_authentication.set_mitm(mitm);
default_authentication.set_secure_connections(secure_connections); _default_authentication.set_secure_connections(secure_connections);
default_authentication.set_keypress_notification(true); _default_authentication.set_keypress_notification(true);
default_key_distribution.set_signing(signing); _default_key_distribution.set_signing(signing);
if (signing) { if (signing) {
init_signing(); init_signing();
} }
@ -75,27 +75,27 @@ public:
} }
virtual ble_error_t reset(void) { virtual ble_error_t reset(void) {
db.sync(); _db.sync();
SecurityManager::reset(); SecurityManager::reset();
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
} }
virtual ble_error_t preserveBondingStateOnReset(bool enabled) { virtual ble_error_t preserveBondingStateOnReset(bool enabled) {
db.set_restore(enabled); _db.set_restore(enabled);
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
} }
virtual ble_error_t init_signing() { virtual ble_error_t init_signing() {
/* TODO: store init bit to avoid rerunning needlessly*/ /* TODO: store init bit to avoid rerunning needlessly*/
const csrk_t *pcsrk = db.get_local_csrk(); const csrk_t *pcsrk = _db.get_local_csrk();
if (!pcsrk) { if (!pcsrk) {
csrk_t csrk; csrk_t csrk;
/* TODO: generate csrk */ /* TODO: generate csrk */
pcsrk = &csrk; pcsrk = &csrk;
db.set_local_csrk(*pcsrk); _db.set_local_csrk(*pcsrk);
} }
pal.set_csrk(*pcsrk); _pal.set_csrk(*pcsrk);
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
} }
@ -104,7 +104,7 @@ public:
// //
virtual ble_error_t purgeAllBondingState(void) { virtual ble_error_t purgeAllBondingState(void) {
db.clear_entries(); _db.clear_entries();
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
} }
@ -113,29 +113,29 @@ public:
// //
virtual ble_error_t requestPairing(connection_handle_t connection) { virtual ble_error_t requestPairing(connection_handle_t connection) {
SecurityEntry_t *entry = db.get_entry(connection); SecurityEntry_t *entry = _db.get_entry(connection);
if (!entry) { if (!entry) {
return BLE_ERROR_INVALID_PARAM; return BLE_ERROR_INVALID_PARAM;
} }
/* TODO: remove */ /* TODO: remove */
db.get_entry(connection)->master = true; _db.get_entry(connection)->master = true;
/* end temp code */ /* end temp code */
if (!legacy_pairing_allowed && !default_authentication.get_secure_connections()) { if (!_legacy_pairing_allowed && !_default_authentication.get_secure_connections()) {
return BLE_ERROR_OPERATION_NOT_PERMITTED; return BLE_ERROR_OPERATION_NOT_PERMITTED;
} }
set_mitm_performed(connection, false); set_mitm_performed(connection, false);
AuthenticationMask link_authentication(default_authentication); AuthenticationMask link_authentication(_default_authentication);
link_authentication.set_mitm(entry->mitm_requested); link_authentication.set_mitm(entry->mitm_requested);
KeyDistribution link_key_distribution(default_key_distribution); KeyDistribution link_key_distribution(_default_key_distribution);
link_key_distribution.set_signing(entry->signing_requested); link_key_distribution.set_signing(entry->signing_requested);
link_key_distribution.set_encryption(master_sends_keys); link_key_distribution.set_encryption(_master_sends_keys);
return pal.send_pairing_request( return _pal.send_pairing_request(
connection, connection,
entry->oob, entry->oob,
link_authentication, link_authentication,
@ -145,18 +145,18 @@ public:
} }
virtual ble_error_t acceptPairingRequest(connection_handle_t connection) { virtual ble_error_t acceptPairingRequest(connection_handle_t connection) {
SecurityEntry_t *entry = db.get_entry(connection); SecurityEntry_t *entry = _db.get_entry(connection);
if (!entry) { if (!entry) {
return BLE_ERROR_INVALID_PARAM; return BLE_ERROR_INVALID_PARAM;
} }
AuthenticationMask link_authentication(default_authentication); AuthenticationMask link_authentication(_default_authentication);
link_authentication.set_mitm(entry->mitm_requested); link_authentication.set_mitm(entry->mitm_requested);
KeyDistribution link_key_distribution(default_key_distribution); KeyDistribution link_key_distribution(_default_key_distribution);
link_key_distribution.set_signing(entry->signing_requested); link_key_distribution.set_signing(entry->signing_requested);
return pal.send_pairing_response( return _pal.send_pairing_response(
connection, connection,
entry->oob, entry->oob,
link_authentication, link_authentication,
@ -166,11 +166,11 @@ public:
} }
virtual ble_error_t canceltPairingRequest(connection_handle_t connection) { virtual ble_error_t canceltPairingRequest(connection_handle_t connection) {
return pal.cancel_pairing(connection, pairing_failure_t::UNSPECIFIED_REASON); return _pal.cancel_pairing(connection, pairing_failure_t::UNSPECIFIED_REASON);
} }
virtual ble_error_t setPairingRequestAuthorisation(bool required = true) { virtual ble_error_t setPairingRequestAuthorisation(bool required = true) {
pairing_authorisation_required = required; _pairing_authorisation_required = required;
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
} }
@ -179,12 +179,12 @@ public:
// //
virtual ble_error_t allowLegacyPairing(bool allow = true) { virtual ble_error_t allowLegacyPairing(bool allow = true) {
legacy_pairing_allowed = allow; _legacy_pairing_allowed = allow;
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
} }
virtual ble_error_t getSecureConnectionsSupport(bool *enabled) { virtual ble_error_t getSecureConnectionsSupport(bool *enabled) {
return pal.get_secure_connections_support(*enabled); return _pal.get_secure_connections_support(*enabled);
} }
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
@ -192,18 +192,18 @@ public:
// //
virtual ble_error_t setIoCapability(SecurityIOCapabilities_t iocaps) { virtual ble_error_t setIoCapability(SecurityIOCapabilities_t iocaps) {
return pal.set_io_capability((io_capability_t::type) iocaps); return _pal.set_io_capability((io_capability_t::type) iocaps);
} }
virtual ble_error_t setDisplayPasskey(const Passkey_t passkey) { virtual ble_error_t setDisplayPasskey(const Passkey_t passkey) {
return pal.set_display_passkey(PasskeyAsci::to_num(passkey)); return _pal.set_display_passkey(PasskeyAsci::to_num(passkey));
} }
virtual ble_error_t setAuthenticationTimeout( virtual ble_error_t setAuthenticationTimeout(
connection_handle_t connection, connection_handle_t connection,
uint32_t timeout_in_ms uint32_t timeout_in_ms
) { ) {
return pal.set_authentication_timeout(connection, timeout_in_ms / 10); return _pal.set_authentication_timeout(connection, timeout_in_ms / 10);
} }
virtual ble_error_t getAuthenticationTimeout( virtual ble_error_t getAuthenticationTimeout(
@ -211,7 +211,7 @@ public:
uint32_t *timeout_in_ms uint32_t *timeout_in_ms
) { ) {
uint16_t timeout_in_10ms; uint16_t timeout_in_10ms;
ble_error_t status = pal.get_authentication_timeout(connection, timeout_in_10ms); ble_error_t status = _pal.get_authentication_timeout(connection, timeout_in_10ms);
*timeout_in_ms = 10 * timeout_in_10ms; *timeout_in_ms = 10 * timeout_in_10ms;
return status; return status;
} }
@ -220,7 +220,7 @@ public:
connection_handle_t connection, connection_handle_t connection,
SecurityMode_t securityMode SecurityMode_t securityMode
) { ) {
SecurityEntry_t *entry = db.get_entry(connection); SecurityEntry_t *entry = _db.get_entry(connection);
if (!entry) { if (!entry) {
return BLE_ERROR_INVALID_PARAM; return BLE_ERROR_INVALID_PARAM;
} }
@ -251,7 +251,7 @@ public:
} }
virtual ble_error_t setKeypressNotification(bool enabled = true) { virtual ble_error_t setKeypressNotification(bool enabled = true) {
default_authentication.set_keypress_notification(enabled); _default_authentication.set_keypress_notification(enabled);
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
} }
@ -259,7 +259,7 @@ public:
connection_handle_t connection, connection_handle_t connection,
bool enabled = true bool enabled = true
) { ) {
SecurityEntry_t *entry = db.get_entry(connection); SecurityEntry_t *entry = _db.get_entry(connection);
if (!entry) { if (!entry) {
return BLE_ERROR_INVALID_PARAM; return BLE_ERROR_INVALID_PARAM;
} }
@ -282,18 +282,18 @@ public:
} }
virtual ble_error_t setHintFutureRoleReversal(bool enable = true) { virtual ble_error_t setHintFutureRoleReversal(bool enable = true) {
master_sends_keys = enable; _master_sends_keys = enable;
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
} }
virtual ble_error_t slave_security_request(connection_handle_t connection) { virtual ble_error_t slave_security_request(connection_handle_t connection) {
SecurityEntry_t *entry = db.get_entry(connection); SecurityEntry_t *entry = _db.get_entry(connection);
if (!entry) { if (!entry) {
return BLE_ERROR_INVALID_PARAM; return BLE_ERROR_INVALID_PARAM;
} }
AuthenticationMask link_authentication(default_authentication); AuthenticationMask link_authentication(_default_authentication);
link_authentication.set_mitm(entry->mitm_requested); link_authentication.set_mitm(entry->mitm_requested);
return pal.slave_security_request(connection, link_authentication); return _pal.slave_security_request(connection, link_authentication);
} }
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
@ -313,7 +313,7 @@ public:
link_encryption_t *encryption link_encryption_t *encryption
) { ) {
SecurityEntry_t *entry = db.get_entry(connection); SecurityEntry_t *entry = _db.get_entry(connection);
if (!entry) { if (!entry) {
return BLE_ERROR_INVALID_PARAM; return BLE_ERROR_INVALID_PARAM;
} }
@ -337,7 +337,7 @@ public:
connection_handle_t connection, connection_handle_t connection,
link_encryption_t encryption link_encryption_t encryption
) { ) {
SecurityEntry_t *entry = db.get_entry(connection); SecurityEntry_t *entry = _db.get_entry(connection);
if (!entry) { if (!entry) {
return BLE_ERROR_INVALID_PARAM; return BLE_ERROR_INVALID_PARAM;
} }
@ -357,7 +357,7 @@ public:
if (encryption == link_encryption_t::NOT_ENCRYPTED) { if (encryption == link_encryption_t::NOT_ENCRYPTED) {
if (entry->encrypted) { if (entry->encrypted) {
return pal.disable_encryption(connection); return _pal.disable_encryption(connection);
} }
} else if (encryption == link_encryption_t::ENCRYPTED) { } else if (encryption == link_encryption_t::ENCRYPTED) {
@ -390,7 +390,7 @@ public:
connection_handle_t connection, connection_handle_t connection,
uint8_t *size uint8_t *size
) { ) {
SecurityEntry_t *entry = db.get_entry(connection); SecurityEntry_t *entry = _db.get_entry(connection);
if (entry) { if (entry) {
*size = entry->encryption_key_size; *size = entry->encryption_key_size;
return BLE_ERROR_NONE; return BLE_ERROR_NONE;
@ -403,17 +403,17 @@ public:
uint8_t minimumByteSize, uint8_t minimumByteSize,
uint8_t maximumByteSize uint8_t maximumByteSize
) { ) {
return pal.set_encryption_key_requirements(minimumByteSize, maximumByteSize); return _pal.set_encryption_key_requirements(minimumByteSize, maximumByteSize);
} }
virtual ble_error_t enable_encryption(connection_handle_t connection) { virtual ble_error_t enable_encryption(connection_handle_t connection) {
SecurityEntry_t *entry = db.get_entry(connection); SecurityEntry_t *entry = _db.get_entry(connection);
if (!entry) { if (!entry) {
return BLE_ERROR_INVALID_PARAM; return BLE_ERROR_INVALID_PARAM;
} }
if (entry->master) { if (entry->master) {
if (entry->ltk_stored) { if (entry->ltk_stored) {
db.get_entry_peer_keys( _db.get_entry_peer_keys(
mbed::callback(this, &GenericSecurityManager::enable_encryption_cb), mbed::callback(this, &GenericSecurityManager::enable_encryption_cb),
connection connection
); );
@ -438,7 +438,7 @@ public:
SecurityEntry_t& entry, SecurityEntry_t& entry,
SecurityEntryKeys_t& entryKeys SecurityEntryKeys_t& entryKeys
) { ) {
pal.enable_encryption(entry.handle, entryKeys.ltk, entryKeys.ediv, entryKeys.rand); _pal.enable_encryption(entry.handle, entryKeys.ltk, entryKeys.ediv, entryKeys.rand);
return DB_CB_ACTION_NO_UPDATE_REQUIRED; return DB_CB_ACTION_NO_UPDATE_REQUIRED;
} }
@ -447,7 +447,7 @@ public:
// //
virtual ble_error_t setPrivateAddressTimeout(uint16_t timeout_in_seconds) { virtual ble_error_t setPrivateAddressTimeout(uint16_t timeout_in_seconds) {
return pal.set_private_address_timeout(timeout_in_seconds); return _pal.set_private_address_timeout(timeout_in_seconds);
} }
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
@ -455,7 +455,7 @@ public:
// //
virtual ble_error_t getSigningKey(connection_handle_t connection, bool authenticated) { virtual ble_error_t getSigningKey(connection_handle_t connection, bool authenticated) {
SecurityEntry_t *entry = db.get_entry(connection); SecurityEntry_t *entry = _db.get_entry(connection);
if (!entry) { if (!entry) {
return BLE_ERROR_INVALID_PARAM; return BLE_ERROR_INVALID_PARAM;
} }
@ -463,7 +463,7 @@ public:
if (entry->csrk_stored && (entry->mitm_csrk || !authenticated)) { if (entry->csrk_stored && (entry->mitm_csrk || !authenticated)) {
/* we have a key that is either authenticated or we don't care if it is /* we have a key that is either authenticated or we don't care if it is
* so retrieve it from the db now */ * so retrieve it from the db now */
db.get_entry_csrk( _db.get_entry_csrk(
mbed::callback(this, &GenericSecurityManager::return_csrk_cb), mbed::callback(this, &GenericSecurityManager::return_csrk_cb),
connection connection
); );
@ -494,7 +494,7 @@ public:
SecurityEntry_t& entry, SecurityEntry_t& entry,
SecurityEntryKeys_t& entryKeys SecurityEntryKeys_t& entryKeys
) { ) {
pal.set_ltk(entry.handle, entryKeys.ltk); _pal.set_ltk(entry.handle, entryKeys.ltk);
return DB_CB_ACTION_NO_UPDATE_REQUIRED; return DB_CB_ACTION_NO_UPDATE_REQUIRED;
} }
@ -502,7 +502,7 @@ public:
connection_handle_t connection, connection_handle_t connection,
csrk_t csrk csrk_t csrk
) { ) {
SecurityEntry_t *entry = db.get_entry(connection); SecurityEntry_t *entry = _db.get_entry(connection);
if (!entry) { if (!entry) {
return DB_CB_ACTION_NO_UPDATE_REQUIRED; return DB_CB_ACTION_NO_UPDATE_REQUIRED;
} }
@ -520,7 +520,7 @@ public:
// //
virtual ble_error_t requestAuthentication(connection_handle_t connection) { virtual ble_error_t requestAuthentication(connection_handle_t connection) {
SecurityEntry_t *entry = db.get_entry(connection); SecurityEntry_t *entry = _db.get_entry(connection);
if (!entry) { if (!entry) {
return BLE_ERROR_INVALID_PARAM; return BLE_ERROR_INVALID_PARAM;
} }
@ -551,7 +551,7 @@ public:
bool useOOB, bool useOOB,
bool OOBProvidesMITM = true bool OOBProvidesMITM = true
) { ) {
SecurityEntry_t *entry = db.get_entry(connection); SecurityEntry_t *entry = _db.get_entry(connection);
if (!entry) { if (!entry) {
return BLE_ERROR_INVALID_PARAM; return BLE_ERROR_INVALID_PARAM;
} }
@ -565,14 +565,14 @@ public:
connection_handle_t connection, connection_handle_t connection,
bool confirmation bool confirmation
) { ) {
return pal.confirmation_entered(connection, confirmation); return _pal.confirmation_entered(connection, confirmation);
} }
virtual ble_error_t passkeyEntered( virtual ble_error_t passkeyEntered(
connection_handle_t connection, connection_handle_t connection,
Passkey_t passkey Passkey_t passkey
) { ) {
return pal.passkey_request_reply( return _pal.passkey_request_reply(
connection, connection,
PasskeyAsci::to_num(passkey) PasskeyAsci::to_num(passkey)
); );
@ -582,7 +582,7 @@ public:
connection_handle_t connection, connection_handle_t connection,
Keypress_t keypress Keypress_t keypress
) { ) {
return pal.send_keypress_notification(connection, keypress); return _pal.send_keypress_notification(connection, keypress);
} }
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
@ -599,27 +599,28 @@ public:
} }
protected: protected:
GenericSecurityManager(ble::pal::SecurityManager& palImpl) GenericSecurityManager(ble::pal::SecurityManager& palImpl, GenericSecurityDb& dbImpl)
: pal(palImpl), : _pal(palImpl),
pairing_authorisation_required(false), _db(dbImpl),
legacy_pairing_allowed(true), _pairing_authorisation_required(false),
master_sends_keys(false), _legacy_pairing_allowed(true),
default_authentication(0), _master_sends_keys(false),
default_key_distribution(KeyDistribution::KEY_DISTRIBUTION_ALL) { _default_authentication(0),
_default_key_distribution(KeyDistribution::KEY_DISTRIBUTION_ALL) {
_app_event_handler = &defaultEventHandler; _app_event_handler = &defaultEventHandler;
pal.set_event_handler(this); _pal.set_event_handler(this);
} }
private: private:
ble::pal::SecurityManager& pal; ble::pal::SecurityManager& _pal;
GenericSecurityDb db; GenericSecurityDb& _db;
bool pairing_authorisation_required; bool _pairing_authorisation_required;
bool legacy_pairing_allowed; bool _legacy_pairing_allowed;
bool master_sends_keys; bool _master_sends_keys;
AuthenticationMask default_authentication; AuthenticationMask _default_authentication;
KeyDistribution default_key_distribution; KeyDistribution _default_key_distribution;
/* implements ble::pal::SecurityManagerEventHandler */ /* implements ble::pal::SecurityManagerEventHandler */
public: public:
@ -636,17 +637,17 @@ public:
KeyDistribution responder_dist KeyDistribution responder_dist
) { ) {
/* TODO: remove */ /* TODO: remove */
db.get_entry(connection)->master = false; _db.get_entry(connection)->master = false;
/* end temp code */ /* end temp code */
/* cancel pairing if secure connection paring is not possible */ /* cancel pairing if secure connection paring is not possible */
if (!legacy_pairing_allowed && !authentication.get_secure_connections()) { if (!_legacy_pairing_allowed && !authentication.get_secure_connections()) {
canceltPairingRequest(connection); canceltPairingRequest(connection);
} }
set_mitm_performed(connection, false); set_mitm_performed(connection, false);
if (pairing_authorisation_required) { if (_pairing_authorisation_required) {
_app_event_handler->acceptPairingRequest(connection); _app_event_handler->acceptPairingRequest(connection);
} }
} }
@ -673,7 +674,7 @@ public:
} }
virtual void on_pairing_completed(connection_handle_t connection) { virtual void on_pairing_completed(connection_handle_t connection) {
SecurityEntry_t *entry = db.get_entry(connection); SecurityEntry_t *entry = _db.get_entry(connection);
if (entry) { if (entry) {
if (entry->encryption_requested) { if (entry->encryption_requested) {
enable_encryption(connection); enable_encryption(connection);
@ -703,13 +704,13 @@ public:
connection_handle_t connection, connection_handle_t connection,
AuthenticationMask authentication AuthenticationMask authentication
) { ) {
SecurityEntry_t *entry = db.get_entry(connection); SecurityEntry_t *entry = _db.get_entry(connection);
if (!entry) { if (!entry) {
return; return;
} }
if (authentication.get_secure_connections() if (authentication.get_secure_connections()
&& default_authentication.get_secure_connections() && _default_authentication.get_secure_connections()
&& !entry->secure_connections) { && !entry->secure_connections) {
requestPairing(connection); requestPairing(connection);
} }
@ -730,7 +731,7 @@ public:
link_encryption_t result link_encryption_t result
) { ) {
SecurityEntry_t *entry = db.get_entry(connection); SecurityEntry_t *entry = _db.get_entry(connection);
if (!entry) { if (!entry) {
return; return;
} }
@ -760,7 +761,7 @@ public:
// MITM // MITM
// //
virtual void set_mitm_performed(connection_handle_t connection, bool enable = true) { virtual void set_mitm_performed(connection_handle_t connection, bool enable = true) {
SecurityEntry_t *entry = db.get_entry(connection); SecurityEntry_t *entry = _db.get_entry(connection);
if (entry) { if (entry) {
entry->mitm_performed = true; entry->mitm_performed = true;
} }
@ -816,7 +817,7 @@ public:
const irk_t irk, const irk_t irk,
const csrk_t csrk const csrk_t csrk
) { ) {
SecurityEntry_t *entry = db.get_entry(connection); SecurityEntry_t *entry = _db.get_entry(connection);
if (!entry) { if (!entry) {
return; return;
} }
@ -824,7 +825,7 @@ public:
entry->mitm_ltk = entry->mitm_performed; entry->mitm_ltk = entry->mitm_performed;
entry->mitm_csrk = entry->mitm_performed; entry->mitm_csrk = entry->mitm_performed;
db.set_entry_peer( _db.set_entry_peer(
connection, connection,
(peer_address_type == advertising_peer_address_type_t::PUBLIC_ADDRESS), (peer_address_type == advertising_peer_address_type_t::PUBLIC_ADDRESS),
peer_identity_address, peer_identity_address,
@ -846,12 +847,12 @@ public:
connection_handle_t connection, connection_handle_t connection,
const ltk_t ltk const ltk_t ltk
) { ) {
SecurityEntry_t *entry = db.get_entry(connection); SecurityEntry_t *entry = _db.get_entry(connection);
if (!entry) { if (!entry) {
return; return;
} }
entry->mitm_ltk = entry->mitm_performed; entry->mitm_ltk = entry->mitm_performed;
db.set_entry_peer_ltk(connection, ltk); _db.set_entry_peer_ltk(connection, ltk);
} }
virtual void on_keys_distributed_ediv_rand( virtual void on_keys_distributed_ediv_rand(
@ -859,14 +860,14 @@ public:
const ediv_t ediv, const ediv_t ediv,
const rand_t rand const rand_t rand
) { ) {
db.set_entry_peer_ediv_rand(connection, ediv, rand); _db.set_entry_peer_ediv_rand(connection, ediv, rand);
} }
virtual void on_keys_distributed_local_ltk( virtual void on_keys_distributed_local_ltk(
connection_handle_t connection, connection_handle_t connection,
const ltk_t ltk const ltk_t ltk
) { ) {
db.set_entry_local_ltk(connection, ltk); _db.set_entry_local_ltk(connection, ltk);
} }
virtual void on_keys_distributed_local_ediv_rand( virtual void on_keys_distributed_local_ediv_rand(
@ -874,14 +875,14 @@ public:
const ediv_t ediv, const ediv_t ediv,
const rand_t rand const rand_t rand
) { ) {
db.set_entry_local_ediv_rand(connection, ediv, rand); _db.set_entry_local_ediv_rand(connection, ediv, rand);
} }
virtual void on_keys_distributed_irk( virtual void on_keys_distributed_irk(
connection_handle_t connection, connection_handle_t connection,
const irk_t irk const irk_t irk
) { ) {
db.set_entry_peer_irk(connection, irk); _db.set_entry_peer_irk(connection, irk);
} }
virtual void on_keys_distributed_bdaddr( virtual void on_keys_distributed_bdaddr(
@ -889,7 +890,7 @@ public:
advertising_peer_address_type_t peer_address_type, advertising_peer_address_type_t peer_address_type,
const address_t &peer_identity_address const address_t &peer_identity_address
) { ) {
db.set_entry_peer_bdaddr( _db.set_entry_peer_bdaddr(
connection, connection,
(peer_address_type == advertising_peer_address_type_t::PUBLIC_ADDRESS), (peer_address_type == advertising_peer_address_type_t::PUBLIC_ADDRESS),
peer_identity_address peer_identity_address
@ -900,14 +901,14 @@ public:
connection_handle_t connection, connection_handle_t connection,
const csrk_t csrk const csrk_t csrk
) { ) {
SecurityEntry_t *entry = db.get_entry(connection); SecurityEntry_t *entry = _db.get_entry(connection);
if (!entry) { if (!entry) {
return; return;
} }
entry->mitm_csrk = entry->mitm_performed; entry->mitm_csrk = entry->mitm_performed;
db.set_entry_peer_csrk(connection, csrk); _db.set_entry_peer_csrk(connection, csrk);
_app_event_handler->signingKey( _app_event_handler->signingKey(
connection, connection,
@ -921,7 +922,7 @@ public:
const ediv_t ediv, const ediv_t ediv,
const rand_t rand const rand_t rand
) { ) {
db.get_entry_local_keys( _db.get_entry_local_keys(
mbed::callback(this, &GenericSecurityManager::set_ltk_cb), mbed::callback(this, &GenericSecurityManager::set_ltk_cb),
connection, connection,
ediv, ediv,
@ -930,16 +931,17 @@ public:
} }
virtual void on_disconnected(connection_handle_t connection) { virtual void on_disconnected(connection_handle_t connection) {
SecurityEntry_t *entry = db.get_entry(connection); SecurityEntry_t *entry = _db.get_entry(connection);
if (!entry) { if (!entry) {
return; return;
} }
entry->connected = false; entry->connected = false;
db.sync(); _db.sync();
} }
virtual void on_connected(connection_handle_t connection, address_t peer_address) { virtual void on_connected(connection_handle_t connection, address_t peer_address) {
SecurityEntry_t *entry = db.connect_entry(connection, peer_address); /* TODO: if resolvable peer address, find identity address */
SecurityEntry_t *entry = _db.connect_entry(connection, peer_address);
if (!entry) { if (!entry) {
return; return;
} }