IoCapabilities.NO_INPUT_NO_OUTPUT)
# Possible Authentication Requirements
- auth_reqs = (
- AuthenticationRequirements.NO_BONDING,
- # TODO(optedoblivion): Figure out MITM cases
- AuthenticationRequirements.NO_BONDING_MITM_PROTECTION,
- AuthenticationRequirements.DEDICATED_BONDING,
- AuthenticationRequirements.DEDICATED_BONDING_MITM_PROTECTION,
- AuthenticationRequirements.GENERAL_BONDING,
- AuthenticationRequirements.GENERAL_BONDING_MITM_PROTECTION)
+ auth_reqs = (AuthenticationRequirements.NO_BONDING, AuthenticationRequirements.NO_BONDING_MITM_PROTECTION,
+ AuthenticationRequirements.DEDICATED_BONDING,
+ AuthenticationRequirements.DEDICATED_BONDING_MITM_PROTECTION,
+ AuthenticationRequirements.GENERAL_BONDING, AuthenticationRequirements.GENERAL_BONDING_MITM_PROTECTION)
# Possible Out-of-Band data options
oob_present = (
void ClassicPairingHandler::NotifyUiDisplayYesNo(uint32_t numeric_value) {
ASSERT(user_interface_handler_ != nullptr);
ConfirmationData data(*GetRecord()->GetPseudoAddress(), device_name_, numeric_value);
+ data.PutExtraData("remote_io_caps", hci::IoCapabilityText(remote_io_capability_));
+ data.PutExtraData("remote_auth_reqs", hci::AuthenticationRequirementsText(remote_authentication_requirements_));
+ data.PutExtraData("remote_oob_data_present", hci::OobDataPresentText(remote_oob_present_));
user_interface_handler_->CallOn(user_interface_, &UI::DisplayConfirmValue, data);
}
void ClassicPairingHandler::NotifyUiDisplayYesNo() {
ASSERT(user_interface_handler_ != nullptr);
ConfirmationData data(*GetRecord()->GetPseudoAddress(), device_name_);
+ data.PutExtraData("remote_io_caps", hci::IoCapabilityText(remote_io_capability_));
+ data.PutExtraData("remote_auth_reqs", hci::AuthenticationRequirementsText(remote_authentication_requirements_));
+ data.PutExtraData("remote_oob_data_present", hci::OobDataPresentText(remote_oob_present_));
user_interface_handler_->CallOn(user_interface_, &UI::DisplayYesNoDialog, data);
}
void ClassicPairingHandler::NotifyUiDisplayPasskey(uint32_t passkey) {
ASSERT(user_interface_handler_ != nullptr);
ConfirmationData data(*GetRecord()->GetPseudoAddress(), device_name_, passkey);
+ data.PutExtraData("remote_io_caps", hci::IoCapabilityText(remote_io_capability_));
+ data.PutExtraData("remote_auth_reqs", hci::AuthenticationRequirementsText(remote_authentication_requirements_));
+ data.PutExtraData("remote_oob_data_present", hci::OobDataPresentText(remote_oob_present_));
user_interface_handler_->CallOn(user_interface_, &UI::DisplayPasskey, data);
}
void ClassicPairingHandler::NotifyUiDisplayPasskeyInput() {
ASSERT(user_interface_handler_ != nullptr);
ConfirmationData data(*GetRecord()->GetPseudoAddress(), device_name_);
+ data.PutExtraData("remote_io_caps", hci::IoCapabilityText(remote_io_capability_));
+ data.PutExtraData("remote_auth_reqs", hci::AuthenticationRequirementsText(remote_authentication_requirements_));
+ data.PutExtraData("remote_oob_data_present", hci::OobDataPresentText(remote_oob_present_));
user_interface_handler_->CallOn(user_interface_, &UI::DisplayEnterPasskeyDialog, data);
}
}
void ClassicPairingHandler::OnPairingPromptAccepted(const bluetooth::hci::AddressWithType& address, bool confirmed) {
- LOG_WARN("TODO Not Implemented!");
+ // NOTE: This is not used by Classic, only by LE
+ LOG_ALWAYS_FATAL("This is not supported by Classic Pairing Handler, only LE");
}
void ClassicPairingHandler::OnConfirmYesNo(const bluetooth::hci::AddressWithType& address, bool confirmed) {
LOG_INFO("Received: %s", hci::EventCodeText(packet.GetEventCode()).c_str());
ASSERT_LOG(GetRecord()->GetPseudoAddress()->GetAddress() == packet.GetBdAddr(), "Address mismatch");
- // Using local variable until device database pointer is ready
remote_io_capability_ = packet.GetIoCapability();
remote_authentication_requirements_ = packet.GetAuthenticationRequirements();
remote_oob_present_ = packet.GetOobDataPresent();
namespace {
std::unordered_map<bluetooth::hci::AddressWithType, bt_bdname_t>
address_name_map_;
+
+std::unordered_map<std::string, int> gd_legacy_io_caps_map_ = {
+ {bluetooth::hci::IoCapabilityText(
+ bluetooth::hci::IoCapability::DISPLAY_ONLY),
+ BTM_IO_CAP_OUT},
+ {bluetooth::hci::IoCapabilityText(
+ bluetooth::hci::IoCapability::DISPLAY_YES_NO),
+ BTM_IO_CAP_IO},
+ {bluetooth::hci::IoCapabilityText(
+ bluetooth::hci::IoCapability::KEYBOARD_ONLY),
+ BTM_IO_CAP_IN},
+ {bluetooth::hci::IoCapabilityText(
+ bluetooth::hci::IoCapability::NO_INPUT_NO_OUTPUT),
+ BTM_IO_CAP_NONE},
+};
+
+std::unordered_map<std::string, int> gd_legacy_auth_reqs_map_ = {
+ {bluetooth::hci::AuthenticationRequirementsText(
+ bluetooth::hci::AuthenticationRequirements::NO_BONDING),
+ BTM_AUTH_SP_NO},
+ {bluetooth::hci::AuthenticationRequirementsText(
+ bluetooth::hci::AuthenticationRequirements::
+ NO_BONDING_MITM_PROTECTION),
+ BTM_AUTH_SP_YES},
+ {bluetooth::hci::AuthenticationRequirementsText(
+ bluetooth::hci::AuthenticationRequirements::DEDICATED_BONDING),
+ BTM_AUTH_AP_NO},
+ {bluetooth::hci::AuthenticationRequirementsText(
+ bluetooth::hci::AuthenticationRequirements::
+ DEDICATED_BONDING_MITM_PROTECTION),
+ BTM_AUTH_AP_YES},
+ {bluetooth::hci::AuthenticationRequirementsText(
+ bluetooth::hci::AuthenticationRequirements::GENERAL_BONDING),
+ BTM_AUTH_SPGB_NO},
+ {bluetooth::hci::AuthenticationRequirementsText(
+ bluetooth::hci::AuthenticationRequirements::
+ GENERAL_BONDING_MITM_PROTECTION),
+ BTM_AUTH_SPGB_YES},
+};
}
class ShimUi : public bluetooth::security::UI {
io_req_evt_data.bd_addr = bluetooth::ToRawAddress(address.GetAddress());
// Local IO Caps (Phone is always DisplayYesNo)
io_req_evt_data.io_cap = BTM_IO_CAP_IO;
- io_req_evt_data.auth_req = BTM_AUTH_AP_YES;
+ // Local Auth Reqs (Phone is always DEDICATED_BONDING)
+ io_req_evt_data.auth_req = BTM_AUTH_AP_NO;
io_req_evt_data.oob_data = BTM_OOB_NONE;
(*bta_callbacks_->p_sp_callback)(BTM_SP_IO_REQ_EVT,
(tBTM_SP_EVT_DATA*)&io_req_evt_data);
// Call sp_cback for IO_RSP
tBTM_SP_IO_RSP io_rsp_evt_data;
io_rsp_evt_data.bd_addr = bluetooth::ToRawAddress(address.GetAddress());
- // TODO(optedoblivion): Get remote IO Cap to set here
- io_rsp_evt_data.io_cap = BTM_IO_CAP_IO;
- // TODO(optedoblivion): Get remote AUTH REQ to set here
+ io_rsp_evt_data.io_cap =
+ gd_legacy_io_caps_map_[data.GetExtraData("remote_io_caps")];
+ io_rsp_evt_data.auth_req =
+ gd_legacy_auth_reqs_map_[data.GetExtraData("remote_auth_reqs")];
io_rsp_evt_data.auth_req = BTM_AUTH_AP_YES;
io_rsp_evt_data.oob_data = BTM_OOB_NONE;
(*bta_callbacks_->p_sp_callback)(BTM_SP_IO_RSP_EVT,