pull/6188/head
Vincent Coubard 2018-03-01 15:39:56 +00:00
commit 8e21b5391a
3 changed files with 11 additions and 26 deletions

View File

@ -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;
}
}

View File

@ -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.

View File

@ -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;
}