Skip to content

Commit 8e21b53

Browse files
committed
Merge branch 'master' of https://github.com/paul-szczepanek-arm/mbed-os into pr-sm
2 parents 03f79ee + 392ee6e commit 8e21b53

File tree

3 files changed

+11
-26
lines changed

3 files changed

+11
-26
lines changed

features/FEATURE_BLE/ble/BLETypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class PasskeyAscii {
227227
for (int i = 5, m = 100000; i >= 0; --i, m /= 10) {
228228
uint32_t result = passkey / m;
229229
ascii[i] = NUMBER_OFFSET + result;
230-
passkey -= result;
230+
passkey -= result * m;
231231
}
232232
}
233233

features/FEATURE_BLE/ble/SecurityManager.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -673,19 +673,6 @@ class SecurityManager {
673673
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porters: override this API if security is supported. */
674674
}
675675

676-
/**
677-
* Return the size of the encryption key used on this link.
678-
*
679-
* @param[in] connectionHandle Handle to identify the connection.
680-
* @param[out] byteSize Size of the encryption key in bytes.
681-
* @return BLE_ERROR_NONE or appropriate error code indicating the failure reason.
682-
*/
683-
virtual ble_error_t getEncryptionKeySize(ble::connection_handle_t connectionHandle, uint8_t *byteSize) {
684-
(void) connectionHandle;
685-
(void) byteSize;
686-
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porters: override this API if security is supported. */
687-
}
688-
689676
/**
690677
* Set the requirements for encryption key size. If the peer cannot comply with the requirements
691678
* paring will fail.

features/FEATURE_BLE/source/generic/GenericSecurityManager.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -375,25 +375,21 @@ ble_error_t GenericSecurityManager::setLinkEncryption(
375375
return BLE_ERROR_OPERATION_NOT_PERMITTED;
376376
}
377377

378-
/* ignore if the link is already at required state*/
379378
if (current_encryption == encryption) {
380-
eventHandler->linkEncryptionResult(connection, current_encryption);
381-
return BLE_ERROR_NONE;
382-
}
383379

384-
if (encryption == link_encryption_t::NOT_ENCRYPTED) {
380+
/* ignore if the link is already at required state*/
385381

386-
return BLE_ERROR_INVALID_STATE;
382+
} else if (encryption == link_encryption_t::NOT_ENCRYPTED) {
383+
384+
/* ignore if we are requesting an open link on an already encrypted link */
387385

388386
} else if (encryption == link_encryption_t::ENCRYPTED) {
389387

390-
/* if already better than encrypted don't bother */
391-
if (current_encryption == link_encryption_t::ENCRYPTED_WITH_MITM) {
392-
eventHandler->linkEncryptionResult(connection, current_encryption);
393-
return BLE_ERROR_NONE;
388+
/* only change if we're not already encrypted with mitm */
389+
if (current_encryption != link_encryption_t::ENCRYPTED_WITH_MITM) {
390+
cb->encryption_requested = true;
391+
return enable_encryption(connection);
394392
}
395-
cb->encryption_requested = true;
396-
return enable_encryption(connection);
397393

398394
} else if (encryption == link_encryption_t::ENCRYPTED_WITH_MITM) {
399395

@@ -409,6 +405,8 @@ ble_error_t GenericSecurityManager::setLinkEncryption(
409405
return BLE_ERROR_INVALID_PARAM;
410406
}
411407

408+
eventHandler->linkEncryptionResult(connection, current_encryption);
409+
412410
return BLE_ERROR_NONE;
413411
}
414412

0 commit comments

Comments
 (0)