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

Commit d8ea3c08 authored by David Duarte's avatar David Duarte
Browse files

RootCanal: Add basic LMP encryption tests

Bug: 248004609
Test: atest --host liblmp_tests
Change-Id: I7761a31b2e328f62c0949455c92f4c034aab5c32
parent 2f133d32
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -81,3 +81,27 @@ pub async fn respond(ctx: &impl Context) {
        .build(),
    );
}

#[cfg(test)]
mod tests {
    use super::initiate;
    use super::respond;
    use crate::procedure::Context;
    use crate::test::{sequence, TestContext};

    #[test]
    fn accept_encryption() {
        let context = TestContext::new();
        let procedure = respond;

        include!("../../test/ENC/BV-01-C.in");
    }

    #[test]
    fn initiate_encryption() {
        let context = TestContext::new();
        let procedure = initiate;

        include!("../../test/ENC/BV-05-C.in");
    }
}
+32 −0
Original line number Diff line number Diff line
sequence! { procedure, context,
    // ACL Connection Established
    Lower Tester -> IUT: EncryptionModeReq {
        transaction_id: 0,
        encryption_mode: 0x01,
    }
    IUT ->Lower Tester: Accepted {
        transaction_id: 0,
        accepted_opcode: Opcode::EncryptionModeReq,
    }
    Lower Tester -> IUT: EncryptionKeySizeReq {
        transaction_id: 0,
        key_size: 0x10,
    }
    IUT -> Lower Tester: Accepted {
        transaction_id: 0,
        accepted_opcode: Opcode::EncryptionKeySizeReq,
    }
    Lower Tester -> IUT: StartEncryptionReq {
        transaction_id: 0,
        random_number: [0; 16],
    }
    IUT -> Lower Tester: Accepted {
        transaction_id: 0,
        accepted_opcode: Opcode::StartEncryptionReq,
    }
    IUT -> Upper Tester: EncryptionChange {
        status: ErrorCode::Success,
        connection_handle: context.peer_handle(),
        encryption_enabled: EncryptionEnabled::On,
    }
}
+40 −0
Original line number Diff line number Diff line
sequence! { procedure, context,
    // ACL Connection Established
    Upper Tester -> IUT: SetConnectionEncryption {
        connection_handle: context.peer_handle(),
        encryption_enable: Enable::Enabled
    }
    IUT -> Upper Tester: SetConnectionEncryptionStatus {
       num_hci_command_packets: 1,
       status: ErrorCode::Success,
    }
    IUT -> Lower Tester: EncryptionModeReq {
        transaction_id: 0,
        encryption_mode: 0x01,
    }
    Lower Tester -> IUT: Accepted {
        transaction_id: 0,
        accepted_opcode: Opcode::EncryptionModeReq,
    }
    IUT -> Lower Tester: EncryptionKeySizeReq {
        transaction_id: 0,
        key_size: 0x10,
    }
    Lower Tester -> IUT: Accepted {
        transaction_id: 0,
        accepted_opcode: Opcode::EncryptionKeySizeReq,
    }
    IUT -> Lower Tester: StartEncryptionReq {
        transaction_id: 0,
        random_number: [0; 16],
    }
    Lower Tester -> IUT: Accepted {
        transaction_id: 0,
        accepted_opcode: Opcode::StartEncryptionReq,
    }
    IUT -> Upper Tester: EncryptionChange {
        status: ErrorCode::Success,
        connection_handle: context.peer_handle(),
        encryption_enabled: EncryptionEnabled::On,
    }
}