From: Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 1/3] tester: Refactor Read Local Public Key command
Date: Thu, 21 May 2015 10:34:15 +0300 [thread overview]
Message-ID: <20150521073413.GB15271@comms> (raw)
In-Reply-To: <1431942097-21927-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
On Mon, May 18, 2015 at 12:41:35PM +0300, Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
>
> Save Local Public Key to calculate DHKey for later tests. Also verify
> that Command Status and Meta Event are generated.
ping
> ---
> tools/hci-tester.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 59 insertions(+), 2 deletions(-)
>
> diff --git a/tools/hci-tester.c b/tools/hci-tester.c
> index 460c9a9..9093129 100644
> --- a/tools/hci-tester.c
> +++ b/tools/hci-tester.c
> @@ -46,6 +46,11 @@ struct user_data {
> uint16_t handle_ut;
> };
>
> +struct le_keys {
> + uint8_t remote_sk[32];
> + uint8_t local_pk[64];
> +} key_test_data;
> +
> static void swap_buf(const uint8_t *src, uint8_t *dst, uint16_t len)
> {
> int i;
> @@ -412,9 +417,61 @@ static void test_le_rand(const void *test_data)
> test_command(BT_HCI_CMD_LE_RAND);
> }
>
> +static void test_le_read_local_pk_complete(const void *data, uint8_t size,
> + void *user_data)
> +{
> + const uint8_t *event = data;
> + const struct bt_hci_evt_le_read_local_pk256_complete *evt;
> + struct le_keys *keys = user_data;
> +
> + if (*event != BT_HCI_EVT_LE_READ_LOCAL_PK256_COMPLETE) {
> + tester_warn("Failed Read Local PK256 command");
> + tester_test_failed();
> + return;
> + }
> +
> + evt = (void *)(event + 1);
> + if (evt->status) {
> + tester_warn("HCI Read Local PK complete failed (0x%02x)",
> + evt->status);
> + tester_test_failed();
> + return;
> + }
> +
> + memcpy(keys->local_pk, evt->local_pk256, 64);
> +
> + util_hexdump('>', evt->local_pk256, 64, test_debug, NULL);
> +
> + tester_test_passed();
> +}
> +
> +static void test_le_read_local_pk_status(const void *data, uint8_t size,
> + void *user_data)
> +{
> + uint8_t status = *((uint8_t *) data);
> +
> + if (status) {
> + tester_warn("Failed to send DHKey gen cmd (0x%02x)", status);
> + tester_test_failed();
> + return;
> + }
> +}
> +
> static void test_le_read_local_pk(const void *test_data)
> {
> - test_command(BT_HCI_CMD_LE_READ_LOCAL_PK256);
> + struct user_data *user = tester_get_data();
> +
> + bt_hci_register(user->hci_ut, BT_HCI_EVT_LE_META_EVENT,
> + test_le_read_local_pk_complete,
> + (void *)test_data, NULL);
> +
> + if (!bt_hci_send(user->hci_ut, BT_HCI_CMD_LE_READ_LOCAL_PK256, NULL,
> + 0, test_le_read_local_pk_status,
> + NULL, NULL)) {
> + tester_warn("Failed to send HCI LE Read Local PK256 command");
> + tester_test_failed();
> + return;
> + }
> }
>
> static void test_le_generate_dhkey_complete(const void *data, uint8_t size,
> @@ -790,7 +847,7 @@ int main(int argc, char *argv[])
> test_le_encrypt);
> test_hci_local("LE Rand", NULL, NULL,
> test_le_rand);
> - test_hci_local("LE Read Local PK", NULL, NULL,
> + test_hci_local("LE Read Local PK", &key_test_data, NULL,
> test_le_read_local_pk);
> test_hci_local("LE Generate DHKey", NULL, NULL,
> test_le_generate_dhkey);
> --
> 2.1.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-05-21 7:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-18 9:41 [PATCH 1/3] tester: Refactor Read Local Public Key command Andrei Emeltchenko
2015-05-18 9:41 ` [PATCH 2/3] tester: Verify DHKey generation Andrei Emeltchenko
2015-05-18 9:41 ` [PATCH 3/3] btdev: Indicate support for 4.2 encryption commands Andrei Emeltchenko
2015-05-21 7:34 ` Andrei Emeltchenko [this message]
2015-05-22 11:48 ` [PATCH 1/3] tester: Refactor Read Local Public Key command Johan Hedberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150521073413.GB15271@comms \
--to=andrei.emeltchenko.news@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.