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

Commit 44df5ed6 authored by David Duarte's avatar David Duarte Committed by Henri Chataing
Browse files

Add some LMP Secure Simple Pairing Passkey Entry Notification tests

Bug: 248004609
Test: atest --host liblmp_tests
Bug: 245578454
Ignore-AOSP-First: cherry-pick from AOSP
Merged-In: I9d2f6600664df23ee2da9ef28a09d349a0df175b
Change-Id: I9d2f6600664df23ee2da9ef28a09d349a0df175b
(cherry picked from commit b0edda7b)
parent c8b8d15e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -172,6 +172,10 @@ packet NumericComparaisonFailed: ExtendedPacket(extended_opcode = NUMERIC_COMPAR

packet PasskeyFailed: ExtendedPacket(extended_opcode = PASSKEY_FAILED) {}

packet KeypressNotification: ExtendedPacket(extended_opcode = KEYPRESS_NOTIFICATION) {
  notification_type: 8,
}

packet InRand : Packet(opcode = IN_RAND) {
  random_number: 8[16],
}
+36 −0
Original line number Diff line number Diff line
@@ -954,4 +954,40 @@ mod tests {

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

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

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

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

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

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

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

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

        include!("../../test/SP/BV-36-C.in");
    }
}
+200 −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: IoCapabilityRequestReply {
        bd_addr: context.peer_address(),
        io_capability: IoCapability::KeyboardOnly,
        oob_present: OobDataPresent::NotPresent,
        authentication_requirements: AuthenticationRequirements::NoBondingMitmProtection,
    }
    IUT -> Upper Tester: IoCapabilityRequestReplyComplete {
        num_hci_command_packets: 1,
        status: ErrorCode::Success,
        bd_addr: context.peer_address(),
    }
    IUT -> Lower Tester: IoCapabilityReq {
        transaction_id: 0,
        io_capabilities: 0x02,
        oob_authentication_data: 0x00,
        authentication_requirement: 0x01,
    }
    Lower Tester -> IUT: IoCapabilityRes {
        transaction_id: 0,
        io_capabilities: 0x00,
        oob_authentication_data: 0x00,
        authentication_requirement: 0x01,
    }
    IUT -> Upper Tester: IoCapabilityResponse {
        bd_addr: context.peer_address(),
        io_capability: IoCapability::DisplayOnly,
        oob_data_present: OobDataPresent::NotPresent,
        authentication_requirements: AuthenticationRequirements::NoBondingMitmProtection,
    }
    // Public Key Exchange
    IUT -> Lower Tester: EncapsulatedHeader {
        transaction_id: 0,
        major_type: 1,
        minor_type: 1,
        payload_length: 48,
    }
    Lower Tester -> IUT: Accepted {
        transaction_id: 0,
        accepted_opcode: Opcode::EncapsulatedHeader,
    }
    repeat 3 times with (part in local_p192_public_key(&context)) {
        IUT -> Lower Tester: EncapsulatedPayload {
            transaction_id: 0,
            data: part,
        }
        Lower Tester -> IUT: Accepted {
            transaction_id: 0,
            accepted_opcode: Opcode::EncapsulatedPayload,
        }
    }
    Lower Tester -> IUT: EncapsulatedHeader {
        transaction_id: 0,
        major_type: 1,
        minor_type: 1,
        payload_length: 48,
    }
    IUT -> Lower Tester: Accepted {
        transaction_id: 0,
        accepted_opcode: Opcode::EncapsulatedHeader,
    }
    repeat 3 times with (part in peer_p192_public_key()) {
        Lower Tester -> IUT: EncapsulatedPayload {
            transaction_id: 0,
            data: part,
        }
        IUT -> Lower Tester: Accepted {
            transaction_id: 0,
            accepted_opcode: Opcode::EncapsulatedPayload,
        }
    }
    // Authentication Stage 1: Passkey Entry Protocol
    IUT -> Upper Tester: UserPasskeyRequest {
        bd_addr: context.peer_address(),
    }
    Upper Tester -> IUT: SendKeypressNotification {
        bd_addr: context.peer_address(),
        notification_type: KeypressNotificationType::EntryStarted,
    }
    IUT -> Lower Tester: KeypressNotification {
        transaction_id: 0,
        notification_type: 0x00,
    }
    IUT -> Upper Tester: SendKeypressNotificationComplete {
        num_hci_command_packets: 1,
        status: ErrorCode::Success,
        bd_addr: context.peer_address(),
    }
    Upper Tester -> IUT: SendKeypressNotification {
        bd_addr: context.peer_address(),
        notification_type: KeypressNotificationType::EntryCompleted,
    }
    IUT -> Lower Tester: KeypressNotification {
        transaction_id: 0,
        notification_type: 0x04,
    }
    IUT -> Upper Tester: SendKeypressNotificationComplete {
        num_hci_command_packets: 1,
        status: ErrorCode::Success,
        bd_addr: context.peer_address(),
    }
    Upper Tester -> IUT: UserPasskeyRequestReply {
        bd_addr: context.peer_address(),
        numeric_value: 0,
    }
    IUT -> Upper Tester: UserPasskeyRequestReplyComplete {
        num_hci_command_packets: 1,
        status: ErrorCode::Success,
        bd_addr: context.peer_address(),
    }
    repeat 20 times {
        IUT -> Lower Tester: SimplePairingConfirm {
            transaction_id: 0,
            commitment_value: [0; 16],
        }
        Lower Tester -> IUT: SimplePairingConfirm {
            transaction_id: 0,
            commitment_value: [0; 16],
        }
        IUT -> Lower Tester: SimplePairingNumber {
            transaction_id: 0,
            nonce: [0; 16],
        }
        Lower Tester -> IUT: Accepted {
            transaction_id: 0,
            accepted_opcode: Opcode::SimplePairingNumber,
        }
        Lower Tester -> IUT: SimplePairingNumber {
            transaction_id: 0,
            nonce: [0; 16],
        }
        IUT -> Lower Tester: Accepted {
            transaction_id: 0,
            accepted_opcode: Opcode::SimplePairingNumber,
        }
    }
    // Authentication Stage 2
    IUT -> Lower Tester: DhkeyCheck {
        transaction_id: 0,
        confirmation_value: [0; 16],
    }
    Lower Tester -> IUT: Accepted { transaction_id: 0, accepted_opcode: Opcode::DhkeyCheck }
    Lower Tester -> IUT: DhkeyCheck {
        transaction_id: 0,
        confirmation_value: [0; 16],
    }
    IUT -> Lower Tester: Accepted { transaction_id: 0, accepted_opcode: Opcode::DhkeyCheck }
    IUT -> Upper Tester: SimplePairingComplete {
        status: ErrorCode::Success,
        bd_addr: context.peer_address(),
    }
    // Link Key Calculation
    IUT -> Lower Tester: AuRand {
        transaction_id: 0,
        random_number: [0; 16],
    }
    Lower Tester -> IUT: Sres {
        transaction_id: 0,
        authentication_rsp: [0; 4],
    }
    Lower Tester -> IUT: AuRand {
        transaction_id: 0,
        random_number: [0; 16],
    }
    IUT -> Lower Tester: Sres {
        transaction_id: 0,
        authentication_rsp: [0; 4],
    }
    IUT -> Upper Tester: LinkKeyNotification {
        bd_addr: context.peer_address(),
        key_type: KeyType::AuthenticatedP192,
        link_key: [0; 16],
    }
    IUT -> Upper Tester: AuthenticationComplete {
        status: ErrorCode::Success,
        connection_handle: context.peer_handle(),
    }
}
+157 −0
Original line number Diff line number Diff line
sequence! { procedure, context,
    // ACL Connection Established
    Lower Tester -> IUT: IoCapabilityReq {
        transaction_id: 0,
        io_capabilities: 0x02,
        oob_authentication_data: 0x00,
        authentication_requirement: 0x01,
    }
    IUT -> Upper Tester: IoCapabilityResponse {
        bd_addr: context.peer_address(),
        io_capability: IoCapability::KeyboardOnly,
        oob_data_present: OobDataPresent::NotPresent,
        authentication_requirements: AuthenticationRequirements::NoBondingMitmProtection,
    }
    IUT -> Upper Tester: IoCapabilityRequest {
        bd_addr: context.peer_address(),
    }
    Upper Tester -> IUT: IoCapabilityRequestReply {
        bd_addr: context.peer_address(),
        io_capability: IoCapability::DisplayOnly,
        oob_present: OobDataPresent::NotPresent,
        authentication_requirements: AuthenticationRequirements::NoBondingMitmProtection,
    }
    IUT -> Upper Tester: IoCapabilityRequestReplyComplete {
        num_hci_command_packets: 1,
        status: ErrorCode::Success,
        bd_addr: context.peer_address(),
    }
    IUT -> Lower Tester: IoCapabilityRes {
        transaction_id: 0,
        io_capabilities: 0x00,
        oob_authentication_data: 0x00,
        authentication_requirement: 0x01,
    }
    // Public Key Exchange
    Lower Tester -> IUT: EncapsulatedHeader {
        transaction_id: 0,
        major_type: 1,
        minor_type: 1,
        payload_length: 48,
    }
    IUT -> Lower Tester: Accepted {
        transaction_id: 0,
        accepted_opcode: Opcode::EncapsulatedHeader,
    }
    repeat 3 times with (part in peer_p192_public_key()) {
        Lower Tester -> IUT: EncapsulatedPayload {
            transaction_id: 0,
            data: part,
        }
        IUT -> Lower Tester: Accepted {
            transaction_id: 0,
            accepted_opcode: Opcode::EncapsulatedPayload,
        }
    }
    IUT -> Lower Tester: EncapsulatedHeader {
        transaction_id: 0,
        major_type: 1,
        minor_type: 1,
        payload_length: 48,
    }
    Lower Tester -> IUT: Accepted {
        transaction_id: 0,
        accepted_opcode: Opcode::EncapsulatedHeader,
    }
    repeat 3 times with (part in local_p192_public_key(&context)) {
        IUT -> Lower Tester: EncapsulatedPayload {
            transaction_id: 0,
            data: part,
        }
        Lower Tester -> IUT: Accepted {
            transaction_id: 0,
            accepted_opcode: Opcode::EncapsulatedPayload,
        }
    }
    // Authentication Stage 1: Passkey Entry Protocol
    IUT -> Upper Tester: UserPasskeyNotification { bd_addr: context.peer_address(), passkey: 0 }
    Lower Tester -> IUT: KeypressNotification {
        transaction_id: 0,
        notification_type: 0x00,
    }
    IUT -> Upper Tester: KeypressNotification {
         bd_addr: context.peer_address(),
         notification_type: KeypressNotificationType::EntryStarted,
    }
    Lower Tester -> IUT: KeypressNotification {
        transaction_id: 0,
        notification_type: 0x04,
    }
    IUT -> Upper Tester: KeypressNotification {
         bd_addr: context.peer_address(),
         notification_type: KeypressNotificationType::EntryCompleted,
    }
    repeat 20 times {
        Lower Tester -> IUT: SimplePairingConfirm {
            transaction_id: 0,
            commitment_value: [0; 16],
        }
        IUT -> Lower Tester: SimplePairingConfirm {
            transaction_id: 0,
            commitment_value: [0; 16],
        }
        Lower Tester -> IUT: SimplePairingNumber {
            transaction_id: 0,
            nonce: [0; 16],
        }
        IUT -> Lower Tester: Accepted {
            transaction_id: 0,
            accepted_opcode: Opcode::SimplePairingNumber,
        }
        IUT -> Lower Tester: SimplePairingNumber {
            transaction_id: 0,
            nonce: [0; 16],
        }
        Lower Tester -> IUT: Accepted {
            transaction_id: 0,
            accepted_opcode: Opcode::SimplePairingNumber,
        }
    }
    // Authentication Stage 2
    Lower Tester -> IUT: DhkeyCheck {
        transaction_id: 0,
        confirmation_value: [0; 16],
    }
    IUT -> Lower Tester: Accepted { transaction_id: 0, accepted_opcode: Opcode::DhkeyCheck }
    IUT -> Lower Tester: DhkeyCheck {
        transaction_id: 0,
        confirmation_value: [0; 16],
    }
    Lower Tester -> IUT: Accepted { transaction_id: 0, accepted_opcode: Opcode::DhkeyCheck }
    IUT -> Upper Tester: SimplePairingComplete {
        status: ErrorCode::Success,
        bd_addr: context.peer_address(),
    }
    // Link Key Calculation
    Lower Tester -> IUT: AuRand {
        transaction_id: 0,
        random_number: [0; 16],
    }
    IUT -> Lower Tester: Sres {
        transaction_id: 0,
        authentication_rsp: [0; 4],
    }
    IUT -> Lower Tester: AuRand {
        transaction_id: 0,
        random_number: [0; 16],
    }
    Lower Tester -> IUT: Sres {
        transaction_id: 0,
        authentication_rsp: [0; 4],
    }
    IUT -> Upper Tester: LinkKeyNotification {
        bd_addr: context.peer_address(),
        key_type: KeyType::AuthenticatedP192,
        link_key: [0; 16],
    }
}
+158 −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: IoCapabilityRequestReply {
        bd_addr: context.peer_address(),
        io_capability: IoCapability::KeyboardOnly,
        oob_present: OobDataPresent::NotPresent,
        authentication_requirements: AuthenticationRequirements::NoBondingMitmProtection,
    }
    IUT -> Upper Tester: IoCapabilityRequestReplyComplete {
        num_hci_command_packets: 1,
        status: ErrorCode::Success,
        bd_addr: context.peer_address(),
    }
    IUT -> Lower Tester: IoCapabilityReq {
        transaction_id: 0,
        io_capabilities: 0x02,
        oob_authentication_data: 0x00,
        authentication_requirement: 0x01,
    }
    Lower Tester -> IUT: IoCapabilityRes {
        transaction_id: 0,
        io_capabilities: 0x00,
        oob_authentication_data: 0x00,
        authentication_requirement: 0x01,
    }
    IUT -> Upper Tester: IoCapabilityResponse {
        bd_addr: context.peer_address(),
        io_capability: IoCapability::DisplayOnly,
        oob_data_present: OobDataPresent::NotPresent,
        authentication_requirements: AuthenticationRequirements::NoBondingMitmProtection,
    }
    // Public Key Exchange
    IUT -> Lower Tester: EncapsulatedHeader {
        transaction_id: 0,
        major_type: 1,
        minor_type: 1,
        payload_length: 48,
    }
    Lower Tester -> IUT: Accepted {
        transaction_id: 0,
        accepted_opcode: Opcode::EncapsulatedHeader,
    }
    repeat 3 times with (part in local_p192_public_key(&context)) {
        IUT -> Lower Tester: EncapsulatedPayload {
            transaction_id: 0,
            data: part,
        }
        Lower Tester -> IUT: Accepted {
            transaction_id: 0,
            accepted_opcode: Opcode::EncapsulatedPayload,
        }
    }
    Lower Tester -> IUT: EncapsulatedHeader {
        transaction_id: 0,
        major_type: 1,
        minor_type: 1,
        payload_length: 48,
    }
    IUT -> Lower Tester: Accepted {
        transaction_id: 0,
        accepted_opcode: Opcode::EncapsulatedHeader,
    }
    repeat 3 times with (part in peer_p192_public_key()) {
        Lower Tester -> IUT: EncapsulatedPayload {
            transaction_id: 0,
            data: part,
        }
        IUT -> Lower Tester: Accepted {
            transaction_id: 0,
            accepted_opcode: Opcode::EncapsulatedPayload,
        }
    }
    // Authentication Stage 1: Passkey Entry Protocol
    IUT -> Upper Tester: UserPasskeyRequest {
        bd_addr: context.peer_address(),
    }
    Upper Tester -> IUT: SendKeypressNotification {
        bd_addr: context.peer_address(),
        notification_type: KeypressNotificationType::EntryStarted,
    }
    IUT -> Lower Tester: KeypressNotification {
        transaction_id: 0,
        notification_type: 0x00,
    }
    IUT -> Upper Tester: SendKeypressNotificationComplete {
        num_hci_command_packets: 1,
        status: ErrorCode::Success,
        bd_addr: context.peer_address(),
    }
    Upper Tester -> IUT: SendKeypressNotification {
        bd_addr: context.peer_address(),
        notification_type: KeypressNotificationType::EntryCompleted,
    }
    IUT -> Lower Tester: KeypressNotification {
        transaction_id: 0,
        notification_type: 0x04,
    }
    IUT -> Upper Tester: SendKeypressNotificationComplete {
        num_hci_command_packets: 1,
        status: ErrorCode::Success,
        bd_addr: context.peer_address(),
    }
    Upper Tester -> IUT: UserPasskeyRequestReply {
        bd_addr: context.peer_address(),
        numeric_value: 0,
    }
    IUT -> Upper Tester: UserPasskeyRequestReplyComplete {
        num_hci_command_packets: 1,
        status: ErrorCode::Success,
        bd_addr: context.peer_address(),
    }
    IUT -> Lower Tester: SimplePairingConfirm {
        transaction_id: 0,
        commitment_value: [0; 16],
    }
    Lower Tester -> IUT: SimplePairingConfirm {
        transaction_id: 0,
        commitment_value: [0; 16],
    }
    IUT -> Lower Tester: SimplePairingNumber {
        transaction_id: 0,
        nonce: [0; 16],
    }
    Lower Tester -> IUT: NotAccepted {
        transaction_id: 0,
        not_accepted_opcode: Opcode::SimplePairingNumber,
        error_code: ErrorCode::AuthenticationFailure.to_u8().unwrap(),
    }
    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