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

Commit 458b3de1 authored by David Duarte's avatar David Duarte
Browse files

Add some LMP Secure Simple Pairing failure tests

Bug: 248004609
Test: atest --host liblmp_tests
Change-Id: Ia3e8a8f1e6e0a8d47b2ad2b052599309d5563257
parent cd62e63b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -824,6 +824,7 @@ enum ErrorCode: 8 {
  LINK_LAYER_COLLISION = 0x23,
  ENCRYPTION_MODE_NOT_ACCEPTABLE = 0x25,
  ROLE_SWITCH_FAILED = 0x35,
  HOST_BUSY = 0x38,
  CONTROLLER_BUSY = 0x3A,
  ADVERTISING_TIMEOUT = 0x3C,
  CONNECTION_FAILED_ESTABLISHMENT = 0x3E,
+6 −3
Original line number Diff line number Diff line
@@ -118,9 +118,12 @@ packet NotAccepted : Packet(opcode = NOT_ACCEPTED) {
}

packet AcceptedExt : ExtendedPacket(extended_opcode = ACCEPTED) {
  accepted_opcode: Opcode,
  _fixed_ = 0 : 1,
  accepted_extended_opcode: ExtendedOpcode,
  accepted_opcode: ExtendedOpcode,
}

packet NotAcceptedExt : ExtendedPacket(extended_opcode = NOT_ACCEPTED) {
  not_accepted_opcode: ExtendedOpcode,
  error_code: 8,
}

packet IoCapabilityReq : ExtendedPacket(extended_opcode = IO_CAPABILITY_REQ) {
+27 −0
Original line number Diff line number Diff line
@@ -927,4 +927,31 @@ mod tests {

        include!("../../test/SP/BV-27-C.in");
    }

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

        include!("../../test/SP/BV-30-C.in");
    }

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

        include!("../../test/SP/BV-31-C.in");
    }

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

        include!("../../test/SP/BV-32-C.in");
    }
}
+36 −0
Original line number Diff line number Diff line
sequence! { procedure, context,
    // ACL Connection Established
    Lower Tester -> IUT: IoCapabilityReq {
        transaction_id: 0,
        io_capabilities: 0x01,
        oob_authentication_data: 0x00,
        authentication_requirement: 0x01,
    }
    IUT -> Upper Tester: IoCapabilityResponse {
        bd_addr: context.peer_address(),
        io_capability: IoCapability::DisplayYesNo,
        oob_data_present: OobDataPresent::NotPresent,
        authentication_requirements: AuthenticationRequirements::NoBondingMitmProtection,
    }
    IUT -> Upper Tester: IoCapabilityRequest {
        bd_addr: context.peer_address(),
    }
    Upper Tester -> IUT: IoCapabilityRequestNegativeReply {
        bd_addr: context.peer_address(),
        reason: ErrorCode::PairingNotAllowed,
    }
    IUT -> Upper Tester: IoCapabilityRequestNegativeReplyComplete {
        num_hci_command_packets: 1,
        status: ErrorCode::Success,
        bd_addr: context.peer_address(),
    }
    IUT -> Lower Tester: NotAcceptedExt {
        transaction_id: 0,
        not_accepted_opcode: ExtendedOpcode::IoCapabilityReq,
        error_code: ErrorCode::PairingNotAllowed.to_u8().unwrap(),
    }
    IUT -> Upper Tester: SimplePairingComplete {
        status: ErrorCode::AuthenticationFailure,
        bd_addr: context.peer_address(),
    }
}
+41 −0
Original line number Diff line number Diff line
sequence! { procedure, context,
    // ACL Connection Established
    Upper Tester -> IUT: AuthenticationRequested {
        connection_handle: context.peer_handle()
    }
    IUT -> Upper Tester: AuthenticationRequestedStatus {
       num_hci_command_packets: 1,
       status: ErrorCode::Success,
    }
    IUT -> Upper Tester: LinkKeyRequest {
        bd_addr: context.peer_address(),
    }
    Upper Tester -> IUT: LinkKeyRequestNegativeReply {
        bd_addr: context.peer_address(),
    }
    IUT -> Upper Tester: LinkKeyRequestNegativeReplyComplete {
       num_hci_command_packets: 1,
       status: ErrorCode::Success,
       bd_addr: context.peer_address(),
    }
    IUT -> Upper Tester: IoCapabilityRequest {
        bd_addr: context.peer_address(),
    }
    Upper Tester -> IUT: IoCapabilityRequestNegativeReply {
        bd_addr: context.peer_address(),
        reason: ErrorCode::HostBusy,
    }
    IUT -> Upper Tester: IoCapabilityRequestNegativeReplyComplete {
        num_hci_command_packets: 1,
        status: ErrorCode::Success,
        bd_addr: context.peer_address(),
    }
    IUT -> Upper Tester: SimplePairingComplete {
        status: ErrorCode::AuthenticationFailure,
        bd_addr: context.peer_address(),
    }
    IUT -> Upper Tester: AuthenticationComplete {
        status: ErrorCode::AuthenticationFailure,
        connection_handle: context.peer_handle(),
    }
}
Loading