Skip to content

Commit f6f3d24

Browse files
Merge pull request ARMmbed#24 from paul-szczepanek-arm/slave-request
enable encryption for slave request added
2 parents d537bd9 + 6833c79 commit f6f3d24

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

features/FEATURE_BLE/source/generic/GenericSecurityManager.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -853,16 +853,23 @@ void GenericSecurityManager::on_slave_security_request(
853853
return;
854854
}
855855

856-
if (authentication.get_secure_connections()
857-
&& _default_authentication.get_secure_connections()
858-
&& !cb->secure_connections_paired) {
859-
requestPairing(connection);
856+
bool pairing_required = false;
857+
858+
if (authentication.get_secure_connections() && !cb->secure_connections_paired
859+
&& _default_authentication.get_secure_connections()) {
860+
pairing_required = true;
860861
}
861862

862-
if (authentication.get_mitm()
863-
&& !cb->ltk_mitm_protected) {
863+
if (authentication.get_mitm() && !cb->ltk_mitm_protected) {
864+
pairing_required = true;
864865
cb->mitm_requested = true;
866+
}
867+
868+
if (pairing_required) {
865869
requestPairing(connection);
870+
} else if (!cb->encryption_requested) {
871+
/* this will refresh keys if encryption is already present */
872+
enable_encryption(connection);
866873
}
867874
}
868875

0 commit comments

Comments
 (0)