From: Szymon Janc <szymon.janc@tieto.com>
To: Jakub Tyszkowski <jakub.tyszkowski@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCHv2 1/2] android: Store remote's Identity Resolving Key
Date: Thu, 12 Jun 2014 12:16:12 +0200 [thread overview]
Message-ID: <8994221.GXkAcnXDiz@uw000953> (raw)
In-Reply-To: <1402473614-26767-1-git-send-email-jakub.tyszkowski@tieto.com>
Hi Jakub,
On Wednesday 11 of June 2014 10:00:13 Jakub Tyszkowski wrote:
> Persistent storage is used so we can load IRKs on startup.
> ---
> android/bluetooth.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 59 insertions(+)
>
> diff --git a/android/bluetooth.c b/android/bluetooth.c
> index 36b073e..8638f84 100644
> --- a/android/bluetooth.c
> +++ b/android/bluetooth.c
> @@ -1964,6 +1964,62 @@ static void new_csrk_callback(uint16_t index, uint16_t length,
> store_csrk(dev);
> }
>
> +static void store_irk(struct device *dev, const uint8_t *val)
> +{
> + GKeyFile *key_file;
> + char key_str[33];
> + char addr[18];
> + int i;
> + gsize length = 0;
> + char *data;
> +
> + ba2str(&dev->bdaddr, addr);
> +
> + key_file = g_key_file_new();
> + if (!g_key_file_load_from_file(key_file, DEVICES_FILE, 0, NULL)) {
> + g_key_file_free(key_file);
> + return;
> + }
> +
> + for (i = 0; i < 16; i++)
> + sprintf(key_str + (i * 2), "%2.2X", val[i]);
> +
> + g_key_file_set_string(key_file, addr, "IdentityResolvingKey", key_str);
> +
> + data = g_key_file_to_data(key_file, &length, NULL);
> + g_file_set_contents(DEVICES_FILE, data, length, NULL);
> + g_free(data);
> +
> + g_key_file_free(key_file);
> +}
> +
> +static void new_irk_callback(uint16_t index, uint16_t length,
> + const void *param, void *user_data)
> +{
> + const struct mgmt_ev_new_irk *ev = param;
> + const struct mgmt_addr_info *addr = &ev->key.addr;
> + struct device *dev;
> + char dst[18], rpa[18];
> +
> + if (length < sizeof(*ev)) {
> + error("To small New Irk Event (%u bytes)", length);
> + return;
> + }
> +
> + ba2str(&ev->key.addr.bdaddr, dst);
> + ba2str(&ev->rpa, rpa);
> +
> + DBG("new IRK for %s, RPA %s", dst, rpa);
> +
> + /* TODO: handle new Identity to RPA mapping */
> + dev = find_device(&addr->bdaddr);
> + if (!dev)
> + return;
> +
> + if (ev->store_hint)
> + store_irk(dev, ev->key.val);
> +}
> +
> static void register_mgmt_handlers(void)
> {
> mgmt_register(mgmt_if, MGMT_EV_NEW_SETTINGS, adapter.index,
> @@ -2017,6 +2073,9 @@ static void register_mgmt_handlers(void)
> mgmt_register(mgmt_if, MGMT_EV_NEW_CSRK, adapter.index,
> new_csrk_callback, NULL, NULL);
>
> + mgmt_register(mgmt_if, MGMT_EV_NEW_IRK, adapter.index, new_irk_callback,
> + NULL, NULL);
> +
> }
>
> static void load_link_keys_complete(uint8_t status, uint16_t length,
>
Both patches applied, thanks.
--
Best regards,
Szymon Janc
prev parent reply other threads:[~2014-06-12 10:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-11 8:00 [PATCHv2 1/2] android: Store remote's Identity Resolving Key Jakub Tyszkowski
2014-06-11 8:00 ` [PATCHv2 2/2] android: Load Identity Resolving Keys Jakub Tyszkowski
2014-06-12 10:16 ` Szymon Janc [this message]
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=8994221.GXkAcnXDiz@uw000953 \
--to=szymon.janc@tieto.com \
--cc=jakub.tyszkowski@tieto.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox