From 84c1e8f49696cb7f7ed52c1e9c51cb173290e6b1 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Fri, 18 Jan 2013 14:05:41 +0200 Subject: [PATCH] tools: Add more mgmt_load_ltks invalid params tests --- tools/mgmt-tester.c | 70 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c index fb9443ff7..4233a22d1 100644 --- a/tools/mgmt-tester.c +++ b/tools/mgmt-tester.c @@ -950,7 +950,47 @@ static const struct generic_data load_link_keys_invalid_params_test_2 = { }; static const char load_ltks_valid_param_1[] = { 0x00, 0x00 }; +/* Invalid key count */ static const char load_ltks_invalid_param_1[] = { 0x01, 0x00 }; +/* Invalid addr type */ +static const char load_ltks_invalid_param_2[] = { + 0x01, 0x00, /* count */ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, /* bdaddr */ + 0x00, /* addr type */ + 0x00, /* authenticated */ + 0x00, /* master */ + 0x00, /* encryption size */ + 0x00, 0x00, /* diversifier */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* rand */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* value (1/2) */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* value (2/2 */ +}; +/* Invalid authenticated value */ +static const char load_ltks_invalid_param_3[] = { + 0x01, 0x00, /* count */ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, /* bdaddr */ + 0x01, /* addr type */ + 0x02, /* authenticated */ + 0x00, /* master */ + 0x00, /* encryption size */ + 0x00, 0x00, /* diversifier */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* rand */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* value (1/2) */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* value (2/2 */ +}; +/* Invalid master value */ +static const char load_ltks_invalid_param_4[] = { + 0x01, 0x00, /* count */ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, /* bdaddr */ + 0x01, /* addr type */ + 0x00, /* authunticated */ + 0x02, /* master */ + 0x00, /* encryption size */ + 0x00, 0x00, /* diversifier */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* rand */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* value (1/2) */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* value (2/2 */ +}; static const struct generic_data load_ltks_success_test_1 = { .send_opcode = MGMT_OP_LOAD_LONG_TERM_KEYS, @@ -966,6 +1006,27 @@ static const struct generic_data load_ltks_invalid_params_test_1 = { .expect_status = MGMT_STATUS_INVALID_PARAMS, }; +static const struct generic_data load_ltks_invalid_params_test_2 = { + .send_opcode = MGMT_OP_LOAD_LONG_TERM_KEYS, + .send_param = load_ltks_invalid_param_2, + .send_len = sizeof(load_ltks_invalid_param_2), + .expect_status = MGMT_STATUS_INVALID_PARAMS, +}; + +static const struct generic_data load_ltks_invalid_params_test_3 = { + .send_opcode = MGMT_OP_LOAD_LONG_TERM_KEYS, + .send_param = load_ltks_invalid_param_3, + .send_len = sizeof(load_ltks_invalid_param_3), + .expect_status = MGMT_STATUS_INVALID_PARAMS, +}; + +static const struct generic_data load_ltks_invalid_params_test_4 = { + .send_opcode = MGMT_OP_LOAD_LONG_TERM_KEYS, + .send_param = load_ltks_invalid_param_4, + .send_len = sizeof(load_ltks_invalid_param_4), + .expect_status = MGMT_STATUS_INVALID_PARAMS, +}; + static void powered_delay(void *user_data) { tester_setup_complete(); @@ -1489,6 +1550,15 @@ int main(int argc, char *argv[]) test_bredr("Load Long Term Keys - Invalid Parameters 1", &load_ltks_invalid_params_test_1, NULL, test_command_generic); + test_bredr("Load Long Term Keys - Invalid Parameters 2", + &load_ltks_invalid_params_test_2, NULL, + test_command_generic); + test_bredr("Load Long Term Keys - Invalid Parameters 3", + &load_ltks_invalid_params_test_3, NULL, + test_command_generic); + test_bredr("Load Long Term Keys - Invalid Parameters 4", + &load_ltks_invalid_params_test_4, NULL, + test_command_generic); return tester_run(); } -- 2.47.3