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

Commit bf1785b4 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I561e863e,I00cb33c2 into main

* changes:
  lmp: handle passkey entry failure on initiating side
  build: use `pdlc` instead of `pdl`
parents d9974a52 0a5c4b8a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -60,8 +60,8 @@ fn generate_module(in_file: &PathBuf) {

    // Find the pdl tool. Expecting it at CARGO_HOME/bin
    let pdl = match env::var("CARGO_HOME") {
        Ok(dir) => PathBuf::from(dir).join("bin").join("pdl"),
        Err(_) => PathBuf::from("pdl"),
        Ok(dir) => PathBuf::from(dir).join("bin").join("pdlc"),
        Err(_) => PathBuf::from("pdlc"),
    };

    if !Path::new(pdl.as_os_str()).exists() {
+35 −8
Original line number Diff line number Diff line
@@ -439,12 +439,22 @@ pub async fn initiate(ctx: &impl Context) -> Result<(), ()> {
            | AuthenticationMethod::NumericComparisonUserConfirm => {
                send_commitment(ctx, true).await;

                user_confirmation_request(ctx).await?;
                if user_confirmation_request(ctx).await.is_err() {
                    ctx.send_lmp_packet(
                        lmp::NumericComparisonFailedBuilder { transaction_id: 0 }.build(),
                    );
                    Err(())?;
                }
                Ok(())
            }
            AuthenticationMethod::PasskeyEntry => {
                if initiator.io_capability == hci::IoCapability::KeyboardOnly {
                    user_passkey_request(ctx).await?;
                    if user_passkey_request(ctx).await.is_err() {
                        ctx.send_lmp_packet(
                            lmp::PasskeyFailedBuilder { transaction_id: 0 }.build(),
                        );
                        Err(())?;
                    }
                } else {
                    ctx.send_hci_event(
                        hci::UserPasskeyNotificationBuilder {
@@ -472,7 +482,6 @@ pub async fn initiate(ctx: &impl Context) -> Result<(), ()> {
    .await;

    if result.is_err() {
        ctx.send_lmp_packet(lmp::NumericComparisonFailedBuilder { transaction_id: 0 }.build());
        ctx.send_hci_event(
            hci::SimplePairingCompleteBuilder {
                status: hci::ErrorCode::AuthenticationFailure,
@@ -653,16 +662,36 @@ pub async fn respond(ctx: &impl Context, request: lmp::IoCapabilityReq) -> Resul
            user_confirmation.is_err()
        }
        AuthenticationMethod::PasskeyEntry => {
            if responder.io_capability == hci::IoCapability::KeyboardOnly {
            let skip_first_commitment = if responder.io_capability
                == hci::IoCapability::KeyboardOnly
            {
                // TODO: handle error
                let _user_passkey = user_passkey_request(ctx).await;
                false
            } else {
                ctx.send_hci_event(
                    hci::UserPasskeyNotificationBuilder { bd_addr: ctx.peer_address(), passkey: 0 }
                        .build(),
                );
                match ctx
                    .receive_lmp_packet::<Either<lmp::SimplePairingConfirm, lmp::PasskeyFailed>>()
                    .await
                {
                    Either::Left(_) => true, // TODO: check for `confirm.get_commitment_value()`
                    Either::Right(_) => {
                        ctx.send_hci_event(
                            hci::SimplePairingCompleteBuilder {
                                status: hci::ErrorCode::AuthenticationFailure,
                                bd_addr: ctx.peer_address(),
                            }
            for _ in 0..PASSKEY_ENTRY_REPEAT_NUMBER {
                            .build(),
                        );
                        return Err(());
                    }
                }
            };
            receive_commitment(ctx, skip_first_commitment).await;
            for _ in 1..PASSKEY_ENTRY_REPEAT_NUMBER {
                receive_commitment(ctx, false).await;
            }
            false
@@ -867,7 +896,6 @@ mod tests {
    }

    #[test]
    #[should_panic] // TODO: make the test pass
    fn passkey_entry_initiator_failure_on_initiating_side() {
        let context = TestContext::new();
        let procedure = initiate;
@@ -876,7 +904,6 @@ mod tests {
    }

    #[test]
    #[should_panic] // TODO: make the test pass
    fn passkey_entry_responder_failure_on_initiating_side() {
        let context = TestContext::new();
        let procedure = respond;