Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 37cabe50 authored by Martin Brabham's avatar Martin Brabham
Browse files

GD: Link layer controller classic authentication flow

After running tests on the real device, I have discovered that
these two events come in the opposite order as currently programmed.

Bug: 159075859
Test: cert/run --host --test_filter=SecurityTest:test_dut_initiated_display_yes_no_display_yes_no
Test: cert/run --host --test_filter=SecurityTest:test_dut_initiated_display_yes_no_display_yes_no_init_reject
Tag: #gd-refactor
Change-Id: Ic054c26ce03c502ec60057746036cf416871d980
parent 95e663e7
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -190,6 +190,27 @@ class SecurityTest(GdBaseTestClass):
            expected_init_bond_event=BondMsgType.DEVICE_BONDED,
            expected_resp_bond_event=None)

    # display_yes_no + display_yes_no is JustWorks no confirmation
    def test_dut_initiated_display_yes_no_display_yes_no_init_reject(self):
        # Arrange
        self.dut_security.set_io_capabilities(IoCapabilities.DISPLAY_YES_NO_IO_CAP)
        self.dut_security.set_authentication_requirements(AuthenticationRequirements.DEDICATED_BONDING_MITM_PROTECTION)
        self.dut_security.set_oob_data(OobDataPresent.NOT_PRESENT)
        self.cert_security.set_io_capabilities(IoCapabilities.DISPLAY_YES_NO_IO_CAP)
        self.cert_security.set_authentication_requirements(AuthenticationRequirements.DEDICATED_BONDING_MITM_PROTECTION)
        self.cert_security.set_oob_data(OobDataPresent.NOT_PRESENT)

        # Act and Assert
        self._run_ssp_numeric_comparison(
            initiator=self.dut_security,
            responder=self.cert_security,
            init_ui_response=False,
            resp_ui_response=True,
            expected_init_ui_event=UiMsgType.DISPLAY_YES_NO_WITH_VALUE,
            expected_resp_ui_event=None,
            expected_init_bond_event=BondMsgType.DEVICE_BOND_FAILED,
            expected_resp_bond_event=None)

    # no_input_no_output + display_yes_no is JustWorks no confirmation
    def test_dut_initiated_no_input_no_output_display_yes_no(self):
        # Arrange
+11 −5
Original line number Diff line number Diff line
@@ -1260,16 +1260,16 @@ ErrorCode LinkLayerController::UserConfirmationRequestReply(

  security_manager_.AuthenticationRequestFinished();

  ScheduleTask(milliseconds(5), [this, peer, key_vec]() {
    send_event_(bluetooth::hci::LinkKeyNotificationBuilder::Create(
        peer, key_vec, bluetooth::hci::KeyType::AUTHENTICATED_P256));
  });

  ScheduleTask(milliseconds(5), [this, peer]() {
    send_event_(bluetooth::hci::SimplePairingCompleteBuilder::Create(
        ErrorCode::SUCCESS, peer));
  });

  ScheduleTask(milliseconds(5), [this, peer, key_vec]() {
    send_event_(bluetooth::hci::LinkKeyNotificationBuilder::Create(
        peer, key_vec, bluetooth::hci::KeyType::AUTHENTICATED_P256));
  });

  ScheduleTask(milliseconds(15),
               [this, peer]() { AuthenticateRemoteStage2(peer); });
  return ErrorCode::SUCCESS;
@@ -1280,6 +1280,12 @@ ErrorCode LinkLayerController::UserConfirmationRequestNegativeReply(
  if (security_manager_.GetAuthenticationAddress() != peer) {
    return ErrorCode::AUTHENTICATION_FAILURE;
  }

  ScheduleTask(milliseconds(5), [this, peer]() {
    send_event_(bluetooth::hci::SimplePairingCompleteBuilder::Create(
        ErrorCode::AUTHENTICATION_FAILURE, peer));
  });

  return ErrorCode::SUCCESS;
}