mirror of https://github.com/ARMmbed/mbed-os.git
Merge branch 'master' of https://github.com/paul-szczepanek-arm/mbed-os into pr-sm
commit
8e21b5391a
|
@ -227,7 +227,7 @@ public:
|
|||
for (int i = 5, m = 100000; i >= 0; --i, m /= 10) {
|
||||
uint32_t result = passkey / m;
|
||||
ascii[i] = NUMBER_OFFSET + result;
|
||||
passkey -= result;
|
||||
passkey -= result * m;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -673,19 +673,6 @@ public:
|
|||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porters: override this API if security is supported. */
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the size of the encryption key used on this link.
|
||||
*
|
||||
* @param[in] connectionHandle Handle to identify the connection.
|
||||
* @param[out] byteSize Size of the encryption key in bytes.
|
||||
* @return BLE_ERROR_NONE or appropriate error code indicating the failure reason.
|
||||
*/
|
||||
virtual ble_error_t getEncryptionKeySize(ble::connection_handle_t connectionHandle, uint8_t *byteSize) {
|
||||
(void) connectionHandle;
|
||||
(void) byteSize;
|
||||
return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porters: override this API if security is supported. */
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the requirements for encryption key size. If the peer cannot comply with the requirements
|
||||
* paring will fail.
|
||||
|
|
|
@ -375,25 +375,21 @@ ble_error_t GenericSecurityManager::setLinkEncryption(
|
|||
return BLE_ERROR_OPERATION_NOT_PERMITTED;
|
||||
}
|
||||
|
||||
/* ignore if the link is already at required state*/
|
||||
if (current_encryption == encryption) {
|
||||
eventHandler->linkEncryptionResult(connection, current_encryption);
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
if (encryption == link_encryption_t::NOT_ENCRYPTED) {
|
||||
/* ignore if the link is already at required state*/
|
||||
|
||||
return BLE_ERROR_INVALID_STATE;
|
||||
} else if (encryption == link_encryption_t::NOT_ENCRYPTED) {
|
||||
|
||||
/* ignore if we are requesting an open link on an already encrypted link */
|
||||
|
||||
} else if (encryption == link_encryption_t::ENCRYPTED) {
|
||||
|
||||
/* if already better than encrypted don't bother */
|
||||
if (current_encryption == link_encryption_t::ENCRYPTED_WITH_MITM) {
|
||||
eventHandler->linkEncryptionResult(connection, current_encryption);
|
||||
return BLE_ERROR_NONE;
|
||||
/* only change if we're not already encrypted with mitm */
|
||||
if (current_encryption != link_encryption_t::ENCRYPTED_WITH_MITM) {
|
||||
cb->encryption_requested = true;
|
||||
return enable_encryption(connection);
|
||||
}
|
||||
cb->encryption_requested = true;
|
||||
return enable_encryption(connection);
|
||||
|
||||
} else if (encryption == link_encryption_t::ENCRYPTED_WITH_MITM) {
|
||||
|
||||
|
@ -409,6 +405,8 @@ ble_error_t GenericSecurityManager::setLinkEncryption(
|
|||
return BLE_ERROR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
eventHandler->linkEncryptionResult(connection, current_encryption);
|
||||
|
||||
return BLE_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue